Skip to content

Conversation

@jsarha
Copy link

@jsarha jsarha commented Mar 7, 2023

I've been trying to find a clean and elegant way to do this for a while now. Not sure if this is it. I still have trouble in seeing the big picture on how the dapm widgets are pulled together by SOF driver based on the used topology. But at least this is not very intrusive, when it comes to generic ASoC code. @ranj063 , @lgirdwood, @ujfalusi what do you think?

This is associated with this topology PR: thesofproject/sof#7227

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two branch does the same thing?
if (shared || w->kcontrol_name_no_prefix)?

Copy link
Collaborator

@ujfalusi ujfalusi Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this work similarly, but earlier:

if (w->kcontrol_name_no_prefix) {
	prefix_len = 0;
} else {
	prefix = soc_dapm_prefix(dapm);
	if (prefix)
		prefix_len = strlen(prefix) + 1;
	else
		prefix_len = 0;
}

Answer: No, the prefix is not this prefix.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsarha, so the flag is ignore_wname_in_long_name
and you can just simply:

if (w->ignore_wname_in_long_name)
	wname_in_long_name = false;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed "ignore_wname_in_long_name" to "no_wname_in_long_name", to make the flag name a bit shorter, but otherwise applied.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_token_nop() / nop_get_token() The get_token_void() is hard to put in place, it is to get void data?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it more like drop_kcontrol_prefix in essense, or ingore_prefix?

@jsarha jsarha force-pushed the kcontrol_name_no_prefix branch from 2469872 to 50193c5 Compare March 14, 2023 20:18
@jsarha
Copy link
Author

jsarha commented Mar 30, 2023

I'll make this ready for review, if it would then get more attention.

@jsarha jsarha marked this pull request as ready for review March 30, 2023 09:07
@jsarha jsarha changed the title [RFC] Kcontrol name no prefix Kcontrol name no prefix Apr 4, 2023
@plbossart
Copy link
Member

@jsarha I must admit I've completely lost track of this PR. I know I was the one person who asked for the kcontrol names to be simpler with thesofproject/sof#6576, but I just don't connect the dots with the 'no prefix' part and the ASoC details.

Would you mind adding in the commit messages a description of the 'before' and 'after' names, so that we can all agree on the start point and the result?

Thanks!

@jsarha jsarha force-pushed the kcontrol_name_no_prefix branch from 50193c5 to cff08c2 Compare May 8, 2023 18:56
@jsarha
Copy link
Author

jsarha commented May 8, 2023

@jsarha I must admit I've completely lost track of this PR. I know I was the one person who asked for the kcontrol names to be simpler with thesofproject/sof#6576, but I just don't connect the dots with the 'no prefix' part and the ASoC details.

Would you mind adding in the commit messages a description of the 'before' and 'after' names, so that we can all agree on the start point and the result?

Thanks!

@plbossart , I hope the updated last commit message explains better what this series does. The other changes are a rebase on top of latest sof-dev and a minor typo fix in the second commit message.

@jsarha
Copy link
Author

jsarha commented May 10, 2023

Ping @plbossart and @ranj063 ?

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

topology-related changes are very hard to understand for the average developer @jsarha
I could not figure out what some of the patches try to improve and the consistency between code and commit message can be improved a great deal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the commit message at all.

"
no need to assign the tuple value anywhere, but the
tuple should be copied to struct snd_sof_widget member.
"

what is the difference between assign and copy? I don't get the issue at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to explain in more detail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no luck, this is still very confusing. I don't know the details of the topology and I don't need to learn about them, the patch commit message should be high-level enough to describe the functionality.

In this case, I think using the same 'get_type' naming is very misleading, since the type is irrelevant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't appear to have changed, and all 3 reviewers didn't like the code, so this probably needs more work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really confused here.

Is this the case that we provide "a full control over the user visible mixer name" ?

The example just seems to drop the prefix, that's hardly full control.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already had the full control except for the prefix, that is always added, if the newly added flag is not set. The rest of the name comes from topology2 mixer object's "name"-attribute:

https://github.com/thesofproject/sof/blob/45c3f132151676b77d7c290860ddd6b0b2abcdf7/tools/topology/topology2/cavs-mixin-mixout-hda.conf#L43

The point of this series is to provide means to get rid of the non sense widget name e.g. "gain.2.1" in the beginning of the user visible mixer name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested edit to the commit message

Add SOF_TKN_GAIN_NAME_NO_PREFIX token, sof_topology_token entry in
gain_tokens array, and the associated code in sof_ipc4_widget_setup_comp_pga()
to set no_wname_in_long_name flag in the associated snd_soc_dapm_widget.

