aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShengjiu Wang <b02247@freescale.com>2014-04-03 04:05:40 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:58:16 -0400
commit6a715373c43f16e48883061049e67919281878d1 (patch)
tree6adb52e1327543eb6e99feba74feb147059048d1
parent4bde963732964c65b2e03deac1657f9963eb2da6 (diff)
ENGR00306857 pulseaudio5.0 mute Headphone volume when Headphone plugged
Pulseaudio will detect the Headphone Jack, then swith to Headphone. So register new Jack for Headphone, the iface=CARD. Signed-off-by: Shengjiu Wang <b02247@freescale.com>
-rw-r--r--sound/soc/fsl/Kconfig1
-rw-r--r--sound/soc/fsl/imx-wm8962.c19
2 files changed, 17 insertions, 3 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 81adf8addba3..b858dbed5f14 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -209,6 +209,7 @@ config SND_SOC_IMX_WM8962
209 select SND_SOC_IMX_AUDMUX 209 select SND_SOC_IMX_AUDMUX
210 select SND_SOC_FSL_SSI 210 select SND_SOC_FSL_SSI
211 select SND_SOC_FSL_UTILS 211 select SND_SOC_FSL_UTILS
212 select SND_KCTL_JACK
212 help 213 help
213 Say Y if you want to add support for SoC audio on an i.MX board with 214 Say Y if you want to add support for SoC audio on an i.MX board with
214 a wm8962 codec. 215 a wm8962 codec.
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c
index aeaad67fe90f..2776a08370c0 100644
--- a/sound/soc/fsl/imx-wm8962.c
+++ b/sound/soc/fsl/imx-wm8962.c
@@ -22,6 +22,7 @@
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <sound/soc.h> 23#include <sound/soc.h>
24#include <sound/jack.h> 24#include <sound/jack.h>
25#include <sound/control.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
26#include <sound/soc-dapm.h> 27#include <sound/soc-dapm.h>
27#include <linux/pinctrl/consumer.h> 28#include <linux/pinctrl/consumer.h>
@@ -50,6 +51,8 @@ struct imx_priv {
50 struct platform_device *pdev; 51 struct platform_device *pdev;
51 struct snd_pcm_substream *first_stream; 52 struct snd_pcm_substream *first_stream;
52 struct snd_pcm_substream *second_stream; 53 struct snd_pcm_substream *second_stream;
54 struct snd_kcontrol *headphone_kctl;
55 struct snd_card *snd_card;
53}; 56};
54static struct imx_priv card_priv; 57static struct imx_priv card_priv;
55 58
@@ -103,10 +106,12 @@ static int hpjack_status_check(void)
103 snprintf(buf, 32, "STATE=%d", 2); 106 snprintf(buf, 32, "STATE=%d", 2);
104 snd_soc_dapm_disable_pin(&priv->codec->dapm, "Ext Spk"); 107 snd_soc_dapm_disable_pin(&priv->codec->dapm, "Ext Spk");
105 ret = imx_hp_jack_gpio.report; 108 ret = imx_hp_jack_gpio.report;
109 snd_kctl_jack_report(priv->snd_card, priv->headphone_kctl, 1);
106 } else { 110 } else {
107 snprintf(buf, 32, "STATE=%d", 0); 111 snprintf(buf, 32, "STATE=%d", 0);
108 snd_soc_dapm_enable_pin(&priv->codec->dapm, "Ext Spk"); 112 snd_soc_dapm_enable_pin(&priv->codec->dapm, "Ext Spk");
109 ret = 0; 113 ret = 0;
114 snd_kctl_jack_report(priv->snd_card, priv->headphone_kctl, 0);
110 } 115 }
111 116
112 envp[0] = "NAME=headphone"; 117 envp[0] = "NAME=headphone";
@@ -278,9 +283,10 @@ static struct snd_soc_ops imx_hifi_ops = {
278 .hw_free = imx_hifi_hw_free, 283 .hw_free = imx_hifi_hw_free,
279}; 284};
280 285
281static int imx_wm8962_gpio_init(struct snd_soc_pcm_runtime *rtd) 286static int imx_wm8962_gpio_init(struct snd_soc_card *card)
282{ 287{
283 struct snd_soc_codec *codec = rtd->codec; 288 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
289 struct snd_soc_codec *codec = codec_dai->codec;
284 struct imx_priv *priv = &card_priv; 290 struct imx_priv *priv = &card_priv;
285 291
286 priv->codec = codec; 292 priv->codec = codec;
@@ -481,7 +487,6 @@ static int imx_wm8962_probe(struct platform_device *pdev)
481 data->dai.cpu_dai_name = dev_name(&ssi_pdev->dev); 487 data->dai.cpu_dai_name = dev_name(&ssi_pdev->dev);
482 data->dai.platform_of_node = ssi_np; 488 data->dai.platform_of_node = ssi_np;
483 data->dai.ops = &imx_hifi_ops; 489 data->dai.ops = &imx_hifi_ops;
484 data->dai.init = &imx_wm8962_gpio_init;
485 data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 490 data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
486 SND_SOC_DAIFMT_CBM_CFM; 491 SND_SOC_DAIFMT_CBM_CFM;
487 492
@@ -508,6 +513,14 @@ static int imx_wm8962_probe(struct platform_device *pdev)
508 goto fail; 513 goto fail;
509 } 514 }
510 515
516 priv->snd_card = data->card.snd_card;
517 priv->headphone_kctl = snd_kctl_jack_new("Headphone", 0, NULL);
518 ret = snd_ctl_add(data->card.snd_card, priv->headphone_kctl);
519 if (ret)
520 goto fail;
521
522 imx_wm8962_gpio_init(&data->card);
523
511 if (gpio_is_valid(priv->hp_gpio)) { 524 if (gpio_is_valid(priv->hp_gpio)) {
512 ret = driver_create_file(pdev->dev.driver, &driver_attr_headphone); 525 ret = driver_create_file(pdev->dev.driver, &driver_attr_headphone);
513 if (ret) { 526 if (ret) {