Repository navigation
Init kcontrol values for sof-hda-dsp and sof-soundwire - #42
Conversation
kv2019i
left a comment
There was a problem hiding this comment.
Thanks @libinyang ! There was one more change in alsa-lib, but otherwise looks ok.
| Control "name='PGA1.0 1 Master Playback Volume'" | ||
| } | ||
| True { | ||
| SectionOnce [ |
There was a problem hiding this comment.
The name was changed in alsa-lib to SectionBoot:
https://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=14636be4a87ea1cbb13bf8942d07d2066d626e71
.. otherwise looks good.
There was a problem hiding this comment.
The current name is BootSequence [] .
It may also make sense to put the boot values to the master file (ucm2/sof-soundwire/sof-soundwire.conf) unless the contents is shared with some other configuration files. The contents looks ok.
There was a problem hiding this comment.
The name was changed in alsa-lib to SectionBoot:
https://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=14636be4a87ea1cbb13bf8942d07d2066d626e71.. otherwise looks good.
@kv2019i Thanks for reminder. I will update the UCM.
It may also make sense to put the boot values to the master file (ucm2/sof-soundwire/sof-soundwire.conf) unless the contents is shared with some other configuration files. The contents looks ok.
@perexg OK. I will move it into the master file.
plbossart
left a comment
There was a problem hiding this comment.
We really need to keep speaker stuff with the speaker stuff, and not move all the inits into a common session. This is just not going to work, sorry.
| If.pga1p { | ||
| Condition { | ||
| Type ControlExists | ||
| Control "name='PGA1.0 1 Master Playback Volume'" |
There was a problem hiding this comment.
this is unmaintainable. No one will ever remember what those controls are now that you have moved them between files. I really would like each init value to be located in the file for which this value makes sense. Putting everything together goes against the modularity we wanted to add here.
There was a problem hiding this comment.
Unfortunately, it's the global section for the first boot hardware initialization which is not tied with the verb/device contents. I am not against to put the relevant configs to the sub-configs (codecs/ tree or so), but if you have everything together, just put it to the main config file. We can modify it later.
There was a problem hiding this comment.
There is no way we can guarantee thant PGA1.0.1 Master Playback Volume maps to a RT1308 amplifier or a Maxim 98373 amplifier. The premise is that we would do a generic/modular driver, it doesn't seem right to me to put the init values together when they are meant to be independent.
There was a problem hiding this comment.
Then follow the main condition block in verb HiFi:
If.RT700 {
Condition {
Type String
Haystack "${CardComponents}"
Needle "hs:rt700"
}
True {
BootSequence [
....
]
}
}
I'm ok to put this to RT700-init.conf and inlude those files from sof-soundwire.conf to follow the verb structure.
There was a problem hiding this comment.
There is no way we can guarantee thant PGA1.0.1 Master Playback Volume maps to a RT1308 amplifier or a Maxim 98373 amplifier.
@plbossart As there is no guarantee that PGA1 or PGA2 will map to which codec, we should put PGA settings in a general file. Otherwise, it may introduce some problems. For example, PGA1 maybe used by RT711 on some platforms, but on other platforms, PGA2 is used by RT711.
@plbossart @perexg I think this is a good idea that we can move codec specific settings into the codec specific config, for example, moving the RT700 settings into RT700-init.conf. We may need update alsa-lib to support such usage. Currently alsa-lib only support BootSequence in the card config file.
There was a problem hiding this comment.
@plbossart @perexg I think this is a good idea that we can move codec specific settings into the codec specific config, for example, moving the RT700 settings into RT700-init.conf. We may need update alsa-lib to support such usage. Currently alsa-lib only support BootSequence in the card config file.
And it's correct. It's the global config. Just add <sof-soundwire/RT700-init.conf> lines to the card config file (sof-soundwire.conf).
There was a problem hiding this comment.
There is no way we can guarantee thant PGA1.0.1 Master Playback Volume maps to a RT1308 amplifier or a Maxim 98373 amplifier.
@plbossart As there is no guarantee that PGA1 or PGA2 will map to which codec, we should put PGA settings in a general file. Otherwise, it may introduce some problems. For example, PGA1 maybe used by RT711 on some platforms, but on other platforms, PGA2 is used by RT711.
PGA settings for the topology should always be 100%/0dB by default. There is no reason why we should do any attenuation in the firmware, it's much better to do such attenuations in the codec.
@plbossart @perexg I think this is a good idea that we can move codec specific settings into the codec specific config, for example, moving the RT700 settings into RT700-init.conf. We may need update alsa-lib to support such usage. Currently alsa-lib only support BootSequence in the card config file.
That would be fine and aligned with what we did for previous solutions, we could even put the codec configurations in the codec/ directory as we did for legacy platforms.
There was a problem hiding this comment.
That would be fine and aligned with what we did for previous solutions, we could even put the codec configurations in the codec/ directory as we did for legacy platforms.
The PGA (dsp) related configs should be in dsp/ directory. It's a dsp config, not the codec config.
There was a problem hiding this comment.
PGA settings for the topology should always be 100%/0dB by default. There is no reason why we should do any attenuation in the firmware, it's much better to do such attenuations in the codec.
@plbossart For playback pipeline PGA, 32 is 0dB. The original UCM setting such as cset "name='PGA3.0 3 Master Playback Volume' 50" is wrong and '50' is out of the range. Please see the example of PGA1:
numid=54,iface=MIXER,name='PGA1.0 1 Master Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=32,step=0
: values=32,32
| dBscale-min=-64.00dB,step=2.00dB,mute=1
@plbossart @perexg If we align that we should put PGA setting in dsp/ directory and codec setting in codec/ directory (including the original RT711.conf and etc), I will update the patch.
|
Patch has been updated. I didn't move RT711.conf and etc. into codecs/ folder this time. This is because RT711.conf and RT715.conf is using PGA (which is not related to the codec directly) to control mute/volume. I think we can move the codec conf into codec/ folder after the general MIC LED mute is supported. After general MIC LED mute is supported, we don't need to use anything related to PGA kctl to control the capture mute/volume in the codec config file (such as RT711.conf). |
| } | ||
| True { | ||
| BootSequence [ | ||
| cset "name='PGA8.0 8 Master Playback Volume' 32" |
There was a problem hiding this comment.
Why do we need to initialize all this? Isn't 32 == 0dB == the default?
There was a problem hiding this comment.
This is because we should let user have a way to reset to the default value in case the kcontrols value is wrongly set by mistake.
There was a problem hiding this comment.
We don't do this for codecs, which have a lot more controls that we do, so why would we do it for PGAs only? This seems both overkill and incomplete. if people muck with alsamixer, then there's no much we can do to prevent conflicts.
There was a problem hiding this comment.
User may change the volumes by mistake and he never knows how to recover them. In this case, if we offer a tune-key solution setting, it will be much easier for user. And also we offer some codec specific settings in such as rt711/init.conf.
There was a problem hiding this comment.
@libinyang you're not getting my point. There are tons of codec registers and we ONLY set the values that are not the default. Why would do anything different here? If the user changes the value manually, well that's too bad.
There was a problem hiding this comment.
we already set the values to a known and working state at the driver level.
What happens in userspace is rather unclear to me, e.g. if you have a UCM file shouldn't it discard any changes made during the last session? Why would the UCM file need to restore the default values that are already set by the driver? it'd seem simpler to me to discard changes made by userspace so that driver default + UCM setup provides a reproducible configuration at each card creation.
There was a problem hiding this comment.
I think alsactl will restore the previous setting because 'working state' may not be enough for users. The output devices are different totally. Some users may use headphone while others may use AV receiver. So the initial volume may be horribly too loud for some users and may be too low for other users. And another reason I can think is that users may hope OS remember which output is the default output in next boot up. I checked Windows 7, it will also restore the user setting when boot up.
There was a problem hiding this comment.
@libinyang you are just confusing the heck out of me. The BootSequence will precisely override user settings that might have been set with amixer. We should NOT change the PGA volumes in general anyways, by default it's better to keep the full dynamic range in the DSP and change the volume at the codec level.
Also the topology does define some defaults, so you are just duplicating the work already done by the topology init.
This is really really confusing.
There was a problem hiding this comment.
The BootSequence takes effect only when alsactl init runs. And alsactl init is supposed to run when the first boot of the new machine for the initial value setting. alsactl init won't be run at the second, third.. boot. Also user can manually run alsactl init if he found his machine doesn't have sound any more even after reboot.
So the sequence is:
- For the first time boot up: driver init ->
alsactl init - For other boots up except the first time: driver init ->
alsactl restore - And at anytime user found there is no sound, user can run
alsactl initmanually (in this case, we need the correct setting of PGA and codec).
There was a problem hiding this comment.
Hmm, this is a good discussion. I'm afraid step (3) can be more complicated as audio servers (like Pulseaudio) also store state. This doesn't mean we should not provide means to init the state for ALSA level, but just to highlight the recovery may need more steps from end-user perspective. So requiring user to reboot (or reload the driver), in addition to "alsactl init" (and resetting PA state) does not seem unreasonable.
I was initially thinking that the PGA defaults are fairly harmless and they do add value (recovery if user or buggy application messing with ALSA controls directly), but I think @plbossart raises valid points. Maybe it's not worth the maintenance overhead and we should follow a more conservative approach, where we only provide settings which differ from driver defaults, in BootSequence. Digital/DSP amplify/gain stages typically have 0dB as the default state and this is what we are following for SOF PGAs as well. On some platforms we might want to boost e.g. the DMIC more and this could go to BootSequence, but this would be a non-0dB setting. And I think UCM is a better place for this than topology (UCM can be overridden with longname lookup).
Move the kcontrols initial setting into BootSequence. These values will be setup by 'alsactl init' command. And then leave other applications like pulseaudio to modify the value per user requests. Please refer thesofproject/linux#2067 for more details. Signed-off-by: Libin Yang <[email protected]>
This patch adds the initial kcontrol values for sof-hda-dsp and move the initial kcontrol values into SectionOnce.
Move the initial kcontrols values into SectionOnce can avoid setting the kcontrol values everytime the device is used.
Please see the detail discussion in thesofproject/linux#2067