Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2445048rdb; Wed, 15 Nov 2023 00:22:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFMchzLOjIxjQv++tICkhiOgbmiWf49GUJn4xeazjQpiQ+Jsfm4zJCOg8JdjKmVEbbpSDo X-Received: by 2002:a05:6a21:7894:b0:187:15e2:fdd9 with SMTP id bf20-20020a056a21789400b0018715e2fdd9mr3954263pzc.39.1700036577423; Wed, 15 Nov 2023 00:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700036577; cv=none; d=google.com; s=arc-20160816; b=sAABxVmEVMdsz/NaUWjPw/QmxxYFIXOiWq6lnKJqcRulGxCAQzH2KG8VXI0QIlderz d28kF6kQW7uhAUcFl0Y/bFHV1WHqaGL3gA5Tjlt9tLyeBWEcs7zD7vTGw1HA+d+cT21J 0oqlglFDnb4OoPn+VpJRpTQSC3H2O5GIXZS9gcIj2JV9AXsa4Bl77R6/EVepCPg3JU07 uX1oNCa2D3bRh7Hc3AvpUMbvRrMAVjoBCtVuSZuy7dWJauDY2ppvctind+VJAz35oxeC L6s+nHGDF0b/bNgieZg8Wghz3mgIDMIYsoph3vzWCRjBMgThkvnjFiTKqgBSdedmQSOT EOgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:to:content-language:subject:user-agent:mime-version :date:message-id; bh=/Lkv48UsGgDEcJpQOy6CgD+pvSOlMXyVA93CYX6zw08=; fh=xwO30vKhxPRRQG8HdZoJT6Bq3DaafZI8qtZCpJ3NFPI=; b=uDDpgyosOO2IbNa4OKuLflVZ3LDBwY9QvW37sX7Qz5MqEkY/4eoJL3iEVG+SNpwEzU KxzRpyxd1nyiYhAdd2XMEBTreUqFIRIHiV5w8qI2hDNge13lqrtrg9O8cXUNZz0Zk1Gi VQYxG1z6pFLA8oc6hgDvZuJhYMjBhiCYj96MdPx/OatjRLwknpRdwM41H1ew9MMhL0gc 5GAPzx5k/SanjBUf5Q+YgM8FYXhPPOyfu+MMq9nlhnY51GTP4bcITc6FuNYUtc9+zmvI rmj/VPYpHmot7tetCK3lFTllWFNKnjAwHuoY/Xit4A0ZsKsP5b+hytDAgfribpKzasOK /4dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id i21-20020aa78d95000000b0068e2566615esi9337680pfr.379.2023.11.15.00.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 00:22:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 764AF80320CF; Wed, 15 Nov 2023 00:22:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343499AbjKOIWp (ORCPT + 99 others); Wed, 15 Nov 2023 03:22:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234651AbjKOIWo (ORCPT ); Wed, 15 Nov 2023 03:22:44 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5916E5 for ; Wed, 15 Nov 2023 00:22:40 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2830CC433C8; Wed, 15 Nov 2023 08:22:36 +0000 (UTC) Message-ID: Date: Wed, 15 Nov 2023 09:22:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 10/15] media: uapi: Add V4L2_CTRL_TYPE_FIXED_POINT Content-Language: en-US, nl To: Shengjiu Wang , sakari.ailus@iki.fi, tfiga@chromium.org, m.szyprowski@samsung.com, mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org References: <1699595289-25773-1-git-send-email-shengjiu.wang@nxp.com> <1699595289-25773-11-git-send-email-shengjiu.wang@nxp.com> From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv3fn5xgzDw8Z222TfFceDL/2EzUyTdWc4GaPMC E/c1B4UOle6ZHg02+I8tZicjzj5+yffv1lB5A1btG+AmoZrgf0X2O1B96fqgHx8w9PIpVERN Ysmkfx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PY27XgtPxRxYj AmFUeF486PHx/2Yi4u1rQpIpC5inPxIgR1+ZFvQrAV36SvLFfuMhyCAxV6WBlQc85ArOiQZB Wm7L0repwr7zEJFEkdy8C81WRhMdPvHkAIh3RoY1SGcdB7rB3wCzfYkAuCBqaF7Zgfw8xkad KEiQTexRbM1sc/I8ACpla3N26SfQwrfg6V7TIoweP0RwDrcf5PVvwSWsRQp2LxFCkwnCXOra gYmkrmv0duG1FStpY+IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: <1699595289-25773-11-git-send-email-shengjiu.wang@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 15 Nov 2023 00:22:54 -0800 (PST) On 10/11/2023 06:48, Shengjiu Wang wrote: > Fixed point controls are used by the user to configure > a fixed point value in 64bits, which Q31.32 format. > > Signed-off-by: Shengjiu Wang > --- > .../userspace-api/media/v4l/vidioc-g-ext-ctrls.rst | 13 +++++++------ > .../userspace-api/media/v4l/vidioc-queryctrl.rst | 9 ++++++++- > .../userspace-api/media/videodev2.h.rst.exceptions | 1 + > drivers/media/v4l2-core/v4l2-ctrls-api.c | 5 ++++- > drivers/media/v4l2-core/v4l2-ctrls-core.c | 2 ++ > include/uapi/linux/videodev2.h | 1 + > 6 files changed, 23 insertions(+), 8 deletions(-) > > diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > index e8475f9fd2cf..e7e5d78dc11e 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst > @@ -162,13 +162,13 @@ still cause this situation. > * - __s32 > - ``value`` > - New value or current value. Valid if this control is not of type > - ``V4L2_CTRL_TYPE_INTEGER64`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is > - not set. > + ``V4L2_CTRL_TYPE_INTEGER64``, ``V4L2_CTRL_TYPE_FIXED_POINT`` and > + ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is not set. > * - __s64 > - ``value64`` > - New value or current value. Valid if this control is of type > - ``V4L2_CTRL_TYPE_INTEGER64`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is > - not set. > + ``V4L2_CTRL_TYPE_INTEGER64``, ``V4L2_CTRL_TYPE_FIXED_POINT`` and > + ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is not set. > * - char * > - ``string`` > - A pointer to a string. Valid if this control is of type > @@ -193,8 +193,9 @@ still cause this situation. > * - __s64 * > - ``p_s64`` > - A pointer to a matrix control of signed 64-bit values. Valid if > - this control is of type ``V4L2_CTRL_TYPE_INTEGER64`` and > - ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set. > + this control is of type ``V4L2_CTRL_TYPE_INTEGER64``, > + ``V4L2_CTRL_TYPE_FIXED_POINT`` and ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` > + is set. > * - struct :c:type:`v4l2_area` * > - ``p_area`` > - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is > diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > index 4d38acafe8e1..f3995ec57044 100644 > --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > @@ -235,7 +235,8 @@ See also the examples in :ref:`control`. > - ``default_value`` > - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_INTEGER64``, > ``_BOOLEAN``, ``_BITMASK``, ``_MENU``, ``_INTEGER_MENU``, ``_U8`` > - or ``_U16`` control. Not valid for other types of controls. > + ``_FIXED_POINT`` or ``_U16`` control. Not valid for other types of > + controls. > > .. note:: > > @@ -549,6 +550,12 @@ See also the examples in :ref:`control`. > - n/a > - A struct :c:type:`v4l2_ctrl_av1_film_grain`, containing AV1 Film Grain > parameters for stateless video decoders. > + * - ``V4L2_CTRL_TYPE_FIXED_POINT`` > + - any > + - any > + - any > + - A 64-bit integer valued control, containing parameter which is > + Q31.32 format. > > .. raw:: latex > > diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions > index e61152bb80d1..2faa5a2015eb 100644 > --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions > +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions > @@ -167,6 +167,7 @@ replace symbol V4L2_CTRL_TYPE_AV1_SEQUENCE :c:type:`v4l2_ctrl_type` > replace symbol V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY :c:type:`v4l2_ctrl_type` > replace symbol V4L2_CTRL_TYPE_AV1_FRAME :c:type:`v4l2_ctrl_type` > replace symbol V4L2_CTRL_TYPE_AV1_FILM_GRAIN :c:type:`v4l2_ctrl_type` > +replace symbol V4L2_CTRL_TYPE_FIXED_POINT :c:type:`v4l2_ctrl_type` > > # V4L2 capability defines > replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c > index 002ea6588edf..e6a0fb8d6791 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-api.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c > @@ -57,6 +57,7 @@ static int ptr_to_user(struct v4l2_ext_control *c, > return copy_to_user(c->string, ptr.p_char, len + 1) ? > -EFAULT : 0; > case V4L2_CTRL_TYPE_INTEGER64: > + case V4L2_CTRL_TYPE_FIXED_POINT:n > c->value64 = *ptr.p_s64; > break; > default: > @@ -132,6 +133,7 @@ static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) > > switch (ctrl->type) { > case V4L2_CTRL_TYPE_INTEGER64: > + case V4L2_CTRL_TYPE_FIXED_POINT: > *ctrl->p_new.p_s64 = c->value64; > break; > case V4L2_CTRL_TYPE_STRING: > @@ -540,7 +542,8 @@ static int validate_ctrls(struct v4l2_ext_controls *cs, > */ > if (ctrl->is_ptr) > continue; > - if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) > + if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64 || > + ctrl->type == V4L2_CTRL_TYPE_FIXED_POINT) > p_new.p_s64 = &cs->controls[i].value64; > else > p_new.p_s32 = &cs->controls[i].value; You missed a few more: everywhere in this source where V4L2_CTRL_TYPE_INTEGER64 is used you need to add a check for FIXED_POINT as well. > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c > index a662fb60f73f..9d50df0d9874 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c Same here for this source. Note that v4l2_ctrl_type_op_log() needs a separate case for FIXED_POINT so that it can be logged properly. > @@ -1187,6 +1187,7 @@ static int std_validate_elem(const struct v4l2_ctrl *ctrl, u32 idx, > case V4L2_CTRL_TYPE_INTEGER: > return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl); > case V4L2_CTRL_TYPE_INTEGER64: > + case V4L2_CTRL_TYPE_FIXED_POINT: > /* > * We can't use the ROUND_TO_RANGE define here due to > * the u64 divide that needs special care. > @@ -1779,6 +1780,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, > /* Prefill elem_size for all types handled by std_type_ops */ > switch ((u32)type) { > case V4L2_CTRL_TYPE_INTEGER64: > + case V4L2_CTRL_TYPE_FIXED_POINT: > elem_size = sizeof(s64); > break; > case V4L2_CTRL_TYPE_STRING: There is one more place where V4L2_CTRL_TYPE_INTEGER64 is used: drivers/media/v4l2-core/v4l2-ioctl.c. That should report a fixed point value in the same way as v4l2_ctrl_type_op_log(). > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index cf8c44595a1d..9482ac66a675 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -1903,6 +1903,7 @@ enum v4l2_ctrl_type { > V4L2_CTRL_TYPE_STRING = 7, > V4L2_CTRL_TYPE_BITMASK = 8, > V4L2_CTRL_TYPE_INTEGER_MENU = 9, > + V4L2_CTRL_TYPE_FIXED_POINT = 10, > > /* Compound types are >= 0x0100 */ > V4L2_CTRL_COMPOUND_TYPES = 0x0100, We will probably need a helper to create a fixed point value from the integer and fractional part, and one to extract them. Regards, Hans