Show a patch.

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

{
    "id": 18526,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18526/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18526/",
    "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": "<20230406-feature-controls-lens-v1-1-543189a680de@wolfvision.net>",
    "date": "2023-04-06T14:31:10",
    "name": "[libcamera-devel,RFC,1/4] media: v4l2-ctrls: add lens group status controls for zoom and focus",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "e990359dda0fd03becb7ee8b8a7e962ae3c97ee4",
    "submitter": {
        "id": 135,
        "url": "https://patchwork.libcamera.org/api/1.1/people/135/?format=api",
        "name": "Michael Riesch",
        "email": "michael.riesch@wolfvision.net"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18526/mbox/",
    "series": [
        {
            "id": 3837,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3837/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3837",
            "date": "2023-04-06T14:31:10",
            "name": "media: v4l2-ctrls: add controls for complex lens controller devices",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3837/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18526/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18526/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 A6D8EC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 Apr 2023 14:31:45 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F259C627A9;\n\tThu,  6 Apr 2023 16:31:44 +0200 (CEST)",
            "from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42229603A4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Apr 2023 16:31:42 +0200 (CEST)",
            "from smtp.kernel.org (relay.kernel.org [52.25.139.140])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby dfw.source.kernel.org (Postfix) with ESMTPS id 1E06264892;\n\tThu,  6 Apr 2023 14:31:41 +0000 (UTC)",
            "by smtp.kernel.org (Postfix) with ESMTPS id 7F6DDC4339B;\n\tThu,  6 Apr 2023 14:31:40 +0000 (UTC)",
            "from aws-us-west-2-korg-lkml-1.web.codeaurora.org\n\t(localhost.localdomain [127.0.0.1])\n\tby smtp.lore.kernel.org (Postfix) with ESMTP id 5063DC77B79;\n\tThu,  6 Apr 2023 14:31:40 +0000 (UTC)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680791505;\n\tbh=LSwt6QH3V2tXdTONtoafJp4yQRCHGKBXLqabuQsoORw=;\n\th=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=U0JlOtFtkqRyx6x36lzNNW25YfeyjN1VrsIVtQgzGS+4kswosUpGNoAvu/PxBl6ZX\n\trr/ppFexTqS8hGbr0Ulgh6XNwmJGW5oJReecpGn7ACcIkryzj9iKns9wyaC0APel8M\n\tF9OnbvGGZmUqXV9vChztX5dUwjwCEEh7LWDicLp83qy7WqWNcHKnE0yyPwDwUaj6dU\n\tMYf9fdQdj+lLn7cy/fvyn4gWtbuHA53IJwquMYwiZSkb//J2Wx3OF2g9RDJppT2cFw\n\tG6XZqJTvD/nmIdRRduBBd18vQx6NWG//9uEP91RC6kfvCnYYAbx9k7wihrfed/7Jmw\n\ty7lM6345TJdCg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1680791500;\n\tbh=LSwt6QH3V2tXdTONtoafJp4yQRCHGKBXLqabuQsoORw=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=urg/HvWRXgJz+pvk3cbgWdkLTNo2G1ckU8HJ+j1VxKmSJr8MEGkiaEKg8ecIga6pi\n\tbz/CV38E3nJyEa1K3+Sf9d9PJMEFbMO3uKSOjXmd4scHlYWBxSM6S3FCIoZUD0nn4O\n\tphHLjPbuihFBiDrxTHhzv9TDyn6ovJzqtUCZyxmKLXaU545GajSBRrPCSlQFQ8XIQL\n\t29AuIB3CtwyLH9FYZkloN+ZX7gTaocryLaGi0DsCua6h0lT/X3hLQywouUXk5zYpXs\n\tcr7rMYEtHNJDHp1VjuafrfCTTnjDJYVdE5DlxI1avest079ECVFR57u8ct1AeyyuQU\n\tIQ1+uLVvyp6pw=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=kernel.org\n\theader.i=@kernel.org header.b=\"urg/HvWR\"; \n\tdkim-atps=neutral",
        "Date": "Thu, 06 Apr 2023 16:31:10 +0200",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Message-Id": "<20230406-feature-controls-lens-v1-1-543189a680de@wolfvision.net>",
        "References": "<20230406-feature-controls-lens-v1-0-543189a680de@wolfvision.net>",
        "In-Reply-To": "<20230406-feature-controls-lens-v1-0-543189a680de@wolfvision.net>",
        "To": "Mauro Carvalho Chehab <mchehab@kernel.org>",
        "X-Mailer": "b4 0.12.2",
        "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1680791498; l=8240;\n\ti=michael.riesch@wolfvision.net; s=20230406; h=from:subject:message-id;\n\tbh=Cc1WB+yv71THXEf6l6IJIG9sr2nW0g4dbh9SFdvZUYw=;\n\tb=RPXxrKUDV4B/2gM4uGuCklbkYr9MQz1oymdujxBicfPUt+Nyi6Xji8UwnUaLDRL0UJUABx6xY\n\tXmxNSqdMpnuBaqxBpYGDfxi4kGKBeZemc6+k/TAomPmq/QGSy1UVmn9",
        "X-Developer-Key": "i=michael.riesch@wolfvision.net; a=ed25519;\n\tpk=G03kuYHL670EcdsWaNfVA7KnHWmkSpj98XziQm/hjbk=",
        "X-Endpoint-Received": "by B4 Relay for michael.riesch@wolfvision.net/20230406\n\twith auth_id=38",
        "X-Original-From": "Michael Riesch <michael.riesch@wolfvision.net>",
        "Subject": "[libcamera-devel] [PATCH RFC 1/4] media: v4l2-ctrls: add lens group\n\tstatus controls for zoom and focus",
        "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>",
        "From": "Michael Riesch via B4 Relay via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "michael.riesch@wolfvision.net",
        "Cc": "Michael Riesch via B4 Relay\n\t<devnull+michael.riesch.wolfvision.net@kernel.org>,\n\tlinux-kernel@vger.kernel.org,\n\tMatthias Fend <Matthias.Fend@wolfvision.net>, \n\tlibcamera-devel@lists.libcamera.org,\n\tSakari Ailus <sakari.ailus@linux.intel.com>, linux-media@vger.kernel.org",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Michael Riesch <michael.riesch@wolfvision.net>\n\nAdd the controls V4L2_CID_FOCUS_STATUS and V4L2_CID_ZOOM_STATUS that report\nthe status of the zoom lens group and the focus lens group, respectively.\nThe returned data structure contains the current position of the lens group\nas well as movement indication flags.\n\nSigned-off-by: Michael Riesch <michael.riesch@wolfvision.net>\n---\n .../userspace-api/media/v4l/ext-ctrls-camera.rst   | 48 ++++++++++++++++++++++\n drivers/media/v4l2-core/v4l2-ctrls-core.c          |  9 ++++\n drivers/media/v4l2-core/v4l2-ctrls-defs.c          |  7 ++++\n include/media/v4l2-ctrls.h                         |  2 +\n include/uapi/linux/v4l2-controls.h                 | 13 ++++++\n include/uapi/linux/videodev2.h                     |  2 +\n 6 files changed, 81 insertions(+)",
    "diff": "diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst\nindex daa4f40869f8..3a270bc63f1a 100644\n--- a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst\n+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst\n@@ -149,6 +149,30 @@ enum v4l2_exposure_metering -\n     to the camera, negative values towards infinity. This is a\n     write-only control.\n \n+``V4L2_CID_FOCUS_STATUS (struct)``\n+    The current status of the focus lens group. This is a read-only control.\n+    The returned data structure contains the current position and movement\n+    indication flags. The unit of the current position is undefined. Positive\n+    values move the focus closer to the camera, negative values towards\n+    infinity. The possible flags are described in the table below.\n+\n+.. tabularcolumns:: |p{6.8cm}|p{10.7cm}|\n+\n+.. flat-table::\n+    :header-rows:  0\n+    :stub-columns: 0\n+\n+    * - ``V4L2_LENS_STATUS_IDLE``\n+      - Focus lens group is at rest.\n+    * - ``V4L2_LENS_STATUS_BUSY``\n+      - Focus lens group is moving.\n+    * - ``V4L2_LENS_STATUS_REACHED``\n+      - Focus lens group has reached its target position.\n+    * - ``V4L2_LENS_STATUS_FAILED``\n+      - Focus lens group has failed to reach its target position. The driver\n+\twill not transition from this state until another action is performed\n+\tby an application.\n+\n ``V4L2_CID_FOCUS_AUTO (boolean)``\n     Enables continuous automatic focus adjustments. The effect of manual\n     focus adjustments while this feature is enabled is undefined,\n@@ -239,6 +263,30 @@ enum v4l2_auto_focus_range -\n     movement. A negative value moves the zoom lens group towards the\n     wide-angle direction. The zoom speed unit is driver-specific.\n \n+``V4L2_CID_ZOOM_STATUS (struct)``\n+    The current status of the zoom lens group. This is a read-only control.\n+    The returned data structure contains the current position and movement\n+    indication flags. The unit of the current position is driver-specific and\n+    its value should be a positive integer. The possible flags are described\n+    in the table below.\n+\n+.. tabularcolumns:: |p{6.8cm}|p{10.7cm}|\n+\n+.. flat-table::\n+    :header-rows:  0\n+    :stub-columns: 0\n+\n+    * - ``V4L2_LENS_STATUS_IDLE``\n+      - Zoom lens group is at rest.\n+    * - ``V4L2_LENS_STATUS_BUSY``\n+      - Zoom lens group is moving.\n+    * - ``V4L2_LENS_STATUS_REACHED``\n+      - Zoom lens group has reached its target position.\n+    * - ``V4L2_LENS_STATUS_FAILED``\n+      - Zoom lens group has failed to reach its target position. The driver will\n+\tnot transition from this state until another action is performed by an\n+\tapplication.\n+\n ``V4L2_CID_IRIS_ABSOLUTE (integer)``\n     This control sets the camera's aperture to the specified value. The\n     unit is undefined. Larger values open the iris wider, smaller values\ndiff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c\nindex 29169170880a..f6ad30f311c5 100644\n--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c\n+++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c\n@@ -350,6 +350,9 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)\n \tcase V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:\n \t\tpr_cont(\"HEVC_DECODE_PARAMS\");\n \t\tbreak;\n+\tcase V4L2_CTRL_TYPE_LENS_STATUS:\n+\t\tpr_cont(\"LENS_STATUS\");\n+\t\tbreak;\n \tdefault:\n \t\tpr_cont(\"unknown type %d\", ctrl->type);\n \t\tbreak;\n@@ -918,6 +921,9 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,\n \t\t\treturn -EINVAL;\n \t\tbreak;\n \n+\tcase V4L2_CTRL_TYPE_LENS_STATUS:\n+\t\tbreak;\n+\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n@@ -1605,6 +1611,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,\n \tcase V4L2_CTRL_TYPE_AREA:\n \t\telem_size = sizeof(struct v4l2_area);\n \t\tbreak;\n+\tcase V4L2_CTRL_TYPE_LENS_STATUS:\n+\t\telem_size = sizeof(struct v4l2_ctrl_lens_status);\n+\t\tbreak;\n \tdefault:\n \t\tif (type < V4L2_CTRL_COMPOUND_TYPES)\n \t\t\telem_size = sizeof(s32);\ndiff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c\nindex 564fedee2c88..9b26a3aa9e9c 100644\n--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c\n+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c\n@@ -1044,6 +1044,8 @@ const char *v4l2_ctrl_get_name(u32 id)\n \tcase V4L2_CID_CAMERA_ORIENTATION:\treturn \"Camera Orientation\";\n \tcase V4L2_CID_CAMERA_SENSOR_ROTATION:\treturn \"Camera Sensor Rotation\";\n \tcase V4L2_CID_HDR_SENSOR_MODE:\t\treturn \"HDR Sensor Mode\";\n+\tcase V4L2_CID_FOCUS_STATUS:\t\treturn \"Focus, Status\";\n+\tcase V4L2_CID_ZOOM_STATUS:\t\treturn \"Zoom, Status\";\n \n \t/* FM Radio Modulator controls */\n \t/* Keep the order of the 'case's the same as in v4l2-controls.h! */\n@@ -1593,6 +1595,11 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,\n \t\t*flags |= V4L2_CTRL_FLAG_WRITE_ONLY |\n \t\t\t  V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;\n \t\tbreak;\n+\tcase V4L2_CID_FOCUS_STATUS:\n+\tcase V4L2_CID_ZOOM_STATUS:\n+\t\t*type = V4L2_CTRL_TYPE_LENS_STATUS;\n+\t\t*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_VOLATILE;\n+\t\tbreak;\n \tcase V4L2_CID_FLASH_STROBE_STATUS:\n \tcase V4L2_CID_AUTO_FOCUS_STATUS:\n \tcase V4L2_CID_FLASH_READY:\ndiff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h\nindex e59d9a234631..f7273ffc20c9 100644\n--- a/include/media/v4l2-ctrls.h\n+++ b/include/media/v4l2-ctrls.h\n@@ -52,6 +52,7 @@ struct video_device;\n  * @p_hdr10_cll:\t\tPointer to an HDR10 Content Light Level structure.\n  * @p_hdr10_mastering:\t\tPointer to an HDR10 Mastering Display structure.\n  * @p_area:\t\t\tPointer to an area.\n+ * @p_lens_status:\t\tPointer to a lens status structure.\n  * @p:\t\t\t\tPointer to a compound value.\n  * @p_const:\t\t\tPointer to a constant compound value.\n  */\n@@ -81,6 +82,7 @@ union v4l2_ctrl_ptr {\n \tstruct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;\n \tstruct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;\n \tstruct v4l2_area *p_area;\n+\tstruct v4l2_ctrl_lens_status *p_lens_status;\n \tvoid *p;\n \tconst void *p_const;\n };\ndiff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h\nindex 5e80daa4ffe0..8b037467ba9a 100644\n--- a/include/uapi/linux/v4l2-controls.h\n+++ b/include/uapi/linux/v4l2-controls.h\n@@ -993,6 +993,19 @@ enum v4l2_auto_focus_range {\n \n #define V4L2_CID_HDR_SENSOR_MODE\t\t(V4L2_CID_CAMERA_CLASS_BASE+36)\n \n+struct v4l2_ctrl_lens_status {\n+\t__u32 flags;\n+\t__s32 current_position;\n+};\n+\n+#define V4L2_LENS_STATUS_IDLE\t\t\t(0 << 0)\n+#define V4L2_LENS_STATUS_BUSY\t\t\t(1 << 0)\n+#define V4L2_LENS_STATUS_REACHED\t\t(1 << 1)\n+#define V4L2_LENS_STATUS_FAILED\t\t\t(1 << 2)\n+\n+#define V4L2_CID_FOCUS_STATUS\t\t\t(V4L2_CID_CAMERA_CLASS_BASE + 37)\n+#define V4L2_CID_ZOOM_STATUS\t\t\t(V4L2_CID_CAMERA_CLASS_BASE + 38)\n+\n /* FM Modulator class control IDs */\n \n #define V4L2_CID_FM_TX_CLASS_BASE\t\t(V4L2_CTRL_CLASS_FM_TX | 0x900)\ndiff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h\nindex 17a9b975177a..256c21c68720 100644\n--- a/include/uapi/linux/videodev2.h\n+++ b/include/uapi/linux/videodev2.h\n@@ -1888,6 +1888,8 @@ enum v4l2_ctrl_type {\n \tV4L2_CTRL_TYPE_HEVC_SLICE_PARAMS\t= 0x0272,\n \tV4L2_CTRL_TYPE_HEVC_SCALING_MATRIX\t= 0x0273,\n \tV4L2_CTRL_TYPE_HEVC_DECODE_PARAMS\t= 0x0274,\n+\n+\tV4L2_CTRL_TYPE_LENS_STATUS\t\t= 0x0300,\n };\n \n /*  Used in the VIDIOC_QUERYCTRL ioctl for querying controls */\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "1/4"
    ]
}