Patch Detail
Show a patch.
GET /api/patches/10608/?format=api
{ "id": 10608, "url": "https://patchwork.libcamera.org/api/patches/10608/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10608/", "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": "<20201208034234.2501401-3-hiroh@chromium.org>", "date": "2020-12-08T03:42:33", "name": "[libcamera-devel,v4,3/3] android: camera_device: Reorder configurations before requesting", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "20a254c583723982a5a5aa53944c8c742fb0179d", "submitter": { "id": 63, "url": "https://patchwork.libcamera.org/api/people/63/?format=api", "name": "Hirokazu Honda", "email": "hiroh@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10608/mbox/", "series": [ { "id": 1513, "url": "https://patchwork.libcamera.org/api/series/1513/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1513", "date": "2020-12-08T03:42:31", "name": "[libcamera-devel,v4,1/3] android: camera_device: Introduce Camera3StreamConfig", "version": 4, "mbox": "https://patchwork.libcamera.org/series/1513/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10608/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10608/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 56FF1BDB20\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 8 Dec 2020 03:43:20 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 22E7D67E6F;\n\tTue, 8 Dec 2020 04:43:20 +0100 (CET)", "from mail-pg1-x543.google.com (mail-pg1-x543.google.com\n\t[IPv6:2607:f8b0:4864:20::543])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B044D67E74\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Dec 2020 04:43:18 +0100 (CET)", "by mail-pg1-x543.google.com with SMTP id o4so10973113pgj.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Dec 2020 19:43:18 -0800 (PST)", "from hiroh.c.googlers.com.com\n\t(128.141.236.35.bc.googleusercontent.com. [35.236.141.128])\n\tby smtp.gmail.com with ESMTPSA id\n\ty23sm9028227pfc.178.2020.12.07.19.43.15\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 07 Dec 2020 19:43:16 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"ll7ii2tL\"; dkim-atps=neutral", "DKIM-Signature": "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=t05elDKU5gwArfQXcC3tSZPtb0HxD6iK81Yc5ozHsC4=;\n\tb=ll7ii2tL3dsOcI8B/DmLvcaHccNaLLLOeSErg+Zyt4rMnPzTuFzeOXSnrIeysNHodq\n\tYvXAqmEruvZcMkDuv6szHVuUiGbnS4bzr+EOXBr3jcNyUr9PFl2piUhfnI7y1xicyyEg\n\tyRAhLivokgJnHOx+28QDzWDIdjDXI/rwCcBdE=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\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=t05elDKU5gwArfQXcC3tSZPtb0HxD6iK81Yc5ozHsC4=;\n\tb=aOrT5ks0K+gfvdVS28+K6o4cwlHpC8JxL8q9A8+DT8Dj1xX+/RthT8tTvRQKBMr/7V\n\txsaAgKbySHjcoUeRXd6DtqjQfei44oiane5Q8K7kIlsf+LuXiiDkgPxIv0tcD+w1EuXD\n\tmHu90RoIOQCOh/CY5dTV+cGoUZa6+r4Uid5xcpC5HVG6crFjbgsN9p9vd4w2efgy31XS\n\taEBG339P4SAnor+Rxsx6iIrPD71sUOY21EkBGW6UaENQMC7ejoJ9UQfNgj9+qZ/QzXZm\n\t3w2t3K3RiiAhlbWP1gvpgGU8RY219V0i/UhxOZRKvwoQ6WlL+c/dxuTTjE/3fl53NaVj\n\thczA==", "X-Gm-Message-State": "AOAM531LLtPRdngwa1ZZZrbjygP+PmGmHxrrxAS3arzO9dyZ6LPv06kb\n\txsKsWILAclXcghHIlwTCDUgHiF6ADxNqKp2E", "X-Google-Smtp-Source": "ABdhPJw8paD00u3X+x79zpiUjS+dHLS8NpJylLGxnzmpO708QPc1DcBI/Y/iB/okK6iK9PjDo4oHIg==", "X-Received": "by 2002:a17:90a:e604:: with SMTP id\n\tj4mr2154110pjy.19.1607398997069; \n\tMon, 07 Dec 2020 19:43:17 -0800 (PST)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Dec 2020 03:42:33 +0000", "Message-Id": "<20201208034234.2501401-3-hiroh@chromium.org>", "X-Mailer": "git-send-email 2.29.2.576.ga3fc446d84-goog", "In-Reply-To": "<20201208034234.2501401-1-hiroh@chromium.org>", "References": "<20201208034234.2501401-1-hiroh@chromium.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v4 3/3] android: camera_device: Reorder\n\tconfigurations before requesting", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "This reorders Camera3Configs before executing\nCameraConfiguration::validate() to make it easier for the Camera\nto satisfy the Android framework request.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.cpp | 108 +++++++++++++++++++++++++++++++++-\n 1 file changed, 106 insertions(+), 2 deletions(-)\n\n--\n2.29.2.576.ga3fc446d84-goog", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex b7bf3d88..36d0b343 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -9,6 +9,7 @@\n #include \"camera_ops.h\"\n #include \"post_processor.h\"\n\n+#include <optional>\n #include <sys/mman.h>\n #include <tuple>\n #include <vector>\n@@ -27,6 +28,8 @@\n\n using namespace libcamera;\n\n+LOG_DECLARE_CATEGORY(HAL)\n+\n namespace {\n\n /*\n@@ -140,9 +143,108 @@ struct Camera3StreamConfig {\n \tstd::vector<CameraStream::Type> types;\n \tStreamConfiguration config;\n };\n-} /* namespace */\n\n-LOG_DECLARE_CATEGORY(HAL)\n+/*\n+ * Reorder the configurations so that libcamera::Camera can accept them as much\n+ * as possible. The sort rule is as follows.\n+ * 1.) The configuration for NV12 request whose resolution is the largest.\n+ * 2.) The configuration for JPEG request.\n+ * 3.) Others. Larger resolutions and different formats are put earlier.\n+ */\n+std::vector<Camera3StreamConfig> sortCamera3StreamConfigs(\n+\tstd::vector<Camera3StreamConfig> unsortedConfigs,\n+\tconst camera3_stream_t *jpegStream) {\n+\tconst size_t unsortedSize = unsortedConfigs.size();\n+\tstd::optional<Camera3StreamConfig> jpegConfig = std::nullopt;\n+\n+\tif (jpegStream) {\n+\t\tfor (size_t i = 0; i < unsortedSize; ++i) {\n+\t\t\tconst auto &streams = unsortedConfigs[i].streams;\n+\t\t\tif (std::find(streams.begin(), streams.end(),\n+\t\t\t\t jpegStream) != streams.end()) {\n+\t\t\t\tjpegConfig = std::move(unsortedConfigs[i]);\n+\t\t\t\tunsortedConfigs.erase(unsortedConfigs.begin() + i);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t\tif (!jpegConfig)\n+\t\t\tLOG(HAL, Fatal) << \"No Camera3StreamConfig is found for Jpeg\";\n+\t}\n+\n+\tstd::map<uint32_t, std::vector<Camera3StreamConfig>> formatToConfigs;\n+\tfor (const auto &streamConfig : unsortedConfigs) {\n+\t\tconst StreamConfiguration &config = streamConfig.config;\n+\t\tformatToConfigs[config.pixelFormat].push_back(streamConfig);\n+\n+\t}\n+\tfor (auto &[format, streamConfigs] : formatToConfigs) {\n+\t\t/* Sorted by resolution. Smaller is put first. */\n+\t\tstd::sort(streamConfigs.begin(), streamConfigs.end(),\n+\t\t\t [](const auto &streamConfigA, const auto &streamConfigB) {\n+\t\t\t\tconst Size &sizeA = streamConfigA.config.size;\n+\t\t\t\tconst Size &sizeB = streamConfigB.config.size;\n+\t\t\t\treturn sizeA < sizeB;\n+\t\t\t });\n+\t}\n+\n+\tstd::vector<Camera3StreamConfig> sortedConfigs;\n+\tsortedConfigs.reserve(unsortedSize);\n+\t/*\n+\t * NV12 is the most prioritized format. Put the configuration with NV12\n+\t * and the largest resolution first.\n+\t */\n+\tconst auto nv12It = formatToConfigs.find(formats::NV12);\n+\tif (nv12It != formatToConfigs.end()) {\n+\t\tauto &nv12Configs = nv12It->second;\n+\t\tconst Size &nv12LargestSize = nv12Configs.back().config.size;\n+\t\t/*\n+\t\t * If JPEG will be created from NV12 and the size is larger than\n+\t\t * the largest NV12 configurations, then put the NV12\n+\t\t * configuration for JPEG first.\n+\t\t */\n+\t\tif (jpegConfig && jpegConfig->config.pixelFormat == formats::NV12) {\n+\t\t\tconst Size &nv12SizeForJpeg = jpegConfig->config.size;\n+\n+\t\t\tif (nv12LargestSize < nv12SizeForJpeg) {\n+\t\t\t\tLOG(HAL, Debug) << \"Insert \" << jpegConfig->config.toString();\n+\t\t\t\tsortedConfigs.push_back(std::move(*jpegConfig));\n+\t\t\t\tjpegConfig = std::nullopt;\n+\t\t\t}\n+\t\t}\n+\t\tLOG(HAL, Debug) << \"Insert \" << nv12Configs.back().config.toString();\n+\t\tsortedConfigs.push_back(std::move(nv12Configs.back()));\n+\t\tnv12Configs.pop_back();\n+\t}\n+\n+\t/* If the configuration for JPEG is there, then put it. */\n+\tif (jpegConfig) {\n+\t\tLOG(HAL, Debug) << \"Insert \" << jpegConfig->config.toString();\n+\t\tsortedConfigs.push_back(std::move(*jpegConfig));\n+\t\tjpegConfig = std::nullopt;\n+\t}\n+\n+\t/*\n+\t * Put configurations with different formats and larger resolutions\n+\t * earlier.\n+\t */\n+\twhile (!formatToConfigs.empty()) {\n+\t\tfor (auto it = formatToConfigs.begin(); it != formatToConfigs.end();) {\n+\t\t\tauto& configs = it->second;\n+\t\t\tif (configs.empty()) {\n+\t\t\t\tit = formatToConfigs.erase(it);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tLOG(HAL, Debug) << \"Insert \" << configs.back().config.toString();\n+\t\t\tsortedConfigs.push_back(std::move(configs.back()));\n+\t\t\tconfigs.pop_back();\n+\t\t\tit++;\n+\t\t}\n+\t}\n+\tassert(sortedConfigs.size() == unsortedSize);\n+\n+\treturn sortedConfigs;\n+}\n+} /* namespace */\n\n MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,\n \t\t\t\t\t int flags)\n@@ -1333,6 +1435,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\tstreamConfigs[index].types.push_back(type);\n \t}\n\n+\tstreamConfigs = sortCamera3StreamConfigs(std::move(streamConfigs),\n+\t\t\t\t\t\t jpegStream);\n \tfor (const auto &streamConfig : streamConfigs) {\n \t\tconfig_->addConfiguration(streamConfig.config);\n \t\tfor (size_t i = 0; i < streamConfig.streams.size(); ++i) {\n", "prefixes": [ "libcamera-devel", "v4", "3/3" ] }