Skip to content

Commit 3d026a8

Browse files
committed
Merge series "ASoC: meson: tdm fixes" from Jerome Brunet <[email protected]>:
This patcheset is collection of fixes for the TDM input and output the axg audio architecture. Its fixes: - slave mode format setting - g12 and sm1 skew offset - tdm clock inversion - standard daifmt props names which don't require a specific prefix Jerome Brunet (4): ASoC: meson: axg-tdm-interface: fix link fmt setup ASoC: meson: axg-tdmin: fix g12a skew ASoC: meson: axg-tdm-formatters: fix sclk inversion ASoC: meson: cards: remove DT_PREFIX for standard daifmt properties sound/soc/meson/axg-tdm-formatter.c | 11 ++++++----- sound/soc/meson/axg-tdm-formatter.h | 1 - sound/soc/meson/axg-tdm-interface.c | 26 +++++++++++++++++--------- sound/soc/meson/axg-tdmin.c | 16 +++++++++++++++- sound/soc/meson/axg-tdmout.c | 3 --- sound/soc/meson/meson-card-utils.c | 2 +- 6 files changed, 39 insertions(+), 20 deletions(-) -- 2.25.4
2 parents 4d1976c + e44815a commit 3d026a8

File tree

12 files changed

+125
-47
lines changed

12 files changed

+125
-47
lines changed

drivers/spi/spi-lantiq-ssc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
899899
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) |
900900
SPI_BPW_MASK(16) | SPI_BPW_MASK(32);
901901

