Show a patch.

GET /api/patches/10866/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10866,
    "url": "https://patchwork.libcamera.org/api/patches/10866/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10866/",
    "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": "<20210115170033.27124-4-jacopo@jmondi.org>",
    "date": "2021-01-15T17:00:26",
    "name": "[libcamera-devel,v7,03/10] libcamera: camera_sensor: Provide fall-back for sensor properties",
    "commit_ref": "125ee6ddd6136b76aa8ea4652fb2ccba79923475",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "33ea5a1ea453df1de63a910b6f951a23074dd325",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10866/mbox/",
    "series": [
        {
            "id": 1578,
            "url": "https://patchwork.libcamera.org/api/series/1578/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1578",
            "date": "2021-01-15T17:00:23",
            "name": "libcamera: camera_sensor: Make validation more strict",
            "version": 7,
            "mbox": "https://patchwork.libcamera.org/series/1578/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10866/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10866/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 5A9DAC3383\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jan 2021 17:00:23 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B9A268107;\n\tFri, 15 Jan 2021 18:00:22 +0100 (CET)",
            "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F95F680F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jan 2021 18:00:19 +0100 (CET)",
            "from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 0D811240011\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jan 2021 17:00:18 +0000 (UTC)"
        ],
        "X-Originating-IP": "93.34.118.233",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 15 Jan 2021 18:00:26 +0100",
        "Message-Id": "<20210115170033.27124-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20210115170033.27124-1-jacopo@jmondi.org>",
        "References": "<20210115170033.27124-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v7 03/10] libcamera: camera_sensor:\n\tProvide fall-back for sensor properties",
        "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": "Support for the V4L2 selection API is currently optional in the\nCameraSensor class. Properties registered by using values read through\nthat API are defaulted in several different places (the Android camera\nHAL or the CameraSensor class).\n\nIn the future support for the selection API will be made mandatory, but to\ngive time to sensor drivers in all test platforms to be updated, use\nsensor resolution as fallback values for sensor pixel array properties\nand cache them as class member variables.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/camera_sensor.h |  3 ++\n src/libcamera/camera_sensor.cpp            | 57 ++++++++--------------\n 2 files changed, 24 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex aee10aa6e3c7..86902b85ada8 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 activeArea_;\n+\n \tControlList properties_;\n };\n \ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 048fcd6a1fae..0c9bd4f50cff 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -269,15 +269,21 @@ int CameraSensor::validateSensorDriver()\n \tRectangle rect;\n \tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &rect);\n \tif (ret) {\n+\t\trect = Rectangle(resolution());\n \t\tLOG(CameraSensor, Warning)\n-\t\t\t<< \"Failed to retrieve the readable pixel array size\";\n+\t\t\t<< \"The PixelArraySize property has been defaulted to \"\n+\t\t\t<< rect.toString();\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+\tret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &activeArea_);\n \tif (ret) {\n+\t\tactiveArea_ = Rectangle(pixelArraySize_);\n \t\tLOG(CameraSensor, Warning)\n-\t\t\t<< \"Failed to retrieve the active pixel array size\";\n+\t\t\t<< \"The PixelArrayActiveAreas property has been defaulted to \"\n+\t\t\t<< activeArea_.toString();\n \t\terr = -EINVAL;\n \t}\n \n@@ -373,24 +379,8 @@ int CameraSensor::initProperties()\n \t\tpropertyValue = 0;\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-\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}\n+\tproperties_.set(properties::PixelArraySize, pixelArraySize_);\n+\tproperties_.set(properties::PixelArrayActiveAreas, { activeArea_ });\n \n \t/* Color filter array pattern, register only for RAW sensors. */\n \tfor (const auto &format : formats_) {\n@@ -646,20 +636,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)\n-\t\t\t<< \"Failed to construct camera sensor info: \"\n-\t\t\t<< \"the camera sensor does not report the active area\";\n-\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 depends on the sensor\n+\t * configuration.\n+\t */\n+\tinfo->activeAreaSize = { activeArea_.width, activeArea_.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+\tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &info->analogCrop);\n \tif (ret) {\n \t\tLOG(CameraSensor, Error)\n \t\t\t<< \"Failed to construct camera sensor info: \"\n@@ -672,10 +657,10 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \t * are defined relatively to the active pixel area, while V4L2's\n \t * TGT_CROP target is defined in respect to the full pixel array.\n \t *\n-\t * Compensate it by subtracting the active areas offset.\n+\t * Compensate it by subtracting the active area offset.\n \t */\n-\tinfo->analogCrop.x -= rect.x;\n-\tinfo->analogCrop.y -= rect.y;\n+\tinfo->analogCrop.x -= activeArea_.x;\n+\tinfo->analogCrop.y -= activeArea_.y;\n \n \t/* The bit depth and image size depend on the currently applied format. */\n \tV4L2SubdeviceFormat format{};\n",
    "prefixes": [
        "libcamera-devel",
        "v7",
        "03/10"
    ]
}