Patch Detail
Show a patch.
GET /api/1.1/patches/18219/?format=api
{ "id": 18219, "url": "https://patchwork.libcamera.org/api/1.1/patches/18219/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18219/", "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": "<20230129135830.27490-3-jacopo.mondi@ideasonboard.com>", "date": "2023-01-29T13:58:27", "name": "[libcamera-devel,2/5] 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/18219/mbox/", "series": [ { "id": 3730, "url": "https://patchwork.libcamera.org/api/1.1/series/3730/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3730", "date": "2023-01-29T13:58:25", "name": "libcamera: imx8-isi: Remove pixelformat-2-media-bus map", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3730/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18219/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18219/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 2391DC3242\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 29 Jan 2023 13:58:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 33C54625F4;\n\tSun, 29 Jan 2023 14:58:51 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 092A2625DF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Jan 2023 14:58:48 +0100 (CET)", "from uno.localdomain (mob-5-90-54-203.net.vodafone.it\n\t[5.90.54.203])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7FC71327;\n\tSun, 29 Jan 2023 14:58:47 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675000731;\n\tbh=Ic1Qc2h2V7lJTV/2HtJOoshbChZberdBeIK9bUVQduM=;\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=vY1fb9ztZ8cw5yJCM+BvIF8e3FAhuXPMi0UR4DiOTarQuz6ABfMJ4Hl2x9JBtdleW\n\tqwZ1QCEDnU37wSPZAsPt9DfpcZqzYNkVeGg8XunYJE2lnUCJzZB+XjL6hj69fRiAZA\n\tFy9uWIH2KZ0VGBlhGJjZjdAysR6PdVdG4jCsF5VQWF7ag2Bivn108OTOFjsvZTRmTT\n\tSp1jKbtr+2PzHT0p92+UWIM28lBmC7yu7WPcDspO+Z37YooZGyj9CV1VhHax5gNcKG\n\tPp4wl0bwsNWcao4+6diajkL0fS7zjQe0a4Si3byP+GQg4j6pxJNc/r+ORowxq4TgGt\n\tZ3s33WadA5SfA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1675000727;\n\tbh=Ic1Qc2h2V7lJTV/2HtJOoshbChZberdBeIK9bUVQduM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XsXNWHoBMHIDdDC5JSCLmSNYDUX+DMiR4s6VKL0GEklM7ksgv+JkJtocGXmgUmZrY\n\tf//aNPbQJx4YR1rJRFyoR8LZnn/Rnl766N4UD5fcN27zLnwbH5bT/mwgE4gcnxTQYp\n\tzmzXnR8yP/AWRvNecIMzNyhsoTtsxJyRzeAjmXZo=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XsXNWHoB\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 29 Jan 2023 14:58:27 +0100", "Message-Id": "<20230129135830.27490-3-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.0", "In-Reply-To": "<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>", "References": "<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/5] 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>\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 72bc310d80ec..445fad32656c 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", "2/5" ] }