{"id":12724,"url":"https://patchwork.libcamera.org/api/1.1/patches/12724/?format=json","web_url":"https://patchwork.libcamera.org/patch/12724/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210628122324.14541-2-david.plowman@raspberrypi.com>","date":"2021-06-28T12:23:22","name":"[libcamera-devel,v4,1/3] libcamera: Add support for monochrome sensors","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8bcff97548274fc67394d96332cad2c287bc3e7d","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12724/mbox/","series":[{"id":2184,"url":"https://patchwork.libcamera.org/api/1.1/series/2184/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2184","date":"2021-06-28T12:23:21","name":"Support monochrome raw sensors","version":4,"mbox":"https://patchwork.libcamera.org/series/2184/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12724/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12724/checks/","tags":{},"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 AC0BCC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 12:23:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 10119684DF;\n\tMon, 28 Jun 2021 14:23:29 +0200 (CEST)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E9D86684D3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 14:23:26 +0200 (CEST)","by mail-wm1-x333.google.com with SMTP id u20so6143069wmq.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 05:23:26 -0700 (PDT)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:1ce1:9965:4328:89c4])\n\tby smtp.gmail.com with ESMTPSA id\n\ts62sm19606542wms.13.2021.06.28.05.23.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 28 Jun 2021 05:23:26 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"P0Fr1Zp8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=dQUAlMqJR8YJ6M8zpXZBuaYmsqRmi0LWRoG1purqV1s=;\n\tb=P0Fr1Zp83yvRnS+bgjZUdi9yu5SkC6kdQsDlNSU60KEDn1sN4z1vh9hG4LO1My40hl\n\tr8dQoH3mJVEYt7L8Z5oX5H0cvVeTsSs5jWX78F1rqTXPyg6fBZKeUm38ZMVfDnWFraHJ\n\tQyvwM0KuzEAVGWBH6cTtOslJK6KOgPFBmL36eTfoKuZnh1Ok1D9ltNXOmx+neuxykuKp\n\tFgnVUx1JcJgQWvDAfQTIhOaP+GjDT3wQ4xdIUK0T+TMsVIY5GjoUBfGAgW/n6KeADz6w\n\tqH0f9SD1s1dMpywSjTMcWGVINa67mFPt7M6looS2pPLcuoLUWoSdKrjMamctwlW/nKqt\n\tcT0g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=dQUAlMqJR8YJ6M8zpXZBuaYmsqRmi0LWRoG1purqV1s=;\n\tb=o3K3INxLPootcevKyO76VTCRqwpuPvhy5XZOEKhOmlo0GcHSVKoGoCS1ePqrYQuFCf\n\tbNr25mPfQ9yN/XnNcQ/BPidS4gnJHQd0900x6kBEs4s2weF441y6qziAW0EpoPAdoKhv\n\tVFjkU3qaX/tTjWkwUXGxsBIj5eU8D2f9nZA2a6YG7PH8mTiu5d4E1W8Sq4ej87TZVDZ2\n\tdgS9VyES9xjLGQE7w7GsvrA6gQNKas9EySK7qdywRgN4vIx5BKiPAr6CPmt5MvowDV0+\n\tdQ3WtLy7W2vCwNGVhYuWO/RF1toZVrYZVJP3tbrDSfMczA5KX5xHiOib+ALUiuG+ZA2e\n\tH3pg==","X-Gm-Message-State":"AOAM530yNlEIGkBjOrJTPUpd45ySgJyDS0ARBJWjf9blC8kDi1SncXw0\n\tkTO4k/27cF++dVzS+uvZ8bebaoxe2ovqMw==","X-Google-Smtp-Source":"ABdhPJzTZ7pCqJg+mWkihK0R+GcGKNnYFZ5/dz7mKVGFsbBnn0PFzr3Kd8JFkzVoki28di6e8SQwAA==","X-Received":"by 2002:a05:600c:2248:: with SMTP id\n\ta8mr5330108wmm.188.1624883006493; \n\tMon, 28 Jun 2021 05:23:26 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 28 Jun 2021 13:23:22 +0100","Message-Id":"<20210628122324.14541-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210628122324.14541-1-david.plowman@raspberrypi.com>","References":"<20210628122324.14541-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This commit adds support for monochrome (greyscale) raw sensors. These\nare sensors that have no colour filter array, so all pixels are the\nsame and there are no distinct colour channels.\n\nThese sensors still require many of an ISP's processing stages, such\nas denoise, tone mapping, but not those that involve colours (such as\ndemosaic, or colour matrices).\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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(-)","diff":"diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\nindex 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 {\ndiff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex 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,\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 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);\ndiff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\nindex 104e9aaf..12ecbce5 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 consists of a single colour channel.\n \n ...\n","prefixes":["libcamera-devel","v4","1/3"]}