From patchwork Fri Jun 11 08:42:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12564 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 C4FEEC320B for ; Fri, 11 Jun 2021 08:42:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 81BD66892F; Fri, 11 Jun 2021 10:42:41 +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="hTAbdKRL"; 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 60B3F6029E for ; Fri, 11 Jun 2021 10:42:37 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id x19so2496447pln.2 for ; Fri, 11 Jun 2021 01:42:37 -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=U9OEYzue8vc7okX16AMlQ3ov9LGscixMDny6HO81ri8=; b=hTAbdKRLoJLlyofT1c8sN9PB/sLMdGVyZkzez3hRxWMTuGHN4xlmo6BZmR2fyhm/Ma AErpI4jzY6aN/mLsY+VK2nkFgsrmNK+1mQocaIsGnfJufFGWaj5tx8IQWUvpXRglSAZ0 igzue8e7lh4MoraJr3U5TMptuyhmaJvFHVpCM= 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=U9OEYzue8vc7okX16AMlQ3ov9LGscixMDny6HO81ri8=; b=pHl9oRRxMcBeU8e39ZJuAWr5lcGgtMfP9is3+iaNDoU3TFVazOeH6Q0XMTAMeZdJBI E1ubXJP4H+jsQfRFLM5wUvpqaYcagnb/eTeKPFtpH42kUMS24SzA+Q8rjXWZDc8hsXic EojIS+Io/JFQ6U+2qJdxdYciNOgQ6Fb8F+7tNUIQ+l1tmQFjfqLdQzJk2mBf7dh1dvFt /Oyc5+k+mNG5hW6CG3EqsQymZNTl4DAMczD+Je/n2DFcpCORYFpEt/ituA7L3O6mkrie cHUo7Fsp29x/gwaptEqlYMlmNurCAH3FuQGS6l7nETBruj/L7To6OzZkvSQKMpU6+nwq kvow== X-Gm-Message-State: AOAM532r0DWUMzLpZXcKGHpG5wvFMPjIjvqE+8RrXcSxP6a1x12yQ6jD o6NBFE6nvBuYaQs9mTwu1GlZnE7pyUgc8g== X-Google-Smtp-Source: ABdhPJy/yjLigY+VDO4eSDoxzNI28JKgOiWcniM3Azy87tYrd/uW0OVFDbWmbdKcOUTyUaQi0HK/Iw== X-Received: by 2002:a17:90a:c384:: with SMTP id h4mr3445070pjt.134.1623400955870; Fri, 11 Jun 2021 01:42:35 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:367e:c2e4:d691:eca1]) by smtp.gmail.com with ESMTPSA id 20sm4323542pfi.170.2021.06.11.01.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 01:42:35 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Jun 2021 17:42:25 +0900 Message-Id: <20210611084228.1830629-2-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210611084228.1830629-1-hiroh@chromium.org> References: <20210611084228.1830629-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/4] 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 | 7 ++-- src/libcamera/camera_sensor.cpp | 40 ++++++++++++++++++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index e133ebf4..834d3246 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -39,10 +39,8 @@ public: const std::vector &mbusCodes() const { return mbusCodes_; } const std::vector &sizes() const { return sizes_; } Size resolution() const; - const std::vector &testPatternModes() const - { - return testPatternModes_; - } + std::vector testPatternModes() const; + int setTestPatternMode(uint8_t testPatternMode); V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, const Size &size) const; @@ -84,6 +82,7 @@ private: std::vector mbusCodes_; std::vector sizes_; std::vector testPatternModes_; + std::map testPatternModeToIndex_; Size pixelArraySize_; Rectangle activeArea_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 3e135353..d2f033a5 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -329,7 +329,7 @@ void CameraSensor::initTestPatternModes( continue; } - testPatternModes_.push_back(it->second); + testPatternModeToIndex_[it->second] = index; } } @@ -496,12 +496,48 @@ Size CameraSensor::resolution() const } /** - * \fn CameraSensor::testPatternModes() * \brief Retrieve all the supported test pattern modes of the camera sensor * The test pattern mode values correspond to the controls::TestPattern control. * * \return The list of test pattern modes */ +std::vector CameraSensor::testPatternModes() const +{ + return utils::map_keys(testPatternModeToIndex_); +} + +/** + * \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) +{ + auto it = testPatternModeToIndex_.find(testPatternMode); + if (it == testPatternModeToIndex_.end()) { + LOG(CameraSensor, Error) << "Unsupported test pattern mode: " + << testPatternMode; + return -EINVAL; + } + + 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 From patchwork Fri Jun 11 08:42:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12565 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 9813EC320B for ; Fri, 11 Jun 2021 08:42:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D39DE68939; Fri, 11 Jun 2021 10:42:41 +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="dHqDv8kz"; 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 E58D46029E for ; Fri, 11 Jun 2021 10:42:38 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id h12so2491964plf.4 for ; Fri, 11 Jun 2021 01:42:38 -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=S/CTBALndrol7bWOFs/wylrYjCw+G6VOSg2fPR34U8E=; b=dHqDv8kzyjpyd1R+fXlETOCZU86gxypoOGZOMDPoDqPebbQqbA+JCYMuWFJD0dsnGJ j9jlGh7ZuL7pr1m5hdtwz/r0DdyLQsiPeRA1CxTS/30HCv7YPiJ7RIMalhPbzD8wj0qA 0uoqk4xhgk6PT25U8kk4x4ji12ow/84SqMUoQ= 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=S/CTBALndrol7bWOFs/wylrYjCw+G6VOSg2fPR34U8E=; b=q3aRsC2jYD9i5QLlRDyajZFJA//Pq8hRL2C0ADfzn+OOJroF9y+cyAAKstkehBRid+ MX4EKt4a8HtcJTEIW/ROcAwDPmhML/u2c9PGyCXX7l0UVgIjza28M/qhsK9EX/Me7Tzy O5kFh9lgw7pxlLFNrUsWjOl+f+PMeA+9X2rWBHgxa+ontEg63qPJhtj3PO4vlCAFKdd5 Rfk7kpKzYfaoCdw6z0F5Gw1d5KXW1aotRgi6oHzD+bwECjFBCzm5j73ci8xLIuZ2A0wC oCocUxqxFVaJbjoHhjNuZi55P9OqMWNYIrAFxZ23lvwRO3//PZ9KgKQbFYbo7/KHlraq 7zOw== X-Gm-Message-State: AOAM531QPfc+cck1Tcreo5ypp7MeaCcyjL5G8fyBGTZpFvq6AUzlnw9s t7kk5IRE42fc/nEVB/v5scvg98sRqr1kIQ== X-Google-Smtp-Source: ABdhPJzggJvbkNRBm4oWoaxgdNBNz3V/A9jdJNzFclYwHeibuahZtITRvgS5Jjbh+RI2ErTa0hIQYA== X-Received: by 2002:a17:90a:dac1:: with SMTP id g1mr8021092pjx.199.1623400957334; Fri, 11 Jun 2021 01:42:37 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:367e:c2e4:d691:eca1]) by smtp.gmail.com with ESMTPSA id 20sm4323542pfi.170.2021.06.11.01.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 01:42:36 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Jun 2021 17:42:26 +0900 Message-Id: <20210611084228.1830629-3-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210611084228.1830629-1-hiroh@chromium.org> References: <20210611084228.1830629-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 2/4] 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 Fri Jun 11 08:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12566 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 28F90C3214 for ; Fri, 11 Jun 2021 08:42:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 301996893B; Fri, 11 Jun 2021 10:42:42 +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="ND1qP+vS"; 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 551C96029E for ; Fri, 11 Jun 2021 10:42:40 +0200 (CEST) Received: by mail-pj1-x1031.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso6913648pjx.1 for ; Fri, 11 Jun 2021 01:42:40 -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=oT1OFuDrbYyFFxu/+kTv9BHGwA3kSmtUGooGvF71484=; b=ND1qP+vSVFfjBDc4dYR58HMBcyyPLaTl4QP5CLK5zJIi7+lQXvNAhmm8iZrwBzkmDV vKyKMSBkQiYNW6sdjPlrtks4do7f4YX4bb6We5+SpbWSlo2LU186ioD62aLM1qwzELiU UFelZw2ezo6d/HWZuRmMIdmR6GiAc2Det6wHw= 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=oT1OFuDrbYyFFxu/+kTv9BHGwA3kSmtUGooGvF71484=; b=GBlBU6reWa6gvn9ttPsH+s9eRR8WGxjEiqyCIELW3Q0aFb6n1dCz4k03mZaI/y7ZTW B3A+oRzGzIXkQwM5My+zsS664/s6eSa/t6QHQGQY8do5osLX1dPH34SZveGDilLizkfp b8MCklEj2q8NEg3nvQQCOAV+pqtnVGy2yIQazHpUdPWMsTAj+Z1tzR4R5/ydJnBoanW2 2Ku9aSw+xqG2gdz6XTjYcOQFcnDeesFdQXBa/tTkfP9YaMPJ4Xj+4OLQyU2UengYU52u 49zFs5Z8D7/yxN3+gdpBXd2ak8L5LdQPFX9/5aNIPnicGdYyU6ei+hSvfBeLfLiosaQI +A4A== X-Gm-Message-State: AOAM531GYabEGcZ93sgQDel7s0v6I4S0CZmwB5kVCHhs/XURgOQ6ly2M v9+UvfzX5XHkOD5eE3jV/AR4GJpUep53uQ== X-Google-Smtp-Source: ABdhPJx7RfCImwru/H7n9gq4tC2tGjyowGj6+wU4PjK6eDexyy003/UwlVwK2gZYZ0nxIdEsilhjBA== X-Received: by 2002:a17:90b:1e46:: with SMTP id pi6mr8137079pjb.212.1623400958810; Fri, 11 Jun 2021 01:42:38 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:367e:c2e4:d691:eca1]) by smtp.gmail.com with ESMTPSA id 20sm4323542pfi.170.2021.06.11.01.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 01:42:38 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Jun 2021 17:42:27 +0900 Message-Id: <20210611084228.1830629-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210611084228.1830629-1-hiroh@chromium.org> References: <20210611084228.1830629-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/4] 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 Fri Jun 11 08:42:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12567 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 3B99AC320B for ; Fri, 11 Jun 2021 08:42:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5F3F68938; Fri, 11 Jun 2021 10:42:43 +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="DEb8Li22"; dkim-atps=neutral Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B41E668938 for ; Fri, 11 Jun 2021 10:42:41 +0200 (CEST) Received: by mail-pl1-x631.google.com with SMTP id v12so2482526plo.10 for ; Fri, 11 Jun 2021 01:42:41 -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=ISKwOyPLfe/Qtg2gfe2ELFZN2Vcig6j4flu625qxuEg=; b=DEb8Li22r+Q2sJDsmC+MrUFJ5EmljsBT9H0cX3iYX1J37TwGGMxH0gSqJvlJ+nd5uY zay2O1mjXcOfpcu3oKvGepYwneaKPZWMoadt2DxBcmQqM5GFamwU/oVxPhobQsEUvHLD LxULRRSwiamAKjlUT3Mq03pqythnGtCVm1g2Q= 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=ISKwOyPLfe/Qtg2gfe2ELFZN2Vcig6j4flu625qxuEg=; b=Qw7oHAZgyCVuYkPaFANZMbQXJfAyEyaPt6nd0PpdTtSjpIeipObikweFI3kDFyw+K7 xOmztsDf5M6XKTsqXQqPCfd5z3mKJYiEfe9NSQ2WfeYsWjS/mOvGZJc3YolA+FXajW3w ftRVvbGe3pU7wQkKYVrljyM/7cvPt2gBRIskhRL9Xv0R6sjmXcCRWJDr6D1mqSau2qnm XmJ7951lNTNqce8zPH4ZZEP9Iz2mDq7xWtRRIrW6x++PDgKpvhNTzMH0ePvQrr/1L9YT DRDSyHqEOUzm4l/U/wOYYfQUc3UrrRrIWXc4EDMOm6VIIDRuw79HXo/0cjIg8aq7Tjug 2vmw== X-Gm-Message-State: AOAM532DLYX3COQdgiTFAtSPHFjEguZ+i1G56paw1gzTv4zUeqncNfTM s0ZmLYuapwbraIX4Q+TDNN+jM5nhFplXCw== X-Google-Smtp-Source: ABdhPJzSWCsKwLFsxUiJ+i6VxuvJNekYYrOoq3eV6vK0XTTBbkscbR0xr+7mxRE9JajmlERKK/HzyQ== X-Received: by 2002:a17:90a:1b6b:: with SMTP id q98mr8402031pjq.53.1623400960242; Fri, 11 Jun 2021 01:42:40 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:367e:c2e4:d691:eca1]) by smtp.gmail.com with ESMTPSA id 20sm4323542pfi.170.2021.06.11.01.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 01:42:39 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Jun 2021 17:42:28 +0900 Message-Id: <20210611084228.1830629-5-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210611084228.1830629-1-hiroh@chromium.org> References: <20210611084228.1830629-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/4] 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 --- 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 5e961003..442c36b1 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1926,16 +1926,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; } @@ -2368,6 +2409,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.