From patchwork Fri Apr 9 04:32:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11875 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 C1676BD16B for ; Fri, 9 Apr 2021 04:32:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 785556879E; Fri, 9 Apr 2021 06:32:19 +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="EMksSMuv"; dkim-atps=neutral Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4906F687F6 for ; Fri, 9 Apr 2021 06:32:17 +0200 (CEST) Received: by mail-pf1-x433.google.com with SMTP id y16so3396734pfc.5 for ; Thu, 08 Apr 2021 21:32:17 -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=q5RFrfd6VVochhtE8B6hQ1ngTLphNO+zgetVv/vHVoo=; b=EMksSMuv+cxxP1HsNh7E5a4XHI0jTHFs+J66UEMrwRlUewCgJYz0WK11x+VC6+o5b4 VbFRbhtNEhOVVXiT14DiAvG7/c15HwgoFMEqDfHYxDwrwyleexxa6Wo8Dwdg7B32Nyky mvHYZaOLyPIah0vQgTbkuCV9C4hpW0sRJ1VS4= 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=q5RFrfd6VVochhtE8B6hQ1ngTLphNO+zgetVv/vHVoo=; b=RPsNbGhylOX10Q7lKv17f0velm86ljSNlYufuDfFdHJBnqNVjldzoojzdqh0EMhrLy ollIZlVPvPNfU/QFZ1tYFCbVHJ0tYpzYRfVVNaUg/xZajcgj3QMt/4tJcVBk/eOa3LMH jTZD+b9b52aNvA1Azam4doPPOgZqJuQ8HVjOE/xNno1spGd5DUQ9DD6H+W7dSJP7ke7P y/brkYbeUMD9vXkdbnn0Hc1qhzTmg7J/8mFjxgxsSyeM/0HEP1DRizG9K9Mbxz0myjQ9 X85UhlkRdPZ283Z2Sc/JdMDvpIu/7frP0c7adSXPLUG4NoiD/b3sLWcFdxSZsorJKG/V MT3w== X-Gm-Message-State: AOAM531JZYOe5AoJ8wXLHwjvuzc6hJwu0Z+I6vVvIpS5O7Zu+0ITMDQb m4iItzpGVOuRTvnZeXC+AE3t9OdR4xIB5w== X-Google-Smtp-Source: ABdhPJyJIB/QEeZyHhXjgPpMzZEl/VUM+crdmi7I9O/bUg0zsUehHawrAzMYaEkXvc1Gg/cedWvYYw== X-Received: by 2002:a62:1949:0:b029:241:be9d:c708 with SMTP id 70-20020a6219490000b0290241be9dc708mr10377552pfz.37.1617942735440; Thu, 08 Apr 2021 21:32:15 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7567:510e:1b47:ce92]) by smtp.gmail.com with ESMTPSA id il6sm737275pjb.56.2021.04.08.21.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 21:32:15 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Apr 2021 13:32:04 +0900 Message-Id: <20210409043208.1823330-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210409043208.1823330-1-hiroh@chromium.org> References: <20210409043208.1823330-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/5] 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..be2f710a 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. + - SensorTestPatternMode: + type: int32_t + draft: true + description: | + Control to select the sensor test pattern mode. Currently identical to + ANDROID_SENSOR_TEST_PATTERN_MODE. + + Mode of operation for the test pattern mode. + enum: + - name: SensorTestPatternModeOff + value: 0 + description: | + No test pattern mode is used. The camera device returns from the + image sensor. + - name: SensorTestPatternModeSolidColor + value: 1 + description: | + Each pixel in [R, G_even, G_odd, B] is replaced by its respective + color channel. + - name: SensorTestPatternModeColorBars + 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: SensorTestPatternModeColorBarsFadeToGray + value: 3 + description: | + The test pattern is similar to SensorTestPatternModeColorBars, + 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: SensorTestPatternModePn9 + 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: SensorTestPatternModeCustom1 + 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 Fri Apr 9 04:32:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11876 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 996D7BD16B for ; Fri, 9 Apr 2021 04:32:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E854C687FE; Fri, 9 Apr 2021 06:32:19 +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="WVE1s0Hk"; dkim-atps=neutral Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 65C5A6879F for ; Fri, 9 Apr 2021 06:32:18 +0200 (CEST) Received: by mail-pg1-x52c.google.com with SMTP id f29so2943970pgm.8 for ; Thu, 08 Apr 2021 21:32:18 -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=VUGAIDjTkjuUhahNCh14V0cenxuZqjvdUJFw7LfwF1E=; b=WVE1s0Hk8a3Wdb6GKXvk7onpUWcf2W3qdAmGBanCrWMOsJEziuihgJtK2cFg/RnMY8 lIBWrojr151gtw6NtZWsC6mcKO/5Pg97vv5t1N5qnSDVzaQs/GO/1wDs01JbquRZ3fOC NvN4PDahvtydh1zRwLWX9aWAkcVCu/UOo9hhU= 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=VUGAIDjTkjuUhahNCh14V0cenxuZqjvdUJFw7LfwF1E=; b=DfL5Hr7jAkaqvVMlHetbd91ExqNhxbD9U5cz5RvIBgyBzml4WAt6ghW7A8XZdsG6QT 2lD21dQPzgJ4PS8Gq9+6u7TzPhYDIWRHiIcSaBm+9Hz2+9brXPAoBTwzxaZyqjl102my vrz9uapkU3oTKGU1AxBEBXnV+ha0SE18EhCPAOA06Hlxrsv5BWVjX0NhFJNaA2txytKy UdsmpOGVH34mnlKvhReFeHWWG0+sWgWPKhMlidTv5n+rXRe/uUOdJKWhxq4HrD5q39gs XYjrAPi8YulmYqszahx0qBPSEouq4AMstIAN2lDrDBkn6BOXgLuaGNxH/Lvbk0kQ8RRY JKhg== X-Gm-Message-State: AOAM532DftIZaKAaw5jLt4/1b8pQ/W5++xRtFn6l+5LKWdk3ZdngnCl+ 0mBqZCjL9Kt0wHJO/mGXALTEWf+4TO10aA== X-Google-Smtp-Source: ABdhPJwPuthi3o/kdXblhPm/LEkrQWGyJzUjY9XZnvD6kmSGOONZkZP2uG9mNgvW5pYUcLNZ9N+GzQ== X-Received: by 2002:a65:4383:: with SMTP id m3mr11334327pgp.57.1617942736863; Thu, 08 Apr 2021 21:32:16 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7567:510e:1b47:ce92]) by smtp.gmail.com with ESMTPSA id il6sm737275pjb.56.2021.04.08.21.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 21:32:16 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Apr 2021 13:32:05 +0900 Message-Id: <20210409043208.1823330-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210409043208.1823330-1-hiroh@chromium.org> References: <20210409043208.1823330-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 2/5] libcamera: V4L2Subdevice: Add getter/setter function for 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 supported test pattern modes can be obtained by calling VIDIOC_QUERYMENU to a camera sensor device. This implements the getter and setter functions for the test pattern mode in V4L2SubDevice. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/v4l2_subdevice.h | 5 + src/libcamera/v4l2_subdevice.cpp | 104 ++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index d2b9ca55..f2f5d3f6 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -60,6 +60,9 @@ public: int setFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); + std::vector getAvailableTestPatternModes(); + int setTestPatternMode(int32_t testPatternMode); + static std::unique_ptr fromEntityName(const MediaDevice *media, const std::string &entity); @@ -74,6 +77,8 @@ private: unsigned int code); const MediaEntity *entity_; + + std::map testPatternModeMap_; }; } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 721ff5a9..130e9c4d 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -24,6 +24,7 @@ #include "libcamera/internal/media_object.h" #include "libcamera/internal/utils.h" +#include "android/metadata/system/camera_metadata_tags.h" /** * \file v4l2_subdevice.h * \brief V4L2 Subdevice API @@ -523,4 +524,107 @@ std::vector V4L2Subdevice::enumPadSizes(unsigned int pad, return sizes; } +/** + * \var V4L2Subdevice::testPatternModeMap_ + * \brief The map from controls::SensorTestPatternMode to an index value to be + * used for V4L2_CID_TEST_PATTERN. + * + * The map is constructed in getAvailableTestPatternModes() and referred in + * setTestPatternMode() to find a value associated with the requested test + * pattern mode. + */ +/** + * \fn V4L2Subdevice::getAvailableTestPatternModes() + * \brief Retrieve the available test pattern modes. + * + * \return The available control::SensorTestPatternMode values. + */ +std::vector V4L2Subdevice::getAvailableTestPatternModes() +{ + std::vector patternModes; + if (!testPatternModeMap_.empty()) { + for (const auto &mode : testPatternModeMap_) + patternModes.push_back(mode.first); + return patternModes; + } + + v4l2_queryctrl ctrl; + memset(&ctrl, 0, sizeof(ctrl)); + ctrl.id = V4L2_CID_TEST_PATTERN; + int ret = ioctl(VIDIOC_QUERYCTRL, &ctrl); + if (ret < 0) { + LOG(V4L2, Error) << "Unable to get test pattern mode :" + << strerror(-ret); + return {}; + } + + 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; + } + + const std::string modeName(reinterpret_cast(menu.name)); + std::optional androidTestPatternMode; + /* + * ov13858 and ov5670. + * No corresponding value for "Vertical Color Bar Type 3" and + * "Vertical Color Bar Type 4". + */ + if (modeName == "Disabled") { + androidTestPatternMode = + ANDROID_SENSOR_TEST_PATTERN_MODE_OFF; + } else if (modeName == "Vertical Color Bar Type 1") { + androidTestPatternMode = + ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS; + } else if (modeName == "Vertical Color Bar Type 2") { + androidTestPatternMode = + ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY; + } + + if (androidTestPatternMode) { + testPatternModeMap_[*androidTestPatternMode] = menu.index; + patternModes.push_back(*androidTestPatternMode); + } else { + LOG(V4L2, Debug) << "Skip test pattern mode: " + << modeName; + } + } + + return patternModes; +} + +/** + * \fn V4L2Subdevice::getAvailableTestPatternModes() + * \brief Set the test pattern mode. + * + * \return 0 on success or a negative error code otherwise. + */ +int V4L2Subdevice::setTestPatternMode(int32_t testPatternMode) +{ + auto it = testPatternModeMap_.find(testPatternMode); + if (it != testPatternModeMap_.end()) { + LOG(V4L2, Error) << "Unsupported test pattern mode: " + << testPatternMode; + + return -EINVAL; + } + + v4l2_control ctrl; + memset(&ctrl, 0, sizeof(ctrl)); + ctrl.id = V4L2_CID_TEST_PATTERN; + ctrl.value = it->second; + int ret = ioctl(VIDIOC_S_CTRL, &ctrl); + if (ret < 0) { + LOG(V4L2, Error) << "Unable to set test pattern mode: " + << strerror(-ret); + + return -EINVAL; + } + + return 0; +} } /* namespace libcamera */ From patchwork Fri Apr 9 04:32:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11877 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 760B1BD16B for ; Fri, 9 Apr 2021 04:32:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B5CE68804; Fri, 9 Apr 2021 06:32:21 +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="nlWlIpHT"; 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 BA96F602CB for ; Fri, 9 Apr 2021 06:32:19 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id y32so2928290pga.11 for ; Thu, 08 Apr 2021 21:32:19 -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=9UX/Pnfp6KSzqx9YQKtRbGf0cc/b41v8hSuDVpEZ5VE=; b=nlWlIpHTAsNy2kOGQ4xT6f6TLpH12Yc/6UxgYp9ET8O103P1fnI0yY67VaidObRCYs MwXtc4qRSTts1bN9tbQCym7lzzjo3r7kGEFHXRCoP0VLINrjWLCGG4fnCh6gwQ/V8EBM 3387wpqdarjG6RU6XDkLWFqxQEy7Gcx3SI6qc= 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=9UX/Pnfp6KSzqx9YQKtRbGf0cc/b41v8hSuDVpEZ5VE=; b=KIeEyIClj0zurnEidz11jirqTvgr9kG3VGpPkPH+SPsq3HkVMzwOumuhntnvVAnoh3 XwXlz8ODkFYq8xh43sKVXcDY5s0Wl/TbuHswZ34SpVgyNueHAAZVDFFCAkqzsie7lbJ9 bBWadF6pb66BIDBfxBSi2EpKiZpVSV90cvsda9IXxeUyH6J/YDetW5FI2DyfBgfFyV+g w9IZifw5X0MlkktbmAh53tEjUSFDz9WXlyWxYakZUoaWQLEiNVdqC06Pj3g+SXOFnEPG tB62emtSWz2quFhl2Gbvd76End9jYF6r9Qx6H+0ue5tKD09FwrCgerT+nCbxJbq7eT92 WN7A== X-Gm-Message-State: AOAM531vlSyet6dmvOMbIRXTUNePtfUkupx8WGLXKJc+4SLd+wujY2rk AgbKt+vovplIU7e8auNVzZY5gne3avrmPQ== X-Google-Smtp-Source: ABdhPJyRLX+MBF/QHhVEObnaJ+G799UAbkWEFvFskMo7c+kOtt51EaQ4yqWSbuBfKsHFqPCtHYxT2g== X-Received: by 2002:a63:4512:: with SMTP id s18mr11336232pga.275.1617942738282; Thu, 08 Apr 2021 21:32:18 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7567:510e:1b47:ce92]) by smtp.gmail.com with ESMTPSA id il6sm737275pjb.56.2021.04.08.21.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 21:32:17 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Apr 2021 13:32:06 +0900 Message-Id: <20210409043208.1823330-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210409043208.1823330-1-hiroh@chromium.org> References: <20210409043208.1823330-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/5] libcamera: CameraSensor: Expose 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 adds a getter function for available test pattern modes. The available test pattern modes are initialized one time on CameraSensor::init(). Signed-off-by: Hirokazu Honda --- include/libcamera/internal/camera_sensor.h | 6 ++++++ src/libcamera/camera_sensor.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3e98f71b..d924ae42 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -54,6 +54,11 @@ public: const std::vector &mbusCodes() const { return mbusCodes_; } const std::vector &sizes() const { return sizes_; } Size resolution() const; + const std::vector &availableTestPatternModes() const + { + return availableTestPatternModes_; + } + V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, const Size &size) const; @@ -89,6 +94,7 @@ private: V4L2Subdevice::Formats formats_; std::vector mbusCodes_; std::vector sizes_; + std::vector availableTestPatternModes_; Size pixelArraySize_; Rectangle activeArea_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index f7ed91d9..fba6cb06 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -262,6 +262,8 @@ int CameraSensor::init() } } + availableTestPatternModes_ = subdev_->getAvailableTestPatternModes(); + ret = validateSensorDriver(); if (ret) return ret; @@ -548,6 +550,12 @@ int CameraSensor::initProperties() * \return The supported frame sizes sorted in increasing order */ +/** + * \fn CameraSensor::availableTestPatternModes() + * \brief Retrieve the test pattern modes supported by the camera sensor + * \return The available test pattern modes. + */ + /** * \brief Retrieve the camera sensor resolution * From patchwork Fri Apr 9 04:32:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11878 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 17A92BD16B for ; Fri, 9 Apr 2021 04:32:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CB52D68808; Fri, 9 Apr 2021 06:32:22 +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="OscRek5h"; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 23C68687F6 for ; Fri, 9 Apr 2021 06:32:21 +0200 (CEST) Received: by mail-pf1-x431.google.com with SMTP id o123so3404588pfb.4 for ; Thu, 08 Apr 2021 21:32:21 -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=vsWwxDXMX5080odZxhA6IevxNdiFcMKuo4IlaZKtdaA=; b=OscRek5hjmwBqvX9a22MuH2781vK9kzWnBOTAmdwrShgrD6dzOcNd6DcREn3E4iKic FaZWm9yJQAQSjoru9T6E/vAXW45vDYPWI5I3HLKdk7E267CIz5CSTlQ4sqrM2NTtnFzs 3W8SEaoZCCwgDxNfK1t4lmB1cLPG/RUpCrAFQ= 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=vsWwxDXMX5080odZxhA6IevxNdiFcMKuo4IlaZKtdaA=; b=Xw4h6OoM/qGHSacADd2eqaZHGlIoFJPVskeSFNFdyN5GCfWDE6TZY7Us1Nm2d0whUP gqhsyTLIBpg1C/rPZKQWjPobubm02qXXteYsmhmJyEMdUTjegtqeUDI1YIXYP7pcYT4s KmxVYDL+1PWvmBT/zS6G78//sPbxDEOsVa70dTmrlsBcZufYuliR+eHydztdT+An8sNv CLK+vEgluRGDmO1BVA1T9LjQPf5IEokA5WZr967zBdmllHikL8okGkMNCu+el+nu75h2 Yrt4A049M9IF/JbrBp3/0mCEtrs71Al/JanYzgWjDe6jU1wxtoNiQgPs9ZqNScxJdJFd h22g== X-Gm-Message-State: AOAM532UzKhI9v4ACDnNr3Jw+Je5gk8bQqBq2yu0dHp5tVOPdGIZMHPY Kj95kTuTjb63CKwXQBUMnKpeZUTG7711YA== X-Google-Smtp-Source: ABdhPJySIpSHx7kguDCb4H/Fjlq5f82jWk6+j6Nk9A22hTJdI3Jnm+rRAB1XLJHBG7MUg/YE2AHgNQ== X-Received: by 2002:a63:3d48:: with SMTP id k69mr10989492pga.239.1617942739648; Thu, 08 Apr 2021 21:32:19 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7567:510e:1b47:ce92]) by smtp.gmail.com with ESMTPSA id il6sm737275pjb.56.2021.04.08.21.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 21:32:19 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Apr 2021 13:32:07 +0900 Message-Id: <20210409043208.1823330-5-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210409043208.1823330-1-hiroh@chromium.org> References: <20210409043208.1823330-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/5] libcamera: pipeline: ipu3: Report 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" Add available test pattern modes to controls. 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 519cad4f..c6ca87a7 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -995,6 +995,16 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) controls[&controls::ScalerCrop] = ControlInfo(minCrop, maxCrop, maxCrop); + const std::vector &availableTestPatternModes = + sensor->availableTestPatternModes(); + if (!availableTestPatternModes.empty()) { + std::vector controlValues; + for (int32_t value : availableTestPatternModes) + controlValues.emplace_back(value); + controls[&controls::draft::SensorTestPatternMode] = + ControlInfo(controlValues); + } + data->controlInfo_ = std::move(controls); return 0; From patchwork Fri Apr 9 04:32:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11879 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 771A9BD16B for ; Fri, 9 Apr 2021 04:32:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34772687F7; Fri, 9 Apr 2021 06:32:25 +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="HnxANvM/"; 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 917FF687F6 for ; Fri, 9 Apr 2021 06:32:22 +0200 (CEST) Received: by mail-pf1-x42e.google.com with SMTP id s11so3416993pfm.1 for ; Thu, 08 Apr 2021 21:32:22 -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=rt0niqZ40i9cEjc69uBp4Vek+/PtndSNNMtfOnooYt4=; b=HnxANvM/9MKi5Uri8y7yzZv19onvBtdHJ4hYt/Z3YAW74OVTrzjlBeB6JYmODiPM54 LSnwYvCt6qm10v8gyrrMjssM9bbST3QvTsvyszhqdjnijsskNyMPvYsta5pl9O5L3CTA fneDA6RDzzXI/O9LZgvrGgcpg2bTWMu0P/+bI= 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=rt0niqZ40i9cEjc69uBp4Vek+/PtndSNNMtfOnooYt4=; b=BwnJSgjQ0ajw4h27cit/zXbuUZBRwYu7/sm18gSFBlTjoE2yTADPVuvhB0brdG5d7i 9mziHf626pV9LoXsV8bueGdH59wx37pZT0DXm6Q5rb2fPE9eE2dpUY9h9FfHHZSVOOgS EaJD5Yiq87me5AttxrfSRsaABpkxi/Vqmgb8EuZBVXpo4/l0fy4TpUYXytCEe0mvyhqp CO+cj0Uf7Zjf2HqfFAS0uWUlsg3pf8MmkMlT/WZ98fdk0j2UFgvQux5CICxXdHSVxuwF 9reQtUeK4s04S+3inizbRNssjJowPALHpZJlnvN282cu3Z2VxD6lAb3TIJX4fmnVppST B1MQ== X-Gm-Message-State: AOAM5300o3S7O7g7MA/oHo1ynvLLOqd2u6DUUTz56ziSq5r28dWntAAS m7aMRSrHz5BTlrf1aePtT+AlsuYSF8Y/5Q== X-Google-Smtp-Source: ABdhPJz/BJwhXy2mYFCuJiSUI9atbM+sySGSALys9PoEnfmW9szAp9nOu7YXeICD8yZ0vfbE3iEcMg== X-Received: by 2002:a63:604:: with SMTP id 4mr11261168pgg.267.1617942741087; Thu, 08 Apr 2021 21:32:21 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7567:510e:1b47:ce92]) by smtp.gmail.com with ESMTPSA id il6sm737275pjb.56.2021.04.08.21.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 21:32:20 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Apr 2021 13:32:08 +0900 Message-Id: <20210409043208.1823330-6-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210409043208.1823330-1-hiroh@chromium.org> References: <20210409043208.1823330-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 5/5] 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 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 89044efa..8701cc69 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1075,12 +1075,22 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation_, 1); - std::vector testPatterModes = { - ANDROID_SENSOR_TEST_PATTERN_MODE_OFF, + const auto &sensorTestPatternsInfo = + controlsInfo.find(&controls::draft::SensorTestPatternMode); + std::vector testPatternModes = { + ANDROID_SENSOR_TEST_PATTERN_MODE_OFF }; + if (sensorTestPatternsInfo != controlsInfo.end()) { + const auto &values = sensorTestPatternsInfo->second.values(); + if (!values.empty()) { + testPatternModes.clear(); + for (const auto &value : values) + testPatternModes.push_back(value.get()); + } + } staticMetadata_->addEntry(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, - testPatterModes.data(), - testPatterModes.size()); + testPatternModes.data(), + testPatternModes.size()); std::vector physicalSize = { 2592, 1944,