{"id":3866,"url":"https://patchwork.libcamera.org/api/1.1/patches/3866/?format=json","web_url":"https://patchwork.libcamera.org/patch/3866/","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":"<20200526142237.407557-8-jacopo@jmondi.org>","date":"2020-05-26T14:22:36","name":"[libcamera-devel,7/8] android: camera_device: Translate Android format","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ea3a3a37242a2bedea05a9270ef382d13c7d9965","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/3866/mbox/","series":[{"id":930,"url":"https://patchwork.libcamera.org/api/1.1/series/930/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=930","date":"2020-05-26T14:22:29","name":"android: Implament format translation","version":1,"mbox":"https://patchwork.libcamera.org/series/930/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3866/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3866/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1218461075\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 May 2020 16:19:28 +0200 (CEST)","from localhost.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 6426C40002;\n\tTue, 26 May 2020 14:19:28 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 26 May 2020 16:22:36 +0200","Message-Id":"<20200526142237.407557-8-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200526142237.407557-1-jacopo@jmondi.org>","References":"<20200526142237.407557-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 7/8] 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":"Tue, 26 May 2020 14:19:30 -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\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 26 +++++++++++++++++---------\n 1 file changed, 17 insertions(+), 9 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex f8a52342abe5..b0f5a6a2edb5 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -904,12 +904,27 @@ 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 format code. */\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+\tuint32_t libcameraFormatCode = it->second;\n \n+\t/*\n+\t * Hardcode viewfinder role, replacing the generate configuration\n+\t * parameters with the Android framework requestes ones.\n+\t */\n \tStreamRoles roles = { StreamRole::Viewfinder };\n \tconfig_ = camera_->generateConfiguration(roles);\n \tif (!config_ || config_->empty()) {\n@@ -917,17 +932,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 = PixelFormat(libcameraFormatCode);\n \n \tswitch (config_->validate()) {\n \tcase CameraConfiguration::Valid:\n","prefixes":["libcamera-devel","7/8"]}