{"id":12564,"url":"https://patchwork.libcamera.org/api/1.1/patches/12564/?format=json","web_url":"https://patchwork.libcamera.org/patch/12564/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210611084228.1830629-2-hiroh@chromium.org>","date":"2021-06-11T08:42:25","name":"[libcamera-devel,RFC,1/4] libcamera: camera_sensor: Enable to set a test pattern mode","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ab7b4781e4600516517d4deb6f36d0ea49590db8","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12564/mbox/","series":[{"id":2121,"url":"https://patchwork.libcamera.org/api/1.1/series/2121/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2121","date":"2021-06-11T08:42:24","name":"Support sensor test pattern mode in Android HAL","version":1,"mbox":"https://patchwork.libcamera.org/series/2121/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12564/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12564/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C4FEEC320B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Jun 2021 08:42:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 81BD66892F;\n\tFri, 11 Jun 2021 10:42:41 +0200 (CEST)","from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com\n\t[IPv6:2607:f8b0:4864:20::62d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 60B3F6029E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Jun 2021 10:42:37 +0200 (CEST)","by mail-pl1-x62d.google.com with SMTP id x19so2496447pln.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Jun 2021 01:42:37 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:367e:c2e4:d691:eca1])\n\tby smtp.gmail.com with ESMTPSA id\n\t20sm4323542pfi.170.2021.06.11.01.42.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 11 Jun 2021 01:42:35 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"hTAbdKRL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=U9OEYzue8vc7okX16AMlQ3ov9LGscixMDny6HO81ri8=;\n\tb=hTAbdKRLoJLlyofT1c8sN9PB/sLMdGVyZkzez3hRxWMTuGHN4xlmo6BZmR2fyhm/Ma\n\tAErpI4jzY6aN/mLsY+VK2nkFgsrmNK+1mQocaIsGnfJufFGWaj5tx8IQWUvpXRglSAZ0\n\tigzue8e7lh4MoraJr3U5TMptuyhmaJvFHVpCM=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=U9OEYzue8vc7okX16AMlQ3ov9LGscixMDny6HO81ri8=;\n\tb=pHl9oRRxMcBeU8e39ZJuAWr5lcGgtMfP9is3+iaNDoU3TFVazOeH6Q0XMTAMeZdJBI\n\tE1ubXJP4H+jsQfRFLM5wUvpqaYcagnb/eTeKPFtpH42kUMS24SzA+Q8rjXWZDc8hsXic\n\tEojIS+Io/JFQ6U+2qJdxdYciNOgQ6Fb8F+7tNUIQ+l1tmQFjfqLdQzJk2mBf7dh1dvFt\n\t/Oyc5+k+mNG5hW6CG3EqsQymZNTl4DAMczD+Je/n2DFcpCORYFpEt/ituA7L3O6mkrie\n\tcHUo7Fsp29x/gwaptEqlYMlmNurCAH3FuQGS6l7nETBruj/L7To6OzZkvSQKMpU6+nwq\n\tkvow==","X-Gm-Message-State":"AOAM532r0DWUMzLpZXcKGHpG5wvFMPjIjvqE+8RrXcSxP6a1x12yQ6jD\n\to6NBFE6nvBuYaQs9mTwu1GlZnE7pyUgc8g==","X-Google-Smtp-Source":"ABdhPJy/yjLigY+VDO4eSDoxzNI28JKgOiWcniM3Azy87tYrd/uW0OVFDbWmbdKcOUTyUaQi0HK/Iw==","X-Received":"by 2002:a17:90a:c384:: with SMTP id\n\th4mr3445070pjt.134.1623400955870; \n\tFri, 11 Jun 2021 01:42:35 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 1/4] libcamera: camera_sensor: Enable\n\tto set a test pattern mode","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Provides a function to set the camera sensor a test pattern mode.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n include/libcamera/internal/camera_sensor.h |  7 ++--\n src/libcamera/camera_sensor.cpp            | 40 ++++++++++++++++++++--\n 2 files changed, 41 insertions(+), 6 deletions(-)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex e133ebf4..834d3246 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -39,10 +39,8 @@ public:\n \tconst std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }\n \tconst std::vector<Size> &sizes() const { return sizes_; }\n \tSize resolution() const;\n-\tconst std::vector<int32_t> &testPatternModes() const\n-\t{\n-\t\treturn testPatternModes_;\n-\t}\n+\tstd::vector<int32_t> testPatternModes() const;\n+\tint setTestPatternMode(uint8_t testPatternMode);\n \n \tV4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,\n \t\t\t\t      const Size &size) const;\n@@ -84,6 +82,7 @@ private:\n \tstd::vector<unsigned int> mbusCodes_;\n \tstd::vector<Size> sizes_;\n \tstd::vector<int32_t> testPatternModes_;\n+\tstd::map<int32_t, int32_t> testPatternModeToIndex_;\n \n \tSize pixelArraySize_;\n \tRectangle activeArea_;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 3e135353..d2f033a5 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -329,7 +329,7 @@ void CameraSensor::initTestPatternModes(\n \t\t\tcontinue;\n \t\t}\n \n-\t\ttestPatternModes_.push_back(it->second);\n+\t\ttestPatternModeToIndex_[it->second] = index;\n \t}\n }\n \n@@ -496,12 +496,48 @@ Size CameraSensor::resolution() const\n }\n \n /**\n- * \\fn CameraSensor::testPatternModes()\n  * \\brief Retrieve all the supported test pattern modes of the camera sensor\n  * The test pattern mode values correspond to the controls::TestPattern control.\n  *\n  * \\return The list of test pattern modes\n  */\n+std::vector<int32_t> CameraSensor::testPatternModes() const\n+{\n+\treturn utils::map_keys(testPatternModeToIndex_);\n+}\n+\n+/**\n+ * \\brief Set the camera sensor a specified controls::TestPatternMode\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int CameraSensor::setTestPatternMode(uint8_t testPatternMode)\n+{\n+\tauto it = testPatternModeToIndex_.find(testPatternMode);\n+\tif (it == testPatternModeToIndex_.end()) {\n+\t\tLOG(CameraSensor, Error) << \"Unsupported test pattern mode: \"\n+\t\t\t\t\t << testPatternMode;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tconst uint8_t index = it->second;\n+\n+\tControlList ctrls = getControls({ V4L2_CID_TEST_PATTERN });\n+\tif (ctrls.empty()) {\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"Failed to retrieve test pattern control\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tControlValue value = ctrls.get(V4L2_CID_TEST_PATTERN);\n+\tif (value.get<int32_t>() == index)\n+\t\treturn 0;\n+\n+\tvalue.set<int32_t>(index);\n+\tctrls.set(V4L2_CID_TEST_PATTERN, value);\n+\n+\treturn setControls(&ctrls);\n+}\n \n /**\n  * \\brief Retrieve the best sensor format for a desired output\n","prefixes":["libcamera-devel","RFC","1/4"]}