Patch Detail
Show a patch.
GET /api/patches/11844/?format=api
{ "id": 11844, "url": "https://patchwork.libcamera.org/api/patches/11844/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11844/", "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": "<20210406104050.23814-2-david.plowman@raspberrypi.com>", "date": "2021-04-06T10:40:49", "name": "[libcamera-devel,v2,1/2] libcamera: camera_sensor: Fix frame lengths calculated by sensorInfo()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "f6b4e46d07a82ccb3292405d0db5231173abb8b8", "submitter": { "id": 42, "url": "https://patchwork.libcamera.org/api/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/11844/mbox/", "series": [ { "id": 1895, "url": "https://patchwork.libcamera.org/api/series/1895/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1895", "date": "2021-04-06T10:40:48", "name": "Fix CameraSensor::sensorInfo by updating VBLANK ControlInfo", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1895/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/11844/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11844/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 304A3C0DA5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 6 Apr 2021 10:41:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E94706877C;\n\tTue, 6 Apr 2021 12:41:01 +0200 (CEST)", "from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com\n\t[IPv6:2a00:1450:4864:20::62e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A336860518\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 6 Apr 2021 12:40:59 +0200 (CEST)", "by mail-ej1-x62e.google.com with SMTP id u17so14857705ejk.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 06 Apr 2021 03:40:59 -0700 (PDT)", "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tdf8sm4068486edb.4.2021.04.06.03.40.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 06 Apr 2021 03:40:58 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"f5qbJ1XQ\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=iW6Slu5SHB6NZU7CidwsLoo0btcdnJVJJ2S8lR/hWDE=;\n\tb=f5qbJ1XQh4pKT9oetmaw1elDiJyL4AXtUQj8WUEK8ajCQ62RDE4Ah7F8xH0TDaX2uF\n\tGv8KKBOEzc/xFY8HIWwFDlDiPHtM2G1k76Brm53xGtIbCbtdtpOOmL/lJhfGz30HU3j/\n\tw2c0s8H6fUuKn9YHFtL6ZHpCWUt5DJmEU0sq0Pu1KDoJWdGRWUxaPlJI0mUbCb64o7yv\n\tRe/+bZ6vP9HNHi2ZjZn0eSAlyHqVJrxC5ZFGksRPiVL99H78+8WHYJh5tPOmBNwWW2J3\n\tHwSw6tdiNYHt2559NXGa7l59MxDSlhuJcxqVQAVoqC+R86tbX4ke4dkCFEE3j8hvGyfX\n\tGarA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=iW6Slu5SHB6NZU7CidwsLoo0btcdnJVJJ2S8lR/hWDE=;\n\tb=YGmLM7qHuqmCRFlJt9JUzzuEbgBg313g1GN8etVqwkPNy1TXi2qfotdYiChyxIlPfF\n\tJikcgvZHti7lSL/AFW1KKT02MAfpIcgYYd7GZOq2QjI15gCZ2qySOlYGOKjZkeEAvJQy\n\ti573LjBwNl5cLRKU75mF48lG0jt6s/u9hX0zNDBT2yfHsxavbJUXbuD7yPb45TIDV4tS\n\t7TqggT3LkV3pcYPi00QoGe8grVCd9AtS4injVfCHMVZ4wb0BSHR48+07M2ICogsm1kFK\n\tgCsQrEwHXhl/3g/K9Kpz85Apk+J5g3NFMSw6h8iKBG8UB9BCX4xuPHG9A2GcP14bPzOp\n\tTS0A==", "X-Gm-Message-State": "AOAM533IL0EZaHKQn2tV9n4+jGbDoPXmJoft3xaYweZzNph14DDR0BYn\n\t/qlstiasrFHnifnwIcVBXqSbuzJRVh8dHQ==", "X-Google-Smtp-Source": "ABdhPJxC+XqzXIcFcp9CgQp+y0zxpaRov3HU4PVkzVvqJ3WbiD7wcPj+QHC3hpK2ChSFb7eP+Ws4mQ==", "X-Received": "by 2002:a17:906:7ac9:: with SMTP id\n\tk9mr33844634ejo.229.1617705658960; \n\tTue, 06 Apr 2021 03:40:58 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 6 Apr 2021 11:40:49 +0100", "Message-Id": "<20210406104050.23814-2-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20210406104050.23814-1-david.plowman@raspberrypi.com>", "References": "<20210406104050.23814-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 1/2] libcamera: camera_sensor: Fix\n\tframe lengths calculated by sensorInfo()", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The minimum and maximum vblanking can change when a new format is\napplied to the sensor subdevice, so be sure to retrieve up-to-date\nvalues.\n\nThe V4L2Device acquires the new updateControlInfos() method to perform\nthis function, and which the CameraSensor calls automatically if its\nsetFormat method is used to update the sensor.\n\nHowever, not all pipeline handlers invoke the setFormat method\ndirectly, so the new method must be made publicly available for\npipeline handlers to call if they need to.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/internal/camera_sensor.h | 2 ++\n include/libcamera/internal/v4l2_device.h | 2 ++\n src/libcamera/camera_sensor.cpp | 31 +++++++++++++++++++++-\n src/libcamera/v4l2_device.cpp | 26 ++++++++++++++++++\n 4 files changed, 60 insertions(+), 1 deletion(-)", "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex 3e98f71b..c94744f0 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -68,6 +68,8 @@ public:\n \tconst ControlList &properties() const { return properties_; }\n \tint sensorInfo(CameraSensorInfo *info) const;\n \n+\tvoid updateControlInfos();\n+\n protected:\n \tstd::string logPrefix() const override;\n \ndiff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex d006bf68..274cbe65 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -41,6 +41,8 @@ public:\n \tint setFrameStartEnabled(bool enable);\n \tSignal<uint32_t> frameStart;\n \n+\tvoid updateControlInfos();\n+\n protected:\n \tV4L2Device(const std::string &deviceNode);\n \t~V4L2Device();\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex f7ed91d9..5dbe47a7 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -656,15 +656,30 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu\n /**\n * \\brief Set the sensor output format\n * \\param[in] format The desired sensor output format\n+ *\n+ * The sensor output format is set. The ranges of any controls associated\n+ * with the sensor are also updated.\n+ *\n * \\return 0 on success or a negative error code otherwise\n */\n int CameraSensor::setFormat(V4L2SubdeviceFormat *format)\n {\n-\treturn subdev_->setFormat(pad_, format);\n+\tint ret = subdev_->setFormat(pad_, format);\n+\n+\tif (ret == 0)\n+\t\tupdateControlInfos();\n+\n+\treturn ret;\n }\n \n /**\n * \\brief Retrieve the supported V4L2 controls and their information\n+ *\n+ * Pipeline handlers that do not change the sensor format using the\n+ * CameraSensor::setFormat method may need to call\n+ * CameraSensor::updateControlInfos beforehand, to ensure all the control\n+ * ranges are up to date.\n+ *\n * \\return A map of the V4L2 controls supported by the sensor\n */\n const ControlInfoMap &CameraSensor::controls() const\n@@ -750,6 +765,11 @@ int CameraSensor::setControls(ControlList *ctrls)\n * Sensor information is only available for raw sensors. When called for a YUV\n * sensor, this function returns -EINVAL.\n *\n+ * Pipeline handlers that do not change the sensor format using the\n+ * CameraSensor::setFormat method may need to call\n+ * CameraSensor::updateControlInfos beforehand, to ensure all the control\n+ * ranges are up to date.\n+ *\n * \\return 0 on success, a negative error code otherwise\n */\n int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n@@ -821,6 +841,15 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \treturn 0;\n }\n \n+/**\n+ * \\fn void CameraSensor::updateControlInfos()\n+ * \\brief Update the sensor's ControlInfos in case they have changed\n+ */\n+void CameraSensor::updateControlInfos()\n+{\n+\tsubdev_->updateControlInfos();\n+}\n+\n std::string CameraSensor::logPrefix() const\n {\n \treturn \"'\" + entity_->name() + \"'\";\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex decd19ef..9678962c 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -514,6 +514,32 @@ void V4L2Device::listControls()\n \tcontrols_ = std::move(ctrls);\n }\n \n+/*\n+ * \\brief Update the control information that was previously stored by\n+ * listControls(). Some parts of this information, such as min and max\n+ * values of some controls, are liable to change when a new format is set.\n+ */\n+void V4L2Device::updateControlInfos()\n+{\n+\tfor (auto &controlId : controlIds_) {\n+\t\tunsigned int id = controlId->id();\n+\n+\t\tstruct v4l2_query_ext_ctrl ctrl = {};\n+\t\tctrl.id = id;\n+\n+\t\tif (ioctl(VIDIOC_QUERY_EXT_CTRL, &ctrl)) {\n+\t\t\tLOG(V4L2, Debug)\n+\t\t\t\t<< \"Could not refresh control \"\n+\t\t\t\t<< utils::hex(ctrl.id);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\t/* Assume these are present - listControls() made them. */\n+\t\tcontrolInfo_[id] = ctrl;\n+\t\tcontrols_.at(controlId.get()) = V4L2ControlInfo(ctrl);\n+\t}\n+}\n+\n /*\n * \\brief Update the value of the first \\a count V4L2 controls in \\a ctrls using\n * values in \\a v4l2Ctrls\n", "prefixes": [ "libcamera-devel", "v2", "1/2" ] }