diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index a1e135dc7b892998a5570f187b41e6c47d8dc1b1..353c1b85c4a6a0ded656fe1a45418e864a85df33 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -278,6 +278,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 a721c3b3d18a843a2557a646da19e6cd83c2f4d9..98b239e3070efdfb10c7f1d9ed31ab58145de407 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) {