Show a patch.

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

{
    "id": 18814,
    "url": "https://patchwork.libcamera.org/api/patches/18814/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18814/",
    "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": "<20230712105510.14658-4-naush@raspberrypi.com>",
    "date": "2023-07-12T10:55:10",
    "name": "[libcamera-devel,v1,3/3] libcamera: rpi: pipeline_base: Cache sensor format",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c554a4de5ac406af9ce0767b227e6f461fd004f8",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18814/mbox/",
    "series": [
        {
            "id": 3968,
            "url": "https://patchwork.libcamera.org/api/series/3968/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3968",
            "date": "2023-07-12T10:55:07",
            "name": "Raspberry Pi: Configuration simplifications",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3968/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18814/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18814/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 9496EC32AA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 12 Jul 2023 10:55:23 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2AFC9628C7;\n\tWed, 12 Jul 2023 12:55:21 +0200 (CEST)",
            "from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 091EE628BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Jul 2023 12:55:18 +0200 (CEST)",
            "by mail-wm1-x32d.google.com with SMTP id\n\t5b1f17b1804b1-3fbef8ad9bbso73637715e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Jul 2023 03:55:18 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th14-20020a05600c260e00b003fc05b89e5bsm4729236wma.34.2023.07.12.03.55.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 12 Jul 2023 03:55:17 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689159321;\n\tbh=aHk2zTyENpUWBARItTcIPD+G7T6aEl7gR3EykRwUqm4=;\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=txWKwztZthk50DNfSWa6oOVvbSSiIjrDhNi/w75Z3QQDKlMjNeYIYL7vlFS4fu1MQ\n\tvYiI3XBW+8lZ2lCo7rq+nKOMuLpLUsuzL/EzpaS//V//WoqDA/nMHAbP9cFzqH3c9e\n\tb5sw0VX9mzAMx4EWsOAlnWuNLmGIHOo9FMqx0B6F11CUmj95qUZhfW7Z6IFqr6f/NI\n\tnXTLV/B2//t0C8Nnetzw3sf0p/lMEuQMhRe0RWMLLbNfQEKX0kCb9sM6kJtrjQOv+W\n\tce1WCNTuC6gDQgtfjgnWM8ACJ7XK6CzrA+5DR6KCQSuzm1Yas7NCaf0Q8h5+kxNt99\n\tpGMk5iXeNcGkQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1689159317; x=1691751317;\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=LuE01IzKS/jg841yuDMjBnJW/WQ5GKocPMPeElWrjP4=;\n\tb=gqDv8b4uLltOJhc1mHF1Qbgi0Bu86j8+WWvWVSA0swbLVY3LQlIsIYlsbdBKtRdcTN\n\tQ09d+3oKnVJLDzUCb2h9NHphmcuPak4drABB2LJZ93YJtzQVSn7z8XoCDlFQVcDKTk0l\n\tufoLF9xHwL78yLeTfxa76pJ7kIc2GlYC4gGSlOpYOLTaGlRj/XD2QcHKatMuW5UpL7tV\n\tT6LhZ7rEaCO9dMoFlqbJMI2XXTGayhXV/ofkDnWU5dEg+ibYiPEZ7sgnSZKo7cWCffn4\n\ta68x0CiqPBxkIcXcl8KaXliNu4lqK0WgotzQg6uxLNvBnjKgWNpTTCW7gDCS/ITVHIPO\n\tnzcw=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"gqDv8b4u\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1689159317; x=1691751317;\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=LuE01IzKS/jg841yuDMjBnJW/WQ5GKocPMPeElWrjP4=;\n\tb=Gxchc5FIPC5+tgJw5cdDuOvxqrqW24K6Y5CH0UEifGhjjxx4TmfqS9U75JhWi4gLqV\n\tzwcc+DFHcgdabk/9wY2kbQPSCatGmAxyJn7+vQ8mC7NqAzLu3t5hL4wCqnrkGzyjRHQ3\n\tEekjTQNhYRRNkRpklDjNEISnWPvg11xgvhH5Fb2Fg3Es90Yki8K4SqlBhhuGTwn0SYq7\n\tDdY2BI7BYGsG712PwJLgGdT7BbAMVzIJlh+Zpt7w2shhDOSBBprCIDDkzdnaE+fczccz\n\tRh4abKL8392izmDpX/rR9fgeLuzul/YJwob+06SMsgK0XBAm1QN8UFAtk8S3c8BAFGGm\n\tjH4Q==",
        "X-Gm-Message-State": "ABy/qLZWNhE3HFOuD73oFThe6KC/1FzcAb5yKlUm+jUDpRMhLsMMlYmI\n\t+jM34qJyH8rZ0LCoAW3tEJ2efsEn1oqCHqKptg3VjQ==",
        "X-Google-Smtp-Source": "APBJJlHVmNUlVfq66m5bHfOYA/GcJDdgSCf6QLgThXcxonn9YCvOF3dq+bdojgQzDSqlQvf+7jPCXg==",
        "X-Received": "by 2002:a5d:4c92:0:b0:314:1494:ea01 with SMTP id\n\tz18-20020a5d4c92000000b003141494ea01mr18207220wrs.5.1689159317478; \n\tWed, 12 Jul 2023 03:55:17 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 12 Jul 2023 11:55:10 +0100",
        "Message-Id": "<20230712105510.14658-4-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230712105510.14658-1-naush@raspberrypi.com>",
        "References": "<20230712105510.14658-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1 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": "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": "From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThe 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>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 46 +++++++------------\n .../pipeline/rpi/common/pipeline_base.h       |  2 +\n 2 files changed, 19 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 725c1db0d527..d96277a2794e 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@@ -230,10 +229,10 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \n \t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n \t\tbitDepth = info.isValid() ? info.bitsPerPixel : defaultRawBitDepth;\n-\t\tsensorFormat = data_->findBestFormat(cfg.size, bitDepth);\n+\t\tV4L2SubdeviceFormat subdevFormat = data_->findBestFormat(cfg.size, bitDepth);\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, subdevFormat, packing);\n \n \t\tint ret = raw.dev->tryFormat(&rawFormat);\n \t\tif (ret)\n@@ -453,8 +452,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@@ -472,32 +469,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",
        "v1",
        "3/3"
    ]
}