Patch Detail
Show a patch.
GET /api/1.1/patches/10834/?format=api
{ "id": 10834, "url": "https://patchwork.libcamera.org/api/1.1/patches/10834/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10834/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210107094735.11673-3-jacopo@jmondi.org>", "date": "2021-01-07T09:47:27", "name": "[libcamera-devel,v6,02/10] libcamera: camera_sensor: Validate driver support", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "72facf24b8e61d9bf9befc8b0187f300e533de9c", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/10834/mbox/", "series": [ { "id": 1571, "url": "https://patchwork.libcamera.org/api/1.1/series/1571/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1571", "date": "2021-01-07T09:47:25", "name": "libcamera: camera_sensor: Make validation more strict", "version": 6, "mbox": "https://patchwork.libcamera.org/series/1571/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10834/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10834/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 A3E8BC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 7 Jan 2021 09:47:29 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7FE8D6345C;\n\tThu, 7 Jan 2021 10:47:29 +0100 (CET)", "from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 58EFD631AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 7 Jan 2021 10:47:27 +0100 (CET)", "from uno.localdomain (unknown [93.56.74.111])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 24F0BFF813;\n\tThu, 7 Jan 2021 09:47:25 +0000 (UTC)" ], "X-Originating-IP": "93.56.74.111", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 7 Jan 2021 10:47:27 +0100", "Message-Id": "<20210107094735.11673-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.29.2", "In-Reply-To": "<20210107094735.11673-1-jacopo@jmondi.org>", "References": "<20210107094735.11673-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v6 02/10] libcamera: camera_sensor:\n\tValidate driver support", "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=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The CameraSensor class requires the sensor driver to report\ninformation through V4L2 controls and through the V4L2 selection API,\nand uses that information to register Camera properties and to\nconstruct CameraSensorInfo class instances to provide them to the IPA.\n\nCurrently, validation of the kernel support happens each time a\nfeature is requested, with slighly similar debug/error messages\noutput to the user in case a feature is not supported.\n\nRationalize this by validating the sensor driver requirements in a\nsingle function\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/camera_sensor.h | 1 +\n src/libcamera/camera_sensor.cpp | 84 ++++++++++++++++++++++\n 2 files changed, 85 insertions(+)", "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex f80d836161a5..aee10aa6e3c7 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -69,6 +69,7 @@ protected:\n \n private:\n \tint generateId();\n+\tint validateSensorDriver();\n \tint initProperties();\n \n \tconst MediaEntity *entity_;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex e786821d4ba2..048fcd6a1fae 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -207,6 +207,10 @@ int CameraSensor::init()\n \t */\n \tresolution_ = sizes_.back();\n \n+\tret = validateSensorDriver();\n+\tif (ret)\n+\t\treturn ret;\n+\n \tret = initProperties();\n \tif (ret)\n \t\treturn ret;\n@@ -214,6 +218,86 @@ int CameraSensor::init()\n \treturn 0;\n }\n \n+int CameraSensor::validateSensorDriver()\n+{\n+\t/*\n+\t * Make sure the sensor driver supports the mandatory controls\n+\t * required by the CameraSensor class.\n+\t * - V4L2_CID_PIXEL_RATE is used to calculate the sensor timings\n+\t * - V4L2_CID_HBLANK is used to calculate the line length\n+\t */\n+\tconst std::vector<uint32_t> mandatoryControls{\n+\t\tV4L2_CID_PIXEL_RATE,\n+\t\tV4L2_CID_HBLANK,\n+\t};\n+\n+\tControlList ctrls = subdev_->getControls(mandatoryControls);\n+\tif (ctrls.empty()) {\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"Mandatory V4L2 controls not available\";\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"The sensor kernel driver needs to be fixed\";\n+\t\tLOG(CameraSensor, Error)\n+\t\t\t<< \"See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n+\t * Optional controls are used to register optional sensor properties. If\n+\t * not present, some values will be defaulted.\n+\t */\n+\tconst std::vector<uint32_t> optionalControls{\n+\t\tV4L2_CID_CAMERA_ORIENTATION,\n+\t\tV4L2_CID_CAMERA_SENSOR_ROTATION,\n+\t};\n+\n+\tctrls = subdev_->getControls(optionalControls);\n+\tif (ctrls.empty())\n+\t\tLOG(CameraSensor, Debug) << \"Optional V4L2 controls not supported\";\n+\n+\t/*\n+\t * Make sure the required selection targets are supported.\n+\t *\n+\t * Failures in reading any of the targets are not deemed to be fatal,\n+\t * but some properties and features, like constructing a\n+\t * CameraSensorInfo for the IPA module, won't be supported.\n+\t *\n+\t * \\todo Make support for selection targets mandatory as soon as all\n+\t * test platforms have been updated.\n+\t */\n+\tint err = 0;\n+\tRectangle rect;\n+\tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &rect);\n+\tif (ret) {\n+\t\tLOG(CameraSensor, Warning)\n+\t\t\t<< \"Failed to retrieve the readable pixel array size\";\n+\t\terr = -EINVAL;\n+\t}\n+\n+\tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &rect);\n+\tif (ret) {\n+\t\tLOG(CameraSensor, Warning)\n+\t\t\t<< \"Failed to retrieve the active pixel array size\";\n+\t\terr = -EINVAL;\n+\t}\n+\n+\tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &rect);\n+\tif (ret) {\n+\t\tLOG(CameraSensor, Warning)\n+\t\t\t<< \"Failed to retrieve the sensor crop rectangle\";\n+\t\terr = -EINVAL;\n+\t}\n+\n+\tif (err) {\n+\t\tLOG(CameraSensor, Warning)\n+\t\t\t<< \"The sensor kernel driver needs to be fixed\";\n+\t\tLOG(CameraSensor, Warning)\n+\t\t\t<< \"See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information\";\n+\t}\n+\n+\treturn 0;\n+}\n+\n int CameraSensor::initProperties()\n {\n \t/*\n", "prefixes": [ "libcamera-devel", "v6", "02/10" ] }