Skip to content

[RFC] add possibility for bespoke info - #2483

Closed
juimonen wants to merge 2 commits into
thesofproject:topic/sof-devfrom
juimonen:bespoke_info
Closed

juimonen wants to merge 2 commits into
thesofproject:topic/sof-devfrom
juimonen:bespoke_info

Conversation

@juimonen

@juimonen juimonen commented Oct 1, 2020

Copy link
Copy Markdown

This is an attempt to add the possibility of bespoke info definition in topology.

Jaska Uimonen added 2 commits October 1, 2020 15:15
Currently you can't set bespoke info callback for controls in topology,
because the info type is used to deduce the kcontrol type. So make a new
op to snd_soc_tplg_ops for asking the bespoke type from lower level and
embed this call to new function soc_tplg_get_kcontrol_type, which also
cleans up the redundant control type parsing.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Add control type ops for sof driver so that asoc can ask the control
type defined by bespoke id in topology.

Add also info callback for volume and switch. This enables the
definition of multichannel controls in topology, so that they will be
usable from user space software such as alsamixer.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
@singalsu

singalsu commented Oct 1, 2020

Copy link
Copy Markdown
Collaborator

This worked perfectly in my test with four DMICs, all exercised individual volume and mute commands worked. Note: The prepared topology file (needs SOF patch) does not load with vanilla topic/sof-dev kernel.

Comment thread sound/soc/sof/control.c
return 0;
}

int snd_sof_control_type(type)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

how does this compile? you dont have a datatype for type?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

besides I think the argument should be called info and the return value should be called type?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

whoops...it is compiling as you see from CI results also... but yes don't know how and clearly a mistake, will fix.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

wow, maybe it compiles because the prototype has a type? funny...

Comment thread sound/soc/sof/sof-audio.h
int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int snd_sof_volume_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

one line?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

should we put these to one line as the other ones surrounding are not? it just looks ugly...

@ranj063

ranj063 commented Oct 1, 2020

Copy link
Copy Markdown
Collaborator

@juimonen I still think this change is quite restrictive in terms of allowing bespoke kcontrols. After checking for the type, you're still assuming that it is one of mixer,bytes or enum right? I thought you were exploring the other option of expanding the channels to support 8 instead of 2 in the core?

@plbossart

Copy link
Copy Markdown
Member

@juimonen I still think this change is quite restrictive in terms of allowing bespoke kcontrols. After checking for the type, you're still assuming that it is one of mixer,bytes or enum right? I thought you were exploring the other option of expanding the channels to support 8 instead of 2 in the core?

Right, this feels like 'semi-custom' info. And I don't get if this is in addition to PR #2469 or as an alternative.

@juimonen

juimonen commented Oct 1, 2020

Copy link
Copy Markdown
Author

@plbossart the difference here to #2469 is that we can choose (and show to the user) from topology that we are using custom info callback and not just setting it behind the curtains.

@juimonen

juimonen commented Oct 1, 2020

Copy link
Copy Markdown
Author

@juimonen I still think this change is quite restrictive in terms of allowing bespoke kcontrols. After checking for the type, you're still assuming that it is one of mixer,bytes or enum right? I thought you were exploring the other option of expanding the channels to support 8 instead of 2 in the core?

@ranj063 sorry I didn't understand this comment? The controls are always mixer, bytes or enum right?

Anyway this PR is problematic in that sense, that if I make this custom info change to some topology, and someone uses that new topology with old kernel, the whole topology loading fails... So even I think this is a good thing to do, the "force override" might be just better in this sense.

@ranj063

ranj063 commented Oct 1, 2020

Copy link
Copy Markdown
Collaborator

@ranj063 sorry I didn't understand this comment? The controls are always mixer, bytes or enum right?

thats what I was wondering. are they? wha does bespoke mean then?

@juimonen

juimonen commented Oct 2, 2020

Copy link
Copy Markdown
Author

@ranj063 sorry I didn't understand this comment? The controls are always mixer, bytes or enum right?

thats what I was wondering. are they? wha does bespoke mean then?

So I see it this way: currently we have a list of 10~ enum definitions for info, like volsw, volsw_sx, range, enum, bytes etc. These are types for 3 different items: mixer, bytes and enum. At least that's how they are categorized in asoc. so for example volsw and range are mixers, just different types. I see info of being bespoke subtype, which is falling into some of these 3 different types/categories.

Comment thread sound/soc/sof/control.c
ret = SND_SOC_TPLG_TYPE_ENUM;
break;
default:
ret = -EINVAL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

how many lines of code you'd save, if you just did return SND_SOC_TPLG_TYPE_x; and removed all the breaks and the ret variable ;-)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yeah, sure can do :) just have some vague remembrance in my head for someone complaining about these "excessive" returns... also not sure if needed to add some other logic later, this would be then better. But it can be changed then.

@juimonen

juimonen commented Oct 5, 2020

Copy link
Copy Markdown
Author

Closing this as other solution has been considered better..

@juimonen juimonen closed this Oct 5, 2020
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.

5 participants