Skip to content

Commit

Permalink
ASoC: SOF: append extended data to sof_ipc_comp_mux
Browse files Browse the repository at this point in the history
Append the extended data to the end of the struct sof_ipc_comp_mux,
construct the ipc for COMP_NEW during the topology load stage.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
  • Loading branch information
keyonjie committed Jun 28, 2020
1 parent c575310 commit cf4b23d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,21 +1799,27 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &tw->priv;
struct sof_ipc_comp_mux *mux;
size_t ipc_size = sizeof(*mux) + sizeof(swidget->comp_ext);
int ret;

mux = kzalloc(sizeof(*mux), GFP_KERNEL);
mux = kzalloc(ipc_size, GFP_KERNEL);
if (!mux)
return -ENOMEM;

/* configure mux IPC message */
mux->comp.hdr.size = sizeof(*mux);
mux->comp.hdr.size = ipc_size;
mux->comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW;
mux->comp.id = swidget->comp_id;
mux->comp.type = SOF_COMP_MUX;
mux->comp.pipeline_id = index;
mux->comp.core = core;
mux->config.hdr.size = sizeof(mux->config);

/* append extended data to the end of the component */
memcpy((u8 *)mux + sizeof(*mux),
&swidget->comp_ext, sizeof(swidget->comp_ext));
mux->comp.ext_data_offset = sizeof(*mux);

ret = sof_parse_tokens(scomp, &mux->config, comp_tokens,
ARRAY_SIZE(comp_tokens), private->array,
le32_to_cpu(private->size));
Expand All @@ -1829,7 +1835,7 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
swidget->private = mux;

ret = sof_ipc_tx_message(sdev->ipc, mux->comp.hdr.cmd, mux,
sizeof(*mux), r, sizeof(*r));
ipc_size, r, sizeof(*r));
if (ret < 0)
kfree(mux);

Expand Down

0 comments on commit cf4b23d

Please sign in to comment.