-
Notifications
You must be signed in to change notification settings - Fork 14
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
UCM2: Intel: sof-hda-dsp: Control SOF processing from UCM #49
UCM2: Intel: sof-hda-dsp: Control SOF processing from UCM #49
Conversation
ucm2/sof/ipc3/eq_fir/pass.blob
Outdated
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.
There should be a readme text file that describes how these were generated (currently with scripts in sof/tools/tune/).
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 need a mechanism by which people can install new settings without overriding the existing ones - because at each distro update the new settings would be overridden back...
Something like a search path with a hierarchy (/etc/ or ~/.config) or something.
This could be interesting as well: are settings user-specific or card-specific?
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.
That's a good idea, I'll try to add support for that. I'd assume settings are card specific, so another directory that is safe from distribution updates will be useful for enthusiasts. I'll see if UCM can access e.g. $HOME.
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.
@singalsu, impressive to say the least, I have just few comments to consider.
ucm2/Intel/sof-hda-dsp/HiFi.conf
Outdated
@@ -8,7 +8,7 @@ SectionVerb { | |||
Value.TQ "HiFi" | |||
} | |||
|
|||
Include.hda-analog.File "/HDA/HiFi-analog.conf" | |||
Include.hda-analog.File "/Intel/sof-hda-dsp/HiFi-analog-sof.conf" |
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.
you could drop the -sof postfix, the conf file is under sof-hda-dsp anyways?
How would the support for sof-soundwire
going to be added?
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.
Yep, I will do it. I hope I can soon start also with SDW, it will be simpler than this thanks to endpoint dedicated DAI pipelines.
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.
so for SoundWire i'd really like to see no configurations in Enable, it should all be boot sequences.
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's an excellent start @singalsu, but there are multiple concerns on editing files, overriding defaults and more importantly whether the settings actually need to be applied on an endpoint enable/disable. If we can provide the settings at boot time and let the frameworks update the settings when an endpoint is enabled we would simplify the maintenance of all these files.
ucm2/sof/ipc3/eq_fir/pass.blob
Outdated
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 need a mechanism by which people can install new settings without overriding the existing ones - because at each distro update the new settings would be overridden back...
Something like a search path with a hierarchy (/etc/ or ~/.config) or something.
This could be interesting as well: are settings user-specific or card-specific?
ucm2/Intel/sof-hda-dsp/HiFi.conf
Outdated
@@ -8,7 +8,7 @@ SectionVerb { | |||
Value.TQ "HiFi" | |||
} | |||
|
|||
Include.hda-analog.File "/HDA/HiFi-analog.conf" | |||
Include.hda-analog.File "/Intel/sof-hda-dsp/HiFi-analog-sof.conf" |
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 can't recall why the initial part was 'HDA' but it was intentional.
I don't fully understand the impact of renaming the path, but this is potentially problematic.
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 would be much better to add DSP configuration on top of the /HDA/HiFi-analog.conf
config. Just add only appropriate configs to the proper configuration tree like:
Include.hda-analog.File "/HDA/HiFi-analog.conf"
SectionDevice."Headphones" {
If.headphone_with_drc {
Condition {
Type ControlExists
Control "name='${var:PostMixerAnalogPlaybackDRCSwitch}'"
}
True {
EnableSequence [
cset "name='${var:PostMixerAnalogPlaybackDRCSwitch}' off"
cset-tlv "name='${var:PostMixerAnalogPlaybackDRCBytes}' ${var:HeadphoneDrcBlob}"
.... finish ...
]
}
}
}
Also, if something repeats, you may consider to use macros...
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 @perexg , that would be better way indeed, and there's lot of repeats. I'll do that for next update.
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.
Also, if something repeats, you may consider to use macros...
@perexg I don't seem to be able to use macros inside EnableSequence []
. I get e.g. error ALSA lib parser.c:1237:(parse_sequence) error: sequence command 'Macro.id2.HeadphoneSofDrcEqEnable' is ignored
if I try such.
PostMixerAnalogPlaybackFIRBytes "Post Mixer Analog Playback FIR Eq bytes" | ||
PostMixerAnalogPlaybackDRCBytes "Post Mixer Analog Playback DRC bytes" | ||
PostMixerAnalogPlaybackDRCSwitch "Post Mixer Analog Playback DRC switch" | ||
SpeakerIirBlob "${ConfTopDir}/sof/${var:SOFIPCVer}/eq_iir/highpass_100hz_0db_48khz.blob" |
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.
hard-coding the path makes it difficult to override with a different blob.
I don't have a solution but maybe there should be a separate variable for the path prefix that can use an environment variable or something.
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.
A variable that holds ${ConfTopDir}/sof/${var:SOFIPCVer} would be simple and clean up the code a bit. These are the defaults so I don't expect them to change much. For customize that I'd need help from experts.
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.
Yep, it's possible to access environment variables, with ${env:}. @plbossart Do you have suggestions for it and should it override ${ConfTopDir}/sof or even the ${var:SOFIPCVer} too?
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 was only referring to a path change (similar to what we do for firmware/topology).
the IPC version cannot be changed IMHO, it's a given on a platform. On recent kernels we expose it with debugfs, but that requires 'sudo' access.
} | ||
} | ||
|
||
# Include blob customizations: sys_vendor / product_name .conf |
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 understand the "Include blob customizations', how does this override the defaults?
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.
The file ProductConfigSOF, it it exists, can re-define the previously defined default blobs, e.g. SpeakerFirBlob to enable the FIR filter that is by default passthrough. Or the SpeakerIirBlob that is set for default 100 Hz high-pass.
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.
Isn't it simpler conceptually to do
if (product config)
include product_config_file
else
include default_config_file
It's very hard to debug if parts of the config are overridden and others are not. Only experts would understand what they are doing, the rest of the world needs things to be error-proof.
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 it could be like that. The benefit of current way is that the product config does not need to define every variable, only the ones that should change. E.g. headphone settings should be changed from pass-through default to something else only by user.
With the if - else you propose few code lines would be saved but there would be risk for UCM silently not working if product config misses to set some variables.
cset-tlv "name='${var:PostMixerAnalogPlaybackDRCBytes}' ${var:HeadphoneDrcBlob}" | ||
cset-tlv "name='${var:PostMixerAnalogPlaybackIIRBytes}' ${var:HeadphoneIirBlob}" | ||
cset-tlv "name='${var:PostMixerAnalogPlaybackFIRBytes}' ${var:HeadphoneFirBlob}" | ||
#shell "/bin/echo 'Headphone DRC EQ ${var:HeadphoneIirBlob} ${var:HeadphoneFirBlob} ${var:SOFConfFullPath}' >> /tmp/alsa-ucm.txt" |
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.
is this really a sequence that needs to be done when enabling an endpoint, or could it be done at boot time?
Boot time sequences are stored separately in a different file.
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.
and now that I think of it, I wonder if the only difference between the processing-enabled cases or not enabled should be the boot settings.
In theory when enabling a path the controls are restored by DAPM, are they not? If I am correct we could simplify all this and just provide a bunch of settings. Maybe some of the values will not be used, e.g. if a user never enables a given path, but that's considerably less complicated to maintain.
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 needed with HDA with shared DAI for endpoints. I'm planning to add for EQ components similar on/off switch as DRC has. With such it would be possible to have boot time passed blob and passthrough for anything else but speaker and just control the switch control. But it would also limit customize of other endpoints with this framework. So, I chose to transmit the blob in every EnableSequence. But e.g. with SDW with separate PCMs and DAIs for endpoints there is no need to do runtime blobs passing. I should work with such topology next since SDW PC notebooks are appearing.
The EQ firmware also has capability for enum type EQ presets (but no control exposed) so such could work for convertible notebooks, if UCM would be aware of orientation. I'll implement first the switch. The enum control add needs some thinking it it's feasible.
Note: DRC would work in git main builds with just switch control, and I don't currently see need for playback DRC for other than notebook kind of speaker. But the signed FW release that I'm using has non-working switch control. It requires a stream start for switch to get and hear the boost impact. While with blob send it always works. So, in this work I'm also always sending the DRC blob. Hope the new FW releases include this DRC fix.
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.
Ah yes for HDaudio the settings depend on how the endpoint is configured (speaker or headphone). Same for input if there's no PCH-DMIC.
Indeed I don't see how we can avoid configurations during the Enable step. Thanks for the clarification.
#Define.SpeakerDrcBlob "/usr/share/alsa/ucm2/sof/ipc4/drc/speaker_aaeon_upx-tgl01.blob" | ||
#Define.HeadphoneIirBlob "/usr/share/alsa/ucm2/sof/ipc4/eq_iir/headphone_aaeon_upx-tgl01.blob" | ||
#Define.HeadphoneFirBlob "/usr/share/alsa/ucm2/sof/ipc4/eq_fir/headphone_aaeon_upx-tgl01.blob" | ||
#Define.HeadphoneDrcBlob "/usr/share/alsa/ucm2/sof/ipc4/drc/headphone_aaeon_upx-tgl01.blob" |
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.
Sorry, we should not rely on people editing files. That's a big no-no for files updated by a distro.
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 added those as comments for what a vendor can customize, it might not be clear from the HiFi-analog-sof.conf. Your idea for user's customization is good so I will try to add such possibility. It will be these same UCM variables.
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.
Also I'm not sure UPX is a good example, not sure it can ever have UCM in speaker mode. But since Intel is not selling consumer devices, not even NuC any more, so I though UPX that most of us developers use, might be the best harmless example.
2170562
to
d05f574
Compare
@perexg I just updated this PR. Is the modification to HDA/HiFi-analog.conf like you suggested? I tried to move entire speaker and headphone control to a macro and pass to it the endpoint=Headphone or endpoint=Speaker. But the macro apparently can't use e.g. |
Unfortnunately no. HDA/HiFi-analog.conf should not be touched at all. Just include it to your file and do the modification to the Device sections on top. It is not required to define the whole device - just add new things. Eventually, you can keep those changes in a separarate file and include HDA/HiFi-analog.conf and this new file from the toplevel one. The trees are merged. See my original hint. Also note that there's execution order for the dynamically evaluated trees - see https://www.alsa-project.org/alsa-doc/alsa-lib/group__ucm__conf.html (Configuration tree evaluation paragraph).
Indirect variable references should be supported as:
The inner expression evaluations are not supported. |
d0f710f
to
2b2e831
Compare
Thanks @perexg ! I hope I got right now. This version seems to work OK in my tests. |
2b2e831
to
871446c
Compare
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.
only minor comments.
The DMI convention will probably fail on a number of devices, but that's a good start.
ucm2/Intel/sof-hda-dsp/HiFi-sof.conf
Outdated
cset-tlv "name='${var:PostMixerAnalogPlaybackDRCBytes}' ${var:EndpointDrcBlob}" | ||
cset-tlv "name='${var:PostMixerAnalogPlaybackIIRBytes}' ${var:EndpointIirBlob}" | ||
cset-tlv "name='${var:PostMixerAnalogPlaybackFIRBytes}' ${var:EndpointFirBlob}" | ||
#shell "/bin/echo '${var:__endpoint} ${var:EndpointIirBlob} ${var:EndpointFirBlob} ${var:EndpointDrcBlob}' >> /tmp/alsa-ucm.txt" |
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.
is this command left intentionally @singalsu?
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 looks like a debug statement. To raise the log level, uncomment it.
Is there a better logging solution?
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've commented it out because the log file write breaks UCM when the user logs in. When the shell command is enabled I need to "sudo chmod a+rw /tmp/alsa-ucm.txt" and restart ucm to get it working and logging the blob data file applies to DSP. A debug print to e.g. /var/log/syslog would be great but I haven't seen such in documentation.
ucm2/Intel/sof-hda-dsp/HiFi-sof.conf
Outdated
EnableSequence [ | ||
cset-tlv "name='${var:PostMixerAnalogPlaybackIIRBytes}' ${var:EndpointIirBlob}" | ||
cset-tlv "name='${var:PostMixerAnalogPlaybackFIRBytes}' ${var:EndpointFirBlob}" | ||
#shell "/bin/echo '${var:__endpoint} ${var:EndpointIirBlob} ${var:EndpointFirBlob}' >> /tmp/alsa-ucm.txt" |
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, why is this one commented out?
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.
Yep, I was thinking to remove these after the script stabilizes. They have been a good help in debugging the failures after changes to script.
Add support for Digital Microphones DMIC01 on Qualcomm X1E80100 CRD board. Closes: alsa-project#414 Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Jaroslav Kysela <[email protected]>
228ef05
to
83907e1
Compare
The example set contains passthrough configuration blobs with SOF IPC3 and IPC4 headers for DRC, FIR, and IIR. A few high-pass configurations are added for IIR to be used e.g. for speakers. A DRC blob is added that can be used to boost speaker playback loudness. The blobs are all in binary format. Signed-off-by: Seppo Ingalsuo <[email protected]>
This example shows how to define IIR, FIR, and DRC processing for speaker and headphone endpoints. Signed-off-by: Seppo Ingalsuo <[email protected]>
83907e1
to
261ff87
Compare
This patch adds to Intel/sof-hda-dsp/HiFi.conf inclusion of HiFi-sof.conf that by redefine of headphone and speaker handling adds to UCM control of DRC and EQ SOF processing components. The modified setting are applied in case of SOF processing components' controls are detected. There is no change to operation if no controls are present e.g. with legacy SOF topology. If DRC control is found, it is assumed that also FIR and IIR also exist. If there is no DRC but FIR is found, then it is assumed that IIR also exists. This matches SOF FW builds for IPC3 (FIR, IIR) and IPC4 (DRC, FIR, IIR). The controls names are different in IPC3 and IPC4 topologies. Also the configuration blobs differ. The speaker mode is by default set up with 100 Hz high-pass IIR. The DRC is set to a default speaker setting that boosts playback loudness. The FIR is bypassed. In the headphone mode all the processing is set to bypass and DRC switch is set off. The processing can be customized for products with UCM scripts placed into blobs/sof/product_configs. The file path should be <sys_vendor>/<product_name>.conf from DMI ID. An user configuration can be similarly placed into blobs/sof/user_configs directory to e.g. avoid it being overwritten by distribution. Signed-off-by: Seppo Ingalsuo <[email protected]>
261ff87
to
a50f7d9
Compare
@singalsu I guess this is now resolved upstream now, if so pls close. Thanks ! |
Yep! |
No description provided.