[{"id":11606,"web_url":"https://patchwork.libcamera.org/comment/11606/","msgid":"<20200725163155.GD6253@pendragon.ideasonboard.com>","date":"2020-07-25T16:31:55","subject":"Re: [libcamera-devel] [PATCH v2 5/6] android: camera_device:\n\tBreak-out request template","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 Sat, Jul 25, 2020 at 04:40:57PM +0200, Jacopo Mondi wrote:\n> Currently the request template returned from\n> CameraDevice::constructDefaultRequestSettings() is the same for all\n> the supported template types.\n> \n> To prepare to adjust the template depending on the use case, break out\n> the template generation to a dedicated function that supports the\n> PREVIEW use case. All the other template types use the\n> requestTemplatePreview() function and just update the capture intent\n> property.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/android/camera_device.cpp | 82 ++++++++++++++++++++---------------\n>  src/android/camera_device.h   |  1 +\n>  2 files changed, 47 insertions(+), 36 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 48f8090a93db..b294b88367d4 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -821,48 +821,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \treturn staticMetadata_->get();\n>  }\n>  \n> -/*\n> - * Produce a metadata pack to be used as template for a capture request.\n> - */\n> -const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n> +CameraMetadata *CameraDevice::requestTemplatePreview()\n>  {\n> -\tauto it = requestTemplates_.find(type);\n> -\tif (it != requestTemplates_.end())\n> -\t\treturn it->second->get();\n> -\n> -\t/* Use the capture intent matching the requested template type. */\n> -\tuint8_t captureIntent;\n> -\tswitch (type) {\n> -\tcase CAMERA3_TEMPLATE_PREVIEW:\n> -\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;\n> -\t\tbreak;\n> -\tcase CAMERA3_TEMPLATE_STILL_CAPTURE:\n> -\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;\n> -\t\tbreak;\n> -\tcase CAMERA3_TEMPLATE_VIDEO_RECORD:\n> -\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;\n> -\t\tbreak;\n> -\tcase CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:\n> -\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;\n> -\t\tbreak;\n> -\tcase CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG:\n> -\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG;\n> -\t\tbreak;\n> -\tcase CAMERA3_TEMPLATE_MANUAL:\n> -\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL;\n> -\t\tbreak;\n> -\tdefault:\n> -\t\tLOG(HAL, Error) << \"Invalid template request type: \" << type;\n> -\t\treturn nullptr;\n> -\t}\n> -\n>  \t/*\n>  \t * \\todo Keep this in sync with the actual number of entries.\n>  \t * Currently: 12 entries, 15 bytes\n>  \t */\n>  \tCameraMetadata *requestTemplate = new CameraMetadata(15, 20);\n>  \tif (!requestTemplate->isValid()) {\n> -\t\tLOG(HAL, Error) << \"Failed to allocate template metadata\";\n>  \t\tdelete requestTemplate;\n>  \t\treturn nullptr;\n>  \t}\n> @@ -911,15 +877,59 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n>  \trequestTemplate->addEntry(ANDROID_COLOR_CORRECTION_ABERRATION_MODE,\n>  \t\t\t\t  &aberrationMode, 1);\n>  \n> +\tuint8_t captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;\n>  \trequestTemplate->addEntry(ANDROID_CONTROL_CAPTURE_INTENT,\n>  \t\t\t\t  &captureIntent, 1);\n>  \n> -\tif (!requestTemplate->isValid()) {\n> +\treturn requestTemplate;\n> +}\n> +\n> +/*\n> + * Produce a metadata pack to be used as template for a capture request.\n> + */\n> +const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n> +{\n> +\tauto it = requestTemplates_.find(type);\n> +\tif (it != requestTemplates_.end())\n> +\t\treturn it->second->get();\n> +\n> +\t/* Use the capture intent matching the requested template type. */\n> +\tCameraMetadata *requestTemplate;\n> +\tuint8_t captureIntent;\n> +\tswitch (type) {\n> +\tcase CAMERA3_TEMPLATE_PREVIEW:\n> +\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;\n> +\t\tbreak;\n> +\tcase CAMERA3_TEMPLATE_STILL_CAPTURE:\n> +\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;\n> +\t\tbreak;\n> +\tcase CAMERA3_TEMPLATE_VIDEO_RECORD:\n> +\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;\n> +\t\tbreak;\n> +\tcase CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:\n> +\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;\n> +\t\tbreak;\n> +\tcase CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG:\n> +\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG;\n> +\t\tbreak;\n> +\tcase CAMERA3_TEMPLATE_MANUAL:\n> +\t\tcaptureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL;\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tLOG(HAL, Error) << \"Invalid template request type: \" << type;\n> +\t\treturn nullptr;\n> +\t}\n> +\n> +\trequestTemplate = requestTemplatePreview();\n> +\tif (!requestTemplate || !requestTemplate->isValid()) {\n>  \t\tLOG(HAL, Error) << \"Failed to construct request template\";\n>  \t\tdelete requestTemplate;\n>  \t\treturn nullptr;\n>  \t}\n>  \n> +\trequestTemplate->updateEntry(ANDROID_CONTROL_CAPTURE_INTENT,\n> +\t\t\t\t     &captureIntent, 1);\n> +\n>  \trequestTemplates_[type] = requestTemplate;\n>  \treturn requestTemplate->get();\n>  }\n> diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> index af1b58ab6b4e..5a52ad8f741c 100644\n> --- a/src/android/camera_device.h\n> +++ b/src/android/camera_device.h\n> @@ -83,6 +83,7 @@ private:\n>  \tlibcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);\n>  \tvoid notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n>  \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream);\n> +\tCameraMetadata *requestTemplatePreview();\n>  \tlibcamera::PixelFormat toPixelFormat(int format);\n>  \tstd::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,\n>  \t\t\t\t\t\t\t  int64_t timestamp);","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 19213BD878\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 25 Jul 2020 16:32:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DD8761223;\n\tSat, 25 Jul 2020 18:32:04 +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 B96C760399\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 25 Jul 2020 18:32:02 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 43C1623D;\n\tSat, 25 Jul 2020 18:32:02 +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=\"qR9ahNZT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595694722;\n\tbh=ejdS6FsvZqPB9ZpyrAne78VYm+0pwM88YXGfSYXQO9g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qR9ahNZTpCktxyFkGRusSfKufF1fylK8myNNfgHGhGwnVhuTMRKrdMZwEpTXZPA4Z\n\tWmkBwymHMrE0g/60V/8Q8jPSUAEgtVapit/0rw1UPRWOksnXo6FZX9upgelxJqWUBN\n\tQWJA8oArUO6eWu+EQlyob64S/sQDFwlzVpJ6sfcg=","Date":"Sat, 25 Jul 2020 19:31:55 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200725163155.GD6253@pendragon.ideasonboard.com>","References":"<20200725144058.129388-1-jacopo@jmondi.org>\n\t<20200725144058.129388-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200725144058.129388-6-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 5/6] android: camera_device:\n\tBreak-out request template","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>"}}]