Show a patch.

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

{
    "id": 16710,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16710/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16710/",
    "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": "<20220720164004.3813194-1-paul.elder@ideasonboard.com>",
    "date": "2022-07-20T16:40:04",
    "name": "[libcamera-devel,RFC,v2] pipeline: rkisp1: Query the driver for formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e78225f1d5e35dbe3b97486ef04e5dd3a9a818a9",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16710/mbox/",
    "series": [
        {
            "id": 3311,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3311/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3311",
            "date": "2022-07-20T16:40:04",
            "name": "[libcamera-devel,RFC,v2] pipeline: rkisp1: Query the driver for formats",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3311/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16710/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16710/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 714B4BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Jul 2022 16:40:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB1846330D;\n\tWed, 20 Jul 2022 18:40:21 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7969460489\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jul 2022 18:40:20 +0200 (CEST)",
            "from pyrite.rasen.tech (softbank036240121080.bbtec.net\n\t[36.240.121.80])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CBF346DB;\n\tWed, 20 Jul 2022 18:40:18 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658335221;\n\tbh=4lKxeG6LjdTsi8Pa1kiBbEjsKXzLa3oD323IYT3WqoA=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=NDdd7QxJCEvM9hMD31vHS2MdMy4C5SaE0xq4JIOXYxKfe7ognMCvfhmADePHyFk7H\n\t3/i45RcwGRT1WAD8Jj2SHdzDItF0tnZnb1741fBq/SzsQf7a5txpIUjGsWfoIEC1hh\n\t7+htpIPmmqRR0+0ckmIJBCpCfKwe4VK0h0tJxhKteHH4El55iyE10SWFot+DqwNerR\n\t5saqOPmcUNXSfAzPc+/oh9ltOnLfjQfklVgBZ9bzVwpQZSk8wjomvimuBUdUahUNOj\n\tpL9IATEh4Gzdhia2wAtbKPV6jxKr0vtqtybp09AV6oUlUZYcIyv+pFh43wPhIj4J0o\n\tJRxT0/GSxSO9Q==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658335220;\n\tbh=4lKxeG6LjdTsi8Pa1kiBbEjsKXzLa3oD323IYT3WqoA=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=wFkms+icy79cIjqiKrseRE6kAXOJ/U0M5xCU4BWfnuMny08u6rdvuAI/mwa/wRjQQ\n\tA7ht7lBcEcxBRxDwXlxfDC6NKR9eepFU9CjdVoYB14lVKIaSY/1rNZeU7QPfGY0TiJ\n\t2XMCQw93BaNG5I4AYDLqJp2gdr+m/QIkSMi1N5dY="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"wFkms+ic\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 21 Jul 2022 01:40:04 +0900",
        "Message-Id": "<20220720164004.3813194-1-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC PATCH v2] pipeline: rkisp1: Query the driver\n\tfor formats",
        "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": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Query the driver for the output formats that it supports, instead of\nhardcoding it. While at it, cache the framesizes as well.\n\nThis allows future-proofing for formats that are supported by some but\nnot all versions of the driver.\n\nAs the rkisp1 driver currently does not support VIDIOC_ENUM_FRAMESIZES,\nfallback to the hardcoded list of supported formats and framesizes. This\nfeature will be added to the driver in parallel, though we cannot\nguarantee that users will have a new enough kernel for it.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- enumerate and cache framesizes as well\n  - massage generateConfiguration accordingly\n  - this lets us skip modifying V4L2VideoDevice::formats() to support\n    lack of ENUM_FRAMESIZES\n  - also requires us to keep the list of hardcoded formats for backward\n    compatibility\n---\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 50 +++++++++++++++++--\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  3 ++\n 2 files changed, 48 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 6f175758..cf5feebe 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -41,6 +41,8 @@ bool RkISP1Path::init(MediaDevice *media)\n \tif (video_->open() < 0)\n \t\treturn false;\n \n+\tpopulateFormats(video_);\n+\n \tlink_ = media->link(\"rkisp1_isp\", 2, resizer, 0);\n \tif (!link_)\n \t\treturn false;\n@@ -48,15 +50,44 @@ bool RkISP1Path::init(MediaDevice *media)\n \treturn true;\n }\n \n+void RkISP1Path::populateFormats(std::unique_ptr<V4L2VideoDevice> &video)\n+{\n+\tV4L2VideoDevice::Formats v4l2Formats = video->formats();\n+\tif (v4l2Formats.empty()) {\n+\t\tLOG(RkISP1, Warning)\n+\t\t\t<< \"Failed to enumerate framesizes. Loading default framesizes\";\n+\n+\t\tfor (const PixelFormat &format : formats_)\n+\t\t\tstreamFormats_[format] = { { minResolution_, maxResolution_ } };\n+\t\treturn;\n+\t}\n+\n+\tstd::vector<PixelFormat> formats;\n+\tfor (auto pair : v4l2Formats) {\n+\t\tconst PixelFormat pixelFormat = pair.first.toPixelFormat();\n+\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat);\n+\n+\t\t/* \\todo Add support for RAW formats. */\n+\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n+\t\t\tcontinue;\n+\n+\t\tstreamFormats_[pixelFormat] = pair.second;\n+\t}\n+}\n+\n StreamConfiguration RkISP1Path::generateConfiguration(const Size &resolution)\n {\n \tSize maxResolution = maxResolution_.boundedToAspectRatio(resolution)\n \t\t\t\t\t   .boundedTo(resolution);\n \tSize minResolution = minResolution_.expandedToAspectRatio(resolution);\n \n+\t/*\n+\t * Can we use the global min/max resolutions here or does it need to be\n+\t * resized to the same aspect ratio as the requested resolution?\n+\t */\n \tstd::map<PixelFormat, std::vector<SizeRange>> streamFormats;\n-\tfor (const PixelFormat &format : formats_)\n-\t\tstreamFormats[format] = { { minResolution, maxResolution } };\n+\tfor (auto pair : streamFormats_)\n+\t\tstreamFormats[pair.first] = { { minResolution, maxResolution } };\n \n \tStreamFormats formats(streamFormats);\n \tStreamConfiguration cfg(formats);\n@@ -72,8 +103,14 @@ CameraConfiguration::Status RkISP1Path::validate(StreamConfiguration *cfg)\n \tconst StreamConfiguration reqCfg = *cfg;\n \tCameraConfiguration::Status status = CameraConfiguration::Valid;\n \n-\tif (std::find(formats_.begin(), formats_.end(), cfg->pixelFormat) ==\n-\t    formats_.end())\n+\t/*\n+\t * Default to NV12 if the requested format is not supported. All\n+\t * versions of the ISP are guaranteed to support NV12 on both the main\n+\t * and self paths.\n+\t */\n+\tif (std::find_if(streamFormats_.begin(), streamFormats_.end(),\n+\t\t\t [cfg](auto pair) { return pair.first == cfg->pixelFormat; }) ==\n+\t    streamFormats_.end())\n \t\tcfg->pixelFormat = formats::NV12;\n \n \tcfg->size.boundTo(maxResolution_);\n@@ -207,6 +244,8 @@ void RkISP1Path::stop()\n namespace {\n constexpr Size RKISP1_RSZ_MP_SRC_MIN{ 32, 16 };\n constexpr Size RKISP1_RSZ_MP_SRC_MAX{ 4416, 3312 };\n+\n+/* \\todo Remove this eventually. */\n constexpr std::array<PixelFormat, 6> RKISP1_RSZ_MP_FORMATS{\n \tformats::YUYV,\n \tformats::NV16,\n@@ -214,11 +253,12 @@ constexpr std::array<PixelFormat, 6> RKISP1_RSZ_MP_FORMATS{\n \tformats::NV21,\n \tformats::NV12,\n \tformats::R8,\n-\t/* \\todo Add support for RAW formats. */\n };\n \n constexpr Size RKISP1_RSZ_SP_SRC_MIN{ 32, 16 };\n constexpr Size RKISP1_RSZ_SP_SRC_MAX{ 1920, 1920 };\n+\n+/* \\todo Remove this eventually. */\n constexpr std::array<PixelFormat, 8> RKISP1_RSZ_SP_FORMATS{\n \tformats::YUYV,\n \tformats::NV16,\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex f3f1ae39..42db158f 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -57,11 +57,14 @@ public:\n \tSignal<FrameBuffer *> &bufferReady() { return video_->bufferReady; }\n \n private:\n+\tvoid populateFormats(std::unique_ptr<V4L2VideoDevice> &video);\n+\n \tstatic constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n \n \tconst char *name_;\n \tbool running_;\n \n+\tstd::map<PixelFormat, std::vector<SizeRange>> streamFormats_;\n \tconst Span<const PixelFormat> formats_;\n \tconst Size minResolution_;\n \tconst Size maxResolution_;\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v2"
    ]
}