Show a patch.

GET /api/patches/10644/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10644,
    "url": "https://patchwork.libcamera.org/api/patches/10644/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10644/",
    "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": "<20201211095336.40500-3-hiroh@chromium.org>",
    "date": "2020-12-11T09:53:36",
    "name": "[libcamera-devel,v7,3/3] android: camera_device: Reorder configurations before requesting",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "952e39ea235a7aa46a7ee1dbbfddafd7a50a308d",
    "submitter": {
        "id": 63,
        "url": "https://patchwork.libcamera.org/api/people/63/?format=api",
        "name": "Hirokazu Honda",
        "email": "hiroh@chromium.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/10644/mbox/",
    "series": [
        {
            "id": 1525,
            "url": "https://patchwork.libcamera.org/api/series/1525/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1525",
            "date": "2020-12-11T09:53:34",
            "name": "[libcamera-devel,v7,1/3] android: camera_device: Introduce Camera3StreamConfig",
            "version": 7,
            "mbox": "https://patchwork.libcamera.org/series/1525/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10644/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10644/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 DFE54BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Dec 2020 09:53:50 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F8E267E6B;\n\tFri, 11 Dec 2020 10:53:50 +0100 (CET)",
            "from mail-pl1-x641.google.com (mail-pl1-x641.google.com\n\t[IPv6:2607:f8b0:4864:20::641])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED4B3600FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Dec 2020 10:53:48 +0100 (CET)",
            "by mail-pl1-x641.google.com with SMTP id t18so4350218plo.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Dec 2020 01:53:48 -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\ta17sm8363364pgw.80.2020.12.11.01.53.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 11 Dec 2020 01:53:46 -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=\"NoiyeHtS\"; 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=PshUzRB1+t2w08FIhupSaj8N5u9sFU7dZzaCHxWt0YA=;\n\tb=NoiyeHtSR9SWjVob2SxDJGrYB51VRLJdCAGkPKevXLDPP4T0BWwTpq2qWc/1GKl0JU\n\tmzdHrqsUzOsy6NdT/6Og83JNme/VryaGgQvfOF6drCkNzcDl8gwC9AZq8sdII/RFInRO\n\tsUuoRCQmc71oGLlJqY4Pcd6rzhRe51GKKTDkE=",
        "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=PshUzRB1+t2w08FIhupSaj8N5u9sFU7dZzaCHxWt0YA=;\n\tb=Km0Vc1043oeL8qj4iCco+tz5CzaATwSRV8b9GNno+RmPa2uc4iosCsekOWg2nN2nUA\n\tbcAPUvanV5UKIALiBDHabIr/KU6r+LV7BEKHMS+2acXRZbZT0fApUnXOehw4sLEzG50A\n\tyP5YuRE9rBTj+a7SjEwBEgjnnjaw0QUQArLDvFHWEadkr1jo9Ro931IUyGN7WpLrC/xL\n\tgPEmgJHDe+9GiPQ9SkyyKy08ugzbqfRUwhAw938YsiJhu948Fj30NkPz+yWaJmjvxotD\n\ta/78Dz+NKb5LA2cy56RgyVf3xFQLEN/z7G+O5/b0FNJMotap9+rfDcNR5vbFWdBNklDz\n\tsMoQ==",
        "X-Gm-Message-State": "AOAM53073oISpYIm8O8SH4ha5A+rN7jMb7yfPlKYNqE20Fp6qqWUGQ8G\n\tMBEvK4ASEmzhnktHwUZg6PSwVqRU+a3nDLiw",
        "X-Google-Smtp-Source": "ABdhPJy0/j46dwUE4oEUPn6cW2ldQu4h5wYbIZKJMYTIayOy3i36dIb6kOh++UPnWixCYHEBYJRBgg==",
        "X-Received": "by 2002:a17:90a:bb83:: with SMTP id\n\tv3mr12302242pjr.28.1607680427345; \n\tFri, 11 Dec 2020 01:53:47 -0800 (PST)",
        "From": "Hirokazu Honda <hiroh@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 11 Dec 2020 09:53:36 +0000",
        "Message-Id": "<20201211095336.40500-3-hiroh@chromium.org>",
        "X-Mailer": "git-send-email 2.29.2.576.ga3fc446d84-goog",
        "In-Reply-To": "<20201211095336.40500-1-hiroh@chromium.org>",
        "References": "<20201211095336.40500-1-hiroh@chromium.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v7 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>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Umang Jain <email@uajain.com>\n---\n src/android/camera_device.cpp | 110 +++++++++++++++++++++++++++++++++-\n 1 file changed, 108 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 7e8b2818..0c58c1c5 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -27,6 +27,8 @@\n\n using namespace libcamera;\n\n+LOG_DECLARE_CATEGORY(HAL)\n+\n namespace {\n\n /*\n@@ -144,9 +146,112 @@ struct Camera3StreamConfig {\n \tstd::vector<Camera3Stream> streams;\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+void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,\n+\t\t\t      const camera3_stream_t *jpegStream)\n+{\n+\tconst Camera3StreamConfig *jpegConfig = nullptr;\n+\n+\tstd::map<PixelFormat, std::vector<const Camera3StreamConfig *>> formatToConfigs;\n+\tfor (const auto &streamConfig : unsortedConfigs) {\n+\t\tif (jpegStream && !jpegConfig) {\n+\t\t\tconst auto &streams = streamConfig.streams;\n+\t\t\tif (std::find_if(streams.begin(), streams.end(),\n+\t\t\t\t\t [jpegStream](const auto &stream) {\n+\t\t\t\t\t\t return stream.stream == jpegStream;\n+\t\t\t\t\t }) != streams.end()) {\n+\t\t\t\tjpegConfig = &streamConfig;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t}\n+\t\tformatToConfigs[streamConfig.config.pixelFormat].push_back(&streamConfig);\n+\t}\n+\tif (jpegStream && !jpegConfig)\n+\t\tLOG(HAL, Fatal) << \"No Camera3StreamConfig is found for JPEG\";\n+\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+\t\t\t\t  return sizeA < sizeB;\n+\t\t\t  });\n+\t}\n+\n+\tstd::vector<Camera3StreamConfig> sortedConfigs;\n+\tsortedConfigs.reserve(unsortedConfigs.size());\n+\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 auto &nv12Largest = nv12Configs.back();\n+\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+\t\t\tconst Size &nv12LargestSize = nv12Largest->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 = nullptr;\n+\t\t\t}\n+\t\t}\n+\n+\t\tLOG(HAL, Debug) << \"Insert \" << nv12Largest->config.toString();\n+\t\tsortedConfigs.push_back(*nv12Largest);\n+\t\tnv12Configs.pop_back();\n+\n+\t\tif (nv12Configs.empty())\n+\t\t\tformatToConfigs.erase(nv12It);\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 = nullptr;\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\tLOG(HAL, Debug) << \"Insert \" << configs.back()->config.toString();\n+\t\t\tsortedConfigs.push_back(*configs.back());\n+\t\t\tconfigs.pop_back();\n+\n+\t\t\tif (configs.empty())\n+\t\t\t\tit = formatToConfigs.erase(it);\n+\t\t\telse\n+\t\t\t\tit++;\n+\t\t}\n+\t}\n+\n+\tASSERT(sortedConfigs.size() == unsortedConfigs.size());\n+\n+\tunsortedConfigs = sortedConfigs;\n+}\n+} /* namespace */\n\n MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,\n \t\t\t\t\t int flags)\n@@ -1356,6 +1461,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\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\n",
    "prefixes": [
        "libcamera-devel",
        "v7",
        "3/3"
    ]
}