Skip to content

Commit dcd2589

Browse files
committed
ASOC: Intel: sof_sdw: fix playback failure on max98373
Prepare, trigger and hw_free functions were moved from sdw component driver to sdw dai link ops for each sdw codec, but max98373 overrode this ops and was not updated. This patch moves the setting of dai link ops to sof_sdw.c to make all the dai setting in one place to avoid this kind of bug. Fixes: 7eec07f ('ASOC: Intel: sof_sdw: add dailink .trigger callback') Fixes: 5595f95 ('ASOC: Intel: sof_sdw: add dailink .prepare and .hw_free callback'). Signed-off-by: Rander Wang <rander.wang@intel.com>
1 parent 0799f6b commit dcd2589

File tree

3 files changed

+51
-13
lines changed

3 files changed

+51
-13
lines changed

sound/soc/intel/boards/sof_sdw.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static struct snd_soc_dai_link_component platform_component[] = {
220220
};
221221

222222
/* these wrappers are only needed to avoid typecast compilation errors */
223-
int sdw_startup(struct snd_pcm_substream *substream)
223+
static int sdw_startup(struct snd_pcm_substream *substream)
224224
{
225225
return sdw_startup_stream(substream);
226226
}
@@ -244,7 +244,7 @@ static int sdw_prepare(struct snd_pcm_substream *substream)
244244
return sdw_prepare_stream(sdw_stream);
245245
}
246246

247-
static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
247+
int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
248248
{
249249
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
250250
struct sdw_stream_runtime *sdw_stream;
@@ -303,7 +303,7 @@ static int sdw_hw_free(struct snd_pcm_substream *substream)
303303
return sdw_deprepare_stream(sdw_stream);
304304
}
305305

306-
void sdw_shutdown(struct snd_pcm_substream *substream)
306+
static void sdw_shutdown(struct snd_pcm_substream *substream)
307307
{
308308
sdw_shutdown_stream(substream);
309309
}
@@ -316,18 +316,28 @@ static const struct snd_soc_ops sdw_ops = {
316316
.shutdown = sdw_shutdown,
317317
};
318318

319+
static const struct snd_soc_ops max_98373_sdw_ops = {
320+
.startup = sdw_startup,
321+
.prepare = sdw_prepare,
322+
.trigger = max98373_sdw_trigger,
323+
.hw_free = sdw_hw_free,
324+
.shutdown = sdw_shutdown,
325+
};
326+
319327
static struct sof_sdw_codec_info codec_info_list[] = {
320328
{
321329
.part_id = 0x700,
322330
.direction = {true, true},
323331
.dai_name = "rt700-aif1",
332+
.ops = &sdw_ops,
324333
.init = sof_sdw_rt700_init,
325334
},
326335
{
327336
.part_id = 0x711,
328337
.version_id = 3,
329338
.direction = {true, true},
330339
.dai_name = "rt711-sdca-aif1",
340+
.ops = &sdw_ops,
331341
.init = sof_sdw_rt711_sdca_init,
332342
.exit = sof_sdw_rt711_sdca_exit,
333343
},
@@ -336,6 +346,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
336346
.version_id = 2,
337347
.direction = {true, true},
338348
.dai_name = "rt711-aif1",
349+
.ops = &sdw_ops,
339350
.init = sof_sdw_rt711_init,
340351
.exit = sof_sdw_rt711_exit,
341352
},
@@ -352,31 +363,36 @@ static struct sof_sdw_codec_info codec_info_list[] = {
352363
.direction = {true, true},
353364
.dai_name = "rt1316-aif",
354365
.init = sof_sdw_rt1316_init,
366+
.ops = &sdw_ops,
355367
},
356368
{
357369
.part_id = 0x714,
358370
.direction = {false, true},
359371
.dai_name = "rt715-aif2",
360372
.init = sof_sdw_rt715_sdca_init,
373+
.ops = &sdw_ops,
361374
},
362375
{
363376
.part_id = 0x715,
364377
.direction = {false, true},
365378
.dai_name = "rt715-aif2",
366379
.init = sof_sdw_rt715_init,
380+
.ops = &sdw_ops,
367381
},
368382
{
369383
.part_id = 0x8373,
370384
.direction = {true, true},
371385
.dai_name = "max98373-aif1",
372386
.init = sof_sdw_mx8373_init,
387+
.ops = &max_98373_sdw_ops,
373388
.codec_card_late_probe = sof_sdw_mx8373_late_probe,
374389
},
375390
{
376391
.part_id = 0x5682,
377392
.direction = {true, true},
378393
.dai_name = "rt5682-sdw",
379394
.init = sof_sdw_rt5682_init,
395+
.ops = &sdw_ops,
380396
},
381397
};
382398

@@ -807,7 +823,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
807823
playback, capture,
808824
cpus + *cpu_id, cpu_dai_num,
809825
codecs, codec_num,
810-
NULL, &sdw_ops);
826+
NULL, codec_info_list[codec_index].ops);
811827

812828
ret = set_codec_init_func(link, dai_links + (*be_index)++,
813829
playback, group_id);

sound/soc/intel/boards/sof_sdw_common.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ struct mc_private {
7878

7979
extern unsigned long sof_sdw_quirk;
8080

81-
int sdw_startup(struct snd_pcm_substream *substream);
82-
void sdw_shutdown(struct snd_pcm_substream *substream);
81+
int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
8382

8483
/* generic HDMI support */
8584
int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);
@@ -141,6 +140,8 @@ int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
141140
struct sof_sdw_codec_info *info,
142141
bool playback);
143142

143+
int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd);
144+
144145
int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
145146

146147
/* RT5682 support */

sound/soc/intel/boards/sof_sdw_max98373.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,34 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd)
5555
return ret;
5656
}
5757

58-
static const struct snd_soc_ops max_98373_sdw_ops = {
59-
.startup = sdw_startup,
60-
.trigger = max98373_trigger,
61-
.shutdown = sdw_shutdown,
62-
};
58+
int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd)
59+
{
60+
int ret;
61+
62+
switch (cmd) {
63+
case SNDRV_PCM_TRIGGER_START:
64+
case SNDRV_PCM_TRIGGER_RESUME:
65+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
66+
/* enable max98373 first */
67+
ret = max98373_trigger(substream, cmd);
68+
if (ret < 0)
69+
break;
70+
71+
ret = sdw_trigger(substream, cmd);
72+
break;
73+
case SNDRV_PCM_TRIGGER_STOP:
74+
case SNDRV_PCM_TRIGGER_SUSPEND:
75+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
76+
ret = sdw_trigger(substream, cmd);
77+
if (ret < 0)
78+
break;
79+
80+
ret = max98373_trigger(substream, cmd);
81+
break;
82+
}
83+
84+
return ret;
85+
}
6386

6487
int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
6588
struct snd_soc_dai_link *dai_links,
@@ -72,8 +95,6 @@ int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
7295

7396
info->late_probe = true;
7497

75-
dai_links->ops = &max_98373_sdw_ops;
76-
7798
return 0;
7899
}
79100

0 commit comments

Comments
 (0)