[{"id":17419,"web_url":"https://patchwork.libcamera.org/comment/17419/","msgid":"<YL1dSyY1Gt+Wc36C@pendragon.ideasonboard.com>","date":"2021-06-06T23:42:03","subject":"Re: [libcamera-devel] [PATCH v6 4/6] libcamera: CameraSensor:\n\tEnable retrieving supported test pattern modes","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 Fri, May 28, 2021 at 12:05:29PM +0900, Hirokazu Honda wrote:\n> This enables retrieving supported test pattern modes through\n> CameraSensorInfo.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/internal/camera_sensor.h |  7 +++++\n>  src/libcamera/camera_sensor.cpp            | 32 ++++++++++++++++++++++\n>  2 files changed, 39 insertions(+)\n> \n> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\n> index cf6c1c1e..dcde647d 100644\n> --- a/include/libcamera/internal/camera_sensor.h\n> +++ b/include/libcamera/internal/camera_sensor.h\n> @@ -39,6 +39,10 @@ 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<uint8_t> &testPatternModes() const\n> +\t{\n> +\t\treturn testPatternModes_;\n> +\t}\n>  \n>  \tV4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,\n>  \t\t\t\t      const Size &size) const;\n> @@ -66,6 +70,8 @@ private:\n>  \tvoid initVimcDefaultProperties();\n>  \tvoid initStaticProperties();\n>  \tint initProperties();\n> +\tvoid initTestPatternModes(\n> +\t\tconst std::map<uint8_t, uint8_t> &testPatternModeMap);\n>  \n>  \tconst MediaEntity *entity_;\n>  \tstd::unique_ptr<V4L2Subdevice> subdev_;\n> @@ -77,6 +83,7 @@ private:\n>  \tV4L2Subdevice::Formats formats_;\n>  \tstd::vector<unsigned int> mbusCodes_;\n>  \tstd::vector<Size> sizes_;\n> +\tstd::vector<uint8_t> testPatternModes_;\n>  \n>  \tSize pixelArraySize_;\n>  \tRectangle activeArea_;\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index 0fb8a258..44dd5988 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -297,6 +297,30 @@ void CameraSensor::initVimcDefaultProperties()\n>  \tactiveArea_ = Rectangle(pixelArraySize_);\n>  }\n>  \n> +void CameraSensor::initTestPatternModes(\n> +\tconst std::map<uint8_t, uint8_t> &testPatternModeMap)\n> +{\n> +\tconst auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);\n> +\tif (v4l2TestPattern == controls().end()) {\n> +\t\tLOG(CameraSensor, Debug) << \"No static test pattern map for \\'\"\n> +\t\t\t\t\t << model() << \"\\'\";\n> +\t\treturn;\n> +\t}\n> +\n> +\tfor (const ControlValue &value : v4l2TestPattern->second.values()) {\n> +\t\tconst int32_t index = value.get<int32_t>();\n> +\n> +\t\tconst auto it = testPatternModeMap.find(index);\n> +\t\tif (it == testPatternModeMap.end()) {\n> +\t\t\tLOG(CameraSensor, Debug)\n> +\t\t\t\t<< \"Test pattern mode \" << index << \" ignored\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n> +\t\ttestPatternModes_.push_back(it->second);\n> +\t}\n> +}\n\nCould you please move this function below initProperties(), to match the\ndeclaration order in the class ? I would actually move it right after\ninitStaticProperties() and update the class definition accordingly.\n\n> +\n>  void CameraSensor::initStaticProperties()\n>  {\n>  \tconst CameraSensorProperties *props = CameraSensorProperties::get(model_);\n> @@ -305,6 +329,8 @@ void CameraSensor::initStaticProperties()\n>  \n>  \t/* Register the properties retrieved from the sensor database. */\n>  \tproperties_.set(properties::UnitCellSize, props->unitCellSize);\n> +\n> +\tinitTestPatternModes(props->testPatternModeMap);\n>  }\n>  \n>  int CameraSensor::initProperties()\n> @@ -469,6 +495,12 @@ Size CameraSensor::resolution() const\n>  \treturn std::min(sizes_.back(), activeArea_.size());\n>  }\n>  \n> +/**\n> + * \\fn CameraSensor::testPatternModes()\n> + * \\brief Retrieve all the supported test pattern modes of the camera sensor\n\nI'd add\n\n *\n * The test pattern mode values correspond to the controls::TestPattern control.\n *\n\nas I had to read the code to see if it was V4L2 or libcamera control\nvalues.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + * \\return The list of test pattern modes\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 6C9F6C3206\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  6 Jun 2021 23:42:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DDA5E68921;\n\tMon,  7 Jun 2021 01:42:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E27768921\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Jun 2021 01:42:17 +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 C6DE780F;\n\tMon,  7 Jun 2021 01:42:16 +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=\"k26Dj0Xy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1623022937;\n\tbh=VKqISIt7QAduImVZJ/DR7N/PrCOg1ZUINiA5Sf0Bz0Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=k26Dj0Xy8MM73/RCzhkOsGdprLuaCPDEyhFiSjZzxhLTFV+kKjl7GC4ubFIM506ba\n\tbENacrj5EQc6jbmjb4plVrz2kgWB0wV3DRMQQfB0/ygR5E3Y+/ZRFKXzRuzY6Hj8Bp\n\tSG5nTM8k8F8PYL4HAF708zUnEhpRs6NTRQI4dooA=","Date":"Mon, 7 Jun 2021 02:42:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YL1dSyY1Gt+Wc36C@pendragon.ideasonboard.com>","References":"<20210528030531.189492-1-hiroh@chromium.org>\n\t<20210528030531.189492-4-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210528030531.189492-4-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v6 4/6] libcamera: CameraSensor:\n\tEnable retrieving supported test pattern modes","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>"}}]