Show a patch.

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

{
    "id": 16057,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16057/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16057/",
    "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": "<20220526082737.1081262-9-chenghaoyang@google.com>",
    "date": "2022-05-26T08:27:36",
    "name": "[libcamera-devel,v2,8/9] 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/16057/mbox/",
    "series": [
        {
            "id": 3141,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3141/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3141",
            "date": "2022-05-26T08:27:28",
            "name": "Use two imgus in ipu3 pipeline handler",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3141/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16057/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16057/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 8BA12C326F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 May 2022 08:28:02 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C2D165673;\n\tThu, 26 May 2022 10:28:02 +0200 (CEST)",
            "from mail-pf1-x436.google.com (mail-pf1-x436.google.com\n\t[IPv6:2607:f8b0:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3483565673\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 May 2022 10:28:00 +0200 (CEST)",
            "by mail-pf1-x436.google.com with SMTP id b135so1104963pfb.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 May 2022 01:28:00 -0700 (PDT)",
            "from chenghaoyang-low.c.googlers.com.com\n\t(21.160.199.104.bc.googleusercontent.com. [104.199.160.21])\n\tby smtp.gmail.com with ESMTPSA id\n\tm2-20020a170902bb8200b0016191b843e2sm834429pls.235.2022.05.26.01.27.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 26 May 2022 01:27:57 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653553682;\n\tbh=ZeDNURdjdyolK7MV1DwwFCdS+FkO9cKYEFkxNaUib1g=;\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=gepzAd7gbYe7nxM8t3wJrIY0+nTP/PT9HbOlLdKa7GW2gpIRohaDDDi+wY6/qDsTY\n\tVJOWRLYrd51Pdl5Y6+s9cha3V3w+Tj2zmmLXazctyZzf7K7fp123I+D1URVRvr71Rp\n\tbsazaL6TELs6gCFPu1xh0N6eZmK8XjAinkefqOz+75EphWSfJa/PwTE53SS9ibSxby\n\tSuSgZT9tiI4G1YZbLhGn6l2oSufSFcs2dhwVgAB5iUoO6TyNnrl10DOxSqoHJaUpmo\n\t+wg9Ied7sSuIjvtI4jn/VMY7e1JN0IYU52Sp32ErzjyjM97MLp6Fs7K/IlNRt8C1iO\n\tOUQbekmxUX9ng==",
            "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=J74eD7TTiFhFOR3n/DIz1MYSG15gDmNy5jy9eAcJETo=;\n\tb=il34IYLEnrR9QSYyhsII6+Z2PazHNowBRRARnLprDSTpxzUVIIjZ0qrIvxucFflcYA\n\tEZtnug2BWQWt5fYBxnPKAwdByMveJ1cITEUw3Nq40DFuSAQZl2qp+DmjwiBjzQQ0eFe8\n\taOplZD89eup13xX/vkBwiBzvKmVAM1ElOLkhY="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"il34IYLE\"; \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=J74eD7TTiFhFOR3n/DIz1MYSG15gDmNy5jy9eAcJETo=;\n\tb=QRDcRWO4/P7JkshgFnEdF4L39bRp3ZE4510iX6xKt5VeP0bkP4B4vhDhA5TuNmJsWH\n\t5WjmUbL6CtfXI9uyWixIJOIZClO8CTnZgPOpUSi6LJVIPsjdgepw/Q9RpXgMsORcon2t\n\t+m8mnGJv/07VwdOTk2Y5GoEKmLyERUSBoTvKFK3zI/+WL9Hvp2Fi+JMnVWPOzdk0u6mB\n\tQFOUKYHE43mGtY57sn88Re5YO1XK0meamFisxWd4dF1Hi0XR30XJD4s+A6O/jHjDdbfR\n\t9BDDrDwTbU1CT5pMYat9blSpsTyjGCOPCXHs7g49ud7gFSeztZCvfd4btTPs81psmSyP\n\tVlxQ==",
        "X-Gm-Message-State": "AOAM5306iHl/5ZHHYk6fziCeB9JhZH0CVPONjkoFd0RUdXfdja6qGhrC\n\thyGejP7vTxTR69oclvDEpdI1bBFRazo2KoMh",
        "X-Google-Smtp-Source": "ABdhPJxNxC+Vndyjv62GkjEwwDfEN+ggYAAKz0XOt45w8L56yxxPOTS2XJvtuseLnPG8Qg3Y7AdObQ==",
        "X-Received": "by 2002:a63:b25d:0:b0:3f6:5842:2685 with SMTP id\n\tt29-20020a63b25d000000b003f658422685mr29106776pgo.363.1653553678243; \n\tThu, 26 May 2022 01:27:58 -0700 (PDT)",
        "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 26 May 2022 08:27:36 +0000",
        "Message-Id": "<20220526082737.1081262-9-chenghaoyang@google.com>",
        "X-Mailer": "git-send-email 2.36.1.124.g0e6072fb45-goog",
        "In-Reply-To": "<20220526082737.1081262-1-chenghaoyang@google.com>",
        "References": "<20220526082737.1081262-1-chenghaoyang@google.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 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.\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",
        "v2",
        "8/9"
    ]
}