Skip to content

Commit a68f203

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 7524980 commit a68f203

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
@@ -347,6 +347,44 @@ static int tas2764_hw_params(struct snd_pcm_substream *substream,
347347
return tas2764_set_samplerate(tas2764, params_rate(params));
348348
}
349349

350+
static int tas2764_write_sdout_zero_mask(struct tas2764_priv *tas2764, int bclk_ratio)
351+
{
352+
struct snd_soc_component *component = tas2764->component;
353+
int nsense_slots = bclk_ratio / 8;
354+
u32 cropped_mask;
355+
int i, ret;
356+
357+
if (!tas2764->sdout_zero_mask)
358+
return 0;
359+
360+
cropped_mask = tas2764->sdout_zero_mask & GENMASK(nsense_slots - 1, 0);
361+
362+
for (i = 0; i < 4; i++) {
363+
ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
364+
(cropped_mask >> (i * 8)) & 0xff);
365+
366+
if (ret < 0)
367+
return ret;
368+
}
369+
370+
ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
371+
TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
372+
TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
373+
374+
if (ret < 0)
375+
return ret;
376+
377+
return 0;
378+
}
379+
380+
static int tas2764_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
381+
{
382+
struct snd_soc_component *component = dai->component;
383+
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
384+
385+
return tas2764_write_sdout_zero_mask(tas2764, ratio);
386+
}
387+
350388
static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
351389
{
352390
struct snd_soc_component *component = dai->component;
@@ -496,6 +534,7 @@ static int tas2764_set_ivsense_transmit(struct tas2764_priv *tas2764, int i_slot
496534
static const struct snd_soc_dai_ops tas2764_dai_ops = {
497535
.mute_stream = tas2764_mute,
498536
.hw_params = tas2764_hw_params,
537+
.set_bclk_ratio = tas2764_set_bclk_ratio,
499538
.set_fmt = tas2764_set_fmt,
500539
.set_tdm_slot = tas2764_set_dai_tdm_slot,
501540
.no_capture_mute = 1,
@@ -652,23 +691,6 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
652691
return ret;
653692
}
654693

655-
if (tas2764->sdout_zero_mask) {
656-
for (i = 0; i < 4; i++) {
657-
ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
658-
(tas2764->sdout_zero_mask >> (i * 8)) & 0xff);
659-
660-
if (ret < 0)
661-
return ret;
662-
}
663-
664-
ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
665-
TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
666-
TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
667-
668-
if (ret < 0)
669-
return ret;
670-
}
671-
672694
if (tas2764->devid == DEVID_SN012776) {
673695
ret = tas2764_apply_unk_apple_quirk(component);
674696

0 commit comments

Comments
 (0)