{"id":15269,"url":"https://patchwork.libcamera.org/api/patches/15269/?format=json","web_url":"https://patchwork.libcamera.org/patch/15269/","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":"<20220110165524.72978-5-jacopo@jmondi.org>","date":"2022-01-10T16:55:23","name":"[libcamera-devel,4/5] android: camera_device: Use YUV post-processor","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"97dd8f09ed0605e2046bab3fc60a42179144e17b","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/15269/mbox/","series":[{"id":2887,"url":"https://patchwork.libcamera.org/api/series/2887/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2887","date":"2022-01-10T16:55:19","name":"android: Plumb the YUV processor in","version":1,"mbox":"https://patchwork.libcamera.org/series/2887/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15269/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15269/checks/","tags":{},"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 07814C325B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Jan 2022 16:54:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 040DF6093F;\n\tMon, 10 Jan 2022 17:54:36 +0100 (CET)","from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE896604F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jan 2022 17:54:32 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id F25EB240004;\n\tMon, 10 Jan 2022 16:54:31 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 10 Jan 2022 17:55:23 +0100","Message-Id":"<20220110165524.72978-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220110165524.72978-1-jacopo@jmondi.org>","References":"<20220110165524.72978-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/5] android: camera_device: Use YUV\n\tpost-processor","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Hirokazu Honda <hiroh@chromium.org>\n\nWhen creating the list of StreamConfiguration to be requested to the camera,\nmap NV12 streams of equal size and format together, so that they will be\ngenerated by using the YUV post-processor.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 32 +++++++++++++++++++++++++++++---\n 1 file changed, 29 insertions(+), 3 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex a44f199d25d8..4e44bcfa0852 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -605,14 +605,40 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\tcontinue;\n \t\t}\n \n+\t\t/*\n+\t\t * While gralloc usage flags are supposed to report usage\n+\t\t * patterns to select a suitable buffer allocation strategy, in\n+\t\t * practice they're also used to make other decisions, such as\n+\t\t * selecting the actual format for the IMPLEMENTATION_DEFINED\n+\t\t * HAL pixel format. To avoid issues, we thus have to set the\n+\t\t * GRALLOC_USAGE_HW_CAMERA_WRITE flag unconditionally, even for\n+\t\t * streams that will be produced in software.\n+\t\t */\n+\t\tstream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;\n+\n+\t\t/*\n+\t\t * If a CameraStream with the same size and format of the\n+\t\t * current stream has already been requested, associate the two.\n+\t\t */\n+\t\tauto iter = std::find_if(\n+\t\t\tstreamConfigs.begin(), streamConfigs.end(),\n+\t\t\t[&size, &format](const Camera3StreamConfig &streamConfig) {\n+\t\t\t\treturn streamConfig.config.size == size &&\n+\t\t\t\t       streamConfig.config.pixelFormat == format;\n+\t\t\t});\n+\t\tif (iter != streamConfigs.end()) {\n+\t\t\t/* Add usage to copy the buffer in streams[0] to stream. */\n+\t\t\titer->streams[0].stream->usage |= GRALLOC_USAGE_SW_READ_OFTEN;\n+\t\t\tstream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;\n+\t\t\titer->streams.push_back({ stream, CameraStream::Type::Mapped });\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\tCamera3StreamConfig streamConfig;\n \t\tstreamConfig.streams = { { stream, CameraStream::Type::Direct } };\n \t\tstreamConfig.config.size = size;\n \t\tstreamConfig.config.pixelFormat = format;\n \t\tstreamConfigs.push_back(std::move(streamConfig));\n-\n-\t\t/* This stream will be produced by hardware. */\n-\t\tstream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;\n \t}\n \n \t/* Now handle the MJPEG streams, adding a new stream if required. */\n","prefixes":["libcamera-devel","4/5"]}