From patchwork Thu Jun 10 08:25:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12545 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 C5B0CBD78E for ; Thu, 10 Jun 2021 08:25:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2358C6892F; Thu, 10 Jun 2021 10:25:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mjIFKA5t"; dkim-atps=neutral Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 770F6602C5 for ; Thu, 10 Jun 2021 10:25:46 +0200 (CEST) Received: by mail-pl1-x634.google.com with SMTP id 69so595150plc.5 for ; Thu, 10 Jun 2021 01:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Kp7vtkneKHWsTVr8H9RoZEqk8QShPlfAx9tM5R6qx14=; b=mjIFKA5tl5yMYk48QwoSc0BCWBHh05UurqyVwIt8EpvmSBm+SfTopr3Dcjyo7cZund f4NAC+J/wwX3WMfaMmjiW1BjhMuoxXX/1kxSDiq1C6bhWiOhRZEqyO3lBP00xXUctAb6 5gV0fBFS8mpPSLUBNCLGkTohl02Fk65Izk29E= 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:mime-version :content-transfer-encoding; bh=Kp7vtkneKHWsTVr8H9RoZEqk8QShPlfAx9tM5R6qx14=; b=sd9ZWxaOaIUEv3wmR3NbTeSkmj/mPCN9YyHhz2LTJAL/gs6tLj8LXOo39yPo0VmI+a t0IAsi2V94t5scZYR8sCK1azMcVrzKS+n5eY1bJtdpD7eTt3VCigvZVFbUu/cE66I7Fe C7hTJOv5xGjicakPZB2MScn3J8CPik4t6XC0QTuVvKeHqUpfaJTFmAUexXLryUpMEE2q Lk7xJm+Bfcl6zgnMRy9XCxnHGMbvV1OLrQAva5czwwMJI7tJGAJ59bln4twvlXqV64x/ omoCLC9XVR+kgN4yo2jHZets6b0sSTonnIDeBmUtgNAWA/d/8XDY93UbYNE97ZZRPk2a vJyA== X-Gm-Message-State: AOAM532C4BZ3biUn3IyaKzfO/pqmnqynzq3WhROObjmCLi8LCxFjtTSk tzTYqhtcedy65M9pVhYn3DgEeDaFjwt07Q== X-Google-Smtp-Source: ABdhPJzs381kdWohINj9jtvLVYmaqrHNk4ZabF6IQL+A+uKPWSO1zupySStn1OsuYr4Ae/BCe5DdEQ== X-Received: by 2002:a17:903:2289:b029:109:8cf1:7d9a with SMTP id b9-20020a1709032289b02901098cf17d9amr3809543plh.53.1623313544763; Thu, 10 Jun 2021 01:25:44 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:44 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:34 +0900 Message-Id: <20210610082539.529739-1-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 1/6] libcamera: controls: Add sensor test pattern mode 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 control is used to report available sensor test pattern modes and also specify the mode to sensor. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/control_ids.yaml | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index f62ade48..d92f29f5 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -622,4 +622,62 @@ controls: detection, additional format conversions etc) count as an additional pipeline stage. + - TestPatternMode: + type: int32_t + draft: true + description: | + Control to select the test pattern mode. Currently identical to + ANDROID_SENSOR_TEST_PATTERN_MODE. + enum: + - name: TestPatternModeOff + value: 0 + description: | + No test pattern mode is used. The camera device returns frames from + the image sensor. + - name: TestPatternModeSolidColor + value: 1 + description: | + Each pixel in [R, G_even, G_odd, B] is replaced by its respective + color channel provided in test pattern data. + \todo Add control for test pattern data. + - name: TestPatternModeColorBars + value: 2 + description: | + All pixel data is replaced with an 8-bar color pattern. The vertical + bars (left-to-right) are as follows; white, yellow, cyan, green, + magenta, red, blue and black. Each bar should take up 1/8 of the + sensor pixel array width. When this is not possible, the bar size + should be rounded down to the nearest integer and the pattern can + repeat on the right side. Each bar's height must always take up the + full sensor pixel array height. + - name: TestPatternModeColorBarsFadeToGray + value: 3 + description: | + The test pattern is similar to TestPatternModeColorBars, + except that each bar should start at its specified color at the top + and fade to gray at the bottom. Furthermore each bar is further + subdevided into a left and right half. The left half should have a + smooth gradient, and the right half should have a quantized + gradient. In particular, the right half's should consist of blocks + of the same color for 1/16th active sensor pixel array width. The + least significant bits in the quantized gradient should be copied + from the most significant bits of the smooth gradient. The height of + each bar should always be a multiple of 128. When this is not the + case, the pattern should repeat at the bottom of the image. + - name: TestPatternModePn9 + value: 4 + description: | + All pixel data is replaced by a pseudo-random sequence generated + from a PN9 512-bit sequence (typically implemented in hardware with + a linear feedback shift register). The generator should be reset at + the beginning of each frame, and thus each subsequent raw frame with + this test pattern should be exactly the same as the last. + - name: TestPatternModeCustom1 + value: 256 + description: | + The first custom test pattern. All custom patterns that are + available only on this camera device are at least this numeric + value. All of the custom test patterns will be static (that is the + raw image must not vary from frame to frame). + ... From patchwork Thu Jun 10 08:25:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12546 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 B9DC0BD78E for ; Thu, 10 Jun 2021 08:25:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A4AF6892B; Thu, 10 Jun 2021 10:25:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MyeSSwbE"; dkim-atps=neutral Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 48AAF602C5 for ; Thu, 10 Jun 2021 10:25:48 +0200 (CEST) Received: by mail-pj1-x102c.google.com with SMTP id h16so3205220pjv.2 for ; Thu, 10 Jun 2021 01:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aXPp9utSmFRdgbvjmka9zrFr9zhgWAhDypHo5gIOfiE=; b=MyeSSwbECIaZfTeiP+bZnOTTob9t5jEYG7+veB7lhmDGrtmYUqBVCO7/6eGz72D2Yl t5pVP8GdzOrYXl3lFH0VH4djk7kC6Tr5kDqqspWYko5wqmJRycgsajSikfSnJTr6vyFp 8fOs1Jf69E2iLIrt6vHu/ipL9EnMf8bzXhvZM= 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=aXPp9utSmFRdgbvjmka9zrFr9zhgWAhDypHo5gIOfiE=; b=O3yD7dG4ZKH9FboF1PfrO8cV9fYn734DPRIJcWZfjsk14M7+xW234J0krJ5Po1XQnQ FTpFPaieWlnsa9LcaAqHrElLCdeLLWJWJrlzBhF63nNku97Vx/HcHFITlCeDKPpeAZ7+ GSbu1k0aSx6+Ng0jRrSvJtgtneKm8Az8E/N3pddYPIjWapq9vqTszcAo+tY6e1AJFAJf 7hTQJa6SNRXdCy2CyCvBgRc8ErQIsJ0aRtBN2dI+4cY6+A0r7baUZ4BqabBgJpbHVusF SIovwehnzWBnKQeZ/ZtUuGAXMwooNNgKxVbVfjcEAZpY8suD39mkYYaNvINJJEMZqLeH US8g== X-Gm-Message-State: AOAM530g+Hc5blemwbUwVds4XkraXLFhjPUUNExvFM1+oNYGzYN/C7Ze VBbrKU95P37g+InZexi+2959jjlyuyyy/w== X-Google-Smtp-Source: ABdhPJxqI+lhoglcy0wuj0fd4qgzrKkiojLKuPTjLFvs/DESNQG2Z3JYioyjrPq1uZl0LBbja4Vl0g== X-Received: by 2002:a17:90a:4dc1:: with SMTP id r1mr2203353pjl.192.1623313546565; Thu, 10 Jun 2021 01:25:46 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:46 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:35 +0900 Message-Id: <20210610082539.529739-2-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610082539.529739-1-hiroh@chromium.org> References: <20210610082539.529739-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 2/6] libcamera: V4L2Device: Support v4l2 menu control 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 adds a support of v4l2 menu. The control info for v4l2 menu contains indices without names and 64bit values of querymenu. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/v4l2_device.h | 5 + src/libcamera/v4l2_device.cpp | 186 +++++++++++++++-------- 2 files changed, 127 insertions(+), 64 deletions(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index b82e2a14..c318e976 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -56,6 +56,11 @@ protected: int fd() const { return fd_; } private: + static ControlType v4l2CtrlType(uint32_t ctrlType); + static std::unique_ptr v4l2ControlId(const v4l2_query_ext_ctrl &ctrl); + ControlInfo v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl); + ControlInfo v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl); + void listControls(); void updateControls(ControlList *ctrls, Span v4l2Ctrls); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index b39c6266..cda3769a 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -32,69 +32,6 @@ LOG_DEFINE_CATEGORY(V4L2) namespace { -ControlType v4l2CtrlType(uint32_t ctrlType) -{ - switch (ctrlType) { - case V4L2_CTRL_TYPE_U8: - return ControlTypeByte; - - case V4L2_CTRL_TYPE_BOOLEAN: - return ControlTypeBool; - - case V4L2_CTRL_TYPE_INTEGER: - return ControlTypeInteger32; - - case V4L2_CTRL_TYPE_INTEGER64: - return ControlTypeInteger64; - - case V4L2_CTRL_TYPE_MENU: - case V4L2_CTRL_TYPE_BUTTON: - case V4L2_CTRL_TYPE_BITMASK: - case V4L2_CTRL_TYPE_INTEGER_MENU: - /* - * More precise types may be needed, for now use a 32-bit - * integer type. - */ - return ControlTypeInteger32; - - default: - return ControlTypeNone; - } -} - -std::unique_ptr v4l2ControlId(const v4l2_query_ext_ctrl &ctrl) -{ - const size_t len = strnlen(ctrl.name, sizeof(ctrl.name)); - const std::string name(static_cast(ctrl.name), len); - const ControlType type = v4l2CtrlType(ctrl.type); - - return std::make_unique(ctrl.id, name, type); -} - -ControlInfo v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl) -{ - switch (ctrl.type) { - case V4L2_CTRL_TYPE_U8: - return ControlInfo(static_cast(ctrl.minimum), - static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); - - case V4L2_CTRL_TYPE_BOOLEAN: - return ControlInfo(static_cast(ctrl.minimum), - static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); - - case V4L2_CTRL_TYPE_INTEGER64: - return ControlInfo(static_cast(ctrl.minimum), - static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); - - default: - return ControlInfo(static_cast(ctrl.minimum), - static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); - } -} } /* namespace */ /** @@ -524,6 +461,121 @@ int V4L2Device::ioctl(unsigned long request, void *argp) * \return The V4L2 device file descriptor, -1 if the device node is not open */ +/** + * \brief Retrieve ControlType for V4L2 control type + * \param[in] ctrlType V4L2 control type + * + * \return ControlType for \a ctrlType + */ +ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType) +{ + switch (ctrlType) { + case V4L2_CTRL_TYPE_U8: + return ControlTypeByte; + + case V4L2_CTRL_TYPE_BOOLEAN: + return ControlTypeBool; + + case V4L2_CTRL_TYPE_INTEGER: + return ControlTypeInteger32; + + case V4L2_CTRL_TYPE_INTEGER64: + return ControlTypeInteger64; + + case V4L2_CTRL_TYPE_MENU: + case V4L2_CTRL_TYPE_BUTTON: + case V4L2_CTRL_TYPE_BITMASK: + case V4L2_CTRL_TYPE_INTEGER_MENU: + /* + * More precise types may be needed, for now use a 32-bit + * integer type. + */ + return ControlTypeInteger32; + + default: + return ControlTypeNone; + } +} + +/** + * \brief Create ControlId for v4l2_query_ext_ctrl + * \param[in] ctrl v4l2_query_ext_ctrl + * + * \return ControlId for \a ctrl + */ +std::unique_ptr V4L2Device::v4l2ControlId(const v4l2_query_ext_ctrl &ctrl) +{ + const size_t len = strnlen(ctrl.name, sizeof(ctrl.name)); + const std::string name(static_cast(ctrl.name), len); + const ControlType type = v4l2CtrlType(ctrl.type); + + return std::make_unique(ctrl.id, name, type); +} + +/** + * \brief Create ControlInfo from v4l2_query_ext_ctrl + * \param[in] ctrl v4l2_query_ext_ctrl + * + * \return ControlInfo from \a v4l2_query_ext_ctrl + */ +ControlInfo V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl) +{ + switch (ctrl.type) { + case V4L2_CTRL_TYPE_U8: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + + case V4L2_CTRL_TYPE_BOOLEAN: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + + case V4L2_CTRL_TYPE_INTEGER64: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + + case V4L2_CTRL_TYPE_INTEGER_MENU: + case V4L2_CTRL_TYPE_MENU: + return v4l2MenuControlInfo(ctrl); + + default: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + } +} + +/** + * \brief Create ControlInfo for a V4L2 menu control + * \param[in] ctrl The v4l2_query_ext_ctrl that represents a menu + * + * The created ControlInfo contains indices acquired by VIDIOC_QUERYMENU. + * + * \return ControlInfo for a V4L2 menu control + */ +ControlInfo V4L2Device::v4l2MenuControlInfo(const struct v4l2_query_ext_ctrl &ctrl) +{ + std::vector indices; + struct v4l2_querymenu menu = {}; + menu.id = ctrl.id; + + if (ctrl.minimum < 0) + return ControlInfo(); + + for (int32_t index = ctrl.minimum; index <= ctrl.maximum; ++index) { + menu.index = index; + if (ioctl(VIDIOC_QUERYMENU, &menu) != 0) + continue; + + indices.push_back(index); + } + + return ControlInfo(indices, + ControlValue(static_cast(ctrl.default_value))); +} + /* * \brief List and store information about all controls supported by the * V4L2 device @@ -533,7 +585,6 @@ void V4L2Device::listControls() ControlInfoMap::Map ctrls; struct v4l2_query_ext_ctrl ctrl = {}; - /* \todo Add support for menu controls. */ while (1) { ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND; @@ -562,6 +613,9 @@ void V4L2Device::listControls() continue; } + LOG(V4L2, Debug) << "Control: " << ctrl.name + << " (" << utils::hex(ctrl.id) << ")"; + controlIds_.emplace_back(v4l2ControlId(ctrl)); controlInfo_.emplace(ctrl.id, ctrl); @@ -630,6 +684,10 @@ void V4L2Device::updateControls(ControlList *ctrls, value.set(v4l2Ctrl.value64); break; + case ControlTypeInteger32: + value.set(v4l2Ctrl.value); + break; + case ControlTypeByte: /* * No action required, the VIDIOC_[GS]_EXT_CTRLS ioctl From patchwork Thu Jun 10 08:25:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12547 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 284AFBD78E for ; Thu, 10 Jun 2021 08:25:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D203A6892C; Thu, 10 Jun 2021 10:25:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gr1ag6l/"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BE7916892C for ; Thu, 10 Jun 2021 10:25:49 +0200 (CEST) Received: by mail-pj1-x1036.google.com with SMTP id m13-20020a17090b068db02901656cc93a75so3289585pjz.3 for ; Thu, 10 Jun 2021 01:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PUYx5PJu6hrDJL7A0XDt0lAHR0rHKJv94avBEeNop2k=; b=gr1ag6l/iMO24dO+nim4I1Fe1iCYzONdK2K147XSTjHtDfv0bsTfu2XBVIXxhWTeIC 06I8AS2PWXRXiNwJWZnb47FNIOMraYr2IuX2Amch9ucaNEnuX3rDQSNRfkRmhhfh0n2l gjh80BYtXaWay1cK33wUyF37XKUolQLBch46s= 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=PUYx5PJu6hrDJL7A0XDt0lAHR0rHKJv94avBEeNop2k=; b=B4hHxRmLdeguCx/PUBUItzr31pxWVlxfCn1sY2wzQM82UYVW7JxwzV4fqdEiZ3dtDs yDrbGtA6ecW+HKUxmQX7SpJnDojwlAW9Q9sWTnQvjtLKqqKG4qJLtXHGJtxRK1u51n9P K+u4c7SRH0YzGxqZf3XO/Rvf7pjPT1ij+PijjIy7yVv++l9SJqf6DvTzNIEqKDK5FLxy M3P7BvCZAKz/bKyHdDtTUxIiozH3m4ul7hGz8g6uVNmuR9TA2QEETZG/5aD1DxLTpZb9 iHU54pAKBozuh3wn/UoCXXjlObi4MfiYXz4uBeTxOEr4cxCWsi8MmnHYbP7ODa8f9usd VNrw== X-Gm-Message-State: AOAM532j/ZK3tsYaxee719XfXVP6696QZkchyORo8+iT4T718fYt7Tcu +8Wal4rivrzcuRxlFDtVY0wbK8boXsaH+g== X-Google-Smtp-Source: ABdhPJzDC1GHyuUa+ehxEThet9f+er9MYUuc6c/9JOSdTTjk1Jg10E1GQcS6VBKMa0Ldg++8nO8jQQ== X-Received: by 2002:a17:90a:9481:: with SMTP id s1mr2211734pjo.48.1623313548189; Thu, 10 Jun 2021 01:25:48 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:47 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:36 +0900 Message-Id: <20210610082539.529739-3-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610082539.529739-1-hiroh@chromium.org> References: <20210610082539.529739-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 3/6] libcamera: CameraSensorProperties: Add table of v4l2 index and test pattern 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 V4L2 specification defines the sensor test pattern modes through a menu control, where a numerical index is associated to a string that describes the test pattern. The index-to-pattern mapping is driver specific and requires a corresponding representation in the library. Add to the static list of CameraSensorProperties a map of indexes to libcamera::controls::TestPatternModes values to be able to map the indexes returned by the driver to the corresponding test pattern mode. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- .../internal/camera_sensor_properties.h | 2 ++ src/libcamera/camera_sensor_properties.cpp | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h index f5e242cb..67c77920 100644 --- a/include/libcamera/internal/camera_sensor_properties.h +++ b/include/libcamera/internal/camera_sensor_properties.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__ #define __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__ +#include #include #include @@ -17,6 +18,7 @@ struct CameraSensorProperties { static const CameraSensorProperties *get(const std::string &sensor); Size unitCellSize; + std::map testPatternModes; }; } /* namespace libcamera */ diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp index a2c04009..f660743a 100644 --- a/src/libcamera/camera_sensor_properties.cpp +++ b/src/libcamera/camera_sensor_properties.cpp @@ -9,6 +9,8 @@ #include +#include + #include "libcamera/internal/log.h" /** @@ -34,6 +36,11 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties) * * \var CameraSensorProperties::unitCellSize * \brief The physical size of a pixel, including pixel edges, in nanometers. + * + * \var CameraSensorProperties::testPatternModes + * \brief Map that associates the indexes of the sensor test pattern modes as + * returned by V4L2_CID_TEST_PATTERN with the corresponding TestPattern + * control value */ /** @@ -47,18 +54,44 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen static const std::map sensorProps = { { "imx219", { .unitCellSize = { 1120, 1120 }, + .testPatternModes = { + { 0, controls::draft::TestPatternModeOff }, + { 1, controls::draft::TestPatternModeColorBars }, + { 2, controls::draft::TestPatternModeSolidColor }, + { 3, controls::draft::TestPatternModeColorBarsFadeToGray }, + { 4, controls::draft::TestPatternModePn9 }, + }, } }, { "imx258", { .unitCellSize = { 1120, 1120 }, + /* \todo fill test pattern modes for imx258. */ + .testPatternModes = {}, } }, { "ov5670", { .unitCellSize = { 1120, 1120 }, + .testPatternModes = { + { 0, controls::draft::TestPatternModeOff }, + { 1, controls::draft::TestPatternModeColorBars }, + }, } }, { "ov13858", { .unitCellSize = { 1120, 1120 }, + .testPatternModes = { + { 0, controls::draft::TestPatternModeOff }, + { 1, controls::draft::TestPatternModeColorBars }, + }, } }, { "ov5693", { .unitCellSize = { 1400, 1400 }, + .testPatternModes = { + { 0, controls::draft::TestPatternModeOff }, + { 2, controls::draft::TestPatternModeColorBars }, + /* + * No corresponding test pattern mode for + * 1: "Random data" and 3: "Colour Bars with + * Rolling Bar". + */ + }, } }, }; From patchwork Thu Jun 10 08:25:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12548 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 8296ABD78E for ; Thu, 10 Jun 2021 08:25:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 458D468939; Thu, 10 Jun 2021 10:25:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LCeEBi6c"; dkim-atps=neutral Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA36E68935 for ; Thu, 10 Jun 2021 10:25:51 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id y11so13856038pgp.11 for ; Thu, 10 Jun 2021 01:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9K5PveEwZBbwwCEIhfIir0TSqZrkTwudduhTEgwn/MQ=; b=LCeEBi6c2jhhWVy5qCkNDb5KobY9t6hZhyU2F2AJnmQcBPEKf5DKqZR560AqVhQNW0 CJPBUes7Lc/6dcgX0JiL1YhSSNMoBI3CSq4lxWRZyPvm2owM/Xjj9yYI/h/uhcHLInps dfVT92wyw/3QrleS6CqVspzqmI5sJ297pOP74= 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=9K5PveEwZBbwwCEIhfIir0TSqZrkTwudduhTEgwn/MQ=; b=tdhfQfKLwSXaKBzQJw5fzuE9B+6yj4y8i7Tv73ANSxOpMSH/zXSrcb2J5M8GnYZEwq jK1/JTk4omHxk2b853q5PLP+sxLcuZA6Umv+QVljZ9BYShnv1MzMZb2Z3AF/n1+ikBdF XbroVgOxVBz/J5iYwPUqSzo0RwebWDSoZOwHlqFFM0Z338W1rhtw67L+5kRQQzoZqZxW WeFXhm3hGb/hVXv4wvKeNtb0AH6Bkw1V9hPFK5tG4byfpENPmBBXGfcjZixy2S9R6Bua E3wwfVO9pYvtiZQSEiJfwiye62tKqzzg5IKnHMzA/Mc7skP+yTYvZ4WNW2TaE3QEMY6z 7yPg== X-Gm-Message-State: AOAM533+6dWk9/3pgFdmZ8F/w8bY199VLQHDlF/3QrHDGh9/gap7fk9r 6yG7JzQRsBKMU56keqscDBESohnpsTnUmQ== X-Google-Smtp-Source: ABdhPJx1Glb6NzJ4+eGOAL+2DEl1hcLbjp4oGYv9yS0bkxKvHlFa+b5W7dlBHxmGV1cEWrZM09yp8A== X-Received: by 2002:a63:ec03:: with SMTP id j3mr3825560pgh.272.1623313550371; Thu, 10 Jun 2021 01:25:50 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:49 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:37 +0900 Message-Id: <20210610082539.529739-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610082539.529739-1-hiroh@chromium.org> References: <20210610082539.529739-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 4/6] libcamera: CameraSensor: Enable retrieving supported test pattern modes 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 enables retrieving supported test pattern modes through CameraSensorInfo. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 7 +++++ src/libcamera/camera_sensor.cpp | 34 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index cf6c1c1e..e133ebf4 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -39,6 +39,10 @@ public: const std::vector &mbusCodes() const { return mbusCodes_; } const std::vector &sizes() const { return sizes_; } Size resolution() const; + const std::vector &testPatternModes() const + { + return testPatternModes_; + } V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, const Size &size) const; @@ -65,6 +69,8 @@ private: int validateSensorDriver(); void initVimcDefaultProperties(); void initStaticProperties(); + void initTestPatternModes( + const std::map &testPatternModeMap); int initProperties(); const MediaEntity *entity_; @@ -77,6 +83,7 @@ private: V4L2Subdevice::Formats formats_; std::vector mbusCodes_; std::vector sizes_; + std::vector testPatternModes_; Size pixelArraySize_; Rectangle activeArea_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 0fb8a258..3e135353 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -305,6 +305,32 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, props->unitCellSize); + + initTestPatternModes(props->testPatternModes); +} + +void CameraSensor::initTestPatternModes( + const std::map &testPatternModes) +{ + const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); + if (v4l2TestPattern == controls().end()) { + LOG(CameraSensor, Debug) << "No static test pattern map for \'" + << model() << "\'"; + return; + } + + for (const ControlValue &value : v4l2TestPattern->second.values()) { + const int32_t index = value.get(); + + const auto it = testPatternModes.find(index); + if (it == testPatternModes.end()) { + LOG(CameraSensor, Debug) + << "Test pattern mode " << index << " ignored"; + continue; + } + + testPatternModes_.push_back(it->second); + } } int CameraSensor::initProperties() @@ -469,6 +495,14 @@ Size CameraSensor::resolution() const return std::min(sizes_.back(), activeArea_.size()); } +/** + * \fn CameraSensor::testPatternModes() + * \brief Retrieve all the supported test pattern modes of the camera sensor + * The test pattern mode values correspond to the controls::TestPattern control. + * + * \return The list of test pattern modes + */ + /** * \brief Retrieve the best sensor format for a desired output * \param[in] mbusCodes The list of acceptable media bus codes From patchwork Thu Jun 10 08:25:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12549 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 2F562BD78E for ; Thu, 10 Jun 2021 08:25:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DCA3568938; Thu, 10 Jun 2021 10:25:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gyw9VIqZ"; dkim-atps=neutral Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ABCA8602C5 for ; Thu, 10 Jun 2021 10:25:53 +0200 (CEST) Received: by mail-pl1-x62c.google.com with SMTP id v12so586283plo.10 for ; Thu, 10 Jun 2021 01:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eGamX387RzZe2eIC3xUR0g3TZDatng8JNNtBxBmx/TQ=; b=gyw9VIqZnr4xjBKn/PNE+Zf2PqVFj4cuhv/zhycSyqvgH5Np6yMgU20CzFHBLZxHDW uXtib3PUOyLUDBI/X4TcXUJv1rnmrAZI3uxALJ9YSMO4bSgufzynbLqvuLfw7PdDYNRD oINWYWxBwt039Fj+8rX2OHrx5jh3clTcFTHks= 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=eGamX387RzZe2eIC3xUR0g3TZDatng8JNNtBxBmx/TQ=; b=bmeIqGl8nJXj2SYuvFNGM+Yz4tlHVp5s71ynPrrkj8wgRREz9MFhmPfw9VqaHvoapG 3HKYK6++fHMe99NZ+pVffccyNtlVH9rAijoYUQCo6YWOaYikli9SqhyOOm+XKkiRVGJN 0UgzO+WWabbSIY1VLBBdBZAwmPaKTytfOQDrKM7lqv7sG8uRmuK+LfHnJ87WHAW7I03H SzoDDtkHviSYuhca5ahRQPC49xMa8A/SWUN44+bym7m/M54hFkHonavP6ccDq0qoDb8w BQG8Ragr288twtekize0/YISTl0zkDiKYy+D+TRoedhKVWzjFNY2cpGb+roBVTzB1Ja1 mOTA== X-Gm-Message-State: AOAM533d0uNvT+i4mA9LNk6OVcPI0m2dVsUooCDh7PjqFsUiJYvJO/nE dgHdcdApLpP0OkE6Yv/wzn/j7vK9CvNFig== X-Google-Smtp-Source: ABdhPJz3YxbXw4Uzl1Sht86xUJy348WJ4mYbJnJdmGeocgtNsE9r4nPihw1BbPYAdy1vPrXPJvxECg== X-Received: by 2002:a17:903:2482:b029:fd:696c:1d2b with SMTP id p2-20020a1709032482b02900fd696c1d2bmr3949935plw.24.1623313552106; Thu, 10 Jun 2021 01:25:52 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:51 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:38 +0900 Message-Id: <20210610082539.529739-5-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610082539.529739-1-hiroh@chromium.org> References: <20210610082539.529739-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 5/6] libcamera: pipeline: ipu3: Report available sensor test pattern mode 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" PipelineHandlerIPU3 gets available test pattern modes of the sensor device and reports them to a client. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index b986bb70..52b11687 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -935,6 +935,16 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) ControlInfoMap::Map controls = IPU3Controls; const ControlInfoMap &sensorControls = sensor->controls(); + const std::vector &testPatternModes = sensor->testPatternModes(); + if (!testPatternModes.empty()) { + std::vector values; + values.reserve(testPatternModes.size()); + + for (int32_t pattern : testPatternModes) + values.emplace_back(pattern); + + controls[&controls::draft::TestPatternMode] = ControlInfo(values); + } /* * Compute exposure time limits. From patchwork Thu Jun 10 08:25:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12550 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 8DE80BD78E for ; Thu, 10 Jun 2021 08:25:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4FA636893C; Thu, 10 Jun 2021 10:25:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YqSm8Tfj"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 782036892B for ; Thu, 10 Jun 2021 10:25:55 +0200 (CEST) Received: by mail-pj1-x1029.google.com with SMTP id pi6-20020a17090b1e46b029015cec51d7cdso3344676pjb.5 for ; Thu, 10 Jun 2021 01:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hqu8pksEUVvipvwGZ2F8p2REk5PKW/IuLTrKzsk2/go=; b=YqSm8Tfj31Q0ZUfDA/Cho8VWPsxwTZOtjFYj9mFpHZLSCjtciO9BYH+HNdLCzNKUJg l8QfUVefjGnTrcEYse9OFtUipTF3Ydj7EwrGzkgMUam/qsh4LvUkdWh9gfjCwjWXl23E dRgepoSlGwbxCX8HgH0ZXP/8OVUlkop8Yp1GU= 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=hqu8pksEUVvipvwGZ2F8p2REk5PKW/IuLTrKzsk2/go=; b=o+GWM1247SGif4Hk3Qvm4he3Lu1BPDTON4j4oZohiumuD3nZcdG6ejf9DwXFoJ6lAa 8Wo/DDt5nGTvWRu3d7s70K1ZR/9nIIQtVKFOI7dvQyf9uWT0vmi+54+8n9ZoZe1kAu31 rEeyLm4mRiTwWIswcaaeGoyNAVAD+DG6SKhuieBvpQ87k7c1w+TeFfYZJYFTcVJwZMaU g05muSaxRU3nvpVyCxC5Q8PEbcGwVVKjT7mgaOHiIu4PC5jnft7QUqOQR/zQCDp2c3Mx jd+espVKJ14BwayHOWZcM2pTu3us/7VzMRfLly+soabiguNJ55SXbVLWs1w0nBnmGwSj o8gA== X-Gm-Message-State: AOAM530Huv+BePpgrWN0VqUYY3VIpQHCqqIDznFrVj8Rf6PFqJlI1MyU CisZ4OyIyzBm7jF9ur/1e4ZDZARuH1FgSw== X-Google-Smtp-Source: ABdhPJyLJkXyTLorQLVPedHxehln6bwneeZ+Og6hz/GvWtlyGpg/DOQbQC1TtcJ7S2dZL32pwcTu1Q== X-Received: by 2002:a17:90a:6a8d:: with SMTP id u13mr2184443pjj.55.1623313553870; Thu, 10 Jun 2021 01:25:53 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:53 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:39 +0900 Message-Id: <20210610082539.529739-6-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610082539.529739-1-hiroh@chromium.org> References: <20210610082539.529739-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 6/6] android: CameraDevice: Report queried test pattern modes 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 to the Android camera stack the list of supported test pattern modes constructed by inspecting the values reported by libcamera through the controls::draft::TestPatternMode control. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 51 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index fe332ec3..5e961003 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1083,11 +1083,56 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, orientation_); - std::vector testPatterModes = { - ANDROID_SENSOR_TEST_PATTERN_MODE_OFF, + std::vector testPatternModes = { + ANDROID_SENSOR_TEST_PATTERN_MODE_OFF }; + const auto &testPatternsInfo = + controlsInfo.find(&controls::draft::TestPatternMode); + if (testPatternsInfo != controlsInfo.end()) { + const auto &values = testPatternsInfo->second.values(); + ASSERT(!values.empty()); + for (const auto &value : values) { + switch (value.get()) { + case controls::draft::TestPatternModeOff: + /* + * ANDROID_SENSOR_TEST_PATTERN_MODE_OFF is + * already in testPatternModes. + */ + break; + + case controls::draft::TestPatternModeSolidColor: + testPatternModes.push_back( + ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR); + break; + + case controls::draft::TestPatternModeColorBars: + testPatternModes.push_back( + ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS); + break; + + case controls::draft::TestPatternModeColorBarsFadeToGray: + testPatternModes.push_back( + ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY); + break; + + case controls::draft::TestPatternModePn9: + testPatternModes.push_back( + ANDROID_SENSOR_TEST_PATTERN_MODE_PN9); + break; + + case controls::draft::TestPatternModeCustom1: + /* We don't support this yet. */ + break; + + default: + LOG(HAL, Error) << "Unknown test pattern mode: " + << value.get(); + continue; + } + } + } staticMetadata_->addEntry(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, - testPatterModes); + testPatternModes); uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,