[{"id":4390,"web_url":"https://patchwork.libcamera.org/comment/4390/","msgid":"<20200407124004.GC1716317@oden.dyn.berto.se>","date":"2020-04-07T12:40:04","subject":"Re: [libcamera-devel] [RFC 1/1] libcamera:\n\tV4L2VideoDevice::to[V4L2]PixelFormat(): add Bayer formats","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Andrey,\n\nThanks for your work.\n\nOn 2020-04-05 00:57:30 +0300, Andrey Konovalov wrote:\n> Add support for 8-bit, 10-bit, and 10-bit packed raw Bayer formats in\n> toPixelFormat() and toV4L2PixelFormat() methods of V4L2VideoDevice class.\n> \n> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 56 ++++++++++++++++++++++++++++++\n>  1 file changed, 56 insertions(+)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index eb33a68..2e3aafc 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1687,6 +1687,36 @@ PixelFormat V4L2VideoDevice::toPixelFormat(V4L2PixelFormat v4l2Fourcc)\n>  \tcase V4L2_PIX_FMT_MJPEG:\n>  \t\treturn PixelFormat(DRM_FORMAT_MJPEG);\n>  \n> +\t/* 8-bit Bayer formats. */\n> +\tcase V4L2_PIX_FMT_SRGGB8:\n> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB8);\n> +\tcase V4L2_PIX_FMT_SGRBG8:\n> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG8);\n> +\tcase V4L2_PIX_FMT_SGBRG8:\n> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG8);\n> +\tcase V4L2_PIX_FMT_SBGGR8:\n> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR8);\n> +\n> +\t/* 10-bit Bayer formats. */\n> +\tcase V4L2_PIX_FMT_SRGGB10:\n> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB10);\n> +\tcase V4L2_PIX_FMT_SGRBG10:\n> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG10);\n> +\tcase V4L2_PIX_FMT_SGBRG10:\n> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG10);\n> +\tcase V4L2_PIX_FMT_SBGGR10:\n> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR10);\n> +\n> +\t/* 10-bit Bayer packed formats. */\n> +\tcase V4L2_PIX_FMT_SRGGB10P:\n> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> +\tcase V4L2_PIX_FMT_SGRBG10P:\n> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> +\tcase V4L2_PIX_FMT_SGBRG10P:\n> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> +\tcase V4L2_PIX_FMT_SBGGR10P:\n> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED);\n\nThis fits the idea we had when adding the MIPI_FORMAT_MOD_CSI2_PACKED \nmodifier. But it's I misunderstood how modifies are used in DRM when \ndoing so. The patch for DRM is not accepted in upstream Linux yet and \nthis is a local change we took into libcamera where we bet on it was the \nright approach.\n\nNow we know we need to think one more time about if this is right \nsolution for this problem so I'm  bit reluctant building more things on \ntop of. If other thinks it's fine to do so I will not block it however.\n\n> +\n>  \t/* V4L2 formats not yet supported by DRM. */\n>  \tcase V4L2_PIX_FMT_GREY:\n>  \tdefault:\n> @@ -1734,6 +1764,8 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n>  V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelFormat,\n>  \t\t\t\t\t\t   bool multiplanar)\n>  {\n> +\tbool csi2Packed = pixelFormat.modifier() == MIPI_FORMAT_MOD_CSI2_PACKED;\n> +\n>  \tswitch (pixelFormat) {\n>  \t/* RGB formats. */\n>  \tcase DRM_FORMAT_BGR888:\n> @@ -1777,6 +1809,30 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n>  \t/* Compressed formats. */\n>  \tcase DRM_FORMAT_MJPEG:\n>  \t\treturn V4L2PixelFormat(V4L2_PIX_FMT_MJPEG);\n> +\n> +\t/* 8-bit Bayer formats. */\n> +\tcase DRM_FORMAT_SRGGB8:\n> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8);\n> +\tcase DRM_FORMAT_SGRBG8:\n> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8);\n> +\tcase DRM_FORMAT_SGBRG8:\n> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8);\n> +\tcase DRM_FORMAT_SBGGR8:\n> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n> +\n> +\t/* 10-bit Bayer formats, the packed ones included. */\n> +\tcase DRM_FORMAT_SRGGB10:\n> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P)\n> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10);\n> +\tcase DRM_FORMAT_SGRBG10:\n> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P)\n> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10);\n> +\tcase DRM_FORMAT_SGBRG10:\n> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P)\n> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10);\n> +\tcase DRM_FORMAT_SBGGR10:\n> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P)\n> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10);\n\nIf the issue above is resolved in such a way that this patch is accepted \nthis needs to be extended to also support IPU3_FORMAT_MOD_PACKED.\n\n>  \t}\n>  \n>  \t/*\n> -- \n> 2.17.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA4C5600F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2020 14:40:06 +0200 (CEST)","by mail-lj1-x243.google.com with SMTP id p14so3481166lji.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Apr 2020 05:40:06 -0700 (PDT)","from localhost (h-200-138.A463.priv.bahnhof.se. [176.10.200.138])\n\tby smtp.gmail.com with ESMTPSA id\n\tc4sm13253383lfm.37.2020.04.07.05.40.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Apr 2020 05:40:05 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"tX/QmvhV\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=tCEGzMyeEIL5IQ4PV8BpsOO22ctqCbCjZPdPa+8BrZ8=;\n\tb=tX/QmvhVvBhtoRMU2KZOZyLFmte/Lnpa3USgL7I/JeQC9QQwNQHFwiImZ8hJ1yVp4b\n\tp4IL4NpfKC1ik2JJP5/FVLK4MCAUgQ/3ErcJSwOl0VgWq2r81XO/QzX0jl1iQUg+iMA6\n\tayxvyqr4aB6vp9MiFNq9WY0ZoaidlHAeBY5s2lceEh4Alcn+KGAi9MxvjZexw55n5uYx\n\tS1yyaW9c+I6bHxM3PcVPIcl6yPLOrl81acHb+pAmahNeOboKmN9xwYryEY3SZioJ5sn9\n\t6tMd2zXaZIfiKgIVoCsxIE6q7LfF7e+Qr0Fgt1CJctufNzA6JXr0vHF3fPzpZV9j7dVR\n\tfemg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=tCEGzMyeEIL5IQ4PV8BpsOO22ctqCbCjZPdPa+8BrZ8=;\n\tb=NlNXpwi6cMcXlZw65pZoC4LISegYujbA1u/dzGYaPXYO14tNypSQCwKJplkBKymh6h\n\ta03wq+jgMC6CglQnPctWzTfiDzTGr65gr664mhaZPTmPbyVtb+I28CbdQpa5rw94RmQn\n\tjBVzMh67DrF1iDkToprv0RjKkpqae41bZKsq9BFNdUxbVKkJG+0VqVRaxGRECeDro+vl\n\tpvKaywiv3yjnMd1wF+A8el3mbdEoDxusYQe8nRNa55GG653POQAId9NkYqZiBtQ2wilt\n\tQJaUbEKO9VB6asxNcO33U5xGxbmny3zn3tpUDNXn24PJtTQ0eUx8IdTXctBc6JEpuM+x\n\tJLRQ==","X-Gm-Message-State":"AGi0PuZErif2AJc7WHtJJEVMLkMz/R8l43xqe2ormeRZ1EHT8yTEapQ3\n\tZp+ezf4ltUE650Y3eOH5QmoHWEMGt6M=","X-Google-Smtp-Source":"APiQypJYpmwGlrBMyWroXxMVnPyMrtMx5CeErZKooFTb9WyFdY7vU0q82vbghsrWl0mmABSjUfjgOA==","X-Received":"by 2002:a2e:889a:: with SMTP id\n\tk26mr1603861lji.162.1586263206100; \n\tTue, 07 Apr 2020 05:40:06 -0700 (PDT)","Date":"Tue, 7 Apr 2020 14:40:04 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Andrey Konovalov <andrey.konovalov@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200407124004.GC1716317@oden.dyn.berto.se>","References":"<20200404215730.16194-1-andrey.konovalov@linaro.org>\n\t<20200404215730.16194-2-andrey.konovalov@linaro.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200404215730.16194-2-andrey.konovalov@linaro.org>","Subject":"Re: [libcamera-devel] [RFC 1/1] libcamera:\n\tV4L2VideoDevice::to[V4L2]PixelFormat(): add Bayer formats","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":"Tue, 07 Apr 2020 12:40:07 -0000"}},{"id":4430,"web_url":"https://patchwork.libcamera.org/comment/4430/","msgid":"<24a8992d-a74f-d107-8849-45a18c97bbb0@linaro.org>","date":"2020-04-08T17:58:11","subject":"Re: [libcamera-devel] [RFC 1/1] libcamera:\n\tV4L2VideoDevice::to[V4L2]PixelFormat(): add Bayer formats","submitter":{"id":25,"url":"https://patchwork.libcamera.org/api/people/25/","name":"Andrey Konovalov","email":"andrey.konovalov@linaro.org"},"content":"Hi Niklas,\n\nThank you for the review!\n\nOn 07.04.2020 15:40, Niklas Söderlund wrote:\n> Hi Andrey,\n> \n> Thanks for your work.\n> \n> On 2020-04-05 00:57:30 +0300, Andrey Konovalov wrote:\n>> Add support for 8-bit, 10-bit, and 10-bit packed raw Bayer formats in\n>> toPixelFormat() and toV4L2PixelFormat() methods of V4L2VideoDevice class.\n>>\n>> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n>> ---\n>>   src/libcamera/v4l2_videodevice.cpp | 56 ++++++++++++++++++++++++++++++\n>>   1 file changed, 56 insertions(+)\n>>\n>> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n>> index eb33a68..2e3aafc 100644\n>> --- a/src/libcamera/v4l2_videodevice.cpp\n>> +++ b/src/libcamera/v4l2_videodevice.cpp\n>> @@ -1687,6 +1687,36 @@ PixelFormat V4L2VideoDevice::toPixelFormat(V4L2PixelFormat v4l2Fourcc)\n>>   \tcase V4L2_PIX_FMT_MJPEG:\n>>   \t\treturn PixelFormat(DRM_FORMAT_MJPEG);\n>>   \n>> +\t/* 8-bit Bayer formats. */\n>> +\tcase V4L2_PIX_FMT_SRGGB8:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB8);\n>> +\tcase V4L2_PIX_FMT_SGRBG8:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG8);\n>> +\tcase V4L2_PIX_FMT_SGBRG8:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG8);\n>> +\tcase V4L2_PIX_FMT_SBGGR8:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR8);\n>> +\n>> +\t/* 10-bit Bayer formats. */\n>> +\tcase V4L2_PIX_FMT_SRGGB10:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB10);\n>> +\tcase V4L2_PIX_FMT_SGRBG10:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG10);\n>> +\tcase V4L2_PIX_FMT_SGBRG10:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG10);\n>> +\tcase V4L2_PIX_FMT_SBGGR10:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR10);\n>> +\n>> +\t/* 10-bit Bayer packed formats. */\n>> +\tcase V4L2_PIX_FMT_SRGGB10P:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED);\n>> +\tcase V4L2_PIX_FMT_SGRBG10P:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED);\n>> +\tcase V4L2_PIX_FMT_SGBRG10P:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED);\n>> +\tcase V4L2_PIX_FMT_SBGGR10P:\n>> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> \n> This fits the idea we had when adding the MIPI_FORMAT_MOD_CSI2_PACKED\n> modifier. But it's I misunderstood how modifies are used in DRM when\n> doing so. The patch for DRM is not accepted in upstream Linux yet and\n> this is a local change we took into libcamera where we bet on it was the\n> right approach.\n\nAh.. OK. I am not familiar with modifiers usage in DRM. Will take a look.\nThanks for the explanation.\n\n> Now we know we need to think one more time about if this is right\n> solution for this problem so I'm  bit reluctant building more things on\n> top of.\n\nOK. This makes sense.\n\n> If other thinks it's fine to do so I will not block it however.\n> \n>> +\n>>   \t/* V4L2 formats not yet supported by DRM. */\n>>   \tcase V4L2_PIX_FMT_GREY:\n>>   \tdefault:\n>> @@ -1734,6 +1764,8 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n>>   V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelFormat,\n>>   \t\t\t\t\t\t   bool multiplanar)\n>>   {\n>> +\tbool csi2Packed = pixelFormat.modifier() == MIPI_FORMAT_MOD_CSI2_PACKED;\n>> +\n>>   \tswitch (pixelFormat) {\n>>   \t/* RGB formats. */\n>>   \tcase DRM_FORMAT_BGR888:\n>> @@ -1777,6 +1809,30 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n>>   \t/* Compressed formats. */\n>>   \tcase DRM_FORMAT_MJPEG:\n>>   \t\treturn V4L2PixelFormat(V4L2_PIX_FMT_MJPEG);\n>> +\n>> +\t/* 8-bit Bayer formats. */\n>> +\tcase DRM_FORMAT_SRGGB8:\n>> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8);\n>> +\tcase DRM_FORMAT_SGRBG8:\n>> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8);\n>> +\tcase DRM_FORMAT_SGBRG8:\n>> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8);\n>> +\tcase DRM_FORMAT_SBGGR8:\n>> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n>> +\n>> +\t/* 10-bit Bayer formats, the packed ones included. */\n>> +\tcase DRM_FORMAT_SRGGB10:\n>> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P)\n>> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10);\n>> +\tcase DRM_FORMAT_SGRBG10:\n>> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P)\n>> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10);\n>> +\tcase DRM_FORMAT_SGBRG10:\n>> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P)\n>> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10);\n>> +\tcase DRM_FORMAT_SBGGR10:\n>> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P)\n>> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10);\n> \n> If the issue above is resolved in such a way that this patch is accepted\n> this needs to be extended to also support IPU3_FORMAT_MOD_PACKED.\n\nRight. I'll add the support for IPU3_FORMAT_MOD_PACKED in the next version.\n\n\nThanks,\nAndrey\n\n>>   \t}\n>>   \n>>   \t/*\n>> -- \n>> 2.17.1\n>>\n>> _______________________________________________\n>> libcamera-devel mailing list\n>> libcamera-devel@lists.libcamera.org\n>> https://lists.libcamera.org/listinfo/libcamera-devel\n>","headers":{"Return-Path":"<andrey.konovalov@linaro.org>","Received":["from mail-lf1-x136.google.com (mail-lf1-x136.google.com\n\t[IPv6:2a00:1450:4864:20::136])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A95D76279B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2020 19:58:14 +0200 (CEST)","by mail-lf1-x136.google.com with SMTP id m19so3815647lfq.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Apr 2020 10:58:14 -0700 (PDT)","from [192.168.118.216] (37-144-159-139.broadband.corbina.ru.\n\t[37.144.159.139]) by smtp.gmail.com with ESMTPSA id\n\td22sm10739137lfe.75.2020.04.08.10.58.12\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 08 Apr 2020 10:58:12 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=linaro.org\n\theader.i=@linaro.org header.b=\"ADGcoYrr\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=abOpIW5psqrfBDKaX8B+UJ6DpsICboZpS3a+3c6nJVI=;\n\tb=ADGcoYrrnSIAWos7s1XMO26LnoJq5skp9HHxrHf92z7nzWO+VdzTQVx6lubB8snwJR\n\tqSdvvIN37JxoPgjaQ0XR1zCZoY5uFZmcLfy3KHpJ0KR8FjxXPRxaJsbLH6kHFeW9ujK2\n\tOQJvpr6wuIwIU4VbTpY+1otXq7ZIEQDv56tdajALiBCtEGTGAtgG3sN5HTqjFN22Pgpc\n\tgftcJcI8LmgLUkryGI4m2pkCu+ayqbdbapiJrRIvn/Frxq8HoqmhVTzk/DIkD0D2rNu9\n\tWbMDpFLo4Y72eg2W+VIi+I+r/I+U3vmlZ36jgzaow1wLsrZ9DkT/+4bX8O8I3gHEDevY\n\tJ28A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=abOpIW5psqrfBDKaX8B+UJ6DpsICboZpS3a+3c6nJVI=;\n\tb=F1EWLkPfTyDXGOzZaFPvoI+T85abgYTG5EZRulVwyPVT8nDb1Q/UDZ6IqQjzxUjh+6\n\t5+mIhFI+1EHsundUvYQ/XLytp4E2I3bHNE+RivtKtugQppJT9ZeQ0z5K9KRqVuZERhQk\n\tijeHfUVsMKDF3A6xP1hUm2y9Av8n9+LBLWR5/qmxOl5hJJ2B3EeS/+G80Wovxzripe0N\n\tIbSGD3/+1AgSj1NX0zv2522X54w34FBUyvbfQa2I534dpvBvGO1ZWhQIatRRDOhLZS5C\n\tCVtNTEyQU5UJl18/NamIRRI0LPDXuxEhjLbbM5TiinO+CwpXaLz7/f5wpC/TFcSrXpic\n\tA/YA==","X-Gm-Message-State":"AGi0PubgtZT8zhLa4hJvpzXZAV9ZLU0yOmul1CsfJcaNxoHpPsdoBdI+\n\tlp+BE1AHV8vOXN3kmv0CVrAIASAHMW8=","X-Google-Smtp-Source":"APiQypLQxIWTuKJuHWKAfNTStApx+JIc8UnQXjM8UiWvTg/DJ0QPjKfZKjI0LqIHkqu4nIeaMvBq8Q==","X-Received":"by 2002:a19:7407:: with SMTP id v7mr550008lfe.124.1586368693889; \n\tWed, 08 Apr 2020 10:58:13 -0700 (PDT)","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20200404215730.16194-1-andrey.konovalov@linaro.org>\n\t<20200404215730.16194-2-andrey.konovalov@linaro.org>\n\t<20200407124004.GC1716317@oden.dyn.berto.se>","From":"Andrey Konovalov <andrey.konovalov@linaro.org>","Message-ID":"<24a8992d-a74f-d107-8849-45a18c97bbb0@linaro.org>","Date":"Wed, 8 Apr 2020 20:58:11 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.4.1","MIME-Version":"1.0","In-Reply-To":"<20200407124004.GC1716317@oden.dyn.berto.se>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [RFC 1/1] libcamera:\n\tV4L2VideoDevice::to[V4L2]PixelFormat(): add Bayer formats","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":"Wed, 08 Apr 2020 17:58:14 -0000"}},{"id":11739,"web_url":"https://patchwork.libcamera.org/comment/11739/","msgid":"<20200731001803.GM6107@pendragon.ideasonboard.com>","date":"2020-07-31T00:18:03","subject":"Re: [libcamera-devel] [RFC 1/1] libcamera:\n\tV4L2VideoDevice::to[V4L2]PixelFormat(): add Bayer formats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Andrey,\n\nRevisiting a pretty old topic :-)\n\nOn Wed, Apr 08, 2020 at 08:58:11PM +0300, Andrey Konovalov wrote:\n> On 07.04.2020 15:40, Niklas Söderlund wrote:\n> > On 2020-04-05 00:57:30 +0300, Andrey Konovalov wrote:\n> >> Add support for 8-bit, 10-bit, and 10-bit packed raw Bayer formats in\n> >> toPixelFormat() and toV4L2PixelFormat() methods of V4L2VideoDevice class.\n> >>\n> >> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n> >> ---\n> >>   src/libcamera/v4l2_videodevice.cpp | 56 ++++++++++++++++++++++++++++++\n> >>   1 file changed, 56 insertions(+)\n> >>\n> >> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> >> index eb33a68..2e3aafc 100644\n> >> --- a/src/libcamera/v4l2_videodevice.cpp\n> >> +++ b/src/libcamera/v4l2_videodevice.cpp\n> >> @@ -1687,6 +1687,36 @@ PixelFormat V4L2VideoDevice::toPixelFormat(V4L2PixelFormat v4l2Fourcc)\n> >>   \tcase V4L2_PIX_FMT_MJPEG:\n> >>   \t\treturn PixelFormat(DRM_FORMAT_MJPEG);\n> >>   \n> >> +\t/* 8-bit Bayer formats. */\n> >> +\tcase V4L2_PIX_FMT_SRGGB8:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB8);\n> >> +\tcase V4L2_PIX_FMT_SGRBG8:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG8);\n> >> +\tcase V4L2_PIX_FMT_SGBRG8:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG8);\n> >> +\tcase V4L2_PIX_FMT_SBGGR8:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR8);\n> >> +\n> >> +\t/* 10-bit Bayer formats. */\n> >> +\tcase V4L2_PIX_FMT_SRGGB10:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB10);\n> >> +\tcase V4L2_PIX_FMT_SGRBG10:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG10);\n> >> +\tcase V4L2_PIX_FMT_SGBRG10:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG10);\n> >> +\tcase V4L2_PIX_FMT_SBGGR10:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR10);\n> >> +\n> >> +\t/* 10-bit Bayer packed formats. */\n> >> +\tcase V4L2_PIX_FMT_SRGGB10P:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SRGGB10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> >> +\tcase V4L2_PIX_FMT_SGRBG10P:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SGRBG10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> >> +\tcase V4L2_PIX_FMT_SGBRG10P:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SGBRG10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> >> +\tcase V4L2_PIX_FMT_SBGGR10P:\n> >> +\t\treturn PixelFormat(DRM_FORMAT_SBGGR10, MIPI_FORMAT_MOD_CSI2_PACKED);\n> > \n> > This fits the idea we had when adding the MIPI_FORMAT_MOD_CSI2_PACKED\n> > modifier. But it's I misunderstood how modifies are used in DRM when\n> > doing so. The patch for DRM is not accepted in upstream Linux yet and\n> > this is a local change we took into libcamera where we bet on it was the\n> > right approach.\n> \n> Ah.. OK. I am not familiar with modifiers usage in DRM. Will take a look.\n> Thanks for the explanation.\n> \n> > Now we know we need to think one more time about if this is right\n> > solution for this problem so I'm  bit reluctant building more things on\n> > top of.\n> \n> OK. This makes sense.\n> \n> > If other thinks it's fine to do so I will not block it however.\n> > \n> >> +\n> >>   \t/* V4L2 formats not yet supported by DRM. */\n> >>   \tcase V4L2_PIX_FMT_GREY:\n> >>   \tdefault:\n> >> @@ -1734,6 +1764,8 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n> >>   V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelFormat,\n> >>   \t\t\t\t\t\t   bool multiplanar)\n> >>   {\n> >> +\tbool csi2Packed = pixelFormat.modifier() == MIPI_FORMAT_MOD_CSI2_PACKED;\n> >> +\n> >>   \tswitch (pixelFormat) {\n> >>   \t/* RGB formats. */\n> >>   \tcase DRM_FORMAT_BGR888:\n> >> @@ -1777,6 +1809,30 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n> >>   \t/* Compressed formats. */\n> >>   \tcase DRM_FORMAT_MJPEG:\n> >>   \t\treturn V4L2PixelFormat(V4L2_PIX_FMT_MJPEG);\n> >> +\n> >> +\t/* 8-bit Bayer formats. */\n> >> +\tcase DRM_FORMAT_SRGGB8:\n> >> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8);\n> >> +\tcase DRM_FORMAT_SGRBG8:\n> >> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8);\n> >> +\tcase DRM_FORMAT_SGBRG8:\n> >> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8);\n> >> +\tcase DRM_FORMAT_SBGGR8:\n> >> +\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n> >> +\n> >> +\t/* 10-bit Bayer formats, the packed ones included. */\n> >> +\tcase DRM_FORMAT_SRGGB10:\n> >> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P)\n> >> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10);\n> >> +\tcase DRM_FORMAT_SGRBG10:\n> >> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P)\n> >> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10);\n> >> +\tcase DRM_FORMAT_SGBRG10:\n> >> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P)\n> >> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10);\n> >> +\tcase DRM_FORMAT_SBGGR10:\n> >> +\t\treturn (csi2Packed) ? V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P)\n> >> +\t\t\t: V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10);\n> > \n> > If the issue above is resolved in such a way that this patch is accepted\n> > this needs to be extended to also support IPU3_FORMAT_MOD_PACKED.\n> \n> Right. I'll add the support for IPU3_FORMAT_MOD_PACKED in the next version.\n\nI haven't seen a new version of this patch, but I believe the feature\nhas been added in the meantime. If that's not the case, could you let me\nknow ?","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A7B57BD878\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Jul 2020 00:18:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DEA961988;\n\tFri, 31 Jul 2020 02:18:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C55960540\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Jul 2020 02:18:13 +0200 (CEST)","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 772C69B1;\n\tFri, 31 Jul 2020 02:18:12 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RiN0atpZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596154692;\n\tbh=OJrint014vAumD+RcoYzPioiCqgdjCNvMLem1UPS6V8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RiN0atpZrUjQB3MfxNmFFFzvV2UpY84PAsWZzjqweVniObhZrp4mvmv9L2jUmgxrO\n\tONE31eTHU7tZPLNb7Y7YBpjN9TBrlr+bHu3GCfYU5bo34yh08MMj6/HBoMaWMRuzz+\n\tKrPHmFUbttyEOrVGcg1wDG9vWeapfp+EsGGj7O20=","Date":"Fri, 31 Jul 2020 03:18:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Andrey Konovalov <andrey.konovalov@linaro.org>","Message-ID":"<20200731001803.GM6107@pendragon.ideasonboard.com>","References":"<20200404215730.16194-1-andrey.konovalov@linaro.org>\n\t<20200404215730.16194-2-andrey.konovalov@linaro.org>\n\t<20200407124004.GC1716317@oden.dyn.berto.se>\n\t<24a8992d-a74f-d107-8849-45a18c97bbb0@linaro.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<24a8992d-a74f-d107-8849-45a18c97bbb0@linaro.org>","Subject":"Re: [libcamera-devel] [RFC 1/1] libcamera:\n\tV4L2VideoDevice::to[V4L2]PixelFormat(): add Bayer formats","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]