-
Notifications
You must be signed in to change notification settings - Fork 132
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
ASoC: SOF: topology: set default values to volume control #258
Conversation
Can one of the admins verify this patch? |
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.
Some cosmetic changes and a more important question on whether we'd override user defaults (if any) stored in astate.conf?
sound/soc/sof/topology.c
Outdated
@@ -1258,6 +1261,13 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, | |||
goto err; | |||
} | |||
|
|||
/* set default max volume values to control */ |
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.
default 0dB?
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 but in theory 0 dB could be out of min..max range. So use max if 0 dB is above range.
vol = min(vol_0db, vol_max);
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.
ok. but so what is max and where do I get it :) ?
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 I know left it to 0db. I can do later the min(0 or max), but I need to change a lot to get the max from topology.
sound/soc/sof/topology.c
Outdated
const unsigned int *p; | ||
int ret, tlv[TLV_ITEMS]; | ||
int ret, i, tlv[TLV_ITEMS]; |
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.
nitpick: kernel reviewers like xmas-tree declarations and variables on different lines.
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.
ok will fix
sound/soc/sof/topology.c
Outdated
@@ -36,6 +36,8 @@ | |||
#define VOLUME_FWL 16 | |||
/* 0.5 dB step value in topology TLV */ | |||
#define VOL_HALF_DB_STEP 50 | |||
/* full volume for default values */ | |||
#define VOL_ZERO_DB (1 << 16) |
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.
BIT(VOLUME_FWL) ?
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.
ok, I didn't even check/understand the previously defined values. Can change 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.
Could all add comment to VOLUME_FWL that define to 16 sets the volume linear gain value to use Qx.16 format.
It's out of scope of this PR but those macros VOL_TWENTIETH_ROOT_OF_TEN and VOL_FORTIETH_ROOT_OF_TEN could be re-calculated for a higher number of fractional bits (31) and shifted right by (31-VOLUME_FWL) to match the volume multiplier Q format. Then the used Q format should be controllable in single macro.
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 added your comment to the VOLUME_FWL define.
cdata->chanv[i].channel = i; | ||
cdata->chanv[i].value = VOL_ZERO_DB; | ||
} | ||
|
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.
do you happen to know how this will work or interfere with alsactrl trying to restore previous values?
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 should work, because this is topology loading, and I guess any alsactl command should not come in the middle (?). Not sure what happens if control is called in the middle of topology loading. PM is caching the stuff and in reload this part is never called. However, good point, I'll re-enable my alsactl and give it a try anyway.
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.
@plbossart I tested with following scenario in my ubuntu:
- alsactl removed, so "first boot" set both pga channels to 0db
- I changed manually from alsamixer the pga volumes and re-enabled alsactl
- after boot the pga volumes are still in positions I set in 2
So I can't still guarantee fully all use cases, but this basic one is working.
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.
works for me as well, I took the code and all the settings were moved to 0dB on all PGAs. I changed one of the gains, rebooted and the values were kept, so it looks functional to me. Will merge, thanks Jaska!
Currently volume control doesn't have any default values when it is created. This will cause an issue when PM kicks in and in resume the non-existing values are set to firmware. Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
@juimonen I have 2 questions about this patch:
After the system boots, there always a volume_put() call that sets these values to default. SO, I have not come across the problem of not the driver have no cached value for volume.
|
@juimonen I take back my first comment. I dont see a volume_put() call at boot anymore on the Yorp. So might be a good idea to add this. But do we still need the ipc? |
@ranj063 I see this in up2 with ubuntu, when there's no asound.state file. I think this happens with first boot after flashing the image. I'm not sure if there's some other process that tries to set them at first boot, because I'm not sure I get it every time (I flash quite rarely). Anyway I've seen this issue many times happening. You get it by disabling alsactl. Yorp/Chrome might behave totally different. As said if there is some process in userspace setting the values, there's no issue. I was thinking getting the values with ipc, but this is in the middle of creating the pga, so it doesn't exists yet at this point in dsp. So there are no default values yet, unless we do it after the pga creation. Pipeline is not ready so don't know what would happen with ipc. So this is kind of chicken/egg problem... |
@juimonen for the ipc, we dont need the pipeline, do we? After the ipc to create the volume component is done, we could send another ipc (SOF_IPC_COMP_SET_VALUE) to set the default value for it right? |
@ranj063 You mean calling "get" with ipc? So we should get the default that firmware is setting. Or do you mean that we decide that kernel side is deciding the default and just syncing with DSP? Sorry it is little bit hazy to me which one is deciding... :) |
@ranj063 Ok. I'll try it out. let's see what happens and how it looks like... |
@juimonen thinking about this...can we somehow use the sof_ipc_comp_reply when the new volume comp is setup to respond with the default value in the firmware and use that? |
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.
verified on Up2 w/ HDMI
@ranj063 the solution might not be the optimal or the final one but we've going to review all this anyways when we cache the values instead of always querying the DSP regardless of its state. merged for now to make the problem go away. |
This check erroneously flags cases like the one in my recent printk enumeration patch[0], where the spaces are syntactic, and `section:' vs. `section :' is syntactically important: ERROR: space prohibited before that ':' (ctx:WxW) #258: FILE: include/asm-generic/vmlinux.lds.h:314: + .printk_fmts : AT(ADDR(.printk_fmts) - LOAD_OFFSET) { 0: https://lore.kernel.org/patchwork/patch/1375749/ Link: https://lkml.kernel.org/r/YBwhqsc2TIVeid3t@chrisdown.name Link: https://lkml.kernel.org/r/YB6UsjCOy1qrrlSD@chrisdown.name Signed-off-by: Chris Down <chris@chrisdown.name> Acked-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Add various tests to check maximum number of supported programs being attached: # ./vmtest.sh -- ./test_progs -t tc_opts [...] ./test_progs -t tc_opts [ 1.185325] bpf_testmod: loading out-of-tree module taints kernel. [ 1.186826] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel [ 1.270123] tsc: Refined TSC clocksource calibration: 3407.988 MHz [ 1.272428] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fc932722, max_idle_ns: 440795381586 ns [ 1.276408] clocksource: Switched to clocksource tsc #252 tc_opts_after:OK #253 tc_opts_append:OK #254 tc_opts_basic:OK #255 tc_opts_before:OK #256 tc_opts_chain_classic:OK #257 tc_opts_chain_mixed:OK #258 tc_opts_delete_empty:OK #259 tc_opts_demixed:OK #260 tc_opts_detach:OK #261 tc_opts_detach_after:OK #262 tc_opts_detach_before:OK #263 tc_opts_dev_cleanup:OK #264 tc_opts_invalid:OK #265 tc_opts_max:OK <--- (new test) #266 tc_opts_mixed:OK #267 tc_opts_prepend:OK #268 tc_opts_replace:OK #269 tc_opts_revision:OK Summary: 18/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20230929204121.20305-2-daniel@iogearbox.net
Add a new test case which performs double query of the bpf_mprog through libbpf API, but also via raw bpf(2) syscall. This is testing to gather first the count and then in a subsequent probe the full information with the program array without clearing passed structs in between. # ./vmtest.sh -- ./test_progs -t tc_opts [...] ./test_progs -t tc_opts [ 1.398818] tsc: Refined TSC clocksource calibration: 3407.999 MHz [ 1.400263] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fd336761, max_idle_ns: 440795243819 ns [ 1.402734] clocksource: Switched to clocksource tsc [ 1.426639] bpf_testmod: loading out-of-tree module taints kernel. [ 1.428112] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel #252 tc_opts_after:OK #253 tc_opts_append:OK #254 tc_opts_basic:OK #255 tc_opts_before:OK #256 tc_opts_chain_classic:OK #257 tc_opts_chain_mixed:OK #258 tc_opts_delete_empty:OK #259 tc_opts_demixed:OK #260 tc_opts_detach:OK #261 tc_opts_detach_after:OK #262 tc_opts_detach_before:OK #263 tc_opts_dev_cleanup:OK #264 tc_opts_invalid:OK #265 tc_opts_max:OK #266 tc_opts_mixed:OK #267 tc_opts_prepend:OK #268 tc_opts_query:OK <--- (new test) #269 tc_opts_replace:OK #270 tc_opts_revision:OK Summary: 19/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20231006220655.1653-4-daniel@iogearbox.net Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Add a new test case to query on an empty bpf_mprog and pass the revision directly into expected_revision for attachment to assert that this does succeed. ./test_progs -t tc_opts [ 1.406778] tsc: Refined TSC clocksource calibration: 3407.990 MHz [ 1.408863] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fcaf6eb0, max_idle_ns: 440795321766 ns [ 1.412419] clocksource: Switched to clocksource tsc [ 1.428671] bpf_testmod: loading out-of-tree module taints kernel. [ 1.430260] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel #252 tc_opts_after:OK #253 tc_opts_append:OK #254 tc_opts_basic:OK #255 tc_opts_before:OK #256 tc_opts_chain_classic:OK #257 tc_opts_chain_mixed:OK #258 tc_opts_delete_empty:OK #259 tc_opts_demixed:OK #260 tc_opts_detach:OK #261 tc_opts_detach_after:OK #262 tc_opts_detach_before:OK #263 tc_opts_dev_cleanup:OK #264 tc_opts_invalid:OK #265 tc_opts_max:OK #266 tc_opts_mixed:OK #267 tc_opts_prepend:OK #268 tc_opts_query:OK #269 tc_opts_query_attach:OK <--- (new test) #270 tc_opts_replace:OK #271 tc_opts_revision:OK Summary: 20/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20231006220655.1653-6-daniel@iogearbox.net Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Currently volume control doesn't have any default values
when it is created. This will cause an issue when PM
kicks in and in resume the non-existing values are
set to firmware.
Signed-off-by: Jaska Uimonen jaska.uimonen@intel.com