Skip to content

Conversation

@jsarha
Copy link

@jsarha jsarha commented Jun 28, 2023

Ok, this PR has evolved enough so that the branch name does not anymore match the content, so I guess its time to turn the page and create a new one. The predecessor can be found as draft here: #4226

The existing soc-dapm code may add a prefix to control names, which in
some cases is useful but in others leads to long and confusing kcontrol
names such as "gain 2.1 Main Playback Volume".

This patch suggests an added flag to prevent the widget name prefix
from being added. That flag will be set in the topology file on a
per-widget basis.

The flag no_wname_in_kcontrol_name is added to struct snd_soc_dapm_widget,
and the logic in dapm_create_or_share_kcontrol() is changed to not to
add widget name if the flag is set.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
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 couple of comments below @jsarha. This looks ok at a high level but there are some parts I wasn't able to understand.

#define SOF_TKN_COMP_NUM_AUDIO_FORMATS 410
#define SOF_TKN_COMP_NUM_INPUT_PINS 411
#define SOF_TKN_COMP_NUM_OUTPUT_PINS 412

Copy link
Member

Choose a reason for hiding this comment

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

spurious line?

type == SND_SOC_TPLG_TUPLE_TYPE_BYTE ||
type == SND_SOC_TPLG_TUPLE_TYPE_BOOL)) {
dev_err(scomp->dev, "Bad tuple type %d\n", type);
return -EINVAL;
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 what this error check does?

Copy link
Author

Choose a reason for hiding this comment

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

If the tuple data type is not something that can easily be interpreted as boolean, then there is reason to believe that the topology is otherwise broken too. But sure, I can change this to a warning only.

break;
}
if (ret != 0)
return ret;
Copy link
Member

Choose a reason for hiding this comment

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

and do we really want to stop the topology parsing here? This seems like a warning at best to me, this doesn't break functionality, does it?

Copy link
Author

Choose a reason for hiding this comment

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

Yep, maybe not. I'll remove it and make sof_w_no_wname_in_long_name() void.

@jsarha jsarha force-pushed the no_wname_in_kcontrol_name branch 3 times, most recently from 64b366f to cb4b59e Compare June 30, 2023 07:27
@jsarha
Copy link
Author

jsarha commented Jul 4, 2023

@plbossart I think have your comments covered.

plbossart
plbossart previously approved these changes Aug 4, 2023
@plbossart
Copy link
Member

@bardliao @ranj063 @ujfalusi can you review?

@jsarha has been at this for a long time and it'd be nice to have this upstream soonish

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jsarha why do we need to duplicate the parsing code when we can simply do this:

static const struct sof_topology_token widget_kcontrol_name_token[] = {
	{SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
		offsetof(struct snd_soc_dapm_widget, no_wname_in_kcontrol_name)},
};

ret = sof_parse_tokens(scomp, w, widget_kcontrol_name_token,
		       ARRAY_SIZE(widget_kcontrol_name_token), private->array,
			       le32_to_cpu(private->size));
if (ret) {
	dev_err(scomp->dev, "error: parse stream tokens failed %d\n",
		le32_to_cpu(private->size));
	return ret;
}

Copy link
Author

Choose a reason for hiding this comment

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

@ranj063 , I am pretty sure that does not work with bit-fields. I would have to turn no_wname_in_kcontrol_name from 1 bit wide to one byte wide. offsetof only has one byte granularity, hasn't it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jsarha any reason why we can't make it a bool or a byte instead of a 1bit value?

Copy link
Author

@jsarha jsarha Aug 7, 2023

Choose a reason for hiding this comment

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

Only that all the other flags in the struct are bit-fields, so it would look a bit out of place there, and the header is generic ASoC code, not sof only. Of course we have @lgirdwood in the team so we can ask directly, what do you say? Can I change this just unsigned char: 44de36b

The other option would be adding a bit-mask to struct sof_topology_token and implementing get_token_u8_bitfield().

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jsarha I dont think there's any restriction that this can to be a bit field in the struct. I'd modify it to a bool to keep it simple.

Copy link
Author

@jsarha jsarha Aug 8, 2023

Choose a reason for hiding this comment

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

Simple me... its not that hard really. I can of course do it like this:

static int get_w_no_wname_in_long_name(void *elem, void *object, u32 offset)
{
	struct snd_soc_tplg_vendor_value_elem *velem = elem;
	struct snd_soc_dapm_widget *w = object;

	w->no_wname_in_kcontrol_name = !!le32_to_cpu(velem->value);
	return 0;
}

static const struct sof_topology_token dapm_widget_token[] = {
	{SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME, SND_SOC_TPLG_TUPLE_TYPE_BOOL,
	 get_w_no_wname_in_long_name, 0 }
};

That would be fine, would't it, @ranj063 ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jsarha yes thats perfect!

… name

Adds SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME token, and copies the
token's tuple value to the no_wname_in_kcontrol_name flag in struct
snd_soc_dapm_widget.

If the tuple value for the token in the topology is true, then the
widget name is not added to the mixer name. In practice "gain.2.1 Post
Mixer Analog Playback Volume" becomes just "Post Mixer Analog Playback
Volume".

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
@plbossart plbossart merged commit 246b5b7 into thesofproject:topic/sof-dev Aug 10, 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