Patch Detail
Show a patch.
GET /api/patches/18649/?format=api
{ "id": 18649, "url": "https://patchwork.libcamera.org/api/patches/18649/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18649/", "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": "<20230523-rkisp1-vblank-v1-1-381c6f025ff6@skidata.com>", "date": "2023-05-23T17:04:43", "name": "[libcamera-devel,RFC] rkisp1: adjust vblank to target framerate", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ff22cc950e5460776875bf9c3a48d78fe133dcad", "submitter": { "id": 163, "url": "https://patchwork.libcamera.org/api/people/163/?format=api", "name": "Benjamin Bara", "email": "bbara93@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18649/mbox/", "series": [ { "id": 3887, "url": "https://patchwork.libcamera.org/api/series/3887/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3887", "date": "2023-05-23T17:04:43", "name": "[libcamera-devel,RFC] rkisp1: adjust vblank to target framerate", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3887/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18649/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18649/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 C2184C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 May 2023 17:05:01 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DF52626DE;\n\tTue, 23 May 2023 19:05:01 +0200 (CEST)", "from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com\n\t[IPv6:2a00:1450:4864:20::52b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 16006626DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 May 2023 19:04:59 +0200 (CEST)", "by mail-ed1-x52b.google.com with SMTP id\n\t4fb4d7f45d1cf-50bcb4a81ceso193459a12.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 May 2023 10:04:59 -0700 (PDT)", "from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id\n\tv21-20020a170906339500b0096efd44dbffsm4665136eja.105.2023.05.23.10.04.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 23 May 2023 10:04:57 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1684861501;\n\tbh=ESXPLeMaQ817J3EHsBdJ8AOWu2sUAj3LMUWOsrx4sLg=;\n\th=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=Ugj+sAkfway55ubNNOo2TmkGmP5UJPxpDUUzXDAcso4tZ+lfTWSbNZT48jtbIA8+t\n\tl3g6s5lg+j8pYIquSPn2dBOIux4jQOiEyNtW7GMrswYPHx6OVSCXy0IaKPamRmjiH6\n\tidSJqw8ofmmpTHLLvbepYyqTXrnvmIKinAt+U93y6QYAgpXvlBnF+xnBrfyh3Fg1Aj\n\tY+XB8niy2CCsaw4pKzFjIIOsbYoKe1GpHxK0rmJ3X+XxlJ6olWpOJ1E863zHxfoVcE\n\t1xTSUDAFOFU/b9uZlTxPjIgbc/ZrcwpEBQDyruSG/u6MqIjybrk3bwS/6w970py/cT\n\t9GZ5xmmBvT6FA==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20221208; t=1684861498; x=1687453498;\n\th=cc:to:message-id:content-transfer-encoding:mime-version:subject\n\t:date:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=9ytBgpWtWaJ7QUJRzjRkIsKVLtH4LxiyjpZMmMQ5Te8=;\n\tb=lYVo5NYEcIShOaMCairXwZNZ40QA+SRDc+ZuheY3JyznvZKCN7D+jEdO6C9cFc2+Ex\n\tDIF/UNiLOJ4cw6YCC8pl7Him5wbJ+3ycsy5ip3j3MGAX/bmLXSMrHerXdGXZYXD2sHxC\n\t3B2R/Nm5KdO62YJjiKx8VTIygBgKv09uekBS2OC1i3yxRTlONrUxNk1D0vaxubuTfSEN\n\tcVZjUU+GJwnajlf9MLvOLaoEdNJEM65H5vNQKqmu+DTPU1/I6B6vTp0HCUZPbaEwmyEJ\n\tJ4CPpGiN3DarFbjV3OSMllNUp7isJRZt45Rcd5H8yJQ6pwA8VOhKekzL1RhR3bU7O5eJ\n\t3xEQ==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"lYVo5NYE\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1684861498; x=1687453498;\n\th=cc:to:message-id:content-transfer-encoding:mime-version:subject\n\t:date:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=9ytBgpWtWaJ7QUJRzjRkIsKVLtH4LxiyjpZMmMQ5Te8=;\n\tb=WUJ2YLVFMzlcuRoR4GMtYzrlWa8CjnDeD+B8IJbmp8BkVdmgmUYXAYgEyJ4TrtZrSo\n\tR1B09jv9gzcaZGOa8hGHnM+ZwJi6HlBh/2PAHzfufyVkGi5riS+c0uDTwXDFqVllcLNM\n\tiBj8eDJLp5a5c7jyyMo7covp2HJ96nC+Uf7Fqa0IJsi6dxs9X23usp26VOHwVmDYpbR8\n\tvFN3PjI6on4IsnXD8v0wXE9ZclD3hxv6JbMv05yZsk5HAxonFf2B4O5M5lGkTSEMSj57\n\t6BSAib9RXhrq3vxrZ83WQOiLF+JrpcSwaTq7cIIV8ne1B+ZSgawJK65bxFiH5Y6qrUk2\n\tnVhQ==", "X-Gm-Message-State": "AC+VfDxNdMSKgmCZ3qAb5OGEnQPbGXCabHFAKJ7BGqzQTAwBDXjy7YJj\n\tchJNU8G7KYlpLr/ldf0c4PkZOwGZRv0=", "X-Google-Smtp-Source": "ACHHUZ7Z1iorHkyL7b1wF3B6HHp223/TWXPW2afnkBzMrWrkKyXwPgTdtoMgq9vss1UGivTWOFMwjg==", "X-Received": "by 2002:a17:907:16a9:b0:959:a9a1:589e with SMTP id\n\thc41-20020a17090716a900b00959a9a1589emr14808716ejc.76.1684861497915; \n\tTue, 23 May 2023 10:04:57 -0700 (PDT)", "Date": "Tue, 23 May 2023 19:04:43 +0200", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20230523-rkisp1-vblank-v1-1-381c6f025ff6@skidata.com>", "X-B4-Tracking": "v=1; b=H4sIACrybGQC/x2NQQqDQAwAvyI5N6C7rdheCz7Aa+khq1GD7SpJk\n\tYL49649DsMwGxirsMEt20B5FZM5JihOGbQjxYFRusTgcufzi/Ook9hS4BpeFCf01FWlK6srnwl\n\tSE8gYg1Jsx6N6k31YD7Eo9/L9jx7Q1Hd47vsPhIz8BX0AAAA=", "To": "libcamera-devel@lists.libcamera.org", "X-Mailer": "b4 0.12.2", "Subject": "[libcamera-devel] [PATCH RFC] rkisp1: adjust vblank to target\n\tframerate", "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": "Benjamin Bara via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Benjamin Bara <bbara93@gmail.com>", "Cc": "Benjamin Bara <benjamin.bara@skidata.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Benjamin Bara <benjamin.bara@skidata.com>\n\nSet the vertical blanking of a sensor accordingly to a targeted\nframerate.\n\nE.g. gst_libcamera_clamp_and_set_frameduration() sets\nFrameDurationLimits to the initControls_, which are then passed to\nCamera::start() (and from there to PipelineHandler::start()).\n\nExample (imx327: 1080p@25; default/minimum hBlank: 280):\nvBlank = 0.04 * 148500000 / 2200 - 1080 = 1620\nwhich results to:\n16390.268661 (25.00 fps) cam0-stream0 seq: 000001 bytesused: 2073600/1036800\n16390.308661 (25.00 fps) cam0-stream0 seq: 000002 bytesused: 2073600/1036800\n\nWhen doing this on sensors where the allowed exposure range depends on\nvblank (e.g. on the imx327), the upper exposure limit is increased (\nfrom 1123 to 2698 in the example above).\n\nAs the sensor controls are \"cached\" in the IPA context, they must be\nupdated. This is done by passing the updated values via the start()\nmethod.\n\nIn general, this could be done independently of the IPA.\n\nSigned-off-by: Benjamin Bara <benjamin.bara@skidata.com>\n---\nSome checks are still missing in this version, but I wanted to check\nfirst if my approach fits and if this is something worth to look further\ninto.\n\nI also saw that the getBlanking() method inside of the rpi IPA is doing\nsomething similar, but I guess this can be done independent of the\nsensor and IPA.\n\nMany thanks and best regards,\nBenjamin\n---\n include/libcamera/ipa/rkisp1.mojom | 2 +-\n src/ipa/rkisp1/rkisp1.cpp | 18 ++++++++++++++--\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 37 +++++++++++++++++++++++++++++++-\n 3 files changed, 53 insertions(+), 4 deletions(-)\n\n\n---\nbase-commit: e8fccaea46b9e545282cd37d54b1acb168608a46\nchange-id: 20230523-rkisp1-vblank-3ad862689e4a\n\nBest regards,", "diff": "diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\nindex 1009e970..0e0df9e8 100644\n--- a/include/libcamera/ipa/rkisp1.mojom\n+++ b/include/libcamera/ipa/rkisp1.mojom\n@@ -19,7 +19,7 @@ interface IPARkISP1Interface {\n \t libcamera.IPACameraSensorInfo sensorInfo,\n \t libcamera.ControlInfoMap sensorControls)\n \t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls);\n-\tstart() => (int32 ret);\n+\tstart(libcamera.ControlInfoMap sensorControls) => (int32 ret);\n \tstop();\n \n \tconfigure(IPAConfigInfo configInfo,\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 6544c925..2c092efa 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -53,7 +53,7 @@ public:\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls) override;\n-\tint start() override;\n+\tint start(const ControlInfoMap &sensorControls) override;\n \tvoid stop() override;\n \n \tint configure(const IPAConfigInfo &ipaConfig,\n@@ -197,8 +197,22 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \treturn 0;\n }\n \n-int IPARkISP1::start()\n+int IPARkISP1::start(const ControlInfoMap &sensorControls)\n {\n+\t/*\n+\t * it might be possible that VBLANK has been changed and that this has\n+\t * an impact on the exposure limits. therefore re-set them here.\n+\t */\n+\tconst auto itExp = sensorControls.find(V4L2_CID_EXPOSURE);\n+\tint32_t minExposure = itExp->second.min().get<int32_t>();\n+\tint32_t maxExposure = itExp->second.max().get<int32_t>();\n+\tcontext_.configuration.sensor.minShutterSpeed =\n+\t\tminExposure * context_.configuration.sensor.lineDuration;\n+\tcontext_.configuration.sensor.maxShutterSpeed =\n+\t\tmaxExposure * context_.configuration.sensor.lineDuration;\n+\tLOG(IPARkISP1, Debug)\n+\t\t<< \"Exposure: [\" << minExposure << \", \" << maxExposure << \"]\";\n+\n \tsetControls(0);\n \n \treturn 0;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 8a30fe06..f9b3a3f7 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -914,12 +914,47 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n \tRkISP1CameraData *data = cameraData(camera);\n \tint ret;\n \n+\t/*\n+\t * \\todo Move this to a IPA-indepent location where a camera sensor\n+\t * instance is available and the targeted frame duration is known.\n+\t * Additionally, the IPA's sensor controls must be set accordingly.\n+\t */\n+\tauto frameDurations = controls->get(controls::FrameDurationLimits);\n+\tif (frameDurations && frameDurations->size() == 2) {\n+\t\tControlList sensorControls = data->sensor_->controls();\n+\t\tControlList ctrls;\n+\t\tIPACameraSensorInfo sensorInfo;\n+\t\tif (data->sensor_->sensorInfo(&sensorInfo)) {\n+\t\t\tLOG(RkISP1, Error) << \"couldn't fetch sensor info\";\n+\t\t}\n+\n+\t\t/*\n+\t\t * setup vertical blanking for target frame rate:\n+\t\t * frameWidth = width + hBlank\n+\t\t * frameHeight = height + vBlank\n+\t\t * frameDuration = frameWidth * frameHeight / pixelRate\n+\t\t * =>\n+\t\t * vBlank = frameDuration [us] * pixelRate / frameWidth - height\n+\t\t */\n+\t\tuint32_t frameWidth = sensorInfo.minLineLength;\n+\t\tuint32_t height = sensorInfo.outputSize.height;\n+\t\tuint64_t pixelRate = sensorInfo.pixelRate;\n+\t\tuint32_t maxFrameDuration = (*frameDurations)[1];\n+\t\tint32_t vBlank = maxFrameDuration * pixelRate / (frameWidth * 1000000) - height;\n+\t\tLOG(RkISP1, Debug) << \"Setting VBLANK to \" << vBlank;\n+\t\tctrls.set(V4L2_CID_VBLANK, vBlank);\n+\t\tdata->sensor_->setControls(&ctrls);\n+\t\tdata->sensor_->updateControlInfo();\n+\t} else {\n+\t\tLOG(RkISP1, Debug) << \"Skip setting VBLANK\";\n+\t}\n+\n \t/* Allocate buffers for internal pipeline usage. */\n \tret = allocateBuffers(camera);\n \tif (ret)\n \t\treturn ret;\n \n-\tret = data->ipa_->start();\n+\tret = data->ipa_->start(data->sensor_->controls());\n \tif (ret) {\n \t\tfreeBuffers(camera);\n \t\tLOG(RkISP1, Error)\n", "prefixes": [ "libcamera-devel", "RFC" ] }