mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-05 13:05:25 +07:00
ASoC: tas2770: Refactor sample rate function
Refactor the tas2770_set_samplerate to simplify the code and access the I2C bus only once per rate request. The ramp rate and sample rate bits are contained in the same register so a single call to the snd_soc_update_bits function is all that is needed Signed-off-by: Dan Murphy <dmurphy@ti.com> Link: https://lore.kernel.org/r/20200918190548.12598-9-dmurphy@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d3964aff73
commit
be05ab41c6
@ -252,80 +252,43 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
|
|||||||
|
|
||||||
static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
|
static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct snd_soc_component *component = tas2770->component;
|
struct snd_soc_component *component = tas2770->component;
|
||||||
|
int ramp_rate_val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
switch (samplerate) {
|
switch (samplerate) {
|
||||||
case 48000:
|
case 48000:
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
|
||||||
TAS2770_TDM_CFG_REG0_SMP_MASK,
|
TAS2770_TDM_CFG_REG0_31_44_1_48KHZ;
|
||||||
TAS2770_TDM_CFG_REG0_SMP_48KHZ);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_MASK,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_44_1_48KHZ);
|
|
||||||
break;
|
break;
|
||||||
case 44100:
|
case 44100:
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
|
||||||
TAS2770_TDM_CFG_REG0_SMP_MASK,
|
TAS2770_TDM_CFG_REG0_31_44_1_48KHZ;
|
||||||
TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_MASK,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_44_1_48KHZ);
|
|
||||||
break;
|
break;
|
||||||
case 96000:
|
case 96000:
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
|
||||||
TAS2770_TDM_CFG_REG0_SMP_MASK,
|
TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
|
||||||
TAS2770_TDM_CFG_REG0_SMP_48KHZ);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_MASK,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_88_2_96KHZ);
|
|
||||||
break;
|
break;
|
||||||
case 88200:
|
case 88200:
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
|
||||||
TAS2770_TDM_CFG_REG0_SMP_MASK,
|
TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
|
||||||
TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_MASK,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_88_2_96KHZ);
|
|
||||||
break;
|
break;
|
||||||
case 19200:
|
case 19200:
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
|
||||||
TAS2770_TDM_CFG_REG0_SMP_MASK,
|
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
|
||||||
TAS2770_TDM_CFG_REG0_SMP_48KHZ);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_MASK,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ);
|
|
||||||
break;
|
break;
|
||||||
case 17640:
|
case 17640:
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
|
||||||
TAS2770_TDM_CFG_REG0_SMP_MASK,
|
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
|
||||||
TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_MASK,
|
|
||||||
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
||||||
|
TAS2770_TDM_CFG_REG0_SMP_MASK |
|
||||||
|
TAS2770_TDM_CFG_REG0_31_MASK,
|
||||||
|
ramp_rate_val);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user