Show a patch.

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

{
    "id": 18568,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18568/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18568/",
    "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": "<20230427144740.64075-3-jacopo.mondi@ideasonboard.com>",
    "date": "2023-04-27T14:47:36",
    "name": "[libcamera-devel,v3,2/6] libcamera: imx8-isi: Break out YUV format selection",
    "commit_ref": "dd78f2f8add6ad284183e73b4e1eee0f35bd76ba",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b3a610a26292cd501ac9a3f2d1776cdd9cc1bf54",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18568/mbox/",
    "series": [
        {
            "id": 3852,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3852/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3852",
            "date": "2023-04-27T14:47:34",
            "name": "libcamera: imx8-isi: Remove pixelformat-2-media-bus map",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3852/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18568/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18568/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 CA580C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 Apr 2023 14:48:04 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BF7B7627E5;\n\tThu, 27 Apr 2023 16:48:03 +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 CFB3D627E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Apr 2023 16:47:59 +0200 (CEST)",
            "from uno.lan (unknown\n\t[IPv6:2001:b07:5d2e:52c9:1cf0:b3bc:c785:4625])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6BA03802;\n\tThu, 27 Apr 2023 16:47:47 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1682606883;\n\tbh=u4yhRYsQGr3RW1k3tBHwyYwm5pcIqohWWED5ANd4P9M=;\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=ij/WXMutXDBqTWexCjObxCbHknwf8QBs3+UHuOlJLw0LIORQwWs2KB+UAvuMRHTVv\n\tFHh7Oc5dX9EzgltsDlo1xE65ekqf9gGmm8cXGEup7lgs6N+7UthS2DmvkzYNukZ0Cu\n\tHgmrZDxeVH+R04WvJXGE2IdGuiGKDv7OOngLN8Inh9Xm/t4gbe75yFD8rpFGnTeDHK\n\tvWeRhG4bJKs+f6jz+Xyb72YZ1M+9Gelj0wRlnYIzftRNmJfThQKLG3fRaBmFJcyLCy\n\tze2dSj+Szxy7+8kpLTHRNtvWif4FR5VGc77gm5cME3c426gBwl50DBbtiGFR68iwq+\n\tuDnfPIaIITfsA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1682606867;\n\tbh=u4yhRYsQGr3RW1k3tBHwyYwm5pcIqohWWED5ANd4P9M=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=oT2846KNYoG+ZXRFKaccjsGvc7vnoBHtzh0jHdfH3Qnracp+H2RnGU2YoT8eEEapS\n\tEJddwA9QXBzlKUuRncSXrXrhX6zVnZlvVm3b2Op2lugr47OxbDe3jNU4uofsKU3inJ\n\t9XMCB5VdXaM6FmyVhhSEUC6gTwxJl4VF2d95dYCM="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"oT2846KN\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 27 Apr 2023 16:47:36 +0200",
        "Message-Id": "<20230427144740.64075-3-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.40.0",
        "In-Reply-To": "<20230427144740.64075-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20230427144740.64075-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 2/6] libcamera: imx8-isi: Break out YUV\n\tformat selection",
        "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": "As per the RAW format selection, the media bus format selection\nprocedure relies on the direct association of PixelFormat and media\nbus code in the formatsMap_ map.\n\nAs the ISI can generate YUV and RGB formats from any non-Bayer media\nbus format, break out the YUV/RGB media bus format selection to a\nseparate function.\n\nThe newly introduced getYuvMediaBusFormat() tests a list of\nknown-supported media bus formats against the list of media bus\nformats supported by the sensor and tries to prefer media bus\ncodes with the same encoding as the requested PixelFormat.\n\nUse the newly introduced function in\nISICameraConfiguration::validateYuv() to make sure the sensor can\nproduce a YUV/RGB media bus format.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\nTested-by: Daniel Scally <dan.scally@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 75 ++++++++++++++++++++\n 1 file changed, 75 insertions(+)",
    "diff": "diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex d124f1cc96d3..148f108d630f 100644\n--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n@@ -60,6 +60,7 @@ public:\n \t}\n \n \tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n+\tunsigned int getYuvMediaBusFormat(const PixelFormat &pixelFormat) const;\n \n \tstd::unique_ptr<CameraSensor> sensor_;\n \tstd::unique_ptr<V4L2Subdevice> csis_;\n@@ -259,6 +260,64 @@ unsigned int ISICameraData::getRawMediaBusFormat(PixelFormat *pixelFormat) const\n \treturn sensorCode;\n }\n \n+/*\n+ * Get a YUV/RGB media bus format from which the ISI can produce a processed\n+ * stream, preferring codes with the same colour encoding as the requested\n+ * pixelformat.\n+ *\n+ * If the sensor does not provide any YUV/RGB media bus format the ISI cannot\n+ * generate any processed pixel format as it cannot debayer.\n+ */\n+unsigned int ISICameraData::getYuvMediaBusFormat(const PixelFormat &pixelFormat) const\n+{\n+\tstd::vector<unsigned int> mbusCodes = sensor_->mbusCodes();\n+\n+\t/*\n+\t * The ISI can produce YUV/RGB pixel formats from any non-RAW Bayer\n+\t * media bus formats.\n+\t *\n+\t * Keep the list in sync with the mxc_isi_bus_formats[] array in\n+\t * the ISI driver.\n+\t */\n+\tstd::vector<unsigned int> yuvCodes = {\n+\t\tMEDIA_BUS_FMT_UYVY8_1X16,\n+\t\tMEDIA_BUS_FMT_YUV8_1X24,\n+\t\tMEDIA_BUS_FMT_RGB565_1X16,\n+\t\tMEDIA_BUS_FMT_RGB888_1X24,\n+\t};\n+\n+\tstd::sort(mbusCodes.begin(), mbusCodes.end());\n+\tstd::sort(yuvCodes.begin(), yuvCodes.end());\n+\n+\tstd::vector<unsigned int> supportedCodes;\n+\tstd::set_intersection(mbusCodes.begin(), mbusCodes.end(),\n+\t\t\t      yuvCodes.begin(), yuvCodes.end(),\n+\t\t\t      std::back_inserter(supportedCodes));\n+\n+\tif (supportedCodes.empty()) {\n+\t\tLOG(ISI, Warning) << \"Cannot find a supported YUV/RGB format\";\n+\n+\t\treturn 0;\n+\t}\n+\n+\t/* Prefer codes with the same encoding as the requested pixel format. */\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat);\n+\tfor (unsigned int code : supportedCodes) {\n+\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingYUV &&\n+\t\t    (code == MEDIA_BUS_FMT_UYVY8_1X16 ||\n+\t\t     code == MEDIA_BUS_FMT_YUV8_1X24))\n+\t\t\treturn code;\n+\n+\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRGB &&\n+\t\t    (code == MEDIA_BUS_FMT_RGB565_1X16 ||\n+\t\t     code == MEDIA_BUS_FMT_RGB888_1X24))\n+\t\t\treturn code;\n+\t}\n+\n+\t/* Otherwise return the first found code. */\n+\treturn supportedCodes[0];\n+}\n+\n /* -----------------------------------------------------------------------------\n  * Camera Configuration\n  */\n@@ -459,6 +518,22 @@ ISICameraConfiguration::validateYuv(std::set<Stream *> &availableStreams,\n {\n \tCameraConfiguration::Status status = Valid;\n \n+\tStreamConfiguration &yuvConfig = config_[0];\n+\tPixelFormat yuvPixelFormat = yuvConfig.pixelFormat;\n+\n+\t/*\n+\t * Make sure the sensor can produce a compatible YUV/RGB media bus\n+\t * format. If the sensor can only produce RAW Bayer we can only fail\n+\t * here as we can't adjust to anything but RAW.\n+\t */\n+\tunsigned int yuvMediaBusCode = data_->getYuvMediaBusFormat(yuvPixelFormat);\n+\tif (!yuvMediaBusCode) {\n+\t\tLOG(ISI, Error) << \"Cannot adjust pixelformat \"\n+\t\t\t\t<< yuvConfig.pixelFormat;\n+\t\treturn Invalid;\n+\t}\n+\n+\t/* Adjust all the other streams. */\n \tfor (const auto &[i, cfg] : utils::enumerate(config_)) {\n \n \t\tLOG(ISI, Debug) << \"Stream \" << i << \": \" << cfg.toString();\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "2/6"
    ]
}