-
Notifications
You must be signed in to change notification settings - Fork 131
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: dont wake dsp up in kcontrol IO #1006
Conversation
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.
code can be further optimized and question on kcontrol init below.
sound/soc/sof/topology.c
Outdated
ret = snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, | ||
ipc_cmd, ctrl_type, | ||
scontrol->cmd, | ||
false); |
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 can move this block outside of the switch case since it's duplicated in all cases.
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.
done
sound/soc/sof/topology.c
Outdated
@@ -3005,6 +3053,7 @@ static void sof_complete(struct snd_soc_component *scomp) | |||
break; | |||
} | |||
} | |||
snd_sof_get_kcontrol_val(sdev); |
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 am still lost on how the controls are initialized
- by topology
- by reading DSP values over IPC?
- by alsa-mixer?
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 Currently, we don't have the ability to get the default value by topology. So it is by reading DSP value over IPC for now. And it may be overwrite by alsa-mixer after booting up.
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, you should add a comment on this so that the sequence is documented.
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 done
806a5b1
to
5c3c4b0
Compare
sound/soc/sof/topology.c
Outdated
@@ -3005,6 +3048,7 @@ static void sof_complete(struct snd_soc_component *scomp) | |||
break; | |||
} | |||
} | |||
snd_sof_get_kcontrol_val(sdev); |
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.
Maybe add a comment here letting the readers know that we are caching kcontrol values now in order to use them later and not do calls to DSP everytime.
e.g /* cache initial values of SOF 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.
@dbaluta done. I also rename the function.
301cd45
to
fd4c78e
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.
Still thrown-off by the last comment
sound/soc/sof/topology.c
Outdated
@@ -3005,6 +3048,12 @@ static void sof_complete(struct snd_soc_component *scomp) | |||
break; | |||
} | |||
} | |||
/* | |||
* cache initial values of SOF kcontrols by reading DSP value over | |||
* IPC. It may be overwrite by alsa-mixer after booting up |
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.
overwritten
sound/soc/sof/topology.c
Outdated
* cache initial values of SOF kcontrols by reading DSP value over | ||
* IPC. It may be overwrite by alsa-mixer after booting up | ||
*/ | ||
/* TODO: cache initial values of SOF kcontrols by 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.
well that confuses me.
@ranj063 is there a way to get those values from topology, and if yes, why do we read from the DSP?
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 this was my thinking too. There are 3 open PR's all addressing kcontrol IO issues and they're all related. Let me spend some time over the next couple of days to connect them all
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 @bardliao I looked into this and there are a few things I want to bring up:
- There are no default values specified for volume/switch controls in topology
- byte controls have the option of adding default data but this is optional
- Even if there are default values specified in topology, the DSP can override these values based on whether these are valid or not. For example, if the defaul value for volume control exceeds the max supported, the DSP will only set the default value to 0DB atm
- But overall I agree with the idea that kcontrol IO get could always return the cached value. But this does need the step below to cache the value by reading it once from the DSP.
- Lastly, I do not understand what this comment means "TODO: cache initial values of SOF kcontrols by topology"?
For the case of process type components, it is already cached (please refer to jaska's PR).
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 The TODO is originally a reminder to me to get the cached data from topology is there is one. But on the second thought, I think we don't need to do here. We can set the topology's default value to the dsp in topology loading and get the value via ipc here. It can prevent the error if the dsp didn't accept the topology's default value.
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 @bardliao I looked into this and there are a few things I want to bring up:
- There are no default values specified for volume/switch controls in topology
- byte controls have the option of adding default data but this is optional
- Even if there are default values specified in topology, the DSP can override these values based on whether these are valid or not. For example, if the defaul value for volume control exceeds the max supported, the DSP will only set the default value to 0DB atm
- But overall I agree with the idea that kcontrol IO get could always return the cached value. But this does need the step below to cache the value by reading it once from the DSP.
- Lastly, I do not understand what this comment means "TODO: cache initial values of SOF kcontrols by topology"?
For the case of process type components, it is already cached (please refer to jaska's PR).
@ranj063 I take your answer as agreement but would like a formal approval before I merge. Thanks
Always get kcontrol value from cache, set kcontrol value to DSP when DSP is active. Kcontrol values will be restored when DSP boot up. We will set the default value of kcontrol in sof_complete to make sure the value is align with firmware. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
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.
looks good but question below:
* cache initial values of SOF kcontrols by reading DSP value over | ||
* IPC. It may be overwritten by alsa-mixer after booting up | ||
*/ | ||
snd_sof_cache_kcontrol_val(sdev); |
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.
question: do we deal with this cache at the first boot or every time we resume (runtime_pm or not)?
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 think it is enough if we do this at first boot. When we resume, we actually do the opposite where we send the cached values to the DSP
Always get kcontrol value from cache, set kcontrol value to DSP
when DSP is active. Kcontrol values will be restored when DSP boot up.
We will set the default value of kcontrol in sof_complete to make sure
the value is align with firmware.
The benefit of this PR is that we don't need to power up/down DSP repeatedly when we want to get/set a set of kcontrols.
Currently, we set the kcontorl default value by reading from FW. We can send another patch to prioritize it to read from topology first once we can get the default value from topology.
The PR is rebased from #169