-
Notifications
You must be signed in to change notification settings - Fork 19
tplg: refine topology file to support voulume with multi-channels #34
Conversation
|
This patch works with:thesofproject/linux#39 |
| # Volume Mixer control with max value of 32 | ||
| C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID, | ||
| CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), | ||
| CONTROLMIXER_OPS(volsw, 1 binds the mixer control to volume get/put handlers, 1, 1), |
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.
@RanderWang This seems incorrect. the sof volume_put/get handlers can handle any number of channels up to MAX chan allowed in topology?
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.
yes, volume_put/get works with MAX chan. But user only see two channels in user mode. Please
refer to my thesofproject/linux#39
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.
this also makes no sense to me. this would require all topology files to be changes to remove this special value of 256 used to bind volume with kcontrols.
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.
@RanderWang if the issue is because the default info function used in topology (volsw) supports only 2 channels, then the right fix for this issue would be have a bespoke info function in SOF as well? as Pierre pointed out, we cannot change the binding for all the topologies that are known to work today.
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.
@ranj063 yes, I totally agree with you. But I have pointed out that: if the id is set to 256, the info function cant be binded to a bespoke sof info function. This is the limitation of Asoc
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.
@RanderWang, i am not sure this is the right thing to do. But can we try "volsw_xr_sw" for info instead of "volsw" to get around the stereo restriction?
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.
@ranj063 "volsw_xr_sw" doesn't work and it makes topology loaded failed.
To get info function to be bound with vendor id like 256, a great change will be made
in Asoc. I discussed with Mengdong who is a expert in topology, and got this conclusion.
|
|
||
| dnl KCONTROL_2CHANNELS(reg) | ||
| define(`KCONTROL_2CHANNELS', | ||
| `KCONTROL_CHANNEL(FL, $1, 0),' |
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.
@RanderWang we dont really use the reg and shift values in our IO handler at all. Should we just remove them so that people dont get confused about why it is like this?
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 is used in soc-topology.c in ASOC
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.
@RanderWang the question is if it's used in the SOF code.
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.
@RanderWang agreed it may be used by other kcontrol handlers. But have you verified the reg and shift values are correct? I still think we should remove them.
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.
@ranj063 @plbossart It is not used in SOF now, but not never. I verify the the reg and shift, no problem. It is used in Asoc for two usages. The first usage is to check the volume control is for mono audio or for stereo audio. If it is removed, it is for mono audio. The second usage is to set hardware register. But for SOF, it is no use.
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.
I don't get what you are trying to do
- the binding change looks wrong, this change will break all known topology files
- the speaker mapping isn't right in all cases, e.g. capture.
And please fix typos in commit messages....
|
|
||
| dnl KCONTROL_2CHANNELS(reg) | ||
| define(`KCONTROL_2CHANNELS', | ||
| `KCONTROL_CHANNEL(FL, $1, 0),' |
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.
@RanderWang the question is if it's used in the SOF code.
| `KCONTROL_CHANNEL(FC, $1, 4),' | ||
| `KCONTROL_CHANNEL(LFE, $1, 5),' | ||
| `KCONTROL_CHANNEL(SL, $1, 6),' | ||
| `KCONTROL_CHANNEL(SR, $1, 7)') |
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.
This is a bit controversial. It's not because there are 8 channels that they will follow the speaker arrangement that you describe here. It's probably a better idea to keep the names less precise, e.g. vol_ch0..vo_chl7, to avoid confusions.
Take the example of capture on the GP-MRB, the channels are FM, AUX and mic, nothing to do with 7.1 speaker notation
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.
I followed the topology definition in alsa lib, else it would be built failed
- The channel map reg is the register offset for the control, shift is the
- bit shift within the register for the channel and the section name is the
- channel name and can be one of the following :-
-
- mono # mono stream
-
- fl # front left
-
- fr # front right
-
- rl # rear left
-
- rr # rear right
-
- fc # front center
-
- lfe # LFE
-
- sl # side left
-
- sr # side right
-
- rc # rear center
topology/m4/mixercontrol.m4
Outdated
| dnl KCONTROL_CHANNEL_ARRAY(size, reg) | ||
| define(`KCONTROL_CHANNEL_ARRAY', | ||
| `ifelse( | ||
| $1, `2', `KCONTROL_2CHANNELS($2)', |
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.
what about odd number of channels. it's perfectly doable in TDM mode...
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.
Thanks, I will refine it
| # Volume Mixer control with max value of 32 | ||
| C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID, | ||
| CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), | ||
| CONTROLMIXER_OPS(volsw, 1 binds the mixer control to volume get/put handlers, 1, 1), |
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.
this also makes no sense to me. this would require all topology files to be changes to remove this special value of 256 used to bind volume with kcontrols.
| # Volume Mixer control with max value of 32 | ||
| C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID, | ||
| CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), | ||
| CONTROLMIXER_OPS(volsw, 1 binds the mixer control to volume get/put handlers, 1, 1), |
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.
same here, not sure why you are changing this binding.
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.
see my above comments and thesofproject/linux#39
| # Volume Mixer control with max value of 32 | ||
| C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, | ||
| CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), | ||
| CONTROLMIXER_OPS(volsw, 1 binds the mixer control to volume get/put handlers, 1, 1), |
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.
here too, why change to 1?
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.
see my above comments and thesofproject/linux#39
|
[Qurestion] the binding change looks wrong, this change will break all known topology files |
|
update my patch, thanks for review. I discussed with Meng dong, made clear something (2) Does vender id like 256 still works? (3)why use standard id to support multi-channels? not vendor id. to change ABI is impossible. And to hacking in Asoc to fix this issue is a great |
|
@RanderWang the idea behind the venor IDs is that you can create your own versions of get(), put() and info() or reuse existing versions. I'm not following you here as to why the vendor versions can't use 8 channels, can you point me to the limitation in topology or ASoC core that is blocking this for you. |
|
@RanderWang the SOF kcontrol volume_put() IO handler takes care of reading the volume table and sending the gain to the firmware. How is the standard kcontrol handler doing this? |
|
@RanderWang browsing through the legacy driver code, I ran into sst_slot_enum_info which seems to be a bespoke info callback for an enum control. This might be useful for you to add the info callback to the SOF IO handler. |
|
@ranj063 yes, in sst driver, it use standard id: SNDRV_CTL_ELEM_IFACE_MIXER |
|
@lgirdwood the following lines are gotten from the alsa lib.
At the design time, info function can't be bound to bespoke one. /*
the usage of info in soc_tplg_kcontrol_elems_load in function:soc_tplg_kcontrol_bind_io the get & put can be bound for id are equal, but for info, id is not equal. I discussed with Meng Dong. She said it is a mistake, and you can't expect it at design time. |
topology/m4/mixercontrol.m4
Outdated
| `KCONTROL_CHANNEL(FR, $1, 1),' | ||
| `KCONTROL_CHANNEL(FC, $1, 2)') | ||
|
|
||
| dnl KCONTROL_4CHANNELS(reg) |
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.
We also need to watch the naming here, because it should also imply any channel mapping (rather than just calling it 4channels). Can you have a look and see if ALSA has a naming scheme for common channel mappings and reuse.
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.
Yes, I check it in alsa, but I don't find any usage of 4 channels except mono or stereo audio. I search in google and find that audio with more then 2 channels are all called surround audio.
Using standard SND_SOC_TPLG_CTL_VOLSW to register our kcontrol function because only it supports binding all kcontrol functions to bespoke ones Info function can't be bound to a bespoke one with vendor ID To support multi-channels volume control, please use these m4 files in your topology files Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
|
Refine the name of channel, thanks for review |
|
@RanderWang it seems to me you are trying to work-around a limitation in the ASoC topology core and/or alsa-lib, so why not fix this limitation directly? I don't get your point that the ABI cannot be changed, sure it can as long as it's backwards compatible. |
|
@plbossart yes, it is a work-around method. I want to use our vendor id, but it does't work. And after I thought many times, I found standard id work. I also discussed with MengDong about ABI. If ABI is modified, asoc and alsa lib also need to be refined. This results all the released topology files can't work with modified linux kernel. She got great pain with a case like this. |
Using standard SND_SOC_TPLG_CTL_VOLSW to register our kcontrol function
because only it supports binding all kcontrol functions to bespoke ones
Info function can't be bound to a bespoke one with vendor ID
To support multi-channels volume control, please use these m4 files
in your topology files
Test is on APL, works
This patch works with:thesofproject/linux#39
Signed-off-by: Rander Wang rander.wang@linux.intel.com