linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Jaroslav Kysela <perex@perex.cz>,
	Shengjiu Wang <shengjiu.wang@gmail.com>
Cc: alsa-devel@alsa-project.org, Xiubo.Lee@gmail.com,
	lgirdwood@gmail.com, Shengjiu Wang <shengjiu.wang@nxp.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-sound@vger.kernel.org, tiwai@suse.com,
	nicoleotsuka@gmail.com, vkoul@kernel.org, broonie@kernel.org,
	festevam@gmail.com
Subject: Re: [RFC PATCH 1/6] ALSA: compress: add Sample Rate Converter codec support
Date: Fri, 9 Aug 2024 09:19:58 +0200	[thread overview]
Message-ID: <ed1192e0-00e7-4739-a687-c96dc2d62898@linux.intel.com> (raw)
In-Reply-To: <c9039808-cd04-452d-9f6c-f91811088456@perex.cz>


>>>> Then there's the issue of parameters, we chose to only add parameters
>>>> for standard encoders/decoders. Post-processing is highly specific and
>>>> the parameter definitions varies from one implementation to another -
>>>> and usually parameters are handled in an opaque way with binary
>>>> controls. This is best handled with a UUID that needs to be known only
>>>> to applications and low-level firmware/hardware, the kernel code should
>>>> not have to be modified for each and every processing and to add new
>>>> parameters. It just does not scale and it's unmaintainable.
>>>>
>>>> At the very least if you really want to use this compress API,
>>>> extend it
>>>> to use a non-descript "UUID-defined" type and an opaque set of
>>>> parameters with this UUID passed in a header.
>>>
>>> We don't need to use UUID-defined scheme for simple (A)SRC
>>> implementation. As I noted, the specific runtime controls may use
>>> existing ALSA control API.
>>
>> "Simple (A)SRC" is an oxymoron. There are multiple ways to define the
>> performance, and how the drift estimator is handled. There's nothing
>> simple if you look under the hood. The SOF implementation has for
>> example those parameters:
>>
>> uint32_t source_rate;           /**< Define fixed source rate or */
>>                 /**< use 0 to indicate need to get */
>>                 /**< the rate from stream */
>> uint32_t sink_rate;             /**< Define fixed sink rate or */
>>                 /**< use 0 to indicate need to get */
>>                 /**< the rate from stream */
>> uint32_t asynchronous_mode;     /**< synchronous 0, asynchronous 1 */
>>                 /**< When 1 the ASRC tracks and */
>>                 /**< compensates for drift. */
>> uint32_t operation_mode;        /**< push 0, pull 1, In push mode the */
>>                 /**< ASRC consumes a defined number */
>>                 /**< of frames at input, with varying */
>>                 /**< number of frames at output. */
>>                 /**< In pull mode the ASRC outputs */
>>                 /**< a defined number of frames while */
>>                 /**< number of input frames varies. */
>>
>> They are clearly different from what is suggested above with a 'ratio-
>> mod'.
> 
> I don't think so. The proposed (A)SRC for compress-accel is just one
> case for the above configs where the input is known and output is
> controlled by the requested rate. The I/O mechanism is abstracted enough
> in this case and the driver/hardware/firmware must follow it.

ASRC is usually added when the nominal rates are known but the clock
sources differ and the drift needs to be estimated at run-time and the
coefficients or interpolation modified dynamically

If the ratio is known exactly and there's no clock drift, then it's a
different problem where the filter coefficients are constant.

