diff options
author | Shengjiu Wang <b02247@freescale.com> | 2014-04-03 16:05:40 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-16 08:58:16 -0500 |
commit | 6a715373c43f16e48883061049e67919281878d1 (patch) | |
tree | 6adb52e1327543eb6e99feba74feb147059048d1 /sound | |
parent | 4bde963732964c65b2e03deac1657f9963eb2da6 (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>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/fsl/Kconfig | 1 | ||||
-rw-r--r-- | sound/soc/fsl/imx-wm8962.c | 19 |
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 select SND_SOC_IMX_AUDMUX select SND_SOC_FSL_SSI select SND_SOC_FSL_UTILS + select SND_KCTL_JACK help Say Y if you want to add support for SoC audio on an i.MX board with 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 @@ #include <linux/clk.h> #include <sound/soc.h> #include <sound/jack.h> +#include <sound/control.h> #include <sound/pcm_params.h> #include <sound/soc-dapm.h> #include <linux/pinctrl/consumer.h> @@ -50,6 +51,8 @@ struct imx_priv { struct platform_device *pdev; struct snd_pcm_substream *first_stream; struct snd_pcm_substream *second_stream; + struct snd_kcontrol *headphone_kctl; + struct snd_card *snd_card; }; static struct imx_priv card_priv; @@ -103,10 +106,12 @@ static int hpjack_status_check(void) snprintf(buf, 32, "STATE=%d", 2); snd_soc_dapm_disable_pin(&priv->codec->dapm, "Ext Spk"); ret = imx_hp_jack_gpio.report; + snd_kctl_jack_report(priv->snd_card, priv->headphone_kctl, 1); } else { snprintf(buf, 32, "STATE=%d", 0); snd_soc_dapm_enable_pin(&priv->codec->dapm, "Ext Spk"); ret = 0; + snd_kctl_jack_report(priv->snd_card, priv->headphone_kctl, 0); } envp[0] = "NAME=headphone"; @@ -278,9 +283,10 @@ static struct snd_soc_ops imx_hifi_ops = { .hw_free = imx_hifi_hw_free, }; -static int imx_wm8962_gpio_init(struct snd_soc_pcm_runtime *rtd) +static int imx_wm8962_gpio_init(struct snd_soc_card *card) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; + struct snd_soc_codec *codec = codec_dai->codec; struct imx_priv *priv = &card_priv; priv->codec = codec; @@ -481,7 +487,6 @@ static int imx_wm8962_probe(struct platform_device *pdev) data->dai.cpu_dai_name = dev_name(&ssi_pdev->dev); data->dai.platform_of_node = ssi_np; data->dai.ops = &imx_hifi_ops; - data->dai.init = &imx_wm8962_gpio_init; data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM; @@ -508,6 +513,14 @@ static int imx_wm8962_probe(struct platform_device *pdev) goto fail; } + priv->snd_card = data->card.snd_card; + priv->headphone_kctl = snd_kctl_jack_new("Headphone", 0, NULL); + ret = snd_ctl_add(data->card.snd_card, priv->headphone_kctl); + if (ret) + goto fail; + + imx_wm8962_gpio_init(&data->card); + if (gpio_is_valid(priv->hp_gpio)) { ret = driver_create_file(pdev->dev.driver, &driver_attr_headphone); if (ret) { |