Show a patch.

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

{
    "id": 10660,
    "url": "https://patchwork.libcamera.org/api/patches/10660/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10660/",
    "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": "<20201213134251.7574-1-sebastian.fricke.linux@gmail.com>",
    "date": "2020-12-13T13:42:52",
    "name": "[libcamera-devel,v3] pipeline-rkisp1-Fix-sensor-ISP-format-mismatch",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "fc57272d0f5963120493302719fbcc9fe780bb05",
    "submitter": {
        "id": 73,
        "url": "https://patchwork.libcamera.org/api/people/73/?format=api",
        "name": "Sebastian Fricke",
        "email": "sebastian.fricke.linux@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10660/mbox/",
    "series": [
        {
            "id": 1532,
            "url": "https://patchwork.libcamera.org/api/series/1532/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1532",
            "date": "2020-12-13T13:42:52",
            "name": "[libcamera-devel,v3] pipeline-rkisp1-Fix-sensor-ISP-format-mismatch",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1532/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10660/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10660/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 EF282C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 13 Dec 2020 13:43:18 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 76E116033B;\n\tSun, 13 Dec 2020 14:43:18 +0100 (CET)",
            "from mail-wr1-x443.google.com (mail-wr1-x443.google.com\n\t[IPv6:2a00:1450:4864:20::443])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2133760322\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 13 Dec 2020 14:43:16 +0100 (CET)",
            "by mail-wr1-x443.google.com with SMTP id m5so13736754wrx.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 13 Dec 2020 05:43:16 -0800 (PST)",
            "from basti.fritz.box\n\t(p200300d1ff3f43008b35b1d5c468db1a.dip0.t-ipconnect.de.\n\t[2003:d1:ff3f:4300:8b35:b1d5:c468:db1a])\n\tby smtp.gmail.com with ESMTPSA id\n\th20sm28360705wrb.21.2020.12.13.05.43.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 13 Dec 2020 05:43:14 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"g/fqz48w\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=4M6iPsppgQfot7CHRP0EYYcM6J7H2HJ6x0eOj6CH1fo=;\n\tb=g/fqz48wN+TYgsDtcVva7pqVWhfBGdzWZSr/oW7HvmeNptcMjCur8Sc07SBLmsI7u3\n\tZlbKj9npysA24X0lVejnmND1W6b8xemrt0opNJghPSKTz/DoWnNgc2/V/T3fGLN6v0Jl\n\tnSOyOotpZLzQLENR9iFOZhZnR+4tfLdcEpEMzAvXksz991HyemBoreznWkMdF62A3obM\n\tM0ietvqsKB5t+LOoqv5G+skVLx1j/29msZIAd2IAESChXRKjDi2Sb4ekzxFaGWbR1C/r\n\tZjcDIYEIOgrEvJVJkdJ9KBA02yPYr0b3+ZmMAHSskWeaY5Ag8ImwLp2raPFBYVCn6bCK\n\tmUtQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=4M6iPsppgQfot7CHRP0EYYcM6J7H2HJ6x0eOj6CH1fo=;\n\tb=SHedRvPfBdeX1107Zh/6DGebbJC4jn73qDCObskS+Lnn6Nu0XZrk0MprL+CNnzhS0v\n\t0n/vsPdVrM2nLvGCnSFPLrq02RzJ27D+pPPp3qZU+jOE+b5TdQXIqeAg9iJHk12hZttJ\n\t315SKo+aU8usv/fi1NMWggBnqIn/dFbJF2ni25Bmv3/tw9dikbLdBNkoX5+tLVMx1w/q\n\twiPQCWd/iyXmb2s6vo12M1wxAjW9swaLNP/xiUGpEABuYWpFXgZ2PKvJC6jW19kDpQaS\n\taUcgpAsmn6VBx2tWBBNCxlX0Y4CK8uwZo9CF/Oblo7dqtmNYp1KyG+vCMG5sBFY2oAoi\n\tZdWA==",
        "X-Gm-Message-State": "AOAM533Tq4KRW+Y9odf4RbkQqaANWXZlDYAGb+3mZy6RMnxCNqwGB+yC\n\t5vAWAZQ3PlOsvhxQF0Cq0tAu6N8VbCs=",
        "X-Google-Smtp-Source": "ABdhPJzxwgmp3RzUXO7NsEjC7U2RyJ17p9Y2G9OGlmKHM0bW7XiKfr9D1ZWqwcJxmeIxctGfVEQn/Q==",
        "X-Received": "by 2002:adf:e541:: with SMTP id\n\tz1mr24034806wrm.143.1607866995326; \n\tSun, 13 Dec 2020 05:43:15 -0800 (PST)",
        "From": "Sebastian Fricke <sebastian.fricke.linux@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 13 Dec 2020 14:42:52 +0100",
        "Message-Id": "<20201213134251.7574-1-sebastian.fricke.linux@gmail.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3]\n\tpipeline-rkisp1-Fix-sensor-ISP-format-mismatch",
        "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>",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "This patch fixes a mismatch of image formats during the pipeline\ncreation of the RkISP1. The mismatch happens because the current code\ndoes not check if the configured format exceeds the maximum viable\nresolution of the ISP.\n\nMake sure to use a sensor format resolution that is smaller or equal to\nthe maximum allowed resolution for the RkISP1. The maximum resolution\nis defined within the `rkisp1-common.h` file as:\ndefine RKISP1_ISP_MAX_WIDTH        4032\ndefine RKISP1_ISP_MAX_HEIGHT        3024\n\nEnumerate the frame-sizes of the ISP entity and compare the maximum with\nthe configured resolution.\n\nThis means that some camera sensors can never operate with their maximum\nresolution, for example on my OV13850 camera sensor, there are two\npossible resolutions: 4224x3136 & 2112x1568, the first of those two will\nnever be picked as it surpasses the maximum of the ISP.\n\nSigned-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com>\n---\n\nAttention: This patch depends on the following patch for the Linux\nKernel media subsystem.\nhttps://patchwork.kernel.org/project/linux-media/patch/20201212185306.19135-1-sebastian.fricke.linux@gmail.com/\n\nv1: https://lists.libcamera.org/pipermail/libcamera-devel/2020-November/015113.html\nv2: https://lists.libcamera.org/pipermail/libcamera-devel/2020-November/015136.html\n\nChangelog:\n\nChanges since v2:\n\n* Replace the act of attempting to set the ISP format before negotiating\n  the actual format for both the ISP input pad and the sensor in order\n  to get the maximum frame size. With a logic that involves enumerating\n  the maximum size directly from the subdevice and using that size for\n  the negotiation process.\n* Improve the log messages\n\nChanges since v1:\n\n* Change snake_case variable names to camelCase\n* Use the request comment style\n* Correct the scope of the newly implemented variables\n* Correct the subject of the debug log for the ISP format configuration\n* Update the comment above the ISP format configuration\n* Check if the original format is not equal to the configured ISP format\n  instead of checking if it is greater, this denies a false positive\n  where the height exceeds the maximum while the width is smaller.\n  If the configured format does not exceed the maximum resolution of the\n  ISP, it will stay untouched so the inequality always means that we\n  have to reconfigure the format.\n* Adjust the comparison of the ISP format size with the available sensor\n  formats, to detect a false-positive were the width is smaller while\n  the height exceeds the maximum\n* Use the standard function `max`\n\n-----\n\nThe following tests were all able to create a working camera pipeline:\n1. Without stream configuration\n2. With a normal stream configuration\n3. With a stream configuration that exceeds the maximum of the ISP\n4. With a very small resolution stream configuration\n5. With a configuration that is closer to the upper than to the lower\nresolution\n\n-----\n\n1. LIBCAMERA_LOG_LEVELS=0 cam -c 1 --capture=3\n\n[7:56:14.564557994] [9200] DEBUG Camera camera.cpp:831 streams configuration: (0) 1920x1920-NV12\n[7:56:14.565294449] [9200]  INFO Camera camera.cpp:890 configuring streams: (0) 1920x1920-NV12\n...\n[7:56:14.567584898] [9201]  INFO RkISP1 rkisp1.cpp:689 Sensor format 4224x3136 is not supported by the ISP (maximum: 4032x3024), trying to re-configure to a smaller sensor format\n[7:56:14.567738605] [9201] DEBUG RkISP1 rkisp1.cpp:713 Sensor configured with 2112x1568-SBGGR10_1X10\n[7:56:14.567941896] [9201] DEBUG RkISP1 rkisp1.cpp:724 ISP input pad configured with 2112x1568-SBGGR10_1X10 crop (0x0)/2112x1568\n[7:56:14.568196812] [9201] DEBUG RkISP1 rkisp1.cpp:730 Configuring ISP output pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:56:14.568360144] [9201] DEBUG RkISP1 rkisp1.cpp:742 ISP output pad configured with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:56:14.568529602] [9201] DEBUG RkISP1 rkisp1_path.cpp:119 Configured main resizer input pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:56:14.568647435] [9201] DEBUG RkISP1 rkisp1_path.cpp:125 Configuring main resizer output pad with 1920x1920-YUYV8_2X8\n[7:56:14.568762351] [9201] DEBUG RkISP1 rkisp1_path.cpp:143 Configured main resizer output pad with 1920x1920-YUYV8_1_5X8\n\n2. LIBCAMERA_LOG_LEVELS=0 cam -c 1 --capture=3 -s width=900,height=600,pixelformat=NV12,role=video\n\n[7:57:58.012056371] [9204] DEBUG Camera camera.cpp:831 streams configuration: (0) 1920x1920-NV12\n[7:57:58.012524202] [9204]  INFO Camera camera.cpp:890 configuring streams: (0) 900x600-NV12\n...\n[7:57:58.014565860] [9205] DEBUG RkISP1 rkisp1.cpp:713 Sensor configured with 2112x1568-SBGGR10_1X10\n[7:57:58.014776442] [9205] DEBUG RkISP1 rkisp1.cpp:724 ISP input pad configured with 2112x1568-SBGGR10_1X10 crop (0x0)/2112x1568\n[7:57:58.014913816] [9205] DEBUG RkISP1 rkisp1.cpp:730 Configuring ISP output pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:57:58.015064607] [9205] DEBUG RkISP1 rkisp1.cpp:742 ISP output pad configured with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:57:58.015230273] [9205] DEBUG RkISP1 rkisp1_path.cpp:119 Configured main resizer input pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:57:58.015348689] [9205] DEBUG RkISP1 rkisp1_path.cpp:125 Configuring main resizer output pad with 900x600-YUYV8_2X8\n[7:57:58.015463314] [9205] DEBUG RkISP1 rkisp1_path.cpp:143 Configured main resizer output pad with 900x600-YUYV8_1_5X8\n\n3. LIBCAMERA_LOG_LEVELS=0 cam -c 1 --capture=3 -s width=4500,height=3500,pixelformat=NV12,role=video\n\n[7:59:52.764968202] [9210] DEBUG Camera camera.cpp:831 streams configuration: (0) 1920x1920-NV12\n[7:59:52.765415033] [9210] DEBUG RkISP1 rkisp1_path.cpp:94 Adjusting format from 4500x3500-NV12 to 4416x3312-NV12\n[7:59:52.765671115] [9210] DEBUG RkISP1 rkisp1_path.cpp:94 Adjusting format from 4500x3500-NV12 to 1920x1920-NV12\n[7:59:52.765905613] [9210] DEBUG RkISP1 rkisp1_path.cpp:94 Adjusting format from 4500x3500-NV12 to 4416x3312-NV12\n[7:59:52.766147987] [9210] DEBUG CameraSensor camera_sensor.cpp:436 'ov13850 1-0010': No supported format or size found\nCamera configuration adjusted\n[7:59:52.766558943] [9210] DEBUG CameraSensor camera_sensor.cpp:436 'ov13850 1-0010': No supported format or size found\n[7:59:52.766702151] [9210]  INFO Camera camera.cpp:890 configuring streams: (0) 4416x3312-NV12\n...\n[7:59:52.768968097] [9211]  INFO RkISP1 rkisp1.cpp:689 Sensor format 4224x3136 is not supported by the ISP (maximum: 4032x3024), trying to re-configure to a smaller sensor format\n[7:59:52.769120347] [9211] DEBUG RkISP1 rkisp1.cpp:713 Sensor configured with 2112x1568-SBGGR10_1X10\n[7:59:52.769320721] [9211] DEBUG RkISP1 rkisp1.cpp:724 ISP input pad configured with 2112x1568-SBGGR10_1X10 crop (0x0)/2112x1568\n[7:59:52.769455762] [9211] DEBUG RkISP1 rkisp1.cpp:730 Configuring ISP output pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:59:52.769606552] [9211] DEBUG RkISP1 rkisp1.cpp:742 ISP output pad configured with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:59:52.769771927] [9211] DEBUG RkISP1 rkisp1_path.cpp:119 Configured main resizer input pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[7:59:52.769888301] [9211] DEBUG RkISP1 rkisp1_path.cpp:125 Configuring main resizer output pad with 4416x3312-YUYV8_2X8\n[7:59:52.770003217] [9211] DEBUG RkISP1 rkisp1_path.cpp:143 Configured main resizer output pad with 4416x3312-YUYV8_1_5X8\n\n4. LIBCAMERA_LOG_LEVELS=0 cam -c 1 --capture=3 -s width=40,height=30,pixelformat=NV12,role=video\n\n[8:03:00.496627233] [9218] DEBUG Camera camera.cpp:831 streams configuration: (0) 1920x1920-NV12\n[8:03:00.497419103] [9218]  INFO Camera camera.cpp:890 configuring streams: (0) 40x30-NV12\n...\n[8:03:00.499715966] [9219] DEBUG RkISP1 rkisp1.cpp:713 Sensor configured with 2112x1568-SBGGR10_1X10\n[8:03:00.499924215] [9219] DEBUG RkISP1 rkisp1.cpp:724 ISP input pad configured with 2112x1568-SBGGR10_1X10 crop (0x0)/2112x1568\n[8:03:00.500168047] [9219] DEBUG RkISP1 rkisp1.cpp:730 Configuring ISP output pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[8:03:00.500336630] [9219] DEBUG RkISP1 rkisp1.cpp:742 ISP output pad configured with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[8:03:00.500513087] [9219] DEBUG RkISP1 rkisp1_path.cpp:119 Configured main resizer input pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[8:03:00.500632962] [9219] DEBUG RkISP1 rkisp1_path.cpp:125 Configuring main resizer output pad with 40x30-YUYV8_2X8\n[8:03:00.500745836] [9219] DEBUG RkISP1 rkisp1_path.cpp:143 Configured main resizer output pad with 40x30-YUYV8_1_5X8\n\n5. LIBCAMERA_LOG_LEVELS=0 cam -c 1 --capture=3 -s width=3450,height=2456,pixelformat=NV12,role=video\n\n[8:01:23.689086810] [9215] DEBUG Camera camera.cpp:831 streams configuration: (0) 1920x1920-NV12\n[8:01:23.689893848] [9215]  INFO Camera camera.cpp:890 configuring streams: (0) 3450x2456-NV12\n...\n[8:01:23.692257211] [9216]  INFO RkISP1 rkisp1.cpp:689 Sensor format 4224x3136 is not supported by the ISP (maximum: 4032x3024), trying to re-configure to a smaller sensor format\n[8:01:23.692415876] [9216] DEBUG RkISP1 rkisp1.cpp:713 Sensor configured with 2112x1568-SBGGR10_1X10\n[8:01:23.692615084] [9216] DEBUG RkISP1 rkisp1.cpp:724 ISP input pad configured with 2112x1568-SBGGR10_1X10 crop (0x0)/2112x1568\n[8:01:23.692753041] [9216] DEBUG RkISP1 rkisp1.cpp:730 Configuring ISP output pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[8:01:23.692901499] [9216] DEBUG RkISP1 rkisp1.cpp:742 ISP output pad configured with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[8:01:23.693066581] [9216] DEBUG RkISP1 rkisp1_path.cpp:119 Configured main resizer input pad with 2112x1568-YUYV8_2X8 crop (0x0)/2112x1568\n[8:01:23.693183831] [9216] DEBUG RkISP1 rkisp1_path.cpp:125 Configuring main resizer output pad with 3450x2456-YUYV8_2X8\n[8:01:23.693297289] [9216] DEBUG RkISP1 rkisp1_path.cpp:143 Configured main resizer output pad with 3450x2456-YUYV8_1_5X8\n\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 34 +++++++++++++++++++++++-\n 1 file changed, 33 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 4d98c902..d6fc624c 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -667,12 +667,44 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \tif (ret)\n \t\treturn ret;\n \n+\tV4L2Subdevice::Formats ispFormats = isp_->formats(0);\n+\tif (ispFormats.empty())\n+\t\treturn -1;\n+\n+\t/*\n+\t * The maximum resolution is identical for all media bus codes on\n+\t * the RkISP1 isp entity. Therefore take the first available resolution.\n+\t */\n+\tSize ispMaximum = ispFormats.begin()->second[0].max;\n+\n \t/*\n \t * Configure the format on the sensor output and propagate it through\n \t * the pipeline.\n \t */\n \tV4L2SubdeviceFormat format = config->sensorFormat();\n-\tLOG(RkISP1, Debug) << \"Configuring sensor with \" << format.toString();\n+\n+\tif (ispMaximum.width < format.size.width ||\n+\t    ispMaximum.height < format.size.height) {\n+\t\tSize maxSize;\n+\t\tLOG(RkISP1, Info) << \"Sensor format \" << format.size.toString()\n+\t\t\t\t  << \" is not supported by the ISP (maximum: \"\n+\t\t\t\t  << ispMaximum.toString() << \"), trying to \"\n+\t\t\t\t  << \"re-configure to a smaller sensor format\";\n+\n+\t\tfor (const Size &size : sensor->sizes()) {\n+\t\t\tif (size.width > ispMaximum.width ||\n+\t\t\t    size.height > ispMaximum.height)\n+\t\t\t\tcontinue;\n+\t\t\tmaxSize = std::max(maxSize, size);\n+\t\t}\n+\t\tif (maxSize == Size(0, 0)) {\n+\t\t\tLOG(RkISP1, Error) << \"No available sensor resolution\"\n+\t\t\t\t\t      \"that is smaller or equal to \"\n+\t\t\t\t\t   << format.toString();\n+\t\t\treturn -1;\n+\t\t}\n+\t\tformat.size = maxSize;\n+\t}\n \n \tret = sensor->setFormat(&format);\n \tif (ret < 0)\n",
    "prefixes": [
        "libcamera-devel",
        "v3"
    ]
}