Skip to content

Commit

Permalink
ASoC: intel: sof_sdw: Increment be_id in init_dai_link
Browse files Browse the repository at this point in the history
Rather than incrementing the ID for the dai_links in many places
throughout the code, just increment it each time we initialise a new DAI
link.

Signed-off-by: Charles Keepax <[email protected]>
  • Loading branch information
charleskeepax authored and plbossart committed Aug 17, 2023
1 parent c4b74e9 commit 57639be
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ static int quirk_override = -1;
module_param_named(quirk, quirk_override, int, 0444);
MODULE_PARM_DESC(quirk, "Board-specific quirk override");

#define INC_ID(BE, LINK) do { (BE)++; (LINK)++; } while (0)

static void log_quirks(struct device *dev)
{
if (SOF_JACK_JDSRC(sof_sdw_quirk))
Expand Down Expand Up @@ -1099,14 +1097,14 @@ static int get_dailink_info(struct device *dev,
}

static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
int be_id, char *name, int playback, int capture,
int *be_id, char *name, int playback, int capture,
struct snd_soc_dai_link_component *cpus, int cpus_num,
struct snd_soc_dai_link_component *codecs, int codecs_num,
int (*init)(struct snd_soc_pcm_runtime *rtd),
const struct snd_soc_ops *ops)
{
dev_dbg(dev, "create dai link %s, id %d\n", name, be_id);
dai_links->id = be_id;
dev_dbg(dev, "create dai link %s, id %d\n", name, *be_id);
dai_links->id = (*be_id)++;
dai_links->name = name;
dai_links->platforms = platform_component;
dai_links->num_platforms = ARRAY_SIZE(platform_component);
Expand All @@ -1122,7 +1120,7 @@ static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links
}

static int init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
int be_id, char *name, int playback, int capture,
int *be_id, char *name, int playback, int capture,
const char *cpu_dai_name,
const char *codec_name, const char *codec_dai_name,
int (*init)(struct snd_soc_pcm_runtime *rtd),
Expand Down Expand Up @@ -1494,7 +1492,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
playback = (stream == SNDRV_PCM_STREAM_PLAYBACK);
capture = (stream == SNDRV_PCM_STREAM_CAPTURE);

init_dai_link(dev, dai_links + *link_index, (*be_id)++, name,
init_dai_link(dev, dai_links + *link_index, be_id, name,
playback, capture, cpus, cpu_dai_num, codecs, codec_num,
NULL, &sdw_ops);

Expand Down Expand Up @@ -1684,7 +1682,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
playback = info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK];
capture = info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE];

ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name,
ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name,
playback, capture, cpu_dai_name,
codec_name, info->dais[0].dai_name,
NULL, info->ops);
Expand All @@ -1695,7 +1693,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
if (ret < 0)
return ret;

INC_ID(be_id, link_index);
link_index++;
}

DMIC:
Expand All @@ -1706,24 +1704,24 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
goto HDMI;
}

ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic01",
ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, "dmic01",
0, 1, // DMIC only supports capture
"DMIC01 Pin", "dmic-codec", "dmic-hifi",
sof_sdw_dmic_init, NULL);
if (ret)
return ret;

INC_ID(be_id, link_index);
link_index++;

ret = init_simple_dai_link(dev, dai_links + link_index, be_id, "dmic16k",
ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, "dmic16k",
0, 1, // DMIC only supports capture
"DMIC16k Pin", "dmic-codec", "dmic-hifi",
/* don't call sof_sdw_dmic_init() twice */
NULL, NULL);
if (ret)
return ret;

INC_ID(be_id, link_index);
link_index++;
}

HDMI:
Expand All @@ -1741,14 +1739,14 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
codec_dai_name = "snd-soc-dummy-dai";
}

ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name,
ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name,
1, 0, // HDMI only supports playback
cpu_dai_name, codec_name, codec_dai_name,
sof_sdw_hdmi_init, NULL);
if (ret)
return ret;

INC_ID(be_id, link_index);
link_index++;
}

if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) {
Expand All @@ -1758,7 +1756,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);

ret = init_simple_dai_link(dev, dai_links + link_index, be_id, name,
ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name,
1, 1, cpu_dai_name, asoc_dummy_dlc.name,
asoc_dummy_dlc.dai_name, NULL, NULL);
if (ret)
Expand Down

0 comments on commit 57639be

Please sign in to comment.