Patch Detail
Show a patch.
GET /api/1.1/patches/15904/?format=api
{ "id": 15904, "url": "https://patchwork.libcamera.org/api/1.1/patches/15904/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15904/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220512103258.324339-9-chenghaoyang@google.com>", "date": "2022-05-12T10:32:58", "name": "[libcamera-devel,8/8] Request StillCapture stream as default in Android adapter", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "09e512bdf63f835ef771233080955abe71aeb2a0", "submitter": { "id": 117, "url": "https://patchwork.libcamera.org/api/1.1/people/117/?format=api", "name": "Cheng-Hao Yang", "email": "chenghaoyang@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15904/mbox/", "series": [ { "id": 3111, "url": "https://patchwork.libcamera.org/api/1.1/series/3111/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3111", "date": "2022-05-12T10:32:50", "name": "Use two imgus in ipu3 pipeline handler", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3111/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15904/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15904/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 367FCC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 May 2022 10:33:21 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1B2C65664;\n\tThu, 12 May 2022 12:33:20 +0200 (CEST)", "from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com\n\t[IPv6:2607:f8b0:4864:20::102a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 970E965674\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 May 2022 12:33:18 +0200 (CEST)", "by mail-pj1-x102a.google.com with SMTP id\n\tqe3-20020a17090b4f8300b001dc24e4da73so5555935pjb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 May 2022 03:33:18 -0700 (PDT)", "from chenghaoyang-low.c.googlers.com.com\n\t(174.71.80.34.bc.googleusercontent.com. [34.80.71.174])\n\tby smtp.gmail.com with ESMTPSA id\n\tt19-20020a62d153000000b005087c23ad8dsm3402219pfl.0.2022.05.12.03.33.15\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 12 May 2022 03:33:16 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652351601;\n\tbh=acJunBReIxo39VWFgDP8qmaBHsVlPZCUe1Y3ALtmwnA=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=OYrFpAHipu9/cvo3czW8S8dtfsP95snlHsgPSxW+4quGw/40n5KFcN1KL58d7uK9U\n\tS+1u9lQaHdZWTLAUUamh2empDflIHps8PkvlypmF0+h5+vy72CakWbBO2G+vJ8c94t\n\tcp6YuQ+uScLdspK6EiezV5axIwUlezQCLdKCA/pK7M6z7VPzc6ydciGD/zmAUquKQH\n\tbb+07wsNrxldLjZtIDXdOLbF6bBIvy2iob9u2g5Kt/53C0aHKoRt2K3ESG5g0F5TEk\n\tF411xsHAu2vojzHNR0HCTLi5Igp/+0OO7y5B8GNENGE+tK4tNSRZAaUA2i1HA8V77z\n\tH4J8U4Xlap79w==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=mbLUbwi5z4zvZkxI7LouTIRYkgWbjYMYSYQH9WUdIn4=;\n\tb=hYFRJJ3/Q727Kk9OpN/Uze9nVO95Ff37kL5AlpHHvFfvf6RK3AbMBaPTFlth1IHPCO\n\tE8O3MbEybYC3ZG2e/hD8jkIhYor99qdBgCO29lQ1n9Dg4wogWV2zP6Yr6w5saI3mljly\n\tu3OFfCAkaC03uM3OK8ubP6nFhb5b+PrAeKD/c=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"hYFRJJ3/\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=mbLUbwi5z4zvZkxI7LouTIRYkgWbjYMYSYQH9WUdIn4=;\n\tb=qLRxxx6ZI3hoUAIjKcOE5JZ+UK6fXbUrEgve9KGuz9lB4mQocAifpUF2fhJDYcaByD\n\tuHp3k4+prLf5juZCdCTNp8786hTjhv8Awbqg7WYtxe9kVknLG5TUvxMsSCbClAY8Lhi9\n\tPXNySmqxLlpZvBUHgTz2Pwjp2QqPIeczCDZokGtYGZmSrM5mZCc7FKe9RdMQPBYRVOtF\n\tcvbz0s6j7c7Z16+idmFOVRpnshH+4EEbHX+ca5SOYTWpywq6wUfZwOu+e6pe1PsqFRh1\n\tKNM3iZyVp+2qVQ5ZzpTJiEmIssGzuo5ScxfilkKt/VwmbwJLCTdyg3kYx+vbICz4OAfQ\n\ty4VQ==", "X-Gm-Message-State": "AOAM531SjTy/ZF/ti9ddcwIVdSWjNKOjZ/pPGxhnH1wgge0W9+5Rp7XE\n\tu9gYZ8n+xbSv/7U1AEVJMw1xQvoV6yKZRgNx", "X-Google-Smtp-Source": "ABdhPJylwq7ABQ7PmENZf1mdfi5+FH2YdYwvAnexuILP/NUg836VQwJRDbqiB67YjsYiO1vQ303EDA==", "X-Received": "by 2002:a17:90a:a410:b0:1dc:d03b:5623 with SMTP id\n\ty16-20020a17090aa41000b001dcd03b5623mr10288806pjp.95.1652351596647; \n\tThu, 12 May 2022 03:33:16 -0700 (PDT)", "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 12 May 2022 10:32:58 +0000", "Message-Id": "<20220512103258.324339-9-chenghaoyang@google.com>", "X-Mailer": "git-send-email 2.36.0.512.ge40c2bad7a-goog", "In-Reply-To": "<20220512103258.324339-1-chenghaoyang@google.com>", "References": "<20220512103258.324339-1-chenghaoyang@google.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 8/8] Request StillCapture stream as\n\tdefault in Android adapter", "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>", "From": "Harvey Yang via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Harvey Yang <chenghaoyang@chromium.org>", "Cc": "Harvey Yang <chenghaoyang@google.com>,\n\tHarvey Yang <chenghaoyang@chromium.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "If the pipeline handler accepts, the Android adapter requests to handle\nthe StillCapture stream separately, instead of being mapped to an\nexisting video/preview stream.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/android/camera_device.cpp | 214 ++++++++++++++++++----------------\n src/android/camera_device.h | 21 ++++\n 2 files changed, 132 insertions(+), 103 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 00d48471..b8403cc2 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -36,23 +36,6 @@ LOG_DECLARE_CATEGORY(HAL)\n \n namespace {\n \n-/*\n- * \\struct Camera3StreamConfig\n- * \\brief Data to store StreamConfiguration associated with camera3_stream(s)\n- * \\var streams List of the pairs of a stream requested by Android HAL client\n- * and CameraStream::Type associated with the stream\n- * \\var config StreamConfiguration for streams\n- */\n-struct Camera3StreamConfig {\n-\tstruct Camera3Stream {\n-\t\tcamera3_stream_t *stream;\n-\t\tCameraStream::Type type;\n-\t};\n-\n-\tstd::vector<Camera3Stream> streams;\n-\tStreamConfiguration config;\n-};\n-\n /*\n * Reorder the configurations so that libcamera::Camera can accept them as much\n * as possible. The sort rule is as follows.\n@@ -536,16 +519,6 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\treturn -EINVAL;\n #endif\n \n-\t/*\n-\t * Generate an empty configuration, and construct a StreamConfiguration\n-\t * for each camera3_stream to add to it.\n-\t */\n-\tstd::unique_ptr<CameraConfiguration> config = camera_->generateConfiguration();\n-\tif (!config) {\n-\t\tLOG(HAL, Error) << \"Failed to generate camera configuration\";\n-\t\treturn -EINVAL;\n-\t}\n-\n \t/*\n \t * Clear and remove any existing configuration from previous calls, and\n \t * ensure the required entries are available without further\n@@ -614,93 +587,79 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\tstream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;\n \t}\n \n+\tstd::unique_ptr<CameraConfiguration> config;\n+\n \t/* Now handle the MJPEG streams, adding a new stream if required. */\n \tif (jpegStream) {\n-\t\tCameraStream::Type type;\n-\t\tint index = -1;\n-\n-\t\t/* Search for a compatible stream in the non-JPEG ones. */\n-\t\tfor (size_t i = 0; i < streamConfigs.size(); ++i) {\n-\t\t\tCamera3StreamConfig &streamConfig = streamConfigs[i];\n-\t\t\tconst auto &cfg = streamConfig.config;\n-\n-\t\t\t/*\n-\t\t\t * \\todo The PixelFormat must also be compatible with\n-\t\t\t * the encoder.\n-\t\t\t */\n-\t\t\tif (cfg.size.width != jpegStream->width ||\n-\t\t\t cfg.size.height != jpegStream->height)\n-\t\t\t\tcontinue;\n-\n-\t\t\tLOG(HAL, Info)\n-\t\t\t\t<< \"Android JPEG stream mapped to libcamera stream \" << i;\n-\n-\t\t\ttype = CameraStream::Type::Mapped;\n-\t\t\tindex = i;\n-\n-\t\t\t/*\n-\t\t\t * The source stream will be read by software to\n-\t\t\t * produce the JPEG stream.\n-\t\t\t */\n-\t\t\tcamera3_stream_t *stream = streamConfig.streams[0].stream;\n-\t\t\tstream->usage |= GRALLOC_USAGE_SW_READ_OFTEN;\n-\t\t\tbreak;\n-\t\t}\n+\t\t/* Check if the JPEG stream can be produced by software. */\n+\t\tjpegStream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;\n \n \t\t/*\n-\t\t * Without a compatible match for JPEG encoding we must\n-\t\t * introduce a new stream to satisfy the request requirements.\n+\t\t * \\todo The pixelFormat should be a 'best-fit' choice\n+\t\t * and may require a validation cycle. This is not yet\n+\t\t * handled, and should be considered as part of any\n+\t\t * stream configuration reworks.\n \t\t */\n-\t\tif (index < 0) {\n-\t\t\t/*\n-\t\t\t * \\todo The pixelFormat should be a 'best-fit' choice\n-\t\t\t * and may require a validation cycle. This is not yet\n-\t\t\t * handled, and should be considered as part of any\n-\t\t\t * stream configuration reworks.\n-\t\t\t */\n-\t\t\tCamera3StreamConfig streamConfig;\n-\t\t\tstreamConfig.config.size.width = jpegStream->width;\n-\t\t\tstreamConfig.config.size.height = jpegStream->height;\n-\t\t\tstreamConfig.config.pixelFormat = formats::NV12;\n-\t\t\tstreamConfigs.push_back(std::move(streamConfig));\n-\n-\t\t\tLOG(HAL, Info) << \"Adding \" << streamConfig.config.toString()\n-\t\t\t\t << \" for MJPEG support\";\n-\n-\t\t\ttype = CameraStream::Type::Internal;\n-\t\t\tindex = streamConfigs.size() - 1;\n-\t\t}\n-\n-\t\t/* The JPEG stream will be produced by software. */\n-\t\tjpegStream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;\n-\n-\t\tstreamConfigs[index].streams.push_back({ jpegStream, type });\n-\t}\n+\t\tCamera3StreamConfig sConfig;\n+\t\tsConfig.config.streamRole = libcamera::StreamRole::StillCapture;\n+\t\tsConfig.config.size.width = jpegStream->width;\n+\t\tsConfig.config.size.height = jpegStream->height;\n+\t\tsConfig.config.pixelFormat = formats::NV12;\n+\n+\t\tstd::vector<Camera3StreamConfig> streamConfigsCopy(streamConfigs);\n+\t\tstreamConfigsCopy.push_back(std::move(sConfig));\n+\n+\t\tLOG(HAL, Info) << \"Adding \" << sConfig.config.toString()\n+\t\t\t << \" for MJPEG support\";\n+\n+\t\tstreamConfigsCopy.back().streams.push_back({ jpegStream, CameraStream::Type::Internal });\n+\n+\t\tconfig = tryValidation(streamConfigsCopy, jpegStream);\n+\t\tif (config) {\n+\t\t\tstreamConfigs = streamConfigsCopy;\n+\t\t} else {\n+\t\t\tbool foundCompatibleStream = false;\n+\t\t\t/* Search for a compatible stream in the non-JPEG ones. */\n+\t\t\tfor (size_t i = 0; i < streamConfigs.size(); ++i) {\n+\t\t\t\tCamera3StreamConfig &streamConfig = streamConfigs[i];\n+\t\t\t\tconst auto &cfg = streamConfig.config;\n+\n+\t\t\t\t/*\n+\t\t\t\t * \\todo The PixelFormat must also be compatible with\n+\t\t\t\t * the encoder.\n+\t\t\t\t */\n+\t\t\t\tif (cfg.size.width != jpegStream->width ||\n+\t\t\t\t cfg.size.height != jpegStream->height)\n+\t\t\t\t\tcontinue;\n+\n+\t\t\t\tLOG(HAL, Info)\n+\t\t\t\t\t<< \"Android JPEG stream mapped to libcamera stream \" << i;\n+\t\t\t\tfoundCompatibleStream = true;\n+\n+\t\t\t\t/*\n+\t\t\t\t * The source stream will be read by software to\n+\t\t\t\t * produce the JPEG stream.\n+\t\t\t\t */\n+\t\t\t\tcamera3_stream_t *stream = streamConfig.streams[0].stream;\n+\t\t\t\tstream->usage |= GRALLOC_USAGE_SW_READ_OFTEN;\n+\t\t\t\tstreamConfigs[i].streams.push_back({ jpegStream, CameraStream::Type::Mapped });\n+\t\t\t\tbreak;\n+\t\t\t}\n \n-\tsortCamera3StreamConfigs(streamConfigs, jpegStream);\n-\tfor (const auto &streamConfig : streamConfigs) {\n-\t\tconfig->addConfiguration(streamConfig.config);\n+\t\t\tif (!foundCompatibleStream) {\n+\t\t\t\tLOG(HAL, Error)\n+\t\t\t\t\t<< \"No compatibleStream found for jpeg\";\n \n-\t\tfor (auto &stream : streamConfig.streams) {\n-\t\t\tstreams_.emplace_back(this, config.get(), stream.type,\n-\t\t\t\t\t stream.stream, config->size() - 1);\n-\t\t\tstream.stream->priv = static_cast<void *>(&streams_.back());\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n \t\t}\n \t}\n \n-\tswitch (config->validate()) {\n-\tcase CameraConfiguration::Valid:\n-\t\tbreak;\n-\tcase CameraConfiguration::Adjusted:\n-\t\tLOG(HAL, Info) << \"Camera configuration adjusted\";\n-\n-\t\tfor (const StreamConfiguration &cfg : *config)\n-\t\t\tLOG(HAL, Info) << \" - \" << cfg.toString();\n+\tif (!config) {\n+\t\tconfig = tryValidation(streamConfigs, jpegStream);\n+\t\tif (!config)\n+\t\t\treturn -EINVAL;\n \n-\t\treturn -EINVAL;\n-\tcase CameraConfiguration::Invalid:\n-\t\tLOG(HAL, Info) << \"Camera configuration invalid\";\n-\t\treturn -EINVAL;\n \t}\n \n \t/*\n@@ -1527,3 +1486,52 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons\n \n \treturn resultMetadata;\n }\n+\n+std::unique_ptr<CameraConfiguration> CameraDevice::tryValidation(\n+\tstd::vector<Camera3StreamConfig> &streamConfigs,\n+\tconst camera3_stream_t *jpegStream)\n+{\n+\t/*\n+\t * Generate an empty configuration, and construct a StreamConfiguration\n+\t * for each camera3_stream to add to it.\n+\t */\n+\tstd::unique_ptr<CameraConfiguration> config = camera_->generateConfiguration();\n+\tif (!config) {\n+\t\tLOG(HAL, Error) << \"Failed to generate camera configuration\";\n+\t\treturn nullptr;\n+\t}\n+\n+\tsortCamera3StreamConfigs(streamConfigs, jpegStream);\n+\tfor (const auto &streamConfig : streamConfigs) {\n+\t\tconfig->addConfiguration(streamConfig.config);\n+\n+\t\tfor (auto &stream : streamConfig.streams) {\n+\t\t\tstreams_.emplace_back(this, config.get(), stream.type,\n+\t\t\t\t\t stream.stream, config->size() - 1);\n+\t\t\tstream.stream->priv = static_cast<void *>(&streams_.back());\n+\t\t}\n+\t}\n+\n+\tswitch (config->validate()) {\n+\tcase CameraConfiguration::Valid:\n+\t\tbreak;\n+\tcase CameraConfiguration::Adjusted:\n+\t\tLOG(HAL, Info) << \"Camera configuration adjusted\";\n+\n+\t\tfor (const StreamConfiguration &cfg : *config)\n+\t\t\tLOG(HAL, Info) << \" - \" << cfg.toString();\n+\n+\t\tconfig.reset();\n+\t\tbreak;\n+\tcase CameraConfiguration::Invalid:\n+\t\tLOG(HAL, Info) << \"Camera configuration invalid\";\n+\n+\t\tconfig.reset();\n+\t\tbreak;\n+\t}\n+\n+\tif (!config)\n+\t\tstreams_.clear();\n+\n+\treturn config;\n+}\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 64050416..8540e3f5 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -34,6 +34,23 @@\n class Camera3RequestDescriptor;\n struct CameraConfigData;\n \n+/*\n+ * \\struct Camera3StreamConfig\n+ * \\brief Data to store StreamConfiguration associated with camera3_stream(s)\n+ * \\var streams List of the pairs of a stream requested by Android HAL client\n+ * and CameraStream::Type associated with the stream\n+ * \\var config StreamConfiguration for streams\n+ */\n+struct Camera3StreamConfig {\n+\tstruct Camera3Stream {\n+\t\tcamera3_stream_t *stream;\n+\t\tCameraStream::Type type;\n+\t};\n+\n+\tstd::vector<Camera3Stream> streams;\n+\tlibcamera::StreamConfiguration config;\n+};\n+\n class CameraDevice : protected libcamera::Loggable\n {\n public:\n@@ -101,6 +118,10 @@ private:\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(\n \t\tconst Camera3RequestDescriptor &descriptor) const;\n \n+\tstd::unique_ptr<libcamera::CameraConfiguration> tryValidation(\n+\t\tstd::vector<Camera3StreamConfig> &streamConfigs,\n+\t\tconst camera3_stream_t *jpegStream);\n+\n \tunsigned int id_;\n \tcamera3_device_t camera3Device_;\n \n", "prefixes": [ "libcamera-devel", "8/8" ] }