From patchwork Sun Dec 11 13:02:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dorota Czaplejewicz X-Patchwork-Id: 32182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1759681wrr; Sun, 11 Dec 2022 05:08:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5L0ygQhj89eBJ7B/1a4aPvoVmQ6lmB1oSHgbmdJJp931Mp8KCGxK691pjtFVhwF9icv/ii X-Received: by 2002:a17:906:c044:b0:78d:f454:3783 with SMTP id bm4-20020a170906c04400b0078df4543783mr10511778ejb.38.1670764099554; Sun, 11 Dec 2022 05:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670764099; cv=none; d=google.com; s=arc-20160816; b=pUMXaDTY6JJnWq6KvFqtcrSy/09WZRFdMBKo2ioA/SWBVxMlZR+8FW0SU+5ihyWnl9 8UmNBj27Gp5C4jno1edseXYuzGfR7PPPBOQS5afrSXMzQwXwDIPy8QwqOtCvaNwthfrJ v1Z2JZvS/AaRPUvCeq6j0GhUrnrQ4KoCoEbjd+y7mlqiHe/WdyrftrfmB6IPOuo3GQOZ Galc85mzZJdqP6TY7xK/Ca6ko/bwv5IJevtbVKyxybkMHqsoBQhLreFbRy9AibSfGdAF 474RAWajJH05Rm+BNIDd+3q/iurM+iT88EOPcYm7tNJnECPstvnvZSHeThw2E+sbeIn/ fCRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:organization:message-id:subject:to :from:dkim-signature:date; bh=ozrD9AFITM2MCIRBs6B9c5/wGcWvhzHB5YQOevLw+Vw=; b=f8V0+tjzpcPsrIdEsbeRSid3nJ1d5+38if0GtBX1bLYQhiQfBog9H9pLf+nxeF3TFI oqEkboYpXdFhN7TBez450tqZAgBZuXMn4uOZUwbA0WkO1X4cLh3ntEEq0+tRp6cWOQd5 wrSiJ6eQgVdJjhIsvlcDMpnS7upYI/KPCnp3DsCmat956MElZbdM+VBEb2tZhjFnuHdL iSfWr8F0JcBevFj1KtWi4z3FUI2KdgVO9EG8PuNMZSnzliZyXmOVfBU+vuaSyDA6/tgM 69EIBhs0IcjiBd8NtN7lApcHCNahyY4AWndpJ4Tg0sAj0o7898cL/q9PytGB6bjURbW6 pXow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@puri.sm header.s=comms header.b=cdlbRuUZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb27-20020a1709076d9b00b0078e0e8508fbsi4328016ejc.457.2022.12.11.05.07.56; Sun, 11 Dec 2022 05:08:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@puri.sm header.s=comms header.b=cdlbRuUZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbiLKNDa (ORCPT + 99 others); Sun, 11 Dec 2022 08:03:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbiLKNDX (ORCPT ); Sun, 11 Dec 2022 08:03:23 -0500 Received: from comms.puri.sm (comms.puri.sm [159.203.221.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70653BC9A; Sun, 11 Dec 2022 05:03:22 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 4AD5DEF93D; Sun, 11 Dec 2022 05:02:52 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aJhmIaotL3Ao; Sun, 11 Dec 2022 05:02:51 -0800 (PST) Date: Sun, 11 Dec 2022 14:02:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=puri.sm; s=comms; t=1670763771; bh=3siezGDNug+NuYJKLWyZorIF87F8xCDbpriaUUSAiBk=; h=Date:From:To:Subject:From; b=cdlbRuUZEcrw64buujadebEnzCUhNZMuvngo+xccAAqlRB1TaScK0UCEzbeZlbP2A paCjncf2/wOPEvW3dB4V9O5bb+XEEcz09ncxEE4A5cZUvqStXSp3o5bSQEexGlcwEM Wn66wq6doqq6VRLSTGxGBAeWYLKmC4CTs0jaV/2AxjT5GZQ9f6Xrg2iwsNYq2h482G W1pcxMu/CNeGtR5Yj1ShGGMpBeckRzpv3LNjg5AeQ7/IJdXD9Kd5V5W1AT12uQKaDe ivM3mtRZa81G/v2Vr8V0yNem0QfiH2cP7EPPp54igrrAGWlviv0Rvx52CNujudLx7a 9lxzI10Dr6zxQ== From: Dorota Czaplejewicz To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@puri.sm Subject: [PATCHv3 1/2] doc/media api: Try to make enum usage clearer Message-ID: <20221211125718.2815126-1-dorota.czaplejewicz@puri.sm> Organization: Purism MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751923136122888438?= X-GMAIL-MSGID: =?utf-8?q?1751923136122888438?= This clarifies which side of the calls is responsible for doing what to which parts of the struct. This also explicitly states that repeating values are disallowed. It also expands the terse description of the access algorithm into more prose-like, active voice description, which trades conciseness for ease of comprehension. Added: mbus codes must not repeat Added: no holes in the enumeration Added: enumerations per what? Added: who fills in what in calls Changed: "zero" -> "0" Changed: "given" -> "specified" Still unclear how it works so didn't describe: "which". What is a "try format" vs "active format"? Signed-off-by: Dorota Czaplejewicz --- Hi, I took those patches out of the freezer. I made sure they still apply (they do), and corrected some errors pointed out by Jacopo in the previous round of reviews. Thanks, Dorota .../v4l/vidioc-subdev-enum-mbus-code.rst | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst index 417f1a19bcc4..63bff24d0520 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst @@ -31,15 +31,28 @@ Arguments Description =========== -To enumerate media bus formats available at a given sub-device pad -applications initialize the ``pad``, ``which`` and ``index`` fields of -struct -:c:type:`v4l2_subdev_mbus_code_enum` and -call the :ref:`VIDIOC_SUBDEV_ENUM_MBUS_CODE` ioctl with a pointer to this -structure. Drivers fill the rest of the structure or return an ``EINVAL`` -error code if either the ``pad`` or ``index`` are invalid. All media bus -formats are enumerable by beginning at index zero and incrementing by -one until ``EINVAL`` is returned. +This call is used by the application to access the enumeration +of media bus formats for the selected pad. + +The enumerations are defined by the driver, and indexed using the ``index`` field +of struct :c:type:`v4l2_subdev_mbus_code_enum`. +Each enumeration starts with the ``index`` of 0, and +the lowest invalid index marks the end of enumeration. + +Therefore, to enumerate media bus formats available at a given sub-device pad, +initialize the ``pad``, and ``which`` fields to desired values, +and set ``index`` to 0. +Then call the :ref:`VIDIOC_SUBDEV_ENUM_MBUS_CODE` ioctl +with a pointer to this structure. + +A successful call will return with the ``code`` field filled in +with a mbus code value. +Repeat with increasing ``index`` until ``EINVAL`` is received. +``EINVAL`` means that either ``pad`` is invalid, +or that there are no more codes available at this pad. + +The driver must not return the same value of ``code`` for different indices +at the same pad. Available media bus formats may depend on the current 'try' formats at other pads of the sub-device, as well as on the current active links. @@ -57,14 +70,15 @@ information about the try formats. * - __u32 - ``pad`` - - Pad number as reported by the media controller API. + - Pad number as reported by the media controller API. Filled in by the application. * - __u32 - ``index`` - - Number of the format in the enumeration, set by the application. + - Index of the mbus code in the enumeration belonging to the given pad. + Filled in by the application. * - __u32 - ``code`` - The media bus format code, as defined in - :ref:`v4l2-mbus-format`. + :ref:`v4l2-mbus-format`. Filled in by the driver. * - __u32 - ``which`` - Media bus format codes to be enumerated, from enum From patchwork Sun Dec 11 13:02:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dorota Czaplejewicz X-Patchwork-Id: 32179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1758953wrr; Sun, 11 Dec 2022 05:07:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6OB0Y8Rc8ziZTNF0hDizXJ9w0WupTNJVeya6zd6kYp3NH0eUDheR9zxx6on3oVUc912K8v X-Received: by 2002:a17:906:bc58:b0:7c0:fd1a:79f0 with SMTP id s24-20020a170906bc5800b007c0fd1a79f0mr10497117ejv.21.1670764022745; Sun, 11 Dec 2022 05:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670764022; cv=none; d=google.com; s=arc-20160816; b=M7r5w0Pqq5ounFpyHk56qMXp1LJkPCZFXGQYAYRYEpG1NGDjl5ITWAlG1ZkzCVwlHc s/UZzOBcS+rzMv/S8mNGJFtSBLlJI85ZMD+bh3x9NRmXIgy2dC87aQmr5pRtxZqJzwp6 9wW2Dj3+Qa0y+SoNXPEoR7koBUwD2FV3o7QZoEYY87lZ7uUVL2zbx+tf2zzZkpR2j7gp iecW6jWT+ZrUddN7HOr/tRm6hkPyASlxeCwpslreCmYN5j/qwdIOIYfmmeIF7RkRXf07 jvIIo/MDSbZdI7SO7NSE+5j0nbSEPgV5aJyduwCZrmEGsadMFXxqTbYOHUVe5NGNHLNR 29Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:organization:references:in-reply-to :message-id:subject:to:from:dkim-signature:date; bh=g74YO+yyuM9gZ7bSMScyGL1d34+DCfxO5oh+iawE9zQ=; b=CSZqHV9Z5l8UFUQeui8GOEXhj1s3qjW13rIxrImeAu0HQawcvASZZjjNxA62pSADgi k1vua0b6vhidyuucRABjLFH0QDB4wbsBu96ak11G8XD0LZdwski97NVHfDJ3m/HBj/s/ CUnGoHyaMEfgIpsaEeOp1xkfSXDA0riKAH43aWfByRpc6G0vzJ6leLetEQixYUcNCg3V 35XtrIwht95YZcpjOoa7brIRc8cCax8J1NBJOMYj1nM0k3jPWuGIiZt6B0xy327ygo9p ebTgeXNakSHYSE20CQVnk6Zommv/AtYtCPSoZ1eTU8spZG9AREuo/EiW/S1G3gHIlQa1 OEIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@puri.sm header.s=comms header.b=R1h3ppXn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc38-20020a17090716a600b007c0b79e51casi4453672ejc.726.2022.12.11.05.06.38; Sun, 11 Dec 2022 05:07:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@puri.sm header.s=comms header.b=R1h3ppXn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbiLKNDC (ORCPT + 99 others); Sun, 11 Dec 2022 08:03:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiLKNC6 (ORCPT ); Sun, 11 Dec 2022 08:02:58 -0500 Received: from comms.puri.sm (comms.puri.sm [159.203.221.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27DD6B494; Sun, 11 Dec 2022 05:02:55 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 9309CEF95D; Sun, 11 Dec 2022 05:02:54 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LLMKInvpj9o2; Sun, 11 Dec 2022 05:02:53 -0800 (PST) Date: Sun, 11 Dec 2022 14:02:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=puri.sm; s=comms; t=1670763773; bh=i0g+3oryYH+bTrIcDnrXvCPR8IHUH6ivXegwOUCTJr8=; h=Date:From:To:Subject:In-Reply-To:References:From; b=R1h3ppXnvqwH42II/jPs2ZonYRC/ueCjjTydIr5+A1IGl3KCDSKZSDLlC2qunK9Zt XLy/Po5QR46esOiiwtLbInNzJ+ATqHc7Rpf6Bw9PcHNCNT+nxPuDB8++phKpm+oWar Cn8lvBziyw5Ma+xDVkXu1rEB0pnbzZ4EsOuZrTmAyevgZBXXCegxVi8bI8SACw2fO2 0h19hqAwm7NC6o4Jn0l9Kv9YMChlRXFq7T10/sxT18YKDpt4ZlqLYrRq7u7gjzcbsN 9kaKjRmdXCtwSSC0kIhoSs3WQzZMiWIY/2yDqx7eQX4xAjCZ3qbOZ44R3T61rCDX/Q lBFtyiGCRdXJg== From: Dorota Czaplejewicz To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@puri.sm Subject: [PATCHv3 2/2] media api: Try to make enum usage clearer Message-ID: <20221211125718.2815126-2-dorota.czaplejewicz@puri.sm> In-Reply-To: <20221211125718.2815126-1-dorota.czaplejewicz@puri.sm> References: <20221211125718.2815126-1-dorota.czaplejewicz@puri.sm> Organization: Purism MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751923055948232743?= X-GMAIL-MSGID: =?utf-8?q?1751923055948232743?= This clarifies which side of the calls is responsible for doing what to which parts of the struct. It also expands the terse description of the access algorithm into more prose-like, active voice description, which trades conciseness for ease of comprehension. Fixed: typo "format" -> "frame size" in enum-frame-size Added: no holes in the enumeration Added: enumerations per what? Added: who fills in what in calls Changed: "given" -> "specified" Signed-off-by: Dorota Czaplejewicz --- .../v4l/vidioc-subdev-enum-frame-size.rst | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst index c25a9896df0e..82b5d2538fa9 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst @@ -31,18 +31,30 @@ Arguments Description =========== -This ioctl allows applications to enumerate all frame sizes supported by -a sub-device on the given pad for the given media bus format. Supported -formats can be retrieved with the +This ioctl allows applications to access the enumeration of frame sizes +supported by a sub-device on the specified pad +for the specified media bus format. +Supported formats can be retrieved with the :ref:`VIDIOC_SUBDEV_ENUM_MBUS_CODE` ioctl. -To enumerate frame sizes applications initialize the ``pad``, ``which`` -, ``code`` and ``index`` fields of the struct -:c:type:`v4l2_subdev_mbus_code_enum` and -call the :ref:`VIDIOC_SUBDEV_ENUM_FRAME_SIZE` ioctl with a pointer to the -structure. Drivers fill the minimum and maximum frame sizes or return an -EINVAL error code if one of the input parameters is invalid. +The enumerations are defined by the driver, and indexed using the ``index`` field +of the struct :c:type:`v4l2_subdev_mbus_code_enum`. +Each pair of ``pad`` and ``code`` correspond to a separate enumeration. +Each enumeration starts with the ``index`` of 0, and +the lowest invalid index marks the end of the enumeration. + +Therefore, to enumerate frame sizes allowed on the specified pad +and using the specified mbus format, initialize the +``pad``, ``which``, and ``code`` fields to desired values, +and set ``index`` to 0. +Then call the :ref:`VIDIOC_SUBDEV_ENUM_FRAME_SIZE` ioctl with a pointer to the +structure. + +A successful call will return with minimum and maximum frame sizes filled in. +Repeat with increasing ``index`` until ``EINVAL`` is received. +``EINVAL`` means that either no more entries are available in the enumeration, +or that an input parameter was invalid. Sub-devices that only support discrete frame sizes (such as most sensors) will return one or more frame sizes with identical minimum and @@ -72,26 +84,28 @@ information about try formats. * - __u32 - ``index`` - - Number of the format in the enumeration, set by the application. + - Index of the frame size in the enumeration belonging to the given pad and format. + Filled in by the application. * - __u32 - ``pad`` - Pad number as reported by the media controller API. + Filled in by the application. * - __u32 - ``code`` - The media bus format code, as defined in - :ref:`v4l2-mbus-format`. + :ref:`v4l2-mbus-format`. Filled in by the application. * - __u32 - ``min_width`` - - Minimum frame width, in pixels. + - Minimum frame width, in pixels. Filled in by the driver. * - __u32 - ``max_width`` - - Maximum frame width, in pixels. + - Maximum frame width, in pixels. Filled in by the driver. * - __u32 - ``min_height`` - - Minimum frame height, in pixels. + - Minimum frame height, in pixels. Filled in by the driver. * - __u32 - ``max_height`` - - Maximum frame height, in pixels. + - Maximum frame height, in pixels. Filled in by the driver. * - __u32 - ``which`` - Frame sizes to be enumerated, from enum