Commit 73d9cf7c authored by Mark Brown's avatar Mark Brown

Clean ups and preparation for IPC abstraction in the SOF driver

Merge series from Ranjani Sridharan <ranjani.sridharan@linux.intel.com>:

In preparation for adding support for the new IPC version that has been
introduced in the SOF firmware, this patch set includes some clean ups
and necessary modifications to commonly used functions that will be
re-used across different IPC-specific code.
parents 6b1b0f7d 40bdb2fd
...@@ -442,16 +442,8 @@ int snd_sof_device_remove(struct device *dev) ...@@ -442,16 +442,8 @@ int snd_sof_device_remove(struct device *dev)
snd_sof_ipc_free(sdev); snd_sof_ipc_free(sdev);
snd_sof_free_debug(sdev); snd_sof_free_debug(sdev);
}
/*
* Unregistering the machine driver results in unloading the topology.
* Some widgets, ex: scheduler, attempt to power down the core they are
* scheduled on, when they are unloaded. Therefore, the DSP must be
* removed only after the topology has been unloaded.
*/
if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED)
snd_sof_remove(sdev); snd_sof_remove(sdev);
}
/* release firmware */ /* release firmware */
snd_sof_fw_unload(sdev); snd_sof_fw_unload(sdev);
......
...@@ -717,7 +717,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa ...@@ -717,7 +717,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
/* read format from topology */ /* read format from topology */
snd_mask_none(fmt); snd_mask_none(fmt);
switch (dai->comp_dai.config.frame_fmt) { switch (dai->comp_dai->config.frame_fmt) {
case SOF_IPC_FRAME_S16_LE: case SOF_IPC_FRAME_S16_LE:
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE); snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
break; break;
...@@ -752,10 +752,10 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa ...@@ -752,10 +752,10 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
break; break;
case SOF_DAI_INTEL_DMIC: case SOF_DAI_INTEL_DMIC:
/* DMIC only supports 16 or 32 bit formats */ /* DMIC only supports 16 or 32 bit formats */
if (dai->comp_dai.config.frame_fmt == SOF_IPC_FRAME_S24_4LE) { if (dai->comp_dai->config.frame_fmt == SOF_IPC_FRAME_S24_4LE) {
dev_err(component->dev, dev_err(component->dev,
"error: invalid fmt %d for DAI type %d\n", "error: invalid fmt %d for DAI type %d\n",
dai->comp_dai.config.frame_fmt, dai->comp_dai->config.frame_fmt,
dai->dai_config->type); dai->dai_config->type);
} }
break; break;
......
...@@ -103,7 +103,7 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -103,7 +103,7 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
.id = swidget->comp_id, .id = swidget->comp_id,
}; };
struct sof_ipc_reply reply; struct sof_ipc_reply reply;
int ret, ret1, core; int ret, ret1;
if (!swidget->private) if (!swidget->private)
return 0; return 0;
...@@ -112,14 +112,9 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -112,14 +112,9 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
if (--swidget->use_count) if (--swidget->use_count)
return 0; return 0;
core = swidget->core;
switch (swidget->id) { switch (swidget->id) {
case snd_soc_dapm_scheduler: case snd_soc_dapm_scheduler:
{ {
const struct sof_ipc_pipe_new *pipeline = swidget->private;
core = pipeline->core;
ipc_free.hdr.cmd |= SOF_IPC_TPLG_PIPE_FREE; ipc_free.hdr.cmd |= SOF_IPC_TPLG_PIPE_FREE;
break; break;
} }
...@@ -149,10 +144,10 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -149,10 +144,10 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
* disable widget core. continue to route setup status and complete flag * disable widget core. continue to route setup status and complete flag
* even if this fails and return the appropriate error * even if this fails and return the appropriate error
*/ */
ret1 = snd_sof_dsp_core_put(sdev, core); ret1 = snd_sof_dsp_core_put(sdev, swidget->core);
if (ret1 < 0) { if (ret1 < 0) {
dev_err(sdev->dev, "error: failed to disable target core: %d for widget %s\n", dev_err(sdev->dev, "error: failed to disable target core: %d for widget %s\n",
core, swidget->widget->name); swidget->core, swidget->widget->name);
if (!ret) if (!ret)
ret = ret1; ret = ret1;
} }
...@@ -175,9 +170,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -175,9 +170,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
struct sof_ipc_cmd_hdr *hdr; struct sof_ipc_cmd_hdr *hdr;
struct sof_ipc_comp *comp; struct sof_ipc_comp *comp;
struct snd_sof_dai *dai; struct snd_sof_dai *dai;
size_t ipc_size;
int ret; int ret;
int core;
/* skip if there is no private data */ /* skip if there is no private data */
if (!swidget->private) if (!swidget->private)
...@@ -187,15 +180,8 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -187,15 +180,8 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
if (++swidget->use_count > 1) if (++swidget->use_count > 1)
return 0; return 0;
/* set core ID */
core = swidget->core;
if (swidget->id == snd_soc_dapm_scheduler) {
pipeline = swidget->private;
core = pipeline->core;
}
/* enable widget core */ /* enable widget core */
ret = snd_sof_dsp_core_get(sdev, core); ret = snd_sof_dsp_core_get(sdev, swidget->core);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "error: failed to enable target core for widget %s\n", dev_err(sdev->dev, "error: failed to enable target core for widget %s\n",
swidget->widget->name); swidget->widget->name);
...@@ -205,23 +191,12 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -205,23 +191,12 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
switch (swidget->id) { switch (swidget->id) {
case snd_soc_dapm_dai_in: case snd_soc_dapm_dai_in:
case snd_soc_dapm_dai_out: case snd_soc_dapm_dai_out:
ipc_size = sizeof(struct sof_ipc_comp_dai) + sizeof(struct sof_ipc_comp_ext);
comp = kzalloc(ipc_size, GFP_KERNEL);
if (!comp) {
ret = -ENOMEM;
goto core_put;
}
dai = swidget->private; dai = swidget->private;
comp = &dai->comp_dai->comp;
dai->configured = false; dai->configured = false;
memcpy(comp, &dai->comp_dai, sizeof(struct sof_ipc_comp_dai));
/* append extended data to the end of the component */ ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, dai->comp_dai, comp->hdr.size,
memcpy((u8 *)comp + sizeof(struct sof_ipc_comp_dai), &swidget->comp_ext, &r, sizeof(r));
sizeof(swidget->comp_ext));
ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, comp, ipc_size, &r, sizeof(r));
kfree(comp);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "error: failed to load widget %s\n", dev_err(sdev->dev, "error: failed to load widget %s\n",
swidget->widget->name); swidget->widget->name);
...@@ -275,7 +250,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ...@@ -275,7 +250,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
return 0; return 0;
core_put: core_put:
snd_sof_dsp_core_put(sdev, core); snd_sof_dsp_core_put(sdev, swidget->core);
use_count_dec: use_count_dec:
swidget->use_count--; swidget->use_count--;
return ret; return ret;
...@@ -624,22 +599,6 @@ int sof_set_hw_params_upon_resume(struct device *dev) ...@@ -624,22 +599,6 @@ int sof_set_hw_params_upon_resume(struct device *dev)
return snd_sof_dsp_hw_params_upon_resume(sdev); return snd_sof_dsp_hw_params_upon_resume(sdev);
} }
const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
int pipeline_id)
{
const struct snd_sof_widget *swidget;
list_for_each_entry(swidget, &sdev->widget_list, list)
if (swidget->id == snd_soc_dapm_scheduler) {
const struct sof_ipc_pipe_new *pipeline =
swidget->private;
if (pipeline->pipeline_id == pipeline_id)
return pipeline;
}
return NULL;
}
int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify) int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
{ {
struct sof_ipc_fw_version *v = &sdev->fw_ready.version; struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
...@@ -895,20 +854,6 @@ struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp, ...@@ -895,20 +854,6 @@ struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
return NULL; return NULL;
} }
struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp,
unsigned int pcm_id)
{
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_sof_pcm *spcm;
list_for_each_entry(spcm, &sdev->pcm_list, list) {
if (le32_to_cpu(spcm->pcm.pcm_id) == pcm_id)
return spcm;
}
return NULL;
}
struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp, struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp,
const char *name) const char *name)
{ {
......
...@@ -134,7 +134,7 @@ struct snd_sof_dai { ...@@ -134,7 +134,7 @@ struct snd_sof_dai {
struct snd_soc_component *scomp; struct snd_soc_component *scomp;
const char *name; const char *name;
struct sof_ipc_comp_dai comp_dai; struct sof_ipc_comp_dai *comp_dai;
int number_configs; int number_configs;
int current_config; int current_config;
bool configured; /* DAI configured during BE hw_params */ bool configured; /* DAI configured during BE hw_params */
...@@ -220,10 +220,6 @@ struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp, ...@@ -220,10 +220,6 @@ struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp,
struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp, struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
unsigned int comp_id, unsigned int comp_id,
int *direction); int *direction);
struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp,
unsigned int pcm_id);
const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
int pipeline_id);
void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream); void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
void snd_sof_pcm_init_elapsed_work(struct work_struct *work); void snd_sof_pcm_init_elapsed_work(struct work_struct *work);
...@@ -264,4 +260,9 @@ int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev ...@@ -264,4 +260,9 @@ int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev
struct snd_sof_pcm *spcm); struct snd_sof_pcm *spcm);
int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
struct snd_sof_pcm *spcm, int dir, bool free_widget_list); struct snd_sof_pcm *spcm, int dir, bool free_widget_list);
int get_token_u32(void *elem, void *object, u32 offset);
int get_token_u16(void *elem, void *object, u32 offset);
int get_token_comp_format(void *elem, void *object, u32 offset);
int get_token_dai_type(void *elem, void *object, u32 offset);
int get_token_uuid(void *elem, void *object, u32 offset);
#endif #endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment