[{"id":17818,"web_url":"https://patchwork.libcamera.org/comment/17818/","msgid":"<CAEmqJPq3Uayk8hcP5U+tpgHpdFENxR=h-VzCoa5ZY+Q21nHS9A@mail.gmail.com>","date":"2021-06-25T14:54:15","subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: Add support for\n\tmonochrome sensors","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nSorry, I realised this was not tagged by me so...\n\nOn Tue, 15 Jun 2021 at 11:51, David Plowman <david.plowman@raspberrypi.com>\nwrote:\n\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> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n\nThe mono case is a bit awkward, but really we must deal with it.\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\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\n> 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>                 BGGR = 0,\n>                 GBRG = 1,\n>                 GRBG = 2,\n> -               RGGB = 3\n> +               RGGB = 3,\n> +               MONO = 4\n>         };\n>\n>         enum Packing : uint16_t {\n> diff --git a/src/libcamera/bayer_format.cpp\n> 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,\n> BayerFormatComparator> bayerToV4l2{\n>         { { BayerFormat::GBRG, 16, BayerFormat::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },\n>         { { BayerFormat::GRBG, 16, BayerFormat::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },\n>         { { BayerFormat::RGGB, 16, BayerFormat::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },\n> +       { { BayerFormat::MONO, 8, BayerFormat::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_GREY) },\n> +       { { BayerFormat::MONO, 10, BayerFormat::CSI2Packed },\n> 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>\n> mbusCodeToBayer{\n>         { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16,\n> BayerFormat::None } },\n>         { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16,\n> BayerFormat::None } },\n>         { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16,\n> BayerFormat::None } },\n> +       { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::None\n> } },\n> +       { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10,\n> BayerFormat::None } },\n>  };\n>\n>  } /* namespace */\n> @@ -198,9 +204,10 @@ std::string BayerFormat::toString() const\n>                 \"BGGR\",\n>                 \"GBRG\",\n>                 \"GRBG\",\n> -               \"RGGB\"\n> +               \"RGGB\",\n> +               \"MONO\"\n>         };\n> -       if (isValid() && order <= RGGB)\n> +       if (isValid() && order <= MONO)\n>                 result = orderStrings[order];\n>         else\n>                 return \"INVALID\";\n> @@ -280,6 +287,9 @@ BayerFormat BayerFormat::transform(Transform t) const\n>  {\n>         BayerFormat result = *this;\n>\n> +       if (order == MONO)\n> +               return result;\n> +\n>         /*\n>          * Observe that flipping bit 0 of the Order enum performs a\n> horizontal\n>          * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly,\n> diff --git a/src/libcamera/camera_sensor.cpp\n> 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>                 case BayerFormat::RGGB:\n>                         cfa = properties::draft::RGGB;\n>                         break;\n> +               case BayerFormat::MONO:\n> +                       cfa = properties::draft::MONO;\n> +                       break;\n>                 }\n>\n>                 properties_.set(properties::draft::ColorFilterArrangement,\n> cfa);\n> diff --git a/src/libcamera/property_ids.yaml\n> 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\n> 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\n> channel.\n>\n>  ...\n> --\n> 2.20.1\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 DD109C321D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Jun 2021 14:54:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3AFFE684CE;\n\tFri, 25 Jun 2021 16:54:33 +0200 (CEST)","from mail-lf1-x130.google.com (mail-lf1-x130.google.com\n\t[IPv6:2a00:1450:4864:20::130])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BF2C7684C9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jun 2021 16:54:31 +0200 (CEST)","by mail-lf1-x130.google.com with SMTP id a15so8903799lfr.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jun 2021 07:54:31 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"hqawS7Tg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=Bz61zKuMwZvVB7WZDfvN9P/ml5xzRAEruRQt1fHbLTE=;\n\tb=hqawS7TgvodSfUICZWplJ0OplIpd1Lz+fK16UoAn/fAzrC5DMblpu3zp8iGkXU01O2\n\tDw0IVNIrElEr8FiGPYFaJAwx91n+NpM/bDSY8iGwwh7odt8XJrUDQWYhHsp9m/ZANof7\n\tPDbXYOwCMgeh1TQ5rutjNYyUUxnEx+GgBO/ncqT9oWqlu13yX5XNrrocqCCbsgahzZSM\n\tzUyu2tkQ0kki85gWGFEQb3nep20wCKsGyk5qlUfDsl0hOgRdpX4tQzj8J4jdQ26dEUlU\n\tMQQohozXmQpYTh/NlnBGz+fojNRtN2ZSMLpbolNwGRaHwVkJPz6kVfimE6B52TJQYcAN\n\tbMOg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=Bz61zKuMwZvVB7WZDfvN9P/ml5xzRAEruRQt1fHbLTE=;\n\tb=LsBbun/pJIoIubGY3zREv2QfUx/XeiX6fCoDiLipBrZheSSunhpRnP5EK4iDgENJyf\n\teRoahYIOPXzdXhsi5UfyoGA1bRjolXegzqvlP4KSddhLQSzdpJQaIrrSFZweRO3nitEj\n\t0fI/z6UbYw/fGz3gEGCegIzKX6OqZBe2rHbu7SOYAxeBB4UpxkimPIhJdbCdJJg9O2Rw\n\tkSbkvZRqDGI4gOCQ+3hMjiP6Fd4MrqYOWWoXkCfewcBqCrWlfIfhjqTonpzOh/d2eNPQ\n\tTPMOlBJ2agOch5wkYuhGpjGdo8rN+DxonXj1cEilYYZKYZRyCQCznTF0yx1wlsX4Hx8g\n\tKSUA==","X-Gm-Message-State":"AOAM532vKrLv1/7MgGslAzMjG6XPTcaPgNM/JUfjDGWGGBAGKI3YHo5A\n\t/gruSuqWOd0V77I/vzTdMR46RwVj5hDYFhRXQPuqOw==","X-Google-Smtp-Source":"ABdhPJxEre0PmRV50AGl55bBCH/RRazZ2SZUcWW15XLVhr848RCarpc2lV1gGWj+Nzd472fCEkOg3er9NHx6ZR0DD78=","X-Received":"by 2002:a19:5206:: with SMTP id m6mr8179514lfb.210.1624632871068;\n\tFri, 25 Jun 2021 07:54:31 -0700 (PDT)","MIME-Version":"1.0","References":"<20210615105139.16171-1-david.plowman@raspberrypi.com>\n\t<20210615105139.16171-2-david.plowman@raspberrypi.com>","In-Reply-To":"<20210615105139.16171-2-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Fri, 25 Jun 2021 15:54:15 +0100","Message-ID":"<CAEmqJPq3Uayk8hcP5U+tpgHpdFENxR=h-VzCoa5ZY+Q21nHS9A@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"0000000000002bc17905c598517d\"","Subject":"Re: [libcamera-devel] [PATCH 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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]