* [RFC] ASoC: soc-core: proposal to remove num_auto_selectable_formats from snd_soc_dai_ops
@ 2025-10-31 4:56 HariKrishna Sagala
2025-10-31 6:58 ` Kuninori Morimoto
0 siblings, 1 reply; 3+ messages in thread
From: HariKrishna Sagala @ 2025-10-31 4:56 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx
Cc: shuah, david.hunter.linux, linux-sound, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]
Hi,
Good day.
I’d like to propose a small cleanup and simplification in the
snd_soc_dai_ops structure by removing the
"num_auto_selectable_formats" parameter.
Context:
Currently,snd_soc_dai_ops includes the "num_auto_selectable_formats"
field to indicate the number of entries in the "auto_selectable_formats"
array.However, this count can be derived programmatically using the
ARRAY_SIZE() macro wherever needed.
Proposal:
Remove the "num_auto_selectable_formats" field from the
snd_soc_dai_ops structure.Replace usage references to this field with
ARRAY_SIZE(auto_selectable_formats) in the relevant code paths.
One effect I see is if the parameter "auto_selectable_formats" has
only one priority format because few codecs are defined as a u64
variable,will correct and prepare a patch.
Please provide suggestions, objections and also to consider any
compatibility problems,historic importance of same.
If there are no objections, I would like to prepare a patch for
the same.
Thanks.
Regards,
HariKrishna.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] ASoC: soc-core: proposal to remove num_auto_selectable_formats from snd_soc_dai_ops
2025-10-31 4:56 [RFC] ASoC: soc-core: proposal to remove num_auto_selectable_formats from snd_soc_dai_ops HariKrishna Sagala
@ 2025-10-31 6:58 ` Kuninori Morimoto
2025-10-31 14:15 ` harikrishna
0 siblings, 1 reply; 3+ messages in thread
From: Kuninori Morimoto @ 2025-10-31 6:58 UTC (permalink / raw)
To: HariKrishna Sagala
Cc: lgirdwood, broonie, perex, tiwai, shuah, david.hunter.linux,
linux-sound, linux-kernel
Hi HariKrishna
Thank you for suggestion
> Iʼd like to propose a small cleanup and simplification in the
> snd_soc_dai_ops structure by removing the
> "num_auto_selectable_formats" parameter.
Do you mean like this ?
struct snd_soc_dai_ops {
...
const u64 *auto_selectable_formats;
- int num_auto_selectable_formats;
...
};
> Currently,snd_soc_dai_ops includes the "num_auto_selectable_formats"
> field to indicate the number of entries in the "auto_selectable_formats"
> array.However, this count can be derived programmatically using the
> ARRAY_SIZE() macro wherever needed.
If my understanding was correct, unfortunately we can't do it.
We can use ARRAY_SIZE() in each driver, because we can access to raw array.
But can't use it on ASoC framework, becase auto_selectable_formats is just
a pointer. see how ARRAY_SIZE() is defined.
--- driver ---
my_formats[] = {
[0] = SND_SOC_POSSIBLE_DAIFMT_xxx | SND_SOC_POSSIBLE_DAIFMT_xxx ...,
[1] = SND_SOC_POSSIBLE_DAIFMT_xxx | SND_SOC_POSSIBLE_DAIFMT_xxx ...,
};
// We can use ARRAY_SIZE() in driver, because we know raw array.
my_dai_ops = {
...
.auto_selectable_formats = my_formats,
=> .num_auto_selectable_formats = ARRAY_SIZE(my_formats),
};
--- soc-xxx.c ---
// it will be error, because we don't know its size
=> int num = ARRAY_SIZE(ops->auto_selectable_formats);
Or do you mean create new macro, like this ?
#define ASOC_SELECT_FORMATS(array)\
.auto_selectable_formats = array,
.num_auto_selectable_formats = ARRAY_SIZE(array)
my_ops = {
...
- .auto_selectable_formats = my_formats,
- .num_auto_selectable_formats = ARRAY_SIZE(my_formats),
+ ASOC_SELECT_FORMATS(my_formats),
};
Or am I misunderstanding your suggestion ?
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] ASoC: soc-core: proposal to remove num_auto_selectable_formats from snd_soc_dai_ops
2025-10-31 6:58 ` Kuninori Morimoto
@ 2025-10-31 14:15 ` harikrishna
0 siblings, 0 replies; 3+ messages in thread
From: harikrishna @ 2025-10-31 14:15 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: lgirdwood, broonie, perex, tiwai, shuah, david.hunter.linux,
linux-sound, linux-kernel
On Fri, Oct 31, 2025 at 12:28 PM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>
>
> Hi HariKrishna
>
> Thank you for suggestion
>
> > Iʼd like to propose a small cleanup and simplification in the
> > snd_soc_dai_ops structure by removing the
> > "num_auto_selectable_formats" parameter.
>
> Do you mean like this ?
>
> struct snd_soc_dai_ops {
> ...
> const u64 *auto_selectable_formats;
> - int num_auto_selectable_formats;
> ...
> };
>
> > Currently,snd_soc_dai_ops includes the "num_auto_selectable_formats"
> > field to indicate the number of entries in the "auto_selectable_formats"
> > array.However, this count can be derived programmatically using the
> > ARRAY_SIZE() macro wherever needed.
>
> If my understanding was correct, unfortunately we can't do it.
>
> We can use ARRAY_SIZE() in each driver, because we can access to raw array.
> But can't use it on ASoC framework, becase auto_selectable_formats is just
> a pointer. see how ARRAY_SIZE() is defined.
>
> --- driver ---
> my_formats[] = {
> [0] = SND_SOC_POSSIBLE_DAIFMT_xxx | SND_SOC_POSSIBLE_DAIFMT_xxx ...,
> [1] = SND_SOC_POSSIBLE_DAIFMT_xxx | SND_SOC_POSSIBLE_DAIFMT_xxx ...,
> };
>
> // We can use ARRAY_SIZE() in driver, because we know raw array.
> my_dai_ops = {
> ...
> .auto_selectable_formats = my_formats,
> => .num_auto_selectable_formats = ARRAY_SIZE(my_formats),
> };
>
> --- soc-xxx.c ---
> // it will be error, because we don't know its size
> => int num = ARRAY_SIZE(ops->auto_selectable_formats);
>
> Or do you mean create new macro, like this ?
>
> #define ASOC_SELECT_FORMATS(array)\
> .auto_selectable_formats = array,
> .num_auto_selectable_formats = ARRAY_SIZE(array)
>
> my_ops = {
> ...
> - .auto_selectable_formats = my_formats,
> - .num_auto_selectable_formats = ARRAY_SIZE(my_formats),
> + ASOC_SELECT_FORMATS(my_formats),
> };
>
> Or am I misunderstanding your suggestion ?
>
>
> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto
Hi Kuninori Morimoto,
Yes, you are right.
I have got it now.
We can use it in codec driver not in framework.
Thought of changing the type of "U64 *auto_selectable_formats" to
"U64 (*auto_selectable_formats)[]" and removing the
"num_auto_selectable_formats".
But cannot be used to get count. Apologies for this.
Thanks for the guidance.
Regards,
HariKrishna.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-31 14:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 4:56 [RFC] ASoC: soc-core: proposal to remove num_auto_selectable_formats from snd_soc_dai_ops HariKrishna Sagala
2025-10-31 6:58 ` Kuninori Morimoto
2025-10-31 14:15 ` harikrishna
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).