Patch Detail
Show a patch.
GET /api/patches/1929/?format=api
{ "id": 1929, "url": "https://patchwork.libcamera.org/api/patches/1929/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1929/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190904141825.20697-7-jacopo@jmondi.org>", "date": "2019-09-04T14:18:23", "name": "[libcamera-devel,v5,6/8] android: camera_device: Fix handling of request template", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "38ec67f057058d7a33b95039583a9c84783a863b", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1929/mbox/", "series": [ { "id": 480, "url": "https://patchwork.libcamera.org/api/series/480/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=480", "date": "2019-09-04T14:18:17", "name": "android: Rework metadata tags", "version": 5, "mbox": "https://patchwork.libcamera.org/series/480/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1929/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1929/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE92960BB2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 4 Sep 2019 16:17:09 +0200 (CEST)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 08F9D1C000B;\n\tWed, 4 Sep 2019 14:17:07 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Jacopo Mondi <jacopo@jmondi.org>, kamesan@google.com, jcliang@google.com,\n\tshik@google.com, wtlee@google.com", "Date": "Wed, 4 Sep 2019 16:18:23 +0200", "Message-Id": "<20190904141825.20697-7-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20190904141825.20697-1-jacopo@jmondi.org>", "References": "<20190904141825.20697-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 6/8] android: camera_device: Fix\n\thandling of request template", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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>", "X-List-Received-Date": "Wed, 04 Sep 2019 14:17:10 -0000" }, "content": "According to the Android camera HALv3 documentation, the request\ntemplate metadata pack should not be modified after it is returned to\nthe camera stack from the HAL.\n\nCurrently, the same metadata pack is used for all types of template\nrequest, without updating the capture intent there contained to match\nthe requested template type, as correctly reported by the\ncros_camera_test test application.\n\nIn order to avoid modifying the single request template already returned\nto the camera stack in order to update the capture intent it contains,\ncreate a map that associates a dedicated template to each supported\ncapture type.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 98 +++++++++++++++++------------------\n src/android/camera_device.h | 2 +-\n 2 files changed, 49 insertions(+), 51 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 5f8d19b9ef3d..c4f11e91bcf1 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -51,7 +51,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()\n \n CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)\n \t: running_(false), camera_(camera), staticMetadata_(nullptr),\n-\t requestTemplate_(nullptr)\n+\t requestTemplates_()\n {\n \tcamera_->requestCompleted.connect(this, &CameraDevice::requestComplete);\n }\n@@ -62,9 +62,9 @@ CameraDevice::~CameraDevice()\n \t\tfree_camera_metadata(staticMetadata_);\n \tstaticMetadata_ = nullptr;\n \n-\tif (requestTemplate_)\n-\t\tfree_camera_metadata(requestTemplate_);\n-\trequestTemplate_ = nullptr;\n+\tfor (auto &it : requestTemplates_)\n+\t\tfree_camera_metadata(it.second);\n+\trequestTemplates_.clear();\n }\n \n /*\n@@ -515,119 +515,117 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n {\n \tint ret;\n \n-\t/*\n-\t * \\todo Inspect type and pick the right metadata pack.\n-\t * As of now just use a single one for all templates.\n-\t */\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-\tif (requestTemplate_)\n-\t\treturn requestTemplate_;\n+\tif (requestTemplates_.find(type) != requestTemplates_.end())\n+\t\treturn requestTemplates_[type];\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-\trequestTemplate_ = allocate_camera_metadata(15, 20);\n-\tif (!requestTemplate_) {\n+\tcamera_metadata_t * requestTemplate = allocate_camera_metadata(15, 20);\n+\tif (!requestTemplate) {\n \t\tLOG(HAL, Error) << \"Failed to allocate template metadata\";\n \t\treturn nullptr;\n \t}\n \n \tuint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AE_MODE,\n \t\t\t&aeMode, 1);\n \tMETADATA_ASSERT(ret);\n \n \tint32_t aeExposureCompensation = 0;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,\n \t\t\t&aeExposureCompensation, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,\n \t\t\t&aePrecaptureTrigger, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AE_LOCK,\n \t\t\t&aeLock, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AF_TRIGGER,\n \t\t\t&afTrigger, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AWB_MODE,\n \t\t\t&awbMode, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_AWB_LOCK,\n \t\t\t&awbLock, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t flashMode = ANDROID_FLASH_MODE_OFF;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_FLASH_MODE,\n \t\t\t&flashMode, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_STATISTICS_FACE_DETECT_MODE,\n \t\t\t&faceDetectMode, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_NOISE_REDUCTION_MODE, &noiseReduction, 1);\n \tMETADATA_ASSERT(ret);\n \n \tuint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;\n-\tret = add_camera_metadata_entry(requestTemplate_,\n+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_COLOR_CORRECTION_ABERRATION_MODE,\n \t\t\t&aberrationMode, 1);\n \tMETADATA_ASSERT(ret);\n \n-\tret = add_camera_metadata_entry(requestTemplate_,\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+\tret = add_camera_metadata_entry(requestTemplate,\n \t\t\tANDROID_CONTROL_CAPTURE_INTENT,\n \t\t\t&captureIntent, 1);\n \tMETADATA_ASSERT(ret);\n \n-\treturn requestTemplate_;\n+\trequestTemplates_[type] = requestTemplate;\n+\n+\treturn requestTemplate;\n }\n \n /*\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 7897ba9dc5c7..64382bbac76a 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -66,7 +66,7 @@ private:\n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n \n \tcamera_metadata_t *staticMetadata_;\n-\tcamera_metadata_t *requestTemplate_;\n+\tstd::map<unsigned int, camera_metadata_t *> requestTemplates_;\n \tconst camera3_callback_ops_t *callbacks_;\n };\n \n", "prefixes": [ "libcamera-devel", "v5", "6/8" ] }