From patchwork Wed Apr 21 04:23:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12018 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 ED9BBBDB16 for ; Wed, 21 Apr 2021 04:23:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B05A868843; Wed, 21 Apr 2021 06:23:58 +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="YZ44PQIe"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52ED4602C8 for ; Wed, 21 Apr 2021 06:23:57 +0200 (CEST) Received: by mail-pl1-x629.google.com with SMTP id e9so3926039plj.2 for ; Tue, 20 Apr 2021 21:23:57 -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=m/eODOzB3ee2ue1j6Fr81wG3SrpHu+DMI0Z0DLkyzX4=; b=YZ44PQIe4xQgr6axz1/1/9YEU3ezDP+srQWyCWl3fjTy2aHhNiKDKRI6DSP+KJwEvG pQjS4IvAWnSFj+x1nCN2UFOH0l68n4UH+IgZ6UXH+OTR3aAWiAEQTNoZ+PgjCLP93sUf hVlHhRqKa2qC22yYsp0Nvsty7CZv0ZWUBdw9U= 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=m/eODOzB3ee2ue1j6Fr81wG3SrpHu+DMI0Z0DLkyzX4=; b=c9IPeiDUH09RNP54dvseE2I+vy8yevqXxc8j/Rkv2+0QOMb4razcaFGTuepc57FQ6E V55ofKqLB2jrFo1ytcERN/9QKtxHor1/7ZPI88OQlQtXc9o56Wkadx9I5ZhLoEkRn1a2 mDTH3MpmkzdIYrnsyadde5Mrfrxo/dPpfOiI1t1WrfjKNVkx9AZZRMlVBjeu4TWwpg+4 /P2NSJBRQE1ba4vk4Vb3pdmlBhPeEzlfaXg0JCE3RSAyEohtMXYazamOkjbox7F/NlM1 O9VuQC87JrGIsi09ieFE4AJovA+Y7TeiI8RfpJW/EJoDzPgvy2pGNqmzwePVFoOm/ote faLg== X-Gm-Message-State: AOAM5318zG9Hd+VC9X0c+FSi0QvxDNBLKAfBgXZLqA8LMtpvxK761lIc +ht5q7NIidjRp9DOpFuT1I94qdj7htnZRg== X-Google-Smtp-Source: ABdhPJy4xzcEtwpVEon0TOimvHZTSoSz2RorqVB5GpqqNbROwdoGMtjN0a32gx9FnlgyeZ36E48Xrw== X-Received: by 2002:a17:902:e34b:b029:ec:9a57:9cba with SMTP id p11-20020a170902e34bb02900ec9a579cbamr18377459plc.56.1618979035814; Tue, 20 Apr 2021 21:23:55 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:23:55 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:40 +0900 Message-Id: <20210421042346.312854-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index b4771f9d..5de75eb0 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -608,4 +608,63 @@ 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. + + Mode of operation for the test pattern mode. + enum: + - name: TestPatternModeOff + value: 0 + description: | + No test pattern mode is used. The camera device returns 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 mode 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 21 04:23:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12019 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 4E531BDB16 for ; Wed, 21 Apr 2021 04:24:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1132268847; Wed, 21 Apr 2021 06:24:01 +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="lC0drX+g"; dkim-atps=neutral Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE77468847 for ; Wed, 21 Apr 2021 06:23:58 +0200 (CEST) Received: by mail-pg1-x52b.google.com with SMTP id q10so28536910pgj.2 for ; Tue, 20 Apr 2021 21:23:58 -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=oqMdxWFl01BiCkNk8pajo+3bLMuJCJj2thUDkBkDj74=; b=lC0drX+g4lbcTnhYQPm8gj+xNQ/X5/TaTGKkCWpdm1FqaCKbH1NkWuaLla/+mb3N/u qv1eqhoPV+b9Uyr/p5t6gylSqbNMNuXCoCTndHmTjlfPDTB+QITIODc07FLPE6VaMFKW AZfbLgkb481Zf+0Q9kOWpTNzTkCGZgkFb6tbg= 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=oqMdxWFl01BiCkNk8pajo+3bLMuJCJj2thUDkBkDj74=; b=fhibcxGKFzvOOr6qhb0BdkTi7Qe59CGzsuSCvKgQt7m+EnYyQKMBkHM1AVdHSDsBBw zAZ9/UgKE9gJnBaVbZDkB5zL0MA53OFwZkjOzDVKQfZV+r0Q8b7XqDGEgCjPGC/ayrAy mNrfhWovBrNhXyAtLK/XFJzVnaRRcc04q/5IQgbD+S2WD7FhWePJtgsu0tYeT/A17qll qucy1FU0Hr8q7rIoLYukUNdq8tT42k2FuZVwH307/r3yKcAOTXQT+5sz6vRuuNu2Rgnr XjXr1pCJ3Sh1EvBa9P0NMm5rJS/FPg3RU8PYpxKewU6eJwAvtVez0zjNVF26Nhk5lLen svtw== X-Gm-Message-State: AOAM532WN9+iGW5Dj1rrKtxRYkTq2MaRrMWMKBBnV87o3t+3BeDmr1gt Iw7gv1lJp99TBgMI1OZKTYdrpElQDFqTFg== X-Google-Smtp-Source: ABdhPJz56qO+X5XfxXJw/t4qApnh8F5kDLuOFe/be49VRf00IYJeUkay73pYwb3gqeTTKr78G9mucw== X-Received: by 2002:a17:90a:c589:: with SMTP id l9mr8526604pjt.24.1618979037276; Tue, 20 Apr 2021 21:23:57 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:23:56 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:41 +0900 Message-Id: <20210421042346.312854-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/7] libcamera: Controls: Add ControlTypeMenu 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 control type for v4l2 menu. Signed-off-by: Hirokazu Honda --- include/libcamera/controls.h | 28 ++++++++++++++++++++++++++++ src/libcamera/controls.cpp | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1a5690a5..357819e7 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -9,6 +9,7 @@ #define __LIBCAMERA_CONTROLS_H__ #include +#include #include #include #include @@ -32,6 +33,28 @@ enum ControlType { ControlTypeString, ControlTypeRectangle, ControlTypeSize, + ControlTypeMenu, +}; + +struct ControlMenu { + uint32_t index; + bool isName = false; + + union { + char name[28]; + int64_t value; + }; + + std::string toString() const + { + std::stringstream ss; + ss << "index: " << index; + if (isName) + ss << "name: " << name; + else + ss << "value: " << value; + return ss.str(); + } }; namespace details { @@ -85,6 +108,11 @@ struct control_type { static constexpr ControlType value = ControlTypeSize; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeMenu; +}; + template struct control_type> : public control_type> { }; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index c58ed394..8ab5ac92 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeString] = sizeof(char), [ControlTypeRectangle] = sizeof(Rectangle), [ControlTypeSize] = sizeof(Size), + [ControlTypeMenu] = sizeof(ControlMenu), }; } /* namespace */ @@ -254,6 +255,12 @@ std::string ControlValue::toString() const str += value->toString(); break; } + case ControlTypeMenu: { + const ControlMenu *value = + reinterpret_cast(data); + str += value->toString(); + break; + } case ControlTypeNone: case ControlTypeString: break; From patchwork Wed Apr 21 04:23:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12020 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 E3377BDB16 for ; Wed, 21 Apr 2021 04:24:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6B0FC68848; Wed, 21 Apr 2021 06:24:01 +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="kvXPIsgM"; dkim-atps=neutral Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 53A2468839 for ; Wed, 21 Apr 2021 06:24:00 +0200 (CEST) Received: by mail-pg1-x52a.google.com with SMTP id p12so28545825pgj.10 for ; Tue, 20 Apr 2021 21:24:00 -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=v7vOsb8DbMt3IBCLrf+iB6KOuge3VtWhyJKcdnF4+ec=; b=kvXPIsgM1Uuxj5tzi9tiFm+TbqRGqzk1VabmBVMAqEOYOWbbHZ9Xul9LSEZkKoV1DV pnuc8NYdQYe1sLydZ3MVTvMA4xI554Fmq6GXmVLnCHu9ArEfvERAljwOmvw+pV9CpCfL CDPQq2rPmorCQhnBp+EAgSV7Pf7yElTt/n4qg= 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=v7vOsb8DbMt3IBCLrf+iB6KOuge3VtWhyJKcdnF4+ec=; b=DxIpXjf0ucJdGi6Ql1KGIaYnQ8ppZpSz15ogbBlE4ypU/V7v5363alskN61MPfMF2l 93YRl4uHmZdyv2kHSure1r6OkfdSrN73TMt/wvl8Paf6Ta1kTkemoEKEIzE3Sy+AjsUH 62tfrg80Evq+pAVUmgy7TSbFCctBCpv0Z/rQWAdbwmkjL5tQpfDJmA4HrEMFhWzWjz6i gMCYmxvQdllc4dH50iNorNJ3t1KhJgA0Faz8P2m8BBP1AF0ladvFgZpsGPekIFxk3K4+ wn8C8aTkug+6v2x5qKLZP7QtQT8gpnEEPfu9tjNy3Ag5q1wJOHMh6f4l7RvHxMnXvlWU IUsA== X-Gm-Message-State: AOAM533q9xD0TZmKN9nXFYyvltv7V54e5csvjNg6HEvElVFuk8DooQqa 7fNkVS//jty3ZTiNOWhepjbCFjHaYPnxfw== X-Google-Smtp-Source: ABdhPJwWtjwSTNk8tuAsQNm301roTJGBuYP+e8iVCMNV1R1+umgHv8G7PX/8PFCKm5bz8SW27k9W+w== X-Received: by 2002:a17:90a:b947:: with SMTP id f7mr8513650pjw.166.1618979038777; Tue, 20 Apr 2021 21:23:58 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:23:58 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:42 +0900 Message-Id: <20210421042346.312854-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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_controls.h | 1 + include/libcamera/internal/v4l2_device.h | 3 + src/libcamera/v4l2_controls.cpp | 10 ++- src/libcamera/v4l2_device.cpp | 90 ++++++++++++++++++++-- 4 files changed, 98 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/v4l2_controls.h b/include/libcamera/internal/v4l2_controls.h index 0851b8dd..c42f2529 100644 --- a/include/libcamera/internal/v4l2_controls.h +++ b/include/libcamera/internal/v4l2_controls.h @@ -24,6 +24,7 @@ class V4L2ControlInfo : public ControlInfo { public: V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl); + V4L2ControlInfo(const ControlInfo &ctrl); }; } /* namespace libcamera */ diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 4cce3840..2436a83c 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -53,6 +53,9 @@ protected: int fd() const { return fd_; } private: + bool createV4L2ControlInfoForMenu(const v4l2_query_ext_ctrl &ctrl, + V4L2ControlInfo &v4l2CtrlInfo); + void listControls(); void updateControls(ControlList *ctrls, const std::vector &v4l2Ctrls); diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 3f8ec6ca..2c965cfa 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -73,9 +73,12 @@ ControlType v4l2_ctrl_type(const struct v4l2_query_ext_ctrl &ctrl) return ControlTypeInteger64; case V4L2_CTRL_TYPE_MENU: + case V4L2_CTRL_TYPE_INTEGER_MENU: + return ControlTypeMenu; + 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. @@ -148,4 +151,9 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) } } +V4L2ControlInfo::V4L2ControlInfo(const ControlInfo &ctrl) + : ControlInfo(ctrl) +{ +} + } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 8f29cd7f..585e527b 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -459,6 +459,47 @@ int V4L2Device::ioctl(unsigned long request, void *argp) * \return The device node path */ +bool V4L2Device::createV4L2ControlInfoForMenu(const v4l2_query_ext_ctrl &ctrl, + V4L2ControlInfo &v4l2CtrlInfo) +{ + 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 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; + ControlMenu ctrlMenu; + ctrlMenu.index = static_cast(menu.index); + ctrlMenu.isName = isName; + if (isName) { + strcpy(ctrlMenu.name, + reinterpret_cast(menu.name)); + } else { + ctrlMenu.value = menu.value; + } + + values.push_back(ControlValue(ctrlMenu)); + } + + if (values.empty()) { + LOG(V4L2, Error) + << "No applicable value: " << utils::hex(ctrl.id); + return false; + } + + v4l2CtrlInfo = V4L2ControlInfo( + ControlInfo(libcamera::Span( + values.data(), values.size()))); + + return true; +} + /** * \fn V4L2Device::fd() * \brief Retrieve the V4L2 device file descriptor @@ -474,7 +515,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; @@ -485,15 +525,20 @@ void V4L2Device::listControls() ctrl.flags & V4L2_CTRL_FLAG_DISABLED) continue; + V4L2ControlInfo v4l2CtrlInfo(ControlInfo(0)); 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: + v4l2CtrlInfo = V4L2ControlInfo(ctrl); + break; + case V4L2_CTRL_TYPE_MENU: + case V4L2_CTRL_TYPE_INTEGER_MENU: + if (!createV4L2ControlInfoForMenu(ctrl, v4l2CtrlInfo)) + continue; break; /* \todo Support other control types. */ default: @@ -503,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(), std::move(v4l2CtrlInfo)); } controls_ = std::move(ctrls); @@ -539,7 +587,39 @@ void V4L2Device::updateControls(ControlList *ctrls, case ControlTypeInteger64: newValue.set(v4l2Ctrl.value64); break; - + case ControlTypeMenu: + switch (v4l2Ctrl.id) { + case V4L2_CID_TEST_PATTERN: { + ControlMenu menu; + menu.index = v4l2Ctrl.value; + menu.isName = true; + + bool found = false; + for (const ControlValue &validValue : it->second.values()) { + const auto &ctrlMenu = validValue.get(); + if (!ctrlMenu.isName) + continue; + if (menu.index == ctrlMenu.index) { + strcpy(menu.name, ctrlMenu.name); + found = true; + break; + } + } + + if (!found) { + LOG(V4L2, Error) + << "Matched value is not found" + << ", index=" << menu.index; + continue; + } + + newValue.set(menu); + break; + } + default: + LOG(V4L2, Error) << "Unknown id: " << v4l2Ctrl.id; + break; + } case ControlTypeByte: /* * No action required, the VIDIOC_[GS]_EXT_CTRLS ioctl From patchwork Wed Apr 21 04:23:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12021 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 69AFABDB16 for ; Wed, 21 Apr 2021 04:24:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 293AD68843; Wed, 21 Apr 2021 06:24:04 +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="FfllY6BK"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCB356884B for ; Wed, 21 Apr 2021 06:24:01 +0200 (CEST) Received: by mail-pf1-x42c.google.com with SMTP id i190so27461086pfc.12 for ; Tue, 20 Apr 2021 21:24:01 -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=HrT9i7XhDSbb+NstUsVDkxKE8NA2VTx4jZnojrfc6r0=; b=FfllY6BKD8QyJ2roNcdIFLR4yEdiQafZx9t816HQEvBC59mfrpU6HmSxBQwaLoZz0Q CzyKAEaJ6GQZBGwEdD3mIil4H2N5zGl9QT0BNsOLVaYwGdDV2gKD1J6ztoP24UsOfuxe 1NvjR6Xds/JMw36m4GFq42ROH0kjXnTGFYib4= 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=HrT9i7XhDSbb+NstUsVDkxKE8NA2VTx4jZnojrfc6r0=; b=lSDRnMWYvpCwVb3XDNYrH3tnMZuqqRGFLwB+d+fudYuWkTSKrDvyib8AFpVkg0dvt0 FQCJKh0KJuqGbGzSDEA+h/PBfFQ/10nozQfm4WmzdaEeFAMeRGIHeJ1r0xKzfqRzJ3IO ZszYywz1wCsdlPbmt8A8EzX1gq1ZHat2PkKFV0LLFKyy6ayEtp6CcY/UXGobz4WhUgEU vUzizKwo2+iXeqLODRUp2mYFEDNKA55sGG2N0JCVCfAh73DSa1WcLAIJnL/1PquUNVTo 2edDZjSqyodob8NhocTFVWY+24VdFKxmVXtqato77j9gH9HHMVJbhJFrc7Bm/aS4Ltis HFXw== X-Gm-Message-State: AOAM5336mcDpo3Du2MQWHcko1NvsqgxEo3UBHew7dlLfiF9yRAsng+Hl wPGl8PXXrBUDx9Ten0XAOqS0yeLhRxrpzw== X-Google-Smtp-Source: ABdhPJwR4OtpYKCfcJbosQ6h8CaY27RPBijXsxAZJM110sXHIQPkPU0i1S4TnnHg7JF8HQY7UENlag== X-Received: by 2002:a65:4486:: with SMTP id l6mr20307671pgq.347.1618979040278; Tue, 20 Apr 2021 21:24:00 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:23:59 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:43 +0900 Message-Id: <20210421042346.312854-5-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 37 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h index 7d743e46..c0b181f8 100644 --- a/include/libcamera/internal/sensor_database.h +++ b/include/libcamera/internal/sensor_database.h @@ -10,11 +10,13 @@ #include #include +#include namespace libcamera { struct SensorInfo { Size unitCellSize; + Span> testPatternModeMap; }; class SensorDatabase diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp index 68e69e8b..da469b67 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,54 @@ namespace libcamera { namespace { +constexpr std::pair 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 }, +}; + +constexpr std::pair ov5670TestPatternModeMap[] = { + { "Disabled", controls::draft::TestPatternModeOff }, + { "Vertical Color Bar Type 1", controls::draft::TestPatternModeColorBars }, +}; + +constexpr std::pair 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 } + .unitCellSize = { 1120, 1120 }, + .testPatternModeMap = + libcamera::Span>( + imx219TestPatternModeMap), }; /** * \brief Omnivision ov5670 sensor properties */ constexpr SensorInfo ov5670Info = { - .unitCellSize = { 1120, 1120 } + .unitCellSize = { 1120, 1120 }, + .testPatternModeMap = + libcamera::Span>( + ov5670TestPatternModeMap), }; /** * \brief Omnivision 13858 sensor properties */ constexpr SensorInfo ov13858Info = { - .unitCellSize = { 1120, 1120 } + .unitCellSize = { 1120, 1120 }, + .testPatternModeMap = + libcamera::Span>( + ov13858TestPatternModeMap), + }; #define SENSOR_INFO(_sensor) \ From patchwork Wed Apr 21 04:23:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12022 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 C74A7BDB16 for ; Wed, 21 Apr 2021 04:24:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8520668846; Wed, 21 Apr 2021 06:24:05 +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="IVe/hgRN"; dkim-atps=neutral Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C0DA602C3 for ; Wed, 21 Apr 2021 06:24:03 +0200 (CEST) Received: by mail-pf1-x42a.google.com with SMTP id a12so27472953pfc.7 for ; Tue, 20 Apr 2021 21:24:03 -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=DgyIxqKBQJt6BM45ov5SUpTjBy04mX0jLBNjwW3YiL4=; b=IVe/hgRNVyHVfvt0I6aYNROHZwRu9SHOFBwKBtvvzHSmDb+gCxz+NnIXkqq5NtpeHv QSCMxDk7GvhyTz5REBlIGhfMq0Ey/AVAHdewf16Bd+EaYXUykVvAH575Wnt0/1BqdIvC vLEMHHduBHkYEZpokWIwd2dBgTGiDhSTqPNq0= 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=DgyIxqKBQJt6BM45ov5SUpTjBy04mX0jLBNjwW3YiL4=; b=tvSE1YBCSvtORab3O9cxPlzTAzafZVV9BPtxZGyWB2Et18N+q9LBpbhkKhCiQeI9B5 cClOy5UZOKxbNpei5fgJe5igJpWq8r+roZfL7hRi6vptNxfqJ30NbnKaaFqMIg3AdADj d4nbyHuEuI8R5aWu0kt+iGhnfBWWFDDZsTe8jW6G/cDEYHrY5t/EMmCaV1mXErswUMdW sq1XMUEhlZVhjVrWTZBJH3IGmVzq8m7N7Lmjnlv6uCK8KxHpNzXli7PADl7ebund2kyK 8r2O7GeAQXRgCamFfQBPogYhYvcuXbGh1vctaxF40dJJhc+Z6mtgL87xNT/sWBphhCDu OIog== X-Gm-Message-State: AOAM530PUW8RMMo24rC+AL/IO/Qwb3BtQe5dLyUbFSA8mQ6eN3OSG9Vc 92IptSyazG1GOWljnBNlQRe+CxyiF7QWPA== X-Google-Smtp-Source: ABdhPJwOgQrS3d/ueLzok3I9H+uUCFcI9Hxeoqg68VOSghsg8GCPuhbDga8QuIGSU+6GWjG7NTCagQ== X-Received: by 2002:a65:61a1:: with SMTP id i1mr20075098pgv.411.1618979041841; Tue, 20 Apr 2021 21:24:01 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:24:01 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:44 +0900 Message-Id: <20210421042346.312854-6-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/7] libcamera: CameraSensor: Attach available 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 add available test pattern modes to libcamera to CameraSensorInfo. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/camera_sensor.h | 2 ++ src/libcamera/camera_sensor.cpp | 38 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3fa3a419..75b884db 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 availableTestPatternModes; }; class CameraSensor : protected Loggable diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 850c94b3..d20cfb4c 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -840,6 +840,44 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get(); + const SensorInfo *staticInfo = SensorDatabase::get(model_); + if (!staticInfo) { + LOG(CameraSensor, Warning) + << "No static properties available for '" << model_ << "'"; + LOG(CameraSensor, Warning) + << "Please consider updating the sensor database"; + return -EINVAL; + } + + const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); + if (v4l2TestPattern == controls().end()) { + LOG(CameraSensor, Debug) << "No static test pattern map for \'" + << model() << "\'"; + return 0; + } + + for (const ControlValue &value : v4l2TestPattern->second.values()) { + const ControlMenu &menu = value.get(); + ASSERT(menu.isName); + + int32_t matchedTestPattern = -1; + for (const auto &[name, testPattern] : staticInfo->testPatternModeMap) { + if (strcmp(menu.name, name) == 0) { + matchedTestPattern = testPattern; + break; + } + } + + if (matchedTestPattern != -1) { + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << menu.name << "\' added"; + info->availableTestPatternModes.push_back(matchedTestPattern); + } else { + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << menu.name << "\' ignored"; + } + } + return 0; } From patchwork Wed Apr 21 04:23:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12023 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 2D44FBDB16 for ; Wed, 21 Apr 2021 04:24:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E28AD68853; Wed, 21 Apr 2021 06:24:07 +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="feoh30Ol"; dkim-atps=neutral Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA044602C3 for ; Wed, 21 Apr 2021 06:24:04 +0200 (CEST) Received: by mail-pg1-x52b.google.com with SMTP id y32so28532797pga.11 for ; Tue, 20 Apr 2021 21:24:04 -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=WKvWlo2rlqpJwhfL/Ss63p7PuDJHY1LEzWBviZ3QGB4=; b=feoh30OlpsEM2bvRk0Qa8hfq6qoQ5vGyDNj0Ii5QbHtrhx6DEyuizsDm3FAUqpkBG3 v4OT9ANdF+PqKZYK3ENovrw6LiPAD3Hn1u+mGshVDvWlWrE2P2VP4gVrpl7TB/mA/zm9 8zXFYKSgpFkCGBqmKbRTiQA7+ncd5ClF9Uyv0= 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=WKvWlo2rlqpJwhfL/Ss63p7PuDJHY1LEzWBviZ3QGB4=; b=W0xkA7zUoCDyfU36lwcFf9S+loliPvwVFIN7kJloR9hiyvFdf8LsDYIUuFzohMQOnZ iAjLvPbJXbD/vE6aO9TH4TGN+O7GVXr0L3EgmA+ciViV/YIgiQuYQYrfcKSkigXtB3qR +69tX39Qm1zrfzkTk31tbFjrLaw7/zQy8NKTm76CWlHBK8rj2uhGZpurWveTb6XZwkLm HssFJwUAZ8PbdPQKHk68QDRPWuHqT38P3PGMrgIVW44XiRcMESHHDU8mf4T1KukGbATh 7FSYV+9f98KCeWsPy8g234CuHGHBVjexpUiU2A7lG5P/eD1GL3VPLcy9sFf34HFOy7Sz EzuA== X-Gm-Message-State: AOAM533xGqMHxB5Xt+MNi0lEuo6/6fFXQYthKOS4OLTljQbLuQTfcnNL nGPFJ754gs1e8+7CYuenBMskj1TN128Rkw== X-Google-Smtp-Source: ABdhPJyR30WGvTiqeKPr1GLOM9lS00c4SqoUVXhTPZRxlEj5AjbnHe24RzToxGRDNzIgn7CmwDYD4A== X-Received: by 2002:a17:90a:ce8d:: with SMTP id g13mr8752890pju.85.1618979043393; Tue, 20 Apr 2021 21:24:03 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:24:02 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:45 +0900 Message-Id: <20210421042346.312854-7-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 51446fcf..76903d31 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -891,6 +891,18 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) ControlInfoMap::Map controls = IPU3Controls; const ControlInfoMap &sensorControls = sensor->controls(); + if (!sensorInfo.availableTestPatternModes.empty()) { + std::vector values( + sensorInfo.availableTestPatternModes.size()); + for (size_t i = 0; i < values.size(); ++i) { + values[i] = ControlValue( + sensorInfo.availableTestPatternModes[i]); + } + + controls[&controls::draft::TestPatternMode] = + ControlInfo(libcamera::Span(values)); + } + /* * Compute exposure time limits. * From patchwork Wed Apr 21 04:23:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12024 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 83D89BDB17 for ; Wed, 21 Apr 2021 04:24:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 424D068856; Wed, 21 Apr 2021 06:24:08 +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="We9cpFK0"; dkim-atps=neutral Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 86626602C3 for ; Wed, 21 Apr 2021 06:24:06 +0200 (CEST) Received: by mail-pf1-x42e.google.com with SMTP id p67so22523014pfp.10 for ; Tue, 20 Apr 2021 21:24:06 -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=2ahqEEkbk0IO54qh9kBPBbYxJzeWa4xWg0+E7yMfngo=; b=We9cpFK0U/7LdWasytMKLoX1Gy0+j0JUEAmPdFT4rn43Vpa5ynER8uUEC7NvqAWW7y Nhd7JA3MMYaIWtzDFY/zQmxUI8Kp++MTJzGyuWLjWwECaJ6eA8w1UQOXJo+oITzmvtyG 7LuE8bhHsp5JWIv7UHZTKR2DM4ePK0OHrtxsc= 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=2ahqEEkbk0IO54qh9kBPBbYxJzeWa4xWg0+E7yMfngo=; b=PL7IfAty3AoFP7ffUiPXQx5FbQ0QRTSqJgVvhhXvW+gXxs0bKPuqKgRDsyG3CLGFuv GbXp2nGWCmiujLygSk+OjVOhvFHpEJ84YAk7qcf1VGTgxmGATsBIXH/km960MiIiVsAq JQesfiuGfCovGICmlO+ZKTAk+zwdlXlFsrVL3EjGgfE6emGX2K5okdT8hOsSgQbd7qEX PgwFRNF9GE7D+3XjalFdYbv6Eys8uk8Bnd/7GqK/onXTZc9xJ/YW+dvmGeCMGyGk6RNL bBmGIVV2BD8SJt4ZREN7VRaM5KlXshKoIxUQo2JEczeNdCTft2mqQaoDVZ9PLEUNVefq k5Lw== X-Gm-Message-State: AOAM533/p6CpVSmHGXxMIGs2nuxduPUQbPIenFnef/gmnx/ramLaOwDe dtxjt2I/eMczwWnwVjXi5PbmrxGm+lhBtw== X-Google-Smtp-Source: ABdhPJw5G9yb8tGK3V8PZYLmr0o56+um0LdVyF0UWHJiHfq3AhwqjNpruxvwoQv+XyPbxnGu497ZDA== X-Received: by 2002:a17:90b:302:: with SMTP id ay2mr8796379pjb.84.1618979044956; Tue, 20 Apr 2021 21:24:04 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7aaa:cbeb:5d87:4ab6]) by smtp.gmail.com with ESMTPSA id z18sm461316pfa.39.2021.04.20.21.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 21:24:04 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Apr 2021 13:23:46 +0900 Message-Id: <20210421042346.312854-8-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210421042346.312854-1-hiroh@chromium.org> References: <20210421042346.312854-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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,