Skip to content

[RFC] ASoC: SOF: add topology support for IPC4 - #3263

Closed
bardliao wants to merge 2 commits into
thesofproject:topic/sof-devfrom
bardliao:topology2
Closed

bardliao wants to merge 2 commits into
thesofproject:topic/sof-devfrom
bardliao:topology2

Conversation

@bardliao

@bardliao bardliao commented Nov 8, 2021

Copy link
Copy Markdown
Collaborator

Creating topology2 support for IPC4.

@bardliao

bardliao commented Nov 8, 2021

Copy link
Copy Markdown
Collaborator Author

The first commit is also on #3251. Added it here is just to avoid build error.

Comment thread sound/soc/sof/Makefile Resolved
Comment thread sound/soc/sof/ipc4-topology.c Outdated

static const struct sof_topology_token ipc4_sched_tokens[] = {
{SOF_TKN_SCHED_LP_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc4_pipeline, lp_mode), 0}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why does this need to be a seaprate array? It doesnt clash with any existing scheduler tokens for IPC3. So why not just include it in there?

Comment thread sound/soc/sof/ipc4-topology.c Outdated
};

/**
* sof_ipc4_comp_alloc - allocate and initialize buffer for a new component

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we hange to init memory for new component. Its confusing with there being a buffer component in topology

Comment thread sound/soc/sof/Makefile Outdated

snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\
control.o trace.o utils.o sof-audio.o stream-ipc.o ipc4.o \
topology-common.o

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same with this commit. Topology2.0 has nothign to do with this change. You will need to do the same thing irrespective of whether you use topolpogy1.0 or 2.0

Comment thread sound/soc/sof/ipc4-topology.c Outdated
*
* Return: The pointer to the new allocated component, NULL if failed.
*/
static struct sof_ipc_comp *sof_ipc4_comp_alloc(struct snd_sof_widget *swidget,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why cant we reuse cof_comp_alloc() here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

IPC4 doesn't need to set hdr.cmd. Since IPC4 doesn't use hdr we can reuse it

Comment thread sound/soc/sof/ipc4-topology.c Outdated
return comp;
}

static int sof_ipc4_widget_load_dai(struct snd_soc_component *scomp, int index,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not pass ipc4_dai->dai and reuse sof_load_dai from IP3?

Comment thread sound/soc/sof/ipc4-topology.c Outdated
* PCM Topology
*/

static int sof_ipc4_widget_load_pcm(struct snd_soc_component *scomp, int index,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel there's a lot of duplicaed code we can avoid here. Can you please address the duplication and why it is unavaoidable @RanderWang @bardliao

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@ranj063 yes, we can reuse more code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ranj063 @RanderWang After revisiting the code, I think only few code should be split. I will restructure the code. Thanks.

@bardliao
bardliao force-pushed the topology2 branch 5 times, most recently from 73f0cfe to 9fbc666 Compare November 11, 2021 14:53
@bardliao
bardliao requested a review from ranj063 November 11, 2021 15:02
Comment thread sound/soc/sof/Makefile Resolved
}
scontrol->volume_table[size - 1] = IPC4_VOL_MAX;

return 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems like both this function and the get_tlv_data can be shared too no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

seems like both this function and the get_tlv_data can be shared too no?

Volume control is firmware dependency, right? Each firmware defines their own maxima volume/step etc. set_up_volume_table doesn't look similar. get_tlv_data looks similar but /* min value in topology tlv data is multiplied by 100 */ is on the IPC3 version.

return 0;
}

int sof_ipc4_control_load_volume(struct snd_soc_component *scomp,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is IPCv4 sepcific in this load_volume() compared to the IPC3 version?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

what is IPCv4 sepcific in this load_volume() compared to the IPC3 version?

It is not about IPC, but about firmware. Different firmware can have their own volume definition. max, min, step, how to calculate, etc.

cdata = scontrol->control_data;
for (i = 0; i < scontrol->num_channels; i++) {
cdata->chanv[i].channel = i;
cdata->chanv[i].value = IPC4_VOL_MAX;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ahh just this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ahh just this?

This is to set the default volume.

return 0;
}

int sof_ipc4_widget_load_pipeline(struct snd_soc_component *scomp, int index,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@bardliao this looks mostly good but I wonder if we can take this one step further. Basically every load function performs 4 steps:

  1. Alloc memory
  2. parse tokens
  3. set IPC message bits (optionally)
  4. additional processig (optionally)

Now, before we add support for IPC4, if we can demarcate these steps in all the load functions for IPC3, then we can use some kind of ops to abstract this for IPC3 and IPC4. This will make the transition easier if there were ever an IPC5. Just a thought.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@bardliao this looks mostly good but I wonder if we can take this one step further. Basically every load function performs 4 steps:

  1. Alloc memory
  2. parse tokens
  3. set IPC message bits (optionally)
  4. additional processig (optionally)

Now, before we add support for IPC4, if we can demarcate these steps in all the load functions for IPC3, then we can use some kind of ops to abstract this for IPC3 and IPC4. This will make the transition easier if there were ever an IPC5. Just a thought.

Agree, but in step 2 (parse tokens) is tied to data struct. We will parse tokens and store the data into the struct we need. And the struct is different from IPCs. So the ops may include step 2.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@bardliao I made a small poc to show my idea in #3287. Please have a look.

Move the token definitions along with the code for parsing them to a common
file so they can be shared with IPCv4 topology parser.

Signed-off-by: Rander Wang <rander.wang@intel.com>
This patch adds topology support for IPC4. We reuse the common part
of the existing topology and create new files for the IPC4 part.

Signed-off-by: Rander Wang <rander.wang@intel.com>
@bardliao bardliao changed the title [RFC] ASoC: SOF: add topology2 support for IPC4 [RFC] ASoC: SOF: add topology support for IPC4 Nov 15, 2021
@bardliao bardliao closed this Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants