Patch Detail
Show a patch.
GET /api/patches/18876/?format=api
{ "id": 18876, "url": "https://patchwork.libcamera.org/api/patches/18876/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18876/", "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": "<20230724095925.20877-4-jacopo.mondi@ideasonboard.com>", "date": "2023-07-24T09:59:25", "name": "[libcamera-devel,v3,3/3] libcamera: rpi: pipeline_base: Cache sensor format", "commit_ref": "cd7d917a04e252023f85afcf49e8c9ca1ee99838", "pull_url": null, "state": "superseded", "archived": false, "hash": "0be3e9dec0e02fdb150b816158d17456bacbb43c", "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/18876/mbox/", "series": [ { "id": 3982, "url": "https://patchwork.libcamera.org/api/series/3982/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3982", "date": "2023-07-24T09:59:22", "name": "[libcamera-devel,v3,1/3] libcamera: rpi: pipeline_base: Remove populateSensorFormats()", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3982/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18876/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18876/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 9E15FC32AA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Jul 2023 09:59:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 936DA628CC;\n\tMon, 24 Jul 2023 11:59:43 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 45234628C2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Jul 2023 11:59:40 +0200 (CEST)", "from uno.localdomain (mob-5-91-20-233.net.vodafone.it\n\t[5.91.20.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C2CE12B1;\n\tMon, 24 Jul 2023 11:58:42 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1690192783;\n\tbh=29iHnH9c9w7smKo5V0ntKFuWaUJ8AL/0yKn0ydo8CNY=;\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=vEj3AFgJWlX+1pf6PfyUhkUVl4Y98F+k6k/HJ/lmFCUguVuDYZfkU7S9JcIe0xWXI\n\t/q+1+1Z/q8GqA1EVLOYjQjwbGNLGi/UhDJjUggZfW4xKlhkljVUBm0Mrn56UfImChL\n\t7gB4RrexhEqLtEeQejpzj5yx30qdsfENe9zLrgOc5isciylPDLyvRAKddwkIiUiPET\n\tLPKlniKAKg+TJcfvvdlCc3Vuw1/j8J4JRQkH5Y/M0fXNc0oh8SsXwhKtsX8mGAxBzt\n\tQFZ00mrmYZdFT2Wgz6qFFdCcRrcprbK3UJWK8uwJHaVbGovxx7Xvi06gQrVaefT8VH\n\tsPRWH3V9tkndg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1690192722;\n\tbh=29iHnH9c9w7smKo5V0ntKFuWaUJ8AL/0yKn0ydo8CNY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VSNhxVCKhN2sWnuHJqlgbAc2l1RwQWxEP98hlkRYaBk5QvbXye5R4g2bBPWC74YAa\n\tOE8SALLtfi6IN7nqURcwPtiGhxFgXeUi4m91EmA4NYlc3FTpj1BP1TskImEtT11oyv\n\t3cOPKBfYhimaL4bFkUsOCR67M1+ucseK15QurY/w=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VSNhxVCK\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 24 Jul 2023 11:59:25 +0200", "Message-Id": "<20230724095925.20877-4-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "In-Reply-To": "<20230724095925.20877-1-jacopo.mondi@ideasonboard.com>", "References": "<20230724095925.20877-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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 | 52 +++++++++----------\n .../pipeline/rpi/common/pipeline_base.h | 2 +\n 2 files changed, 26 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 d794e9fc429f..e0fbeec37fe9 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -207,6 +207,17 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \tstd::sort(outStreams.begin(), outStreams.end(),\n \t\t [](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });\n \n+\t/* Compute the sensor configuration. */\n+\tunsigned int bitDepth = defaultRawBitDepth;\n+\tif (!rawStreams.empty()) {\n+\t\tBayerFormat bayerFormat = BayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);\n+\t\tbitDepth = bayerFormat.bitDepth;\n+\t}\n+\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 \t/* Do any platform specific fixups. */\n \tstatus = data_->platformValidate(rawStreams, outStreams);\n \tif (status == Invalid)\n@@ -217,12 +228,8 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\tStreamConfiguration &cfg = config_.at(raw.index);\n \t\tV4L2DeviceFormat rawFormat;\n \n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n-\t\tunsigned int bitDepth = info.isValid() ? info.bitsPerPixel : defaultRawBitDepth;\n-\t\tV4L2SubdeviceFormat sensorFormat = 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, sensorFormat_, packing);\n \n \t\tint ret = raw.dev->tryFormat(&rawFormat);\n \t\tif (ret)\n@@ -442,8 +449,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@@ -461,32 +466,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", "v3", "3/3" ] }