Show a patch.

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

{
    "id": 17857,
    "url": "https://patchwork.libcamera.org/api/patches/17857/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17857/",
    "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": "<20221124025133.17875-7-laurent.pinchart@ideasonboard.com>",
    "date": "2022-11-24T02:51:30",
    "name": "[libcamera-devel,v4,6/9] pipeline: rkisp1: Query the driver for formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a4919e52d76efe44268afcce85056b639a8964f9",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17857/mbox/",
    "series": [
        {
            "id": 3634,
            "url": "https://patchwork.libcamera.org/api/series/3634/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3634",
            "date": "2022-11-24T02:51:24",
            "name": "Add Bayer format support for RkISP1",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3634/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17857/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17857/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 3A1B3C3286\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 02:52:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EE6A263328;\n\tThu, 24 Nov 2022 03:52:00 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7CEA96331D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 03:51:58 +0100 (CET)",
            "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 04DCC7FA;\n\tThu, 24 Nov 2022 03:51:57 +0100 (CET)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669258321;\n\tbh=vbZrXKcEm2GXr2rsjpJpTqeKEP7JchVUjp/cZ0lgleg=;\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:\n\tFrom;\n\tb=FcAZRNzVq+AnKekbd/52JWXU6ey2vVlwY2rUYHimA9uIuD784QFKlyO0B3+iIQI+K\n\tOMFe6TTXTm/v83Ahb7kbOR1Vny1ARCOrwbYG5WgHxNdY9B2aZGxGwYbRThg98WDuzk\n\t+F/64d10uG+/lKv7inIWzicuBozkolK+bkEfTrYuMGZ+X/dJf5PUzgTG3L0VNd8DJU\n\tgwm78pGTfHjoiK7fjaUuoY8yVcfN10y1BdTAqNq0uIy0gRA5HyFShPorU4WNqrg+iJ\n\t0i1MmluDchwEZ7NEMC27gSx2N4KxQ0u6SgdvqdsR3S2K0fxBTbB9CJg+cCJE7V1l6q\n\tInW5EKYuUXtXg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669258318;\n\tbh=vbZrXKcEm2GXr2rsjpJpTqeKEP7JchVUjp/cZ0lgleg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=UbuAcE8OG6OU+RMYsn0X4AQQ4qJvxiquWurytQASFriAqo/zLG5sni/4lHu+j+QBR\n\txtyuZQzfncnat79SrsOKYxyAd2d8EJYMIDYYgz52pl3xOPlHqrfQUqyKu5dV88C8AP\n\t7HrleVYQBzTYel8Q39dLVWmOYbHc92gNUyniKoCI="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"UbuAcE8O\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 24 Nov 2022 04:51:30 +0200",
        "Message-Id": "<20221124025133.17875-7-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.37.4",
        "In-Reply-To": "<20221124025133.17875-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20221124025133.17875-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 6/9] 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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Paul Elder <paul.elder@ideasonboard.com>\n\nQuery the driver for the output formats and sizes that it supports,\ninstead of hardcoding them. This allows future-proofing for formats that\nare supported by some but not 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>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v3:\n\n- Demote Warning message to Info and rewrite it\n\nChanges since v2:\n\n- Don't pass V4L2VideoDevice to RkISP1Path::populateFormats()\n- Use structured binding in for range loop\n- Use std::set::count() to replace std::find_if()\n- Don't cache sizes, use std::set instead of std::map\n- Update min and max resolutions based on enumerated sizes\n- Drop comment about aspect ratio\n\nChanges since v1:\n\n- Enumerate and cache framesizes as well\n- Massage generateConfiguration accordingly\n- This lets us skip modifying V4L2VideoDevice::formats() to support lack\n  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 | 51 +++++++++++++++++--\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  8 ++-\n 2 files changed, 54 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 2d38f0fb37ab..7a2b0d172d84 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();\n+\n \tlink_ = media->link(\"rkisp1_isp\", 2, resizer, 0);\n \tif (!link_)\n \t\treturn false;\n@@ -48,6 +50,41 @@ bool RkISP1Path::init(MediaDevice *media)\n \treturn true;\n }\n \n+void RkISP1Path::populateFormats()\n+{\n+\tV4L2VideoDevice::Formats v4l2Formats = video_->formats();\n+\tif (v4l2Formats.empty()) {\n+\t\tLOG(RkISP1, Info)\n+\t\t\t<< \"Failed to enumerate supported formats and sizes, using defaults\";\n+\n+\t\tfor (const PixelFormat &format : formats_)\n+\t\t\tstreamFormats_.insert(format);\n+\t\treturn;\n+\t}\n+\n+\tminResolution_ = { 65535, 65535 };\n+\tmaxResolution_ = { 0, 0 };\n+\n+\tstd::vector<PixelFormat> formats;\n+\tfor (const auto &[format, sizes] : v4l2Formats) {\n+\t\tconst PixelFormat pixelFormat = format.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_.insert(pixelFormat);\n+\n+\t\tfor (const auto &size : sizes) {\n+\t\t\tif (minResolution_ > size.min)\n+\t\t\t\tminResolution_ = size.min;\n+\t\t\tif (maxResolution_ < size.max)\n+\t\t\t\tmaxResolution_ = size.max;\n+\t\t}\n+\t}\n+}\n+\n StreamConfiguration RkISP1Path::generateConfiguration(const Size &resolution)\n {\n \tSize maxResolution = maxResolution_.boundedToAspectRatio(resolution)\n@@ -55,7 +92,7 @@ StreamConfiguration RkISP1Path::generateConfiguration(const Size &resolution)\n \tSize minResolution = minResolution_.expandedToAspectRatio(resolution);\n \n \tstd::map<PixelFormat, std::vector<SizeRange>> streamFormats;\n-\tfor (const PixelFormat &format : formats_)\n+\tfor (const auto &format : streamFormats_)\n \t\tstreamFormats[format] = { { minResolution, maxResolution } };\n \n \tStreamFormats formats(streamFormats);\n@@ -72,8 +109,12 @@ 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 (!streamFormats_.count(cfg->pixelFormat))\n \t\tcfg->pixelFormat = formats::NV12;\n \n \tcfg->size.boundTo(maxResolution_);\n@@ -204,6 +245,10 @@ void RkISP1Path::stop()\n \trunning_ = false;\n }\n \n+/*\n+ * \\todo Remove the hardcoded resolutions and formats once all users will have\n+ * migrated to a recent enough kernel.\n+ */\n namespace {\n constexpr Size RKISP1_RSZ_MP_SRC_MIN{ 32, 16 };\n constexpr Size RKISP1_RSZ_MP_SRC_MAX{ 4416, 3312 };\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex f3f1ae391d65..d88effbb6f56 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <memory>\n+#include <set>\n #include <vector>\n \n #include <libcamera/base/signal.h>\n@@ -57,14 +58,17 @@ public:\n \tSignal<FrameBuffer *> &bufferReady() { return video_->bufferReady; }\n \n private:\n+\tvoid populateFormats();\n+\n \tstatic constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n \n \tconst char *name_;\n \tbool running_;\n \n \tconst Span<const PixelFormat> formats_;\n-\tconst Size minResolution_;\n-\tconst Size maxResolution_;\n+\tstd::set<PixelFormat> streamFormats_;\n+\tSize minResolution_;\n+\tSize maxResolution_;\n \n \tstd::unique_ptr<V4L2Subdevice> resizer_;\n \tstd::unique_ptr<V4L2VideoDevice> video_;\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "6/9"
    ]
}