Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Conversation

@RanderWang
Copy link
Collaborator

@RanderWang RanderWang commented Jul 19, 2018

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

@RanderWang
Copy link
Collaborator Author

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),
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

Copy link
Member

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.

Copy link
Collaborator

@ranj063 ranj063 Jul 19, 2018

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.

Copy link
Collaborator Author

@RanderWang RanderWang Jul 20, 2018

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

Copy link
Collaborator

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?

Copy link
Collaborator Author

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),'
Copy link
Collaborator

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?

Copy link
Collaborator Author

@RanderWang RanderWang Jul 19, 2018

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

Copy link
Member

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

@RanderWang RanderWang Jul 20, 2018

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.

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.

I don't get what you are trying to do

  1. the binding change looks wrong, this change will break all known topology files
  2. 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),'
Copy link
Member

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)')
Copy link
Member

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

Copy link
Collaborator Author

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

dnl KCONTROL_CHANNEL_ARRAY(size, reg)
define(`KCONTROL_CHANNEL_ARRAY',
`ifelse(
$1, `2', `KCONTROL_2CHANNELS($2)',
Copy link
Member

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

Copy link
Collaborator Author

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),
Copy link
Member

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),
Copy link
Member

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.

Copy link
Collaborator Author

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),
Copy link
Member

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?

Copy link
Collaborator Author

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

@RanderWang
Copy link
Collaborator Author

RanderWang commented Jul 20, 2018

[Qurestion] the binding change looks wrong, this change will break all known topology files
[Answer] no, 256 still works because it is still kept in SOF kernel driver and registered to ASOC.
If this id is not registered to Asoc, it would stop working

@RanderWang
Copy link
Collaborator Author

RanderWang commented Jul 20, 2018

update my patch, thanks for review.

I discussed with Meng dong, made clear something
(1) Is this patch compatible with existing topology files?
Yes, I just add another path, not rebuild one. The legacy
topology files still work

(2) Does vender id like 256 still works?
yes, it still works with two channels volume controller

(3)why use standard id to support multi-channels? not vendor id.
we need binding info function in kcontrol to return correct channel number.
It can't be done with vendor id because there is a limitation in Asoc.
At the design time of topology ABI, it is expected that info function should
be the default one, so the info id is used as a type not a id. But later, the feature
that info function can be bound to a bespoke one is added. It is a pity that
the info id is wrong. So the new feature doesn't work at all.

to change ABI is impossible. And to hacking in Asoc to fix this issue is a great
work. Now the standard id works. It is ok.

@lgirdwood
Copy link
Member

lgirdwood commented Jul 20, 2018

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

@ranj063
Copy link
Collaborator

ranj063 commented Jul 20, 2018

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

@ranj063
Copy link
Collaborator

ranj063 commented Jul 21, 2018

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

@RanderWang
Copy link
Collaborator Author

RanderWang commented Jul 23, 2018

@ranj063 yes, in sst driver, it use standard id: SNDRV_CTL_ELEM_IFACE_MIXER
What I use is also standard id: SND_SOC_TPLG_CTL_VOLSW. So no difference.
Thank your for your info!

@RanderWang
Copy link
Collaborator Author

RanderWang commented Jul 23, 2018

@lgirdwood the following lines are gotten from the alsa lib.

  • This mapping shows info() using the standard "volsw" info callback whilst
  • the get() and put() are mapped to bespoke driver callbacks.
  • The Standard operations names for control get(), put() and info calls
  • are :-
    • volsw
    • volsw_sx
    • volsw_xr_sx
    • enum

At the design time, info function can't be bound to bespoke one.

/*

  • Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
  • Kcontrol ops need get/put/info.
  • Bytes ext ops need get/put.
    */
    struct snd_soc_tplg_io_ops {
    __le32 get;
    __le32 put;
    __le32 info;
    } attribute((packed));
    you can get idea from the comments. info is not used as get & put. It is set to volsw, and get & put are set to vendor defined id, for example 256.

the usage of info in soc_tplg_kcontrol_elems_load
switch (control_hdr->ops.info) {
case SND_SOC_TPLG_CTL_VOLSW:
case SND_SOC_TPLG_CTL_STROBE:
case SND_SOC_TPLG_CTL_VOLSW_SX:
....

in function:soc_tplg_kcontrol_bind_io

	if (k->put == NULL && ops[i].id == hdr->ops.put) // 256 == 256
		k->put = ops[i].put;
	if (k->get == NULL && ops[i].id == hdr->ops.get) // 256 == 256
		k->get = ops[i].get;
	if (k->info == NULL && ops[i].id == hdr->ops.info) // 256 != 1 (VOLSW)
		k->info = ops[i].info;

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.

`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(FC, $1, 2)')

dnl KCONTROL_4CHANNELS(reg)
Copy link
Member

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.

Copy link
Collaborator Author

@RanderWang RanderWang Jul 25, 2018

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>
@RanderWang
Copy link
Collaborator Author

Refine the name of channel, thanks for review

@plbossart
Copy link
Member

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

@RanderWang
Copy link
Collaborator Author

RanderWang commented Jul 26, 2018

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

@RanderWang RanderWang closed this Aug 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants