{"id":14447,"url":"https://patchwork.libcamera.org/api/patches/14447/?format=json","web_url":"https://patchwork.libcamera.org/patch/14447/","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":"<20211102025522.735085-1-hiroh@chromium.org>","date":"2021-11-02T02:55:21","name":"[libcamera-devel,v3,1/2] libcamera: camera_sensor: Enable to set a test pattern mode","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"09cb3b875a427277be3730dd918c91b862550099","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/14447/mbox/","series":[{"id":2685,"url":"https://patchwork.libcamera.org/api/series/2685/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2685","date":"2021-11-02T02:55:21","name":"[libcamera-devel,v3,1/2] libcamera: camera_sensor: Enable to set a test pattern mode","version":3,"mbox":"https://patchwork.libcamera.org/series/2685/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14447/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14447/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 023CFBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Nov 2021 02:55:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69B7060325;\n\tTue,  2 Nov 2021 03:55:32 +0100 (CET)","from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com\n\t[IPv6:2607:f8b0:4864:20::52c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3D0560122\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Nov 2021 03:55:30 +0100 (CET)","by mail-pg1-x52c.google.com with SMTP id g184so18855105pgc.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 01 Nov 2021 19:55:30 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:da96:7796:6eb0:5a01])\n\tby smtp.gmail.com with ESMTPSA id\n\tn15sm3589677pfv.216.2021.11.01.19.55.26\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 01 Nov 2021 19:55:28 -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=\"SRmuC+bm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=bR2E/rRUz9GO/O8iAKRnCbBmN61briK7K/2FP8sHj/o=;\n\tb=SRmuC+bm5ucUSDwbpZRSyadlcG6bIen/FVZt8Zl5GboKrup0i6E+C576yAbxe5rBJl\n\trYARX9NH++AVXPuR26kbgrzMRrlyMXzOZuocDlPkGXldnLX1+sTfOMBwXub/YYEvkVvB\n\tvTzmfL5BarsNKxl5hjVcEY17QGauhJDr6nj30=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=bR2E/rRUz9GO/O8iAKRnCbBmN61briK7K/2FP8sHj/o=;\n\tb=fKfQSRc+NHoKaF8KL7qz0J0ccAOiwJvkTwIqlksKH4u4s7SH02Gj0E+rutj7VSOyJq\n\tBrod3c/iRPgwVP/wRJuU+6xabpwyg2MnjnhQ49O91p39/CQH8Mz+AGfkF9xgTWFczCqo\n\tRNpHB6OhrDejP08PCc/+QxJ8ygFZbtdbKRKQTtXAydq4ODKMICI9gd82gIBd5giAm6Yj\n\tVZRa1D4zAD9e8pJQ0Tgkm32z7XdiHAUdrHDub3nwYwpAWqcwXL4vZuf32a0274T+++2G\n\tqoqtW6mGgFZrmHLEY8hrPwkp7zGGlRncG5Feypvr9wv7x2kWdhVWDqfbvDscn8oOJL5d\n\tgo4A==","X-Gm-Message-State":"AOAM5335eUo/UDzfzTU+jxx1hosh5uWFb+YwnJtARj0EWv8eJ/x1Qk+p\n\tJzheKGiABsVuDDNBZbkTj6rz1BL7FJ+b4w==","X-Google-Smtp-Source":"ABdhPJz7IZCY5EQQeFhvaw697KaAYCMc7SQf+tqP8zbJFLZ4YDSzXTO4TjWebhwTwVAORHov+PywdQ==","X-Received":"by 2002:a05:6a00:a8e:b0:480:ab08:1568 with SMTP id\n\tb14-20020a056a000a8e00b00480ab081568mr18057296pfl.28.1635821728597; \n\tMon, 01 Nov 2021 19:55:28 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  2 Nov 2021 11:55:21 +0900","Message-Id":"<20211102025522.735085-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.33.1.1089.g2158813163f-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 1/2] 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":"This adds a function to set a camera sensor driver a test pattern\nmode.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/camera_sensor.h |  6 +++\n src/libcamera/camera_sensor.cpp            | 50 +++++++++++++++++++---\n 2 files changed, 50 insertions(+), 6 deletions(-)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex d25a1165..d08cfec5 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -26,6 +26,8 @@ namespace libcamera {\n class BayerFormat;\n class MediaEntity;\n \n+struct CameraSensorProperties;\n+\n class CameraSensor : protected Loggable\n {\n public:\n@@ -44,6 +46,7 @@ public:\n \t{\n \t\treturn testPatternModes_;\n \t}\n+\tint setTestPatternMode(int32_t testPatternMode);\n \n \tV4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,\n \t\t\t\t      const Size &size) const;\n@@ -78,6 +81,8 @@ private:\n \tstd::unique_ptr<V4L2Subdevice> subdev_;\n \tunsigned int pad_;\n \n+\tconst CameraSensorProperties *props_;\n+\n \tstd::string model_;\n \tstd::string id_;\n \n@@ -85,6 +90,7 @@ private:\n \tstd::vector<unsigned int> mbusCodes_;\n \tstd::vector<Size> sizes_;\n \tstd::vector<int32_t> testPatternModes_;\n+\tint32_t testPatternMode_;\n \n \tSize pixelArraySize_;\n \tRectangle activeArea_;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 9fdb8c09..4770f52e 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -54,8 +54,8 @@ LOG_DEFINE_CATEGORY(CameraSensor)\n  * Once constructed the instance must be initialized with init().\n  */\n CameraSensor::CameraSensor(const MediaEntity *entity)\n-\t: entity_(entity), pad_(UINT_MAX), bayerFormat_(nullptr),\n-\t  properties_(properties::properties)\n+\t: entity_(entity), pad_(UINT_MAX), testPatternMode_(-1),\n+\t  bayerFormat_(nullptr), properties_(properties::properties)\n {\n }\n \n@@ -300,14 +300,16 @@ void CameraSensor::initVimcDefaultProperties()\n \n void CameraSensor::initStaticProperties()\n {\n-\tconst CameraSensorProperties *props = CameraSensorProperties::get(model_);\n-\tif (!props)\n+\tprops_ = CameraSensorProperties::get(model_);\n+\tif (!props_) {\n+\t\tLOG(CameraSensor, Debug) << \"No properties for \" << model_;\n \t\treturn;\n+\t}\n \n \t/* Register the properties retrieved from the sensor database. */\n-\tproperties_.set(properties::UnitCellSize, props->unitCellSize);\n+\tproperties_.set(properties::UnitCellSize, props_->unitCellSize);\n \n-\tinitTestPatternModes(props->testPatternModes);\n+\tinitTestPatternModes(props_->testPatternModes);\n }\n \n void CameraSensor::initTestPatternModes(\n@@ -531,6 +533,42 @@ Size CameraSensor::resolution() const\n  * \\return The list of test pattern modes\n  */\n \n+/**\n+ * \\brief Set the test pattern mode for the camera sensor\n+ * \\param[in] testPatternMode Test pattern mode control value to set the camera\n+ * sensor\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int CameraSensor::setTestPatternMode(int32_t testPatternMode)\n+{\n+\tif (testPatternMode_ == testPatternMode)\n+\t\treturn 0;\n+\n+\tif (!props_) {\n+\t\tLOG(CameraSensor, Error) << \"No properties are found\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tauto it = props_->testPatternModes.find(testPatternMode);\n+\tif (it == props_->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+\tControlList ctrls{ controls() };\n+\tctrls.set(V4L2_CID_TEST_PATTERN, it->second);\n+\n+\tint ret = setControls(&ctrls);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\ttestPatternMode_ = testPatternMode;\n+\n+\treturn 0;\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","v3","1/2"]}