Skip to content
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

Merged
merged 1 commit into from
Jun 11, 2019

Conversation

bardliao
Copy link
Collaborator

@bardliao bardliao commented Jun 4, 2019

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

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.

code can be further optimized and question on kcontrol init below.

ret = snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
ipc_cmd, ctrl_type,
scontrol->cmd,
false);
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -3005,6 +3053,7 @@ static void sof_complete(struct snd_soc_component *scomp)
break;
}
}
snd_sof_get_kcontrol_val(sdev);
Copy link
Member

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

  1. by topology
  2. by reading DSP values over IPC?
  3. by alsa-mixer?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart done

@bardliao bardliao force-pushed the kcontrol-io branch 2 times, most recently from 806a5b1 to 5c3c4b0 Compare June 5, 2019 01:37
@@ -3005,6 +3048,7 @@ static void sof_complete(struct snd_soc_component *scomp)
break;
}
}
snd_sof_get_kcontrol_val(sdev);
Copy link
Collaborator

@dbaluta dbaluta Jun 5, 2019

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 */

Copy link
Collaborator Author

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.

@bardliao bardliao force-pushed the kcontrol-io branch 2 times, most recently from 301cd45 to fd4c78e Compare June 6, 2019 00:51
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.

Still thrown-off by the last comment

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overwritten

* 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 */
Copy link
Member

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?

Copy link
Collaborator

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

Copy link
Collaborator

@ranj063 ranj063 Jun 10, 2019

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:

  1. There are no default values specified for volume/switch controls in topology
  2. byte controls have the option of adding default data but this is optional
  3. 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
  4. 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.
  5. 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).

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

Copy link
Member

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:

  1. There are no default values specified for volume/switch controls in topology
  2. byte controls have the option of adding default data but this is optional
  3. 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
  4. 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.
  5. 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>
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.

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

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

Copy link
Collaborator

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

@plbossart plbossart merged commit 38d0e9f into thesofproject:topic/sof-dev Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants