Show a patch.

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

{
    "id": 3670,
    "url": "https://patchwork.libcamera.org/api/patches/3670/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3670/",
    "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": "<20200502224540.1725-1-laurent.pinchart@ideasonboard.com>",
    "date": "2020-05-02T22:45:40",
    "name": "[libcamera-devel,v1.1,3/3] libcamera: camera_sensor: Prepare for multi-subdev camera sensors",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c75c613b48f5b22bbcbf401e7ad7a3239e3c5d9d",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3670/mbox/",
    "series": [
        {
            "id": 873,
            "url": "https://patchwork.libcamera.org/api/series/873/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=873",
            "date": "2020-05-02T22:45:40",
            "name": null,
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/873/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3670/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3670/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1C467603F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 May 2020 00:45:47 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7CAD7521\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 May 2020 00:45:46 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"qqCaziWo\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1588459546;\n\tbh=Sn9n93lGdJDazGsq/UkCyNT35BtC+YFKMBLOpb9sVQ4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=qqCaziWo61vlzspKe80akwpjPIQP2Fn2z7T+Wrug6prGgZTB2bA5RZGfkuuonLW0L\n\th7cWYLHfEM7j7Etk8hbla+8pTR5XgAJypwHXRI4ZjwNfd6dzVkoUb94/Y6XZuyTJ7V\n\t9jZdZJxxGRoo/x57WlzdbualYYhwCa0/aiu7nODI=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun,  3 May 2020 01:45:40 +0300",
        "Message-Id": "<20200502224540.1725-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.3",
        "In-Reply-To": "<20200502135355.22757-4-laurent.pinchart@ideasonboard.com>",
        "References": "<20200502135355.22757-4-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1.1 3/3] libcamera: camera_sensor:\n\tPrepare for multi-subdev camera sensors",
        "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>",
        "X-List-Received-Date": "Sat, 02 May 2020 22:45:47 -0000"
    },
    "content": "While most camera sensors are exposed to userspace as a single subdev,\nthis is not always the case. A notable exception is the smiapp driver,\nwhich exposes two or three subdevs. The subdev at the output of the\ncamera sensor will thus have more than one pad. Prepare for this by\nremoving the single-pad restriction, and locating the source pad\ndynamically.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Correctly test pad direction in init()\n---\n src/libcamera/camera_sensor.cpp       | 23 ++++++++++++++---------\n src/libcamera/include/camera_sensor.h |  2 ++\n 2 files changed, 16 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex d6a823f4d7cd..4154700a19b5 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -131,7 +131,7 @@ LOG_DEFINE_CATEGORY(CameraSensor);\n  * Once constructed the instance must be initialized with init().\n  */\n CameraSensor::CameraSensor(const MediaEntity *entity)\n-\t: entity_(entity), properties_(properties::properties)\n+\t: entity_(entity), pad_(UINT_MAX), properties_(properties::properties)\n {\n }\n \n@@ -152,9 +152,14 @@ CameraSensor::~CameraSensor()\n  */\n int CameraSensor::init()\n {\n-\tint ret;\n+\tfor (const MediaPad *pad : entity_->pads()) {\n+\t\tif (pad->flags() & MEDIA_PAD_FL_SOURCE) {\n+\t\t\tpad_ = pad->index();\n+\t\t\tbreak;\n+\t\t}\n+\t}\n \n-\tif (entity_->pads().size() != 1) {\n+\tif (pad_ == UINT_MAX) {\n \t\tLOG(CameraSensor, Error)\n \t\t\t<< \"Sensors with more than one pad are not supported\";\n \t\treturn -EINVAL;\n@@ -197,7 +202,7 @@ int CameraSensor::init()\n \n \t/* Create and open the subdev. */\n \tsubdev_ = std::make_unique<V4L2Subdevice>(entity_);\n-\tret = subdev_->open();\n+\tint ret = subdev_->open();\n \tif (ret < 0)\n \t\treturn ret;\n \n@@ -241,7 +246,7 @@ int CameraSensor::init()\n \tproperties_.set(properties::Rotation, propertyValue);\n \n \t/* Enumerate and cache media bus codes and sizes. */\n-\tconst ImageFormats formats = subdev_->formats(0);\n+\tconst ImageFormats formats = subdev_->formats(pad_);\n \tif (formats.isEmpty()) {\n \t\tLOG(CameraSensor, Error) << \"No image format found\";\n \t\treturn -EINVAL;\n@@ -405,7 +410,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu\n  */\n int CameraSensor::setFormat(V4L2SubdeviceFormat *format)\n {\n-\treturn subdev_->setFormat(0, format);\n+\treturn subdev_->setFormat(pad_, format);\n }\n \n /**\n@@ -489,7 +494,7 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \n \t/* Get the active area size. */\n \tRectangle rect = {};\n-\tint ret = subdev_->getSelection(0, V4L2_SEL_TGT_CROP_DEFAULT, &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@@ -500,7 +505,7 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \tinfo->activeAreaSize = { rect.width, rect.height };\n \n \t/* It's mandatory for the subdevice to report its crop rectangle. */\n-\tret = subdev_->getSelection(0, V4L2_SEL_TGT_CROP, &info->analogCrop);\n+\tret = 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@@ -510,7 +515,7 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \n \t/* The bit depth and image size depend on the currently applied format. */\n \tV4L2SubdeviceFormat format{};\n-\tret = subdev_->getFormat(0, &format);\n+\tret = subdev_->getFormat(pad_, &format);\n \tif (ret)\n \t\treturn ret;\n \tinfo->bitsPerPixel = format.bitsPerPixel();\ndiff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\nindex 92cd90353e72..24993b74148f 100644\n--- a/src/libcamera/include/camera_sensor.h\n+++ b/src/libcamera/include/camera_sensor.h\n@@ -70,6 +70,8 @@ protected:\n private:\n \tconst MediaEntity *entity_;\n \tstd::unique_ptr<V4L2Subdevice> subdev_;\n+\tunsigned int pad_;\n+\n \tstd::string model_;\n \n \tstd::vector<unsigned int> mbusCodes_;\n",
    "prefixes": [
        "libcamera-devel",
        "v1.1",
        "3/3"
    ]
}