902-
spi->wq = alloc_ordered_workqueue(dev_name(dev), 0);
902+
spi->wq = alloc_ordered_workqueue(dev_name(dev), WQ_MEM_RECLAIM);
903903
if (!spi->wq) {
904904
err = -ENOMEM;
905905
goto err_clk_put;

sound/soc/codecs/max98357a.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,61 @@
2323
struct max98357a_priv {
2424
struct gpio_desc *sdmode;
2525
unsigned int sdmode_delay;
26+
int sdmode_switch;
2627
};
2728

28-
static int max98357a_sdmode_event(struct snd_soc_dapm_widget *w,
29-
struct snd_kcontrol *kcontrol, int event)
29+
static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
30+
int cmd, struct snd_soc_dai *dai)
3031
{
31-
struct snd_soc_component *component =
32-
snd_soc_dapm_to_component(w->dapm);
32+
struct snd_soc_component *component = dai->component;
3333
struct max98357a_priv *max98357a =
3434
snd_soc_component_get_drvdata(component);
3535

3636
if (!max98357a->sdmode)
3737
return 0;
3838

39-
if (event & SND_SOC_DAPM_POST_PMU) {
40-
msleep(max98357a->sdmode_delay);
41-
gpiod_set_value(max98357a->sdmode, 1);
42-
dev_dbg(component->dev, "set sdmode to 1");
43-
} else if (event & SND_SOC_DAPM_PRE_PMD) {
39+
switch (cmd) {
40+
case SNDRV_PCM_TRIGGER_START:
41+
case SNDRV_PCM_TRIGGER_RESUME:
42+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
43+
mdelay(max98357a->sdmode_delay);
44+
if (max98357a->sdmode_switch) {
45+
gpiod_set_value(max98357a->sdmode, 1);
46+
dev_dbg(component->dev, "set sdmode to 1");
47+
}
48+
break;
49+
case SNDRV_PCM_TRIGGER_STOP:
50+
case SNDRV_PCM_TRIGGER_SUSPEND:
51+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
4452
gpiod_set_value(max98357a->sdmode, 0);
4553
dev_dbg(component->dev, "set sdmode to 0");
54+
break;
4655
}
4756

4857
return 0;
4958
}
5059

60+
static int max98357a_sdmode_event(struct snd_soc_dapm_widget *w,
61+
struct snd_kcontrol *kcontrol, int event)
62+
{
63+
struct snd_soc_component *component =
64+
snd_soc_dapm_to_component(w->dapm);
65+
struct max98357a_priv *max98357a =
66+
snd_soc_component_get_drvdata(component);
67+
68+
if (event & SND_SOC_DAPM_POST_PMU)
69+
max98357a->sdmode_switch = 1;
70+
else if (event & SND_SOC_DAPM_POST_PMD)
71+
max98357a->sdmode_switch = 0;
72+
73+
return 0;
74+
}
75+
5176
static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = {
5277
SND_SOC_DAPM_OUTPUT("Speaker"),
5378
SND_SOC_DAPM_OUT_DRV_E("SD_MODE", SND_SOC_NOPM, 0, 0, NULL, 0,
5479
max98357a_sdmode_event,
55-
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
80+
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
5681
};
5782

5883
static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
@@ -71,6 +96,10 @@ static const struct snd_soc_component_driver max98357a_component_driver = {
7196
.non_legacy_dai_naming = 1,
7297
};
7398

99+
static const struct snd_soc_dai_ops max98357a_dai_ops = {
100+
.trigger = max98357a_daiops_trigger,
101+
};
102+
74103
static struct snd_soc_dai_driver max98357a_dai_driver = {
75104
.name = "HiFi",
76105
.playback = {
@@ -90,6 +119,7 @@ static struct snd_soc_dai_driver max98357a_dai_driver = {
90119
.channels_min = 1,
91120
.channels_max = 2,
92121
},
122+
.ops = &max98357a_dai_ops,
93123
};
94124

95125
static int max98357a_platform_probe(struct platform_device *pdev)

sound/soc/codecs/max98390.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static const struct snd_kcontrol_new max98390_dai_controls =
678678

679679
static const struct snd_soc_dapm_widget max98390_dapm_widgets[] = {
680680
SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback",
681-
MAX98390_R203A_AMP_EN, 0, 0, max98390_dac_event,
681+
SND_SOC_NOPM, 0, 0, max98390_dac_event,
682682
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
683683
SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0,
684684
&max98390_dai_controls),

sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,45 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
336336
struct snd_interval *chan = hw_param_interval(params,
337337
SNDRV_PCM_HW_PARAM_CHANNELS);
338338
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
339-
struct snd_soc_dpcm *dpcm = container_of(
340-
params, struct snd_soc_dpcm, hw_params);
341-
struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
342-
struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
339+
struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL;
340+
341+
/*
342+
* The following loop will be called only for playback stream
343+
* In this platform, there is only one playback device on every SSP
344+
*/
345+
for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) {
346+
rtd_dpcm = dpcm;
347+
break;
348+
}
349+
350+
/*
351+
* This following loop will be called only for capture stream
352+
* In this platform, there is only one capture device on every SSP
353+
*/
354+
for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
355+
rtd_dpcm = dpcm;
356+
break;
357+
}
358+
359+
if (!rtd_dpcm)
360+
return -EINVAL;
361+
362+
/*
363+
* The above 2 loops are mutually exclusive based on the stream direction,
364+
* thus rtd_dpcm variable will never be overwritten
365+
*/
343366

344367
/*
345368
* The ADSP will convert the FE rate to 48k, stereo, 24 bit
346369
*/
347-
if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
348-
!strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
349-
!strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
370+
if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Port") ||
371+
!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Headset Playback") ||
372+
!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Capture Port")) {
350373
rate->min = rate->max = 48000;
351374
chan->min = chan->max = 2;
352375
snd_mask_none(fmt);
353376
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
354-
} else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
377+
} else if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio DMIC cap")) {
355378
if (params_channels(params) == 2 ||
356379
DMIC_CH(dmic_constraints) == 2)
357380
chan->min = chan->max = 2;
@@ -362,7 +385,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
362385
* The speaker on the SSP0 supports S16_LE and not S24_LE.
363386
* thus changing the mask here
364387
*/
365-
if (!strcmp(be_dai_link->name, "SSP0-Codec"))
388+
if (!strcmp(rtd_dpcm->be->dai_link->name, "SSP0-Codec"))
366389
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
367390

