[{"id":17634,"web_url":"https://patchwork.libcamera.org/comment/17634/","msgid":"<eafa64be-283c-9cd7-f2eb-53c2765751da@ideasonboard.com>","date":"2021-06-18T20:04:00","subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: Add support for\n\tmonochrome sensors","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi David,\n\nOn 18/06/2021 17:18, David Plowman wrote:\n> This commit adds support for monochrome (greyscale) raw sensors. These\n> are sensors that have no colour filter array, so all pixels are the\n> same and there are no distinct colour channels.\n> \n> These sensors still require many of an ISP's processing stages, such\n> as denoise, tone mapping, but not those that involve colours (such as\n> demosaic, or colour matrices).\n\n\nAha, I was wondering why we needed a bayer format if it wasn't a bayer\npattern - but it's about continuity in the processing pipeline.\n\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  include/libcamera/internal/bayer_format.h |  3 ++-\n>  src/libcamera/bayer_format.cpp            | 14 ++++++++++++--\n>  src/libcamera/camera_sensor.cpp           |  3 +++\n>  src/libcamera/property_ids.yaml           |  4 ++++\n>  4 files changed, 21 insertions(+), 3 deletions(-)\n> \n> diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\n> index 5b8c1dc9..723382d4 100644\n> --- a/include/libcamera/internal/bayer_format.h\n> +++ b/include/libcamera/internal/bayer_format.h\n> @@ -23,7 +23,8 @@ public:\n>  \t\tBGGR = 0,\n>  \t\tGBRG = 1,\n>  \t\tGRBG = 2,\n> -\t\tRGGB = 3\n> +\t\tRGGB = 3,\n> +\t\tMONO = 4\n>  \t};\n>  \n>  \tenum Packing : uint16_t {\n> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\n> index ed61202c..11355f14 100644\n> --- a/src/libcamera/bayer_format.cpp\n> +++ b/src/libcamera/bayer_format.cpp\n> @@ -45,6 +45,8 @@ namespace libcamera {\n>   * \\brief G then R on the first row, B then G on the second row.\n>   * \\var BayerFormat::RGGB\n>   * \\brief R then G on the first row, G then B on the second row.\n> + * \\var BayerFormat::MONO\n> + * \\brief Monochrome image data, there is no colour filter array.\n>   */\n>  \n>  /**\n> @@ -111,6 +113,8 @@ const std::map<BayerFormat, V4L2PixelFormat, BayerFormatComparator> bayerToV4l2{\n>  \t{ { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },\n>  \t{ { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },\n>  \t{ { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },\n> +\t{ { BayerFormat::MONO, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) },\n> +\t{ { BayerFormat::MONO, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) },\n>  };\n>  \n>  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{\n> @@ -146,6 +150,8 @@ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{\n>  \t{ MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::None } },\n>  \t{ MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::None } },\n>  \t{ MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::None } },\n> +\t{ MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::None } },\n> +\t{ MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::None } },\n>  };\n>  \n>  } /* namespace */\n> @@ -198,9 +204,10 @@ std::string BayerFormat::toString() const\n>  \t\t\"BGGR\",\n>  \t\t\"GBRG\",\n>  \t\t\"GRBG\",\n> -\t\t\"RGGB\"\n> +\t\t\"RGGB\",\n> +\t\t\"MONO\"\n>  \t};\n> -\tif (isValid() && order <= RGGB)\n> +\tif (isValid() && order <= MONO)\n>  \t\tresult = orderStrings[order];\n>  \telse\n>  \t\treturn \"INVALID\";\n> @@ -280,6 +287,9 @@ BayerFormat BayerFormat::transform(Transform t) const\n>  {\n>  \tBayerFormat result = *this;\n>  \n> +\tif (order == MONO)\n> +\t\treturn result;\n> +\n>  \t/*\n>  \t * Observe that flipping bit 0 of the Order enum performs a horizontal\n>  \t * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly,\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index 3e135353..fb67c15a 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -427,6 +427,9 @@ int CameraSensor::initProperties()\n>  \t\tcase BayerFormat::RGGB:\n>  \t\t\tcfa = properties::draft::RGGB;\n>  \t\t\tbreak;\n> +\t\tcase BayerFormat::MONO:\n> +\t\t\tcfa = properties::draft::MONO;\n> +\t\t\tbreak;\n>  \t\t}\n>  \n>  \t\tproperties_.set(properties::draft::ColorFilterArrangement, cfa);\n> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n> index 104e9aaf..87be68f7 100644\n> --- a/src/libcamera/property_ids.yaml\n> +++ b/src/libcamera/property_ids.yaml\n> @@ -706,5 +706,9 @@ controls:\n>            description: |\n>              Sensor is not Bayer; output has 3 16-bit values for each pixel,\n>              instead of just 1 16-bit value per pixel.\n> +        - name: MONO\n> +          value: 5\n> +          description: |\n> +            Sensor is not Bayer; output consits of a single colour channel.\n\ns/consits/consists/\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>  \n>  ...\n>","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 260A2C3218\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jun 2021 20:04:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E2FE968943;\n\tFri, 18 Jun 2021 22:04:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA2486050D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jun 2021 22:04:05 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7578E3F0;\n\tFri, 18 Jun 2021 22:04:05 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"HlYv+YbZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624046645;\n\tbh=+EIB9ocVLNqJgAIabmphCSWdkz5sDD9tZZRZfJlnHLs=;\n\th=Reply-To:To:References:From:Subject:Date:In-Reply-To:From;\n\tb=HlYv+YbZ9tlfANi6iOxPg4mjgRWRXVVMDMrcyZq1+PMZn1J5/WRnbGKUmkTVYJmx7\n\tIFpMsOL1vzBtp0/LziGQ0A4+6300eHL79dTQ9IsQvAYpeMogFISOz8QedSmO18uRVt\n\tKOpd1e++TToRAYJGo798RTP+Wk0nW8od/vNRME1c=","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210618161807.24242-1-david.plowman@raspberrypi.com>\n\t<20210618161807.24242-2-david.plowman@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Organization":"Ideas on Board","Message-ID":"<eafa64be-283c-9cd7-f2eb-53c2765751da@ideasonboard.com>","Date":"Fri, 18 Jun 2021 21:04:00 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.8.1","MIME-Version":"1.0","In-Reply-To":"<20210618161807.24242-2-david.plowman@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: Add support for\n\tmonochrome sensors","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>","Reply-To":"kieran.bingham@ideasonboard.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]