diff mbox series

[v3,06/10] media: uapi: Add a macro to tell whether an mbus code is metadata

Message ID 20230808075538.3043934-7-sakari.ailus@linux.intel.com
State New
Headers show
Series Generic line based metadata support, internal pads | expand

Commit Message

Sakari Ailus Aug. 8, 2023, 7:55 a.m. UTC
Add a macro to tell whether a given mbus code is metadata.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 include/uapi/linux/media-bus-format.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Sakari Ailus Sept. 6, 2023, 11:33 a.m. UTC | #1
Hi Laurent,

On Tue, Sep 05, 2023 at 08:06:04PM +0300, Laurent Pinchart wrote:
> On Tue, Sep 05, 2023 at 10:37:45AM +0000, Sakari Ailus wrote:
> > On Tue, Sep 05, 2023 at 12:47:21PM +0300, Tomi Valkeinen wrote:
> > > On 08/08/2023 10:55, Sakari Ailus wrote:
> > > > Add a macro to tell whether a given mbus code is metadata.
> > > > 
> > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > > ---
> > > >   include/uapi/linux/media-bus-format.h | 3 +++
> > > >   1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
> > > > index 9ee031397372..2486b4178c5f 100644
> > > > --- a/include/uapi/linux/media-bus-format.h
> > > > +++ b/include/uapi/linux/media-bus-format.h
> > > > @@ -182,4 +182,7 @@
> > > >   #define MEDIA_BUS_FMT_META_20			0x8006
> > > >   #define MEDIA_BUS_FMT_META_24			0x8007
> > > > +#define MEDIA_BUS_FMT_IS_META(code)		\
> > > > +	((code) & 0xf000 == 0x7000 || (code) & 0xf000 == 0x8000)
> > > > +
> > > >   #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
> > > 
> > > mbus code seems to be u32, so the above won't work. Maybe:
> > > 
> > > (((code) & ~0xfffULL) == 0x7000 || ((code) & ~0xfffULL) == 0x8000)
> > > 
> > > Also, embedded formats with 0x9nnn codes are added later in the series.
> > 
> > Thanks, I'll address these for v4.
> 
> It would be nice to make this an inline function, to avoid evaluating
> the code twice. I think you can move it to an internal kernel header, it
> doesn't need to be exposed to userspace.

This was meant for user space consumption for setting the buffer type to
the video node accordingly. It's certainly possible to do that without this
macro, too.
Sakari Ailus Sept. 7, 2023, 8:20 a.m. UTC | #2
On Wed, Sep 06, 2023 at 01:06:36PM +0000, Sakari Ailus wrote:
> On Wed, Sep 06, 2023 at 03:23:08PM +0300, Laurent Pinchart wrote:
> > On Wed, Sep 06, 2023 at 11:33:30AM +0000, Sakari Ailus wrote:
> > > On Tue, Sep 05, 2023 at 08:06:04PM +0300, Laurent Pinchart wrote:
> > > > On Tue, Sep 05, 2023 at 10:37:45AM +0000, Sakari Ailus wrote:
> > > > > On Tue, Sep 05, 2023 at 12:47:21PM +0300, Tomi Valkeinen wrote:
> > > > > > On 08/08/2023 10:55, Sakari Ailus wrote:
> > > > > > > Add a macro to tell whether a given mbus code is metadata.
> > > > > > > 
> > > > > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > > > > > ---
> > > > > > >   include/uapi/linux/media-bus-format.h | 3 +++
> > > > > > >   1 file changed, 3 insertions(+)
> > > > > > > 
> > > > > > > diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
> > > > > > > index 9ee031397372..2486b4178c5f 100644
> > > > > > > --- a/include/uapi/linux/media-bus-format.h
> > > > > > > +++ b/include/uapi/linux/media-bus-format.h
> > > > > > > @@ -182,4 +182,7 @@
> > > > > > >   #define MEDIA_BUS_FMT_META_20			0x8006
> > > > > > >   #define MEDIA_BUS_FMT_META_24			0x8007
> > > > > > > +#define MEDIA_BUS_FMT_IS_META(code)		\
> > > > > > > +	((code) & 0xf000 == 0x7000 || (code) & 0xf000 == 0x8000)
> > > > > > > +
> > > > > > >   #endif /* __LINUX_MEDIA_BUS_FORMAT_H */
> > > > > > 
> > > > > > mbus code seems to be u32, so the above won't work. Maybe:
> > > > > > 
> > > > > > (((code) & ~0xfffULL) == 0x7000 || ((code) & ~0xfffULL) == 0x8000)
> > > > > > 
> > > > > > Also, embedded formats with 0x9nnn codes are added later in the series.
> > > > > 
> > > > > Thanks, I'll address these for v4.
> > > > 
> > > > It would be nice to make this an inline function, to avoid evaluating
> > > > the code twice. I think you can move it to an internal kernel header, it
> > > > doesn't need to be exposed to userspace.
> > > 
> > > This was meant for user space consumption for setting the buffer type to
> > > the video node accordingly. It's certainly possible to do that without this
> > > macro, too.
> > 
> > I think userspace would be fine without it :-)
> 
> I'll see if this would seem useful in yavta support before dropping it: the
> buffer type needs to be specified correctly and knowing the format is a
> metadata format maybe helpful. Let's see.

As yavta doesn't deal with mbus codes, this isn't useful for it. I'll drop
it for now.
diff mbox series

Patch

diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
index 9ee031397372..2486b4178c5f 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -182,4 +182,7 @@ 
 #define MEDIA_BUS_FMT_META_20			0x8006
 #define MEDIA_BUS_FMT_META_24			0x8007
 
+#define MEDIA_BUS_FMT_IS_META(code)		\
+	((code) & 0xf000 == 0x7000 || (code) & 0xf000 == 0x8000)
+
 #endif /* __LINUX_MEDIA_BUS_FORMAT_H */