In chromebook case, the machine driver will get the r0 calibration data and temperature from VPD. Therefore, the codec exports r0 and temperature config API for it. Signed-off-by: Shuming Fan <shumingf@xxxxxxxxxxx> --- sound/soc/codecs/rt1011.c | 41 +++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt1011.h | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/sound/soc/codecs/rt1011.c b/sound/soc/codecs/rt1011.c index a92a0bacd812..a992bb2224b2 100644 --- a/sound/soc/codecs/rt1011.c +++ b/sound/soc/codecs/rt1011.c @@ -1325,6 +1325,47 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol, .put = rt1011_r0_load_mode_put \ } +int rt1011_r0_config(struct snd_soc_component *component, unsigned int r0) +{ + struct rt1011_priv *rt1011 = + snd_soc_component_get_drvdata(component); + struct device *dev; + unsigned int r0_integer, r0_factor, format; + + if (!component->card->instantiated) + return 0; + + if (!r0) + return -EINVAL; + + dev = regmap_get_device(rt1011->regmap); + rt1011->r0_reg = r0; + + format = 2147483648U; /* 2^24 * 128 */ + r0_integer = format / rt1011->r0_reg / 128; + r0_factor = ((format / rt1011->r0_reg * 100) / 128) + - (r0_integer * 100); + dev_dbg(dev, "New r0 resistance about %d.%02d ohm, reg=0x%X\n", + r0_integer, r0_factor, rt1011->r0_reg); + + if (rt1011->r0_reg) + rt1011_r0_load(rt1011); + + return 0; +} +EXPORT_SYMBOL_GPL(rt1011_r0_config); + +int rt1011_temperature_config(struct snd_soc_component *component, + unsigned int temp) +{ + snd_soc_component_update_bits(component, + RT1011_STP_INITIAL_RESISTANCE_TEMP, 0x3ff, + (temp << 2)); + + return 0; +} +EXPORT_SYMBOL_GPL(rt1011_temperature_config); + static const struct snd_kcontrol_new rt1011_snd_controls[] = { /* I2S Data In Selection */ SOC_ENUM("DIN Source", rt1011_din_source_enum), diff --git a/sound/soc/codecs/rt1011.h b/sound/soc/codecs/rt1011.h index 2d65983f3d0f..b99df334be14 100644 --- a/sound/soc/codecs/rt1011.h +++ b/sound/soc/codecs/rt1011.h @@ -670,4 +670,9 @@ struct rt1011_priv { int recv_spk_mode; }; +int rt1011_r0_config(struct snd_soc_component *component, unsigned int r0); +int rt1011_temperature_config(struct snd_soc_component *component, + unsigned int temp); + + #endif /* end of _RT1011_H_ */ -- 2.23.0
<<attachment: winmail.dat>>
_______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx https://mailman.alsa-project.org/mailman/listinfo/alsa-devel