Show a patch.

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

{
    "id": 19145,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19145/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19145/",
    "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": "<20231013091003.2571-1-naush@raspberrypi.com>",
    "date": "2023-10-13T09:10:03",
    "name": "[libcamera-devel] pipeline: rpi: Move flip handling validation code",
    "commit_ref": "0d4342bf2242d26775cd73dcdbcf146cc7425153",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "2e361fae67b1de5deb34a2e1b12de70cee1c850f",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19145/mbox/",
    "series": [
        {
            "id": 4050,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4050/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4050",
            "date": "2023-10-13T09:10:03",
            "name": "[libcamera-devel] pipeline: rpi: Move flip handling validation code",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4050/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19145/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19145/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 E56D4C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 09:10:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F04006297B;\n\tFri, 13 Oct 2023 11:10:09 +0200 (CEST)",
            "from mail-wr1-x434.google.com (mail-wr1-x434.google.com\n\t[IPv6:2a00:1450:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B1C36295F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 11:10:07 +0200 (CEST)",
            "by mail-wr1-x434.google.com with SMTP id\n\tffacd0b85a97d-32003aae100so1987977f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 02:10:07 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tv15-20020a5d43cf000000b003233b554e6esm20482082wrr.85.2023.10.13.02.10.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 02:10:06 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697188210;\n\tbh=qdCBY8SGQ31vCCWq4/C0U1NCCZPPOQGHETH43bN3tSE=;\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=Nw5F2gGQht6EX0rVwTf8FpQBKqbLA6zyVzJUE7RnsI0jL2TmZg8uYZgzZCQkaStBP\n\txd6eUndKc6JMOMIocNQGxWmMQIfZj2bl2Pj/xD/NzfwHyCUCP6BYHaSiLS0WcDehjc\n\t3P0VBI6dW2lv0mhXh9ZTFsWHQhuYCFGPfSgcPjC394SfiENTRrlX9uhgtUg5QPIVzu\n\tYSwnkWCO0gk+YNpmOOlX5jy70PPl4aRCQIzIewnApPV5AjSPwYsSceJiOTOWMiSI+M\n\t+WPHHC6hOWNmP9n24/YcY3UN6f6l978RxszTQI3Bjmv/7R/leZPp30rAIq4Me5uFAp\n\tZkhcJ49E9QYJw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697188206; x=1697793006;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=G0eki5a9qXNrnvqCWIms+tfm0M23ES+9LJBeasDRMdQ=;\n\tb=Bat718g3gcWSr9JwG96azlb3Tj6Xh3Q75t1blU0nFYso5Jd8h0naCnqffA7vEixSzY\n\trqeBePfyF/qMf/sqtXERwMiaYaioKzsufbneDN3gKZot+MuEydNQs3Gnwl28UtjLAsfy\n\t/JYfijYtg9o67qRF6YVyQ3+lcYMNku5rQJT/CBGPfWf8mt550ZqPZtAarPg3ZYTNnmeV\n\tkJIlCnPUd/FDfu9CgjBzjeR99FCnPdGJnoIzU4UXXkdayjA1N4p/zxJcjuhMtFTzUN0q\n\tXQuY5zkBOY6Vbg+r1Lqhg+FiCyHlt7X24n6UcN6Z1mas9n7YmSSc0XmClqd6f2SEcK8s\n\tmmJA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Bat718g3\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697188206; x=1697793006;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=G0eki5a9qXNrnvqCWIms+tfm0M23ES+9LJBeasDRMdQ=;\n\tb=X/ZPP3VdBXDllsjY6aGwDVAnphZNxPAlRHFFNaibpuFSSFJR2cVqRiCYLbNTRBMk8N\n\tWbWdQkVwQZPrEb3w3KumYv49Re8C7LrPTLBjQACz4PIFcWlCsZ+aPQwoA+PkBumBGUbO\n\tD+2maDQnDXhbhX0bGcLESJ/mlTju9T3zDkRqC1nK0XIjYIja/UfgutRxm5oMe6IpN+0z\n\tPnxewYsAI5xxUBcHCr/ELsiMRv6ZrmUP7fvfoXv4fdOky9sgwBNm/yi9pSycsn9cazBs\n\trAPrIchm/jHW/dH+UZPt1UglCEWkBj7zYqHEjwldw/exf3VkEeW3IDbPnkwMRlJV9A9s\n\tiqfQ==",
        "X-Gm-Message-State": "AOJu0Yyc3UjvWc/I1bNRRZgpZyYkbmMC94nU3inZRn9utH2dodl4GrPG\n\tSN9giyknkT2sfpR+qswNYNyvUmIPsZRowQil7lF1qw==",
        "X-Google-Smtp-Source": "AGHT+IEAxm3Q10n4S3cm/MUaHKX6bEz2DLIVdmkrfuGN2XvhzfLQipbCauQybcV46EykUB/kAfiqsA==",
        "X-Received": "by 2002:adf:a388:0:b0:32d:8872:aac6 with SMTP id\n\tl8-20020adfa388000000b0032d8872aac6mr5932675wrb.31.1697188206545; \n\tFri, 13 Oct 2023 02:10:06 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 13 Oct 2023 10:10:03 +0100",
        "Message-Id": "<20231013091003.2571-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231013074841.16972-15-naush@raspberrypi.com>",
        "References": "<20231013074841.16972-15-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] pipeline: rpi: Move flip handling\n\tvalidation code",
        "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Naushir Patuck <naush@raspberrypi.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": "Move the handling of Bayer order changes due to flips to run before\nplatformValidate(). This removes the need for this code to be split\nbetween platformValidate() and validate() as it is right now.\n\nAlso add some validation to ensure the vc4 pipeline handler only\nsupports CSI2 packing or no packing.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 43 +++++++++++++------\n src/libcamera/pipeline/rpi/vc4/vc4.cpp        | 15 ++++---\n 2 files changed, 38 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 825eae80d014..7c88b87e0608 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -231,16 +231,12 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t}\n \t}\n \n-\t/* Do any platform specific fixups. */\n-\tstatus = data_->platformValidate(this);\n-\tif (status == Invalid)\n-\t\treturn Invalid;\n-\n-\t/* Further fixups on the RAW streams. */\n+\t/* Start with some initial generic RAW stream adjustments. */\n \tfor (auto &raw : rawStreams_) {\n-\t\tint ret = raw.dev->tryFormat(&raw.format);\n-\t\tif (ret)\n-\t\t\treturn Invalid;\n+\t\tStreamConfiguration *rawStream = raw.cfg;\n+\n+\t\t/* Adjust the RAW stream to match the computed sensor format. */\n+\t\tBayerFormat sensorBayer = BayerFormat::fromMbusCode(sensorFormat_.mbus_code);\n \n \t\t/*\n \t\t * Some sensors change their Bayer order when they are h-flipped\n@@ -249,12 +245,33 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t * Note how we must fetch the \"native\" (i.e. untransformed) Bayer\n \t\t * order, because the sensor may currently be flipped!\n \t\t */\n-\t\tBayerFormat bayer = BayerFormat::fromPixelFormat(raw.cfg->pixelFormat);\n \t\tif (data_->flipsAlterBayerOrder_) {\n-\t\t\tbayer.order = data_->nativeBayerOrder_;\n-\t\t\tbayer = bayer.transform(combinedTransform_);\n+\t\t\tsensorBayer.order = data_->nativeBayerOrder_;\n+\t\t\tsensorBayer = sensorBayer.transform(combinedTransform_);\n+\t\t}\n+\n+\t\t/* Apply the sensor adjusted Bayer order to the user request. */\n+\t\tBayerFormat cfgBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat);\n+\t\tcfgBayer.order = sensorBayer.order;\n+\n+\t\tif (rawStream->pixelFormat != cfgBayer.toPixelFormat()) {\n+\t\t\trawStream->pixelFormat = cfgBayer.toPixelFormat();\n+\t\t\tstatus = Adjusted;\n \t\t}\n-\t\traw.cfg->pixelFormat = bayer.toPixelFormat();\n+\t}\n+\n+\t/* Do any platform specific fixups. */\n+\tStatus st = data_->platformValidate(this);\n+\tif (st == Invalid)\n+\t\treturn Invalid;\n+\telse if (st == Adjusted)\n+\t\tstatus = Adjusted;\n+\n+\t/* Further fixups on the RAW streams. */\n+\tfor (auto &raw : rawStreams_) {\n+\t\tint ret = raw.dev->tryFormat(&raw.format);\n+\t\tif (ret)\n+\t\t\treturn Invalid;\n \n \t\tif (RPi::PipelineHandlerBase::updateStreamConfig(raw.cfg, raw.format))\n \t\t\tstatus = Adjusted;\ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex 233473e2fe2b..425ab9ae6ea5 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -409,16 +409,17 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig\n \n \t\t/* Adjust the RAW stream to match the computed sensor format. */\n \t\tStreamConfiguration *rawStream = rawStreams[0].cfg;\n-\t\tBayerFormat rawBayer = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.mbus_code);\n+\t\tBayerFormat rawBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat);\n \n-\t\t/* Handle flips to make sure to match the RAW stream format. */\n-\t\tif (flipsAlterBayerOrder_)\n-\t\t\trawBayer = rawBayer.transform(rpiConfig->combinedTransform_);\n+\t\t/* Apply the sensor bitdepth. */\n+\t\trawBayer.bitDepth = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.mbus_code).bitDepth;\n \n-\t\t/* Apply the user requested packing. */\n-\t\trawBayer.packing = BayerFormat::fromPixelFormat(rawStream->pixelFormat).packing;\n-\t\tPixelFormat rawFormat = rawBayer.toPixelFormat();\n+\t\t/* Default to CSI2 packing if the user request is unsupported. */\n+\t\tif (rawBayer.packing != BayerFormat::Packing::CSI2 &&\n+\t\t    rawBayer.packing != BayerFormat::Packing::None)\n+\t\t\trawBayer.packing = BayerFormat::Packing::CSI2;\n \n+\t\tPixelFormat rawFormat = rawBayer.toPixelFormat();\n \t\tif (rawStream->pixelFormat != rawFormat ||\n \t\t    rawStream->size != rpiConfig->sensorFormat_.size) {\n \t\t\trawStream->pixelFormat = rawFormat;\n",
    "prefixes": [
        "libcamera-devel"
    ]
}