[{"id":19524,"web_url":"https://patchwork.libcamera.org/comment/19524/","msgid":"<20210908001648.GZ968527@pyrite.rasen.tech>","date":"2021-09-08T00:16:48","subject":"Re: [libcamera-devel] [PATCH v2 05/17] android: capabilities:\n\tCollect per-stream frame durations","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Sep 07, 2021 at 09:40:55PM +0200, Jacopo Mondi wrote:\n> Collect the per-stream frame durations while building the list\n> of supported stream formats and resolutions.\n> \n> In order to get an updated list of controls it is necessary to apply\n> to the Camera the configuration we're testing, which was so far only\n> validated.\n> \n> The per-configuration durations will be used to populate the Android\n> ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS static metadata.\n> \n\nWhere did your Signed-off-by go? :D\n\n\nPaul\n\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  src/android/camera_capabilities.cpp | 36 ++++++++++++++++++++++++++---\n>  src/android/camera_capabilities.h   |  2 ++\n>  2 files changed, 35 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\n> index e92bca42779a..4e82f12a904e 100644\n> --- a/src/android/camera_capabilities.cpp\n> +++ b/src/android/camera_capabilities.cpp\n> @@ -608,7 +608,29 @@ int CameraCapabilities::initializeStreamConfigurations()\n>  \t\t}\n>  \n>  \t\tfor (const Size &res : resolutions) {\n> -\t\t\tstreamConfigurations_.push_back({ res, androidFormat });\n> +\t\t\t/*\n> +\t\t\t * Configure the Camera with the collected format and\n> +\t\t\t * resolution to get an updated list of controls.\n> +\t\t\t */\n> +\t\t\tcfg.size = res;\n> +\t\t\tint ret = camera_->configure(cameraConfig.get());\n> +\t\t\tif (ret)\n> +\t\t\t\treturn ret;\n> +\n> +\t\t\tconst ControlInfoMap &controls = camera_->controls();\n> +\t\t\tconst auto frameDurations = controls.find(\n> +\t\t\t\t&controls::FrameDurationLimits);\n> +\t\t\tif (frameDurations == controls.end()) {\n> +\t\t\t\tLOG(HAL, Error)\n> +\t\t\t\t\t<< \"Camera does not report frame durations\";\n> +\t\t\t\treturn -EINVAL;\n> +\t\t\t}\n> +\n> +\t\t\tint64_t minFrameDuration = frameDurations->second.min().get<int64_t>() * 1000;\n> +\t\t\tint64_t maxFrameDuration = frameDurations->second.max().get<int64_t>() * 1000;\n> +\t\t\tstreamConfigurations_.push_back({\n> +\t\t\t\tres, androidFormat, minFrameDuration, maxFrameDuration,\n> +\t\t\t});\n>  \n>  \t\t\t/*\n>  \t\t\t * If the format is HAL_PIXEL_FORMAT_YCbCr_420_888\n> @@ -620,10 +642,18 @@ int CameraCapabilities::initializeStreamConfigurations()\n>  \t\t\t *\n>  \t\t\t * \\todo Support JPEG streams produced by the camera\n>  \t\t\t * natively.\n> +\t\t\t *\n> +\t\t\t * \\todo HAL_PIXEL_FORMAT_BLOB is a 'stalling' format,\n> +\t\t\t * its duration should take into account the time\n> +\t\t\t * required for the YUV to JPEG encoding. For now\n> +\t\t\t * use the same frame durations as collected for\n> +\t\t\t * the YUV/RGB streams.\n>  \t\t\t */\n>  \t\t\tif (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {\n> -\t\t\t\tstreamConfigurations_.push_back(\n> -\t\t\t\t\t{ res, HAL_PIXEL_FORMAT_BLOB });\n> +\t\t\t\tstreamConfigurations_.push_back({\n> +\t\t\t\t\tres, HAL_PIXEL_FORMAT_BLOB,\n> +\t\t\t\t\tminFrameDuration, maxFrameDuration,\n> +\t\t\t\t});\n>  \t\t\t\tmaxJpegSize = std::max(maxJpegSize, res);\n>  \t\t\t}\n>  \t\t}\n> diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h\n> index a12596993ee5..6e55ddab445e 100644\n> --- a/src/android/camera_capabilities.h\n> +++ b/src/android/camera_capabilities.h\n> @@ -43,6 +43,8 @@ private:\n>  \tstruct Camera3StreamConfiguration {\n>  \t\tlibcamera::Size resolution;\n>  \t\tint androidFormat;\n> +\t\tint64_t minFrameDurationNsec;\n> +\t\tint64_t maxFrameDurationNsec;\n>  \t};\n>  \n>  \tbool validateManualSensorCapability();\n> -- \n> 2.32.0\n>","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 00F22BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Sep 2021 00:17:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 510B46916C;\n\tWed,  8 Sep 2021 02:17:08 +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 3679760137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Sep 2021 02:16:56 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 58442317;\n\tWed,  8 Sep 2021 02:16:54 +0200 (CEST)"],"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=\"RR9Flqbz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631060215;\n\tbh=7jWlg1K1OQO7h9v1zd1LASANRb/wnujFMwqAR/eHQvI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RR9Flqbzmy9x/GRAbP0cZEZvtrprvJjzTAtGYI1QXeTpinoue9Pry0+eDt59ZyG7g\n\t4/azsiOcNnxkft+LqyNi1BnlqbQ/ODz0EJhtm+y4mXlYuaPzP0XHeZuhtkQXIJEDzU\n\tizKVECGXIGeFBBlipGM51wx1Tv+dhEayVjzTOnQA=","Date":"Wed, 8 Sep 2021 09:16:48 +0900","From":"paul.elder@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20210908001648.GZ968527@pyrite.rasen.tech>","References":"<20210907194107.803730-1-jacopo@jmondi.org>\n\t<20210907194107.803730-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210907194107.803730-6-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 05/17] android: capabilities:\n\tCollect per-stream frame durations","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>"}},{"id":20076,"web_url":"https://patchwork.libcamera.org/comment/20076/","msgid":"<YVz8Meus0go9t97J@pendragon.ideasonboard.com>","date":"2021-10-06T01:30:25","subject":"Re: [libcamera-devel] [PATCH v2 05/17] android: capabilities:\n\tCollect per-stream frame durations","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 Tue, Sep 07, 2021 at 09:40:55PM +0200, Jacopo Mondi wrote:\n> Collect the per-stream frame durations while building the list\n> of supported stream formats and resolutions.\n> \n> In order to get an updated list of controls it is necessary to apply\n> to the Camera the configuration we're testing, which was so far only\n> validated.\n\nNot ideal, but that's unavoidable for now.\n\n> The per-configuration durations will be used to populate the Android\n> ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS static metadata.\n> \n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  src/android/camera_capabilities.cpp | 36 ++++++++++++++++++++++++++---\n>  src/android/camera_capabilities.h   |  2 ++\n>  2 files changed, 35 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\n> index e92bca42779a..4e82f12a904e 100644\n> --- a/src/android/camera_capabilities.cpp\n> +++ b/src/android/camera_capabilities.cpp\n> @@ -608,7 +608,29 @@ int CameraCapabilities::initializeStreamConfigurations()\n>  \t\t}\n>  \n>  \t\tfor (const Size &res : resolutions) {\n> -\t\t\tstreamConfigurations_.push_back({ res, androidFormat });\n> +\t\t\t/*\n> +\t\t\t * Configure the Camera with the collected format and\n> +\t\t\t * resolution to get an updated list of controls.\n\nCould you add\n\n\t\t\t * \\todo Avoid the need to configure the camera when\n\t\t\t * redesigning the configuration API\n\nhere ?\n\n> +\t\t\t */\n> +\t\t\tcfg.size = res;\n> +\t\t\tint ret = camera_->configure(cameraConfig.get());\n> +\t\t\tif (ret)\n> +\t\t\t\treturn ret;\n> +\n> +\t\t\tconst ControlInfoMap &controls = camera_->controls();\n> +\t\t\tconst auto frameDurations = controls.find(\n> +\t\t\t\t&controls::FrameDurationLimits);\n> +\t\t\tif (frameDurations == controls.end()) {\n> +\t\t\t\tLOG(HAL, Error)\n> +\t\t\t\t\t<< \"Camera does not report frame durations\";\n> +\t\t\t\treturn -EINVAL;\n> +\t\t\t}\n> +\n> +\t\t\tint64_t minFrameDuration = frameDurations->second.min().get<int64_t>() * 1000;\n> +\t\t\tint64_t maxFrameDuration = frameDurations->second.max().get<int64_t>() * 1000;\n\nOne day we should really standardize everything on the same time unit.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\tstreamConfigurations_.push_back({\n> +\t\t\t\tres, androidFormat, minFrameDuration, maxFrameDuration,\n> +\t\t\t});\n>  \n>  \t\t\t/*\n>  \t\t\t * If the format is HAL_PIXEL_FORMAT_YCbCr_420_888\n> @@ -620,10 +642,18 @@ int CameraCapabilities::initializeStreamConfigurations()\n>  \t\t\t *\n>  \t\t\t * \\todo Support JPEG streams produced by the camera\n>  \t\t\t * natively.\n> +\t\t\t *\n> +\t\t\t * \\todo HAL_PIXEL_FORMAT_BLOB is a 'stalling' format,\n> +\t\t\t * its duration should take into account the time\n> +\t\t\t * required for the YUV to JPEG encoding. For now\n> +\t\t\t * use the same frame durations as collected for\n> +\t\t\t * the YUV/RGB streams.\n>  \t\t\t */\n>  \t\t\tif (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {\n> -\t\t\t\tstreamConfigurations_.push_back(\n> -\t\t\t\t\t{ res, HAL_PIXEL_FORMAT_BLOB });\n> +\t\t\t\tstreamConfigurations_.push_back({\n> +\t\t\t\t\tres, HAL_PIXEL_FORMAT_BLOB,\n> +\t\t\t\t\tminFrameDuration, maxFrameDuration,\n> +\t\t\t\t});\n>  \t\t\t\tmaxJpegSize = std::max(maxJpegSize, res);\n>  \t\t\t}\n>  \t\t}\n> diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h\n> index a12596993ee5..6e55ddab445e 100644\n> --- a/src/android/camera_capabilities.h\n> +++ b/src/android/camera_capabilities.h\n> @@ -43,6 +43,8 @@ private:\n>  \tstruct Camera3StreamConfiguration {\n>  \t\tlibcamera::Size resolution;\n>  \t\tint androidFormat;\n> +\t\tint64_t minFrameDurationNsec;\n> +\t\tint64_t maxFrameDurationNsec;\n>  \t};\n>  \n>  \tbool validateManualSensorCapability();","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 2A216BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Oct 2021 01:30:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A00D7691BD;\n\tWed,  6 Oct 2021 03:30:34 +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 57104602DC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Oct 2021 03:30:33 +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 D8754581;\n\tWed,  6 Oct 2021 03:30:32 +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=\"PX2H1lmD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633483833;\n\tbh=RU4FrcLUer+EBlGuM1mRfkR0U7Of3k19Bj2Vu0/NEi8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PX2H1lmDXngANZZBr2sId4suK6nVYnWCJRu6TQJpzboa/ZleRXwv71QpOkjALyJOD\n\tSGTDVtt6Jehz0MxLYZ145bSv4k3slvoFHlME7dNNAu1lCFf1iXxcMR6pMUqdtBnw7d\n\tRznj7Bj0rW+fx/L5dtYWdidl30ohS6NRp7VfA0To=","Date":"Wed, 6 Oct 2021 04:30:25 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YVz8Meus0go9t97J@pendragon.ideasonboard.com>","References":"<20210907194107.803730-1-jacopo@jmondi.org>\n\t<20210907194107.803730-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210907194107.803730-6-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 05/17] android: capabilities:\n\tCollect per-stream frame durations","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>"}}]