Patch Detail
Show a patch.
GET /api/patches/17564/?format=api
{ "id": 17564, "url": "https://patchwork.libcamera.org/api/patches/17564/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17564/", "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": "<20221010074232.2404-1-naush@raspberrypi.com>", "date": "2022-10-10T07:42:32", "name": "[libcamera-devel] camera_sensor: Add minimum and maximum line length to IPACameraSensorInfo", "commit_ref": "e5fc0132f80d644757373ab0e0e3db00fe6ee010", "pull_url": null, "state": "accepted", "archived": false, "hash": "23785463c940ee600b80e794d73f47b05593fb0a", "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/17564/mbox/", "series": [ { "id": 3544, "url": "https://patchwork.libcamera.org/api/series/3544/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3544", "date": "2022-10-10T07:42:32", "name": "[libcamera-devel] camera_sensor: Add minimum and maximum line length to IPACameraSensorInfo", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3544/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17564/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17564/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 DFF50BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Oct 2022 07:42:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1354962D51;\n\tMon, 10 Oct 2022 09:42:38 +0200 (CEST)", "from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CF28960485\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Oct 2022 09:42:36 +0200 (CEST)", "by mail-wm1-x331.google.com with SMTP id\n\tbi26-20020a05600c3d9a00b003c1e11f54d2so4770681wmb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Oct 2022 00:42:36 -0700 (PDT)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ti9-20020a5d5229000000b0022cd59331b2sm8298754wra.95.2022.10.10.00.42.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 10 Oct 2022 00:42:35 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665387758;\n\tbh=Qsf+5b2dLrm0FrYoxEn/ZzJbHRm1UE3/6d0tW9dpuYg=;\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:\n\tFrom;\n\tb=lp6hT9p3obDYebuXYWHfYYn2ZS/TeoJZidGFK8YEYhuN/ZtpiPC1tGlPfEwkZ/b7G\n\tnlmMkVvqK4js6Fb+m/xZ761U5xXRwFKbdWqJGoDjJ3vQMwpiPQMHbERHUKT7ywEiGq\n\tN/z9P4YW8QQ6z6PNWsWR0yVGs4kNmmN1X1Drzd8pqpRgX4p3DIlEV5E6LDXrWN0FKk\n\ty7lZkanrM9ZFGICq2njps9vfC9rs05GXdiM7/soSGV805T40d0Q2dnrnUSOFHtDEDZ\n\tpAa/o+YR5LglgU5RvUpUdcEgfgtScXUQrB35CzgI+RB+WG5A6SKUTOO90pSw58ht4+\n\t8puiuXqHG7SlA==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\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=ksdjIYrPTEBjqYnLASM0a44bymOLNN3CjzVI65MwYYY=;\n\tb=V/9hTIz5RdRClC3yBQeOLBxFE/w+PGXqMTwjX0OYC7vKSL6zsL0sXjN6Og+BlBx/w/\n\tfyyfHqotBzvi9CbsAmzxOX3Ia/a2Hdrj2XME9YbTiDeGo5QwBT8utg/xD5DTor/5KL08\n\tkS2FKjILWlqg9ftHNr5gUWz3wr8wbrnth6QuyerBR98CyDqASxMcy8iWXY2+6XK+uGKy\n\t+/gGNJEj0pYBYUNYWHgh/x1Br56S96w2Zi7shcwBv3YYIumCLy1JTdJ9v4PGyVIuWMnm\n\teD/Seh600I+qi+cr9Lt+xvaHSDgmfwdrkDLJ4A2VhczGjyUm7gpDzF6Fpyrz4s6768xY\n\tRXkA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"V/9hTIz5\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=ksdjIYrPTEBjqYnLASM0a44bymOLNN3CjzVI65MwYYY=;\n\tb=fR3CRP5xcUIKoZWRbyqpQpTb6vsXCdBF7uJak33LM5l5c3ZzskiIrgLccJdAn95lvP\n\tX/sn1M79ZSm75rc0MlYIBgB0LgGPFHI78GpQnAwywQ5Zl7diNaOjudG72mRvT477YFkN\n\tJl6DyxSvLO93+yV8pbEP7DnLR5Ovc8hoOMLMTOrMR7oWY+vVqNCP45VPG6J+3iaDSK1K\n\tCxeg90/FDoT0yCA5M7PlXGpKjIQKFO5y5IWdzBFy4V3swOGtZPZSGsjbsjaAOWKE+HhY\n\tO361wkit+FMbsRzQVtFf+2XhuiFmHl3N2RI9lB7QOecyYjfuDGYb81klY7GsAm3PCr5t\n\tWp1w==", "X-Gm-Message-State": "ACrzQf00Gzz1O+Uh7Kjnt9xu9ZVaWar+Aa3WdMlpSQnoK0kOYujoK6xA\n\t4q13yffyIqPoc+fqi+2FHCPcoyiOiZkdfQ==", "X-Google-Smtp-Source": "AMsMyM54jAZp9o1mZFZPBfoFhQypwE2D0cHYi/pdBFlXT80Xw4vXgTQ8HhEMlJJQv75Kb4fi02dbcA==", "X-Received": "by 2002:a05:600c:524d:b0:3b4:8ad0:6d with SMTP id\n\tfc13-20020a05600c524d00b003b48ad0006dmr12125390wmb.194.1665387756033; \n\tMon, 10 Oct 2022 00:42:36 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 10 Oct 2022 08:42:32 +0100", "Message-Id": "<20221010074232.2404-1-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20221006131744.5179-2-naush@raspberrypi.com>", "References": "<20221006131744.5179-2-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] camera_sensor: Add minimum and maximum\n\tline length to IPACameraSensorInfo", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add fields for minimum and maximum line length (in units of pixels) to the\nIPACameraSensorInfo structure. This replaces the existing lineLength field.\n\nUpdate the ipu3, raspberrypi and rkisp1 IPAs to use IPACameraSensorInfo::minLineLength\ninstead of IPACameraSensorInfo::lineLength, as logically we will always want to\nuse the fastest sensor readout by default.\n\nSince the IPAs now use minLineLength for their calculations, set the starting\nvalue of the V4L2_CID_HBLANK control to its minimum in CameraSensor::init().\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>\n---\n include/libcamera/ipa/core.mojom | 21 +++++++++++++------\n src/ipa/ipu3/ipu3.cpp | 6 ++++--\n src/ipa/raspberrypi/raspberrypi.cpp | 2 +-\n src/ipa/rkisp1/rkisp1.cpp | 2 +-\n src/libcamera/camera_sensor.cpp | 32 +++++++++++++++++++++++++++--\n 5 files changed, 51 insertions(+), 12 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom\nindex 74f3339e56f2..2bc3028c22d6 100644\n--- a/include/libcamera/ipa/core.mojom\n+++ b/include/libcamera/ipa/core.mojom\n@@ -172,10 +172,17 @@ module libcamera;\n */\n \n /**\n- * \\var IPACameraSensorInfo::lineLength\n- * \\brief Total line length in pixels\n+ * \\var IPACameraSensorInfo::minLineLength\n+ * \\brief The minimum line length in pixels\n *\n- * The total line length in pixel clock periods, including blanking.\n+ * The minimum allowable line length in pixel clock periods, including blanking.\n+ */\n+\n+/**\n+ * \\var IPACameraSensorInfo::maxLineLength\n+ * \\brief The maximum line length in pixels\n+ *\n+ * The maximum allowable line length in pixel clock periods, including blanking.\n */\n \n /**\n@@ -189,7 +196,7 @@ module libcamera;\n * To obtain the minimum frame duration:\n *\n * \\verbatim\n- frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)\n+ frameDuration(s) = minFrameLength(lines) * minLineLength(pixels) / pixelRate(pixels per second)\n \\endverbatim\n */\n \n@@ -204,7 +211,7 @@ module libcamera;\n * To obtain the maximum frame duration:\n *\n * \\verbatim\n- frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)\n+ frameDuration(s) = maxFrameLength(lines) * maxLineLength(pixels) / pixelRate(pixels per second)\n \\endverbatim\n */\n struct IPACameraSensorInfo {\n@@ -217,7 +224,9 @@ struct IPACameraSensorInfo {\n \tSize outputSize;\n \n \tuint64 pixelRate;\n-\tuint32 lineLength;\n+\n+\tuint32 minLineLength;\n+\tuint32 maxLineLength;\n \n \tuint32 minFrameLength;\n \tuint32 maxFrameLength;\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex b93a09d40c39..c89f76c56ee3 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -336,7 +336,8 @@ int IPAIPU3::init(const IPASettings &settings,\n \n \t/* Clean context */\n \tcontext_.configuration = {};\n-\tcontext_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = sensorInfo.minLineLength\n+\t\t\t\t\t\t * 1.0s / sensorInfo.pixelRate;\n \n \t/* Load the tuning data file. */\n \tFile file(settings.configurationFile);\n@@ -499,7 +500,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \tcontext_.frameContexts.clear();\n \n \t/* Initialise the sensor configuration. */\n-\tcontext_.configuration.sensor.lineDuration = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = sensorInfo_.minLineLength\n+\t\t\t\t\t\t * 1.0s / sensorInfo_.pixelRate;\n \n \t/*\n \t * Compute the sensor V4L2 controls to be used by the algorithms and\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 8d731435764e..358a119da222 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -356,7 +356,7 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo)\n \t * Calculate the line length as the ratio between the line length in\n \t * pixels and the pixel rate.\n \t */\n-\tmode_.lineLength = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate);\n+\tmode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate);\n \n \t/*\n \t * Set the frame length limits for the mode to ensure exposure and\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 32feb1682749..ddb22d98eb41 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -246,7 +246,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \tcontext_.configuration.hw.revision = hwRevision_;\n \n \tcontext_.configuration.sensor.size = info.outputSize;\n-\tcontext_.configuration.sensor.lineDuration = info.lineLength * 1.0s / info.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate;\n \n \t/*\n \t * When the AGC computes the new exposure values for a frame, it needs\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 911fd0beae4e..572a313a8f99 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -176,6 +176,32 @@ int CameraSensor::init()\n \tif (ret)\n \t\treturn ret;\n \n+\t/*\n+\t * Set HBLANK to the minimum to start with a well-defined line length,\n+\t * allowing IPA modules that do not modify HBLANK to use the sensor\n+\t * minimum line length in their calculations.\n+\t *\n+\t * At present, there is no way of knowing if a control is read-only.\n+\t * As a workaround, assume that if the minimum and maximum values of\n+\t * the V4L2_CID_HBLANK control are the same, it implies the control\n+\t * is read-only.\n+\t *\n+\t * \\todo The control API ought to have a flag to specify if a control\n+\t * is read-only which could be used below.\n+\t */\n+\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n+\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n+\tconst int32_t hblankMax = hblank.max().get<int32_t>();\n+\n+\tif (hblankMin != hblankMax) {\n+\t\tControlList ctrl(subdev_->controls());\n+\n+\t\tctrl.set(V4L2_CID_HBLANK, hblankMin);\n+\t\tret = subdev_->setControls(&ctrl);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \treturn applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);\n }\n \n@@ -883,10 +909,12 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const\n \t\treturn -EINVAL;\n \t}\n \n-\tint32_t hblank = ctrls.get(V4L2_CID_HBLANK).get<int32_t>();\n-\tinfo->lineLength = info->outputSize.width + hblank;\n \tinfo->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get<int64_t>();\n \n+\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n+\tinfo->minLineLength = info->outputSize.width + hblank.min().get<int32_t>();\n+\tinfo->maxLineLength = info->outputSize.width + hblank.max().get<int32_t>();\n+\n \tconst ControlInfo vblank = ctrls.infoMap()->at(V4L2_CID_VBLANK);\n \tinfo->minFrameLength = info->outputSize.height + vblank.min().get<int32_t>();\n \tinfo->maxFrameLength = info->outputSize.height + vblank.max().get<int32_t>();\n", "prefixes": [ "libcamera-devel" ] }