Skip to content

Commit 1bbc783

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 04ac1ee commit 1bbc783

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

sound/soc/codecs/tas2764.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,44 @@ static int tas2764_hw_params(struct snd_pcm_substream *substream,
351351
return tas2764_set_samplerate(tas2764, params_rate(params));
352352
}
353353

354+
static int tas2764_write_sdout_zero_mask(struct tas2764_priv *tas2764, int bclk_ratio)
355+
{
356+
struct snd_soc_component *component = tas2764->component;
357+
int nsense_slots = bclk_ratio / 8;
358+
u32 cropped_mask;
359+
int i, ret;
360+
361+
if (!tas2764->sdout_zero_mask)
362+
return 0;
363+
364+
cropped_mask = tas2764->sdout_zero_mask & GENMASK(nsense_slots - 1, 0);
365+
366+
for (i = 0; i < 4; i++) {
367+
ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
368+
(cropped_mask >> (i * 8)) & 0xff);
369+
370+
if (ret < 0)
371+
return ret;
372+
}
373+
374+
ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
375+
TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
376+
TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
377+
378+
if (ret < 0)
379+
return ret;
380+
381+
return 0;
382+
}
383+
384+
static int tas2764_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
385+
{
386+
struct snd_soc_component *component = dai->component;
387+
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
388+
389+
return tas2764_write_sdout_zero_mask(tas2764, ratio);
390+
}
391+
354392
static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
355393
{
356394
struct snd_soc_component *component = dai->component;
@@ -500,6 +538,7 @@ static int tas2764_set_ivsense_transmit(struct tas2764_priv *tas2764, int i_slot
500538
static const struct snd_soc_dai_ops tas2764_dai_ops = {
501539
.mute_stream = tas2764_mute,
502540
.hw_params = tas2764_hw_params,
541+
.set_bclk_ratio = tas2764_set_bclk_ratio,
503542
.set_fmt = tas2764_set_fmt,
504543
.set_tdm_slot = tas2764_set_dai_tdm_slot,
505544
.no_capture_mute = 1,

0 commit comments

Comments
 (0)