Patch Detail
Show a patch.
GET /api/1.1/patches/18385/?format=api
{ "id": 18385, "url": "https://patchwork.libcamera.org/api/1.1/patches/18385/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18385/", "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": "<20230313091944.9530-3-jacopo.mondi@ideasonboard.com>", "date": "2023-03-13T09:19:40", "name": "[libcamera-devel,v2,2/6] libcamera: imx8-isi: Break out YUV format selection", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "b41b2fdb15bbddb527d290f379127dadd1e78931", "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/18385/mbox/", "series": [ { "id": 3803, "url": "https://patchwork.libcamera.org/api/1.1/series/3803/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3803", "date": "2023-03-13T09:19:38", "name": "libcamera: imx8-isi: Remove pixelformat-2-media-bus map", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3803/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18385/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18385/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 7AC21BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Mar 2023 09:20:08 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 279826270B;\n\tMon, 13 Mar 2023 10:20:05 +0100 (CET)", "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 1BB0E62707\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Mar 2023 10:20:03 +0100 (CET)", "from uno.homenet.telecomitalia.it\n\t(host-79-33-55-183.retail.telecomitalia.it [79.33.55.183])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 40A7D563;\n\tMon, 13 Mar 2023 10:20:02 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678699205;\n\tbh=fnk8FXPK22xua3Le8vS/sLAF9iAKZiM3KrwNi1CY3Ks=;\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=aQ2TNQHyoD1THLiUxtRKNY8J2f68tGS20oK56QczXhZdQe2fpYEWg/ZyIPZB/VmAa\n\tOaaI/Itl2MCGUpeWD+RzLFqKUaSeEdE+H+TaW9y+ozMw1O11J0zbejwVPQv8hQoEs3\n\t0CTIx6aWMhDW/oAaExCHakIqtdJyQmyZ1B7VRcp6KpNsG9TnGRjUbXSbDz0vpy1o/9\n\tDekl+N7mIzW+t5o+2wSBwO9kvbA+jUc1m02b8A7z9F0URxGRLQxboEPASmzY2HuHk8\n\t0cft4a8uH6788IXj9yhsDqupa5uUG4sAl1bv6dYkwwXL2lmlo2qpcrkRqYUjIqmki0\n\tPZgyuOj3eSkNQ==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1678699202;\n\tbh=fnk8FXPK22xua3Le8vS/sLAF9iAKZiM3KrwNi1CY3Ks=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gkx8sR9ebh0va2eKJodQtr8U6J8NoHbiP/N9zYYs/jZUJVh99YPaeKYCh8rt8zjtb\n\tLtzGGFgei5mww8kiRV8ec0vrSn4pHIOyDCSkOl9k+YJf/R73OPqGnFUlxIRgj7RE3R\n\t1cw4LEAUVoWkWaVcSJ4Gv2eoi5tMVrj1JllNd2xw=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"gkx8sR9e\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 13 Mar 2023 10:19:40 +0100", "Message-Id": "<20230313091944.9530-3-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.0", "In-Reply-To": "<20230313091944.9530-1-jacopo.mondi@ideasonboard.com>", "References": "<20230313091944.9530-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 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 | 76 ++++++++++++++++++++\n 1 file changed, 76 insertions(+)", "diff": "diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex ffb96e6284f0..390e82b6947f 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(PixelFormat *pixelFormat) const;\n \n \tstd::unique_ptr<CameraSensor> sensor_;\n \tstd::unique_ptr<V4L2Subdevice> csis_;\n@@ -255,6 +256,65 @@ 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(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+\t\t*pixelFormat = {};\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@@ -455,6 +515,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", "v2", "2/6" ] }