Repository navigation
ASoC: SOF: control: override volume info callback #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,28 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol, | |
| return change; | ||
| } | ||
|
|
||
| int snd_sof_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | ||
| { | ||
| struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value; | ||
| struct snd_sof_control *scontrol = sm->dobj.private; | ||
| unsigned int channels = scontrol->num_channels; | ||
| int platform_max; | ||
|
|
||
| if (!sm->platform_max) | ||
| sm->platform_max = sm->max; | ||
| platform_max = sm->platform_max; | ||
|
|
||
| if (platform_max == 1 && !strstr(kcontrol->id.name, " Volume")) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also don't get what this means and the intent of this test.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart Ditto here same as soc-ops.c |
||
| uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
| else | ||
| uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
|
|
||
| uinfo->count = channels; | ||
| uinfo->value.integer.min = 0; | ||
| uinfo->value.integer.max = platform_max - sm->min; | ||
| return 0; | ||
| } | ||
|
|
||
| int snd_sof_switch_get(struct snd_kcontrol *kcontrol, | ||
| struct snd_ctl_elem_value *ucontrol) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1041,6 +1041,15 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, | |
| goto out; | ||
| } | ||
|
|
||
| /* | ||
| * If control has more than 2 channels we need to override the info. This is because even if | ||
| * ASoC layer has defined topology's max channel count to SND_SOC_TPLG_MAX_CHAN = 8, the | ||
| * pre-defined dapm control types (and related functions) creating the actual control | ||
| * restrict the channels only to mono or stereo. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the question will be: why not fix the ASoC topology core, instead of doing an SOF-specific fix? Intel is pretty much the only user of the topology, so it'd be odd not to fix what we depend on?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart its a bit of a chicken and egg kind of situation. topolopgy expects one of the three kinds of controls (mixer, enum or bytes) and this is determined based on the info op ID. So, bespoke info IDs are not allowed. But adding a bespoke info ID is also hard because we dont know what type of control to load in this case. What I think might be a better thing to do would be to introduce a new type of info called SND_SOC_TPLG_CTL_VOLSW_MULTI_CHANNEL or something like that and use that in tplg. This would require changes in alsalib as well. @juimonen what do you think?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason why SND_SOC_TPLG_CTL_VOLSW would be limited to 2ch? |
||
| */ | ||
| if (le32_to_cpu(mc->num_channels) > 2) | ||
| kc->info = snd_sof_volume_info; | ||
|
|
||
| /* init the volume get/put data */ | ||
| scontrol->size = struct_size(scontrol->control_data, chanv, | ||
| le32_to_cpu(mc->num_channels)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't hurt to add a comment on what max and platform_max represent? I am not familiar with all this and can't follow if the code makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart This is verbatim following soc-opc.c:snd_soc_info_volsw_range(), i.e. the function we override. There seems to be support to a range of channels that do not start from 1 and thus the code is a bit funky. But yeah, following soc-ops.c seems fine.