Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions sound/soc/sof/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Copy Markdown
Member

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.

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.

@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.


if (platform_max == 1 && !strstr(kcontrol->id.name, " Volume"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

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.

@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)
{
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/sof/sof-audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
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 *ucontrol);
int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

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.

@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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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));
Expand Down