368391
return 0;

sound/soc/intel/boards/skl_hda_dsp_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct skl_hda_private {
3333
int dai_index;
3434
const char *platform_name;
3535
bool common_hdmi_codec_drv;
36+
bool idisp_codec;
3637
};
3738

3839
extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];

sound/soc/intel/boards/skl_hda_dsp_generic.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
7979
link->platforms->name = ctx->platform_name;
8080
link->nonatomic = 1;
8181

82+
if (!ctx->idisp_codec)
83+
return 0;
84+
8285
if (strstr(link->name, "HDMI")) {
8386
ret = skl_hda_hdmi_add_pcm(card, ctx->pcm_count);
8487

@@ -118,19 +121,20 @@ static char hda_soc_components[30];
118121
static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
119122
{
120123
struct snd_soc_card *card = &hda_soc_card;
124+
struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
121125
struct snd_soc_dai_link *dai_link;
122-
u32 codec_count, codec_mask, idisp_mask;
126+
u32 codec_count, codec_mask;
123127
int i, num_links, num_route;
124128

125129
codec_mask = mach_params->codec_mask;
126130
codec_count = hweight_long(codec_mask);
127-
idisp_mask = codec_mask & IDISP_CODEC_MASK;
131+
ctx->idisp_codec = !!(codec_mask & IDISP_CODEC_MASK);
128132

129133
if (!codec_count || codec_count > 2 ||
130-
(codec_count == 2 && !idisp_mask))
134+
(codec_count == 2 && !ctx->idisp_codec))
131135
return -EINVAL;
132136

133-
if (codec_mask == idisp_mask) {
137+
if (codec_mask == IDISP_CODEC_MASK) {
134138
/* topology with iDisp as the only HDA codec */
135139
num_links = IDISP_DAI_COUNT + DMIC_DAI_COUNT;
136140
num_route = IDISP_ROUTE_COUNT;
@@ -152,7 +156,7 @@ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
152156
num_route = ARRAY_SIZE(skl_hda_map);
153157
card->dapm_widgets = skl_hda_widgets;
154158
card->num_dapm_widgets = ARRAY_SIZE(skl_hda_widgets);
155-
if (!idisp_mask) {
159+
if (!ctx->idisp_codec) {
156160
for (i = 0; i < IDISP_DAI_COUNT; i++) {
157161
skl_hda_be_dai_links[i].codecs = dummy_codec;
158162
skl_hda_be_dai_links[i].num_codecs =
@@ -211,6 +215,8 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
211215
if (!mach)
212216
return -EINVAL;
213217

218+
snd_soc_card_set_drvdata(&hda_soc_card, ctx);
219+
214220
ret = skl_hda_fill_card_info(&mach->mach_params);
215221
if (ret < 0) {
216222
dev_err(&pdev->dev, "Unsupported HDAudio/iDisp configuration found\n");
@@ -223,7 +229,6 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
223229
ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
224230

225231
hda_soc_card.dev = &pdev->dev;
226-
snd_soc_card_set_drvdata(&hda_soc_card, ctx);
227232

228233
if (mach->mach_params.dmic_num > 0) {
229234
snprintf(hda_soc_components, sizeof(hda_soc_components),

sound/soc/meson/axg-tdm-formatter.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks);
7070
static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
7171
{
7272
struct axg_tdm_stream *ts = formatter->stream;
73-
bool invert = formatter->drv->quirks->invert_sclk;
73+
bool invert;
7474
int ret;
7575

7676
/* Do nothing if the formatter is already enabled */
@@ -96,11 +96,12 @@ static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
9696
return ret;
9797

9898
/*
99-
* If sclk is inverted, invert it back and provide the inversion
100-
* required by the formatter
99+
* If sclk is inverted, it means the bit should latched on the
100+
* rising edge which is what our HW expects. If not, we need to
101+
* invert it before the formatter.
101102
*/
102-
invert ^= axg_tdm_sclk_invert(ts->iface->fmt);
103-
ret = clk_set_phase(formatter->sclk, invert ? 180 : 0);
103+
invert = axg_tdm_sclk_invert(ts->iface->fmt);
104+
ret = clk_set_phase(formatter->sclk, invert ? 0 : 180);
104105
if (ret)
105106
return ret;
106107

sound/soc/meson/axg-tdm-formatter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct snd_kcontrol;
1616

1717
struct axg_tdm_formatter_hw {
1818
unsigned int skew_offset;
19-
bool invert_sclk;
2019
};
2120

2221
struct axg_tdm_formatter_ops {

sound/soc/meson/axg-tdm-interface.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,25 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
119119
{
120120
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
121121

122-
/* These modes are not supported */
123-
if (fmt & (SND_SOC_DAIFMT_CBS_CFM | SND_SOC_DAIFMT_CBM_CFS)) {
122+
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
123+
case SND_SOC_DAIFMT_CBS_CFS:
124+
if (!iface->mclk) {
125+
dev_err(dai->dev, "cpu clock master: mclk missing\n");
126+
return -ENODEV;
127+
}
128+
break;
129+
130+
case SND_SOC_DAIFMT_CBM_CFM:
131+
break;
132+
133+
case SND_SOC_DAIFMT_CBS_CFM:
134+
case SND_SOC_DAIFMT_CBM_CFS:
124135
dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
136+
/* Fall-through */
137+
default:
125138
return -EINVAL;
126139
}
127140

128-
/* If the TDM interface is the clock master, it requires mclk */
129-
if (!iface->mclk && (fmt & SND_SOC_DAIFMT_CBS_CFS)) {
130-
dev_err(dai->dev, "cpu clock master: mclk missing\n");
131-
return -ENODEV;
132-
}
133-
134141
iface->fmt = fmt;
135142
return 0;
136143
}
@@ -319,7 +326,8 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream,
319326
if (ret)
320327
return ret;
321328

322-
if (iface->fmt & SND_SOC_DAIFMT_CBS_CFS) {
329+
if ((iface->fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
330+
SND_SOC_DAIFMT_CBS_CFS) {
323331
ret = axg_tdm_iface_set_sclk(dai, params);
324332
if (ret)
325333
return ret;

sound/soc/meson/axg-tdmin.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,29 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = {
228228
.regmap_cfg = &axg_tdmin_regmap_cfg,
229229
.ops = &axg_tdmin_ops,
230230
.quirks = &(const struct axg_tdm_formatter_hw) {
231-
.invert_sclk = false,
232231
.skew_offset = 2,
233232
},
234233
};
235234

235+
static const struct axg_tdm_formatter_driver g12a_tdmin_drv = {
236+
.component_drv = &axg_tdmin_component_drv,
237+
.regmap_cfg = &axg_tdmin_regmap_cfg,
238+
.ops = &axg_tdmin_ops,
239+
.quirks = &(const struct axg_tdm_formatter_hw) {
240+
.skew_offset = 3,
241+
},
242+
};
243+
236244
static const struct of_device_id axg_tdmin_of_match[] = {
237245
{
238246
.compatible = "amlogic,axg-tdmin",
239247
.data = &axg_tdmin_drv,
248+
}, {
249+
.compatible = "amlogic,g12a-tdmin",
250+
.data = &g12a_tdmin_drv,
251+
}, {
252+
.compatible = "amlogic,sm1-tdmin",
253+
.data = &g12a_tdmin_drv,
240254
}, {}
241255
};
242256
MODULE_DEVICE_TABLE(of, axg_tdmin_of_match);

0 commit comments

Comments
 (0)