Message ID | 20200313233856.25202-8-laurent.pinchart@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Le samedi 14 mars 2020 à 01:38 +0200, Laurent Pinchart a écrit : > DRM has a format for 8-bit greyscale data, DRM_FORMAT_R8. Despite the > 'R' name, which comes from GL/Vulkan to mean single-channel data, the > format maps to greyscale for display. We can thus map it to > V4L2_PIX_FMT_GREY. The mapping looks fine to me, but may lead to surprising result in absence of colorimetry support. Most YCbCr 4:0:0 will be limited range, while on the GFX side, most of R8 usage will be full range. Just be aware. Nicolas > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/v4l2_videodevice.cpp | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp > index f68b67b33293..f89bf2ff781e 100644 > --- a/src/libcamera/v4l2_videodevice.cpp > +++ b/src/libcamera/v4l2_videodevice.cpp > @@ -1473,12 +1473,15 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) > case V4L2_PIX_FMT_NV21M: > return DRM_FORMAT_NV21; > > + /* Greyscale formats. */ > + case V4L2_PIX_FMT_GREY: > + return DRM_FORMAT_R8; > + > /* Compressed formats. */ > case V4L2_PIX_FMT_MJPEG: > return DRM_FORMAT_MJPEG; > > /* V4L2 formats not yet supported by DRM. */ > - case V4L2_PIX_FMT_GREY: > default: > /* > * \todo We can't use LOG() in a static method of a Loggable > @@ -1557,6 +1560,10 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar > case DRM_FORMAT_NV21: > return V4L2_PIX_FMT_NV21; > > + /* Greyscale formats. */ > + case DRM_FORMAT_R8: > + return V4L2_PIX_FMT_GREY; > + > /* Compressed formats. */ > case DRM_FORMAT_MJPEG: > return V4L2_PIX_FMT_MJPEG;
Hi Nicolas, On Sat, Mar 14, 2020 at 07:14:12AM -0400, Nicolas Dufresne wrote: > Le samedi 14 mars 2020 à 01:38 +0200, Laurent Pinchart a écrit : > > DRM has a format for 8-bit greyscale data, DRM_FORMAT_R8. Despite the > > 'R' name, which comes from GL/Vulkan to mean single-channel data, the > > format maps to greyscale for display. We can thus map it to > > V4L2_PIX_FMT_GREY. > > The mapping looks fine to me, but may lead to surprising result in > absence of colorimetry support. Most YCbCr 4:0:0 will be limited range, > while on the GFX side, most of R8 usage will be full range. Just be > aware. Thanks for the comment. In the specific case I'm trying to support, data comes from a sensor that doesn't have a Bayer filter, so it's really full range greyscale (it's actually 10 bits scaled down to 8 bits). In the general case, we need to convey colorimetry information, I agree with you, and that's something that can't be conveyed just through a 4CC, we will need a dedicated API. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > > src/libcamera/v4l2_videodevice.cpp | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp > > index f68b67b33293..f89bf2ff781e 100644 > > --- a/src/libcamera/v4l2_videodevice.cpp > > +++ b/src/libcamera/v4l2_videodevice.cpp > > @@ -1473,12 +1473,15 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) > > case V4L2_PIX_FMT_NV21M: > > return DRM_FORMAT_NV21; > > > > + /* Greyscale formats. */ > > + case V4L2_PIX_FMT_GREY: > > + return DRM_FORMAT_R8; > > + > > /* Compressed formats. */ > > case V4L2_PIX_FMT_MJPEG: > > return DRM_FORMAT_MJPEG; > > > > /* V4L2 formats not yet supported by DRM. */ > > - case V4L2_PIX_FMT_GREY: > > default: > > /* > > * \todo We can't use LOG() in a static method of a Loggable > > @@ -1557,6 +1560,10 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar > > case DRM_FORMAT_NV21: > > return V4L2_PIX_FMT_NV21; > > > > + /* Greyscale formats. */ > > + case DRM_FORMAT_R8: > > + return V4L2_PIX_FMT_GREY; > > + > > /* Compressed formats. */ > > case DRM_FORMAT_MJPEG: > > return V4L2_PIX_FMT_MJPEG;
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index f68b67b33293..f89bf2ff781e 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1473,12 +1473,15 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) case V4L2_PIX_FMT_NV21M: return DRM_FORMAT_NV21; + /* Greyscale formats. */ + case V4L2_PIX_FMT_GREY: + return DRM_FORMAT_R8; + /* Compressed formats. */ case V4L2_PIX_FMT_MJPEG: return DRM_FORMAT_MJPEG; /* V4L2 formats not yet supported by DRM. */ - case V4L2_PIX_FMT_GREY: default: /* * \todo We can't use LOG() in a static method of a Loggable @@ -1557,6 +1560,10 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar case DRM_FORMAT_NV21: return V4L2_PIX_FMT_NV21; + /* Greyscale formats. */ + case DRM_FORMAT_R8: + return V4L2_PIX_FMT_GREY; + /* Compressed formats. */ case DRM_FORMAT_MJPEG: return V4L2_PIX_FMT_MJPEG;
DRM has a format for 8-bit greyscale data, DRM_FORMAT_R8. Despite the 'R' name, which comes from GL/Vulkan to mean single-channel data, the format maps to greyscale for display. We can thus map it to V4L2_PIX_FMT_GREY. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/libcamera/v4l2_videodevice.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)