Clean ups and preparation for IPC abstraction in the SOF driver
Subsystems (3)
cover Clean ups and preparation for IPC abstraction in the SOF driver
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.
Pierre-Louis Bossart (1):
ASoC: SOF: sof-audio: removed unused function
Rander Wang (1):
ASoC: SOF: move definition of snd_sof_ipc to header file
Ranjani Sridharan (16):
ASoC: SOF: remove snd_sof_pipeline_find()
ASoC: SOF: simplify snd_sof_device_remove()
ASoC: SOF: set swidget's core for scheduler widget
ASoC: SOF: topology: remove redundant code
ASoC: SOF: topology: remove redundant code in sof_link_afe_load()
ASoC: SOF: topology: Drop the size parameter from struct
sof_topology_token
ASoC: SOF: topology: Modify the get_token op for string tokens
ASoC: SOF: topology: expose some get_token ops
ASoC: SOF: change comp_dai to a pointer in struct snd_sof_dai
ASoC: SOF: make struct snd_sof_widget IPC agnostic
ASoC: SOF: topology: make sof_route_load() IPC agnostic
ASoC: SOF: Add a tuples array to struct snd_sof_widget
ASoC: SOF: topology: Modify signature for token parsing functions
ASoC: SOF: topology: Rename arguments in sof_parse_token_sets()
ASoC: SOF: topology: Rename arguments in sof_parse_tokens()
ASoC: SOF: make struct snd_sof_dai IPC agnostic
include/sound/sof/dai.h | 5 + include/sound/sof/topology.h | 5 - sound/soc/sof/core.c | 10 +- sound/soc/sof/intel/hda-dai.c | 27 ++- sound/soc/sof/intel/hda.c | 39 +++- sound/soc/sof/ipc.c | 12 -- sound/soc/sof/pcm.c | 77 +++---- sound/soc/sof/sof-audio.c | 108 +++------- sound/soc/sof/sof-audio.h | 30 ++- sound/soc/sof/sof-priv.h | 12 ++ sound/soc/sof/topology.c | 391 +++++++++++++++++----------------- 11 files changed, 354 insertions(+), 362 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/18 ASoC: SOF: remove snd_sof_pipeline_find()
It is not used.
--- sound/soc/sof/sof-audio.c | 16 ---------------- sound/soc/sof/sof-audio.h | 2 -- 2 files changed, 18 deletions(-)
sound/soc/sof/sof-audio.c +0 -16
@@ -624,22 +624,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;
sound/soc/sof/sof-audio.h +0 -2
@@ -222,8 +222,6 @@ struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp, 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);
Signature · 1 line
2.25.1
PATCH 2/18 ASoC: SOF: simplify snd_sof_device_remove()
In reply to Ranjani SridharanThe commit "ASoC: SOF: core: Unregister machine driver before IPC and debugfs" moved the call to unregister the machine driver to be done before freeing the IPC. With this change, we can safely move the call to snd_sof_remove() inside the same if() block just above.
--- sound/soc/sof/core.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
sound/soc/sof/core.c +1 -9
@@ -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);
Signature · 1 line
2.25.1
PATCH 3/18 ASoC: SOF: set swidget's core for scheduler widget
In reply to Ranjani SridharanSet the swidget's core for scheduler type widgets to match that of the pipeline core. This simplifies the flow for core get/put during widget setup/free.
--- sound/soc/sof/sof-audio.c | 23 +++++------------------ sound/soc/sof/topology.c | 1 + 2 files changed, 6 insertions(+), 18 deletions(-)
sound/soc/sof/sof-audio.c +5 -18
@@ -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; }
@@ -177,7 +172,6 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)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 +181,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);
@@ -275,7 +262,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;
sound/soc/sof/topology.c +1 -0
@@ -1707,6 +1707,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 ;
Signature · 1 line
2.25.1
PATCH 4/18 ASoC: SOF: sof-audio: removed unused function
In reply to Ranjani SridharanFrom: Pierre-Louis Bossart <[email protected]>
cppcheck warning:
sound/soc/sof/sof-audio.c:884:0: style: The function 'snd_sof_find_spcm_pcm_id' is never used. [unusedFunction]
--- sound/soc/sof/sof-audio.c | 14 -------------- sound/soc/sof/sof-audio.h | 2 -- 2 files changed, 16 deletions(-)
sound/soc/sof/sof-audio.c +0 -14
@@ -866,20 +866,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) {
sound/soc/sof/sof-audio.h +0 -2
@@ -220,8 +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);void snd_sof_pcm_period_elapsed (struct snd_pcm_substream *substream);void snd_sof_pcm_init_elapsed_work (struct work_struct *work);
Signature · 1 line
2.25.1
PATCH 5/18 ASoC: SOF: topology: remove redundant code
In reply to Ranjani SridharanWith the change in the commit:
"ASoC: SOF: Intel: hda: assign link DMA channel at run-time", there is no need to find the CPU DAI in sof_link_hda_load().
run-time')
--- sound/soc/sof/topology.c | 8 -------- 1 file changed, 8 deletions(-)
sound/soc/sof/topology.c +0 -8
@@ -3140,7 +3140,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;
@@ -3161,13 +3160,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);
Signature · 1 line
2.25.1
PATCH 6/18 ASoC: SOF: topology: remove redundant code in sof_link_afe_load()
In reply to Ranjani SridharanLooks like a copy-paste error. The CPU DAI is never used.
--- sound/soc/sof/topology.c | 7 ------- 1 file changed, 7 deletions(-)
sound/soc/sof/topology.c +0 -7
@@ -3014,7 +3014,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;
@@ -3033,12 +3032,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);
Signature · 1 line
2.25.1
PATCH 7/18 ASoC: SOF: topology: Drop the size parameter from struct sof_topology_token
In reply to Ranjani SridharanIt is always 0 and never used while parsing.
--- sound/soc/sof/topology.c | 163 ++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 88 deletions(-)
sound/soc/sof/topology.c +75 -88
@@ -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) +static 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) +static 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) +static 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,7 +505,7 @@ 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) +static 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);
@@ -515,7 +514,7 @@ static int get_token_comp_format(void *elem, void *object, u32 offset, u32 size)return 0 ; } -static int get_token_dai_type (void *elem,void *object,u32 offset,u32 size) +static 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);
@@ -524,8 +523,7 @@ static int get_token_dai_type(void *elem, void *object, u32 offset, u32 size)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);
@@ -537,80 +535,80 @@ static int get_token_process_type(void *elem, void *object, u32 offset,/* 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 +619,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 +682,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 +725,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 +758,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 +837,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++; }
@@ -884,8 +873,7 @@ static int sof_parse_string_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++; }
@@ -924,8 +912,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++; }
Signature · 1 line
2.25.1
PATCH 8/18 ASoC: SOF: topology: Modify the get_token op for string tokens
In reply to Ranjani SridharanModify the get_token op for string type tokens to pass the string as the argument instead of a pointer to struct snd_soc_tplg_vendor_string_elem.
--- sound/soc/sof/topology.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
sound/soc/sof/topology.c +4 -8
@@ -507,28 +507,25 @@ static int get_token_uuid(void *elem, void *object, u32 offset)static 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) { -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) { -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 ; }
@@ -872,8 +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].get_token (elem->string, object, offset + tokens[j].offset); found++; }
Signature · 1 line
2.25.1
PATCH 9/18 ASoC: SOF: topology: expose some get_token ops
In reply to Ranjani SridharanThese will be used later on by IPC-specific code.
--- sound/soc/sof/sof-audio.h | 5 +++++ sound/soc/sof/topology.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
sound/soc/sof/sof-audio.h +5 -0
@@ -260,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
sound/soc/sof/topology.c +5 -5
@@ -477,7 +477,7 @@ struct sof_topology_token {u32 offset; }; -static int get_token_u32 (void *elem,void *object,u32 offset) +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);
@@ -486,7 +486,7 @@ static int get_token_u32(void *elem, void *object, u32 offset)return 0 ; } -static int get_token_u16 (void *elem,void *object,u32 offset) +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);
@@ -495,7 +495,7 @@ static int get_token_u16(void *elem, void *object, u32 offset)return 0 ; } -static int get_token_uuid (void *elem,void *object,u32 offset) +int get_token_uuid (void *elem,void *object,u32 offset) {struct snd_soc_tplg_vendor_uuid_elem *velem = elem;u8 *dst = (u8 *)object + offset;
@@ -505,7 +505,7 @@ static int get_token_uuid(void *elem, void *object, u32 offset)return 0 ; } -static int get_token_comp_format (void *elem,void *object,u32 offset) +int get_token_comp_format (void *elem,void *object,u32 offset) {u32 *val = (u32 *)((u8 *)object + offset);
@@ -513,7 +513,7 @@ static int get_token_comp_format(void *elem, void *object, u32 offset)return 0 ; } -static int get_token_dai_type (void *elem,void *object,u32 offset) +int get_token_dai_type (void *elem,void *object,u32 offset) {u32 *val = (u32 *)((u8 *)object + offset);
Signature · 1 line
2.25.1
PATCH 10/18 ASoC: SOF: change comp_dai to a pointer in struct snd_sof_dai
In reply to Ranjani SridharanThis will avoid having to add the extended data for DAI components during sof_widget_setup() as an extra step.
--- sound/soc/sof/pcm.c | 6 +++--- sound/soc/sof/sof-audio.c | 18 +++--------------- sound/soc/sof/sof-audio.h | 2 +- sound/soc/sof/topology.c | 17 +++++------------ 4 files changed, 12 insertions(+), 31 deletions(-)
sound/soc/sof/pcm.c +3 -3
@@ -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_pabreak ;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 ;
sound/soc/sof/sof-audio.c +3 -15
@@ -170,7 +170,6 @@ 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;/* skip if there is no private data */
@@ -192,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);
sound/soc/sof/sof-audio.h +1 -1
@@ -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 */
sound/soc/sof/topology.c +5 -12
@@ -1478,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,
@@ -1487,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",
@@ -1496,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; }
@@ -2429,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);
@@ -2668,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);
Signature · 1 line
2.25.1
PATCH 11/18 ASoC: SOF: make struct snd_sof_widget IPC agnostic
In reply to Ranjani SridharanParse the UUID token and save it in the new uuid field in struct snd_sof_widget. struct sof_ipc_comp_ext is no longer needed. So remove it too.
--- include/sound/sof/topology.h | 5 ----- sound/soc/sof/sof-audio.h | 3 +-- sound/soc/sof/topology.c | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 17 deletions(-)
include/sound/sof/topology.h +0 -5
@@ -303,9 +303,4 @@ enum sof_event_types { SOF_KEYWORD_DETECT_DAPM_EVENT, }; -/* extended data struct for UUID components */ -struct sof_ipc_comp_ext { -uint8_t uuid[SOF_UUID_SIZE ]; -} __packed; -#endif
sound/soc/sof/sof-audio.h +1 -2
@@ -110,8 +110,7 @@ struct snd_sof_widget {struct list_head list;/* list in sdev widget list */ struct snd_sof_widget *pipe_widget; -/* extended data for UUID components */ -struct sof_ipc_comp_ext comp_ext; +u8 uuid[SOF_UUID_SIZE ];void *private;/* core does not touch this */ };
sound/soc/sof/topology.c +10 -10
@@ -743,7 +743,7 @@ static const struct sof_topology_token core_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)}, + offsetof(struct snd_sof_widget , uuid)}, };/*
@@ -1419,16 +1419,17 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,* * Return: The pointer to the new allocated component, NULL if failed. */ -static struct sof_ipc_comp *sof_comp_alloc (struct snd_sof_widget *swidget, -size_t *ipc_size,int index) +static struct sof_ipc_comp *sof_comp_alloc (struct snd_sof_widget *swidget,size_t *ipc_size, +int index) {u8 nil_uuid[SOF_UUID_SIZE ] = {0 };struct sof_ipc_comp *comp;size_t total_size = *ipc_size; +size_t ext_size =sizeof (swidget->uuid);/* only non-zero UUID is valid */ -if (memcmp (&swidget->comp_ext, nil_uuid,SOF_UUID_SIZE )) - total_size +=sizeof (swidget->comp_ext); +if (memcmp (swidget->uuid, nil_uuid,SOF_UUID_SIZE )) + total_size += ext_size; comp =kzalloc (total_size,GFP_KERNEL );if (!comp)
@@ -1444,8 +1445,8 @@ static struct sof_ipc_comp *sof_comp_alloc(struct snd_sof_widget *swidget,/* handle the extended data if needed */ if (total_size > *ipc_size) {/* append extended data to the end of the component */ -memcpy ((u8 *)comp + *ipc_size, &swidget->comp_ext,sizeof (swidget->comp_ext)); - comp->ext_data_length =sizeof (swidget->comp_ext); +memcpy ((u8 *)comp + *ipc_size, swidget->uuid, ext_size); + comp->ext_data_length = ext_size; }/* update ipc_size and return */
@@ -2276,9 +2277,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, swidget->core = comp.core; - ret =sof_parse_tokens (scomp, &swidget->comp_ext, comp_ext_tokens, -ARRAY_SIZE (comp_ext_tokens), tw->priv.array, -le32_to_cpu (tw->priv.size)); + ret =sof_parse_tokens (scomp, swidget, comp_ext_tokens,ARRAY_SIZE (comp_ext_tokens), + tw->priv.array,le32_to_cpu (tw->priv.size));if (ret !=0 ) {dev_err (scomp->dev,"error: parsing comp_ext_tokens failed %d\n" , ret);
Signature · 1 line
2.25.1
Re: [PATCH 11/18] ASoC: SOF: make struct snd_sof_widget IPC agnostic
Quoted 33 lines · Ranjani Sridharan
Parse the UUID token and save it in the new uuid field in struct
snd_sof_widget. structsof_ipc_comp_extis no longer needed. So remove it too.Signed-off-by Ranjani Sridharan <[email protected]>Reviewed-by Bard Liao <[email protected]>Reviewed-by Péter Ujfalusi <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>--- include/sound/sof/topology.h | 5 ----- sound/soc/sof/sof-audio.h | 3 +-- sound/soc/sof/topology.c | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 17 deletions(-)include/sound/sof/topology.h +0
-5@@ -303,9 +303,4 @@ enum sof_event_types { SOF_KEYWORD_DETECT_DAPM_EVENT, }; -/* extended data struct for UUID components */ -struct sof_ipc_comp_ext { -uint8_t uuid[SOF_UUID_SIZE ]; -} __packed; -#endif sound/soc/sof/sof-audio.h +0
-0
sound/soc/sof/sof-audio.h struct snd_sof_widget { · line 113
Quoted 6 lines
sound/soc/sof/sof-audio.h +1
-2@@ -110,8 +110,7 @@ struct snd_sof_widget {struct list_head list;/* list in sdev widget list */ struct snd_sof_widget *pipe_widget; -/* extended data for UUID components */ -struct sof_ipc_comp_ext comp_ext; +u8 uuid[SOF_UUID_SIZE ];
Can this be uuid_t perhaps?
Quoted 25 lines
sound/soc/sof/sof-audio.h +0
-0void *private;/* core does not touch this */ };sound/soc/sof/topology.c +3
-3@@ -743,7 +743,7 @@ static const struct sof_topology_token core_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)}, + offsetof(struct snd_sof_widget , uuid)}, };/* @@ -1419,16 +1419,17 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,* * Return: The pointer to the new allocated component, NULL if failed. */ -static struct sof_ipc_comp *sof_comp_alloc (struct snd_sof_widget *swidget, -size_t *ipc_size,int index) +static struct sof_ipc_comp *sof_comp_alloc (struct snd_sof_widget *swidget,size_t *ipc_size, +int index) {
sound/soc/sof/topology.c static int sof_connect_dai_widget(struct snd_soc_component *scomp, · line 1432
Quoted 10 lines
sound/soc/sof/topology.c +3
-2u8 nil_uuid[SOF_UUID_SIZE ] = {0 };struct sof_ipc_comp *comp;size_t total_size = *ipc_size; +size_t ext_size =sizeof (swidget->uuid);/* only non-zero UUID is valid */ -if (memcmp (&swidget->comp_ext, nil_uuid,SOF_UUID_SIZE )) - total_size +=sizeof (swidget->comp_ext); +if (memcmp (swidget->uuid, nil_uuid,SOF_UUID_SIZE )) + total_size += ext_size;
And if you change type above then uuid_is_null(swidget->uuid) here?
sound/soc/sof/topology.c static struct sof_ipc_comp *sof_comp_alloc(struct snd_sof_widget *swidget, · line 1448
Quoted 10 lines
sound/soc/sof/topology.c +1
-2comp =kzalloc (total_size,GFP_KERNEL );if (!comp)@@ -1444,8 +1445,8 @@ static struct sof_ipc_comp *sof_comp_alloc(struct snd_sof_widget *swidget,/* handle the extended data if needed */ if (total_size > *ipc_size) {/* append extended data to the end of the component */ -memcpy ((u8 *)comp + *ipc_size, &swidget->comp_ext,sizeof (swidget->comp_ext)); - comp->ext_data_length =sizeof (swidget->comp_ext); +memcpy ((u8 *)comp + *ipc_size, swidget->uuid, ext_size);
and uuid_copy() here?
Quoted 16 lines
sound/soc/sof/topology.c +3
-3+ comp->ext_data_length = ext_size; }/* update ipc_size and return */ @@ -2276,9 +2277,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, swidget->core = comp.core; - ret =sof_parse_tokens (scomp, &swidget->comp_ext, comp_ext_tokens, -ARRAY_SIZE (comp_ext_tokens), tw->priv.array, -le32_to_cpu (tw->priv.size)); + ret =sof_parse_tokens (scomp, swidget, comp_ext_tokens,ARRAY_SIZE (comp_ext_tokens), + tw->priv.array,le32_to_cpu (tw->priv.size));if (ret !=0 ) {dev_err (scomp->dev,"error: parsing comp_ext_tokens failed %d\n" , ret);
Re: [PATCH 11/18] ASoC: SOF: make struct snd_sof_widget IPC agnostic
On Mon, 2022-03-07 at 19:55 +0100, Amadeusz Sławiński wrote:
...
Quoted 4 lines
sound/soc/sof/sof-audio.h struct snd_sof_widget { · line 113
Quoted 2 lines
sound/soc/sof/sof-audio.h +1
-0+u8 uuid[SOF_UUID_SIZE ];Can this be
uuid_tperhaps?
Yes, makes sense.
...
Quoted 7 lines
sound/soc/sof/topology.c static int sof_connect_dai_widget(struct snd_soc_component *scomp, · line 1432
Quoted 5 lines
/* only non-zero UUID is valid */
sound/soc/sof/topology.c +2
-2-if (memcmp (&swidget->comp_ext, nil_uuid,SOF_UUID_SIZE )) - total_size +=sizeof (swidget->comp_ext); +if (memcmp (swidget->uuid, nil_uuid,SOF_UUID_SIZE )) + total_size += ext_size;And if you change type above then
uuid_is_null(swidget->uuid)here?
Sure.
Quoted 15 lines
Quoted 5 lines
comp = kzalloc(total_size, GFP_KERNEL); if (!comp)Review static struct sof_ipc_comp · line 1451
Quoted 9 lines
(quoted diff) +1
-2@@ -1444,8 +1445,8 @@ static struct sof_ipc_comp *sof_comp_alloc(struct snd_sof_widget *swidget, /* handle the extended data if needed */ if (total_size > *ipc_size) { /* append extended data to the end of the component */ - memcpy((u8 *)comp + *ipc_size, &swidget->comp_ext, sizeof(swidget->comp_ext)); - comp->ext_data_length = sizeof(swidget->comp_ext); + memcpy((u8 *)comp + *ipc_size, swidget->uuid, ext_size);and
uuid_copy()here?
But I'd like to retain the memcpy() here as this is IPC payload and the ipc struct does not contain the uuid field.
Thanks,
Ranjani
PATCH 12/18 ASoC: SOF: topology: make sof_route_load() IPC agnostic
In reply to Ranjani SridharanThe IPC structure can be set up using the fields in struct snd_sof_route when the pipeline connections are established.
--- sound/soc/sof/sof-audio.c | 15 ++++++--------- sound/soc/sof/topology.c | 17 ----------------- 2 files changed, 6 insertions(+), 26 deletions(-)
sound/soc/sof/sof-audio.c +6 -9
@@ -259,28 +259,25 @@ EXPORT_SYMBOL(sof_widget_setup);static int sof_route_setup_ipc (struct snd_sof_dev *sdev,struct snd_sof_route *sroute) { -struct sof_ipc_pipe_comp_connect *connect; +struct sof_ipc_pipe_comp_connect connect;struct sof_ipc_reply reply;int ret; -/* skip if there's no private data */ -if (!sroute->private) -return 0 ; -/* nothing to do if route is already set up */ if (sroute->setup)return 0 ; - connect = sroute->private; + connect.hdr.size =sizeof (connect); + connect.hdr.cmd =SOF_IPC_GLB_TPLG_MSG |SOF_IPC_TPLG_COMP_CONNECT ; + connect.source_id = sroute->src_widget->comp_id; + connect.sink_id = sroute->sink_widget->comp_id;dev_dbg (sdev->dev,"setting up route %s -> %s\n" , sroute->src_widget->widget->name, sroute->sink_widget->widget->name);/* send ipc */ - ret =sof_ipc_tx_message (sdev->ipc, - connect->hdr.cmd, - connect,sizeof (*connect), + ret =sof_ipc_tx_message (sdev->ipc, connect.hdr.cmd, &connect,sizeof (connect), &reply,sizeof (reply));if (ret <0 ) {dev_err (sdev->dev,"%s: route setup failed %d\n" , __func__, ret);
sound/soc/sof/topology.c +0 -17
@@ -3323,7 +3323,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, struct snd_soc_dapm_route *route) {struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp); -struct sof_ipc_pipe_comp_connect *connect;struct snd_sof_widget *source_swidget, *sink_swidget;struct snd_soc_dobj *dobj = &route->dobj;struct snd_sof_route *sroute;
@@ -3335,16 +3334,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,return -ENOMEM ; sroute->scomp = scomp; - - connect =kzalloc (sizeof (*connect),GFP_KERNEL ); -if (!connect) { -kfree (sroute); -return -ENOMEM ; - } - - connect->hdr.size =sizeof (*connect); - connect->hdr.cmd =SOF_IPC_GLB_TPLG_MSG |SOF_IPC_TPLG_COMP_CONNECT ; -dev_dbg (scomp->dev,"sink %s control %s source %s\n" , route->sink, route->control ? route->control :"none" , route->source);
@@ -3368,8 +3357,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, source_swidget->id == snd_soc_dapm_output) goto err; - connect->source_id = source_swidget->comp_id; -/* sink component */ sink_swidget =snd_sof_find_swidget (scomp, (char *)route->sink);if (!sink_swidget) {
@@ -3387,8 +3374,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, sink_swidget->id == snd_soc_dapm_output) goto err; - connect->sink_id = sink_swidget->comp_id; -/* * For virtual routes, both sink and source are not * buffer. Since only buffer linked to component is supported by
@@ -3403,7 +3388,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, }else { sroute->route = route; dobj->private = sroute; - sroute->private = connect; sroute->src_widget = source_swidget; sroute->sink_widget = sink_swidget;
@@ -3414,7 +3398,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, } err: -kfree (connect);kfree (sroute);return ret; }
Signature · 1 line
2.25.1
PATCH 13/18 ASoC: SOF: Add a tuples array to struct snd_sof_widget
In reply to Ranjani SridharanAdd 2 new fields to snd_sof_widget to store an array of tuples defined by struct snd_sof_tuple and the number of tuples. When the topology gets parsed, the tuples associated with a widget will be stored in this array and will be used to construct the IPC structure depending on the IPC version.
--- sound/soc/sof/sof-audio.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
sound/soc/sof/sof-audio.h +15 -0
@@ -30,6 +30,18 @@#define WIDGET_IS_DAI (id) ((id) == snd_soc_dapm_dai_in || (id) == snd_soc_dapm_dai_out) +/** struct snd_sof_tuple - Tuple info +* @token: Token ID +* @value: union of a string or a u32 values +*/ +struct snd_sof_tuple { +u32 token; +union { +u32 v; +const char *s; + } value; +}; +/* PCM stream, mapped to FW component */ struct snd_sof_pcm_stream {u32 comp_id;
@@ -112,6 +124,9 @@ struct snd_sof_widget {u8 uuid[SOF_UUID_SIZE ]; +int num_tuples; +struct snd_sof_tuple *tuples; +void *private;/* core does not touch this */ };
Signature · 1 line
2.25.1
PATCH 14/18 ASoC: SOF: topology: Modify signature for token parsing functions
In reply to Ranjani SridharanModify the signature for sof_parse_uuid_tokens(), sof_parse_word_tokens() and sof_parse_string_tokens() to reorder the arguments to be more intuitive and rename the count arg to num_tokens.
--- sound/soc/sof/topology.c | 78 ++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 26 deletions(-)
sound/soc/sof/topology.c +52 -26
@@ -807,12 +807,21 @@ static const struct sof_topology_token afe_tokens[] = { offsetof(struct sof_ipc_dai_mtk_afe_params, format)}, }; +/** +* sof_parse_uuid_tokens - Parse multiple sets of UUID tokens +* @scomp: pointer to soc component +* @object: target ipc struct for parsed values +* @offset: offset within the object pointer +* @tokens: array of struct sof_topology_token containing the tokens to be matched +* @num_tokens: number of tokens in tokens array +* @array: source pointer to consecutive vendor arrays in topology +* +* This function parses multiple sets of string type tokens in vendor arrays +*/ static int sof_parse_uuid_tokens (struct snd_soc_component *scomp, -void *object, -const struct sof_topology_token *tokens, -int count, -struct snd_soc_tplg_vendor_array *array, -size_t offset) +void *object,size_t offset, +const struct sof_topology_token *tokens,int num_tokens, +struct snd_soc_tplg_vendor_array *array) {struct snd_soc_tplg_vendor_uuid_elem *elem;int found =0 ;
@@ -823,7 +832,7 @@ static int sof_parse_uuid_tokens(struct snd_soc_component *scomp, elem = &array->uuid[i];/* search for token */ -for (j =0 ; j < count; j++) { +for (j =0 ; j < num_tokens; j++) {/* match token type */ if (tokens[j].type !=SND_SOC_TPLG_TUPLE_TYPE_UUID )continue ;
@@ -843,12 +852,21 @@ static int sof_parse_uuid_tokens(struct snd_soc_component *scomp,return found; } +/** +* sof_parse_string_tokens - Parse multiple sets of tokens +* @scomp: pointer to soc component +* @object: target ipc struct for parsed values +* @offset: offset within the object pointer +* @tokens: array of struct sof_topology_token containing the tokens to be matched +* @num_tokens: number of tokens in tokens array +* @array: source pointer to consecutive vendor arrays in topology +* +* This function parses multiple sets of string type tokens in vendor arrays +*/ static int sof_parse_string_tokens (struct snd_soc_component *scomp, -void *object, -const struct sof_topology_token *tokens, -int count, -struct snd_soc_tplg_vendor_array *array, -size_t offset) +void *object,int offset, +const struct sof_topology_token *tokens,int num_tokens, +struct snd_soc_tplg_vendor_array *array) {struct snd_soc_tplg_vendor_string_elem *elem;int found =0 ;
@@ -859,7 +877,7 @@ static int sof_parse_string_tokens(struct snd_soc_component *scomp, elem = &array->string[i];/* search for token */ -for (j =0 ; j < count; j++) { +for (j =0 ; j < num_tokens; j++) {/* match token type */ if (tokens[j].type !=SND_SOC_TPLG_TUPLE_TYPE_STRING )continue ;
@@ -878,12 +896,21 @@ static int sof_parse_string_tokens(struct snd_soc_component *scomp,return found; } +/** +* sof_parse_word_tokens - Parse multiple sets of tokens +* @scomp: pointer to soc component +* @object: target ipc struct for parsed values +* @offset: offset within the object pointer +* @tokens: array of struct sof_topology_token containing the tokens to be matched +* @num_tokens: number of tokens in tokens array +* @array: source pointer to consecutive vendor arrays in topology +* +* This function parses multiple sets of word type tokens in vendor arrays +*/ static int sof_parse_word_tokens (struct snd_soc_component *scomp, -void *object, -const struct sof_topology_token *tokens, -int count, -struct snd_soc_tplg_vendor_array *array, -size_t offset) +void *object,int offset, +const struct sof_topology_token *tokens,int num_tokens, +struct snd_soc_tplg_vendor_array *array) {struct snd_soc_tplg_vendor_value_elem *elem;int found =0 ;
@@ -894,7 +921,7 @@ static int sof_parse_word_tokens(struct snd_soc_component *scomp, elem = &array->value[i];/* search for token */ -for (j =0 ; j < count; j++) { +for (j =0 ; j < num_tokens; j++) {/* match token type */ if (!(tokens[j].type == SND_SOC_TPLG_TUPLE_TYPE_WORD || tokens[j].type == SND_SOC_TPLG_TUPLE_TYPE_SHORT ||
@@ -907,8 +934,7 @@ static int sof_parse_word_tokens(struct snd_soc_component *scomp,continue ;/* load token */ - tokens[j].get_token (elem, object, - offset + tokens[j].offset); + tokens[j].get_token (elem, object, offset + tokens[j].offset); found++; }
@@ -964,19 +990,19 @@ static int sof_parse_token_sets(struct snd_soc_component *scomp,/* call correct parser depending on type */ switch (le32_to_cpu (array->type)) {case SND_SOC_TPLG_TUPLE_TYPE_UUID : - found +=sof_parse_uuid_tokens (scomp, object, tokens, - count, array, offset); + found +=sof_parse_uuid_tokens (scomp, object, offset, tokens, count, + array);break ;case SND_SOC_TPLG_TUPLE_TYPE_STRING : - found +=sof_parse_string_tokens (scomp, object, tokens, - count, array, offset); + found +=sof_parse_string_tokens (scomp, object, offset, tokens, count, + array);break ;case SND_SOC_TPLG_TUPLE_TYPE_BOOL :case SND_SOC_TPLG_TUPLE_TYPE_BYTE :case SND_SOC_TPLG_TUPLE_TYPE_WORD :case SND_SOC_TPLG_TUPLE_TYPE_SHORT : - found +=sof_parse_word_tokens (scomp, object, tokens, - count, array, offset); + found +=sof_parse_word_tokens (scomp, object, offset, tokens, count, + array);break ;default : dev_err(scomp->dev, "error: unknown token type %d\n",
Signature · 1 line
2.25.1
PATCH 15/18 ASoC: SOF: topology: Rename arguments in sof_parse_token_sets()
In reply to Ranjani SridharanRename the priv_size arg to array_size and clarify the arguments in the comments.
--- sound/soc/sof/topology.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
sound/soc/sof/topology.c +10 -11
@@ -949,27 +949,26 @@ static int sof_parse_word_tokens(struct snd_soc_component *scomp,* @object: target ipc struct for parsed values * @tokens: token definition array describing what tokens to parse * @count: number of tokens in definition array -* @array: source pointer to consecutive vendor arrays to be parsed -* @priv_size: total size of the consecutive source arrays -* @sets: number of similar token sets to be parsed, 1 set has count elements +* @array: source pointer to consecutive vendor arrays in topology +* @array_size: total size of @array +* @token_instance_num: number of times the same tokens needs to be parsed i.e. the function +* looks for @token_instance_num of each token in the @tokens * @object_size: offset to next target ipc struct with multiple sets * * This function parses multiple sets of tokens in vendor arrays into * consecutive ipc structs. */ static int sof_parse_token_sets (struct snd_soc_component *scomp, -void *object, -const struct sof_topology_token *tokens, -int count, -struct snd_soc_tplg_vendor_array *array, -int priv_size,int sets,size_t object_size) +void *object,const struct sof_topology_token *tokens, +int count,struct snd_soc_tplg_vendor_array *array, +int array_size,int token_instance_num,size_t object_size) {size_t offset =0 ;int found =0 ;int total =0 ;int asize; -while (priv_size >0 && total < count * sets) { +while (array_size >0 && total < count * token_instance_num) { asize =le32_to_cpu (array->size);/* validate asize */
@@ -980,8 +979,8 @@ static int sof_parse_token_sets(struct snd_soc_component *scomp, }/* make sure there is enough data before parsing */ - priv_size -= asize; -if (priv_size <0 ) { + array_size -= asize; +if (array_size <0 ) {dev_err (scomp->dev,"error: invalid array size 0x%x\n" , asize);return -EINVAL ;
Signature · 1 line
2.25.1
PATCH 16/18 ASoC: SOF: topology: Rename arguments in sof_parse_tokens()
In reply to Ranjani SridharanRename the count and priv_size arguments in sof_parse_tokens() and add comments to clarify the arguments.
--- sound/soc/sof/topology.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
sound/soc/sof/topology.c +18 -7
@@ -1024,12 +1024,23 @@ static int sof_parse_token_sets(struct snd_soc_component *scomp,return 0 ; } -static int sof_parse_tokens (struct snd_soc_component *scomp, -void *object, -const struct sof_topology_token *tokens, -int count, +/** +* sof_parse_tokens - Parse one set of tokens +* @scomp: pointer to soc component +* @object: target ipc struct for parsed values +* @tokens: token definition array describing what tokens to parse +* @num_tokens: number of tokens in definition array +* @array: source pointer to consecutive vendor arrays in topology +* @array_size: total size of @array +* +* This function parses a single set of tokens in vendor arrays into +* consecutive ipc structs. +*/ +static int sof_parse_tokens (struct snd_soc_component *scomp,void *object, +const struct sof_topology_token *tokens,int num_tokens,struct snd_soc_tplg_vendor_array *array, -int priv_size) +int array_size) + {/* * sof_parse_tokens is used when topology contains only a single set of
@@ -1037,8 +1048,8 @@ static int sof_parse_tokens(struct snd_soc_component *scomp,* sof_parse_token_sets are sets = 1 (only 1 set) and * object_size = 0 (irrelevant). */ -return sof_parse_token_sets (scomp, object, tokens, count, array, - priv_size,1 ,0 ); +return sof_parse_token_sets (scomp, object, tokens, num_tokens, array, + array_size,1 ,0 ); } static void sof_dbg_comp_config(struct snd_soc_component *scomp,
Signature · 1 line
2.25.1
PATCH 17/18 ASoC: SOF: make struct snd_sof_dai IPC agnostic
In reply to Ranjani SridharanRemove the comp_dai and dai_config members of struct snd_sof_dai and replace it with a void *private field. Introduce a new struct sof_dai_private_data that will contain the pointer to these two fields. The topology parser will populate this structure and save it as part of the "private" member in snd_sof_dai. Change all users of these fields to use the private member instead.
--- include/sound/sof/dai.h | 5 +++ sound/soc/sof/intel/hda-dai.c | 27 +++++++++--- sound/soc/sof/intel/hda.c | 39 ++++++++++++++---- sound/soc/sof/pcm.c | 77 ++++++++++++++++++----------------- sound/soc/sof/sof-audio.c | 30 +++++++++----- sound/soc/sof/sof-audio.h | 3 +- sound/soc/sof/topology.c | 38 ++++++++++++----- 7 files changed, 143 insertions(+), 76 deletions(-)
include/sound/sof/dai.h +5 -0
@@ -116,4 +116,9 @@ struct sof_ipc_dai_config { }; } __packed; +struct sof_dai_private_data { +struct sof_ipc_comp_dai *comp_dai; +struct sof_ipc_dai_config *dai_config; +}; +#endif
sound/soc/sof/intel/hda-dai.c +21 -6
@@ -167,6 +167,7 @@ static struct sof_ipc_dai_config *hda_dai_update_config(struct snd_soc_dapm_widg int channel) {struct snd_sof_widget *swidget = w->dobj.private; +struct sof_dai_private_data *private;struct sof_ipc_dai_config *config;struct snd_sof_dai *sof_dai;
@@ -175,12 +176,19 @@ static struct sof_ipc_dai_config *hda_dai_update_config(struct snd_soc_dapm_widg sof_dai = swidget->private; -if (!sof_dai || !sof_dai->dai_config) { -dev_err (swidget->scomp->dev,"error: No config for DAI %s\n" , w->name); +if (!sof_dai || !sof_dai->private) { +dev_err (swidget->scomp->dev,"%s: No private data for DAI %s\n" , __func__, + w->name);return NULL ; } - config = &sof_dai->dai_config[sof_dai->current_config]; + private = sof_dai->private; +if (!private->dai_config) { +dev_err (swidget->scomp->dev,"%s: No config for DAI %s\n" , __func__, w->name); +return NULL ; + } + + config = &private->dai_config[sof_dai->current_config];/* update config with stream tag */ config->hda.link_dma_ch = channel;
@@ -294,6 +302,7 @@ static int hda_link_dai_config_pause_push_ipc(struct snd_soc_dapm_widget *w)struct snd_sof_widget *swidget = w->dobj.private;struct snd_soc_component *component = swidget->scomp;struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (component); +struct sof_dai_private_data *private;struct sof_ipc_dai_config *config;struct snd_sof_dai *sof_dai;struct sof_ipc_reply reply;
@@ -301,12 +310,18 @@ static int hda_link_dai_config_pause_push_ipc(struct snd_soc_dapm_widget *w) sof_dai = swidget->private; -if (!sof_dai || !sof_dai->dai_config) { -dev_err (sdev->dev,"No config for DAI %s\n" , w->name); +if (!sof_dai || !sof_dai->private) { +dev_err (sdev->dev,"%s: No private data for DAI %s\n" , __func__, w->name); +return -EINVAL ; + } + + private = sof_dai->private; +if (!private->dai_config) { +dev_err (sdev->dev,"%s: No config for DAI %s\n" , __func__, w->name);return -EINVAL ; } - config = &sof_dai->dai_config[sof_dai->current_config]; + config = &private->dai_config[sof_dai->current_config];/* set PAUSE command flag */ config->flags =FIELD_PREP (SOF_DAI_CONFIG_FLAGS_CMD_MASK ,SOF_DAI_CONFIG_FLAGS_PAUSE );
sound/soc/sof/intel/hda.c +30 -9
@@ -47,14 +47,21 @@ int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w, unsigned int quirk_struct snd_soc_component *component = swidget->scomp;struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (component);struct sof_ipc_dai_config *config; +struct sof_dai_private_data *private;struct snd_sof_dai *sof_dai;struct sof_ipc_reply reply;int ret; sof_dai = swidget->private; -if (!sof_dai || !sof_dai->dai_config) { -dev_err (sdev->dev,"No config for DAI %s\n" , w->name); +if (!sof_dai || !sof_dai->private) { +dev_err (sdev->dev,"%s: No private data for DAI %s\n" , __func__, w->name); +return -EINVAL ; + } + + private = sof_dai->private; +if (!private->dai_config) { +dev_err (sdev->dev,"%s: No config for DAI %s\n" , __func__, w->name);return -EINVAL ; }
@@ -65,7 +72,7 @@ int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w, unsigned int quirk_return ret; } - config = &sof_dai->dai_config[sof_dai->current_config]; + config = &private->dai_config[sof_dai->current_config];/* * For static pipelines, the DAI widget would already be set up and calling
@@ -101,6 +108,7 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_fstruct snd_sof_widget *swidget = w->dobj.private;struct snd_soc_component *component = swidget->scomp;struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (component); +struct sof_dai_private_data *private;struct sof_ipc_dai_config *config;struct snd_sof_dai *sof_dai;struct sof_ipc_reply reply;
@@ -108,8 +116,14 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_f sof_dai = swidget->private; -if (!sof_dai || !sof_dai->dai_config) { -dev_err (sdev->dev,"error: No config to free DAI %s\n" , w->name); +if (!sof_dai || !sof_dai->private) { +dev_err (sdev->dev,"%s: No private data for DAI %s\n" , __func__, w->name); +return -EINVAL ; + } + + private = sof_dai->private; +if (!private->dai_config) { +dev_err (sdev->dev,"%s: No config for DAI %s\n" , __func__, w->name);return -EINVAL ; }
@@ -117,7 +131,7 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_fif (!sof_dai->configured)return 0 ; - config = &sof_dai->dai_config[sof_dai->current_config]; + config = &private->dai_config[sof_dai->current_config];/* set HW_FREE flag along with any quirks */ config->flags = SOF_DAI_CONFIG_FLAGS_HW_FREE |
@@ -154,6 +168,7 @@ static int sdw_dai_config_ipc(struct snd_sof_dev *sdev, int link_id, int alh_stream_id, int dai_id, bool setup) { struct snd_sof_widget *swidget = w->dobj.private; +struct sof_dai_private_data *private;struct sof_ipc_dai_config *config;struct snd_sof_dai *sof_dai;
@@ -164,12 +179,18 @@ static int sdw_dai_config_ipc(struct snd_sof_dev *sdev, sof_dai = swidget->private; -if (!sof_dai || !sof_dai->dai_config) { -dev_err (sdev->dev,"error: No config for DAI %s\n" , w->name); +if (!sof_dai || !sof_dai->private) { +dev_err (sdev->dev,"%s: No private data for DAI %s\n" , __func__, w->name); +return -EINVAL ; + } + + private = sof_dai->private; +if (!private->dai_config) { +dev_err (sdev->dev,"%s: No config for DAI %s\n" , __func__, w->name);return -EINVAL ; } - config = &sof_dai->dai_config[sof_dai->current_config]; + config = &private->dai_config[sof_dai->current_config];/* update config with link and stream ID */ config->dai_index = (link_id <<8 ) | dai_id;
sound/soc/sof/pcm.c +40 -37
157 lines not on this page · raw message
sound/soc/sof/sof-audio.c +19 -11
@@ -29,11 +29,12 @@ static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *static int sof_dai_config_setup (struct snd_sof_dev *sdev,struct snd_sof_dai *dai) { +struct sof_dai_private_data *private = dai->private;struct sof_ipc_dai_config *config;struct sof_ipc_reply reply;int ret; - config = &dai->dai_config[dai->current_config]; + config = &private->dai_config[dai->current_config];if (!config) {dev_err (sdev->dev,"error: no config for DAI %s\n" , dai->name);return -EINVAL ;
@@ -191,12 +192,16 @@ 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: + { +struct sof_dai_private_data *dai_data; + dai = swidget->private; - comp = &dai->comp_dai->comp; + dai_data = dai->private; + comp = &dai_data->comp_dai->comp; dai->configured = false; - ret =sof_ipc_tx_message (sdev->ipc, comp->hdr.cmd, dai->comp_dai, comp->hdr.size, - &r,sizeof (r)); + ret =sof_ipc_tx_message (sdev->ipc, comp->hdr.cmd, dai_data->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);
@@ -216,6 +221,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)return ret; }break ; + }case snd_soc_dapm_scheduler: pipeline = swidget->private; ret = sof_ipc_tx_message(sdev->ipc, pipeline->hdr.cmd, pipeline,
@@ -620,12 +626,13 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)/* update DAI config. The IPC will be sent in sof_widget_setup() */ if (WIDGET_IS_DAI (swidget->id)) {struct snd_sof_dai *dai = swidget->private; +struct sof_dai_private_data *private = dai->private;struct sof_ipc_dai_config *config; -if (!dai || !dai->dai_config) +if (!dai || !private || !private->dai_config)continue ; - config = dai->dai_config; + config = private->dai_config;/* * The link DMA channel would be invalidated for running * streams but not for streams that were in the PAUSED
@@ -911,18 +918,19 @@ static int sof_dai_get_clk(struct snd_soc_pcm_runtime *rtd, int clk_type)snd_soc_rtdcom_lookup (rtd,SOF_AUDIO_PCM_DRV_NAME );struct snd_sof_dai *dai =snd_sof_find_dai (component, (char *)rtd->dai_link->name); +struct sof_dai_private_data *private = dai->private;/* use the tplg configured mclk if existed */ -if (!dai || !dai->dai_config) +if (!dai || !private || !private->dai_config)return 0 ; -switch (dai->dai_config->type) { +switch (private->dai_config->type) {case SOF_DAI_INTEL_SSP :switch (clk_type) {case SOF_DAI_CLK_INTEL_SSP_MCLK : -return dai->dai_config->ssp.mclk_rate; +return private->dai_config->ssp.mclk_rate;case SOF_DAI_CLK_INTEL_SSP_BCLK : -return dai->dai_config->ssp.bclk_rate; +return private->dai_config->ssp.bclk_rate;default :dev_err (rtd->dev,"fail to get SSP clk %d rate\n" , clk_type);
@@ -932,7 +940,7 @@ static int sof_dai_get_clk(struct snd_soc_pcm_runtime *rtd, int clk_type)default :/* not yet implemented for platforms other than the above */ dev_err (rtd->dev,"DAI type %d not supported yet!\n" , - dai->dai_config->type); + private->dai_config->type);return -EINVAL ; } }
sound/soc/sof/sof-audio.h +1 -2
@@ -148,12 +148,11 @@ struct snd_sof_dai {struct snd_soc_component *scomp;const char *name; -struct sof_ipc_comp_dai *comp_dai;int number_configs;int current_config;bool configured;/* DAI configured during BE hw_params */ -struct sof_ipc_dai_config *dai_config;struct list_head list;/* list in sdev dai list */ +void *private; };/*
sound/soc/sof/topology.c +27 -11
@@ -1496,14 +1496,21 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, struct snd_sof_dai *dai) {struct snd_soc_tplg_private *private = &tw->priv; +struct sof_dai_private_data *dai_data;struct sof_ipc_comp_dai *comp_dai;size_t ipc_size =sizeof (*comp_dai);int ret; + dai_data =kzalloc (sizeof (*dai_data),GFP_KERNEL ); +if (!dai_data) +return -ENOMEM ; + comp_dai = (struct sof_ipc_comp_dai *)sof_comp_alloc (swidget, &ipc_size, index); -if (!comp_dai) -return -ENOMEM ; +if (!comp_dai) { + ret = -ENOMEM ; + goto free; + }/* configure dai IPC message */ comp_dai->comp.type =SOF_COMP_DAI ;
@@ -1515,7 +1522,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)); -return ret; + goto free; } ret = sof_parse_tokens(scomp, &comp_dai->config, comp_tokens,
@@ -1524,7 +1531,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); -return ret; + goto free; } dev_dbg(scomp->dev, "dai %s: type %d index %d\n",
@@ -1533,9 +1540,14 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,if (dai) { dai->scomp = scomp; - dai->comp_dai = comp_dai; + dai_data->comp_dai = comp_dai; + dai->private = dai_data; } +return 0 ; + +free: +kfree (dai_data);return ret; }
@@ -2457,9 +2469,11 @@ 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); +struct sof_dai_private_data *dai_data = dai->private; + +kfree (dai_data->comp_dai); +kfree (dai_data->dai_config); +kfree (dai_data);list_del (&dai->list); }break ;
@@ -2681,11 +2695,13 @@ static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size,struct sof_ipc_dai_config *config, int num_conf, int curr_conf) { + struct sof_dai_private_data *dai_data;struct snd_sof_dai *dai;int found =0 ;int i;list_for_each_entry (dai, &sdev->dai_list, list) { + dai_data = dai->private;if (!dai->name)continue ;
@@ -2697,15 +2713,15 @@ 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_data->comp_dai->dai_index;dev_dbg (sdev->dev,"set DAI config for %s index %d\n" , dai->name, config[curr_conf].dai_index); dai->number_configs = num_conf; dai->current_config = curr_conf; - dai->dai_config =kmemdup (config, size * num_conf,GFP_KERNEL ); -if (!dai->dai_config) + dai_data->dai_config =kmemdup (config, size * num_conf,GFP_KERNEL ); +if (!dai_data->dai_config)return -ENOMEM ; found =1 ;
Signature · 1 line
2.25.1
PATCH 18/18 ASoC: SOF: move definition of snd_sof_ipc to header file
In reply to Ranjani SridharanFrom: Rander Wang <[email protected]>
Move definition of struct snd_sof_ipc to the header file so it can be shared with new IPC versions.
--- sound/soc/sof/ipc.c | 12 ------------ sound/soc/sof/sof-priv.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-)
sound/soc/sof/ipc.c +0 -12
@@ -27,18 +27,6 @@ static void ipc_stream_message(struct snd_sof_dev *sdev, void *msg_buf);* IPC message Tx/Rx message handling. */ -/* SOF generic IPC data */ -struct snd_sof_ipc { -struct snd_sof_dev *sdev; - -/* protects messages and the disable flag */ -struct mutex tx_mutex; -/* disables further sending of ipc's */ -bool disable_ipc_tx; - -struct snd_sof_ipc_msg msg; -}; -struct sof_ipc_ctrl_data_params {size_t msg_bytes;size_t hdr_bytes;
sound/soc/sof/sof-priv.h +12 -0
@@ -345,6 +345,18 @@ struct snd_sof_ipc_msg {bool ipc_complete; }; +/* SOF generic IPC data */ +struct snd_sof_ipc { +struct snd_sof_dev *sdev; + +/* protects messages and the disable flag */ +struct mutex tx_mutex; +/* disables further sending of ipc's */ +bool disable_ipc_tx; + +struct snd_sof_ipc_msg msg; +}; +/* * SOF Device Level. */
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 9 lines · Ranjani Sridharan
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.
Pierre-Louis Bossart (1):
ASoC: SOF: sof-audio: removed unused function[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/18] ASoC: SOF: remove snd_sof_pipeline_find()
commit: 5187357e45c3b3d4cab3b990a893369eb8ca6f70
[02/18] ASoC: SOF: simplify snd_sof_device_remove()
commit: 80df2226268f039326f9daebd25047cf15e22497
[03/18] ASoC: SOF: set swidget's core for scheduler widget
commit: 3a790f3a7c283d94325a85ac6ee4d1458e89b645
[04/18] ASoC: SOF: sof-audio: removed unused function
commit: c99b70a2d21ab744bdee7a2ea7ec8a35caba9725
[05/18] ASoC: SOF: topology: remove redundant code
commit: fb763299bd8e075f1e9fb0a1cd296b0400fe8442
[06/18] ASoC: SOF: topology: remove redundant code in sof_link_afe_load()
commit: 9911ce06db9dd26d62cd131318588dc039696a99
[07/18] ASoC: SOF: topology: Drop the size parameter from struct sof_topology_token
commit: 6a6b5727f8eedff8932db6056c07a81eeeca9250
[08/18] ASoC: SOF: topology: Modify the get_token op for string tokens
commit: 5ef969e2f8e199d8881ea4cd78cb86df1c67d92b
[09/18] ASoC: SOF: topology: expose some get_token ops
commit: ea7e5ee67fb71d92b0eb0be8467fd34b0e2def6c
[10/18] ASoC: SOF: change comp_dai to a pointer in struct snd_sof_dai
commit: 40bdb2fd6b151e34fdf841238627dd0cfa960093[11/18] ASoC: SOF: make struct snd_sof_widget IPC agnostic
(no commit info)
[12/18] ASoC: SOF: topology: make sof_route_load() IPC agnostic
(no commit info)
[13/18] ASoC: SOF: Add a tuples array to struct snd_sof_widget
(no commit info)
[14/18] ASoC: SOF: topology: Modify signature for token parsing functions
(no commit info)
[15/18] ASoC: SOF: topology: Rename arguments in sof_parse_token_sets()
(no commit info)
[16/18] ASoC: SOF: topology: Rename arguments in sof_parse_tokens()
(no commit info)
[17/18] ASoC: SOF: make struct snd_sof_dai IPC agnostic
(no commit info)
[18/18] ASoC: SOF: move definition of snd_sof_ipc to header file
(no commit info)
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark