[{"id":15482,"web_url":"https://patchwork.libcamera.org/comment/15482/","msgid":"<YEER5lvKfDVFfrso@pendragon.ideasonboard.com>","date":"2021-03-04T16:59:18","subject":"Re: [libcamera-devel] [PATCH] libcamera: camera_sensor: Cap\n\tresolution to max frame size","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Thu, Mar 04, 2021 at 02:17:09PM +0100, Jacopo Mondi wrote:\n> Since commit 96aecfe36508 (\"libcamera: camera_sensor: Use active area\n> size as resolution\") the CameraSensor::resolution() method returned the\n> sensor's active pixel area size.\n> \n> As the CameraSensor::resolution() method is widely used in the library\n> code base to retrieve the maximum frame size the sensor can produce,\n> in case it is smaller than the pixel area size the returned size cannot\n> be used to configure the sensor correctly.\n> \n> Fix this by returning the maximum frame resolution the sensor can\n> produce, or the pixel area size in case the sensor embeds and ISP that\n> can upscale and the supported maximum frame size is thus larger that\n> the pixel array size.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/internal/camera_sensor.h |  2 +-\n>  src/libcamera/camera_sensor.cpp            | 14 +++++++++++++-\n>  2 files changed, 14 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\n> index 71d012f795fe..3e98f71b5e7f 100644\n> --- a/include/libcamera/internal/camera_sensor.h\n> +++ b/include/libcamera/internal/camera_sensor.h\n> @@ -53,7 +53,7 @@ public:\n>  \tconst MediaEntity *entity() const { return entity_; }\n>  \tconst std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }\n>  \tconst std::vector<Size> &sizes() const { return sizes_; }\n> -\tSize resolution() const { return activeArea_.size(); }\n> +\tSize resolution() const;\n> \n>  \tV4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,\n>  \t\t\t\t      const Size &size) const;\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index a04982971616..edc2c27084ed 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -551,10 +551,22 @@ int CameraSensor::initProperties()\n>   */\n> \n>  /**\n> - * \\fn CameraSensor::resolution()\n>   * \\brief Retrieve the camera sensor resolution\n> + *\n> + * The camera sensor resolution is the largest frame size the sensor can produce\n> + * or, if the camera sensor embeds and ISP that can up-scale, the pixel area\n> + * size.\n\nShould we express it the other way around, with the active pixel area\nbeing the default ?\n\n * The camera sensor resolution is the active pixel area size, clamped to the\n * maximum frame size the sensor can produce if it is smaller than the active\n * pixel area.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nTested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + *\n> + * \\todo Consider if it desirable to distinguish between the maximum resolution\n> + * the sensor can produce (also including upscaled ones) and the actual pixel\n> + * array size by splitting this method in two.\n> + *\n>   * \\return The camera sensor resolution in pixels\n>   */\n> +Size CameraSensor::resolution() const\n> +{\n> +\treturn std::min(sizes_.back(), activeArea_.size());\n> +}\n> \n>  /**\n>   * \\brief Retrieve the best sensor format for a desired output","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 CE5BFBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Mar 2021 16:59:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 380B468A91;\n\tThu,  4 Mar 2021 17:59:51 +0100 (CET)","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 12701602ED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Mar 2021 17:59:49 +0100 (CET)","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 7EC7B27A;\n\tThu,  4 Mar 2021 17:59:48 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"h/OB+hIc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614877188;\n\tbh=0tXyoUVAE9u3hHSQlY7w8Rl4LV4NSTHKaHG0sEzDXKw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=h/OB+hIckFcN6OiN/c4u5PpYWRSqJFo9WUZmqWvc6UNOht5dIEx+qZqKk3matoEfX\n\t80OmPxQHmsT2E7d2VPJlB/nN/eazeon+eYP+k1eb81l93vA0v5lUb9kLXzBpJ3hZs6\n\t2d+3+4Nh4YN3bb6D6P5LeN5uNBniDv6c1zi4s9DA=","Date":"Thu, 4 Mar 2021 18:59:18 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YEER5lvKfDVFfrso@pendragon.ideasonboard.com>","References":"<20210304131709.981268-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210304131709.981268-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: camera_sensor: Cap\n\tresolution to max frame size","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]