>> Same if you have a 'simple EQ'. there are dozens of ways to implement
>> the functionality with FIR, IIR or a combination of the two, and
>> multiple bands.
>>
>> The point is that you have to think upfront about a generic way to pass
>> parameters. We didn't have to do it for encoders/decoders because we
>> only catered to well-documented standard solutions only. By choosing to
>> support PCM processing, a new can of worms is now open.
>>
>> I repeat: please do not make the mistake of listing all processing with
>> an enum and a new structure for parameters every time someone needs a
>> specific transform in their pipeline. We made that mistake with SOF and
>> had to backtrack rather quickly. The only way to scale is an identifier
>> that is NOT included in the kernel code but is known to higher and
>> lower-levels only.
> 
> There are two ways - black box (UUID - as you suggested) - or well
> defined purpose (abstraction). For your example 'simple EQ', the
> parameters should be the band (frequency range) volume values. It's
> abstract and the real filters (resp. implementation) used behind may
> depend on the hardware/driver capabilities.

Indeed there is a possibility that the parameters are high-level, but
that would require firmware or hardware to be able to generate actual
coefficients from those parameters. That usually requires some advanced
math which isn't necessarily obvious to implement with fixed-point hardware.

> From my view, the really special cases may be handled as black box, but
> others like (A)SRC should follow some well-defined abstraction IMHO to
> not force user space to handle all special cases.

I am not against the high-level abstractions, e.g. along the lines of
what Android defined:
https://developer.android.com/reference/android/media/audiofx/AudioEffect

That's not sufficient however, we also need to make sure there's an
ability to provide pre-computed coefficients in an opaque manner for
processing that doesn't fit in the well-defined cases. In practice there
are very few 3rd party IP that fits in well-defined cases, everyone has
secret-sauce parameters and options.

  reply	other threads:[~2024-08-09  7:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 10:26 [RFC PATCH 0/6] ASoC: fsl: add memory to memory function for ASRC Shengjiu Wang
2024-08-06 10:26 ` [RFC PATCH 1/6] ALSA: compress: add Sample Rate Converter codec support Shengjiu Wang
2024-08-06 11:16   ` Pierre-Louis Bossart
2024-08-06 11:39     ` Jeff Brower
2024-08-08  9:17     ` Shengjiu Wang
2024-08-08 11:27       ` Pierre-Louis Bossart
2024-08-08 12:02         ` Jaroslav Kysela
2024-08-08 12:19           ` Pierre-Louis Bossart
2024-08-08 15:51             ` Jaroslav Kysela
2024-08-09  7:19               ` Pierre-Louis Bossart [this message]
2024-08-09 10:14                 ` Shengjiu Wang
2024-08-09 12:52                   ` Pierre-Louis Bossart
2024-08-09 14:00                     ` Jaroslav Kysela
2024-08-09 19:20                       ` Pierre-Louis Bossart
2024-08-12 10:24                       ` Shengjiu Wang
2024-08-12 13:31                         ` Jaroslav Kysela
2024-08-12 13:43                           ` Pierre-Louis Bossart
2024-08-14  2:22                             ` Shengjiu Wang
2024-08-14  9:40                               ` Pierre-Louis Bossart
2024-08-14 11:12                                 ` Shengjiu Wang
2024-08-14 11:58                                   ` Pierre-Louis Bossart
2024-08-14 14:48                                     ` Jaroslav Kysela
2024-08-09 13:51                   ` Jaroslav Kysela
2024-08-06 10:26 ` [RFC PATCH 2/6] ASoC: fsl_asrc: define functions for memory to memory usage Shengjiu Wang
2024-08-06 10:26 ` [RFC PATCH 3/6] ASoC: fsl_easrc: " Shengjiu Wang
2024-08-06 10:26 ` [RFC PATCH 4/6] ASoC: fsl_asrc_m2m: Add memory to memory function Shengjiu Wang
2024-08-06 10:26 ` [RFC PATCH 5/6] ASoC: fsl_asrc: register m2m platform device Shengjiu Wang
2024-08-06 10:26 ` [RFC PATCH 6/6] ASoC: fsl_easrc: " Shengjiu Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed1192e0-00e7-4739-a687-c96dc2d62898@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=Xiubo.Lee@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=festevam@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nicoleotsuka@gmail.com \
    --cc=perex@perex.cz \
    --cc=shengjiu.wang@gmail.com \
    --cc=shengjiu.wang@nxp.com \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).