Patch Detail
Show a patch.
GET /api/patches/10590/?format=api
{ "id": 10590, "url": "https://patchwork.libcamera.org/api/patches/10590/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10590/", "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": "<20201207084218.2307410-3-hiroh@chromium.org>", "date": "2020-12-07T08:42:18", "name": "[libcamera-devel,v3,3/3] android: camera_device: Reorder configurations before requesting", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bd2d41642360904b3ff9288ed4672e5ce6c09340", "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/10590/mbox/", "series": [ { "id": 1508, "url": "https://patchwork.libcamera.org/api/series/1508/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1508", "date": "2020-12-07T08:42:16", "name": "[libcamera-devel,v3,1/3] android: camera_device: Introduce Camera3StreamConfig", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1508/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10590/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10590/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 4DCE0BDB20\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 7 Dec 2020 10:44:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D9ED467E18;\n\tMon, 7 Dec 2020 11:44:45 +0100 (CET)", "from mail-oi1-x233.google.com (mail-oi1-x233.google.com\n\t[IPv6:2607:f8b0:4864:20::233])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9971F67E12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 7 Dec 2020 11:44:44 +0100 (CET)", "by mail-oi1-x233.google.com with SMTP id d27so7364372oic.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Dec 2020 02:44:44 -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\t22sm12772144pfn.190.2020.12.07.00.42.33\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 07 Dec 2020 00:42:34 -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=\"Ll7gTIdc\"; 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=5B3+4fHuXABlXZmpKC3ZgA6+5KHCXp2gsSEH09n1+nQ=;\n\tb=Ll7gTIdcdNe3WHItA7XbpnZfvFedEjwM8knaA6LTnCHS4/HkMh+rQ6/n+8uVYw6tCr\n\tGDp6G95XK3BXkVyP1QLh5PY9JFHhh0lacwi+PQwmq9GqQnnDiEiUcd+bxStMrYZm7Lvm\n\tnXMH9BtwFOFTtIie8XjI4LdNhcgdoFqxbKcsI=", "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=5B3+4fHuXABlXZmpKC3ZgA6+5KHCXp2gsSEH09n1+nQ=;\n\tb=iJdTXLo0BxMXG3mz9b75kY+0AAPeEP3+CfOgAoGHBnVtkyA1cG3inZm6Z52kGNRA6a\n\tBpUdexOommO4UoSJNH1E5gotSRHXDpOxMUQDCajVKksMX+qWZdlYlmtKvoiyk4zFtKb9\n\tZAXET38Io1F0nhzhUJ1a08aRPhp0erBgpktzF9N6EQeUVB9JZs+AfSliuEfclAc6zSMt\n\tjMYrOhMlg3GgCyqjfNzFg6O9o+Uf4dQwRNbMenUZAej34UCCgC0Im85P/2f1wzPraq0X\n\tfknG79tybO2QD51lgR3NHRzEPrGVcba13sKo7/zJfP7xv/VG1d5oZdLHinby+nO9ya7Y\n\tdTKw==", "X-Gm-Message-State": "AOAM531Uli1fFt5y8AE8/z3hXaC48szF7jLsPlx21bGMPqJai6hWTjui\n\toDD1WACKi69dGOJQsHau5G7/+poPnVZFE2ne9Ks=", "X-Google-Smtp-Source": "ABdhPJzaJdalaesUQmPIlathtcSondTtnNKDtIvPKIUZ9AuReMDfqlk1WqdB3ee3Yu5n2c/8wwkWcA==", "X-Received": "by 2002:a17:90a:e64e:: with SMTP id\n\tep14mr9019778pjb.5.1607330555266; \n\tMon, 07 Dec 2020 00:42:35 -0800 (PST)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 7 Dec 2020 08:42:18 +0000", "Message-Id": "<20201207084218.2307410-3-hiroh@chromium.org>", "X-Mailer": "git-send-email 2.29.2.576.ga3fc446d84-goog", "In-Reply-To": "<20201207084218.2307410-1-hiroh@chromium.org>", "References": "<20201207084218.2307410-1-hiroh@chromium.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v3 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---\n src/android/camera_device.cpp | 104 +++++++++++++++++++++++++++++++++-\n 1 file changed, 102 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..dcba4e7d 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,104 @@ 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 CameraDevice can accept them as much as\n+ * 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> unsortedStreamConfigs,\n+\tconst camera3_stream_t *jpegStream) {\n+\tconst size_t unsortedStreamConfigsSize = unsortedStreamConfigs.size();\n+\tstd::optional<Camera3StreamConfig> streamConfigForJpeg = std::nullopt;\n+\tif (jpegStream) {\n+\t\tfor (auto it = unsortedStreamConfigs.begin();\n+\t\t it != unsortedStreamConfigs.end(); it++) {\n+\t\t\tconst auto &streams = it->streams;\n+\t\t\tif (std::find(streams.begin(), streams.end(),\n+\t\t\t\t jpegStream) != streams.end()) {\n+\t\t\t\tstreamConfigForJpeg = *it;\n+\t\t\t\tunsortedStreamConfigs.erase(it);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+ if (!streamConfigForJpeg)\n+ LOG(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 : unsortedStreamConfigs) {\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\t const Size &sizeA = streamConfigA.config.size;\n+\t\t\t\t const Size &sizeB = streamConfigB.config.size;\n+ return sizeA < sizeB;\n+\t\t\t });\n+\t}\n+\n+\tstd::vector<Camera3StreamConfig> sortedStreamConfigs;\n+ sortedStreamConfigs.reserve(unsortedStreamConfigsSize);\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 nv12Stream = formatToConfigs.find(formats::NV12);\n+\tif (nv12Stream != formatToConfigs.end()) {\n+\t\tauto &nv12StreamConfigs = nv12Stream->second;\n+\t\tconst Size &nv12LargestSize = nv12StreamConfigs.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 (streamConfigForJpeg &&\n+\t\t streamConfigForJpeg->config.pixelFormat == formats::NV12) {\n+\t\t\tconst Size &nv12SizeForJpeg = streamConfigForJpeg->config.size;\n+\t\t\tif (nv12LargestSize < nv12SizeForJpeg) {\n+\t\t\t\tsortedStreamConfigs.push_back(*streamConfigForJpeg);\n+\t\t\t\tstreamConfigForJpeg = std::nullopt;\n+\t\t\t}\n+\t\t}\n+\t\tsortedStreamConfigs.push_back(nv12StreamConfigs.back());\n+\t\tnv12StreamConfigs.pop_back();\n+\t}\n+\n+\t/* If the configuration for JPEG is there, then put it. */\n+\tif (streamConfigForJpeg) {\n+\t\tsortedStreamConfigs.push_back(*streamConfigForJpeg);\n+\t\tstreamConfigForJpeg = 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& streamConfigs = it->second;\n+\t\t\tif (streamConfigs.empty()) {\n+\t\t\t\tit = formatToConfigs.erase(it);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tsortedStreamConfigs.push_back(streamConfigs.back());\n+\t\t\tstreamConfigs.pop_back();\n+\t\t\tit++;\n+\t\t}\n+\t}\n+\tassert(sortedStreamConfigs.size() == unsortedStreamConfigsSize);\n+\n+\treturn sortedStreamConfigs;\n+}\n+} /* namespace */\n\n MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,\n \t\t\t\t\t int flags)\n@@ -1333,6 +1431,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", "v3", "3/3" ] }