From patchwork Fri Dec 18 16:47:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10682 X-Patchwork-Delegate: jacopo@jmondi.org 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 B2AA1C0F1A for ; Fri, 18 Dec 2020 16:47:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 040E2615B2; Fri, 18 Dec 2020 17:47:52 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE2E16052C for ; Fri, 18 Dec 2020 17:47:49 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 9C49D2000D for ; Fri, 18 Dec 2020 16:47:49 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:46 +0100 Message-Id: <20201218164754.81422-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/9] libcamera: properties: SensorPhysicalSize draft property 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" Define the 'SensorPhysicalSize' draft property. The property is currently identical to ANDROID_SENSOR_INFO_PHYSICAL_SIZE. Signed-off-by: Jacopo Mondi --- src/libcamera/property_ids.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 64e88f0361d6..f8e32c1bd8cf 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -678,4 +678,15 @@ controls: \todo Turn this property into a "maximum control value" for the ScalerCrop control once "dynamic" controls have been implemented. + # ---------------------------------------------------------------------------- + # Draft properties section + + - SensorPhysicalSize: + type: float + size: [2] + draft: true + description: | + The physical dimensions of the full pixel array in millimeters. + Currently identical to ANDROID_SENSOR_INFO_PHYSICAL_SIZE. + ... From patchwork Fri Dec 18 16:47:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10683 X-Patchwork-Delegate: jacopo@jmondi.org 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 CFECBC0F1A for ; Fri, 18 Dec 2020 16:47:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A53B3619AF; Fri, 18 Dec 2020 17:47:52 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C8B16052C for ; Fri, 18 Dec 2020 17:47:50 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 0A7DF20012 for ; Fri, 18 Dec 2020 16:47:49 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:47 +0100 Message-Id: <20201218164754.81422-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/9] libcamera: properties: ColorFilterArrangement draft property 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" Define the 'ColorFilterArrangement' draft property. The property is currently identical to ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- This patch introdues the following warnings property_ids.cpp:716: warning: no matching class member found for libcamera::properties::draft::ColorFilterArrangementEnum::RGGB property_ids.cpp:719: warning: no matching class member found for libcamera::properties::draft::ColorFilterArrangementEnum::GRBG property_ids.cpp:722: warning: no matching class member found for libcamera::properties::draft::ColorFilterArrangementEnum::GBRG property_ids.cpp:725: warning: no matching class member found for libcamera::properties::draft::ColorFilterArrangementEnum::BGGR Removing one letter from the identifiers, or adding one, makes the warning disapper: -- 2.29.2 diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 411d5b2a398d..8a19b989e6c4 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -697,16 +697,16 @@ controls: top-left 2x2 section of the sensor, in reading order. Currently identical to ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT. enum: - - name: RGGB + - name: RGGBZ value: 0 description: RGGB color filter arrangement - - name: GRBG + - name: GRBGZ value: 1 description: GRBG color filter arrangement - - name: GBRG + - name: GBRGZ value: 2 description: GBRG color filter arrangement - - name: BGGR + - name: BGGRZ value: 3 description: BGGR color filter arrangement - name: RGB A Doxygen bug maybe ? --- src/libcamera/property_ids.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index f8e32c1bd8cf..411d5b2a398d 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -689,4 +689,30 @@ controls: The physical dimensions of the full pixel array in millimeters. Currently identical to ANDROID_SENSOR_INFO_PHYSICAL_SIZE. + - ColorFilterArrangement: + type: int32_t + draft: true + description: | + The arrangement of color filters on sensor; represents the colors in the + top-left 2x2 section of the sensor, in reading order. Currently + identical to ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT. + enum: + - name: RGGB + value: 0 + description: RGGB color filter arrangement + - name: GRBG + value: 1 + description: GRBG color filter arrangement + - name: GBRG + value: 2 + description: GBRG color filter arrangement + - name: BGGR + value: 3 + description: BGGR color filter arrangement + - name: RGB + value: 4 + description: | + Sensor is not Bayer; output has 3 16-bit values for each pixel, + instead of just 1 16-bit value per pixel. + ... From patchwork Fri Dec 18 16:47:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10684 X-Patchwork-Delegate: jacopo@jmondi.org 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 87690C0F1A for ; Fri, 18 Dec 2020 16:47:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B78B61599; Fri, 18 Dec 2020 17:47:54 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A2DAF61598 for ; Fri, 18 Dec 2020 17:47:50 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 63AF220009 for ; Fri, 18 Dec 2020 16:47:50 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:48 +0100 Message-Id: <20201218164754.81422-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/9] libcamera: bayer_format: Add support for mbus codes 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" The existing implementation of the BayerFormat class supports converting a V4L2PixelFormat to a BayerFormat and vice-versa. Expand the class by adding support for converting a media bus code to a BayerFormat instance, by providing a conversion table and a dedicated constructor. Expand the number of supported compression and expand the documentation. Do not provide support for converting a BayerFormat to a media bus code as the feature is currently not required. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/bayer_format.h | 3 ++ src/libcamera/bayer_format.cpp | 66 ++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 4280b76b016f..7d7539e275ff 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -30,6 +30,8 @@ public: None = 0, CSI2Packed = 1, IPU3Packed = 2, + ALAW8Compression = 3, + DPCM8Compression = 4, }; constexpr BayerFormat() @@ -43,6 +45,7 @@ public: } explicit BayerFormat(V4L2PixelFormat v4l2Format); + explicit BayerFormat(unsigned int mbusCode); bool isValid() const { return bitDepth != 0; } std::string toString() const; diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index c42792ff1948..a4eba4592bfe 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -8,6 +8,9 @@ #include "libcamera/internal/bayer_format.h" #include +#include + +#include #include @@ -45,7 +48,8 @@ namespace libcamera { /** * \enum BayerFormat::Packing - * \brief Different types of packing that can be applied to a BayerFormat + * \brief Different types of packing or compressions that can be applied to a + * BayerFormat * * \var BayerFormat::None * \brief No packing @@ -53,6 +57,10 @@ namespace libcamera { * \brief Format uses MIPI CSI-2 style packing * \var BayerFormat::IPU3Packed * \brief Format uses IPU3 style packing + * \var BayerFormat::ALAW8Compression + * \brief Format uses ALAW8 compression + * \var BayerFormat::DPCM8Compression + * \brief Format uses DPCM8 compression */ namespace { @@ -140,6 +148,41 @@ const std::map bayerToV4l2{ { { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) }, }; +const std::unordered_map mbusCodeToBayer{ + { MEDIA_BUS_FMT_SBGGR8_1X8, { BayerFormat::BGGR, 8, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGBRG8_1X8, { BayerFormat::GBRG, 8, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGRBG8_1X8, { BayerFormat::GRBG, 8, BayerFormat::None } }, + { MEDIA_BUS_FMT_SRGGB8_1X8, { BayerFormat::RGGB, 8, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, { BayerFormat::BGGR, 8, BayerFormat::ALAW8Compression } }, + { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, { BayerFormat::GBRG, 8, BayerFormat::ALAW8Compression } }, + { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, { BayerFormat::GRBG, 8, BayerFormat::ALAW8Compression } }, + { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, { BayerFormat::RGGB, 8, BayerFormat::ALAW8Compression } }, + { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, { BayerFormat::BGGR, 8, BayerFormat::DPCM8Compression } }, + { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, { BayerFormat::GBRG, 8, BayerFormat::DPCM8Compression } }, + { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, { BayerFormat::GRBG, 8, BayerFormat::DPCM8Compression } }, + { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, { BayerFormat::RGGB, 8, BayerFormat::DPCM8Compression } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, { BayerFormat::BGGR, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, { BayerFormat::BGGR, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, { BayerFormat::BGGR, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, { BayerFormat::BGGR, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR10_1X10, { BayerFormat::BGGR, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGBRG10_1X10, { BayerFormat::GBRG, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGRBG10_1X10, { BayerFormat::GRBG, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SRGGB10_1X10, { BayerFormat::RGGB, 10, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR12_1X12, { BayerFormat::BGGR, 12, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGBRG12_1X12, { BayerFormat::GBRG, 12, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGRBG12_1X12, { BayerFormat::GRBG, 12, BayerFormat::None } }, + { MEDIA_BUS_FMT_SRGGB12_1X12, { BayerFormat::RGGB, 12, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR14_1X14, { BayerFormat::BGGR, 14, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGBRG14_1X14, { BayerFormat::GBRG, 14, BayerFormat::None } }, + { MEDIA_BUS_FMT_SGRBG14_1X14, { BayerFormat::GRBG, 14, BayerFormat::None } }, + { MEDIA_BUS_FMT_SRGGB14_1X14, { BayerFormat::RGGB, 14, BayerFormat::None } }, + { MEDIA_BUS_FMT_SBGGR16_1X16, { BayerFormat::BGGR, 16, BayerFormat::None } }, + { 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 } }, +}; + } /* namespace */ /** @@ -169,6 +212,22 @@ BayerFormat::BayerFormat(V4L2PixelFormat v4l2Format) *this = it->second; } +/** + * \brief Construct a BayerFormat from a media bus code + * \param[in] mbusCode The media bus code to convert into a BayerFormat + * + * The media bus code numeric identifiers are defined by the V4L2 specification. + */ +BayerFormat::BayerFormat(unsigned int mbusCode) + : order(BGGR), packing(None) +{ + const auto it = mbusCodeToBayer.find(mbusCode); + if (it == mbusCodeToBayer.end()) + bitDepth = 0; + else + *this = it->second; +} + /** * \fn BayerFormat::isValid() * \brief Return whether a BayerFormat is valid @@ -258,6 +317,11 @@ BayerFormat BayerFormat::transform(Transform t) const /** * \var BayerFormat::bitDepth * \brief The bit depth of the samples in the Bayer pattern + * + * For formats using compression schemes such as Packing::ALAW8Compression or + * Packing::DPCM8Compression, the bitDepth value refers to the size of the + * sample when transmitted on the wire or stored into memory. The resulting + * images need to be de-compressed to be viewed properly. */ /** From patchwork Fri Dec 18 16:47:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10685 X-Patchwork-Delegate: jacopo@jmondi.org 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 B060BC0F1A for ; Fri, 18 Dec 2020 16:47:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BFE361FF6; Fri, 18 Dec 2020 17:47:56 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F3E5061596 for ; Fri, 18 Dec 2020 17:47:50 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id C180A20009 for ; Fri, 18 Dec 2020 16:47:50 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:49 +0100 Message-Id: <20201218164754.81422-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/9] libcamera: camera_sensor: Register ColorFilterArrangement 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" Inspect the list of media bus codes supported by the camera sensor in order to deduce the color filter arrangement and register the ColorFilterArrangement draft property. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 36 +++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 1628ba9c892b..2b78eb4cb530 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -17,6 +17,7 @@ #include +#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/formats.h" #include "libcamera/internal/sysfs.h" #include "libcamera/internal/utils.h" @@ -178,10 +179,6 @@ int CameraSensor::init() if (ret < 0) return ret; - ret = initProperties(); - if (ret) - return ret; - /* Enumerate, sort and cache media bus codes and sizes. */ formats_ = subdev_->formats(pad_); if (formats_.empty()) { @@ -210,6 +207,10 @@ int CameraSensor::init() */ resolution_ = sizes_.back(); + ret = initProperties(); + if (ret) + return ret; + return 0; } @@ -307,6 +308,33 @@ int CameraSensor::initProperties() properties_.set(properties::PixelArrayActiveAreas, { crop }); } + /* Color filter arrangement, default to the generic 'RGB' */ + int32_t cfa = properties::draft::RGB; + for (const auto &format : formats_) { + unsigned int mbusCode = format.first; + BayerFormat bayerFormat(mbusCode); + if (!bayerFormat.isValid()) + continue; + + /* Report the CFA ordering of the first valid RAW Bayer format. */ + switch (bayerFormat.order) { + case BayerFormat::BGGR: + cfa = properties::draft::BGGR; + break; + case BayerFormat::GBRG: + cfa = properties::draft::GBRG; + break; + case BayerFormat::GRBG: + cfa = properties::draft::GRBG; + break; + case BayerFormat::RGGB: + cfa = properties::draft::RGGB; + break; + } + break; + } + properties_.set(properties::draft::ColorFilterArrangement, cfa); + return 0; } From patchwork Fri Dec 18 16:47:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10686 X-Patchwork-Delegate: jacopo@jmondi.org 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 12A82C0F1B for ; Fri, 18 Dec 2020 16:47:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7F9F61D25; Fri, 18 Dec 2020 17:47:56 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 57D1F6052C for ; Fri, 18 Dec 2020 17:47:51 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 257DE20009 for ; Fri, 18 Dec 2020 16:47:50 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:50 +0100 Message-Id: <20201218164754.81422-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/9] android: camera_device: Report ColorFilterArrangement 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" Report the ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT property inspecting the draft property reported by the libcamera Camera. Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 1c7bf4ed8073..bad8a51ae7f7 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -897,7 +897,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, &sensitivityRange, 2); + /* Report the color filter arrangement: default it to GRBG. */ uint16_t filterArr = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG; + if (properties.contains(properties::draft::ColorFilterArrangement)) + filterArr = properties.get(properties::draft::ColorFilterArrangement); staticMetadata_->addEntry(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, &filterArr, 1); From patchwork Fri Dec 18 16:47:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10687 X-Patchwork-Delegate: jacopo@jmondi.org 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 91B39C0F1A for ; Fri, 18 Dec 2020 16:47:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40083615D2; Fri, 18 Dec 2020 17:47:57 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B08E661597 for ; Fri, 18 Dec 2020 17:47:51 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 7EA0720008 for ; Fri, 18 Dec 2020 16:47:51 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:51 +0100 Message-Id: <20201218164754.81422-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/9] libcamera: controls: List-initialize ControlList 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" Provide an additional constructor to the ControlList class to allow the construction of instances of the class with the usage of an std::intializer_list<> of ControlId and an associated ControlValue. The new constructor allows to intialize a ControlList instance at construction time, allowing the declaration of populated ControlList instances. Signed-off-by: Jacopo Mondi --- include/libcamera/controls.h | 2 ++ src/libcamera/controls.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3634dc431618..4df6615a3c7b 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -348,9 +348,11 @@ class ControlList { private: using ControlListMap = std::unordered_map; + using ControlsMap = std::unordered_map; public: ControlList(); + ControlList(std::initializer_list controls); ControlList(const ControlIdMap &idmap, ControlValidator *validator = nullptr); ControlList(const ControlInfoMap &infoMap, ControlValidator *validator = nullptr); diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index c58ed3946f3b..7650057dde7d 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -797,6 +797,17 @@ ControlList::ControlList() { } +/** + * \brief Construct a ControlList with a list of values + * \param[in] controls The controls and associated values to initialize the list with + */ +ControlList::ControlList(std::initializer_list controls) + : ControlList() +{ + for (const auto &ctrl : controls) + set(ctrl.first->id(), ctrl.second); +} + /** * \brief Construct a ControlList with an optional control validator * \param[in] idmap The ControlId map for the control list target object From patchwork Fri Dec 18 16:47:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10688 X-Patchwork-Delegate: jacopo@jmondi.org 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 6D45AC0F1B for ; Fri, 18 Dec 2020 16:47:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 363DD615AC; Fri, 18 Dec 2020 17:47:58 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71AD8615AC for ; Fri, 18 Dec 2020 17:47:52 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 39BDD20003 for ; Fri, 18 Dec 2020 16:47:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:53 +0100 Message-Id: <20201218164754.81422-9-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 8/9] libcamera: camera_sensor: Register static properties 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" Register static properties, retrieved inspecting the sensor database, in the CameraSensor class. Static properties are overridden by properties retrieved from the kernel interface at run-time if any overlap between the two sets occurs. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index f80d836161a5..1b3a17f2ce77 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -69,6 +69,7 @@ protected: private: int generateId(); + void initStaticProperties(); int initProperties(); const MediaEntity *entity_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 2b78eb4cb530..18079da2e4b5 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -19,6 +19,7 @@ #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/formats.h" +#include "libcamera/internal/sensor_database.h" #include "libcamera/internal/sysfs.h" #include "libcamera/internal/utils.h" @@ -214,6 +215,21 @@ int CameraSensor::init() return 0; } +void CameraSensor::initStaticProperties() +{ + if (!sensorDatabase.contains(model_)) { + LOG(CameraSensor, Info) + << "No static properties available for '" << model_ << "'"; + LOG(CameraSensor, Info) + << "Please consider updating the sensor database"; + return; + } + + const ControlList &staticProperties = sensorDatabase.properties(model_); + for (const auto &prop : staticProperties) + properties_.set(prop.first, prop.second); +} + int CameraSensor::initProperties() { /* @@ -251,7 +267,10 @@ int CameraSensor::initProperties() if (ret) return ret; - /* Retrieve and store the camera sensor properties. */ + /* Initialize the static properties from the sensor database. */ + initStaticProperties(); + + /* Retrieve and register properties from the kernel interface. */ const ControlInfoMap &controls = subdev_->controls(); int32_t propertyValue; From patchwork Fri Dec 18 16:47:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10689 X-Patchwork-Delegate: jacopo@jmondi.org 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 C8583C0F1A for ; Fri, 18 Dec 2020 16:47:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 95C0862000; Fri, 18 Dec 2020 17:47:58 +0100 (CET) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C5FD9619E2 for ; Fri, 18 Dec 2020 17:47:52 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 914F920003 for ; Fri, 18 Dec 2020 16:47:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 18 Dec 2020 17:47:54 +0100 Message-Id: <20201218164754.81422-10-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218164754.81422-1-jacopo@jmondi.org> References: <20201218164754.81422-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 9/9] android: camera_device: Report sensor physical size 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" Report the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property inspecting the draft SensorPhysicalSize property reported by libcamera. Maintain a default value to support pipelines that do not register the camera property. Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index bad8a51ae7f7..f50a539e907d 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -919,12 +919,20 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() testPatterModes.data(), testPatterModes.size()); - std::vector physicalSize = { - 2592, 1944, - }; + std::vector physicalSize(2); + if (properties.contains(properties::draft::SensorPhysicalSize)) { + const Span data = + properties.get>(properties::draft::SensorPhysicalSize); + physicalSize = { data[0], data[1] }; + } else { + /* + * \todo Drop the default once all pipelines report the + * property. + */ + physicalSize = { 2.592, 1.944 }; + } staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, - physicalSize.data(), - physicalSize.size()); + physicalSize.data(), physicalSize.size()); uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,