Message ID | e6dfbe4afd3f1db4c3f8a81c0813dc418896f5e1.1505916622.git.dave.stevenson@raspberrypi.org (mailing list archive) |
---|---|
State | Obsoleted, archived |
Delegated to: | Hans Verkuil |
Headers |
Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from <linux-media-owner@vger.kernel.org>) id 1duhYI-0002tc-EZ; Wed, 20 Sep 2017 16:08:42 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751622AbdITQIk (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Wed, 20 Sep 2017 12:08:40 -0400 Received: from mx08-00252a01.pphosted.com ([91.207.212.211]:41804 "EHLO mx08-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751636AbdITQIj (ORCPT <rfc822;linux-media@vger.kernel.org>); Wed, 20 Sep 2017 12:08:39 -0400 Received: from pps.filterd (m0102629.ppops.net [127.0.0.1]) by mx08-00252a01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8KG8Wh2006768 for <linux-media@vger.kernel.org>; Wed, 20 Sep 2017 17:08:38 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=pp; bh=8smpbEM1sSfxrfWT9XDANmU3oPC/xrZKDEqPBjYlQic=; b=k1CgwRykl5HqZbGPNmglKnlntBVSACGeac5HShm5BvWiDAfp9pa4pB5bDUH+a6zDgdjL ek8qBLCCp+usYyMDtUv5CYtEFjPVkowUr3ofJ/i5/0sGUqzSPl6OCNZkg+Z8EOldcDUJ JG32gXUgTD/BvK5usVhna1+cxdHIwf9CVFyDOMvWPyli2WiT1kswL8GLyYFOvuAz+M0T VfIAqxD5N024ve4Mju9eYo4cS7G69IDvm5LbhPImCvkkfwhkYJxUFbU7zAccse7PsMHb wxB5K1pgfJVU9Pr8B4dMBEhS6mjfWWnp4u0oiMB9R9RisP4+n3wftJmT4UslFYwq8BIC SA== Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by mx08-00252a01.pphosted.com with ESMTP id 2d0reg260j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for <linux-media@vger.kernel.org>; Wed, 20 Sep 2017 17:08:37 +0100 Received: by mail-wm0-f72.google.com with SMTP id e64so3293054wmi.0 for <linux-media@vger.kernel.org>; Wed, 20 Sep 2017 09:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8smpbEM1sSfxrfWT9XDANmU3oPC/xrZKDEqPBjYlQic=; b=iFJXBmWWa51pTJzJGmePAslkGx/QIGCcG5diSOEQh39HGjZCzN3YPGp05+LPEeITNN glcxdhRbc0vX/aoYOHhX/ryqclg92HoWgJ3MCXolKHDfVMuk1O88O8WhU24/M9nMn5je eofbacV9wsyKKXKCABaCg2fLayDJCDxYS8otnMudcb/7XpXmkDbQFki5ykSi99Kb1C1m P4bZSx4KnPeHuTUK3PP0TtOF9H43FNGdJIHIpX5W3rkqCTCs6ylJOvYEbyMejfzfU2ic oInROyA/8rDtDiOZXkfRMwWes9F/RcWAADkVNdtFFLJdnQtnNN71tg7liE4GhcgtVsyd dMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8smpbEM1sSfxrfWT9XDANmU3oPC/xrZKDEqPBjYlQic=; b=gm6b70Nvm247iK6DcHOcE76dgWFRnbhGaPGexd8thgRm+osxhpOxPcQBJDyliug5eD AyyFDuQzjWTn/4o8KsHt2Q/ZkOHnaACVDA8TR9K3gq6/+XmtRkAndFO3pxnScqKsxlRH XsfZfc/qTvHqt6bPji2i72zzWy91NAnCRU7bTI55dTUnEP9kHeTwwQ6kxlPNcac8oiyq NfJiEIDAKTVthasbz4QliBIJsnnAwLFxLc8n1oWmdMgFo4wdlrxGE6PW0a3N9Lr314bx WVakLNH3wKMm7FbeZsxWLKe18v+rcgoctqaCux7JTQ/RXp47IP3KGlR789SK1S5STqXd sU7A== X-Gm-Message-State: AHPjjUgHPqEfsIkI0LooMNLuJgTqMbAsXRDqw/COyAOsLrnCfRZMDHcA QCJkySuC7H8OuQaXyvnjKCaENi/ZL7sxh+3BGsHpTrfd6pedIsppyziHxoc0dWOhAcXj4fXDLfq UMuU8iF0rScobOoF6iL5vfQ== X-Received: by 10.28.150.16 with SMTP id y16mr4564239wmd.94.1505923717442; Wed, 20 Sep 2017 09:08:37 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB/tErHxHTFB7QFx6ieFKoWOP+1bcy92EbUsw1qbrowJO2fz2Qe5XHeLn6jBHYxPk52KYphYg== X-Received: by 10.28.150.16 with SMTP id y16mr4564224wmd.94.1505923717218; Wed, 20 Sep 2017 09:08:37 -0700 (PDT) Received: from dave-VirtualBox.pitowers.org ([217.33.127.173]) by smtp.googlemail.com with ESMTPSA id p15sm1937467wmi.2.2017.09.20.09.08.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 09:08:36 -0700 (PDT) From: Dave Stevenson <dave.stevenson@raspberrypi.org> To: Mauro Carvalho Chehab <mchehab@kernel.org>, Rob Herring <robh+dt@kernel.org>, Hans Verkuil <hans.verkuil@cisco.com>, Eric Anholt <eric@anholt.net>, Stefan Wahren <stefan.wahren@i2se.com>, Sakari Ailus <sakari.ailus@iki.fi>, linux-media@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, devicetree@vger.kernel.org Cc: Dave Stevenson <dave.stevenson@raspberrypi.org> Subject: [PATCH v3 1/4] [media] v4l2-common: Add helper function for fourcc to string Date: Wed, 20 Sep 2017 17:07:54 +0100 Message-Id: <e6dfbe4afd3f1db4c3f8a81c0813dc418896f5e1.1505916622.git.dave.stevenson@raspberrypi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <cover.1505916622.git.dave.stevenson@raspberrypi.org> References: <cover.1505916622.git.dave.stevenson@raspberrypi.org> In-Reply-To: <cover.1505916622.git.dave.stevenson@raspberrypi.org> References: <cover.1505916622.git.dave.stevenson@raspberrypi.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-20_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709200217 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org |
Commit Message
Dave Stevenson
Sept. 20, 2017, 4:07 p.m. UTC
New helper function char *v4l2_fourcc2s(u32 fourcc, char *buf)
that converts a fourcc into a nice printable version.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
No changes from v2 to v3
drivers/media/v4l2-core/v4l2-common.c | 18 ++++++++++++++++++
include/media/v4l2-common.h | 3 +++
2 files changed, 21 insertions(+)
Comments
Hi Dave, On Wed, Sep 20, 2017 at 05:07:54PM +0100, Dave Stevenson wrote: > New helper function char *v4l2_fourcc2s(u32 fourcc, char *buf) > that converts a fourcc into a nice printable version. > > Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> > --- > > No changes from v2 to v3 > > drivers/media/v4l2-core/v4l2-common.c | 18 ++++++++++++++++++ > include/media/v4l2-common.h | 3 +++ > 2 files changed, 21 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c > index a5ea1f5..0219895 100644 > --- a/drivers/media/v4l2-core/v4l2-common.c > +++ b/drivers/media/v4l2-core/v4l2-common.c > @@ -405,3 +405,21 @@ void v4l2_get_timestamp(struct timeval *tv) > tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; > } > EXPORT_SYMBOL_GPL(v4l2_get_timestamp); > + > +char *v4l2_fourcc2s(u32 fourcc, char *buf) > +{ > + buf[0] = fourcc & 0x7f; > + buf[1] = (fourcc >> 8) & 0x7f; > + buf[2] = (fourcc >> 16) & 0x7f; > + buf[3] = (fourcc >> 24) & 0x7f; > + if (fourcc & (1 << 31)) { > + buf[4] = '-'; > + buf[5] = 'B'; > + buf[6] = 'E'; > + buf[7] = '\0'; > + } else { > + buf[4] = '\0'; > + } > + return buf; > +} > +EXPORT_SYMBOL_GPL(v4l2_fourcc2s); > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h > index aac8b7b..5b0fff9 100644 > --- a/include/media/v4l2-common.h > +++ b/include/media/v4l2-common.h > @@ -264,4 +264,7 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( > > void v4l2_get_timestamp(struct timeval *tv); > > +#define V4L2_FOURCC_MAX_SIZE 8 > +char *v4l2_fourcc2s(u32 fourcc, char *buf); > + > #endif /* V4L2_COMMON_H_ */ I like the idea but the use of a character pointer and assuming a length looks a bit scary. As this seems to be used uniquely for printing stuff, a couple of macros could be used instead. Something like #define V4L2_FOURCC_CONV "%c%c%c%c%s" #define V4L2_FOURCC_TO_CONV(fourcc) \ fourcc & 0x7f, (fourcc >> 8) & 0x7f, (fourcc >> 16) & 0x7f, \ (fourcc >> 24) & 0x7f, fourcc & BIT(31) ? "-BE" : "" You could use it with printk-style functions, e.g. printk("blah fourcc " V4L2_FOURCC_CONV " is a nice format", V4L2_FOURCC_TO_CONV(fourcc)); I guess it'd be better to add more parentheses around "fourcc" but it'd be less clear here that way.
Hi Sakari. On 13 October 2017 at 22:09, Sakari Ailus <sakari.ailus@iki.fi> wrote: > Hi Dave, > > On Wed, Sep 20, 2017 at 05:07:54PM +0100, Dave Stevenson wrote: >> New helper function char *v4l2_fourcc2s(u32 fourcc, char *buf) >> that converts a fourcc into a nice printable version. >> >> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> >> --- >> >> No changes from v2 to v3 >> >> drivers/media/v4l2-core/v4l2-common.c | 18 ++++++++++++++++++ >> include/media/v4l2-common.h | 3 +++ >> 2 files changed, 21 insertions(+) >> >> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c >> index a5ea1f5..0219895 100644 >> --- a/drivers/media/v4l2-core/v4l2-common.c >> +++ b/drivers/media/v4l2-core/v4l2-common.c >> @@ -405,3 +405,21 @@ void v4l2_get_timestamp(struct timeval *tv) >> tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; >> } >> EXPORT_SYMBOL_GPL(v4l2_get_timestamp); >> + >> +char *v4l2_fourcc2s(u32 fourcc, char *buf) >> +{ >> + buf[0] = fourcc & 0x7f; >> + buf[1] = (fourcc >> 8) & 0x7f; >> + buf[2] = (fourcc >> 16) & 0x7f; >> + buf[3] = (fourcc >> 24) & 0x7f; >> + if (fourcc & (1 << 31)) { >> + buf[4] = '-'; >> + buf[5] = 'B'; >> + buf[6] = 'E'; >> + buf[7] = '\0'; >> + } else { >> + buf[4] = '\0'; >> + } >> + return buf; >> +} >> +EXPORT_SYMBOL_GPL(v4l2_fourcc2s); >> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h >> index aac8b7b..5b0fff9 100644 >> --- a/include/media/v4l2-common.h >> +++ b/include/media/v4l2-common.h >> @@ -264,4 +264,7 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( >> >> void v4l2_get_timestamp(struct timeval *tv); >> >> +#define V4L2_FOURCC_MAX_SIZE 8 >> +char *v4l2_fourcc2s(u32 fourcc, char *buf); >> + >> #endif /* V4L2_COMMON_H_ */ > > I like the idea but the use of a character pointer and assuming a length > looks a bit scary. > > As this seems to be used uniquely for printing stuff, a couple of macros > could be used instead. Something like > > #define V4L2_FOURCC_CONV "%c%c%c%c%s" > #define V4L2_FOURCC_TO_CONV(fourcc) \ > fourcc & 0x7f, (fourcc >> 8) & 0x7f, (fourcc >> 16) & 0x7f, \ > (fourcc >> 24) & 0x7f, fourcc & BIT(31) ? "-BE" : "" > > You could use it with printk-style functions, e.g. > > printk("blah fourcc " V4L2_FOURCC_CONV " is a nice format", > V4L2_FOURCC_TO_CONV(fourcc)); > > I guess it'd be better to add more parentheses around "fourcc" but it'd be > less clear here that way. I was following Hans' suggestion made in https://www.spinics.net/lists/linux-media/msg117046.html Hans: Do you agree with Sakari here to make it to a macro? Dave
On 10/17/17 11:17, Dave Stevenson wrote: > Hi Sakari. > > On 13 October 2017 at 22:09, Sakari Ailus <sakari.ailus@iki.fi> wrote: >> Hi Dave, >> >> On Wed, Sep 20, 2017 at 05:07:54PM +0100, Dave Stevenson wrote: >>> New helper function char *v4l2_fourcc2s(u32 fourcc, char *buf) >>> that converts a fourcc into a nice printable version. >>> >>> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> >>> --- >>> >>> No changes from v2 to v3 >>> >>> drivers/media/v4l2-core/v4l2-common.c | 18 ++++++++++++++++++ >>> include/media/v4l2-common.h | 3 +++ >>> 2 files changed, 21 insertions(+) >>> >>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c >>> index a5ea1f5..0219895 100644 >>> --- a/drivers/media/v4l2-core/v4l2-common.c >>> +++ b/drivers/media/v4l2-core/v4l2-common.c >>> @@ -405,3 +405,21 @@ void v4l2_get_timestamp(struct timeval *tv) >>> tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; >>> } >>> EXPORT_SYMBOL_GPL(v4l2_get_timestamp); >>> + >>> +char *v4l2_fourcc2s(u32 fourcc, char *buf) >>> +{ >>> + buf[0] = fourcc & 0x7f; >>> + buf[1] = (fourcc >> 8) & 0x7f; >>> + buf[2] = (fourcc >> 16) & 0x7f; >>> + buf[3] = (fourcc >> 24) & 0x7f; >>> + if (fourcc & (1 << 31)) { >>> + buf[4] = '-'; >>> + buf[5] = 'B'; >>> + buf[6] = 'E'; >>> + buf[7] = '\0'; >>> + } else { >>> + buf[4] = '\0'; >>> + } >>> + return buf; >>> +} >>> +EXPORT_SYMBOL_GPL(v4l2_fourcc2s); >>> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h >>> index aac8b7b..5b0fff9 100644 >>> --- a/include/media/v4l2-common.h >>> +++ b/include/media/v4l2-common.h >>> @@ -264,4 +264,7 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( >>> >>> void v4l2_get_timestamp(struct timeval *tv); >>> >>> +#define V4L2_FOURCC_MAX_SIZE 8 >>> +char *v4l2_fourcc2s(u32 fourcc, char *buf); >>> + >>> #endif /* V4L2_COMMON_H_ */ >> >> I like the idea but the use of a character pointer and assuming a length >> looks a bit scary. >> >> As this seems to be used uniquely for printing stuff, a couple of macros >> could be used instead. Something like >> >> #define V4L2_FOURCC_CONV "%c%c%c%c%s" >> #define V4L2_FOURCC_TO_CONV(fourcc) \ >> fourcc & 0x7f, (fourcc >> 8) & 0x7f, (fourcc >> 16) & 0x7f, \ >> (fourcc >> 24) & 0x7f, fourcc & BIT(31) ? "-BE" : "" 'fourcc' should be in parenthesis '(fourcc)'. >> >> You could use it with printk-style functions, e.g. >> >> printk("blah fourcc " V4L2_FOURCC_CONV " is a nice format", >> V4L2_FOURCC_TO_CONV(fourcc)); >> >> I guess it'd be better to add more parentheses around "fourcc" but it'd be >> less clear here that way. > > I was following Hans' suggestion made in > https://www.spinics.net/lists/linux-media/msg117046.html > > Hans: Do you agree with Sakari here to make it to a macro? Not a bad idea. But I think we should add it to the public videodev2.h header in that case, allowing it to be used by applications as well. How about calling the defines V4L2_FOURCC_FMT and V4L2_FOURCC_FMT_ARGS? Regards, Hans
Hi Hans, On Tue, Oct 17, 2017 at 11:28:46AM +0200, Hans Verkuil wrote: > On 10/17/17 11:17, Dave Stevenson wrote: > > Hi Sakari. > > > > On 13 October 2017 at 22:09, Sakari Ailus <sakari.ailus@iki.fi> wrote: > >> Hi Dave, > >> > >> On Wed, Sep 20, 2017 at 05:07:54PM +0100, Dave Stevenson wrote: > >>> New helper function char *v4l2_fourcc2s(u32 fourcc, char *buf) > >>> that converts a fourcc into a nice printable version. > >>> > >>> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> > >>> --- > >>> > >>> No changes from v2 to v3 > >>> > >>> drivers/media/v4l2-core/v4l2-common.c | 18 ++++++++++++++++++ > >>> include/media/v4l2-common.h | 3 +++ > >>> 2 files changed, 21 insertions(+) > >>> > >>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c > >>> index a5ea1f5..0219895 100644 > >>> --- a/drivers/media/v4l2-core/v4l2-common.c > >>> +++ b/drivers/media/v4l2-core/v4l2-common.c > >>> @@ -405,3 +405,21 @@ void v4l2_get_timestamp(struct timeval *tv) > >>> tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; > >>> } > >>> EXPORT_SYMBOL_GPL(v4l2_get_timestamp); > >>> + > >>> +char *v4l2_fourcc2s(u32 fourcc, char *buf) > >>> +{ > >>> + buf[0] = fourcc & 0x7f; > >>> + buf[1] = (fourcc >> 8) & 0x7f; > >>> + buf[2] = (fourcc >> 16) & 0x7f; > >>> + buf[3] = (fourcc >> 24) & 0x7f; > >>> + if (fourcc & (1 << 31)) { > >>> + buf[4] = '-'; > >>> + buf[5] = 'B'; > >>> + buf[6] = 'E'; > >>> + buf[7] = '\0'; > >>> + } else { > >>> + buf[4] = '\0'; > >>> + } > >>> + return buf; > >>> +} > >>> +EXPORT_SYMBOL_GPL(v4l2_fourcc2s); > >>> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h > >>> index aac8b7b..5b0fff9 100644 > >>> --- a/include/media/v4l2-common.h > >>> +++ b/include/media/v4l2-common.h > >>> @@ -264,4 +264,7 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( > >>> > >>> void v4l2_get_timestamp(struct timeval *tv); > >>> > >>> +#define V4L2_FOURCC_MAX_SIZE 8 > >>> +char *v4l2_fourcc2s(u32 fourcc, char *buf); > >>> + > >>> #endif /* V4L2_COMMON_H_ */ > >> > >> I like the idea but the use of a character pointer and assuming a length > >> looks a bit scary. > >> > >> As this seems to be used uniquely for printing stuff, a couple of macros > >> could be used instead. Something like > >> > >> #define V4L2_FOURCC_CONV "%c%c%c%c%s" > >> #define V4L2_FOURCC_TO_CONV(fourcc) \ > >> fourcc & 0x7f, (fourcc >> 8) & 0x7f, (fourcc >> 16) & 0x7f, \ > >> (fourcc >> 24) & 0x7f, fourcc & BIT(31) ? "-BE" : "" > > 'fourcc' should be in parenthesis '(fourcc)'. Yes, I omitted those for readability here. > > >> > >> You could use it with printk-style functions, e.g. > >> > >> printk("blah fourcc " V4L2_FOURCC_CONV " is a nice format", > >> V4L2_FOURCC_TO_CONV(fourcc)); > >> > >> I guess it'd be better to add more parentheses around "fourcc" but it'd be > >> less clear here that way. > > > > I was following Hans' suggestion made in > > https://www.spinics.net/lists/linux-media/msg117046.html > > > > Hans: Do you agree with Sakari here to make it to a macro? > > Not a bad idea. But I think we should add it to the public videodev2.h > header in that case, allowing it to be used by applications as well. Sounds good. > > How about calling the defines V4L2_FOURCC_FMT and V4L2_FOURCC_FMT_ARGS? printf(3) describes conversion specifiers (%...) and I thought of using "CONV" there for that purpose to make it explicit. Fourcc, implicitly, already is about formats. What would you think of V4L2_FOURCC_CONV and V4L2_FOURCC_CONV_ARGS (or just V4L2_FOURCC_ARGS)?
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index a5ea1f5..0219895 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -405,3 +405,21 @@ void v4l2_get_timestamp(struct timeval *tv) tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; } EXPORT_SYMBOL_GPL(v4l2_get_timestamp); + +char *v4l2_fourcc2s(u32 fourcc, char *buf) +{ + buf[0] = fourcc & 0x7f; + buf[1] = (fourcc >> 8) & 0x7f; + buf[2] = (fourcc >> 16) & 0x7f; + buf[3] = (fourcc >> 24) & 0x7f; + if (fourcc & (1 << 31)) { + buf[4] = '-'; + buf[5] = 'B'; + buf[6] = 'E'; + buf[7] = '\0'; + } else { + buf[4] = '\0'; + } + return buf; +} +EXPORT_SYMBOL_GPL(v4l2_fourcc2s); diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index aac8b7b..5b0fff9 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -264,4 +264,7 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( void v4l2_get_timestamp(struct timeval *tv); +#define V4L2_FOURCC_MAX_SIZE 8 +char *v4l2_fourcc2s(u32 fourcc, char *buf); + #endif /* V4L2_COMMON_H_ */