[{"id":4015,"web_url":"https://patchwork.libcamera.org/comment/4015/","msgid":"<ef77c70fd6f260c8a7754913ad7051b07cfbc4f7.camel@ndufresne.ca>","date":"2020-03-14T11:14:12","subject":"Re: [libcamera-devel] [PATCH 7/8] libcamera: v4l2_videodevice: Map\n\tV4L2_PIX_FMT_GREY to DRM FourCC","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le samedi 14 mars 2020 à 01:38 +0200, Laurent Pinchart a écrit :\n> DRM has a format for 8-bit greyscale data, DRM_FORMAT_R8. Despite the\n> 'R' name, which comes from GL/Vulkan to mean single-channel data, the\n> format maps to greyscale for display. We can thus map it to\n> V4L2_PIX_FMT_GREY.\n\nThe mapping looks fine to me, but may lead to surprising result in\nabsence of colorimetry support. Most YCbCr 4:0:0 will be limited range,\nwhile on the GFX side, most of R8 usage will be full range. Just be\naware.\n\nNicolas\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index f68b67b33293..f89bf2ff781e 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1473,12 +1473,15 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)\n>  \tcase V4L2_PIX_FMT_NV21M:\n>  \t\treturn DRM_FORMAT_NV21;\n>  \n> +\t/* Greyscale formats. */\n> +\tcase V4L2_PIX_FMT_GREY:\n> +\t\treturn DRM_FORMAT_R8;\n> +\n>  \t/* Compressed formats. */\n>  \tcase V4L2_PIX_FMT_MJPEG:\n>  \t\treturn DRM_FORMAT_MJPEG;\n>  \n>  \t/* V4L2 formats not yet supported by DRM. */\n> -\tcase V4L2_PIX_FMT_GREY:\n>  \tdefault:\n>  \t\t/*\n>  \t\t * \\todo We can't use LOG() in a static method of a Loggable\n> @@ -1557,6 +1560,10 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar\n>  \tcase DRM_FORMAT_NV21:\n>  \t\treturn V4L2_PIX_FMT_NV21;\n>  \n> +\t/* Greyscale formats. */\n> +\tcase DRM_FORMAT_R8:\n> +\t\treturn V4L2_PIX_FMT_GREY;\n> +\n>  \t/* Compressed formats. */\n>  \tcase DRM_FORMAT_MJPEG:\n>  \t\treturn V4L2_PIX_FMT_MJPEG;","headers":{"Return-Path":"<nicolas@ndufresne.ca>","Received":["from mail-qk1-x741.google.com (mail-qk1-x741.google.com\n\t[IPv6:2607:f8b0:4864:20::741])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 572216041D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Mar 2020 12:14:15 +0100 (CET)","by mail-qk1-x741.google.com with SMTP id f3so17437968qkh.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Mar 2020 04:14:15 -0700 (PDT)","from skullcanyon ([192.222.193.21])\n\tby smtp.gmail.com with ESMTPSA id\n\tu26sm6607077qku.97.2020.03.14.04.14.12\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 14 Mar 2020 04:14:13 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=message-id:subject:from:to:cc:date:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=TgkU3dv6bCEJIm6LCnINfeBN7jAJY7Hb2d7/VHCX0k0=;\n\tb=STTzLHVqgKwdJRGj47J/7EFzVU516YwKFRbtabjNjoovOeUx5esoSwep6vSe7Dr45K\n\t8mQnvC3bwGU6HOIZ0YxYUAohhSi8Vb8Ag7Wch1Gl8OO5rZejVHrYkdstj/0OEwc3DITZ\n\txKlZLWTi0gNpjric7gXRcRikddq3cFbsTj/9obhaW1+mn9YCreF6eYCAyRvIf0VwnhnD\n\tTcJMA6WmJqjeCJKqiuFloe4v+u/271g4t95DjBQalS3Zeubgbm8cOGdLoo4MFzuuqQD8\n\t02jW8oOPxfy8FCMI2rLFFQcvvIcpyee2NwfLGtWKqBd+kH68j60LIMKTh7GNpWHmRDgw\n\tcqjA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=TgkU3dv6bCEJIm6LCnINfeBN7jAJY7Hb2d7/VHCX0k0=;\n\tb=NcGbOemEVdDgfrIJHhclDUsXp+2RrdOMm64TpPZ1swmFrAxo4KdarKsRePPaSTEEgy\n\tzE3SuAv+oTntG3artf18EoseSVW0fFiQ/EPtnnfz7xluGuQ4o51nRsIj+SVRbnqnBm07\n\tNs6ngY1lBS9nvqa0boQ7U0mMd1ou7W8t0s4Gs1DCccASQF3DGJpsug4GNITZxIBQw8BK\n\tm02J90+s8aGcrWwV/Pd7vJ4mdq9iSq5QFi00BH1jyuYQ+UbO+6w7soLNPmngzpCvUELV\n\tArOXiHreULVVb/wm4JgDot8qwQEq5ewgD6Vm/pJbRF3jV2BK8R5gKSCK5vql5rc8r3DK\n\tRMLw==","X-Gm-Message-State":"ANhLgQ1Nfnu9v7XPZdIruMw4QghAbXHC1mhytLrK/sYioIQN4fwH9stT\n\t5p/yYMrbTmhWI4a2jTb/nGh17Q==","X-Google-Smtp-Source":"ADFU+vtpTVIQfz/pcXG+9wgpKv9DnSm3dwYAAzFtxTpVpHX8XjpmPKcP4TAmcachJHMluTBrkcBidA==","X-Received":"by 2002:a05:620a:12d5:: with SMTP id\n\te21mr17182209qkl.226.1584184454163; \n\tSat, 14 Mar 2020 04:14:14 -0700 (PDT)","Message-ID":"<ef77c70fd6f260c8a7754913ad7051b07cfbc4f7.camel@ndufresne.ca>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Cc":"Martijn Braam <martijn@brixit.nl>, Mickael GUENE <mickael.guene@st.com>, \n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>","Date":"Sat, 14 Mar 2020 07:14:12 -0400","In-Reply-To":"<20200313233856.25202-8-laurent.pinchart@ideasonboard.com>","References":"<20200313233856.25202-1-laurent.pinchart@ideasonboard.com>\n\t<20200313233856.25202-8-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.34.4 (3.34.4-1.fc31) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 7/8] libcamera: v4l2_videodevice: Map\n\tV4L2_PIX_FMT_GREY to DRM FourCC","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 14 Mar 2020 11:14:15 -0000"}},{"id":4016,"web_url":"https://patchwork.libcamera.org/comment/4016/","msgid":"<20200314114732.GB5320@pendragon.ideasonboard.com>","date":"2020-03-14T11:47:32","subject":"Re: [libcamera-devel] [PATCH 7/8] libcamera: v4l2_videodevice: Map\n\tV4L2_PIX_FMT_GREY to DRM FourCC","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nicolas,\n\nOn Sat, Mar 14, 2020 at 07:14:12AM -0400, Nicolas Dufresne wrote:\n> Le samedi 14 mars 2020 à 01:38 +0200, Laurent Pinchart a écrit :\n> > DRM has a format for 8-bit greyscale data, DRM_FORMAT_R8. Despite the\n> > 'R' name, which comes from GL/Vulkan to mean single-channel data, the\n> > format maps to greyscale for display. We can thus map it to\n> > V4L2_PIX_FMT_GREY.\n> \n> The mapping looks fine to me, but may lead to surprising result in\n> absence of colorimetry support. Most YCbCr 4:0:0 will be limited range,\n> while on the GFX side, most of R8 usage will be full range. Just be\n> aware.\n\nThanks for the comment. In the specific case I'm trying to support, data\ncomes from a sensor that doesn't have a Bayer filter, so it's really\nfull range greyscale (it's actually 10 bits scaled down to 8 bits). In\nthe general case, we need to convey colorimetry information, I agree\nwith you, and that's something that can't be conveyed just through a\n4CC, we will need a dedicated API.\n\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/v4l2_videodevice.cpp | 9 ++++++++-\n> >  1 file changed, 8 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index f68b67b33293..f89bf2ff781e 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -1473,12 +1473,15 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)\n> >  \tcase V4L2_PIX_FMT_NV21M:\n> >  \t\treturn DRM_FORMAT_NV21;\n> >  \n> > +\t/* Greyscale formats. */\n> > +\tcase V4L2_PIX_FMT_GREY:\n> > +\t\treturn DRM_FORMAT_R8;\n> > +\n> >  \t/* Compressed formats. */\n> >  \tcase V4L2_PIX_FMT_MJPEG:\n> >  \t\treturn DRM_FORMAT_MJPEG;\n> >  \n> >  \t/* V4L2 formats not yet supported by DRM. */\n> > -\tcase V4L2_PIX_FMT_GREY:\n> >  \tdefault:\n> >  \t\t/*\n> >  \t\t * \\todo We can't use LOG() in a static method of a Loggable\n> > @@ -1557,6 +1560,10 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar\n> >  \tcase DRM_FORMAT_NV21:\n> >  \t\treturn V4L2_PIX_FMT_NV21;\n> >  \n> > +\t/* Greyscale formats. */\n> > +\tcase DRM_FORMAT_R8:\n> > +\t\treturn V4L2_PIX_FMT_GREY;\n> > +\n> >  \t/* Compressed formats. */\n> >  \tcase DRM_FORMAT_MJPEG:\n> >  \t\treturn V4L2_PIX_FMT_MJPEG;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 890F06041D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 14 Mar 2020 12:47:36 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 02AB4B22;\n\tSat, 14 Mar 2020 12:47:35 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584186456;\n\tbh=TTsXQLlNSbDvEeuETY72qOoN5QTlt8BqOl6wc/lRfUo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZMNhX19H7Ox1AamZWtF3xmnLrhudlNyJuQpcKgSewUa2/V8UWQ8iYwPpBF1blKdTb\n\tJx7QaMEhZiBEaUby8jQvHiCFUYdUxacpJf1KMAdWDiizDLAy5QWK7tH9AuvVXLx/Cb\n\t5u3HZzSqR1/QISLi+owMQ+LTTFLtjcQWfXOnKOpc=","Date":"Sat, 14 Mar 2020 13:47:32 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nicolas Dufresne <nicolas@ndufresne.ca>","Cc":"libcamera-devel@lists.libcamera.org, Martijn Braam <martijn@brixit.nl>, \n\tMickael GUENE <mickael.guene@st.com>,\n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>","Message-ID":"<20200314114732.GB5320@pendragon.ideasonboard.com>","References":"<20200313233856.25202-1-laurent.pinchart@ideasonboard.com>\n\t<20200313233856.25202-8-laurent.pinchart@ideasonboard.com>\n\t<ef77c70fd6f260c8a7754913ad7051b07cfbc4f7.camel@ndufresne.ca>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<ef77c70fd6f260c8a7754913ad7051b07cfbc4f7.camel@ndufresne.ca>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 7/8] libcamera: v4l2_videodevice: Map\n\tV4L2_PIX_FMT_GREY to DRM FourCC","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 14 Mar 2020 11:47:36 -0000"}}]