From patchwork Fri Jun 18 22:04:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12656 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0D9BEC3218 for ; Fri, 18 Jun 2021 22:04:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14FD868948; Sat, 19 Jun 2021 00:04:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nzf8YnIU"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 00A3E6050D for ; Sat, 19 Jun 2021 00:04:34 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id l9so6472302wms.1 for ; Fri, 18 Jun 2021 15:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hj6B0uf2+XfEkXDYnx6lc1j20xQ5DPDqDQm8tdePJ70=; b=nzf8YnIUqQmgtPAzAHNwl39UKcFkwKV94Og69eXmYEU8hebg54oYihKIeA++gbd8sX G71g/HPNwRKcY/6kwT9BZdesYoNwFJ6m73LoQalv3CrjWS+5Pggz9l+Tq4Wo/x8r9QOU R7B/OTi9i7wTaTTTbz5pKPGERSIcxbiUGAo3/hsIHrGIHkt39FIu8IT5Hmky5AhfRtIw HiLDMEiS12fUTOU+hwrb8Q5B66AILtp9ukd7fMt/sgPazZjdd2Lvix77Q0sMXVc8Km20 dcXRFy3cK5gaCDQK8jGpXD82Zbi1eft6xv1K2fEbmFdv+JkzoYEorIThdjPgraqBWsfe EbVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hj6B0uf2+XfEkXDYnx6lc1j20xQ5DPDqDQm8tdePJ70=; b=JiCUHj7qv6os9LR/we6nYNDYxLW+Rn2QwH57ylH7u292tgyCMbN1w9hfY5hWfYUEcg Mf4BSMXyKGggBQyBfG1vxlgDjLjvpNBvNvcVnSmoIZU5Vld6csmL1HHqJEeT6yxUS/N/ NEvox7vY1q3U8TOV+8Z3qTfkE+Be+m/qcoV0abr5osqImZHqGevzRf2pLHQaUZXPHqqe 8Z+bow69/tJN6GNrptGFK4wzUhmYejA0qJoPPfMzi7HHlqJ1aowvs9x/QNbX+q/l82mf wIINkO4tYCSHYI7j6MoopFzVQffhaUV12Liwzd5hvvML7jvsHCujRtahb5CGvuWusQbo 3jug== X-Gm-Message-State: AOAM530jzUU8cCbqm2hv4qU1jC+l0RyppMwCljEMo7Ntcp7q7+ZO7lFX tN8+Xt4m86jWhFCFQGFtIQ73TDIIhCInYthQ X-Google-Smtp-Source: ABdhPJyT4Kzxt37LuboXd7PH5W2FfJTl9BQWd+Kz9OMoWHxQ8xH0ifWJtozh19Hefo7D9EZBrrKqzg== X-Received: by 2002:a1c:ed14:: with SMTP id l20mr13491892wmh.20.1624053873449; Fri, 18 Jun 2021 15:04:33 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id z6sm6966322wrl.15.2021.06.18.15.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 15:04:32 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Jun 2021 23:04:28 +0100 Message-Id: <20210618220430.31457-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210618220430.31457-1-david.plowman@raspberrypi.com> References: <20210618220430.31457-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/3] libcamera: Add support for monochrome sensors X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This commit adds support for monochrome (greyscale) raw sensors. These are sensors that have no colour filter array, so all pixels are the same and there are no distinct colour channels. These sensors still require many of an ISP's processing stages, such as denoise, tone mapping, but not those that involve colours (such as demosaic, or colour matrices). Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/bayer_format.h | 3 ++- src/libcamera/bayer_format.cpp | 14 ++++++++++++-- src/libcamera/camera_sensor.cpp | 3 +++ src/libcamera/property_ids.yaml | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 5b8c1dc9..723382d4 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -23,7 +23,8 @@ public: BGGR = 0, GBRG = 1, GRBG = 2, - RGGB = 3 + RGGB = 3, + MONO = 4 }; enum Packing : uint16_t { diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index ed61202c..11355f14 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -45,6 +45,8 @@ namespace libcamera { * \brief G then R on the first row, B then G on the second row. * \var BayerFormat::RGGB * \brief R then G on the first row, G then B on the second row. + * \var BayerFormat::MONO + * \brief Monochrome image data, there is no colour filter array. */ /** @@ -111,6 +113,8 @@ const std::map bayerToV4l2{ { { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) }, { { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) }, { { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) }, + { { BayerFormat::MONO, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) }, + { { BayerFormat::MONO, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) }, }; const std::unordered_map mbusCodeToBayer{ @@ -146,6 +150,8 @@ const std::unordered_map mbusCodeToBayer{ { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::None } }, + { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::None } }, + { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::None } }, }; } /* namespace */ @@ -198,9 +204,10 @@ std::string BayerFormat::toString() const "BGGR", "GBRG", "GRBG", - "RGGB" + "RGGB", + "MONO" }; - if (isValid() && order <= RGGB) + if (isValid() && order <= MONO) result = orderStrings[order]; else return "INVALID"; @@ -280,6 +287,9 @@ BayerFormat BayerFormat::transform(Transform t) const { BayerFormat result = *this; + if (order == MONO) + return result; + /* * Observe that flipping bit 0 of the Order enum performs a horizontal * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly, diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 3e135353..fb67c15a 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -427,6 +427,9 @@ int CameraSensor::initProperties() case BayerFormat::RGGB: cfa = properties::draft::RGGB; break; + case BayerFormat::MONO: + cfa = properties::draft::MONO; + break; } properties_.set(properties::draft::ColorFilterArrangement, cfa); diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 104e9aaf..12ecbce5 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -706,5 +706,9 @@ controls: description: | Sensor is not Bayer; output has 3 16-bit values for each pixel, instead of just 1 16-bit value per pixel. + - name: MONO + value: 5 + description: | + Sensor is not Bayer; output consists of a single colour channel. ...