Skip to content

Commit

Permalink
ASoC: rt1015: Fix DC calibration on bypass boost mode
Browse files Browse the repository at this point in the history
Fix the DC calibration unsuccessful issue on rt1015
bypass boost mode.

Signed-off-by: derek.fang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
oortcomet authored and broonie committed Sep 14, 2020
1 parent 1a5ce48 commit da14517
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
48 changes: 34 additions & 14 deletions sound/soc/codecs/rt1015.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,33 @@ static int rt1015_bypass_boost_get(struct snd_kcontrol *kcontrol,
return 0;
}

static void rt1015_calibrate(struct rt1015_priv *rt1015)
{
struct snd_soc_component *component = rt1015->component;
struct regmap *regmap = rt1015->regmap;

snd_soc_dapm_mutex_lock(&component->dapm);
regcache_cache_bypass(regmap, true);

regmap_write(regmap, RT1015_PWR1, 0xd7df);
regmap_write(regmap, RT1015_PWR4, 0x00b2);
regmap_write(regmap, RT1015_CLSD_INTERNAL8, 0x2008);
regmap_write(regmap, RT1015_CLSD_INTERNAL9, 0x0140);
regmap_write(regmap, RT1015_GAT_BOOST, 0x0efe);
regmap_write(regmap, RT1015_PWR_STATE_CTRL, 0x000d);
regmap_write(regmap, RT1015_PWR_STATE_CTRL, 0x000e);
regmap_write(regmap, RT1015_DC_CALIB_CLSD1, 0x5a00);
regmap_write(regmap, RT1015_DC_CALIB_CLSD1, 0x5a01);
regmap_write(regmap, RT1015_DC_CALIB_CLSD1, 0x5a05);
msleep(500);
regmap_write(regmap, RT1015_PWR1, 0x0);

regcache_cache_bypass(regmap, false);
regcache_mark_dirty(regmap);
regcache_sync(regmap);
snd_soc_dapm_mutex_unlock(&component->dapm);
}

static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
Expand All @@ -494,20 +521,12 @@ static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,

if (!rt1015->dac_is_used) {
rt1015->bypass_boost = ucontrol->value.integer.value[0];
if (rt1015->bypass_boost == RT1015_Bypass_Boost) {
snd_soc_component_write(component,
RT1015_PWR4, 0x00b2);
snd_soc_component_write(component,
RT1015_CLSD_INTERNAL8, 0x2008);
snd_soc_component_write(component,
RT1015_CLSD_INTERNAL9, 0x0140);
snd_soc_component_write(component,
RT1015_GAT_BOOST, 0x0efe);
snd_soc_component_write(component,
RT1015_PWR_STATE_CTRL, 0x000d);
msleep(500);
snd_soc_component_write(component,
RT1015_PWR_STATE_CTRL, 0x000e);
if (rt1015->bypass_boost == RT1015_Bypass_Boost &&
!rt1015->cali_done) {
rt1015_calibrate(rt1015);
rt1015->cali_done = 1;

regmap_write(rt1015->regmap, RT1015_MONO_DYNA_CTRL, 0x0010);
}
} else
dev_err(component->dev, "DAC is being used!\n");
Expand Down Expand Up @@ -888,6 +907,7 @@ static int rt1015_probe(struct snd_soc_component *component)

rt1015->component = component;
rt1015->bclk_ratio = 0;
rt1015->cali_done = 0;
snd_soc_component_write(component, RT1015_BAT_RPO_STEP1, 0x061c);

return 0;
Expand Down
1 change: 1 addition & 0 deletions sound/soc/codecs/rt1015.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ struct rt1015_priv {
int bypass_boost;
int amp_ver;
int dac_is_used;
int cali_done;
};

#endif /* __RT1015_H__ */

0 comments on commit da14517

Please sign in to comment.