aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/soc/sof/core.c10
-rw-r--r--sound/soc/sof/pcm.c6
-rw-r--r--sound/soc/sof/sof-audio.c71
-rw-r--r--sound/soc/sof/sof-audio.h11
-rw-r--r--sound/soc/sof/topology.c206
5 files changed, 102 insertions, 202 deletions
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index 2a35d8ddf43e..95a845d26f6e 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -442,16 +442,8 @@ int snd_sof_device_remove(struct device *dev)
snd_sof_ipc_free(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);
+ }
/* release firmware */
snd_sof_fw_unload(sdev);
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index a312ed855f1a..1d04f75e6d32 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -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 */
snd_mask_none(fmt);
- switch (dai->comp_dai.config.frame_fmt) {
+ switch (dai->comp_dai->config.frame_fmt) {
case SOF_IPC_FRAME_S16_LE:
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
break;
@@ -752,10 +752,10 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
break;
case SOF_DAI_INTEL_DMIC:
/* 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,
"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);
}
break;
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index 9e76b796502f..b49d8e348077 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -103,7 +103,7 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
.id = swidget->comp_id,
};
struct sof_ipc_reply reply;
- int ret, ret1, core;
+ int ret, ret1;
if (!swidget->private)
return 0;
@@ -112,14 +112,9 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
if (--swidget->use_count)
return 0;
- core = swidget->core;
-
switch (swidget->id) {
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;
break;
}
@@ -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
* 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) {
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)
ret = ret1;
}
@@ -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_comp *comp;
struct snd_sof_dai *dai;
- size_t ipc_size;
int ret;
- int core;
/* skip if there is no private data */
if (!swidget->private)
@@ -187,15 +180,8 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
if (++swidget->use_count > 1)
return 0;
- /* set core ID */
- core = swidget->core;
- if (swidget->id == snd_soc_dapm_scheduler) {
- pipeline = swidget->private;
- core = pipeline->core;
- }
-
/* enable widget core */
- ret = snd_sof_dsp_core_get(sdev, core);
+ ret = snd_sof_dsp_core_get(sdev, swidget->core);
if (ret < 0) {
dev_err(sdev->dev, "error: failed to enable target core for widget %s\n",
swidget->widget->name);
@@ -205,23 +191,12 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
switch (swidget->id) {
case snd_soc_dapm_dai_in:
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;
+ comp = &dai->comp_dai->comp;
dai->configured = false;
- memcpy(comp, &dai->comp_dai, sizeof(struct sof_ipc_comp_dai));
- /* append extended data to the end of the component */
- memcpy((u8 *)comp + sizeof(struct sof_ipc_comp_dai), &swidget->comp_ext,
- sizeof(swidget->comp_ext));
-
- ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, comp, ipc_size, &r, sizeof(r));
- kfree(comp);
+ ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, dai->comp_dai, comp->hdr.size,
+ &r, sizeof(r));
if (ret < 0) {
dev_err(sdev->dev, "error: failed to load widget %s\n",
swidget->widget->name);
@@ -275,7 +250,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
return 0;
core_put:
- snd_sof_dsp_core_put(sdev, core);
+ snd_sof_dsp_core_put(sdev, swidget->core);
use_count_dec:
swidget->use_count--;
return ret;
@@ -624,22 +599,6 @@ int sof_set_hw_params_upon_resume(struct device *dev)
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)
{
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,
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,
const char *name)
{
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index f3009e6b91a1..a8eeffc12b24 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -134,7 +134,7 @@ struct snd_sof_dai {
struct snd_soc_component *scomp;
const char *name;
- struct sof_ipc_comp_dai comp_dai;
+ struct sof_ipc_comp_dai *comp_dai;
int number_configs;
int current_config;
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,
struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
unsigned int comp_id,
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_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
struct snd_sof_pcm *spcm);
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);
+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
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 1d119d1dd69d..41927e99ace2 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -473,12 +473,11 @@ static enum sof_comp_type find_process_comp_type(enum sof_ipc_process_type type)
struct sof_topology_token {
u32 token;
u32 type;
- int (*get_token)(void *elem, void *object, u32 offset, u32 size);
+ int (*get_token)(void *elem, void *object, u32 offset);
u32 offset;
- u32 size;
};
-static int get_token_u32(void *elem, void *object, u32 offset, u32 size)
+int get_token_u32(void *elem, void *object, u32 offset)
{
struct snd_soc_tplg_vendor_value_elem *velem = elem;
u32 *val = (u32 *)((u8 *)object + offset);
@@ -487,7 +486,7 @@ static int get_token_u32(void *elem, void *object, u32 offset, u32 size)
return 0;
}
-static int get_token_u16(void *elem, void *object, u32 offset, u32 size)
+int get_token_u16(void *elem, void *object, u32 offset)
{
struct snd_soc_tplg_vendor_value_elem *velem = elem;
u16 *val = (u16 *)((u8 *)object + offset);
@@ -496,7 +495,7 @@ static int get_token_u16(void *elem, void *object, u32 offset, u32 size)
return 0;
}
-static int get_token_uuid(void *elem, void *object, u32 offset, u32 size)
+int get_token_uuid(void *elem, void *object, u32 offset)
{
struct snd_soc_tplg_vendor_uuid_elem *velem = elem;
u8 *dst = (u8 *)object + offset;
@@ -506,111 +505,107 @@ static int get_token_uuid(void *elem, void *object, u32 offset, u32 size)
return 0;
}
-static int get_token_comp_format(void *elem, void *object, u32 offset, u32 size)
+int get_token_comp_format(void *elem, void *object, u32 offset)
{
- struct snd_soc_tplg_vendor_string_elem *velem = elem;
u32 *val = (u32 *)((u8 *)object + offset);
- *val = find_format(velem->string);
+ *val = find_format((const char *)elem);
return 0;
}
-static int get_token_dai_type(void *elem, void *object, u32 offset, u32 size)
+int get_token_dai_type(void *elem, void *object, u32 offset)
{
- struct snd_soc_tplg_vendor_string_elem *velem = elem;
u32 *val = (u32 *)((u8 *)object + offset);
- *val = find_dai(velem->string);
+ *val = find_dai((const char *)elem);
return 0;
}
-static int get_token_process_type(void *elem, void *object, u32 offset,
- u32 size)
+static int get_token_process_type(void *elem, void *object, u32 offset)
{
- struct snd_soc_tplg_vendor_string_elem *velem = elem;
u32 *val = (u32 *)((u8 *)object + offset);
- *val = find_process(velem->string);
+ *val = find_process((const char *)elem);
return 0;
}
/* Buffers */
static const struct sof_topology_token buffer_tokens[] = {
{SOF_TKN_BUF_SIZE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_buffer, size), 0},
+ offsetof(struct sof_ipc_buffer, size)},
{SOF_TKN_BUF_CAPS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_buffer, caps), 0},
+ offsetof(struct sof_ipc_buffer, caps)},
};
/* DAI */
static const struct sof_topology_token dai_tokens[] = {
{SOF_TKN_DAI_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_dai_type,
- offsetof(struct sof_ipc_comp_dai, type), 0},
+ offsetof(struct sof_ipc_comp_dai, type)},
{SOF_TKN_DAI_INDEX, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_dai, dai_index), 0},
+ offsetof(struct sof_ipc_comp_dai, dai_index)},
{SOF_TKN_DAI_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_dai, direction), 0},
+ offsetof(struct sof_ipc_comp_dai, direction)},
};
/* BE DAI link */
static const struct sof_topology_token dai_link_tokens[] = {
{SOF_TKN_DAI_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_dai_type,
- offsetof(struct sof_ipc_dai_config, type), 0},
+ offsetof(struct sof_ipc_dai_config, type)},
{SOF_TKN_DAI_INDEX, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_config, dai_index), 0},
+ offsetof(struct sof_ipc_dai_config, dai_index)},
};
/* scheduling */
static const struct sof_topology_token sched_tokens[] = {
{SOF_TKN_SCHED_PERIOD, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_pipe_new, period), 0},
+ offsetof(struct sof_ipc_pipe_new, period)},
{SOF_TKN_SCHED_PRIORITY, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_pipe_new, priority), 0},
+ offsetof(struct sof_ipc_pipe_new, priority)},
{SOF_TKN_SCHED_MIPS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_pipe_new, period_mips), 0},
+ offsetof(struct sof_ipc_pipe_new, period_mips)},
{SOF_TKN_SCHED_CORE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_pipe_new, core), 0},
+ offsetof(struct sof_ipc_pipe_new, core)},
{SOF_TKN_SCHED_FRAMES, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_pipe_new, frames_per_sched), 0},
+ offsetof(struct sof_ipc_pipe_new, frames_per_sched)},
{SOF_TKN_SCHED_TIME_DOMAIN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_pipe_new, time_domain), 0},
+ offsetof(struct sof_ipc_pipe_new, time_domain)},
};
static const struct sof_topology_token pipeline_tokens[] = {
{SOF_TKN_SCHED_DYNAMIC_PIPELINE, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
- offsetof(struct snd_sof_widget, dynamic_pipeline_widget), 0},
+ offsetof(struct snd_sof_widget, dynamic_pipeline_widget)},
};
/* volume */
static const struct sof_topology_token volume_tokens[] = {
{SOF_TKN_VOLUME_RAMP_STEP_TYPE, SND_SOC_TPLG_TUPLE_TYPE_WORD,
- get_token_u32, offsetof(struct sof_ipc_comp_volume, ramp), 0},
+ get_token_u32, offsetof(struct sof_ipc_comp_volume, ramp)},
{SOF_TKN_VOLUME_RAMP_STEP_MS,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_volume, initial_ramp), 0},
+ offsetof(struct sof_ipc_comp_volume, initial_ramp)},
};
/* SRC */
static const struct sof_topology_token src_tokens[] = {
{SOF_TKN_SRC_RATE_IN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_src, source_rate), 0},
+ offsetof(struct sof_ipc_comp_src, source_rate)},
{SOF_TKN_SRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_src, sink_rate), 0},
+ offsetof(struct sof_ipc_comp_src, sink_rate)},
};
/* ASRC */
static const struct sof_topology_token asrc_tokens[] = {
{SOF_TKN_ASRC_RATE_IN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_asrc, source_rate), 0},
+ offsetof(struct sof_ipc_comp_asrc, source_rate)},
{SOF_TKN_ASRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_asrc, sink_rate), 0},
+ offsetof(struct sof_ipc_comp_asrc, sink_rate)},
{SOF_TKN_ASRC_ASYNCHRONOUS_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32,
- offsetof(struct sof_ipc_comp_asrc, asynchronous_mode), 0},
+ offsetof(struct sof_ipc_comp_asrc, asynchronous_mode)},
{SOF_TKN_ASRC_OPERATION_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32,
- offsetof(struct sof_ipc_comp_asrc, operation_mode), 0},
+ offsetof(struct sof_ipc_comp_asrc, operation_mode)},
};
/* Tone */
@@ -621,62 +616,62 @@ static const struct sof_topology_token tone_tokens[] = {
static const struct sof_topology_token process_tokens[] = {
{SOF_TKN_PROCESS_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING,
get_token_process_type,
- offsetof(struct sof_ipc_comp_process, type), 0},
+ offsetof(struct sof_ipc_comp_process, type)},
};
/* PCM */
static const struct sof_topology_token pcm_tokens[] = {
{SOF_TKN_PCM_DMAC_CONFIG, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_host, dmac_config), 0},
+ offsetof(struct sof_ipc_comp_host, dmac_config)},
};
/* PCM */
static const struct sof_topology_token stream_tokens[] = {
{SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3,
SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
- offsetof(struct snd_sof_pcm, stream[0].d0i3_compatible), 0},
+ offsetof(struct snd_sof_pcm, stream[0].d0i3_compatible)},
{SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3,
SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
- offsetof(struct snd_sof_pcm, stream[1].d0i3_compatible), 0},
+ offsetof(struct snd_sof_pcm, stream[1].d0i3_compatible)},
};
/* Generic components */
static const struct sof_topology_token comp_tokens[] = {
{SOF_TKN_COMP_PERIOD_SINK_COUNT,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_config, periods_sink), 0},
+ offsetof(struct sof_ipc_comp_config, periods_sink)},
{SOF_TKN_COMP_PERIOD_SOURCE_COUNT,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp_config, periods_source), 0},
+ offsetof(struct sof_ipc_comp_config, periods_source)},
{SOF_TKN_COMP_FORMAT,
SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format,
- offsetof(struct sof_ipc_comp_config, frame_fmt), 0},
+ offsetof(struct sof_ipc_comp_config, frame_fmt)},
};
/* SSP */
static const struct sof_topology_token ssp_tokens[] = {
{SOF_TKN_INTEL_SSP_CLKS_CONTROL,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_ssp_params, clks_control), 0},
+ offsetof(struct sof_ipc_dai_ssp_params, clks_control)},
{SOF_TKN_INTEL_SSP_MCLK_ID,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_ssp_params, mclk_id), 0},
+ offsetof(struct sof_ipc_dai_ssp_params, mclk_id)},
{SOF_TKN_INTEL_SSP_SAMPLE_BITS, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32,
- offsetof(struct sof_ipc_dai_ssp_params, sample_valid_bits), 0},
+ offsetof(struct sof_ipc_dai_ssp_params, sample_valid_bits)},
{SOF_TKN_INTEL_SSP_FRAME_PULSE_WIDTH, SND_SOC_TPLG_TUPLE_TYPE_SHORT,
get_token_u16,
- offsetof(struct sof_ipc_dai_ssp_params, frame_pulse_width), 0},
+ offsetof(struct sof_ipc_dai_ssp_params, frame_pulse_width)},
{SOF_TKN_INTEL_SSP_QUIRKS, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32,
- offsetof(struct sof_ipc_dai_ssp_params, quirks), 0},
+ offsetof(struct sof_ipc_dai_ssp_params, quirks)},
{SOF_TKN_INTEL_SSP_TDM_PADDING_PER_SLOT, SND_SOC_TPLG_TUPLE_TYPE_BOOL,
get_token_u16,
offsetof(struct sof_ipc_dai_ssp_params,
- tdm_per_slot_padding_flag), 0},
+ tdm_per_slot_padding_flag)},
{SOF_TKN_INTEL_SSP_BCLK_DELAY, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32,
- offsetof(struct sof_ipc_dai_ssp_params, bclk_delay), 0},
+ offsetof(struct sof_ipc_dai_ssp_params, bclk_delay)},
};
@@ -684,43 +679,42 @@ static const struct sof_topology_token ssp_tokens[] = {
static const struct sof_topology_token alh_tokens[] = {
{SOF_TKN_INTEL_ALH_RATE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_alh_params, rate), 0},
+ offsetof(struct sof_ipc_dai_alh_params, rate)},
{SOF_TKN_INTEL_ALH_CH,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_alh_params, channels), 0},
+ offsetof(struct sof_ipc_dai_alh_params, channels)},
};
/* DMIC */
static const struct sof_topology_token dmic_tokens[] = {
{SOF_TKN_INTEL_DMIC_DRIVER_VERSION,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_dmic_params, driver_ipc_version),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_params, driver_ipc_version)},
{SOF_TKN_INTEL_DMIC_CLK_MIN,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_dmic_params, pdmclk_min), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, pdmclk_min)},
{SOF_TKN_INTEL_DMIC_CLK_MAX,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_dmic_params, pdmclk_max), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, pdmclk_max)},
{SOF_TKN_INTEL_DMIC_SAMPLE_RATE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_dmic_params, fifo_fs), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, fifo_fs)},
{SOF_TKN_INTEL_DMIC_DUTY_MIN,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_params, duty_min), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, duty_min)},
{SOF_TKN_INTEL_DMIC_DUTY_MAX,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_params, duty_max), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, duty_max)},
{SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc_dai_dmic_params,
- num_pdm_active), 0},
+ num_pdm_active)},
{SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_params, fifo_bits), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, fifo_bits)},
{SOF_TKN_INTEL_DMIC_UNMUTE_RAMP_TIME_MS,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_dmic_params, unmute_ramp_time), 0},
+ offsetof(struct sof_ipc_dai_dmic_params, unmute_ramp_time)},
};
@@ -728,28 +722,28 @@ static const struct sof_topology_token dmic_tokens[] = {
static const struct sof_topology_token esai_tokens[] = {
{SOF_TKN_IMX_ESAI_MCLK_ID,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_esai_params, mclk_id), 0},
+ offsetof(struct sof_ipc_dai_esai_params, mclk_id)},
};
/* SAI */
static const struct sof_topology_token sai_tokens[] = {
{SOF_TKN_IMX_SAI_MCLK_ID,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_sai_params, mclk_id), 0},
+ offsetof(struct sof_ipc_dai_sai_params, mclk_id)},
};
/* Core tokens */
static const struct sof_topology_token core_tokens[] = {
{SOF_TKN_COMP_CORE_ID,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_comp, core), 0},
+ offsetof(struct sof_ipc_comp, core)},
};
/* Component extended tokens */
static const struct sof_topology_token comp_ext_tokens[] = {
{SOF_TKN_COMP_UUID,
SND_SOC_TPLG_TUPLE_TYPE_UUID, get_token_uuid,
- offsetof(struct sof_ipc_comp_ext, uuid), 0},
+ offsetof(struct sof_ipc_comp_ext, uuid)},
};
/*
@@ -761,63 +755,56 @@ static const struct sof_topology_token comp_ext_tokens[] = {
static const struct sof_topology_token dmic_pdm_tokens[] = {
{SOF_TKN_INTEL_DMIC_PDM_CTRL_ID,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, id),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, id),},
{SOF_TKN_INTEL_DMIC_PDM_MIC_A_Enable,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, enable_mic_a),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, enable_mic_a)},
{SOF_TKN_INTEL_DMIC_PDM_MIC_B_Enable,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, enable_mic_b),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, enable_mic_b)},
{SOF_TKN_INTEL_DMIC_PDM_POLARITY_A,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, polarity_mic_a),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, polarity_mic_a)},
{SOF_TKN_INTEL_DMIC_PDM_POLARITY_B,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, polarity_mic_b),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, polarity_mic_b)},
{SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, clk_edge),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, clk_edge)},
{SOF_TKN_INTEL_DMIC_PDM_SKEW,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
- offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, skew),
- 0},
+ offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, skew)},
};
/* HDA */
static const struct sof_topology_token hda_tokens[] = {
{SOF_TKN_INTEL_HDA_RATE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_hda_params, rate), 0},
+ offsetof(struct sof_ipc_dai_hda_params, rate)},
{SOF_TKN_INTEL_HDA_CH,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_hda_params, channels), 0},
+ offsetof(struct sof_ipc_dai_hda_params, channels)},
};
/* Leds */
static const struct sof_topology_token led_tokens[] = {
{SOF_TKN_MUTE_LED_USE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct snd_sof_led_control, use_led), 0},
+ offsetof(struct snd_sof_led_control, use_led)},
{SOF_TKN_MUTE_LED_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_WORD,
- get_token_u32, offsetof(struct snd_sof_led_control, direction), 0},
+ get_token_u32, offsetof(struct snd_sof_led_control, direction)},
};
/* AFE */
static const struct sof_topology_token afe_tokens[] = {
{SOF_TKN_MEDIATEK_AFE_RATE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_mtk_afe_params, rate), 0},
+ offsetof(struct sof_ipc_dai_mtk_afe_params, rate)},
{SOF_TKN_MEDIATEK_AFE_CH,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
- offsetof(struct sof_ipc_dai_mtk_afe_params, channels), 0},
+ offsetof(struct sof_ipc_dai_mtk_afe_params, channels)},
{SOF_TKN_MEDIATEK_AFE_FORMAT,
SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format,
- offsetof(struct sof_ipc_dai_mtk_afe_params, format), 0},
+ offsetof(struct sof_ipc_dai_mtk_afe_params, format)},
};
static int sof_parse_uuid_tokens(struct snd_soc_component *scomp,
@@ -847,8 +834,7 @@ static int sof_parse_uuid_tokens(struct snd_soc_component *scomp,
/* matched - now load token */
tokens[j].get_token(elem, object,
- offset + tokens[j].offset,
- tokens[j].size);
+ offset + tokens[j].offset);
found++;
}
@@ -883,9 +869,7 @@ static int sof_parse_string_tokens(struct snd_soc_component *scomp,
continue;
/* matched - now load token */
- tokens[j].get_token(elem, object,
- offset + tokens[j].offset,
- tokens[j].size);
+ tokens[j].get_token(elem->string, object, offset + tokens[j].offset);
found++;
}
@@ -924,8 +908,7 @@ static int sof_parse_word_tokens(struct snd_soc_component *scomp,
/* load token */
tokens[j].get_token(elem, object,
- offset + tokens[j].offset,
- tokens[j].size);
+ offset + tokens[j].offset);
found++;
}
@@ -1495,7 +1478,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
if (ret != 0) {
dev_err(scomp->dev, "error: parse dai tokens failed %d\n",
le32_to_cpu(private->size));
- goto finish;
+ return ret;
}
ret = sof_parse_tokens(scomp, &comp_dai->config, comp_tokens,
@@ -1504,7 +1487,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
if (ret != 0) {
dev_err(scomp->dev, "error: parse dai.cfg tokens failed %d\n",
private->size);
- goto finish;
+ return ret;
}
dev_dbg(scomp->dev, "dai %s: type %d index %d\n",
@@ -1513,17 +1496,9 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
if (dai) {
dai->scomp = scomp;
-
- /*
- * copy only the sof_ipc_comp_dai to avoid collapsing
- * the snd_sof_dai, the extended data is kept in the
- * snd_sof_widget.
- */
- memcpy(&dai->comp_dai, comp_dai, sizeof(*comp_dai));
+ dai->comp_dai = comp_dai;
}
-finish:
- kfree(comp_dai);
return ret;
}
@@ -1707,6 +1682,7 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, int index,
pipeline->period_mips, pipeline->core, pipeline->frames_per_sched,
swidget->dynamic_pipeline_widget);
+ swidget->core = pipeline->core;
swidget->private = pipeline;
return 0;
@@ -2445,6 +2421,7 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
dai = swidget->private;
if (dai) {
+ kfree(dai->comp_dai);
/* free dai config */
kfree(dai->dai_config);
list_del(&dai->list);
@@ -2684,7 +2661,7 @@ static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size,
* dai_index.
*/
for (i = 0; i < num_conf; i++)
- config[i].dai_index = dai->comp_dai.dai_index;
+ config[i].dai_index = dai->comp_dai->dai_index;
dev_dbg(sdev->dev, "set DAI config for %s index %d\n",
dai->name, config[curr_conf].dai_index);
@@ -3013,7 +2990,6 @@ static int sof_link_afe_load(struct snd_soc_component *scomp, int index,
{
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv;
- struct snd_soc_dai *dai;
u32 size = sizeof(*config);
int ret;
@@ -3032,12 +3008,6 @@ static int sof_link_afe_load(struct snd_soc_component *scomp, int index,
dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n",
config->afe.rate, config->afe.channels, config->afe.format);
- dai = snd_soc_find_dai(link->cpus);
- if (!dai) {
- dev_err(scomp->dev, "%s: failed to find dai %s", __func__, link->cpus->dai_name);
- return -EINVAL;
- }
-
config->afe.stream_id = DMA_CHAN_INVALID;
ret = sof_set_dai_config(sdev, size, link, config);
@@ -3139,7 +3109,6 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,
{
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv;
- struct snd_soc_dai *dai;
u32 size = sizeof(*config);
int ret;
@@ -3160,13 +3129,6 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,
dev_dbg(scomp->dev, "HDA config rate %d channels %d\n",
config->hda.rate, config->hda.channels);
- dai = snd_soc_find_dai(link->cpus);
- if (!dai) {
- dev_err(scomp->dev, "error: failed to find dai %s in %s",
- link->cpus->dai_name, __func__);
- return -EINVAL;
- }
-
config->hda.link_dma_ch = DMA_CHAN_INVALID;
ret = sof_set_dai_config(sdev, size, link, config);