[alsa-devel] [PATCH 1/3] ASoC: max98090: read micbias from device property
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/codecs/max98090.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c230626..27df17e 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -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);
From: "Fang, Yang A" yang.a.fang@intel.com
replace of_property_read_u32 with device_property_read_u32
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/codecs/ts3a227e.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 9fd80ac..dfb49b3 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -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,
On Tue, May 26, 2015 at 04:58:05PM -0700, yang.a.fang@intel.com wrote:
-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.
From: "Fang, Yang A" yang.a.fang@intel.com
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
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c index 1be0794..8ef947f 100644 --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -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; }
On Tue, May 26, 2015 at 4:58 PM, yang.a.fang@intel.com wrote:
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
Signed-off-by: Fang, Yang A yang.a.fang@intel.com
sound/soc/codecs/max98090.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c230626..27df17e 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -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);
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.
Extra newline.
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
On Tue, May 26, 2015 at 09:39:54PM -0700, Dylan Reid wrote:
On Tue, May 26, 2015 at 4:58 PM, yang.a.fang@intel.com wrote:
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
Signed-off-by: Fang, Yang A yang.a.fang@intel.com
sound/soc/codecs/max98090.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c230626..27df17e 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -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);
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
Extra newline.
will fix in v2
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
On Tue, May 26, 2015 at 04:58:04PM -0700, yang.a.fang@intel.com wrote:
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
This is adding a new DT binding, the DT binding needs to be documented.
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- .../devicetree/bindings/sound/max98090.txt | 2 ++ sound/soc/codecs/max98090.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt index aa802a2..eecb710 100644 --- a/Documentation/devicetree/bindings/sound/max98090.txt +++ b/Documentation/devicetree/bindings/sound/max98090.txt @@ -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 diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c230626..4b61db7 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -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);
From: "Fang, Yang A" yang.a.fang@intel.com
replace of_property_read_u32 with device_property_read_u32
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/codecs/ts3a227e.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 9fd80ac..12232d7 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -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,
From: "Fang, Yang A" yang.a.fang@intel.com
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
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c index 1be0794..3e5842d 100644 --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -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; }
On Thu, May 28, 2015 at 11:00:46AM -0700, yang.a.fang@intel.com 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?
- 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.
-----Original Message----- From: Mark Brown [mailto:broonie@kernel.org] Sent: Friday, May 29, 2015 2:59 AM To: Fang, Yang A Cc: lgirdwood@gmail.com; alsa-devel@alsa-project.org; dgreid@chromium.org; Nujella, Sathyanarayana; kevin.strasser@linux.intel.com; Sripathi, Srinivas; Iriawan, Denny; Jain, Praveen K; Koul, Vinod Subject: Re: [PATCH v2 1/3] ASoC: max98090: read micbias from device property
On Thu, May 28, 2015 at 11:00:46AM -0700, yang.a.fang@intel.com 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
- 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.
Okay, will put log if out of range .
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- .../devicetree/bindings/sound/max98090.txt | 6 ++++++ sound/soc/codecs/max98090.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt index aa802a2..4e3be66 100644 --- a/Documentation/devicetree/bindings/sound/max98090.txt +++ b/Documentation/devicetree/bindings/sound/max98090.txt @@ -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 diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c230626..679f0a0 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -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);
From: "Fang, Yang A" yang.a.fang@intel.com
replace of_property_read_u32 with device_property_read_u32
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/codecs/ts3a227e.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 9fd80ac..12232d7 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -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,
On Fri, May 29, 2015 at 11:56:11AM -0700, yang.a.fang@intel.com wrote:
From: "Fang, Yang A" yang.a.fang@intel.com
replace of_property_read_u32 with device_property_read_u32
Applied, thanks.
From: "Fang, Yang A" yang.a.fang@intel.com
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
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c index 1be0794..3e5842d 100644 --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -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; }
On Fri, May 29, 2015 at 11:56:12AM -0700, yang.a.fang@intel.com wrote:
- 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.
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.
-----Original Message----- From: Mark Brown [mailto:broonie@kernel.org] Sent: Wednesday, June 03, 2015 11:16 AM To: Fang, Yang A Cc: lgirdwood@gmail.com; alsa-devel@alsa-project.org; dgreid@chromium.org; Nujella, Sathyanarayana; kevin.strasser@linux.intel.com; Sripathi, Srinivas; Iriawan, Denny; Jain, Praveen K; Koul, Vinod Subject: Re: [PATCH v3 3/3] ASoC: Intel: fixed TI button detection
On Fri, May 29, 2015 at 11:56:12AM -0700, yang.a.fang@intel.com wrote:
- 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.
Got it. I will remove the condition.
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().
Thanks Mark. I will use snd_soc_dapm_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.
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.
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
From: "Fang, Yang A" yang.a.fang@intel.com
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
Signed-off-by: Fang, Yang A yang.a.fang@intel.com --- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c index 1be0794..d604ee8 100644 --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -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; }
On Wed, Jun 03, 2015 at 03:07:41PM -0700, yang.a.fang@intel.com wrote:
From: "Fang, Yang A" yang.a.fang@intel.com
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.
On Fri, May 29, 2015 at 11:56:10AM -0700, yang.a.fang@intel.com wrote:
From: "Fang, Yang A" yang.a.fang@intel.com
This patch reads max98090 micbias from acpi or dt
Applied, thanks.
participants (5)
-
Dylan Reid
-
Fang, Yang A
-
Mark Brown
-
Yang Fang
-
yang.a.fang@intel.com