diff options
author | Shengjiu Wang <b02247@freescale.com> | 2014-02-12 10:40:08 +0800 |
---|---|---|
committer | Ke Qinghua <qinghua.ke@freescale.com> | 2014-04-22 15:29:40 +0800 |
commit | f058ed6dfe1ab573c1106ee043bc42645653b3eb (patch) | |
tree | c1664bfcc643a525a4b0d4285101a2bb3b516e28 /sound | |
parent | 6399edbbb21b9e784a0f83aa0d039e6e85c6b3ec (diff) |
ENGR00298750 Register switch device for headphone plugin/plugout
Register switch device for headphone plugin/plugout in wm8962
Signed-off-by: Shengjiu Wang <b02247@freescale.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/fsl/imx-wm8962.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c index d806d7aa5e8d..49689a841c11 100644 --- a/sound/soc/fsl/imx-wm8962.c +++ b/sound/soc/fsl/imx-wm8962.c @@ -20,6 +20,7 @@ #include <linux/slab.h> #include <linux/gpio.h> #include <linux/clk.h> +#include <linux/switch.h> #include <sound/soc.h> #include <sound/jack.h> #include <sound/control.h> @@ -53,6 +54,7 @@ struct imx_priv { struct snd_pcm_substream *second_stream; struct snd_kcontrol *headphone_kctl; struct snd_card *snd_card; + struct switch_dev sdev; }; static struct imx_priv card_priv; @@ -104,11 +106,13 @@ static int hpjack_status_check(void) if (hp_status != priv->hp_active_low) { snprintf(buf, 32, "STATE=%d", 2); + switch_set_state(&priv->sdev, 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); + switch_set_state(&priv->sdev, 0); snd_soc_dapm_enable_pin(&priv->codec->dapm, "Ext Spk"); ret = 0; snd_kctl_jack_report(priv->snd_card, priv->headphone_kctl, 0); @@ -517,6 +521,13 @@ audmux_bypass: platform_set_drvdata(pdev, &data->card); snd_soc_card_set_drvdata(&data->card, data); + priv->sdev.name = "h2w"; + ret = switch_dev_register(&priv->sdev); + if (ret < 0) { + ret = -EINVAL; + goto fail; + } + ret = snd_soc_register_card(&data->card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); @@ -565,11 +576,13 @@ fail: static int imx_wm8962_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); + struct imx_priv *priv = &card_priv; driver_remove_file(pdev->dev.driver, &driver_attr_microphone); driver_remove_file(pdev->dev.driver, &driver_attr_headphone); snd_soc_unregister_card(card); + switch_dev_unregister(&priv->sdev); return 0; } |