[{"id":17899,"web_url":"https://patchwork.libcamera.org/comment/17899/","msgid":"<YNn9qBac012cbzVT@pendragon.ideasonboard.com>","date":"2021-06-28T16:49:44","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: camera_sensor: Enable\n\tto set a test pattern mode","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Tue, Jun 29, 2021 at 01:32:37AM +0900, Hirokazu Honda wrote:\n> Provides a function to set the camera sensor a test pattern mode.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  include/libcamera/internal/camera_sensor.h |  2 ++\n>  src/libcamera/camera_sensor.cpp            | 35 ++++++++++++++++++++--\n>  2 files changed, 35 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\n> index db12b07e..4ecce6c9 100644\n> --- a/include/libcamera/internal/camera_sensor.h\n> +++ b/include/libcamera/internal/camera_sensor.h\n> @@ -44,6 +44,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> @@ -85,6 +86,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_;\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index ee53adf3..be2d32e3 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> @@ -515,6 +515,37 @@ 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> + * \\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> +\tconst CameraSensorProperties *props = CameraSensorProperties::get(model_);\n> +\tif (!props)\n> +\t\treturn -EINVAL;\n\nI think I've commented on that in the previous version, could we cache\nthe CameraSensorProperties pointer in CameraSensor at init time instead\nof looking it up every time ?\n\n> +\n> +\tauto it = props->testPatternModes.find(testPatternMode);\n> +\tASSERT(it != props->testPatternModes.end());\n\nIf an application set the test pattern control to an invalid value, we\nshouldn't crash but return an error. Is that handled in a layer above ?\n\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","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 506BAC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 16:49:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C2AD3684D4;\n\tMon, 28 Jun 2021 18:49:47 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D73606028C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 18:49:46 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 590D2B8A;\n\tMon, 28 Jun 2021 18:49:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"FSI6nR2c\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624898986;\n\tbh=ifUlazMoe9ywfncrW3UTEn3Wv4YdaCCvoQ5lwMcMRY4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FSI6nR2cFBZaHb59MTFMm8JrrP2Ig3wsrqJLBYOUL7rWAsc4m0nUMLvmvqzGjTmdz\n\tqlO8q0OJtkU1cwy8WnSH9vATTC+rG9eiiq7iHYz4RQb95wCfZOfrz1KPknI9ds8Xhw\n\ta4JW8hkSqPTtI/C8fcLW9LbuQAj/5YLHDPIi72rQ=","Date":"Mon, 28 Jun 2021 19:49:44 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YNn9qBac012cbzVT@pendragon.ideasonboard.com>","References":"<20210628163237.3194582-1-hiroh@chromium.org>\n\t<20210628163237.3194582-3-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210628163237.3194582-3-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH 2/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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]