Skip to contentSkip to conversation

ASoC: max98090: read micbias from device property

PATCH Superseded [email protected] 3 participants 21 messages May 26, 2015 – Jun 15, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ASoC: max98090: read micbias from device property

From: "Fang, Yang A" <[email protected]>

This patch reads max98090 micbias from acpi or dt

---
 sound/soc/codecs/max98090.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +8 -1
index c230626..27df17e 100644
@@ -2419,6 +2419,8 @@ static int max98090_probe(struct snd_soc_codec *codec)
 	struct max98090_cdata *cdata;
 	enum max98090_type devtype;
 	int ret = 0;
+	int err;
+	unsigned int micbias;
 
 	dev_dbg(codec->dev, "max98090_probe\n");
 
@@ -2503,8 +2505,13 @@ static int max98090_probe(struct snd_soc_codec *codec)
 	snd_soc_write(codec, M98090_REG_BIAS_CONTROL,
 		M98090_VCM_MODE_MASK);
 
+	err = device_property_read_u32(codec->dev, "max,micbias", &micbias);
+
+	if (err)
+		micbias = M98090_MBVSEL_2V8;
+
 	snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE,
-		M98090_MBVSEL_MASK, M98090_MBVSEL_2V8);
+		M98090_MBVSEL_MASK, micbias);
 
 	max98090_add_widgets(codec);
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/3 ASoC: ts3a227e: use device property api

From: "Fang, Yang A" <[email protected]>

replace of_property_read_u32 with device_property_read_u32

---
 sound/soc/codecs/ts3a227e.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
sound/soc/codecs/ts3a227e.c +6 -8
index 9fd80ac..dfb49b3 100644
@@ -254,12 +254,12 @@ static const struct regmap_config ts3a227e_regmap_config = {
 	.num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults),
 };
 
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device *dev)
 {
 	u32 micbias;
 	int err;
 
-	err = of_property_read_u32(np, "ti,micbias", &micbias);
+	err = device_property_read_u32(dev, "ti,micbias", &micbias);
 	if (!err) {
 		regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3,
 			MICBIAS_SETTING_MASK,
@@ -287,12 +287,10 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
 
-	if (dev->of_node) {
-		ret = ts3a227e_parse_dt(ts3a227e, dev->of_node);
-		if (ret) {
-			dev_err(dev, "Failed to parse device tree: %d\n", ret);
-			return ret;
-		}
+	ret = ts3a227e_parse_dt(ts3a227e, dev);
+	if (ret) {
+		dev_err(dev, "Failed to parse device tree: %d\n", ret);
+		return ret;
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [PATCH 2/3] ASoC: ts3a227e: use device property api

sound/soc/codecs/ts3a227e.c static const struct regmap_config ts3a227e_regmap_config = { · line 257

Quoted 2 lines · On Tue, May 26, 2015 at 04:58:05PM -0700, [email protected] wrote:
sound/soc/codecs/ts3a227e.c +1 -1
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device *dev)

You should rename the function - it's not just parsing DT, it's also parsing ACPI (and any other firmware interface that comes along) now.

#3 lore raw

PATCH 3/3 ASoC: Intel: fixed TI button detection

In reply to [email protected]

From: "Fang, Yang A" <[email protected]>

In order to make TI button interrupt working max98090 codec Need provide mic bias all the time as long as mic is present so SHDN and micbias pin are forced on.we also need set max98090 codec bias close or lower than TI bias.We set them in bios/coreboot kernel reads them from device property

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +41 -0
index 1be0794..8ef947f 100644
@@ -101,6 +101,44 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int pin_status;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +168,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to [email protected]
Quoted 23 lines · On Tue, May 26, 2015 at 4:58 PM, <[email protected]> wrote:

From: "Fang, Yang A" <[email protected]>

This patch reads max98090 micbias from acpi or dt

---
 sound/soc/codecs/max98090.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +2 -0
index c230626..27df17e 100644
@@ -2419,6 +2419,8 @@ static int max98090_probe(struct snd_soc_codec *codec)
        struct max98090_cdata *cdata;
        enum max98090_type devtype;
        int ret = 0;
+       int err;
+       unsigned int micbias;
 
        dev_dbg(codec->dev, "max98090_probe\n");
 

sound/soc/codecs/max98090.c static int max98090_probe(struct snd_soc_codec *codec) · line 2508

Quoted 4 lines
sound/soc/codecs/max98090.c +1 -0
@@ -2503,8 +2505,13 @@ static int max98090_probe(struct snd_soc_codec *codec)
        snd_soc_write(codec, M98090_REG_BIAS_CONTROL,
                M98090_VCM_MODE_MASK);
 
+       err = device_property_read_u32(codec->dev, "max,micbias", &micbias);

Should this be "maxim,micbias" to be consistent with "maxim,dmic-freq"? It should also be added to the Documentation for the max98090, as an optional parameter.

sound/soc/codecs/max98090.c static int max98090_probe(struct snd_soc_codec *codec) · line 2509

Quoted 1 line
sound/soc/codecs/max98090.c +1 -0
+

Extra newline.

Quoted 12 lines
sound/soc/codecs/max98090.c +4 -2
+       if (err)
+               micbias = M98090_MBVSEL_2V8;
+
        snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE,
-               M98090_MBVSEL_MASK, M98090_MBVSEL_2V8);
+               M98090_MBVSEL_MASK, micbias);
 
        max98090_add_widgets(codec);
 
--

1.7.9.5

author
#5 lore raw
Quoted 27 lines · Dylan Reid
Quoted 26 lines · On Tue, May 26, 2015 at 4:58 PM, <[email protected]> wrote:

From: "Fang, Yang A" <[email protected]>

This patch reads max98090 micbias from acpi or dt

---
 sound/soc/codecs/max98090.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/codecs/max98090.c +2 -0
index c230626..27df17e 100644
@@ -2419,6 +2419,8 @@ static int max98090_probe(struct snd_soc_codec *codec)
        struct max98090_cdata *cdata;
        enum max98090_type devtype;
        int ret = 0;
+       int err;
+       unsigned int micbias;
 
        dev_dbg(codec->dev, "max98090_probe\n");
 
@@ -2503,8 +2505,13 @@ static int max98090_probe(struct snd_soc_codec *codec)
        snd_soc_write(codec, M98090_REG_BIAS_CONTROL,
                M98090_VCM_MODE_MASK);
 
Quoted 5 lines

sound/soc/codecs/max98090.c static int max98090_probe(struct snd_soc_codec *codec) · line 2508

Quoted 1 line
sound/soc/codecs/max98090.c +1 -0
+       err = device_property_read_u32(codec->dev, "max,micbias", &micbias);

Should this be "maxim,micbias" to be consistent with "maxim,dmic-freq"? It should also be added to the Documentation for the max98090, as an optional parameter.

Agreed . i will change it in v2 and update the Documentation

Quoted 4 lines

sound/soc/codecs/max98090.c static int max98090_probe(struct snd_soc_codec *codec) · line 2509

Quoted 2 lines
sound/soc/codecs/max98090.c +1 -0
+

Extra newline.

will fix in v2

Quoted 13 lines
Quoted 13 lines
sound/soc/codecs/max98090.c +4 -2
+       if (err)
+               micbias = M98090_MBVSEL_2V8;
+
        snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE,
-               M98090_MBVSEL_MASK, M98090_MBVSEL_2V8);
+               M98090_MBVSEL_MASK, micbias);
 
        max98090_add_widgets(codec);
 
