Patch Detail
Show a patch.
GET /api/patches/16907/?format=api
{ "id": 16907, "url": "https://patchwork.libcamera.org/api/patches/16907/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16907/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20220802102943.3221109-9-chenghaoyang@google.com>", "date": "2022-08-02T10:29:42", "name": "[libcamera-devel,v4,8/9] Request StillCapture stream as default in Android adapter", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "4046dad64a015099b167042ed6ad90afed6876d8", "submitter": { "id": 117, "url": "https://patchwork.libcamera.org/api/people/117/?format=api", "name": "Cheng-Hao Yang", "email": "chenghaoyang@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16907/mbox/", "series": [ { "id": 3357, "url": "https://patchwork.libcamera.org/api/series/3357/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3357", "date": "2022-08-02T10:29:34", "name": "Use two imgus in ipu3 pipeline handler", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3357/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16907/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16907/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 6DA71C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 2 Aug 2022 10:30:04 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 30E5A6331E;\n\tTue, 2 Aug 2022 12:30:04 +0200 (CEST)", "from mail-pf1-x429.google.com (mail-pf1-x429.google.com\n\t[IPv6:2607:f8b0:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C50263327\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 2 Aug 2022 12:30:02 +0200 (CEST)", "by mail-pf1-x429.google.com with SMTP id 17so13214614pfy.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Aug 2022 03:30:02 -0700 (PDT)", "from chenghaoyang-low.c.googlers.com.com\n\t(231.137.80.34.bc.googleusercontent.com. [34.80.137.231])\n\tby smtp.gmail.com with ESMTPSA id\n\tt15-20020a170902e84f00b0016db88f69a2sm1955128plg.141.2022.08.02.03.30.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 02 Aug 2022 03:30:00 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659436204;\n\tbh=cVUZrqn5rxXptGZixyEE7N62IrSbeb/6ouOj91M4N0Q=;\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=qY8FLLl0LCFg4IF8lhpYBF1QcxGpP0Y+K481K/oa8pwI6zXN/aMjQejFCP1eih2WO\n\tuGDJ8vMk0I1w9IkdmuESVE8D2zKvl2XVcsoyHdi2DSrzLhD3MWo8IR4fshbPWnwTTp\n\tQYmsqBN9aPmEsd7H7IbiDE2ZHORwTrAG3/EZvdVDa5PB7cb6zXqpB2YDN2vA6IUqsv\n\tD93kv6yIyV0+PoXqyPkB0sNlKZbsdBzpfPVW5f9IYdi8RCN3j1Ll6jCbAkTS4bV1cD\n\t1ap2dGWMXMnm+FfZ6MPd5uhAm38xg8b1RT4q802dTbb2QdpXP1ZW4QVYTmafQm6e6G\n\tD8lsO89W3LmtQ==", "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=l+ECUe5UPfDYukWy9zAiCTnRz4IAiHnvawL2cEiDqPU=;\n\tb=Mup07Rnk9xMNnPzaJaO8dAFvn+91lNXQZRoxdqZGNjKzSjOIwXBw9cRa13lAvXepBV\n\tQbOq8H7THm/6vLXai609935V/tl/7RR6t4iPAsYVBWdtDoXGYXA4XQedRNrTwYR+2IXk\n\tOuXWtbzkgQKyYSLBEw+WP9W7omKjDAD3AFpoE=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"Mup07Rnk\"; \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=l+ECUe5UPfDYukWy9zAiCTnRz4IAiHnvawL2cEiDqPU=;\n\tb=KdhRsKPZRbuKFKgRwu+LDfyduJ4EI02py7XLfVvvFW7z6jqhJxufzguZH650eRSgRT\n\tj0XOJ1Pe8dQhFHJTFjvRSljBljms97fCdtlfYE3PftprCZ+AlB6t6B11lhsp47t0LkQi\n\tFtjsk9ddj51rTpQW8h3Aunj+pldaM8FgwhhUYmT5pVRLQrwsSbYW/TXhL9UMM0mCzU/q\n\tJR44TXoy2HMbKPEjLY14NZt0G8Ev++hrz4q+IvJeBZ21VgRMbqiLpx7i/cBvFVR/dgeA\n\tniXzda91F1W/vr+rzXc3+qNEqd9/B/xCUtDVrzWkIDbZSv5FvdDHgnes9wZYNksbsq+k\n\tmStQ==", "X-Gm-Message-State": "AJIora91GGua0F7yJd9JVS0d91K5JHVi/G6p+xn1hnHcAZQyuBIDsnId\n\tm5TBgJ1rA9d5RG6oywfzoqoyz6rU5fj6qg==", "X-Google-Smtp-Source": "AGRyM1tXdUFcdz+0ZN6ThZPaXkYbFEOKxPiB6bgNl2/A0LkQ3OQQz5wdlCr9ozdIgA16hkTlGhPC+Q==", "X-Received": "by 2002:a63:4913:0:b0:40d:8235:2d1c with SMTP id\n\tw19-20020a634913000000b0040d82352d1cmr16259816pga.584.1659436201438; \n\tTue, 02 Aug 2022 03:30:01 -0700 (PDT)", "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 2 Aug 2022 10:29:42 +0000", "Message-Id": "<20220802102943.3221109-9-chenghaoyang@google.com>", "X-Mailer": "git-send-email 2.37.1.455.g008518b4e5-goog", "In-Reply-To": "<20220802102943.3221109-1-chenghaoyang@google.com>", "References": "<20220802102943.3221109-1-chenghaoyang@google.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 8/9] 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 or creating a new video stream.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/android/camera_device.cpp | 235 +++++++++++++++++++---------------\n src/android/camera_device.h | 21 +++\n 2 files changed, 154 insertions(+), 102 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 00d48471..bbb72615 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,102 @@ 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/* This stream will be produced by hardware. */\n+\t\tjpegStream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;\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\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\t/* The JPEG stream will be produced by software. */\n+\t\t\tjpegStream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;\n+\n+\t\t\tCameraStream::Type type;\n+\t\t\tint index = -1;\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\tindex = i;\n+\t\t\t\ttype = CameraStream::Type::Mapped;\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\tbreak;\n+\t\t\t}\n+\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 * Without a compatible match for JPEG encoding we must\n+\t\t\t * introduce a new stream to satisfy the request requirements.\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-\n-\tsortCamera3StreamConfigs(streamConfigs, jpegStream);\n-\tfor (const auto &streamConfig : streamConfigs) {\n-\t\tconfig->addConfiguration(streamConfig.config);\n+\t\t\tif (index < 0) {\n+\t\t\t\t/*\n+\t\t\t\t * \\todo The pixelFormat should be a 'best-fit' choice\n+\t\t\t\t * and may require a validation cycle. This is not yet\n+\t\t\t\t * handled, and should be considered as part of any\n+\t\t\t\t * stream configuration reworks.\n+\t\t\t\t */\n+\t\t\t\tCamera3StreamConfig streamConfig;\n+\t\t\t\tstreamConfig.config.size.width = jpegStream->width;\n+\t\t\t\tstreamConfig.config.size.height = jpegStream->height;\n+\t\t\t\tstreamConfig.config.pixelFormat = formats::NV12;\n+\t\t\t\tstreamConfigs.push_back(std::move(streamConfig));\n+\n+\t\t\t\tLOG(HAL, Info) << \"Adding \" << streamConfig.config.toString()\n+\t\t\t\t\t << \" for MJPEG support\";\n+\n+\t\t\t\ttype = CameraStream::Type::Internal;\n+\t\t\t\tindex = streamConfigs.size() - 1;\n+\t\t\t}\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\tstreamConfigs[index].streams.push_back({ jpegStream, type });\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 +1509,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", "v4", "8/9" ] }