Patch Detail
Show a patch.
GET /api/1.1/patches/10781/?format=api
{ "id": 10781, "url": "https://patchwork.libcamera.org/api/1.1/patches/10781/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10781/", "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": "<20201230180120.78407-4-jacopo@jmondi.org>", "date": "2020-12-30T18:01:17", "name": "[libcamera-devel,v3,3/6] libcamera: camera_sensor: Default selection targets", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bff7ac69f80d64f40c2f71a7b183f6105a48af03", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10781/mbox/", "series": [ { "id": 1560, "url": "https://patchwork.libcamera.org/api/1.1/series/1560/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1560", "date": "2020-12-30T18:01:14", "name": "libcamera: camera_sensor: Make validation more strict", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1560/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10781/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10781/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 6A0A9C0F1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 30 Dec 2020 18:01:16 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ABFFF6200A;\n\tWed, 30 Dec 2020 19:01:15 +0100 (CET)", "from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 899E8615B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Dec 2020 19:01:12 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 472472000A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Dec 2020 18:01:12 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 30 Dec 2020 19:01:17 +0100", "Message-Id": "<20201230180120.78407-4-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.29.2", "In-Reply-To": "<20201230180120.78407-1-jacopo@jmondi.org>", "References": "<20201230180120.78407-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v3 3/6] libcamera: camera_sensor: Default\n\tselection targets", "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": "Support for the V4L2 selection API is optional in the CameraSensor\nclass. Currently the properties registred by using values read\nthrough that API are defaulted in several places (the Android camera HAL\nor the CameraSensor class).\n\nIn future support for the selection API will be made mandatory, but to\ngive time to sensor drivers in all test platforms to be updated, provide\na default for each of those properties, simplifying the creation of\nthe camera sensor properties list and of CameraSensorInfo.\n\nProvide a default size of [2592x2944] for the pixel array size and a\ndefault rectangle [16, 12, 2560, 1920] for the active area and analog\ncrop rectangles.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/camera_sensor.h | 3 +\n src/libcamera/camera_sensor.cpp | 71 +++++++++-------------\n 2 files changed, 31 insertions(+), 43 deletions(-)", "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex aee10aa6e3c7..c2d620f05b65 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -84,6 +84,9 @@ private:\n \tstd::vector<unsigned int> mbusCodes_;\n \tstd::vector<Size> sizes_;\n \n+\tSize pixelArraySize_;\n+\tRectangle activeAreaSize_;\n+\n \tControlList properties_;\n };\n \ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex a1f1256bd6f4..2ce19a40b448 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -31,6 +31,9 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(CameraSensor)\n \n+static constexpr Size defaultPixelArraySize = { 2592, 1944 };\n+static constexpr Rectangle defaultActiveAreaSize = { 16, 12, 2560, 1920 };\n+\n /**\n * \\struct CameraSensorInfo\n * \\brief Report the image sensor characteristics\n@@ -266,25 +269,35 @@ int CameraSensor::validateSensorDriver()\n \t * but some properties and features, like constructing a\n \t * CameraSensorInfo for the IPA module, won't be supported.\n \t */\n+\n \tRectangle rect;\n \tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &rect);\n \tif (ret) {\n \t\tLOG(CameraSensor, Info)\n-\t\t\t<< \"Failed to retrieve the readable pixel area size\";\n+\t\t\t<< \"The PixelArraySize property has been defaulted to: \"\n+\t\t\t<< defaultPixelArraySize.toString();\n+\t\trect.width = defaultPixelArraySize.width;\n+\t\trect.height = defaultPixelArraySize.height;\n \t\terr = -EINVAL;\n \t}\n+\tpixelArraySize_.width = rect.width;\n+\tpixelArraySize_.height = rect.height;\n \n \tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &rect);\n \tif (ret) {\n \t\tLOG(CameraSensor, Info)\n-\t\t\t<< \"Failed to retrieve the active pixel area size\";\n+\t\t\t<< \"The PixelArraySize property has been defaulted to: \"\n+\t\t\t<< defaultActiveAreaSize.toString();\n+\t\trect = defaultActiveAreaSize;\n \t\terr = -EINVAL;\n \t}\n+\tactiveAreaSize_ = rect;\n \n \tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &rect);\n \tif (ret) {\n \t\tLOG(CameraSensor, Info)\n-\t\t\t<< \"Failed to retreive the sensor crop rectangle\";\n+\t\t\t<< \"The analog crop rectangle has been defaulted to: \"\n+\t\t\t<< defaultActiveAreaSize.toString();\n \t\terr = -EINVAL;\n \t}\n \n@@ -378,30 +391,8 @@ int CameraSensor::initProperties()\n \t}\n \tproperties_.set(properties::Rotation, propertyValue);\n \n-\tRectangle bounds;\n-\tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &bounds);\n-\tif (!ret)\n-\t\tproperties_.set(properties::PixelArraySize, bounds.size());\n-\telse\n-\t\tLOG(CameraSensor, Debug)\n-\t\t\t<< \"PixelArraySize property not registered\";\n-\n-\tRectangle crop;\n-\tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &crop);\n-\tif (!ret) {\n-\t\t/*\n-\t\t * V4L2_SEL_TGT_CROP_DEFAULT and V4L2_SEL_TGT_CROP_BOUNDS are\n-\t\t * defined relatively to the sensor full pixel array size,\n-\t\t * while properties::PixelArrayActiveAreas is defined relatively\n-\t\t * to properties::PixelArraySize. Adjust it.\n-\t\t */\n-\t\tcrop.x -= bounds.x;\n-\t\tcrop.y -= bounds.y;\n-\t\tproperties_.set(properties::PixelArrayActiveAreas, { crop });\n-\t} else {\n-\t\tLOG(CameraSensor, Debug)\n-\t\t\t<< \"PixelArrayActiveAreas property not registered\";\n-\t}\n+\tproperties_.set(properties::PixelArraySize, pixelArraySize_);\n+\tproperties_.set(properties::PixelArrayActiveAreas, { activeAreaSize_ });\n \n \t/* Color filter array pattern, register only for RAW sensors. */\n \tfor (const auto &format : formats_) {\n@@ -657,21 +648,15 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n {\n \tinfo->model = model();\n \n-\t/* Get the active area size. */\n-\tRectangle rect;\n-\tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &rect);\n-\tif (ret) {\n-\t\tLOG(CameraSensor, Error) << \"Failed to get the active area\";\n-\t\treturn ret;\n-\t}\n-\tinfo->activeAreaSize = { rect.width, rect.height };\n+\t/*\n+\t * The active area size is a static property, while the crop\n+\t * rectangle needs to be re-read as it changes per-mode.\n+\t */\n+\tinfo->activeAreaSize = { activeAreaSize_.width, activeAreaSize_.height };\n \n-\t/* It's mandatory for the subdevice to report its crop rectangle. */\n-\tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &info->analogCrop);\n-\tif (ret) {\n-\t\tLOG(CameraSensor, Error) << \"Failed to get the crop rectangle\";\n-\t\treturn ret;\n-\t}\n+\tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &info->analogCrop);\n+\tif (ret)\n+\t\tinfo->analogCrop = defaultActiveAreaSize;\n \n \t/*\n \t * CameraSensorInfo::analogCrop::x and CameraSensorInfo::analogCrop::y\n@@ -680,8 +665,8 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \t *\n \t * Compensate it by subtracting the active areas offset.\n \t */\n-\tinfo->analogCrop.x -= rect.x;\n-\tinfo->analogCrop.y -= rect.y;\n+\tinfo->analogCrop.x -= activeAreaSize_.x;\n+\tinfo->analogCrop.y -= activeAreaSize_.y;\n \n \t/* The bit depth and image size depend on the currently applied format. */\n \tV4L2SubdeviceFormat format{};\n", "prefixes": [ "libcamera-devel", "v3", "3/6" ] }