Show a patch.

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

{
    "id": 19076,
    "url": "https://patchwork.libcamera.org/api/patches/19076/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19076/",
    "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": "<20230921165550.50956-13-jacopo.mondi@ideasonboard.com>",
    "date": "2023-09-21T16:55:49",
    "name": "[libcamera-devel,v5,12/13] libcamera: rpi: Simplify validate() and configure() for YUV/RGB streams",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "40492a9573ae5da11fe3bb4c8abdcc40ad2cb2d7",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19076/mbox/",
    "series": [
        {
            "id": 4034,
            "url": "https://patchwork.libcamera.org/api/series/4034/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4034",
            "date": "2023-09-21T16:55:37",
            "name": "libcamera: Introduce SensorConfiguration",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/4034/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19076/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19076/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 EE4F2C32B3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Sep 2023 16:56:14 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9F17E6295D;\n\tThu, 21 Sep 2023 18:56:14 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4356662955\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Sep 2023 18:56:06 +0200 (CEST)",
            "from uno.lan (93-46-82-201.ip106.fastwebnet.it [93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A95FA2F6C;\n\tThu, 21 Sep 2023 18:54:28 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695315374;\n\tbh=0gh+wY8QM+2l9+M1e2z0LnVNAjVgWuednSnUxnRvaWE=;\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=dN91WR3lIfMfnQdBCKdZhKrdRm+iZ3LJw8uGK/LdjvjEwEPUjOG2ZjatU5T33kFEm\n\tpDq/8kyLLXvDpygUrflfDyMwXHkpyq1iqE9dTMm0REwAnOYi2fo58wiERBRTTUXPAs\n\tTQC62D4t5IMqa0BRmaWUP10mvTjnALVw/xIExeX2Ljal57u4UvfnNP/l+X+/HrJ4ry\n\t2XFZHxko8sWqczDLcHk5/0Ds9RK9SQsSMSQkEvRQWqZxiCBaFWNQDh5xF9b0fU9Keg\n\toWyM8It9u0+UJwKZ/q5kqo0CgsjpIIS4kF1k4DES6K06xrjM18zBI0u2cZr98oD+ha\n\t45F79T+QporgQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695315268;\n\tbh=0gh+wY8QM+2l9+M1e2z0LnVNAjVgWuednSnUxnRvaWE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=vkt9Xm9U2A16JGJ77fhXIGfY5eHDay1rDaFgx+xKDmviXkXayjOlNIDo6qySVSTmH\n\tFN+fkPp7bNhTUhc/2sKmod4m8m9P0p2SoAZh7iVqQTK31SesbVQ3+c86sN8025q2XW\n\tM/E4OxgBX2NzhN6e88GAW0xCXXkNvDuRrp9HDVvk="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"vkt9Xm9U\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 21 Sep 2023 18:55:49 +0200",
        "Message-ID": "<20230921165550.50956-13-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.42.0",
        "In-Reply-To": "<20230921165550.50956-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20230921165550.50956-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 12/13] libcamera: rpi: Simplify\n\tvalidate() and configure() for YUV/RGB streams",
        "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": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Naushir Patuck <naush@raspberrypi.com>\n\nThis commit simplifies the validate() and configure() calls in the\npipeline handler in a number of ways:\n\n- Determine the V4L2DeviceFormat structure fields for all streams\n  in validate(), cache them and reuse in configure() instead of\n  re-generating this structure multiple times.\n\n- Remove setting a default pixel format in validate(), this code patch\n  will not be used.\n\n- Use the recently added updateStreamConfig() and toV4L2DeviceFormat()\n  helpers to populate fields in the V4L2DeviceFormat and StreamConfiguration\n  structures to reduce code duplication.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 49 ++++---------------\n src/libcamera/pipeline/rpi/vc4/vc4.cpp        | 15 ++----\n 2 files changed, 12 insertions(+), 52 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex f8e8e13dc837..b19dad457e59 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -262,56 +262,25 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \n \t/* Further fixups on the ISP output streams. */\n \tfor (auto &out : outStreams_) {\n-\t\tStreamConfiguration &cfg = config_.at(out.index);\n-\t\tPixelFormat &cfgPixFmt = cfg.pixelFormat;\n-\t\tV4L2VideoDevice::Formats fmts = out.dev->formats();\n-\n-\t\tif (fmts.find(out.dev->toV4L2PixelFormat(cfgPixFmt)) == fmts.end()) {\n-\t\t\t/* If we cannot find a native format, use a default one. */\n-\t\t\tcfgPixFmt = formats::YUV420;\n-\t\t\tstatus = Adjusted;\n-\t\t}\n-\n-\t\tV4L2DeviceFormat format;\n-\t\tformat.fourcc = out.dev->toV4L2PixelFormat(cfg.pixelFormat);\n-\t\tformat.size = cfg.size;\n \n \t\t/*\n-\t\t * platformValidate may have worked out the correct stride so we\n-\t\t * must pass it in. This also needs the planesCount to be set\n-\t\t * correctly or the stride will be ignored.\n+\t\t * We want to send the associated YCbCr info through to the driver.\n+\t\t *\n+\t\t * But for RGB streams, the YCbCr info gets overwritten on the way back\n+\t\t * so we must check against what the stream cfg says, not what we actually\n+\t\t * requested (which carefully included the YCbCr info)!\n \t\t */\n-\t\tconst PixelFormat &pixFormat = format.fourcc.toPixelFormat();\n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFormat);\n-\t\tformat.planesCount = info.numPlanes();\n-\t\tformat.planes[0].bpl = cfg.stride;\n-\n-\t\t/* We want to send the associated YCbCr info through to the driver. */\n-\t\tformat.colorSpace = yuvColorSpace_;\n+\t\tout.format.colorSpace = yuvColorSpace_;\n \n \t\tLOG(RPI, Debug)\n-\t\t\t<< \"Try color space \" << ColorSpace::toString(cfg.colorSpace);\n+\t\t\t<< \"Try color space \" << ColorSpace::toString(out.cfg->colorSpace);\n \n-\t\tint ret = out.dev->tryFormat(&format);\n+\t\tint ret = out.dev->tryFormat(&out.format);\n \t\tif (ret)\n \t\t\treturn Invalid;\n \n-\t\t/*\n-\t\t * But for RGB streams, the YCbCr info gets overwritten on the way back\n-\t\t * so we must check against what the stream cfg says, not what we actually\n-\t\t * requested (which carefully included the YCbCr info)!\n-\t\t */\n-\t\tif (cfg.colorSpace != format.colorSpace) {\n+\t\tif (RPi::PipelineHandlerBase::updateStreamConfig(out.cfg, out.format))\n \t\t\tstatus = Adjusted;\n-\t\t\tLOG(RPI, Debug)\n-\t\t\t\t<< \"Color space changed from \"\n-\t\t\t\t<< ColorSpace::toString(cfg.colorSpace) << \" to \"\n-\t\t\t\t<< ColorSpace::toString(format.colorSpace);\n-\t\t}\n-\n-\t\tcfg.colorSpace = format.colorSpace;\n-\t\tcfg.stride = format.planes[0].bpl;\n-\t\tcfg.frameSize = format.planes[0].size;\n \t}\n \n \treturn status;\ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex 1a03c88d7ee3..a1813ba65725 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -457,6 +457,8 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig\n \t\t * have that fixed up in the code above.\n \t\t */\n \t\toutStreams[i].dev = isp_[i == 0 ? Isp::Output0 : Isp::Output1].dev();\n+\n+\t\toutStreams[i].format = RPi::PipelineHandlerBase::toV4L2DeviceFormat(outStreams[i].dev, outStreams[i].cfg);\n \t}\n \n \treturn status;\n@@ -549,11 +551,7 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi\n \n \t\t/* The largest resolution gets routed to the ISP Output 0 node. */\n \t\tRPi::Stream *stream = i == 0 ? &isp_[Isp::Output0] : &isp_[Isp::Output1];\n-\n-\t\tV4L2PixelFormat fourcc = stream->dev()->toV4L2PixelFormat(cfg->pixelFormat);\n-\t\tformat.size = cfg->size;\n-\t\tformat.fourcc = fourcc;\n-\t\tformat.colorSpace = cfg->colorSpace;\n+\t\tformat = outStreams[i].format;\n \n \t\tLOG(RPI, Debug) << \"Setting \" << stream->name() << \" to \"\n \t\t\t\t<< format;\n@@ -562,13 +560,6 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi\n \t\tif (ret)\n \t\t\treturn -EINVAL;\n \n-\t\tif (format.size != cfg->size || format.fourcc != fourcc) {\n-\t\t\tLOG(RPI, Error)\n-\t\t\t\t<< \"Failed to set requested format on \" << stream->name()\n-\t\t\t\t<< \", returned \" << format;\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n \t\tLOG(RPI, Debug)\n \t\t\t<< \"Stream \" << stream->name() << \" has color space \"\n \t\t\t<< ColorSpace::toString(cfg->colorSpace);\n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "12/13"
    ]
}