linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Shengjiu Wang <shengjiu.wang@gmail.com>
Cc: Shengjiu Wang <shengjiu.wang@nxp.com>,
	vkoul@kernel.org, perex@perex.cz, tiwai@suse.com,
	alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, Xiubo.Lee@gmail.com,
	festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com,
	broonie@kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH v2 4/6] ASoC: fsl_asrc_m2m: Add memory to memory function
Date: Tue, 20 Aug 2024 08:59:04 +0200	[thread overview]
Message-ID: <ceb54a27-144b-40ed-8de5-482f2b0664a0@linux.intel.com> (raw)
In-Reply-To: <CAA+D8ANDAxS42=9zOLQY_h_ihvJCmaXzE+_iZyxbSuikqt1CBw@mail.gmail.com>



On 8/20/24 04:53, Shengjiu Wang wrote:
> On Mon, Aug 19, 2024 at 3:42 PM Pierre-Louis Bossart
> <pierre-louis.bossart@linux.intel.com> wrote:
>>
>>
>>
>> On 8/16/24 12:42, Shengjiu Wang wrote:
>>> Implement the ASRC memory to memory function using
>>> the compress framework, user can use this function with
>>> compress ioctl interface.
>>>
>>> Define below private metadata key value for output
>>> format, output rate and ratio modifier configuration.
>>> ASRC_OUTPUT_FORMAT 0x80000001
>>> ASRC_OUTPUT_RATE   0x80000002
>>> ASRC_RATIO_MOD     0x80000003
>>
>> Can the output format/rate change at run-time?
> 
> Seldom I think.
> 
>>
>> If no, then these parameters should be moved somewhere else - e.g.
>> hw_params or something.
> 
> This means I will do some changes in compress_params.h, add
> output format and output rate definition, follow Jaroslav's example
> right?

yes, having parameters for the PCM case would make sense.

>> I am still not very clear on the expanding the SET_METADATA ioctl to
>> deal with the ratio changes. This isn't linked to the control layer as
>> suggested before, and there's no precedent of calling it multiple times
>> during streaming.
> 
> Which control layer? if you means the snd_kcontrol_new?  it is bound
> with sound card,  but in my case,  I need to the control bind with
> the snd_compr_stream to support multi streams/instances.

I can only quote Jaroslav's previous answer:

"
This argument is not valid. The controls are bound to the card, but the
element identifiers have already iface (interface), device and subdevice
numbers. We are using controls for PCM devices for example. The binding
is straight.

Just add SNDRV_CTL_ELEM_IFACE_COMPRESS define and specify the compress
device number in the 'struct snd_ctl_elem_id'.
"

>> I also wonder how it was tested since tinycompress does not support this?
> 
> I wrote a unit test to test these ASRC M2M functions.

This should be shared IMHO, usually when we add/extend a new interface
it's best to have a userspace test program that can be used by others.

>>> +static int fsl_asrc_m2m_fill_codec_caps(struct fsl_asrc *asrc,
>>> +                                     struct snd_compr_codec_caps *codec)
>>> +{
>>> +     struct fsl_asrc_m2m_cap cap;
>>> +     __u32 rates[MAX_NUM_BITRATES];
>>> +     snd_pcm_format_t k;
>>> +     int i = 0, j = 0;
>>> +     int ret;
>>> +
>>> +     ret = asrc->m2m_get_cap(&cap);
>>> +     if (ret)
>>> +             return -EINVAL;
>>> +
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_5512)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_5512);
>>
>> this doesn't sound compatible with the patch2 definitions?
>>
>> cap->rate_in = SNDRV_PCM_RATE_8000_768000;
> 
> This ASRC M2M driver is designed for two kinds of hw ASRC modules.
> 
> one cap is : cap->rate_in = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_5512;
> another is : cap->rate_in = SNDRV_PCM_RATE_8000_768000;
> they are in patch2 and patch3
> 
> 
>>
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_8000)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_8000);
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_11025)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_11025);
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_16000)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_16000);
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_22050)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_22050);
>>
>> missing 24 kHz
> 
> There is no SNDRV_PCM_RATE_24000 in ALSA.

Right, but that doesn't mean 24kHz cannot be supported. We use
constraints in those cases. see quote from Takashi found with a 2s
Google search

https://mailman.alsa-project.org/pipermail/alsa-devel/2013-November/069356.html

"
CONTINUOUS means that any rate between the specified min and max is
fine, if no min or max is specified any rate is fine. KNOT means there
are rates supported other than the standard rates defines by ALSA, but
the other rates are enumerable. You'd typically specify them by
explicitly listing them all and use a list constraint or you'd use one
of the ratio constraints.
"

>>> +     if (cap.rate_in & SNDRV_PCM_RATE_32000)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_32000);
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_44100)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_44100);
>>> +     if (cap.rate_in & SNDRV_PCM_RATE_48000)
>>> +             rates[i++] = snd_pcm_rate_bit_to_rate(SNDRV_PCM_RATE_48000);
>>
>> missing 64kHz
> 
> Yes, will add it.



  reply	other threads:[~2024-08-20  6:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 10:42 [RFC PATCH v2 0/6] ASoC: fsl: add memory to memory function for ASRC Shengjiu Wang
2024-08-16 10:42 ` [RFC PATCH v2 1/6] ALSA: compress: reserve space in snd_compr_metadata.key for private usage Shengjiu Wang
2024-08-16 10:42 ` [RFC PATCH v2 2/6] ASoC: fsl_asrc: define functions for memory to memory usage Shengjiu Wang
2024-08-16 10:42 ` [RFC PATCH v2 3/6] ASoC: fsl_easrc: " Shengjiu Wang
2024-08-16 10:42 ` [RFC PATCH v2 4/6] ASoC: fsl_asrc_m2m: Add memory to memory function Shengjiu Wang
2024-08-19  6:42   ` Pierre-Louis Bossart
2024-08-20  2:53     ` Shengjiu Wang
2024-08-20  6:59       ` Pierre-Louis Bossart [this message]
2024-08-20  7:37         ` Shengjiu Wang
2024-08-20  7:42           ` Jaroslav Kysela
2024-08-20  7:52             ` Shengjiu Wang
2024-08-20  8:30             ` Pierre-Louis Bossart
2024-08-16 10:42 ` [RFC PATCH v2 5/6] ASoC: fsl_asrc: register m2m platform device Shengjiu Wang
2024-08-16 10:42 ` [RFC PATCH v2 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=ceb54a27-144b-40ed-8de5-482f2b0664a0@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).