Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp255484rdb; Thu, 19 Oct 2023 03:46:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOD2WAGL8nfBeP3oUpHHiJ3vhm5uR+W7k2Qcjvlo+dCE8+/tLuv8lrv2PAoDQjn2R9WWZ2 X-Received: by 2002:a17:902:e54e:b0:1c9:fdbf:296a with SMTP id n14-20020a170902e54e00b001c9fdbf296amr2329147plf.8.1697712361692; Thu, 19 Oct 2023 03:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697712361; cv=none; d=google.com; s=arc-20160816; b=sp3ppqwEbCLCJM/uFEbMI1VmCYEMW9VDmb6XfFzo1jvxZ7TOPBHQChSh5HUJo3qZlw uZ4aR0pXTYl9kO1IcI71aF4nEp7rrs5IC300uqCGXYwzXrti0/fjuJVehR1fGbtVQEmg kGkKggfoFvki2S31oqBnVa1HMeAKvZJA7Z/zGjHs67mUstO9k+30apKJfiVLzHxLwhm+ 2HPgTEWI2jygqERDXaK5dv1fFOdBmejsA3FVqcD+wte37T5918fzQrVfKqTzInecnXyW 3YsJckbWzpn2g0XcMt3Rcv8+kqfEBotO/kLTx8vx7Xyj2/SF5vdo0NqG18GfXZ2+B6id rtDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NT4JCAH2srbjF+FM/8pW8ddkcMPARuEjEdCDwNurqBc=; fh=O9UUzJPi8EOv62sI/lDG+RN+T0kfdG51kBf0zhN+b6g=; b=yms25uJMhABE31zfoO8jub5d6A8iJtG/CS+L0Z02XJ8vU1sJ53Mi4mFTMmShrODhFx E1IFAt3XmojXc8kGWVm4Ndk0RkvDZHg4OEwIE4LfIgG8RsXNWaOCyHkxTsPuAROqdAtj aStJdOiSnmO9edmg/UP/uAr+wtLlf7KIwhaPVynCJC5+PqnUSbCgsDiyveE5cgNP8uRw Tal2nehNOF2eViFrPibE2ybU0CzyHBroRfrHJQEofZPHN3F9o+/cumRbBoQ8dtqvRCyO FkIK91u8zrqz/MWnCwNLSAZYnUsEAfyGPyviuObsn9I2883CPGLzf7sIW4RftGyZ/vJ2 /+dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RMlYNCM2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id a7-20020a170902b58700b001ca85b996a7si1894720pls.192.2023.10.19.03.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:46:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RMlYNCM2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 179F9819973F; Thu, 19 Oct 2023 03:45:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344981AbjJSKon (ORCPT + 99 others); Thu, 19 Oct 2023 06:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232626AbjJSKol (ORCPT ); Thu, 19 Oct 2023 06:44:41 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA410119; Thu, 19 Oct 2023 03:44:38 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-27d1fa1c787so4806575a91.3; Thu, 19 Oct 2023 03:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697712278; x=1698317078; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NT4JCAH2srbjF+FM/8pW8ddkcMPARuEjEdCDwNurqBc=; b=RMlYNCM2GwT153lNtN1yBVW+ggrJU8J5h1q2S8/aQYk6QIGmGnH8xYXm7an1LXuuh6 QCMyXn1MC7vVkcCgNuQBN7BPsvGLBMrk77rpRnePX4sXTm1y11BIkp47VT+U7fMNALLh lyY6r9DAcQnBQuE5NCB6KLW/n/gVs9QFDDizsfE2T9fE8XMw6cKE0DjJBVDFZP0+8Ci1 EaHU8pwOv8B8mMiM5e3IMCOYKJGsmFpItBKYetTf7susItfiqzCusso8e2Qj6VWy6dim Nu0zE7ZxfveG6Uvagn+kS/EXt2YPBbMoR0w7iWPOJhtQgQuiho4Fa47qP9R39coI0EM9 dKQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697712278; x=1698317078; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NT4JCAH2srbjF+FM/8pW8ddkcMPARuEjEdCDwNurqBc=; b=gRG194QnJstlwWagsc/tRmT2VhXmIGaqzk/NsgI35rw7NOTGs6s9KTMSl0M0l5qKNZ 6FaakvOIdf4VSaVuV0TmueGnMU5E/mdVDtboFsOnLO8rlSSDnOojob8sL0HNSSHyb8Za ZLCj9YlsZDRixlg9ftniiQ22i3+LnJIrJTdAUy0Ckjt9JlaK10/OK1xZ0jB7qrn+352x GszY+eDFHjYKI+iOwS1hkRpFWDXdr61eXuGI242kL7JLPeGh4AyWEgk7ILL2Ys4W3bh5 2AUszMZ09NmNVRv2tl2IkCjhV8wkAWEYl+bFXZytAlQSPEdryQ1/wzmWH2BUYk4FXxv+ U6MQ== X-Gm-Message-State: AOJu0Yz/eQwU5CoZEHE2TW0sJwPlQYFMttkVYj3FlwTyNJSrEWUHxWjx X/ayFTMCO0MZv4zpy0yJaC2PgRjMObFuua6NOFk= X-Received: by 2002:a17:90a:aa93:b0:27d:51c4:1681 with SMTP id l19-20020a17090aaa9300b0027d51c41681mr1479084pjq.18.1697712278018; Thu, 19 Oct 2023 03:44:38 -0700 (PDT) MIME-Version: 1.0 References: <1697185865-27528-1-git-send-email-shengjiu.wang@nxp.com> <1697185865-27528-10-git-send-email-shengjiu.wang@nxp.com> <0ae6d9e1-bdd9-45ab-9749-8b0cb5c624ff@xs4all.nl> <36360a55-4cb4-4494-aa69-96837ba7750d@xs4all.nl> <90873bfe-f5c2-44b3-834e-2cea82cb3c48@xs4all.nl> In-Reply-To: <90873bfe-f5c2-44b3-834e-2cea82cb3c48@xs4all.nl> From: Shengjiu Wang Date: Thu, 19 Oct 2023 18:44:26 +0800 Message-ID: Subject: Re: [RFC PATCH v6 09/11] media: uapi: Add audio rate controls support To: Hans Verkuil Cc: 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, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 03:45:03 -0700 (PDT) On Wed, Oct 18, 2023 at 3:58=E2=80=AFPM Hans Verkuil w= rote: > > On 18/10/2023 09:40, Shengjiu Wang wrote: > > On Wed, Oct 18, 2023 at 3:31=E2=80=AFPM Hans Verkuil wrote: > >> > >> On 18/10/2023 09:23, Shengjiu Wang wrote: > >>> On Wed, Oct 18, 2023 at 10:27=E2=80=AFAM Shengjiu Wang wrote: > >>>> > >>>> On Tue, Oct 17, 2023 at 9:37=E2=80=AFPM Hans Verkuil wrote: > >>>>> > >>>>> On 17/10/2023 15:11, Shengjiu Wang wrote: > >>>>>> On Mon, Oct 16, 2023 at 9:16=E2=80=AFPM Hans Verkuil wrote: > >>>>>>> > >>>>>>> Hi Shengjiu, > >>>>>>> > >>>>>>> On 13/10/2023 10:31, Shengjiu Wang wrote: > >>>>>>>> Fixed point controls are used by the user to configure > >>>>>>>> the audio sample rate to driver. > >>>>>>>> > >>>>>>>> Add V4L2_CID_ASRC_SOURCE_RATE and V4L2_CID_ASRC_DEST_RATE > >>>>>>>> new IDs for ASRC rate control. > >>>>>>>> > >>>>>>>> Signed-off-by: Shengjiu Wang > >>>>>>>> --- > >>>>>>>> .../userspace-api/media/v4l/common.rst | 1 + > >>>>>>>> .../media/v4l/ext-ctrls-fixed-point.rst | 36 ++++++++++++= +++++++ > >>>>>>>> .../media/v4l/vidioc-g-ext-ctrls.rst | 4 +++ > >>>>>>>> .../media/v4l/vidioc-queryctrl.rst | 7 ++++ > >>>>>>>> .../media/videodev2.h.rst.exceptions | 1 + > >>>>>>>> drivers/media/v4l2-core/v4l2-ctrls-core.c | 5 +++ > >>>>>>>> drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 +++ > >>>>>>>> include/media/v4l2-ctrls.h | 2 ++ > >>>>>>>> include/uapi/linux/v4l2-controls.h | 13 +++++++ > >>>>>>>> include/uapi/linux/videodev2.h | 3 ++ > >>>>>>>> 10 files changed, 76 insertions(+) > >>>>>>>> create mode 100644 Documentation/userspace-api/media/v4l/ext-ct= rls-fixed-point.rst > >>>>>>>> > >>>>>>>> diff --git a/Documentation/userspace-api/media/v4l/common.rst b/= Documentation/userspace-api/media/v4l/common.rst > >>>>>>>> index ea0435182e44..35707edffb13 100644 > >>>>>>>> --- a/Documentation/userspace-api/media/v4l/common.rst > >>>>>>>> +++ b/Documentation/userspace-api/media/v4l/common.rst > >>>>>>>> @@ -52,6 +52,7 @@ applicable to all devices. > >>>>>>>> ext-ctrls-fm-rx > >>>>>>>> ext-ctrls-detect > >>>>>>>> ext-ctrls-colorimetry > >>>>>>>> + ext-ctrls-fixed-point > >>>>>>> > >>>>>>> Rename this to ext-ctrls-audio-m2m. > >>>>>>> > >>>>>>>> fourcc > >>>>>>>> format > >>>>>>>> planar-apis > >>>>>>>> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-fix= ed-point.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-fixed-point.= rst > >>>>>>>> new file mode 100644 > >>>>>>>> index 000000000000..2ef6e250580c > >>>>>>>> --- /dev/null > >>>>>>>> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-fixed-poin= t.rst > >>>>>>>> @@ -0,0 +1,36 @@ > >>>>>>>> +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later > >>>>>>>> + > >>>>>>>> +.. _fixed-point-controls: > >>>>>>>> + > >>>>>>>> +*************************** > >>>>>>>> +Fixed Point Control Reference > >>>>>>> > >>>>>>> This is for audio controls. "Fixed Point" is just the type, and i= t doesn't make > >>>>>>> sense to group fixed point controls. But it does make sense to gr= oup the audio > >>>>>>> controls. > >>>>>>> > >>>>>>> V4L2 controls can be grouped into classes. Basically it is a way = to put controls > >>>>>>> into categories, and for each category there is also a control th= at gives a > >>>>>>> description of the class (see 2.15.15 in > >>>>>>> https://linuxtv.org/downloads/v4l-dvb-apis-new/driver-api/v4l2-co= ntrols.html#introduction) > >>>>>>> > >>>>>>> If you use e.g. 'v4l2-ctl -l' to list all the controls, then you = will see that > >>>>>>> they are grouped based on what class of control they are. > >>>>>>> > >>>>>>> So I think it would be a good idea to create a new control class = for M2M audio controls, > >>>>>>> instead of just adding them to the catch-all 'User Controls' clas= s. > >>>>>>> > >>>>>>> Search e.g. for V4L2_CTRL_CLASS_COLORIMETRY and V4L2_CID_COLORIME= TRY_CLASS to see how > >>>>>>> it is done. > >>>>>>> > >>>>>>> M2M_AUDIO would probably be a good name for the class. > >>>>>>> > >>>>>>>> +*************************** > >>>>>>>> + > >>>>>>>> +These controls are intended to support an asynchronous sample > >>>>>>>> +rate converter. > >>>>>>> > >>>>>>> Add ' (ASRC).' at the end to indicate the common abbreviation for > >>>>>>> that. > >>>>>>> > >>>>>>>> + > >>>>>>>> +.. _v4l2-audio-asrc: > >>>>>>>> + > >>>>>>>> +``V4L2_CID_ASRC_SOURCE_RATE`` > >>>>>>>> + sets the resampler source rate. > >>>>>>>> + > >>>>>>>> +``V4L2_CID_ASRC_DEST_RATE`` > >>>>>>>> + sets the resampler destination rate. > >>>>>>> > >>>>>>> Document the unit (Hz) for these two controls. > >>>>>>> > >>>>>>>> + > >>>>>>>> +.. c:type:: v4l2_ctrl_fixed_point > >>>>>>>> + > >>>>>>>> +.. cssclass:: longtable > >>>>>>>> + > >>>>>>>> +.. tabularcolumns:: |p{1.5cm}|p{5.8cm}|p{10.0cm}| > >>>>>>>> + > >>>>>>>> +.. flat-table:: struct v4l2_ctrl_fixed_point > >>>>>>>> + :header-rows: 0 > >>>>>>>> + :stub-columns: 0 > >>>>>>>> + :widths: 1 1 2 > >>>>>>>> + > >>>>>>>> + * - __u32 > >>>>>>> > >>>>>>> Hmm, shouldn't this be __s32? > >>>>>>> > >>>>>>>> + - ``integer`` > >>>>>>>> + - integer part of fixed point value. > >>>>>>>> + * - __s32 > >>>>>>> > >>>>>>> and this __u32? > >>>>>>> > >>>>>>> You want to be able to use this generic type as a signed value. > >>>>>>> > >>>>>>>> + - ``fractional`` > >>>>>>>> + - fractional part of fixed point value, which is Q31. > >>>>>>>> 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 f9f73530a6be..1811dabf5c74 100644 > >>>>>>>> --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.r= st > >>>>>>>> +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.r= st > >>>>>>>> @@ -295,6 +295,10 @@ still cause this situation. > >>>>>>>> - ``p_av1_film_grain`` > >>>>>>>> - A pointer to a struct :c:type:`v4l2_ctrl_av1_film_grain= `. Valid if this control is > >>>>>>>> of type ``V4L2_CTRL_TYPE_AV1_FILM_GRAIN``. > >>>>>>>> + * - struct :c:type:`v4l2_ctrl_fixed_point` * > >>>>>>>> + - ``p_fixed_point`` > >>>>>>>> + - A pointer to a struct :c:type:`v4l2_ctrl_fixed_point`. = Valid if this control is > >>>>>>>> + of type ``V4L2_CTRL_TYPE_FIXED_POINT``. > >>>>>>>> * - void * > >>>>>>>> - ``ptr`` > >>>>>>>> - A pointer to a compound type which can be an N-dimensio= nal array > >>>>>>>> diff --git a/Documentation/userspace-api/media/v4l/vidioc-queryc= trl.rst b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > >>>>>>>> index 4d38acafe8e1..9285f4f39eed 100644 > >>>>>>>> --- a/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > >>>>>>>> +++ b/Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst > >>>>>>>> @@ -549,6 +549,13 @@ 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`` > >>>>>>>> + - n/a > >>>>>>>> + - n/a > >>>>>>>> + - n/a > >>>>>>>> + - A struct :c:type:`v4l2_ctrl_fixed_point`, containing pa= rameter which has > >>>>>>>> + integer part and fractional part, i.e. audio sample rat= e. > >>>>>>>> + > >>>>>>>> > >>>>>>>> .. raw:: latex > >>>>>>>> > >>>>>>>> diff --git a/Documentation/userspace-api/media/videodev2.h.rst.e= xceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions > >>>>>>>> index e61152bb80d1..2faa5a2015eb 100644 > >>>>>>>> --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptio= ns > >>>>>>>> +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptio= ns > >>>>>>>> @@ -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:`v4l= 2_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_ty= pe` > >>>>>>>> > >>>>>>>> # V4L2 capability defines > >>>>>>>> replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities > >>>>>>>> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers= /media/v4l2-core/v4l2-ctrls-core.c > >>>>>>>> index a662fb60f73f..7a616ac91059 100644 > >>>>>>>> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > >>>>>>>> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c > >>>>>>>> @@ -1168,6 +1168,8 @@ static int std_validate_compound(const str= uct v4l2_ctrl *ctrl, u32 idx, > >>>>>>>> if (!area->width || !area->height) > >>>>>>>> return -EINVAL; > >>>>>>>> break; > >>>>>>>> + case V4L2_CTRL_TYPE_FIXED_POINT: > >>>>>>>> + break; > >>>>>>> > >>>>>>> Hmm, this would need this patch 'v4l2-ctrls: add support for V4L2= _CTRL_WHICH_MIN/MAX_VAL': > >>>>>>> > >>>>>>> https://patchwork.linuxtv.org/project/linux-media/patch/202310100= 22136.1504015-7-yunkec@google.com/ > >>>>>>> > >>>>>>> since min and max values are perfectly fine for a fixed point val= ue. > >>>>>>> > >>>>>>> Even a step value (currently not supported in that patch) would m= ake sense. > >>>>>>> > >>>>>>> But I wonder if we couldn't simplify this: instead of creating a = v4l2_ctrl_fixed_point, > >>>>>>> why not represent the fixed point value as a Q31.32. Then the sta= ndard > >>>>>>> minimum/maximum/step values can be used, and it acts like a regul= ar V4L2_TYPE_INTEGER64. > >>>>>>> > >>>>>>> Except that both userspace and drivers need to multiply it with 2= ^-32 to get the actual > >>>>>>> value. > >>>>>>> > >>>>>>> So in enum v4l2_ctrl_type add: > >>>>>>> > >>>>>>> V4L2_CTRL_TYPE_FIXED_POINT =3D 10, > >>>>>>> > >>>>>>> (10, because it is no longer a compound type). > >>>>>> > >>>>>> Seems we don't need V4L2_CTRL_TYPE_FIXED_POINT, just use V4L2_TYPE= _INTEGER64? > >>>>>> > >>>>>> The reason I use the 'integer' and 'fractional' is that I want > >>>>>> 'integer' to be the normal sample > >>>>>> rate, for example 48kHz. The 'fractional' is the difference with > >>>>>> normal sample rate. > >>>>>> > >>>>>> For example, the rate =3D 47998.12345. so integer =3D 48000, fra= ctional=3D -1.87655. > >>>>>> > >>>>>> So if we use s64 for rate, then in driver need to convert the rate= to > >>>>>> the closed normal > >>>>>> sample rate + fractional. > >>>>> > >>>>> That wasn't what the documentation said :-) > >>>>> > >>>>> So this is really two controls: one for the 'normal sample rate' (w= hatever 'normal' > >>>>> means in this context) and the offset to the actual sample rate. > >>>>> > >>>>> Presumably the 'normal' sample rate is set once, while the offset c= hanges > >>>>> regularly. > >>>>> > >>>>> But why do you need the 'normal' sample rate? With audio resampling= I assume > >>>>> you resample from one rate to another, so why do you need a third '= normal' > >>>>> rate? > >>>>> > >>>> > >>>> 'Normal' rate is used to select the prefilter table. > >>>> > >>> > >>> Currently I think we may define > >>> V4L2_CID_M2M_AUDIO_SOURCE_RATE > >>> V4L2_CID_M2M_AUDIO_DEST_RATE > >> > >> That makes sense. > >> > >>> V4L2_CID_M2M_AUDIO_ASRC_RATIO_MOD > >> > >> OK, can you document this control? Just write it down in the reply, I = just want > >> to understand how the integer value you set here is used. > >> > > > > It is Q31 value. It is equal to: > > in_rate_new / out_rate_new - in_rate_old / out_rate_old > > So that's not an integer. Also, Q31 is limited to -1...1, and I think > that's too limiting. > > For this having a Q31.32 fixed point type still makes a lot of sense. Can we use V4L2_CTRL_TYPE_INTEGER64 for Q31.32? or still need to define V4L2_CTRL_TYPE_FIXED_POINT? best regards wang shengjiu > > I still feel this is a overly complicated API. > > See more below... > > > > > Best regards > > Wang shengjiu > > > >> Regards, > >> > >> Hans > >> > >>> > >>> All of them can be V4L2_CTRL_TYPE_INTEGER. > >>> > >>> RATIO_MOD was defined in the very beginning version. > >>> I think it is better to let users calculate this value. > >>> > >>> The reason is: > >>> if we define the offset for source rate and dest rate in > >>> driver separately, when offset of source rate is set, > >>> driver don't know if it needs to wait or not the dest rate > >>> offset, then go to calculate the ratio_mod. > > Ah, in order to update the ratio mod userspace needs to set both source a= nd > dest rate at the same time to avoid race conditions. > > That is perfectly possible in the V4L2 control framework. See: > > https://linuxtv.org/downloads/v4l-dvb-apis-new/driver-api/v4l2-controls.h= tml#control-clusters > > In practice, isn't it likely that you would fix either the source or > destination rate, and let the other rate fluctuate? It kind of feels weir= d > to me that both source AND destination rates can fluctuate over time. > > In any case, with a control cluster it doesn't really matter, you can set > one rate or both rates, and it will be handled atomically. > > I feel that the RATIO_MOD control is too hardware specific. This is somet= hing > that should be hidden in the driver. > > Regards, > > Hans > > >>> > >>> best regards > >>> wang shengjiu > >>> > >>>> Best regards > >>>> Wang Shengjiu > >>>> > >>>>> Regards, > >>>>> > >>>>> Hans > >>>>> > >>>>>> > >>>>>> best regards > >>>>>> wang shengjiu > >>>>>> > >>>>>>> > >>>>>>>> > >>>>>>>> default: > >>>>>>>> return -EINVAL; > >>>>>>>> @@ -1868,6 +1870,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(str= uct v4l2_ctrl_handler *hdl, > >>>>>>>> case V4L2_CTRL_TYPE_AREA: > >>>>>>>> elem_size =3D sizeof(struct v4l2_area); > >>>>>>>> break; > >>>>>>>> + case V4L2_CTRL_TYPE_FIXED_POINT: > >>>>>>>> + elem_size =3D sizeof(struct v4l2_ctrl_fixed_point)= ; > >>>>>>>> + break; > >>>>>>>> default: > >>>>>>>> if (type < V4L2_CTRL_COMPOUND_TYPES) > >>>>>>>> elem_size =3D sizeof(s32); > >>>>>>>> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers= /media/v4l2-core/v4l2-ctrls-defs.c > >>>>>>>> index 8696eb1cdd61..d8f232df6b6a 100644 > >>>>>>>> --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > >>>>>>>> +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > >>>>>>>> @@ -1602,6 +1602,10 @@ void v4l2_ctrl_fill(u32 id, const char **= name, enum v4l2_ctrl_type *type, > >>>>>>>> case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: > >>>>>>>> *type =3D V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY; > >>>>>>>> break; > >>>>>>>> + case V4L2_CID_ASRC_SOURCE_RATE: > >>>>>>>> + case V4L2_CID_ASRC_DEST_RATE: > >>>>>>>> + *type =3D V4L2_CTRL_TYPE_FIXED_POINT; > >>>>>>>> + break; > >>>>>>>> default: > >>>>>>>> *type =3D V4L2_CTRL_TYPE_INTEGER; > >>>>>>>> break; > >>>>>>>> diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctr= ls.h > >>>>>>>> index 59679a42b3e7..645e4cccafc7 100644 > >>>>>>>> --- a/include/media/v4l2-ctrls.h > >>>>>>>> +++ b/include/media/v4l2-ctrls.h > >>>>>>>> @@ -56,6 +56,7 @@ struct video_device; > >>>>>>>> * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry= structure. > >>>>>>>> * @p_av1_frame: Pointer to an AV1 frame structure. > >>>>>>>> * @p_av1_film_grain: Pointer to an AV1 film gra= in structure. > >>>>>>>> + * @p_fixed_point: Pointer to a struct v4l2_ctrl_fixe= d_point. > >>>>>>>> * @p: Pointer to a compound valu= e. > >>>>>>>> * @p_const: Pointer to a constant compound val= ue. > >>>>>>>> */ > >>>>>>>> @@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { > >>>>>>>> struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_en= try; > >>>>>>>> struct v4l2_ctrl_av1_frame *p_av1_frame; > >>>>>>>> struct v4l2_ctrl_av1_film_grain *p_av1_film_grain; > >>>>>>>> + struct v4l2_ctrl_fixed_point *p_fixed_point; > >>>>>>>> void *p; > >>>>>>>> const void *p_const; > >>>>>>>> }; > >>>>>>>> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/l= inux/v4l2-controls.h > >>>>>>>> index c3604a0a3e30..91096259e3ea 100644 > >>>>>>>> --- a/include/uapi/linux/v4l2-controls.h > >>>>>>>> +++ b/include/uapi/linux/v4l2-controls.h > >>>>>>>> @@ -112,6 +112,8 @@ enum v4l2_colorfx { > >>>>>>>> > >>>>>>>> /* last CID + 1 */ > >>>>>>>> #define V4L2_CID_LASTP1 (V4L2_CID_BASE+= 44) > >>>>>>>> +#define V4L2_CID_ASRC_SOURCE_RATE (V4L2_CID_BASE + 4= 5) > >>>>>>>> +#define V4L2_CID_ASRC_DEST_RATE (V4L2_CID_= BASE + 46) > >>>>>>> > >>>>>>> This patch needs to be split in three parts: > >>>>>>> > >>>>>>> 1) Add the new M2M_AUDIO control class, > >>>>>>> 2) Add the new V4L2_CTRL_TYPE_FIXED_POINT type, > >>>>>>> 3) Add the new controls. > >>>>>>> > >>>>>>> These are all independent changes, so separating them makes it ea= sier to > >>>>>>> review. > >>>>>>> > >>>>>>>> > >>>>>>>> /* USER-class private control IDs */ > >>>>>>>> > >>>>>>>> @@ -3488,4 +3490,15 @@ struct v4l2_ctrl_av1_film_grain { > >>>>>>>> #define V4L2_CID_MPEG_MFC51_BASE V4L2_CID_CODEC_MFC51_BA= SE > >>>>>>>> #endif > >>>>>>>> > >>>>>>>> +/** > >>>>>>>> + * struct v4l2_ctrl_fixed_point - fixed point parameter. > >>>>>>>> + * > >>>>>>>> + * @rate_integer: integer part of fixed point value. > >>>>>>>> + * @rate_fractional: fractional part of fixed point value > >>>>>>>> + */ > >>>>>>>> +struct v4l2_ctrl_fixed_point { > >>>>>>>> + __u32 integer; > >>>>>>> > >>>>>>> __s32? > >>>>>>> > >>>>>>>> + __u32 fractional; > >>>>>>>> +}; > >>>>>>>> + > >>>>>>>> #endif > >>>>>>>> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux= /videodev2.h > >>>>>>>> index 2ac7b989394c..3ef32c09c2fa 100644 > >>>>>>>> --- a/include/uapi/linux/videodev2.h > >>>>>>>> +++ b/include/uapi/linux/videodev2.h > >>>>>>>> @@ -1888,6 +1888,7 @@ struct v4l2_ext_control { > >>>>>>>> struct v4l2_ctrl_av1_tile_group_entry __user *p_av= 1_tile_group_entry; > >>>>>>>> struct v4l2_ctrl_av1_frame __user *p_av1_frame; > >>>>>>>> struct v4l2_ctrl_av1_film_grain __user *p_av1_film= _grain; > >>>>>>>> + struct v4l2_ctrl_fixed_point __user *p_fixed_point= ; > >>>>>>>> void __user *ptr; > >>>>>>>> }; > >>>>>>>> } __attribute__ ((packed)); > >>>>>>>> @@ -1966,6 +1967,8 @@ enum v4l2_ctrl_type { > >>>>>>>> V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY =3D 0x281, > >>>>>>>> V4L2_CTRL_TYPE_AV1_FRAME =3D 0x282, > >>>>>>>> V4L2_CTRL_TYPE_AV1_FILM_GRAIN =3D 0x283, > >>>>>>>> + > >>>>>>>> + V4L2_CTRL_TYPE_FIXED_POINT =3D 0x290, > >>>>>>>> }; > >>>>>>>> > >>>>>>>> /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ > >>>>>>> > >>>>>>> Regards, > >>>>>>> > >>>>>>> Hans > >>>>> > >> >