{"id":12673,"url":"https://patchwork.libcamera.org/api/patches/12673/?format=json","web_url":"https://patchwork.libcamera.org/patch/12673/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210622023654.969162-2-hiroh@chromium.org>","date":"2021-06-22T02:36:51","name":"[libcamera-devel,RFC,v2,2/5] libcamera: camera_sensor: Enable to set a test pattern mode","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"fa9e06b61e2f3eeacc7b71d7ad5b5b3c7359029f","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12673/mbox/","series":[{"id":2164,"url":"https://patchwork.libcamera.org/api/series/2164/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2164","date":"2021-06-22T02:36:50","name":"[libcamera-devel,RFC,v2,1/5] libcamera: camera_sensor: Reverse the key and value of test pattern mode map","version":2,"mbox":"https://patchwork.libcamera.org/series/2164/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12673/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12673/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 45BABC321B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Jun 2021 02:37:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D83B26893F;\n\tTue, 22 Jun 2021 04:37:05 +0200 (CEST)","from mail-pg1-x536.google.com (mail-pg1-x536.google.com\n\t[IPv6:2607:f8b0:4864:20::536])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 74AC568932\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jun 2021 04:37:02 +0200 (CEST)","by mail-pg1-x536.google.com with SMTP id p9so1523320pgb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jun 2021 19:37:02 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:a025:f98b:b63b:e6b2])\n\tby smtp.gmail.com with ESMTPSA id\n\to7sm18947145pgs.45.2021.06.21.19.36.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 21 Jun 2021 19:37:00 -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=\"gGX0GNNG\"; 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=qC6xpyNnKBKxXei/YEgiG06a5xluSsOfyqqMgqQxzA4=;\n\tb=gGX0GNNGXYJEW2Vvp6PNDpCz2anucxcZlXV1UkzQUq1sBhibJP7BCS5TwqtkbCrp9T\n\tbdW4BVRoNXdjM6peQ77j6l93wen4FLQ8GO6c0NTHKSesHmJsqaK9EoIeRa+7zXBZuXjG\n\tNUigEo4EJzJ1S7FGg622Ou2eM1OSb4DBQ66G8=","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=qC6xpyNnKBKxXei/YEgiG06a5xluSsOfyqqMgqQxzA4=;\n\tb=M8mYp9fKtiH43596SxiI2Z3eui+OhAazn5ol6DQ7CymoNFiSJeCpqYEZN5UqRUtYXn\n\tQQk2USYZY5GT78Kl3YgTmBUkmY1k2v2cy++hIjj3GjEjkKHjhqO9+zsUJoweYgulXbk4\n\tl7GoF5YAxouhrUjwKo0rpOeHs9fMZY1zdRCnYaCPxbVpMe6+UXB+18eVMYRmzIzkywmX\n\tS3JyrYUindJZ/4Xs2+Je1b/4wzwjMIK6EglZ792sLDyf04to4ykN10/nvG4mmomgOax8\n\tDKtWgcANBBH+TgkyL8kbfNnM1WFMoLKRELvy0qttG1Pz8vjDVKVr/sK40KGkYUBs1rGX\n\tMnAg==","X-Gm-Message-State":"AOAM530xUdkgnlhUY8Ym3F/S+Nw+s4l02xWDq4wC6l2khKX8O+sJx/RY\n\tpmRj/56Z5CUmmDOiE0030eGbsLqlMbmZjQ==","X-Google-Smtp-Source":"ABdhPJybxfnGjF2To51FnmJWsO0qajYpr4PvWvY4cUAsNh/NayG6CagCTtVyaBeWKtDwKs9nMboUnA==","X-Received":"by 2002:a63:5445:: with SMTP id e5mr1513954pgm.62.1624329420960; \n\tMon, 21 Jun 2021 19:37:00 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH v2 2/5] libcamera: camera_sensor:\n\tEnable to 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 |  1 +\n src/libcamera/camera_sensor.cpp            | 39 ++++++++++++++++++++++\n 2 files changed, 40 insertions(+)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex e133ebf4..8b9f84c9 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -43,6 +43,7 @@ public:\n \t{\n \t\treturn testPatternModes_;\n \t}\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;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 70bbd97a..ce8ff274 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -507,6 +507,45 @@ Size CameraSensor::resolution() const\n  * \\return The list of test pattern modes\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+\tif (std::find(testPatternModes_.begin(), testPatternModes_.end(),\n+\t\t      testPatternMode) == testPatternModes_.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 CameraSensorProperties *props = CameraSensorProperties::get(model_);\n+\tif (!props)\n+\t\treturn -EINVAL;\n+\n+\tauto it = props->testPatternModes.find(testPatternMode);\n+\tASSERT(it != props->testPatternModes.end());\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  * \\param[in] mbusCodes The list of acceptable media bus codes\n","prefixes":["libcamera-devel","RFC","v2","2/5"]}