--

1.7.9.5

#7 lore raw

PATCH v2 1/3 ASoC: max98090: read micbias from device property

In reply to [email protected]

From: "Fang, Yang A" <[email protected]>

This patch reads max98090 micbias from acpi or dt

---
 .../devicetree/bindings/sound/max98090.txt         |    2 ++
 sound/soc/codecs/max98090.c                        |    8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/max98090.txt +2 -0
index aa802a2..eecb710 100644
@@ -18,6 +18,8 @@ Optional properties:
 
 - maxim,dmic-freq: Frequency at which to clock DMIC
 
+- maxim,micbias: Micbias voltage applies to the analog mic
+
 Pins on the device (for linking into audio routes):
 
   * MIC1
sound/soc/codecs/max98090.c +7 -1
index c230626..4b61db7 100644
@@ -2419,6 +2419,8 @@ static int max98090_probe(struct snd_soc_codec *codec)
 	struct max98090_cdata *cdata;
 	enum max98090_type devtype;
 	int ret = 0;
+	int err;
+	unsigned int micbias;
 
 	dev_dbg(codec->dev, "max98090_probe\n");
 
@@ -2503,8 +2505,12 @@ static int max98090_probe(struct snd_soc_codec *codec)
 	snd_soc_write(codec, M98090_REG_BIAS_CONTROL,
 		M98090_VCM_MODE_MASK);
 
+	err = device_property_read_u32(codec->dev, "maxim,micbias", &micbias);
+	if (err || micbias < M98090_MBVSEL_2V2  || micbias > M98090_MBVSEL_2V8)
+		micbias = M98090_MBVSEL_2V8;
+
 	snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE,
