{"id":3918,"url":"https://patchwork.libcamera.org/api/patches/3918/?format=json","web_url":"https://patchwork.libcamera.org/patch/3918/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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-5-jacopo@jmondi.org>","date":"2020-06-04T13:35:03","name":"[libcamera-devel,v2,4/4] android: camera_device: Translate Android format","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ef7884e31f32ba18a4f937be98ac0254ee86fd52","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3918/mbox/","series":[{"id":951,"url":"https://patchwork.libcamera.org/api/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/3918/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3918/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 1DAC961027\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jun 2020 15:31:49 +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 7C0BA1C0016;\n\tThu,  4 Jun 2020 13:31:48 +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:03 +0200","Message-Id":"<20200604133503.14689-5-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 4/4] android: camera_device: Translate\n\tAndroid format","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":"Translate the Android format code to the libcamera format code\nat stream configuration time, using the translation map built at\ncamera device 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 | 25 ++++++++++++++++---------\n 1 file changed, 16 insertions(+), 9 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex d2570e91fc61..915d9777fd78 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -933,12 +933,26 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\t       << \", format: \" << utils::hex(stream->format);\n \t}\n \n-\t/* Hardcode viewfinder role, collecting sizes from the stream config. */\n+\t/* Only one stream is supported. */\n \tif (stream_list->num_streams != 1) {\n \t\tLOG(HAL, Error) << \"Only one stream supported\";\n \t\treturn -EINVAL;\n \t}\n+\tcamera3_stream_t *camera3Stream = stream_list->streams[0];\n+\n+\t/* Translate Android format code to libcamera pixel format. */\n+\tauto it = formatsMap_.find(camera3Stream->format);\n+\tif (it == formatsMap_.end()) {\n+\t\tLOG(HAL, Error) << \"Requested format \"\n+\t\t\t\t<< utils::hex(camera3Stream->format)\n+\t\t\t\t<< \" not supported\";\n+\t\treturn -EINVAL;\n+\t}\n \n+\t/*\n+\t * Hardcode viewfinder role, replacing the generated configuration\n+\t * parameters with the ones requested by the Android framework.\n+\t */\n \tStreamRoles roles = { StreamRole::Viewfinder };\n \tconfig_ = camera_->generateConfiguration(roles);\n \tif (!config_ || config_->empty()) {\n@@ -946,17 +960,10 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\treturn -EINVAL;\n \t}\n \n-\t/* Only one stream is supported. */\n-\tcamera3_stream_t *camera3Stream = stream_list->streams[0];\n \tStreamConfiguration *streamConfiguration = &config_->at(0);\n \tstreamConfiguration->size.width = camera3Stream->width;\n \tstreamConfiguration->size.height = camera3Stream->height;\n-\n-\t/*\n-\t * \\todo We'll need to translate from Android defined pixel format codes\n-\t * to the libcamera image format codes. For now, do not change the\n-\t * format returned from Camera::generateConfiguration().\n-\t */\n+\tstreamConfiguration->pixelFormat = it->second;\n \n \tswitch (config_->validate()) {\n \tcase CameraConfiguration::Valid:\n","prefixes":["libcamera-devel","v2","4/4"]}