From patchwork Tue Jun 22 02:36:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12672 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 04ECCC321B for ; Tue, 22 Jun 2021 02:37:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77A2F6893A; Tue, 22 Jun 2021 04:37:03 +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="d8OqXYYT"; 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 814A668931 for ; Tue, 22 Jun 2021 04:37:01 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id h4so4333929pgp.5 for ; Mon, 21 Jun 2021 19:37: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:mime-version :content-transfer-encoding; bh=Zz7WzGYUO2IB6wWWddKhE1Rv1w/g7DqXt0ZLxY9iGXE=; b=d8OqXYYTsRnNgJDB/4pdmW2MrlF0SbjGExax+FzNpe1xpbIkR6djtkhs/1Nm0AGD2p MQGwDu2WbEVUEvs/iiL/WcVBZMWKc/3wZGlDFiRgTl7n1iiB125llizrfF9N0N+fqjkV kqUFhTJfHyQeouvtjggxQOvBUMTsOAXU/Q5YY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Zz7WzGYUO2IB6wWWddKhE1Rv1w/g7DqXt0ZLxY9iGXE=; b=UGF7LKI3vAshTKCk34944XcbE8MqYWeZ1an08XLAmrwRGvtNPXXCMgTQqVQFS5HbMs PBD1/kFAyVdavCcvDys/dfuyGwFSvoasDF1ipBa3867rh6eQ2Hj9QnR21ty/yHh6vnwg xdslPBPHqqMozROHtrqslFJtPsUQ+L9WtFIHLxcfQB5Gcd0a9oI22s0PS8vHe3RdJByg vpC39hIjW0GQVOwR4sxjp2t4iHrTzgzWnyVUoIbGVX8UmNZN5sM3FCelhPnqs53inDMh sku98X16cRIViptp3p67kb1ZPLU49H7dlNcCYgluHi0JPWjjeHDNPgw/WqsulUmkQnhg Ct1A== X-Gm-Message-State: AOAM530CSGDNQZyCHl8JYJyk3T4TkfEC0dgfpBseVqvRGdlvvwKDyUFp Lqs9RIkAIo5bA4Vhe08vVg5PYFU8zfuHQg== X-Google-Smtp-Source: ABdhPJzV8Q5erra/3Wz73Qi2qEwUmlyxO2f3IDkEBg0+TXdZyH0b/kdDt6rgcWVUcla+PkIzVzyCCg== X-Received: by 2002:a63:4815:: with SMTP id v21mr1477813pga.213.1624329419456; Mon, 21 Jun 2021 19:36:59 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a025:f98b:b63b:e6b2]) by smtp.gmail.com with ESMTPSA id o7sm18947145pgs.45.2021.06.21.19.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 19:36:59 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jun 2021 11:36:50 +0900 Message-Id: <20210622023654.969162-1-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/5] libcamera: camera_sensor: Reverse the key and value of test pattern mode map 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 key and value of the test pattern mode are originally the index of v4l2 control and the corresponding test pattern mode control value. This key and value are useful in the initialization for reporting available test pattern modes. However, the map of the reversed key and value is much more useful in applying a requested test pattern mode. Reverses the key and value of the map as the initialization is one time but the test pattern mode request will be multiple times. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 8 +++++-- src/libcamera/camera_sensor_properties.cpp | 28 +++++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 3e135353..70bbd97a 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -319,11 +319,15 @@ void CameraSensor::initTestPatternModes( return; } + std::map indexToTestPatternMode; + for (const auto& it : testPatternModes) + indexToTestPatternMode[it.second] = it.first; + for (const ControlValue &value : v4l2TestPattern->second.values()) { const int32_t index = value.get(); - const auto it = testPatternModes.find(index); - if (it == testPatternModes.end()) { + const auto it = indexToTestPatternMode.find(index); + if (it == indexToTestPatternMode.end()) { LOG(CameraSensor, Debug) << "Test pattern mode " << index << " ignored"; continue; diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp index f660743a..d0b2ae0e 100644 --- a/src/libcamera/camera_sensor_properties.cpp +++ b/src/libcamera/camera_sensor_properties.cpp @@ -38,9 +38,9 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties) * \brief The physical size of a pixel, including pixel edges, in nanometers. * * \var CameraSensorProperties::testPatternModes - * \brief Map that associates the indexes of the sensor test pattern modes as - * returned by V4L2_CID_TEST_PATTERN with the corresponding TestPattern - * control value + * \brief Map that associates the TestPattern control value with the indexes of + * the corresponding sensor test pattern modes as returned by + * V4L2_CID_TEST_PATTERN. */ /** @@ -55,11 +55,11 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { "imx219", { .unitCellSize = { 1120, 1120 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 1, controls::draft::TestPatternModeColorBars }, - { 2, controls::draft::TestPatternModeSolidColor }, - { 3, controls::draft::TestPatternModeColorBarsFadeToGray }, - { 4, controls::draft::TestPatternModePn9 }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, + { controls::draft::TestPatternModeSolidColor, 2 }, + { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, + { controls::draft::TestPatternModePn9, 4 }, }, } }, { "imx258", { @@ -70,22 +70,22 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { "ov5670", { .unitCellSize = { 1120, 1120 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 1, controls::draft::TestPatternModeColorBars }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, }, } }, { "ov13858", { .unitCellSize = { 1120, 1120 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 1, controls::draft::TestPatternModeColorBars }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, }, } }, { "ov5693", { .unitCellSize = { 1400, 1400 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 2, controls::draft::TestPatternModeColorBars }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 2 }, /* * No corresponding test pattern mode for * 1: "Random data" and 3: "Colour Bars with From patchwork Tue Jun 22 02:36:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12673 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 45BABC321B for ; Tue, 22 Jun 2021 02:37:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D83B26893F; Tue, 22 Jun 2021 04:37: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="gGX0GNNG"; 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 74AC568932 for ; Tue, 22 Jun 2021 04:37:02 +0200 (CEST) Received: by mail-pg1-x536.google.com with SMTP id p9so1523320pgb.1 for ; Mon, 21 Jun 2021 19:37:02 -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=qC6xpyNnKBKxXei/YEgiG06a5xluSsOfyqqMgqQxzA4=; b=gGX0GNNGXYJEW2Vvp6PNDpCz2anucxcZlXV1UkzQUq1sBhibJP7BCS5TwqtkbCrp9T bdW4BVRoNXdjM6peQ77j6l93wen4FLQ8GO6c0NTHKSesHmJsqaK9EoIeRa+7zXBZuXjG NUigEo4EJzJ1S7FGg622Ou2eM1OSb4DBQ66G8= 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=qC6xpyNnKBKxXei/YEgiG06a5xluSsOfyqqMgqQxzA4=; b=M8mYp9fKtiH43596SxiI2Z3eui+OhAazn5ol6DQ7CymoNFiSJeCpqYEZN5UqRUtYXn QQk2USYZY5GT78Kl3YgTmBUkmY1k2v2cy++hIjj3GjEjkKHjhqO9+zsUJoweYgulXbk4 l7GoF5YAxouhrUjwKo0rpOeHs9fMZY1zdRCnYaCPxbVpMe6+UXB+18eVMYRmzIzkywmX S3JyrYUindJZ/4Xs2+Je1b/4wzwjMIK6EglZ792sLDyf04to4ykN10/nvG4mmomgOax8 DKtWgcANBBH+TgkyL8kbfNnM1WFMoLKRELvy0qttG1Pz8vjDVKVr/sK40KGkYUBs1rGX MnAg== X-Gm-Message-State: AOAM530xUdkgnlhUY8Ym3F/S+Nw+s4l02xWDq4wC6l2khKX8O+sJx/RY pmRj/56Z5CUmmDOiE0030eGbsLqlMbmZjQ== X-Google-Smtp-Source: ABdhPJybxfnGjF2To51FnmJWsO0qajYpr4PvWvY4cUAsNh/NayG6CagCTtVyaBeWKtDwKs9nMboUnA== X-Received: by 2002:a63:5445:: with SMTP id e5mr1513954pgm.62.1624329420960; Mon, 21 Jun 2021 19:37:00 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a025:f98b:b63b:e6b2]) by smtp.gmail.com with ESMTPSA id o7sm18947145pgs.45.2021.06.21.19.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 19:37:00 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jun 2021 11:36:51 +0900 Message-Id: <20210622023654.969162-2-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210622023654.969162-1-hiroh@chromium.org> References: <20210622023654.969162-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 2/5] libcamera: camera_sensor: Enable to set a 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" Provides a function to set the camera sensor a test pattern mode. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 39 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index e133ebf4..8b9f84c9 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -43,6 +43,7 @@ public: { return testPatternModes_; } + int setTestPatternMode(uint8_t testPatternMode); V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, const Size &size) const; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 70bbd97a..ce8ff274 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -507,6 +507,45 @@ Size CameraSensor::resolution() const * \return The list of test pattern modes */ +/** + * \brief Set the camera sensor a specified controls::TestPatternMode + * + * \return 0 on success or a negative error code otherwise + */ +int CameraSensor::setTestPatternMode(uint8_t testPatternMode) +{ + if (std::find(testPatternModes_.begin(), testPatternModes_.end(), + testPatternMode) == testPatternModes_.end()) { + LOG(CameraSensor, Error) << "Unsupported test pattern mode: " + << testPatternMode; + return -EINVAL; + } + + const CameraSensorProperties *props = CameraSensorProperties::get(model_); + if (!props) + return -EINVAL; + + auto it = props->testPatternModes.find(testPatternMode); + ASSERT(it != props->testPatternModes.end()); + const uint8_t index = it->second; + + ControlList ctrls = getControls({ V4L2_CID_TEST_PATTERN }); + if (ctrls.empty()) { + LOG(CameraSensor, Error) + << "Failed to retrieve test pattern control"; + return -EINVAL; + } + + ControlValue value = ctrls.get(V4L2_CID_TEST_PATTERN); + if (value.get() == index) + return 0; + + value.set(index); + ctrls.set(V4L2_CID_TEST_PATTERN, value); + + return setControls(&ctrls); +} + /** * \brief Retrieve the best sensor format for a desired output * \param[in] mbusCodes The list of acceptable media bus codes From patchwork Tue Jun 22 02:36:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12674 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 18C59C321B for ; Tue, 22 Jun 2021 02:37:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8F0156893C; Tue, 22 Jun 2021 04:37:06 +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="J0Ma+yPD"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DB96468935 for ; Tue, 22 Jun 2021 04:37:03 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id x22so8118412pll.11 for ; Mon, 21 Jun 2021 19:37: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=PEUhCurabQ7SLRxMeXHtynWRRCGWPJc8pvJwqNePAac=; b=J0Ma+yPDbMQW5H1GeOrTkSTsvngKbe/bBk7v/WMZjj5SuK6WiNxoYLt7g9KtpGmc5y BO0Bvr8Y15D9wDwmcWh8f6WUKH/iXGug4Llg5ZlTZD5SwasEgzgx0+2ub0W29bFHtFmH I0Cfme7Ahp5kEj5kns/YhmdXh1JIn7/IKhSw8= 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=PEUhCurabQ7SLRxMeXHtynWRRCGWPJc8pvJwqNePAac=; b=HcV4a/obObSmCNOtCLFnuEbDLD6RM80Q0ybJDT0oIHyfrsTPKgjEuVUZ9TZmqrGcmY KCoODwakv+Xlc4uVmz4G027B4i2ow5rv4wnUUcRDe094ZRU4R9LIjATDqKWil0Va9t77 /LlZBs22nyyg0Dg9gSLO+e2hzT2MbZdLdUaj8odka81kCTNw9HlR5PoNPGLlDatu1yie sti6QtXwqZ5R4Jar6MuabZDtsDktmnqjZ6Xrj+jULB010Ln7hsS9rDliDK+TtyZcIxtP IwJX9N9Jn/QknYCh/ESdlWPm3f4UX/nLRB7q9s9tXVtglbpi7OUslhr9MyMk8Z2SFQvR QJmg== X-Gm-Message-State: AOAM533lV0hkZS03jmAQTCHLDhoA9xuvnUR8wCF8Yi3Krd2/HgLOl7Ju rK82ZvqMHpk8wIPL9uSAoF737OJ7PioXlw== X-Google-Smtp-Source: ABdhPJzga2SI3nXeU4VtmBvkSVUWLAXIHV/zh+GGZqDWez27ut+ZFgOKAll6pHh8dnq/iE8l3JqHkA== X-Received: by 2002:a17:902:c613:b029:122:641e:8720 with SMTP id r19-20020a170902c613b0290122641e8720mr16001817plr.41.1624329422342; Mon, 21 Jun 2021 19:37:02 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a025:f98b:b63b:e6b2]) by smtp.gmail.com with ESMTPSA id o7sm18947145pgs.45.2021.06.21.19.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 19:37:02 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jun 2021 11:36:52 +0900 Message-Id: <20210622023654.969162-3-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210622023654.969162-1-hiroh@chromium.org> References: <20210622023654.969162-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: ipu3: Disable a sensor test pattern mode at initialization 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" Turns off a sensor test pattern mode at the initialization of the sensor. Without this, the camera sensor is configured with the last test pattern mode that has been set. Signed-off-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/cio2.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 1be2cbcd..8548f749 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -192,6 +193,13 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat) LOG(IPU3, Debug) << "CIO2 output format " << outputFormat->toString(); + ret = sensor_->setTestPatternMode(controls::draft::TestPatternModeOff); + if (ret) { + LOG(IPU3, Error) + << "Failed to reset test pattern mode: " << ret; + return ret; + } + return 0; } From patchwork Tue Jun 22 02:36:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12675 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 D2EA5C321B for ; Tue, 22 Jun 2021 02:37:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED4756893E; Tue, 22 Jun 2021 04:37:06 +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="TjTad1uy"; 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 8DE7068932 for ; Tue, 22 Jun 2021 04:37:05 +0200 (CEST) Received: by mail-pf1-x42a.google.com with SMTP id c5so2601786pfv.8 for ; Mon, 21 Jun 2021 19:37:05 -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=gzOEmV+QUcgTBzBz3f7jfAL9lrYpj5bnbGr4JngLmwM=; b=TjTad1uylHJ0hBoFLSTxXuPiAIuxa/8PpnMXnd8ppaN6XR0JiDMnNScxg+vtYMAxTS Fbk+2ikVs98hOrPMEwWc0tP8ItG61zSXkX9pAX4Rgo4lkMR0Q2odx71YUoA71r5eyNdY 70gRoisBOIlEZDFo79y5Aj41Tov4Hx2V39Dbk= 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=gzOEmV+QUcgTBzBz3f7jfAL9lrYpj5bnbGr4JngLmwM=; b=q9NWr4eKwfVXislST1MgzOozsTknEBnoqr91PyudcEGpYT1USCwAeHVPmFRjU14beg pmAZ740eWEFfs/IlL6wraSTanvR6HoylfSTnK9Qrppz2Y8lcFFu9GX1xHl8y3/vHXIOc m0g2PTn5ldkNrr/vGz0Po/3sizyJ6n6+MMyfmhrzQwhjGARjfZxx6F4bOor7aDVKGm7d stDNVkNssk8L9KRzlqKwhzoS7I/7HU1HMk9Fpgh7COLu0M+yjKRwtjd1CiGfp/5n+dwY ktBSVUKLci631kPANc1UG8BvWa1AoVGYH+g061NhecIrM+lDmlccMoTNUhsBFvl/cSyZ UGkg== X-Gm-Message-State: AOAM531jHj5Og+LWb3Iw4sU8wXXrtKlc/qymEJfp008tbQ5nG5uPyegz toDZkpePPOWE0TGalrSVHGXhekvCNytGUQ== X-Google-Smtp-Source: ABdhPJw3tUWz7UQvh0mxaDuGuxn9Z9EAF93KPkSE5CbeKudpSEJcRAIYmbZjTnAr2khguYIZ1lQ78A== X-Received: by 2002:a63:5153:: with SMTP id r19mr1542025pgl.56.1624329423818; Mon, 21 Jun 2021 19:37:03 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a025:f98b:b63b:e6b2]) by smtp.gmail.com with ESMTPSA id o7sm18947145pgs.45.2021.06.21.19.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 19:37:03 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jun 2021 11:36:53 +0900 Message-Id: <20210622023654.969162-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210622023654.969162-1-hiroh@chromium.org> References: <20210622023654.969162-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 4/5] libcamera: ipu3: Apply a requested 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" Apply a camera sensor a requested test pattern mode. The test pattern mode can be specified per frame. Signed-off-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/cio2.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 8548f749..9d1ff07d 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "libcamera/internal/camera_sensor.h" @@ -289,6 +290,20 @@ FrameBuffer *CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer) buffer->setRequest(request); } + if (request->controls().contains(controls::draft::TestPatternMode)) { + const uint8_t testPatternMode = + static_cast(request->controls().get( + controls::draft::TestPatternMode)); + int ret = sensor_->setTestPatternMode(testPatternMode); + if (ret) { + LOG(IPU3, Error) + << "Failed to set test pattern mode: " << ret; + } else { + request->metadata().set(controls::draft::TestPatternMode, + testPatternMode); + } + } + int ret = output_->queueBuffer(buffer); if (ret) return nullptr; From patchwork Tue Jun 22 02:36:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12676 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 89F36C321B for ; Tue, 22 Jun 2021 02:37:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 437A868EA1; Tue, 22 Jun 2021 04:37:09 +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="c4RDou7u"; dkim-atps=neutral Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C9CFA68940 for ; Tue, 22 Jun 2021 04:37:06 +0200 (CEST) Received: by mail-pj1-x1031.google.com with SMTP id g24so11201363pji.4 for ; Mon, 21 Jun 2021 19:37: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=B0s4KHmAp6nPmFW5JVa7GT7U2/8B2OuqQN0WjCdQu0w=; b=c4RDou7uyXfiPl+OBPgwmAKCy0TS/npf9SF+XeesvNrzndxZMJTtF56zVdKcuQY9oc samANHaTZsZGJY4aw8+cMr+Li34DiEL93heQNjXZIxXg/UpCtmvO/vHF0T33I8yMeUUJ jd8ZK7YbeRwk18kB0QHD1XaMfBGUg54cj9E1M= 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=B0s4KHmAp6nPmFW5JVa7GT7U2/8B2OuqQN0WjCdQu0w=; b=ADctxWmkPhij8DV1sD05o0ohWyt3yGShfeKMVO1Yf4rfPtXGnPpHihavpSjnUhTfGj Ow1JVJQ8aw/WfH8SoPPsobeeizOeGCNBH69B6FaBTOTVbj9J3HhAmHNiwqZYL/RlFG1f yv3rt2kroWSvzSOqbBo4k76YFtII5+tVdkp4hhuD8Xevr9Je+MfTcQkl6AhqvnEB0iJl lwK4LS1FFcnq+GfqPrNQg7mnTfAYAt/h9Xl5d4IX5ImPtsM2q8R+E9qyBKV1QveUvPfz FS7FTCRLcBY5g1BzKgGugGRNLFJf85IPwngKz4wbUI7o3sX5Oxno6/bVlkx7SHqXHilP XT9w== X-Gm-Message-State: AOAM533shgcz8PGd7D2KVIQZZlN1A7efoLvGp/3xsn/wiWciUxg2LmRw iV26ZccMj5vfw1x8y+FIpHitCN6vP3bQ0A== X-Google-Smtp-Source: ABdhPJz9lzaLbMQ/ryqpuRLrS6uQ8ovzBH/GVMVx02TuChOICy/71EOsv5hgv9nnKJ+euS2aykLqow== X-Received: by 2002:a17:902:868d:b029:11e:6556:acea with SMTP id g13-20020a170902868db029011e6556aceamr20453907plo.59.1624329425245; Mon, 21 Jun 2021 19:37:05 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a025:f98b:b63b:e6b2]) by smtp.gmail.com with ESMTPSA id o7sm18947145pgs.45.2021.06.21.19.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 19:37:04 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jun 2021 11:36:54 +0900 Message-Id: <20210622023654.969162-5-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210622023654.969162-1-hiroh@chromium.org> References: <20210622023654.969162-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 5/5] android: camera_device: Propagate the requested 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" Propagate the requested test pattern mode to libcamera::Camera through libcamera::Request and also set the android metadata to the test pattern mode contained by the complete Request. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 50 ++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 8c71fd06..5c2100ad 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1933,16 +1933,57 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor) return 0; /* Translate the Android request settings to libcamera controls. */ + ControlList &controls = descriptor->request_->controls(); camera_metadata_ro_entry_t entry; if (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) { const int32_t *data = entry.data.i32; Rectangle cropRegion{ data[0], data[1], static_cast(data[2]), static_cast(data[3]) }; - ControlList &controls = descriptor->request_->controls(); controls.set(controls::ScalerCrop, cropRegion); } + if (settings.getEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, &entry)) { + const int32_t data = *entry.data.i32; + switch (data) { + case ANDROID_SENSOR_TEST_PATTERN_MODE_OFF: + controls.set(controls::draft::TestPatternMode, + controls::draft::TestPatternModeOff); + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR: + controls.set(controls::draft::TestPatternMode, + controls::draft::TestPatternModeSolidColor); + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS: + controls.set(controls::draft::TestPatternMode, + controls::draft::TestPatternModeColorBars); + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY: + controls.set(controls::draft::TestPatternMode, + controls::draft::TestPatternModeColorBarsFadeToGray); + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_PN9: + controls.set(controls::draft::TestPatternMode, + controls::draft::TestPatternModePn9); + break; + + case ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1: + controls.set(controls::draft::TestPatternMode, + controls::draft::TestPatternModeCustom1); + break; + + default: + LOG(HAL, Error) + << "Unknown test pattern mode: " << data; + + return -EINVAL; + } + } + return 0; } @@ -2429,6 +2470,13 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect); } + if (metadata.contains(controls::draft::TestPatternMode)) { + const int32_t testPatternMode = + metadata.get(controls::draft::TestPatternMode); + resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, + testPatternMode); + } + /* * Return the result metadata pack even is not valid: get() will return * nullptr.