[{"id":16098,"web_url":"https://patchwork.libcamera.org/comment/16098/","msgid":"<YGe6aQ2FoCCPQdpH@pendragon.ideasonboard.com>","date":"2021-04-03T00:44:25","subject":"Re: [libcamera-devel] [PATCH v3 2/4] android: CameraDevice:\n\tValidate crop_rotate_scale_degrees in configuration","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, Mar 30, 2021 at 02:25:19PM +0900, Hirokazu Honda wrote:\n> Libcamera doesn't handle |crop_rotate_scale_degrees| in\n\ns/Libcamera/libcamera/\n\n> camera3_stream at all. This adds the validation of the requested\n> |crop_rotate_scale_degrees| in configuration, but still not\n> handle the specified values.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/android/camera_device.cpp | 46 +++++++++++++++++++++++++++++++++++\n>  1 file changed, 46 insertions(+)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index ae693664..f88e94bc 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -256,6 +256,44 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,\n>  \tunsortedConfigs = sortedConfigs;\n>  }\n>  \n> +#if defined(CHROMEOS)\n> +/*\n> + * Check whether the crop_rotate_scale_degrees values for all streams in\n> + * the list are valid according to the Chrome OS camera HAL API.\n> + */\n> +bool validateCropRotate(const camera3_stream_configuration_t &streamList)\n> +{\n> +\tASSERT(streamList.num_streams > 0);\n> +\tconst int cropRotateScaleDegrees =\n> +\t\tstreamList.streams[0]->crop_rotate_scale_degrees;\n> +\tfor (unsigned int i = 0; i < streamList.num_streams; ++i) {\n> +\t\tconst camera3_stream_t &stream = *streamList.streams[i];\n> +\n> +\t\tswitch (stream.crop_rotate_scale_degrees) {\n> +\t\tcase CAMERA3_STREAM_ROTATION_0:\n> +\t\tcase CAMERA3_STREAM_ROTATION_90:\n> +\t\tcase CAMERA3_STREAM_ROTATION_270:\n> +\t\t\tbreak;\n> +\n> +\t\t/* 180° rotation is specified by Chrome OS as invalid. */\n> +\t\tcase CAMERA3_STREAM_ROTATION_180:\n> +\t\tdefault:\n> +\t\t\tLOG(HAL, Error) << \"Invalid crop_rotate_scale_degrees: \"\n> +\t\t\t\t\t<< stream.crop_rotate_scale_degrees;\n> +\t\t\treturn false;\n> +\t\t}\n> +\n> +\t\tif (cropRotateScaleDegrees != stream.crop_rotate_scale_degrees) {\n> +\t\t\tLOG(HAL, Error) << \"crop_rotate_scale_degrees in all \"\n> +\t\t\t\t\t<< \"streams are not identical\";\n> +\t\t\treturn false;\n> +\t\t}\n> +\t}\n> +\n> +\treturn true;\n> +}\n> +#endif\n> +\n>  } /* namespace */\n>  \n>  /*\n> @@ -1552,6 +1590,14 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n>  \t\trunning_ = false;\n>  \t}\n>  \n> +\tif (stream_list->num_streams == 0)\n> +\t\treturn -EINVAL;\n> +\n\nThis could be split to a different patch, or be at least mentioned in\nthe commit message.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +#if defined(CHROMEOS)\n> +\tif (!validateCropRotate(*stream_list))\n> +\t\treturn -EINVAL;\n> +#endif\n> +\n>  \t/*\n>  \t * Generate an empty configuration, and construct a StreamConfiguration\n>  \t * for each camera3_stream to add to it.","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 4E004C0DA3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  3 Apr 2021 00:45:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C041E602D7;\n\tSat,  3 Apr 2021 02:45:11 +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 6B1A4602CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Apr 2021 02:45:10 +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 7DA873D7;\n\tSat,  3 Apr 2021 02:45:09 +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=\"UgI+M9HV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1617410709;\n\tbh=d0itofZFncJsqbxTscfVNeX8vBnhG4DlrysRDrpAMXs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=UgI+M9HV9utf+qEVA+/y8cXPxqbBkoliXx5fKlynN14T+mQo6yAI20kM+5iQLqSko\n\tmk92aPSQkTJShQUG0jpqf0fXXhe/ZTFVdUYeYf5k6D8Jgr2pGowmLTX47qnLX4lTGb\n\tG/HpSY1cWMnecnHqXre2xbuzCizxn2Bf2AY/60HI=","Date":"Sat, 3 Apr 2021 03:44:25 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YGe6aQ2FoCCPQdpH@pendragon.ideasonboard.com>","References":"<20210330052521.381550-1-hiroh@chromium.org>\n\t<20210330052521.381550-3-hiroh@chromium.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210330052521.381550-3-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] android: CameraDevice:\n\tValidate crop_rotate_scale_degrees in configuration","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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]