Skip to content

Commit f658445

Browse files
povikjannau
authored andcommitted
ASoC: macaudio: Tune constraining of FEs, add BCLK
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
1 parent bff8e64 commit f658445

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

sound/soc/apple/macaudio.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
SND_SOC_DAIFMT_IB_IF)
4646
#define MACAUDIO_JACK_MASK (SND_JACK_HEADSET | SND_JACK_HEADPHONE)
4747
#define MACAUDIO_SLOTWIDTH 32
48+
/*
49+
* Maximum BCLK frequency
50+
*
51+
* Codec maximums:
52+
* CS42L42 26.0 MHz
53+
* TAS2770 27.1 MHz
54+
* TAS2764 24.576 MHz
55+
*/
56+
#define MACAUDIO_MAX_BCLK_FREQ 24576000
4857

4958
struct macaudio_snd_data {
5059
struct snd_soc_card card;
@@ -500,19 +509,23 @@ static int macaudio_fe_startup(struct snd_pcm_substream *substream)
500509
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
501510
struct macaudio_snd_data *ma = snd_soc_card_get_drvdata(rtd->card);
502511
struct macaudio_link_props *props = &ma->link_props[rtd->dai_link->id];
503-
int ret;
512+
int max_rate, ret;
504513

505514
if (props->is_sense)
506515
return 0;
507516

508-
/* The FEs must never have more channels than the hardware */
509517
ret = snd_pcm_hw_constraint_minmax(substream->runtime,
510-
SNDRV_PCM_HW_PARAM_CHANNELS, 0, ma->max_channels);
518+
SNDRV_PCM_HW_PARAM_CHANNELS,
519+
0, ma->max_channels);
520+
if (ret < 0)
521+
return ret;
511522

512-
if (ret < 0) {
513-
dev_err(rtd->dev, "Failed to constrain FE %d! %d", rtd->dai_link->id, ret);
523+
max_rate = MACAUDIO_MAX_BCLK_FREQ / props->bclk_ratio;
524+
ret = snd_pcm_hw_constraint_minmax(substream->runtime,
525+
SNDRV_PCM_HW_PARAM_RATE,
526+
0, max_rate);
527+
if (ret < 0)
514528
return ret;
515-
}
516529

517530
return 0;
518531
}

0 commit comments

Comments
 (0)