-		M98090_MBVSEL_MASK, M98090_MBVSEL_2V8);
+		M98090_MBVSEL_MASK, micbias);
 
 	max98090_add_widgets(codec);
 
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v2 2/3 ASoC: ts3a227e: use device property api

From: "Fang, Yang A" <[email protected]>

replace of_property_read_u32 with device_property_read_u32

---
 sound/soc/codecs/ts3a227e.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
sound/soc/codecs/ts3a227e.c +7 -8
index 9fd80ac..12232d7 100644
@@ -254,12 +254,13 @@ static const struct regmap_config ts3a227e_regmap_config = {
 	.num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults),
 };
 
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_device_property(struct ts3a227e *ts3a227e,
+				struct device *dev)
 {
 	u32 micbias;
 	int err;
 
-	err = of_property_read_u32(np, "ti,micbias", &micbias);
+	err = device_property_read_u32(dev, "ti,micbias", &micbias);
 	if (!err) {
 		regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3,
 			MICBIAS_SETTING_MASK,
@@ -287,12 +288,10 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
 
-	if (dev->of_node) {
-		ret = ts3a227e_parse_dt(ts3a227e, dev->of_node);
-		if (ret) {
-			dev_err(dev, "Failed to parse device tree: %d\n", ret);
-			return ret;
-		}
+	ret = ts3a227e_parse_device_property(ts3a227e, dev);
+	if (ret) {
+		dev_err(dev, "Failed to parse device property: %d\n", ret);
+		return ret;
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v2 3/3 ASoC: Intel: fixed TI button detection

In reply to [email protected]

From: "Fang, Yang A" <[email protected]>

In order to make TI button interrupt working max98090 codec Need provide mic bias all the time as long as mic is present so SHDN and micbias pin are forced on.we also need set max98090 codec bias close or lower than TI bias.We set them in bios/coreboot kernel reads them from device property

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   40 ++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +40 -0
index 1be0794..3e5842d 100644
@@ -101,6 +101,43 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int pin_status;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +167,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
maintainer
#10 lore raw
In reply to [email protected]
Quoted 3 lines · On Thu, May 28, 2015 at 11:00:46AM -0700, [email protected] wrote:

- maxim,dmic-freq: Frequency at which to clock DMIC

+- maxim,micbias: Micbias voltage applies to the analog mic

This needs to be more specific about what the value is - it looks like it's the value to be written into a particular register?

sound/soc/codecs/max98090.c static int max98090_probe(struct snd_soc_codec *codec) · line 2510

Quoted 3 lines
sound/soc/codecs/max98090.c +3 -0
+	err = device_property_read_u32(codec->dev, "maxim,micbias", &micbias);
+	if (err || micbias < M98090_MBVSEL_2V2  || micbias > M98090_MBVSEL_2V8)
+		micbias = M98090_MBVSEL_2V8;

We should be logging an error if we read and out of range value here - it's expected that the value might be missing but if we manage to read something and it's invalid we should say so rather than silently ignore it.

#11 lore raw
Quoted 13 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Friday, May 29, 2015 2:59 AM
To: Fang, Yang A
Cc: [email protected]; [email protected]; [email protected]; Nujella, Sathyanarayana; [email protected]; Sripathi, Srinivas; Iriawan, Denny; Jain, Praveen K; Koul, Vinod
Subject: Re: [PATCH v2 1/3] ASoC: max98090: read micbias from device property

Quoted 9 lines
Quoted 3 lines · On Thu, May 28, 2015 at 11:00:46AM -0700, [email protected] wrote:

- maxim,dmic-freq: Frequency at which to clock DMIC

+- maxim,micbias: Micbias voltage applies to the analog mic

This needs to be more specific about what the value is - it looks like it's the value to be written into a particular register?

Yes it is written into the register. I will put more information

Quoted 9 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	err = device_property_read_u32(codec->dev, "maxim,micbias",

&micbias);

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (err || micbias < M98090_MBVSEL_2V2  || micbias >

M98090_MBVSEL_2V8)

sound/soc/codecs/max98090.c static int max98090_probe(struct snd_soc_codec *codec) · line 2510

Quoted 1 line
sound/soc/codecs/max98090.c +1 -0
+		micbias = M98090_MBVSEL_2V8;

We should be logging an error if we read and out of range value here - it's expected that the value might be missing but if we manage to read something and it's invalid we should say so rather than silently ignore it.

Okay, will put log if out of range .

#12 lore raw

PATCH v3 1/3 ASoC: max98090: read micbias from device property

In reply to [email protected]

From: "Fang, Yang A" <[email protected]>

This patch reads max98090 micbias from acpi or dt

---
 .../devicetree/bindings/sound/max98090.txt         |    6 ++++++
 sound/soc/codecs/max98090.c                        |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/max98090.txt +6 -0
index aa802a2..4e3be66 100644
@@ -18,6 +18,12 @@ Optional properties:
 
 - maxim,dmic-freq: Frequency at which to clock DMIC
 
+- maxim,micbias: Micbias voltage applies to the analog mic, valid voltages value are:
+	0 - 2.2v
+	1 - 2.55v
+	2 - 2.4v
+	3 - 2.8v
+
 Pins on the device (for linking into audio routes):
 
   * MIC1
sound/soc/codecs/max98090.c +12 -1
index c230626..679f0a0 100644
@@ -2419,6 +2419,8 @@ static int max98090_probe(struct snd_soc_codec *codec)
 	struct max98090_cdata *cdata;
 	enum max98090_type devtype;
 	int ret = 0;
+	int err;
+	unsigned int micbias;
 
 	dev_dbg(codec->dev, "max98090_probe\n");
 
@@ -2503,8 +2505,17 @@ static int max98090_probe(struct snd_soc_codec *codec)
 	snd_soc_write(codec, M98090_REG_BIAS_CONTROL,
 		M98090_VCM_MODE_MASK);
 
+	err = device_property_read_u32(codec->dev, "maxim,micbias", &micbias);
+	if (err) {
+		micbias = M98090_MBVSEL_2V8;
+		dev_info(codec->dev, "use default 2.8v micbias\n");
+	} else if (micbias < M98090_MBVSEL_2V2 || micbias > M98090_MBVSEL_2V8) {
+		dev_err(codec->dev, "micbias out of range 0x%x\n", micbias);
+		micbias = M98090_MBVSEL_2V8;
+	}
+
 	snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE,
-		M98090_MBVSEL_MASK, M98090_MBVSEL_2V8);
+		M98090_MBVSEL_MASK, micbias);
 
 	max98090_add_widgets(codec);
 
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v3 2/3 ASoC: ts3a227e: use device property api

From: "Fang, Yang A" <[email protected]>

replace of_property_read_u32 with device_property_read_u32

---
 sound/soc/codecs/ts3a227e.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
sound/soc/codecs/ts3a227e.c +7 -8
index 9fd80ac..12232d7 100644
@@ -254,12 +254,13 @@ static const struct regmap_config ts3a227e_regmap_config = {
 	.num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults),
 };
 
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_device_property(struct ts3a227e *ts3a227e,
+				struct device *dev)
 {
 	u32 micbias;
 	int err;
 
-	err = of_property_read_u32(np, "ti,micbias", &micbias);
+	err = device_property_read_u32(dev, "ti,micbias", &micbias);
 	if (!err) {
 		regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3,
 			MICBIAS_SETTING_MASK,
@@ -287,12 +288,10 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
 
-	if (dev->of_node) {
-		ret = ts3a227e_parse_dt(ts3a227e, dev->of_node);
-		if (ret) {
-			dev_err(dev, "Failed to parse device tree: %d\n", ret);
-			return ret;
-		}
+	ret = ts3a227e_parse_device_property(ts3a227e, dev);
+	if (ret) {
+		dev_err(dev, "Failed to parse device property: %d\n", ret);
+		return ret;
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
Signature · 1 line
1.7.9.5
maintainer Applied
#14 lore raw

Re: [PATCH v3 2/3] ASoC: ts3a227e: use device property api

Quoted 3 lines · On Fri, May 29, 2015 at 11:56:11AM -0700, [email protected] wrote:

From: "Fang, Yang A" <[email protected]>

replace of_property_read_u32 with device_property_read_u32

Applied, thanks.

#15 lore raw

PATCH v3 3/3 ASoC: Intel: fixed TI button detection

In reply to [email protected]

From: "Fang, Yang A" <[email protected]>

In order to make TI button interrupt working max98090 codec Need provide mic bias all the time as long as mic is present so SHDN and micbias pin are forced on.we also need set max98090 codec bias close or lower than TI bias.We set them in bios/coreboot kernel reads them from device property

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   40 ++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +40 -0
index 1be0794..3e5842d 100644
@@ -101,6 +101,43 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int pin_status;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +167,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
maintainer
#16 lore raw

Re: [PATCH v3 3/3] ASoC: Intel: fixed TI button detection

sound/soc/intel/boards/cht_bsw_max98090_ti.c static int cht_aif1_hw_params(struct snd_pcm_substream *substream, · line 117

Quoted 5 lines · On Fri, May 29, 2015 at 11:56:12AM -0700, [email protected] wrote:
sound/soc/intel/boards/cht_bsw_max98090_ti.c +5 -0
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");

This seems wrong - either we need the pin enabled or we don't. If it's currently enabled for something transient like playback then it might get turned off later so we should still force it on.

sound/soc/intel/boards/cht_bsw_max98090_ti.c static int cht_aif1_hw_params(struct snd_pcm_substream *substream, · line 131

Quoted 9 lines
sound/soc/intel/boards/cht_bsw_max98090_ti.c +9 -0
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");

This is wrong, you're mixing locked and unlocked versions of the DAPM operations which can't be right - the difference between locked and unlocked versions of the operations is that the locked versions is if the locks for DAPM are already held and clearly there's no locking code here. This last operation shuld be a normal _disable_pin().

I'd also expect it to be before the sync - there's no telling how long it'll be till the next sync otherwise and no reason to leave the pin forced on if it's not needed. If it is in use due to some other thing then DAPM should ensure that the state doesn't get changed by the disable.

Indentation is broken for the comment too.

#17 lore raw

Re: [PATCH v3 3/3] ASoC: Intel: fixed TI button detection

Quoted 18 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, June 03, 2015 11:16 AM
To: Fang, Yang A
Cc: [email protected]; [email protected]; [email protected]; Nujella, Sathyanarayana; [email protected]; Sripathi, Srinivas; Iriawan, Denny; Jain, Praveen K; Koul, Vinod
Subject: Re: [PATCH v3 3/3] ASoC: Intel: fixed TI button detection

sound/soc/intel/boards/cht_bsw_max98090_ti.c static int cht_aif1_hw_params(struct snd_pcm_substream *substream,

Quoted 3 lines · On Fri, May 29, 2015 at 11:56:12AM -0700, [email protected] wrote:
sound/soc/intel/boards/cht_bsw_max98090_ti.c +3 -0
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm,

"SHDN");

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm,

"SHDN");

This seems wrong - either we need the pin enabled or we don't. If it's currently enabled for something transient like playback then it might get turned off later so we should still force it on.

Got it. I will remove the condition.

Quoted 12 lines

sound/soc/intel/boards/cht_bsw_max98090_ti.c static int cht_aif1_hw_params(struct snd_pcm_substream *substream,

Quoted 10 lines
sound/soc/intel/boards/cht_bsw_max98090_ti.c +9 -0
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm,

"SHDN");

Quoted 6 lines

This is wrong, you're mixing locked and unlocked versions of the DAPM operations which can't be right - the difference between locked and unlocked versions of the operations is that the locked versions is if the locks for DAPM are already held and clearly there's no locking code here. This last operation shuld be a normal _disable_pin().

Thanks Mark. I will use snd_soc_dapm_disable_pin

Quoted 5 lines

I'd also expect it to be before the sync - there's no telling how long it'll be till the next sync otherwise and no reason to leave the pin forced on if it's not needed. If it is in use due to some other thing then DAPM should ensure that the state doesn't get changed by the disable.

I was thinking widget will be disabled right after calling snd_soc_dapm_sync I just tried to move SHDN before calling snd_soc_dapm_sync .as you said if it is in use dapm will not turn it off immediately for example if playback is
ongoing.It will be turned off few seconds after playback stops.

Quoted 1 line

Indentation is broken for the comment too.

I will remove the comments since I will move the disable SHDN pin code before calling snd_soc_dapm_sync

#18 lore raw

PATCH v4 1/1 ASoC: Intel: fixed TI button detection

In reply to [email protected]

From: "Fang, Yang A" <[email protected]>

In order to make TI button interrupt working max98090 codec Need provide mic bias all the time as long as mic is present so SHDN and micbias pin are forced on.we also need set max98090 codec bias close or lower than TI bias.We set them in bios/coreboot kernel reads them from device property

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   30 ++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +30 -0
index 1be0794..d604ee8 100644
@@ -101,6 +101,33 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_disable_pin(&codec->dapm, "SHDN");
+		snd_soc_dapm_sync(&codec->dapm);
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +157,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
maintainer Applied
#19 lore raw

Re: [PATCH v4] ASoC: Intel: fixed TI button detection

Quoted 7 lines · On Wed, Jun 03, 2015 at 03:07:41PM -0700, [email protected] wrote:

From: "Fang, Yang A" <[email protected]>

In order to make TI button interrupt working max98090 codec Need provide mic bias all the time as long as mic is present so SHDN and micbias pin are forced on.we also need set max98090 codec bias close or lower than TI bias.We set them in bios/coreboot kernel reads them from device property

Applied, thanks.