From patchwork Wed Apr 28 07:36:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12124 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 7C824BDE44 for ; Wed, 28 Apr 2021 07:36:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C3B6688C3; Wed, 28 Apr 2021 09:36:28 +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="OZw6vtKB"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 252F3688C0 for ; Wed, 28 Apr 2021 09:36:26 +0200 (CEST) Received: by mail-pl1-x635.google.com with SMTP id s20so16480966plr.13 for ; Wed, 28 Apr 2021 00:36:26 -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=JAA9SPbVs6+tfAE+HktRBVUwgn3i3AHc7hb4F5a4GD0=; b=OZw6vtKB1HPQ4q4FPQWBiGyw1Ky/xehOeKJzRrjlkrSUgxBfxbJ7NSGMj1Zo4zfjRS Cdr2b7UwKMJeHVzSgTsDRQXG4QMXHn0iOyu0ii2n9jAhBVYbVvX/oQofRi3xW4ZAcg3A sVKzCxMaCkxSpc+t+NOw80XW36kkaPIRB1DA4= 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=JAA9SPbVs6+tfAE+HktRBVUwgn3i3AHc7hb4F5a4GD0=; b=bQ7ToUyA+hdeABVH6+/01UzT2kEnSLzQoO44iDnF16ZEewq/eCfSZNFE0JEXNJmj2T Z0EJ37K0iLI2sq9qsSVlAjUqz1zMvdWUThUQfm80stKQiE1fmYOT1AOenTNO4BoG/f6E kovCbn1OiP8MF2I71pWYLbLuQSS766An4q3yHKAbuREVKRaG/VEjnv/cl/88lanKmxKW WXEKGhE8W3o9nZQuVqdnmSCtr+i6Zz5+cSi07ojLuiFMx4JCDHaIpqihhDH3Mu0xK/oi vKLeMYXvSsMVeLqttDZgq1+7bOlw+Dew+2KiHSvU9smAtz5kjyyd2rDdcUhydGUi9CsU GemA== X-Gm-Message-State: AOAM531n7GNYfOVFo2hiPiMKPq1wr2JKAjtFxy5G9k85YWhwWyXCpNw3 RCHErpShRVFFRGdAvUBuQ/mhzy1IqSrmSg== X-Google-Smtp-Source: ABdhPJy+5YvxCaEQdJkuAmQ6i74DibSTEnAMXhl1QQ3kLiIPE7wnYliuXEgCmq/JhYz44XJbYngqhg== X-Received: by 2002:a17:902:b60d:b029:e6:7a9:7f4 with SMTP id b13-20020a170902b60db02900e607a907f4mr28427195pls.3.1619595384347; Wed, 28 Apr 2021 00:36:24 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:23 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:11 +0900 Message-Id: <20210428073617.373422-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/7] 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 --- 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 b4771f9d..cc472863 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -608,4 +608,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: 5 + 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 Wed Apr 28 07:36:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12125 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 7D391BDE44 for ; Wed, 28 Apr 2021 07:36:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C621688B7; Wed, 28 Apr 2021 09:36:31 +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="cGAGn60S"; 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 9CC1C688B7 for ; Wed, 28 Apr 2021 09:36:27 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id j189so393972pgd.13 for ; Wed, 28 Apr 2021 00:36:27 -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=8J7xgT7XcjyRvJF6TvsJde5q9/7S/xA8Yce3qGUryO8=; b=cGAGn60SCs/jq0inT/o8ab7uvWuEQrVyMtVfKCOgBEXtW7jdbfYcxqnUTK5IDqvBPf VPVAFnyhuIwWEux9fzT9VG1tR7vggALbVO16jDRCaH+Wru8q+oepduTsz3XQzhIMVjZb evGEL9EnxFRr+EUod5FbILRYx1D9cd3LOoDmo= 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=8J7xgT7XcjyRvJF6TvsJde5q9/7S/xA8Yce3qGUryO8=; b=WTAkPzSbzAcK4ZQG6pdQ/xlz+5J0Fs3gcKahSGBzWsGx1Kr+IC6fMcvj5DGoqNrMMb laLBPl+VSQjkXnw/h+iCZsMgZ25IUOtyaEddFQnSHg9GWtFy0zr1SHzVH+eKASa5iIdw yqIhWjdc8miEt7/rrgUkes7Q0ATHW561Oh1F/y/QojFeBQrefcbI7/ToMpTARNTidkxK TrxQnAsNR+chZeXDqTfIb9WXRtMy1F8/hPtfABYGIZuZMtFj1IiRMssXnvulZVpdeBPg Q4TYGEc4TuExsi+agJJWSzBWApA1uaLO7Gp6OpT1bblN3NR3M2QxLQOAjpbUUPQWk96P 2aXQ== X-Gm-Message-State: AOAM533O0ba5JsM+Pz5NRrHdW+Nrx7Ui31w6IjY7QkalcsBBNTUZhoXp sxVGMc+PNiRrvLN8eIwMGrd2P1oWwOvZyg== X-Google-Smtp-Source: ABdhPJzTuCHTTqkzNKlnVV3JvwG0H7S7oCwJNUJ8aWZBxE74avvsSsHFXWRQ8c/3vfEYE9Er7YeVZA== X-Received: by 2002:a63:6b4a:: with SMTP id g71mr25681145pgc.274.1619595385911; Wed, 28 Apr 2021 00:36:25 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:25 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:12 +0900 Message-Id: <20210428073617.373422-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/7] libcamera: controls: Add extra control values to ControlInfo 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 menu contains not only index (int32_t) but also either name (string) or value (int64_t). To support it keeping ControlValue simple, this adds the extra ControlValues to ControlInfo. With the ControlInfo, indeices are stored in ControlInfo::values, and names (or values) are stored in ControlInfo::extraValues. Signed-off-by: Hirokazu Honda --- include/libcamera/controls.h | 5 +++++ src/libcamera/controls.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1a5690a5..a8deb16a 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -271,11 +271,15 @@ public: const ControlValue &def = 0); explicit ControlInfo(Span values, const ControlValue &def = {}); + explicit ControlInfo(Span values, + Span extraValues, + const ControlValue &def = {}); const ControlValue &min() const { return min_; } const ControlValue &max() const { return max_; } const ControlValue &def() const { return def_; } const std::vector &values() const { return values_; } + const std::vector &extraValues() const { return extraValues_; } std::string toString() const; @@ -294,6 +298,7 @@ private: ControlValue max_; ControlValue def_; std::vector values_; + std::vector extraValues_; }; using ControlIdMap = std::unordered_map; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index c58ed394..e2e8619a 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -513,6 +513,28 @@ ControlInfo::ControlInfo(Span values, values_.push_back(value); } +/** + * \brief Construct a ControlInfo from the list of valid values and extra values + * \param[in] values The control valid values + * \param[in] extraValues The control valid extra values associated with \a values + * \param[in] def The control default value + * + * Construct a ControlInfo from a list of valid values and extra values. The + * ControlInfo minimum and maximum values are set to the first and last members + * of the values list respectively. The default value is set to \a def if + * provided, or to the minimum value otherwise. The extra values are associated + * with \a values and in the same order as \a values. + * + */ +ControlInfo::ControlInfo(Span values, + Span extraValues, + const ControlValue &def) + : ControlInfo(values, def) +{ + for (const ControlValue &extraValue : extraValues) + extraValues_.push_back(extraValue); +} + /** * \fn ControlInfo::min() * \brief Retrieve the minimum value of the control From patchwork Wed Apr 28 07:36:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12126 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 65005BDE44 for ; Wed, 28 Apr 2021 07:36:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BDDDE688CE; Wed, 28 Apr 2021 09:36:32 +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="BnBMCfgr"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B90B688B7 for ; Wed, 28 Apr 2021 09:36:29 +0200 (CEST) Received: by mail-pf1-x430.google.com with SMTP id a12so826138pfc.7 for ; Wed, 28 Apr 2021 00:36:29 -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=QMJniqxYRSeszAKe+yuZv/Z9+aZeAH8IQy9wC+Uydis=; b=BnBMCfgrb0eKcJuBIlyv26FSxME/KvskKOjap32veA2nn5bHpTsDY+58epHqKHccrz a068KxWTS1s6Cz+BaXd+OgkhnuwtQhdCzICDjXWpoSK80WI3a2yIMyp6Fla6EUgjzNyO gg8KNRpey0CZqbFr/P+/xVuula8JNeID3oHkY= 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=QMJniqxYRSeszAKe+yuZv/Z9+aZeAH8IQy9wC+Uydis=; b=NyOjTSi2aZXDyB6jrInqhfSayCFDmcS9Ot3U6bpRgHKpJYDvxApJVh4vs+9Qw/Pmd9 Lke4pqCWKSmxOnPGoRPrO5exP2lwQxYN3W6cT9klcxCjqJVlXOrg4Yb7pgW9B/E7lmR7 qqo/3YMJWZO9PvofF2z1EdHOl5fJqtdePfnV3va9gHFjH7mGrQ/iaxR7svj2PPerN06H BGWl1hTGURUHZv04dSTKJ/Il9KTWegSC/RsqK3lKIX4fy1XTiLJosvB2ItdwS/T/dXRC wEh2jiY5aB5rH0EOuOCI+9MtwPk0ah1aSQXLNiLcUbvLLo6jMefkWtt2pQS49S8TTAWh wIjg== X-Gm-Message-State: AOAM531YeVMFhbtMBn71+yRtvYBCZcZkirvzGya6xz3dVyDbaCJD8NuF oLuSJunW7ME0T0spbN5EI+gEE3jYQf82AQ== X-Google-Smtp-Source: ABdhPJxCn/TSPoVM3E7yX6NwuKMMsAp9Qc0OBUcRvL+23/EmkLSk/vSsDaldqdCKTAqaKTDBXvIEWw== X-Received: by 2002:a62:aa09:0:b029:25c:3c28:e2b with SMTP id e9-20020a62aa090000b029025c3c280e2bmr26414320pff.39.1619595387417; Wed, 28 Apr 2021 00:36:27 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:27 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:13 +0900 Message-Id: <20210428073617.373422-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/7] 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. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/v4l2_device.h | 3 + src/libcamera/v4l2_device.cpp | 73 +++++++++++++++++++++--- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 087f07e7..c7a2539c 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -54,6 +54,9 @@ protected: int fd() const { return fd_; } private: + bool createControlInfoForMenu(const v4l2_query_ext_ctrl &ctrl, + ControlInfo &ctrlInfo); + void listControls(); void updateControls(ControlList *ctrls, Span v4l2Ctrls); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 64501523..f2a9038e 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -446,6 +446,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) return 0; } + /** * \fn V4L2Device::deviceNode() * \brief Retrieve the device node path @@ -453,10 +454,55 @@ int V4L2Device::ioctl(unsigned long request, void *argp) */ /** - * \fn V4L2Device::fd() - * \brief Retrieve the V4L2 device file descriptor - * \return The V4L2 device file descriptor, -1 if the device node is not open + * \brief Create ControlInfo for v4l2 menu ctrl. + * \param[in] ctrl The v4l2_query_ext_ctrl that represents a menu + * \param[out] ctrlInfo The created controlInfo + * + * The created ControlInfo contains not only values and also extra values, which + * are indices and name/value acquired by VIDIOC_QUERYMENU, respectively. The + * extra values contains std::string if the type of \a ctrl is + * V4L2_CTRL_TYPE_MENU or int64_t otherwise. + * + * \return True on success or false otherwise */ +bool V4L2Device::createControlInfoForMenu(const v4l2_query_ext_ctrl &ctrl, + ControlInfo &ctrlInfo) +{ + ASSERT(ctrl.type == V4L2_CTRL_TYPE_MENU || + ctrl.type == V4L2_CTRL_TYPE_INTEGER_MENU); + const bool isName = ctrl.type == V4L2_CTRL_TYPE_MENU; + + std::vector indices; + std::vector values; + v4l2_querymenu menu; + memset(&menu, 0, sizeof(menu)); + menu.id = ctrl.id; + + for (menu.index = ctrl.minimum; + static_cast(menu.index) <= ctrl.maximum; menu.index++) { + if (ioctl(VIDIOC_QUERYMENU, &menu) != 0) + continue; + + indices.emplace_back(static_cast(menu.index)); + if (isName) { + std::string name(reinterpret_cast(menu.name)); + values.emplace_back(std::move(name)); + } else { + values.emplace_back(static_cast(menu.value)); + } + } + + if (values.empty()) { + LOG(V4L2, Error) + << "No applicable value: " << utils::hex(ctrl.id); + + return false; + } + + ctrlInfo = ControlInfo(indices, values); + + return true; +} /* * \brief List and store information about all controls supported by the @@ -467,7 +513,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; @@ -478,15 +523,22 @@ void V4L2Device::listControls() ctrl.flags & V4L2_CTRL_FLAG_DISABLED) continue; + ControlInfo ctrlInfo; switch (ctrl.type) { case V4L2_CTRL_TYPE_INTEGER: case V4L2_CTRL_TYPE_BOOLEAN: - case V4L2_CTRL_TYPE_MENU: case V4L2_CTRL_TYPE_BUTTON: case V4L2_CTRL_TYPE_INTEGER64: case V4L2_CTRL_TYPE_BITMASK: - case V4L2_CTRL_TYPE_INTEGER_MENU: case V4L2_CTRL_TYPE_U8: + ctrlInfo = V4L2ControlInfo(ctrl); + break; + + case V4L2_CTRL_TYPE_INTEGER_MENU: + case V4L2_CTRL_TYPE_MENU: + if (!createControlInfoForMenu(ctrl, ctrlInfo)) + continue; + break; /* \todo Support other control types. */ default: @@ -496,10 +548,13 @@ void V4L2Device::listControls() continue; } + LOG(V4L2, Debug) << "Control: " << ctrl.name + << " (" << utils::hex(ctrl.id) << ")"; + controlIds_.emplace_back(std::make_unique(ctrl)); controlInfo_.emplace(ctrl.id, ctrl); - ctrls.emplace(controlIds_.back().get(), V4L2ControlInfo(ctrl)); + ctrls.emplace(controlIds_.back().get(), ctrlInfo); } controls_ = std::move(ctrls); @@ -523,6 +578,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 Wed Apr 28 07:36:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12127 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 7F6E5BDE44 for ; Wed, 28 Apr 2021 07:36:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8CF6688CA; Wed, 28 Apr 2021 09:36:33 +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="dm+8N95l"; dkim-atps=neutral Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 94ABD688B7 for ; Wed, 28 Apr 2021 09:36:30 +0200 (CEST) Received: by mail-pg1-x536.google.com with SMTP id q10so44118482pgj.2 for ; Wed, 28 Apr 2021 00:36:30 -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=CTcArTkFMUPimjbWFygFLSHDbZaIwI0tGHz0MD3v2c4=; b=dm+8N95lTeH6yTgiJr9Qo+sijNIpDTr3XSQkZK6gB2cCyoQ9XNujlpPhc1ZZI/xwJ5 TfwAW4EZN3zy4PwohaMP2lsYvjcASqncv6vldjr5xngxKob552OcPNIKHoo7O1VSB9RW P4ay6UIKklJwGXvTrov/muw7YciokgpCi73Mc= 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=CTcArTkFMUPimjbWFygFLSHDbZaIwI0tGHz0MD3v2c4=; b=oK0S9juad0xyc9/Ve0ZanhPzK6WqgvhsMCDiACT5PKDvqenqjDQ4JJnEnH3hGupB9r uzyqnO63nSepah3LjR34OkbOHccozwacSo2bCOQfXeSEjB4TzcN6xfTLWKTYt3yTj3Q5 RdKwrJZgvsDFcgfCZYlewQ0VB5HtX6xKK1Gc0tyGlmqPr+jEG74PwIUlwOnIrWGl8a5p lkmXQi2Q5fWhxFac8Ofj5l6Pw99ZlB645IrcXxWqJD9oaJtcZLFxXjKxL79xWLwlZJ9T MRiE6SadUHkIiFXLBmpzDrjP7Jm8d3uJ+p20sxZtLIGY+2FK2yIDTEIYkiTJpL8hWmPF HtCA== X-Gm-Message-State: AOAM533UXKO/XrPY4d7flv+3UYF+M9PFNsLpix7VplgigyqsfgLemwmw C8R1+Lv3hiU1JHwoOQkWoMKDqrBgrfmGVA== X-Google-Smtp-Source: ABdhPJz57im4klh/Qk0WFqyA94o0ikEvAEIcSGPViIWTFlKiLMJTJN7vds2mNJUQsLViqjIYfILgiw== X-Received: by 2002:aa7:8d03:0:b029:259:f2ed:1849 with SMTP id j3-20020aa78d030000b0290259f2ed1849mr28050908pfe.30.1619595389004; Wed, 28 Apr 2021 00:36:29 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:28 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:14 +0900 Message-Id: <20210428073617.373422-5-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/7] libcamera: SensorDatabase: Adds table of v4l2 name 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" In V4L2 API, a driver returns a name to represent a test pattern, but it is a driver specific what test pattern is represented by the name. Therefore, this adds a mapping table from the name to a test pattern into a static configuration of a sensor. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/sensor_database.h | 2 + src/libcamera/sensor_database.cpp | 39 ++++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h index 7d743e46..04a5783c 100644 --- a/include/libcamera/internal/sensor_database.h +++ b/include/libcamera/internal/sensor_database.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_SENSOR_DATABASE_H__ #define __LIBCAMERA_SENSOR_DATABASE_H__ +#include #include #include @@ -15,6 +16,7 @@ namespace libcamera { struct SensorInfo { Size unitCellSize; + std::map testPatternModeMap; }; class SensorDatabase diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp index 68e69e8b..a4d4f686 100644 --- a/src/libcamera/sensor_database.cpp +++ b/src/libcamera/sensor_database.cpp @@ -9,6 +9,8 @@ #include +#include "libcamera/control_ids.h" + namespace libcamera { /** @@ -43,25 +45,48 @@ namespace libcamera { namespace { +const std::map imx219TestPatternModeMap = { + { "Disabled", controls::draft::TestPatternModeOff }, + { "Color Bars", controls::draft::TestPatternModeColorBars }, + { "Solid Color", controls::draft::TestPatternModeSolidColor }, + { "Grey Color Bars", controls::draft::TestPatternModeColorBarsFadeToGray }, + { "PN9", controls::draft::TestPatternModePn9 }, +}; + +const std::map ov5670TestPatternModeMap = { + { "Disabled", controls::draft::TestPatternModeOff }, + { "Vertical Color Bar Type 1", controls::draft::TestPatternModeColorBars }, +}; + +const std::map ov13858TestPatternModeMap = { + { "Disabled", controls::draft::TestPatternModeOff }, + { "Vertical Color Bar Type 1", controls::draft::TestPatternModeColorBars }, + { "Vertical Color Bar Type 2", controls::draft::TestPatternModeColorBarsFadeToGray }, +}; + /** * \brief Sony IMX219 sensor properties */ -constexpr SensorInfo imx219Info = { - .unitCellSize = { 1120, 1120 } +const SensorInfo imx219Info = { + .unitCellSize = { 1120, 1120 }, + .testPatternModeMap = imx219TestPatternModeMap, }; /** * \brief Omnivision ov5670 sensor properties */ -constexpr SensorInfo ov5670Info = { - .unitCellSize = { 1120, 1120 } +const SensorInfo ov5670Info = { + .unitCellSize = { 1120, 1120 }, + .testPatternModeMap = ov5670TestPatternModeMap, }; /** * \brief Omnivision 13858 sensor properties */ -constexpr SensorInfo ov13858Info = { - .unitCellSize = { 1120, 1120 } +const SensorInfo ov13858Info = { + .unitCellSize = { 1120, 1120 }, + .testPatternModeMap = ov13858TestPatternModeMap, + }; #define SENSOR_INFO(_sensor) \ @@ -70,7 +95,7 @@ constexpr SensorInfo ov13858Info = { /* * \brief The database of sensor properties */ -constexpr std::pair sensorDatabase__[] = { +const std::pair sensorDatabase__[] = { SENSOR_INFO(imx219), SENSOR_INFO(ov5670), SENSOR_INFO(ov13858), From patchwork Wed Apr 28 07:36:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12128 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 60A80BDE44 for ; Wed, 28 Apr 2021 07:36:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19B8A688C2; Wed, 28 Apr 2021 09:36:36 +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="XnN+XEDX"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3245E688C7 for ; Wed, 28 Apr 2021 09:36:32 +0200 (CEST) Received: by mail-pj1-x102f.google.com with SMTP id k3-20020a17090ad083b0290155b934a295so2181670pju.2 for ; Wed, 28 Apr 2021 00:36:32 -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=4SL2EcLkX9gZT8o1MSisScpd/e0VL4ERGSUlnE+efPs=; b=XnN+XEDX7ctn8yiPZ+6hBfHIDmz1CGOQKbgGzEcVZkgMYzGddp+RjKusxXY6x+BVuD MK+y3E+wM6DPK795LrghneoHY8xnq0iyjAh9YOx6ZEm9AaUnzL0y6VEJHqVLLIdhjIlf nDr1140/Quie8+wgP048IlubtYjBBG+JzGmrA= 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=4SL2EcLkX9gZT8o1MSisScpd/e0VL4ERGSUlnE+efPs=; b=DUTaY9x8sMh9wrnzknCHpGZhXd6Lsq8FM0+wTpjJTUmpfIxC7MVj/UnrXgKNH+Psk6 QSjAv6tITMiXmzpDn7Y/NnMA5xU3zXJDy4S6qDZiULlIXt7w9HLTGIINk8fZ7VF7hZhK W1xxc8dCWTNWJNSSOUezCBPGdqj0ebcl1klMuJ6k41cjpT6UDk4CPmGq2IvMJttU1r6Y lLLXj4FpRlb7USJFJP4X1iZ9kWnMdswoA449I4COsqVtWfZ+gKsS2je4sXgvNM7zrPu8 cT5lodoTWpLzXGScIE6OY7UFxzAkgbGFlkdl52nw59Pab+VDOa5pBPg3OtvcSn0ut21C w7bg== X-Gm-Message-State: AOAM530oirXob8WTeCgRN+ecdDnlNGuoIBm5E4HrT/HzmbnKLbx3k8mI LwicTXyu+L5WwHZPSuwqziMsHnhDkSCg2A== X-Google-Smtp-Source: ABdhPJxC3VYL7v+CQO456NYpwem7fXvgRRUIxC6gS0nq3U7lRmgOZzvgCfqTItyVpun1n0yYBvseAg== X-Received: by 2002:a17:90b:4ac1:: with SMTP id mh1mr2535892pjb.95.1619595390460; Wed, 28 Apr 2021 00:36:30 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:30 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:15 +0900 Message-Id: <20210428073617.373422-6-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/7] 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 --- include/libcamera/internal/camera_sensor.h | 5 +++ src/libcamera/camera_sensor.cpp | 40 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3fa3a419..eec37a54 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -38,6 +38,8 @@ struct CameraSensorInfo { uint32_t minFrameLength; uint32_t maxFrameLength; + + std::vector testPatternModes; }; class CameraSensor : protected Loggable @@ -79,6 +81,8 @@ private: void initVimcDefaultProperties(); void initStaticProperties(); int initProperties(); + void initTestPatternModes( + const std::map &testPatternModeMap); const MediaEntity *entity_; std::unique_ptr subdev_; @@ -90,6 +94,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 850c94b3..a5c0fff7 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -411,6 +411,42 @@ void CameraSensor::initVimcDefaultProperties() activeArea_ = Rectangle(pixelArraySize_); } +void CameraSensor::initTestPatternModes( + const std::map &testPatternModeMap) +{ + const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); + if (v4l2TestPattern == controls().end()) { + LOG(CameraSensor, Debug) << "No static test pattern map for \'" + << model() << "\'"; + return; + } + + const std::vector &indices = v4l2TestPattern->second.values(); + const std::vector &names = v4l2TestPattern->second.extraValues(); + if (indices.size() != names.size()) { + LOG(CameraSensor, Error) + << "The number of indices and names are different" + << ", indices.size()=" << indices.size() + << ", names.size()=" << names.size(); + return; + } + + for (const ControlValue &value : names) { + const std::string &name = value.get(); + + const auto it = testPatternModeMap.find(name); + if (it != testPatternModeMap.end()) { + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << name << "\' ignored"; + continue; + } + + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << name << "\' added"; + testPatternModes_.push_back(it->second); + } +} + void CameraSensor::initStaticProperties() { const SensorInfo *info = SensorDatabase::get(model_); @@ -424,6 +460,8 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, info->unitCellSize); + + initTestPatternModes(info->testPatternModeMap); } int CameraSensor::initProperties() @@ -840,6 +878,8 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get(); + info->testPatternModes = testPatternModes_; + return 0; } From patchwork Wed Apr 28 07:36:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12129 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 2400ABDE44 for ; Wed, 28 Apr 2021 07:36:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D4543688B4; Wed, 28 Apr 2021 09:36:36 +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="AgAYxPoB"; dkim-atps=neutral Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE70C688BC for ; Wed, 28 Apr 2021 09:36:33 +0200 (CEST) Received: by mail-pl1-x62b.google.com with SMTP id e2so28007392plh.8 for ; Wed, 28 Apr 2021 00:36:33 -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=TuN0pQYYQgzxSdB2iYkFDxxp3zogDjb5vpHNNdEskuU=; b=AgAYxPoBv3vNPxvPvMHgM6bXAUVbVOo3kc1vKyYWrvCkrpzBN6XCjS/tCdlFw/CVfT L4fzy6b158bo70ZT+e/LfYUsGRcY1yM6x794Pl9mrdTprNJ/83m9OzOef2wn6AwkWFgl TdholiCUWm7/LPERKhh4evK3TdyABmGJF3ORQ= 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=TuN0pQYYQgzxSdB2iYkFDxxp3zogDjb5vpHNNdEskuU=; b=afrnS6Z2CS0TUEwU2auk9Z25cK1kYL7xalU09UtxDjbX1Tcsy+qZgH/oM7XGzYAUoI CZ7SljgcaiRpHQNpVU1pX965jrcyNL308jcSyJjucdV5dkREmvId7PYsimk9HXuYHAaq j4k+cab8LJgahvm+zv0D20G7zi92Zz8SHP5jtPcg0JExe1CZxwlbRA/5TP/kaTofnwkv G6K7WffQOUet0FAUrQvHwDoVZ6G+J5OdStUVA0fw/BI6ilR+FA7KZJQpRfILu/kjqXna lNw0ymPjBGuUc/XGuAhPEyxbVxBTn/zbQyR4sXW1kRWU8kOGNGkWYFn21OKfoJ62+YF8 5Y1g== X-Gm-Message-State: AOAM531VyN6OcIwZfe1LACzjk9su8OHWUEWmXlaHmXpIoTWTIYIc6QpK 101as+f+W6piRsTsuTif7B8vzJW7XXHZpw== X-Google-Smtp-Source: ABdhPJzca9aDP/KXtpJ+Di9xNRJpuyJPTAYGtYfCxiyRgwgHVcAm6vybaqh0nkOyvOZzMr+FHgcn3g== X-Received: by 2002:a17:90a:5b0a:: with SMTP id o10mr2503073pji.82.1619595391987; Wed, 28 Apr 2021 00:36:31 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:31 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:16 +0900 Message-Id: <20210428073617.373422-7-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/7] 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 --- 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 73306cea..b4d4b97d 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -891,6 +891,16 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) ControlInfoMap::Map controls = IPU3Controls; const ControlInfoMap &sensorControls = sensor->controls(); + if (!sensorInfo.testPatternModes.empty()) { + std::vector values; + values.reserve(sensorInfo.testPatternModes.size()); + + for (int32_t pattern : sensorInfo.testPatternModes) + values.emplace_back(pattern); + + controls[&controls::draft::TestPatternMode] = ControlInfo(values); + } + /* * Compute exposure time limits. * From patchwork Wed Apr 28 07:36:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12130 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 86AEDBDE44 for ; Wed, 28 Apr 2021 07:36:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 37232688BC; Wed, 28 Apr 2021 09:36:39 +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="GXREcBDy"; dkim-atps=neutral Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A6A6688C2 for ; Wed, 28 Apr 2021 09:36:35 +0200 (CEST) Received: by mail-pj1-x102e.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso8645328pjn.3 for ; Wed, 28 Apr 2021 00:36:35 -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=dgY0VyAh1UvCaMt1h0/NXnw6PtEa0f4TRDwpJyByJrU=; b=GXREcBDyNXfAwBylv0uHJJJPCzV/zTFUAEfgsfsE2mCdokBqw1WjEbrqBd5XYJACsJ 2953nR4s71o1feIiVcykgsSmlxGVY4SRWkPNmXHzoiQRAdh5LzjpL60Ruo70fTexsbto FYf4Mp36lR7B4rxuL1XS9b5pP6KnMZCXodqP8= 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=dgY0VyAh1UvCaMt1h0/NXnw6PtEa0f4TRDwpJyByJrU=; b=hMoFvhG1pGGuXomtxEKA1fX1vW3tO2x9reO3Iu3YHJPjVt1j30RIUBT8e1WZElqvdv QS9ghlKG8HmAbh6iYABYLMkM30/0TYQs4ARZU1YszfvLW7DE0D55S3yYB+ouZpY3mFpm 0SJ0DZf668Tn6A3+a0vP07TY0xCGvtTK/f5wJjCXhqxKhhreZbH9m7MhidbyYHbdAexG 71zl3Or2k7mT+hC25RbDM8Ujg+hetsznKKT5Jb+aSLj4gUUjkMMl84+uaIfpqqQ8f67l Yhi50A8uZ/0NPG47ctxdRhtysYF0YreUdSYxfV6jmpClq1hsuPEa4EkXhE0SHpbCpfAf mDAg== X-Gm-Message-State: AOAM530zn330bvQWKtoFzbf3QeCkw0BWGBNKSvnj1ZvNYQ8W3Xzx1puw KWWH7RSR3zCuffJDdHnJq9OUhmxXXzSl7w== X-Google-Smtp-Source: ABdhPJw6r/Men/h/it0SG8CIbqCTCMQjFA+zgCnXjBGGMSMxOxqoAukK1MDCL5V53RbvOFCqNMU6Hw== X-Received: by 2002:a17:902:b582:b029:ed:562a:6f52 with SMTP id a2-20020a170902b582b02900ed562a6f52mr8680320pls.73.1619595393633; Wed, 28 Apr 2021 00:36:33 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:33 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:17 +0900 Message-Id: <20210428073617.373422-8-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/7] 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 test pattern modes obtained by Camera::controls(). Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 46 ++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 3d5b5f24..a96bc09b 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1090,12 +1090,50 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation_, 1); - std::vector testPatterModes = { - ANDROID_SENSOR_TEST_PATTERN_MODE_OFF, + const auto &testPatternsInfo = + controlsInfo.find(&controls::draft::TestPatternMode); + std::vector testPatternModes = { + ANDROID_SENSOR_TEST_PATTERN_MODE_OFF }; + if (testPatternsInfo != controlsInfo.end()) { + const auto &values = testPatternsInfo->second.values(); + if (!values.empty()) { + testPatternModes.clear(); + for (const auto &value : values) { + int aValue = -1; + switch (value.get()) { + case controls::draft::TestPatternModeOff: + aValue = ANDROID_SENSOR_TEST_PATTERN_MODE_OFF; + break; + case controls::draft::TestPatternModeSolidColor: + aValue = ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR; + break; + case controls::draft::TestPatternModeColorBars: + aValue = ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS; + break; + case controls::draft::TestPatternModeColorBarsFadeToGray: + aValue = ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY; + break; + case controls::draft::TestPatternModePn9: + aValue = ANDROID_SENSOR_TEST_PATTERN_MODE_PN9; + break; + case controls::draft::TestPatternModeCustom1: + aValue = ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1; + break; + default: + LOG(HAL, Error) + << "Unknown test pattern mode: " + << value.get(); + continue; + } + + testPatternModes.push_back(aValue); + } + } + } staticMetadata_->addEntry(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, - testPatterModes.data(), - testPatterModes.size()); + testPatternModes.data(), + testPatternModes.size()); uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,