[libcamera-devel] [PATCH v1] libcamera: Update v4l2 pixel format to libcamera pixel format mapping

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Jun 17 06:53:50 CEST 2021


On Thu, Jun 17, 2021 at 01:30:57PM +0900, paul.elder at ideasonboard.com wrote:
> Hi Vedant,
> 
> For the subject, maybe "libcamera: Fix V4L2 pixel format mapping for
> XRGB32" ?
> 
> On Thu, Jun 17, 2021 at 02:18:44AM +0530, Vedant Paranjape wrote:
> > According to DRM FourCCs and linux kernel docs V4L2_PIX_FMT_XRGB32
> 
> I find it odd that the DRM fourccs would document v4l2 pixel formats...
> 
> > is BX24, but it was mapped to formats::XBGR8888, which is XB24.

The patch is correct, but the explanation isn't. There are 4CC values
that refer to different formats in V4L2 and DRM. We can't rely on 'XR24'
in DRM referring to the same format as 'XR24' in V4L2.

> > This patch fixes the mismatch of V4L2_PIX_FMT_XRGB32, i.e, matches it to
> > formats::BGRX8888. Furthermore, this patch adds V4L2_PIX_FMT_RBGX32 pixel
> 
> "Additionally, add a mapping from V4L2_PIX_FMT_RGBX32 to formats::XBGR8888" ?
> 
> Paul
> 
> > format which is represented by XB24, and maps V4L2_PIX_FMT_RGBX32
> > to formats::XBGR8888
> > 
> > Linux kernel pixel format docs: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-rgb.html#bits-per-component
> > DRM FourCC pixel format docs: https://elixir.bootlin.com/linux/latest/source/include/uapi/drm/drm_fourcc.h#L150
> > 
> > Signed-off-by: Vedant Paranjape <vedantparanjape160201 at gmail.com>
> > ---
> >  src/libcamera/v4l2_pixelformat.cpp | 3 ++-

You also need to update formats.cpp.

> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> > index 166d93cf..e86788ed 100644
> > --- a/src/libcamera/v4l2_pixelformat.cpp
> > +++ b/src/libcamera/v4l2_pixelformat.cpp
> > @@ -51,7 +51,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{
> >  	{ V4L2PixelFormat(V4L2_PIX_FMT_RGB24), formats::BGR888 },
> >  	{ V4L2PixelFormat(V4L2_PIX_FMT_BGR24), formats::RGB888 },
> >  	{ V4L2PixelFormat(V4L2_PIX_FMT_XBGR32), formats::XRGB8888 },
> > -	{ V4L2PixelFormat(V4L2_PIX_FMT_XRGB32), formats::XBGR8888 },
> > +	{ V4L2PixelFormat(V4L2_PIX_FMT_RGBX32), formats::XBGR8888 },
> > +	{ V4L2PixelFormat(V4L2_PIX_FMT_XRGB32), formats::BGRX8888 },
> >  	{ V4L2PixelFormat(V4L2_PIX_FMT_RGBA32), formats::ABGR8888 },
> >  	{ V4L2PixelFormat(V4L2_PIX_FMT_ABGR32), formats::ARGB8888 },
> >  	{ V4L2PixelFormat(V4L2_PIX_FMT_ARGB32), formats::BGRA8888 },

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list