Show a patch.

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

{
    "id": 18835,
    "url": "https://patchwork.libcamera.org/api/patches/18835/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18835/",
    "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": "<20230714142634.13134-4-jacopo.mondi@ideasonboard.com>",
    "date": "2023-07-14T14:26:34",
    "name": "[libcamera-devel,v2,3/3] libcamera: rpi: pipeline_base: Cache sensor format",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "28f4e7fe3af172b6017aa340ec2388444ad03cc3",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18835/mbox/",
    "series": [
        {
            "id": 3972,
            "url": "https://patchwork.libcamera.org/api/series/3972/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3972",
            "date": "2023-07-14T14:26:31",
            "name": "Raspberry Pi: Configuration simplifications",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3972/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18835/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18835/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 B1057BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Jul 2023 14:26:59 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F9AB628C3;\n\tFri, 14 Jul 2023 16:26:59 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1EE9660382\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Jul 2023 16:26:56 +0200 (CEST)",
            "from uno.localdomain (mob-5-90-9-92.net.vodafone.it [5.90.9.92])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0967A814;\n\tFri, 14 Jul 2023 16:26:04 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689344819;\n\tbh=VeKYMrG+d3Q4GJWIsBL12kCdRK0bPMgt5MG/x1w5cfE=;\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=Gi/rYVyrN4e+K+vxSYl33evNl0AO2uC4GpcKmnfaLR46skSKv3izhPf4WEdXMX42k\n\tNg34B3nlmMMzspnqzVfTTd5D37CuXVxe29QmqgCFTpp9aOEQpsdBO58Tx1v045iv2b\n\tUxUNFz2OmIGT9ibIT1NUSUxkmlW4dYacL+uavr6UP8ZAidaVtPnqK1Zo7UyAz/G48z\n\tkcwVhLXANzvyQcHoI0kubFoaD/TnSxI6+4Jxk0v/Cq31TtK4e/JNKjhm0FuZZVKmWR\n\tNAAqD7RgzYzN8ppOA8I4Eq8j+q0G1+tNS0TM4nMmq5I957PE0BMkr8kVUBwaXSCJJe\n\tVq+byHhegDD2g==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689344765;\n\tbh=VeKYMrG+d3Q4GJWIsBL12kCdRK0bPMgt5MG/x1w5cfE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=H6e98CX9O+qWaRbQh9Nghm2WyxZ4M5aVUzyS2yvscFNrFJvxMUwbaLA6beSBayn5w\n\tT5uH6EuslBB+Ze6+/RV5dmSipn1G4x4+KtXzFUfOFsd+AeXfX8m3i53cqWUxZu0yJS\n\t6eOiCcSyTg4/aXJ/at0lhSkt8HB2vp5jKw2/e43M="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"H6e98CX9\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 14 Jul 2023 16:26:34 +0200",
        "Message-Id": "<20230714142634.13134-4-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.40.1",
        "In-Reply-To": "<20230714142634.13134-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20230714142634.13134-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 3/3] libcamera: rpi: pipeline_base:\n\tCache sensor format",
        "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": "The format to be applied on the sensor is selected by two criteria: the\ndesired output size and the bit depth. As the selection depends on the\npresence of a RAW stream and the streams configuration is handled in\nvalidate() there is no need to re-compute the format in configure().\n\nCentralize the computation of the sensor format in validate() and remove\nit from configure().\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 44 +++++++------------\n .../pipeline/rpi/common/pipeline_base.h       |  2 +\n 2 files changed, 18 insertions(+), 28 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex a71715a6aff0..26d869265418 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -214,10 +214,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\tbitDepth = bayerFormat.bitDepth;\n \t}\n \n-\tV4L2SubdeviceFormat sensorFormat =\n-\t\tdata_->findBestFormat(rawStreams.empty() ? outStreams[0].cfg->size\n-\t\t\t\t\t\t\t : rawStreams[0].cfg->size,\n-\t\t\t\t      bitDepth);\n+\tsensorFormat_ = data_->findBestFormat(rawStreams.empty() ? outStreams[0].cfg->size\n+\t\t\t\t\t\t\t\t : rawStreams[0].cfg->size,\n+\t\t\t\t\t      bitDepth);\n \n \tstatus = data_->platformValidate(rawStreams, outStreams);\n \tif (status == Invalid)\n@@ -232,7 +231,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\tbitDepth = info.isValid() ? info.bitsPerPixel : defaultRawBitDepth;\n \n \t\tBayerFormat::Packing packing = BayerFormat::fromPixelFormat(cfg.pixelFormat).packing;\n-\t\trawFormat = PipelineHandlerBase::toV4L2DeviceFormat(raw.dev, sensorFormat, packing);\n+\t\trawFormat = PipelineHandlerBase::toV4L2DeviceFormat(raw.dev, sensorFormat_, packing);\n \n \t\tint ret = raw.dev->tryFormat(&rawFormat);\n \t\tif (ret)\n@@ -452,8 +451,6 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n \t\tstream->clearFlags(StreamFlag::External);\n \n \tstd::vector<CameraData::StreamParams> rawStreams, ispStreams;\n-\tstd::optional<BayerFormat::Packing> packing;\n-\tunsigned int bitDepth = defaultRawBitDepth;\n \n \tfor (unsigned i = 0; i < config->size(); i++) {\n \t\tStreamConfiguration *cfg = &config->at(i);\n@@ -471,32 +468,23 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n \tstd::sort(ispStreams.begin(), ispStreams.end(),\n \t\t  [](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });\n \n-\t/*\n-\t * Calculate the best sensor mode we can use based on the user's request,\n-\t * and apply it to the sensor with the cached tranform, if any.\n-\t *\n-\t * If we have been given a RAW stream, use that size for setting up the sensor.\n-\t */\n-\tif (!rawStreams.empty()) {\n-\t\tBayerFormat bayerFormat = BayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);\n-\t\t/* Replace the user requested packing/bit-depth. */\n-\t\tpacking = bayerFormat.packing;\n-\t\tbitDepth = bayerFormat.bitDepth;\n-\t}\n-\n-\tV4L2SubdeviceFormat sensorFormat =\n-\t\tdata->findBestFormat(rawStreams.empty() ? ispStreams[0].cfg->size\n-\t\t\t\t\t\t\t: rawStreams[0].cfg->size,\n-\t\t\t\t     bitDepth);\n+\t/* Apply the format on the sensor with any cached transform. */\n+\tconst RPiCameraConfiguration *rpiConfig =\n+\t\t\t\tstatic_cast<const RPiCameraConfiguration *>(config);\n+\tV4L2SubdeviceFormat sensorFormat = rpiConfig->sensorFormat_;\n \n-\t/* Apply any cached transform. */\n-\tconst RPiCameraConfiguration *rpiConfig = static_cast<const RPiCameraConfiguration *>(config);\n-\n-\t/* Then apply the format on the sensor. */\n \tret = data->sensor_->setFormat(&sensorFormat, rpiConfig->combinedTransform_);\n \tif (ret)\n \t\treturn ret;\n \n+\t/* Use the user requested packing/bit-depth. */\n+\tstd::optional<BayerFormat::Packing> packing;\n+\tif (!rawStreams.empty()) {\n+\t\tBayerFormat bayerFormat =\n+\t\t\tBayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);\n+\t\tpacking = bayerFormat.packing;\n+\t}\n+\n \t/*\n \t * Platform specific internal stream configuration. This also assigns\n \t * external streams which get configured below.\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h\nindex 2eda3cd89812..a139c98a5a2b 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h\n@@ -262,6 +262,8 @@ public:\n \n \t/* Cache the combinedTransform_ that will be applied to the sensor */\n \tTransform combinedTransform_;\n+\t/* The sensor format computed in validate() */\n+\tV4L2SubdeviceFormat sensorFormat_;\n \n private:\n \tconst CameraData *data_;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "3/3"
    ]
}