Skip to content

Commit 5e06ee4

Browse files
povikjannau
authored andcommitted
ASoC: tas2764: Crop SDOUT zero-out mask based on BCLK ratio
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
1 parent ebd334c commit 5e06ee4

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

sound/soc/codecs/tas2764.c

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,44 @@ static int tas2764_hw_params(struct snd_pcm_substream *substream,
348348
return tas2764_set_samplerate(tas2764, params_rate(params));
349349
}
350350

351+
static int tas2764_write_sdout_zero_mask(struct tas2764_priv *tas2764, int bclk_ratio)
352+
{
353+
struct snd_soc_component *component = tas2764->component;
354+
int nsense_slots = bclk_ratio / 8;
355+
u32 cropped_mask;
356+
int i, ret;
357+
358+
if (!tas2764->sdout_zero_mask)
359+
return 0;
360+
361+
cropped_mask = tas2764->sdout_zero_mask & GENMASK(nsense_slots - 1, 0);
362+
363+
for (i = 0; i < 4; i++) {
364+
ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
365+
(cropped_mask >> (i * 8)) & 0xff);
366+
367+
if (ret < 0)
368+
return ret;
369+
}
370+
371+
ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
372+
TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
373+
TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
374+
375+
if (ret < 0)
376+
return ret;
377+
378+
return 0;
379+
}
380+
381+
static int tas2764_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
382+
{
383+
struct snd_soc_component *component = dai->component;
384+
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
385+
386+
return tas2764_write_sdout_zero_mask(tas2764, ratio);
387+
}
388+
351389
static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
352390
{
353391
struct snd_soc_component *component = dai->component;
@@ -489,6 +527,7 @@ static int tas2764_set_ivsense_transmit(struct tas2764_priv *tas2764, int i_slot
489527
static const struct snd_soc_dai_ops tas2764_dai_ops = {
490528
.mute_stream = tas2764_mute,
491529
.hw_params = tas2764_hw_params,
530+
.set_bclk_ratio = tas2764_set_bclk_ratio,
492531
.set_fmt = tas2764_set_fmt,
493532
.set_tdm_slot = tas2764_set_dai_tdm_slot,
494533
.no_capture_mute = 1,
@@ -645,23 +684,6 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
645684
return ret;
646685
}
647686

648-
if (tas2764->sdout_zero_mask) {
649-
for (i = 0; i < 4; i++) {
650-
ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
651-
(tas2764->sdout_zero_mask >> (i * 8)) & 0xff);
652-
653-
if (ret < 0)
654-
return ret;
655-
}
656-
657-
ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
658-
TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
659-
TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
660-
661-
if (ret < 0)
662-
return ret;
663-
}
664-
665687
if (tas2764->devid == DEVID_SN012776) {
666688
ret = tas2764_apply_unk_apple_quirk(component);
667689

0 commit comments

Comments
 (0)