Show a patch.

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

{
    "id": 19886,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19886/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19886/",
    "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": "<20240416091357.211951-17-mzamazal@redhat.com>",
    "date": "2024-04-16T09:13:52",
    "name": "[v8,16/18] libcamera: debayer_cpu: Add BGR888 output support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "9233e8dab985ff2a8230760b3598f0345f04aa50",
    "submitter": {
        "id": 177,
        "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api",
        "name": "Milan Zamazal",
        "email": "mzamazal@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19886/mbox/",
    "series": [
        {
            "id": 4257,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4257/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4257",
            "date": "2024-04-16T09:13:36",
            "name": "libcamera: introduce Software ISP and Software IPA",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/4257/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19886/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19886/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 82006C3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Apr 2024 09:15:20 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 14C0863375;\n\tTue, 16 Apr 2024 11:15:20 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EF36863379\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2024 11:15:10 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-303-b89kLcdrOBOkChhQsVAQaw-1; Tue, 16 Apr 2024 05:15:03 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id CAFF88DED83;\n\tTue, 16 Apr 2024 09:15:02 +0000 (UTC)",
            "from nuthatch.redhat.com (unknown [10.45.225.245])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D3EEF2026964;\n\tTue, 16 Apr 2024 09:15:00 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"KDtBS74Y\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1713258910;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=IQcfL8E/HIDLkIRhxudsYfaEZlPDP2lnst6zQK1e8q8=;\n\tb=KDtBS74YR6SMbIMvIMo/iu6t4aW7md9pTcvcS4H0rpLPpMO6r6BMSlhQ10jSnRF8PIzgdJ\n\taIThfII2vB1+AHBCRLzVzNkX6JFnVBw9xw2oM2hmXYNPdaWMirwTy7ERL810QpIe66GI+8\n\tH20Pp1/JMkS8waG6kAZnkZrh6ZhpKE8=",
        "X-MC-Unique": "b89kLcdrOBOkChhQsVAQaw-1",
        "From": "Milan Zamazal <mzamazal@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Hans de Goede <hdegoede@redhat.com>, Milan Zamazal <mzamazal@redhat.com>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMaxime Ripard <mripard@redhat.com>, Pavel Machek <pavel@ucw.cz>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH v8 16/18] libcamera: debayer_cpu: Add BGR888 output support",
        "Date": "Tue, 16 Apr 2024 11:13:52 +0200",
        "Message-ID": "<20240416091357.211951-17-mzamazal@redhat.com>",
        "In-Reply-To": "<20240416091357.211951-1-mzamazal@redhat.com>",
        "References": "<20240416091357.211951-1-mzamazal@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.4",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Hans de Goede <hdegoede@redhat.com>\n\nBGR888 is RGB888 with the red and blue pixels swapped, adjust\nthe debayering to swap the red and blue pixels in the bayer pattern\nto add support for writing formats::BGR888.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/libcamera/software_isp/debayer_cpu.cpp | 50 ++++++++++++++++++----\n src/libcamera/software_isp/debayer_cpu.h   |  1 +\n 2 files changed, 43 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 82163458..5b553162 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -281,7 +281,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf\n \t\tconfig.bpp = (bayerFormat.bitDepth + 7) & ~7;\n \t\tconfig.patternSize.width = 2;\n \t\tconfig.patternSize.height = 2;\n-\t\tconfig.outputFormats = std::vector<PixelFormat>({ formats::RGB888 });\n+\t\tconfig.outputFormats = std::vector<PixelFormat>({ formats::RGB888, formats::BGR888 });\n \t\treturn 0;\n \t}\n \n@@ -291,7 +291,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf\n \t\tconfig.bpp = 10;\n \t\tconfig.patternSize.width = 4; /* 5 bytes per *4* pixels */\n \t\tconfig.patternSize.height = 2;\n-\t\tconfig.outputFormats = std::vector<PixelFormat>({ formats::RGB888 });\n+\t\tconfig.outputFormats = std::vector<PixelFormat>({ formats::RGB888, formats::BGR888 });\n \t\treturn 0;\n \t}\n \n@@ -302,7 +302,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf\n \n int DebayerCpu::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config)\n {\n-\tif (outputFormat == formats::RGB888) {\n+\tif (outputFormat == formats::RGB888 || outputFormat == formats::BGR888) {\n \t\tconfig.bpp = 24;\n \t\treturn 0;\n \t}\n@@ -338,14 +338,46 @@ int DebayerCpu::setupStandardBayerOrder(BayerFormat::Order order)\n \treturn 0;\n }\n \n-/* \\todo This ignores outputFormat since there is only 1 supported outputFormat\n-   for now */\n-int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, [[maybe_unused]] PixelFormat outputFormat)\n+int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat)\n {\n \tBayerFormat bayerFormat =\n \t\tBayerFormat::fromPixelFormat(inputFormat);\n \n \txShift_ = 0;\n+\tswapRedBlueGains_ = false;\n+\n+\tauto invalidFmt = []() -> int {\n+\t\tLOG(Debayer, Error) << \"Unsupported input output format combination\";\n+\t\treturn -EINVAL;\n+\t};\n+\n+\tswitch (outputFormat) {\n+\tcase formats::RGB888:\n+\t\tbreak;\n+\tcase formats::BGR888:\n+\t\t/* Swap R and B in bayer order to generate BGR888 instead of RGB888 */\n+\t\tswapRedBlueGains_ = true;\n+\n+\t\tswitch (bayerFormat.order) {\n+\t\tcase BayerFormat::BGGR:\n+\t\t\tbayerFormat.order = BayerFormat::RGGB;\n+\t\t\tbreak;\n+\t\tcase BayerFormat::GBRG:\n+\t\t\tbayerFormat.order = BayerFormat::GRBG;\n+\t\t\tbreak;\n+\t\tcase BayerFormat::GRBG:\n+\t\t\tbayerFormat.order = BayerFormat::GBRG;\n+\t\t\tbreak;\n+\t\tcase BayerFormat::RGGB:\n+\t\t\tbayerFormat.order = BayerFormat::BGGR;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\treturn invalidFmt();\n+\t\t}\n+\t\tbreak;\n+\tdefault:\n+\t\treturn invalidFmt();\n+\t}\n \n \tif ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) &&\n \t    bayerFormat.packing == BayerFormat::Packing::None &&\n@@ -392,8 +424,7 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, [[maybe_unused]] Pi\n \t\t}\n \t}\n \n-\tLOG(Debayer, Error) << \"Unsupported input output format combination\";\n-\treturn -EINVAL;\n+\treturn invalidFmt();\n }\n \n int DebayerCpu::configure(const StreamConfiguration &inputCfg,\n@@ -675,6 +706,9 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams\n \t\tgammaCorrection_ = params.gamma;\n \t}\n \n+\tif (swapRedBlueGains_)\n+\t\tstd::swap(params.gainR, params.gainB);\n+\n \tfor (unsigned int i = 0; i < kRGBLookupSize; i++) {\n \t\tconstexpr unsigned int div =\n \t\t\tkRGBLookupSize * DebayerParams::kGain10 / kGammaLookupSize;\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 598fe021..e7a8ba74 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -145,6 +145,7 @@ private:\n \tunsigned int lineBufferIndex_;\n \tunsigned int xShift_; /* Offset of 0/1 applied to window_.x */\n \tbool enableInputMemcpy_;\n+\tbool swapRedBlueGains_;\n \tfloat gammaCorrection_;\n \tunsigned int measuredFrames_;\n \tint64_t frameProcessTime_;\n",
    "prefixes": [
        "v8",
        "16/18"
    ]
}