All of lore.kernel.org
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH] ASoC: rt1011: export r0 and temperature config
@ 2019-10-08  9:33 Shuming [范書銘]
  2019-10-08 10:51 ` Mark Brown
  2019-10-10 14:20 ` Mark Brown
  0 siblings, 2 replies; 10+ messages in thread
From: Shuming [范書銘] @ 2019-10-08  9:33 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: Oder Chiou, Jack Yu, alsa-devel, lars, cychiang,
	Derek [方德義],
	Shuming [范書銘], Flove(HsinFu)

[-- Attachment #1: Type: text/plain, Size: 2368 bytes --]

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@realtek.com>
---
 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 #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 5847 bytes --]

[-- Attachment #3: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-10-17  6:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08  9:33 [alsa-devel] [PATCH] ASoC: rt1011: export r0 and temperature config Shuming [范書銘]
2019-10-08 10:51 ` Mark Brown
2019-10-08 10:59   ` Cheng-yi Chiang
2019-10-08 11:06     ` Mark Brown
2019-10-08 11:22       ` Cheng-yi Chiang
2019-10-08 12:38         ` Mark Brown
2019-10-14  3:28           ` Cheng-yi Chiang
2019-10-10 14:20 ` Mark Brown
2019-10-14  1:46   ` Shuming [范書銘]
2019-10-14  2:47     ` Jimmy Cheng-Yi Chiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.