summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorShengjiu Wang <b02247@freescale.com>2014-04-03 16:05:40 +0800
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:49:57 +0800
commit2237688f52e10f4939354bc74850a543036a1c05 (patch)
tree834b5a28e0f8cc3bae3e9cd7f35b168cb666cca0 /sound
parentbe98d73d36d00b6edc14ec94375053aa6a7d523f (diff)
MLK-11479-09 pulseaudio5.0 mute Headphone volume when Headphone plugged
cherry-pick below patch from v3.14.y: 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> (cherry picked from commit 6a715373c43f16e48883061049e67919281878d1)
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/fsl/Kconfig1
-rw-r--r--sound/soc/fsl/imx-wm8962.c22
2 files changed, 19 insertions, 4 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index afcc6d7d46cf..1d96da1e1e50 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -296,6 +296,7 @@ config SND_SOC_IMX_WM8962
select SND_SOC_IMX_PCM_DMA
select SND_SOC_IMX_AUDMUX
select SND_SOC_FSL_SSI
+ 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 a721c3b3d18a..98b239e3070e 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 *data)
snprintf(buf, 32, "STATE=%d", 2);
snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(priv->codec), "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(snd_soc_codec_get_dapm(priv->codec), "Ext Spk");
ret = 0;
+ snd_kctl_jack_report(priv->snd_card, priv->headphone_kctl, 0);
}
envp[0] = "NAME=headphone";
@@ -278,10 +283,12 @@ 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_card *card = rtd->card;
- struct snd_soc_codec *codec = rtd->codec;
+ struct snd_soc_pcm_runtime *rtd = list_first_entry(
+ &card->rtd_list, struct snd_soc_pcm_runtime, list);
+ struct snd_soc_dai *codec_dai = rtd->codec_dai;
+ struct snd_soc_codec *codec = codec_dai->codec;
struct imx_priv *priv = &card_priv;
priv->codec = codec;
@@ -488,7 +495,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;
@@ -516,6 +522,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", 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) {