{"id":3917,"url":"https://patchwork.libcamera.org/api/1.1/patches/3917/?format=json","web_url":"https://patchwork.libcamera.org/patch/3917/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200604133503.14689-4-jacopo@jmondi.org>","date":"2020-06-04T13:35:02","name":"[libcamera-devel,v2,3/4] android: camera_device: Replace hardcoded stream configuration","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c0c79e3df73ecc6e0f0378aca658fbf66f65c158","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3917/mbox/","series":[{"id":951,"url":"https://patchwork.libcamera.org/api/1.1/series/951/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=951","date":"2020-06-04T13:34:59","name":"android: Implement format translation","version":2,"mbox":"https://patchwork.libcamera.org/series/951/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3917/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3917/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 5710F610A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jun 2020 15:31:48 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id AB6421C0005;\n\tThu,  4 Jun 2020 13:31:47 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  4 Jun 2020 15:35:02 +0200","Message-Id":"<20200604133503.14689-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200604133503.14689-1-jacopo@jmondi.org>","References":"<20200604133503.14689-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/4] android: camera_device: Replace\n\thardcoded stream 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>","X-List-Received-Date":"Thu, 04 Jun 2020 13:31:49 -0000"},"content":"Replace the hardcoded stream configuration map with the information\ncollected at CameraDevice initialization time.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 41 ++++++++++++++++++++---------------\n 1 file changed, 23 insertions(+), 18 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 1f438f0e265d..d2570e91fc61 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -649,23 +649,24 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,\n \t\t\t\t  &maxDigitalZoom, 1);\n \n-\tstd::vector<uint32_t> availableStreamFormats = {\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_BLOB,\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888,\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED,\n-\t};\n+\tstd::vector<uint32_t> availableStreamFormats;\n+\tavailableStreamFormats.reserve(streamConfigurations_.size());\n+\tstd::transform(streamConfigurations_.begin(), streamConfigurations_.end(),\n+\t\t       std::back_inserter(availableStreamFormats),\n+\t\t       [](const auto &entry) { return entry.androidScalerCode; });\n \tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_FORMATS,\n \t\t\t\t  availableStreamFormats.data(),\n \t\t\t\t  availableStreamFormats.size());\n \n-\tstd::vector<uint32_t> availableStreamConfigurations = {\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920,\n-\t\tANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, 2560, 1920,\n-\t\tANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, 2560, 1920,\n-\t\tANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,\n-\t};\n+\tstd::vector<uint32_t> availableStreamConfigurations;\n+\tavailableStreamConfigurations.reserve(streamConfigurations_.size() * 4);\n+\tfor (const auto &entry : streamConfigurations_) {\n+\t\tavailableStreamConfigurations.push_back(entry.androidScalerCode);\n+\t\tavailableStreamConfigurations.push_back(entry.resolution.width);\n+\t\tavailableStreamConfigurations.push_back(entry.resolution.height);\n+\t\tavailableStreamConfigurations.push_back(\n+\t\t\tANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT);\n+\t}\n \tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,\n \t\t\t\t  availableStreamConfigurations.data(),\n \t\t\t\t  availableStreamConfigurations.size());\n@@ -677,11 +678,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\t\t\t  availableStallDurations.data(),\n \t\t\t\t  availableStallDurations.size());\n \n-\tstd::vector<int64_t> minFrameDurations = {\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333,\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, 2560, 1920, 33333333,\n-\t\tANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, 2560, 1920, 33333333,\n-\t};\n+\t/* \\todo Collect the minimum frame duration from the camera. */\n+\tstd::vector<int64_t> minFrameDurations;\n+\tminFrameDurations.reserve(streamConfigurations_.size() * 4);\n+\tfor (const auto &entry : streamConfigurations_) {\n+\t\tminFrameDurations.push_back(entry.androidScalerCode);\n+\t\tminFrameDurations.push_back(entry.resolution.width);\n+\t\tminFrameDurations.push_back(entry.resolution.height);\n+\t\tminFrameDurations.push_back(33333333);\n+\t}\n \tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,\n \t\t\t\t  minFrameDurations.data(),\n \t\t\t\t  minFrameDurations.size());\n","prefixes":["libcamera-devel","v2","3/4"]}