Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,37 +158,42 @@ static int hda_link_config_ipc(struct sof_intel_hda_stream *hda_stream,
struct snd_sof_dai *sof_dai;
struct sof_ipc_reply reply;
int ret = 0;
int i;

list_for_each_entry(sof_dai, &hda_stream->sdev->dai_list, list) {
if (!sof_dai->cpu_dai_name)
continue;

if (!strcmp(dai_name, sof_dai->cpu_dai_name) &&
dir == sof_dai->comp_dai.direction) {
config = sof_dai->dai_config;
for (i = 0; i < sof_dai->num_configs; i++) {
config = sof_dai->dai_config[i];

if (!config) {
dev_err(hda_stream->sdev->dev,
"error: no config for DAI %s\n",
sof_dai->name);
return -EINVAL;
}

if (!config) {
dev_err(hda_stream->sdev->dev,
"error: no config for DAI %s\n",
sof_dai->name);
return -EINVAL;
/* update config with stream tag */
config->hda.link_dma_ch = channel;

/* send IPC */
ret = sof_ipc_tx_message(hda_stream->sdev->ipc,
config->hdr.cmd,
config,
config->hdr.size,
&reply, sizeof(reply));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right there I don't understand how this patch would work. There is nothing in the config that is passed to the firmware that identifies it uniquely, so how would we select one in hw_params? Don't we need a lot more logic than just passing N configs instead of 1? And don't we need a matching PR for firmware to store these configs?


if (ret < 0) {
dev_err(hda_stream->sdev->dev,
"error: failed to set dai config for %s\n",
sof_dai->name);
return ret;
}
}

/* update config with stream tag */
config->hda.link_dma_ch = channel;

/* send IPC */
ret = sof_ipc_tx_message(hda_stream->sdev->ipc,
config->hdr.cmd,
config,
config->hdr.size,
&reply, sizeof(reply));

if (ret < 0)
dev_err(hda_stream->sdev->dev,
"error: failed to set dai config for %s\n",
sof_dai->name);
return ret;
return 0;
}
}

Expand Down
18 changes: 11 additions & 7 deletions sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
struct snd_sof_dai *dai =
snd_sof_find_dai(sdev, (char *)rtd->dai_link->name);
int i;

/* no topology exists for this BE, try a common configuration */
if (!dai) {
Expand Down Expand Up @@ -646,12 +647,15 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
}

/* read rate and channels from topology */
switch (dai->dai_config->type) {

i = dai->cur_config;

switch (dai->dai_config[i]->type) {
case SOF_DAI_INTEL_SSP:
rate->min = dai->dai_config->ssp.fsync_rate;
rate->max = dai->dai_config->ssp.fsync_rate;
channels->min = dai->dai_config->ssp.tdm_slots;
channels->max = dai->dai_config->ssp.tdm_slots;
rate->min = dai->dai_config[i]->ssp.fsync_rate;
rate->max = dai->dai_config[i]->ssp.fsync_rate;
channels->min = dai->dai_config[i]->ssp.tdm_slots;
channels->max = dai->dai_config[i]->ssp.tdm_slots;

dev_dbg(sdev->dev,
"rate_min: %d rate_max: %d\n", rate->min, rate->max);
Expand All @@ -666,15 +670,15 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
dev_err(sdev->dev,
"error: invalid fmt %d for DAI type %d\n",
dai->comp_dai.config.frame_fmt,
dai->dai_config->type);
dai->dai_config[i]->type);
}
break;
case SOF_DAI_INTEL_HDA:
/* do nothing for HDA dai_link */
break;
default:
dev_err(sdev->dev, "error: invalid DAI type %d\n",
dai->dai_config->type);
dai->dai_config[i]->type);
break;
}

Expand Down
50 changes: 27 additions & 23 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,34 +145,38 @@ static int sof_restore_pipelines(struct snd_sof_dev *sdev)
/* restore dai links */
list_for_each_entry_reverse(dai, &sdev->dai_list, list) {
struct sof_ipc_reply reply;
struct sof_ipc_dai_config *config = dai->dai_config;
int i;

if (!config) {
dev_err(sdev->dev, "error: no config for DAI %s\n",
dai->name);
continue;
}
for (i = 0; i < dai->num_configs; i++) {
struct sof_ipc_dai_config *config = dai->dai_config[i];

/*
* The link DMA channel would be invalidated for running
* streams but not for streams that were in the PAUSED
* state during suspend. So invalidate it here before setting
* the dai config in the DSP.
*/
if (config->type == SOF_DAI_INTEL_HDA)
config->hda.link_dma_ch = DMA_CHAN_INVALID;
if (!config) {
dev_err(sdev->dev, "error: no config %d for DAI %s\n",
i, dai->name);
continue;
}

ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config,
config->hdr.size,
&reply, sizeof(reply));
/*
* The link DMA channel would be invalidated for running
* streams but not for streams that were in the PAUSED
* state during suspend. So invalidate it here before
* setting the dai config in the DSP.
*/
if (config->type == SOF_DAI_INTEL_HDA)
config->hda.link_dma_ch = DMA_CHAN_INVALID;

if (ret < 0) {
dev_err(sdev->dev,
"error: failed to set dai config for %s\n",
dai->name);
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config,
config->hdr.size,
&reply, sizeof(reply));

return ret;
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to set dai config %d for %s\n",
i, dai->name);

return ret;
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@

#define DMA_CHAN_INVALID 0xFFFFFFFF

#define SOF_DAI_HW_CONFIG_MAX SND_SOC_TPLG_HW_CONFIG_MAX

struct snd_sof_dev;
struct snd_sof_ipc_msg;
struct snd_sof_ipc;
Expand Down Expand Up @@ -346,7 +348,9 @@ struct snd_sof_dai {
const char *cpu_dai_name;

struct sof_ipc_comp_dai comp_dai;
struct sof_ipc_dai_config *dai_config;
struct sof_ipc_dai_config *dai_config[SOF_DAI_HW_CONFIG_MAX];
int num_configs;
int cur_config;
struct list_head list; /* list in sdev dai list */
};

Expand Down
Loading