In practice setting the "name_no_prefix" attribute in the gain node
means that the widget name is not added as a
prefix to the mixer name.

E.g. "gain.2.1 Post Mixer Analog Playback Volume" becomes just
"Post Mixer Analog Playback Volume".

The decision to skip the prefix addition is made when the topology binary file is created. The topology can be modified on a need-basis to make the control names more user-friendly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part needs to go to sof_widget_ready()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing seems to have changed here either, so this is probably not quite ready for a merge.

jsarha added 3 commits May 11, 2023 23:50
Add no_wname_in_long_name flag to struct snd_soc_dapm_widget, and
the logic in dapm_create_or_share_kcontrol() to not to add widget name
as prefix for kcontrol name if the flag is set.

Without this flag new kcontrols will have a name that has the widget
name in the beginning followed by the name given in the struct
snd_kcontrol_new. Some times the widget name is not very informative
and this flag gives the driver an option to drop it if the name
from the snd_kcontrol_new good as it is.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
Add get_token_void() to be used in struct sof_topology_token arrays,
when there is no need to assign the tuple value anywhere, but the
tuple should be copied to struct snd_sof_widget member.

sof_widget_parse_tokens() only copies the tuples into struct
snd_sof_widget's tuples array if the token is found from some of the
widget's struct sof_topology_token arrays.

The struct sof_topology_token has four members, u32 token, u32 type,
get_token function pointer, and u32 offset. The function pointer is
supposed to copy the tuple value of the matching token at the offset
in object pointer given to it as a parameter.

Sometimes there is no real need to copy the value anywhere, but the
still the tuple (token and value pair) is needed in the struct
snd_sof_widget's tuples array. So this function helps in such a case.

With get_token_void() there can be an entry in the struct
sof_topology_token array that does not write anything to the given
object.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
Add SOF_TKN_GAIN_NAME_NO_PREFIX token, sof_topology_token entry in
gain_tokens array, and the associated code in sof_ipc4_widget_setup_comp_pga()
to set no_wname_in_long_name flag in the associated snd_soc_dapm_widget.

In practice setting the "name_no_prefix" attribute in the gain node
means that the systematically assigned widget name is not added as a
prefix the mixer name.

E.g. "gain.2.1 Post Mixer Analog Playback Volume" becomes just
"Post Mixer Analog Playback Volume".

This gives the topology mixer object's "name"-attribute a full control
over the user visible mixer name, without anything extra added to it.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
@jsarha jsarha force-pushed the kcontrol_name_no_prefix branch from cff08c2 to 970f8c1 Compare May 11, 2023 22:08
@jsarha
Copy link
Author

jsarha commented May 11, 2023

@plbossart and @ranj063 , new version pushed. Tried to address Pierre's comments.

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see suggestions below @jsarha, this needs more work to better explain what you are trying to do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested edit to the commit message

Add SOF_TKN_GAIN_NAME_NO_PREFIX token, sof_topology_token entry in
gain_tokens array, and the associated code in sof_ipc4_widget_setup_comp_pga()
to set no_wname_in_long_name flag in the associated snd_soc_dapm_widget.

In practice setting the "name_no_prefix" attribute in the gain node
means that the widget name is not added as a
prefix to the mixer name.

E.g. "gain.2.1 Post Mixer Analog Playback Volume" becomes just
"Post Mixer Analog Playback Volume".

The decision to skip the prefix addition is made when the topology binary file is created. The topology can be modified on a need-basis to make the control names more user-friendly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no luck, this is still very confusing. I don't know the details of the topology and I don't need to learn about them, the patch commit message should be high-level enough to describe the functionality.

In this case, I think using the same 'get_type' naming is very misleading, since the type is irrelevant.

unsigned char power_checked:1; /* power checked this run */
unsigned char is_supply:1; /* Widget is a supply type widget */
unsigned char is_ep:2; /* Widget is a endpoint type widget */
unsigned char no_wname_in_long_name:1; /* No widget name prefix in kcontrol name */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no_wname_in_kcontrol_name makes more sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the naming was selected based on existing variable names, such as

				wname_in_long_name = false;
				kcname_in_long_name = true;

??

int get_token_dai_type(void *elem, void *object, u32 offset);
int get_token_uuid(void *elem, void *object, u32 offset);
int get_token_string(void *elem, void *object, u32 offset);
int get_token_void(void *elem, void *object, u32 offset);
Copy link
Collaborator

@ranj063 ranj063 May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsarha this is unnecessary. You dont really need to parse the token anywwhere at all. Instead what you can do in in sof_widget_ready() in topology.c, iterate though the list of tuples in the swidget's tuples-array, find the token you are interested in and set the field in swidget based on that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to be clearer, this token is IPC agnostic. So why restrict it to IPC4? it should go to the common topology parser

@jsarha jsarha marked this pull request as draft May 17, 2023 21:54
@jsarha
Copy link
Author

jsarha commented May 17, 2023

Ranjani pointed out quite correctly that the name_no_prefix should come from topoplogy mixer object not from gain object. After banging my head against the wall for two days and still not getting the mixer attribute to work, I decided that its time to push the no_prefix part back on proceed with the mixer renaming separately. There is a new PR here: thesofproject/sof#7641

I will continue with this one on lower priority, in parallel with the mixer renaming part on higher priority.

@jsarha
Copy link
Author

jsarha commented Jun 14, 2023

Ranjani pointed out quite correctly that the name_no_prefix should come from topoplogy mixer object not from gain object. After banging my head against the wall for two days and still not getting the mixer attribute to work, I decided that its time to push the no_prefix part back on proceed with the mixer renaming separately. There is a new PR here: thesofproject/sof#7641

I will continue with this one on lower priority, in parallel with the mixer renaming part on higher priority.

Now that I finally know how I could make the no_prefix property a mixer property, I am not any more sure its a good idea. On the topology and sof driver side there is no problem. However, in the ASoC / ALSA side the flag would need to go to "struct snd_kcontrol_new" [1], but there is no behavioral flags there at the moment. I am a little hesitant to start adding them there as we do not really need that. I am leaning applying the comments here but keeping the flag on the widget side, and making the topology attribute to default to not adding the prefix.

@ranj063 and @plbossart what do you say?

[1]

struct snd_kcontrol_new {

@plbossart
Copy link
Member

Now that I finally know how I could make the no_prefix property a mixer property, I am not any more sure its a good idea. On the topology and sof driver side there is no problem. However, in the ASoC / ALSA side the flag would need to go to "struct snd_kcontrol_new" [1], but there is no behavioral flags there at the moment. I am a little hesitant to start adding them there as we do not really need that. I am leaning applying the comments here but keeping the flag on the widget side, and making the topology attribute to default to not adding the prefix.

@ranj063 and @plbossart what do you say?

Not following at all, sorry.

@jsarha
Copy link
Author

jsarha commented Jun 15, 2023

@plbossart , the question is whether to put the topology attribute in to mixer object and the flag in the driver side in to "struct snd_kcontrol_new". Or if to keep the topology attribute in the gain widget object and the flag in "struct snd_soc_dapm_widget" as they are in this PR ATM.

I am leaning towards the later simply because I intuitively dislike the idea of adding the flag in "struct snd_kcontrol_new", and because we do not need per mixer control of kcontrol name prefixes, per widget is quite good enough. However, I can easily go either way.

@plbossart
Copy link
Member

this is all way beyond my comfort zone, best to see what @ranj063 thinks of all this.

@jsarha jsarha marked this pull request as ready for review June 19, 2023 21:37
@jsarha
Copy link
Author

jsarha commented Jun 19, 2023

@ranj063 and @plbossart , to make things more concrete I updated the PR and now all the comment this far should be addressed, apart from moving the attribute to topology mixer object. Please look the updated PR and my latest comment from topology side too: thesofproject/sof#7227

unsigned char power_checked:1; /* power checked this run */
unsigned char is_supply:1; /* Widget is a supply type widget */
unsigned char is_ep:2; /* Widget is a endpoint type widget */
unsigned char no_wname_in_long_name:1; /* No widget name prefix in kcontrol name */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the naming was selected based on existing variable names, such as

				wname_in_long_name = false;
				kcname_in_long_name = true;

??

unsigned char power_checked:1; /* power checked this run */
unsigned char is_supply:1; /* Widget is a supply type widget */
unsigned char is_ep:2; /* Widget is a endpoint type widget */
unsigned char no_wname_in_long_name:1; /* No widget name prefix in kcontrol name */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit message: the last sentence is missing something, the grammar does not work.

this flag gives the driver an option to drop it if the name
from the snd_kcontrol_new is meaningful enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't appear to have changed, and all 3 reviewers didn't like the code, so this probably needs more work?

{SOF_TKN_GAIN_VAL, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32, offsetof(struct sof_ipc4_gain_data, init_val)},
{SOF_TKN_GAIN_NAME_NO_PREFIX, SND_SOC_TPLG_TUPLE_TYPE_BOOL,
get_token_void, 0},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this limited to gains? Could this not be generalized to e.g. EQs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing seems to have changed here either, so this is probably not quite ready for a merge.

@jsarha jsarha marked this pull request as draft June 28, 2023 21:04
@jsarha jsarha closed this Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants