diff options
author | b02247 <b02247@freescale.com> | 2012-09-25 13:23:26 +0800 |
---|---|---|
committer | b02247 <b02247@freescale.com> | 2012-09-25 15:23:07 +0800 |
commit | ae567a2dc7ca039c219a555f2f6da871cf292614 (patch) | |
tree | 30b1f710397b26ac1775586ca43b4bd4f00b4c0b /sound | |
parent | 4c3a9d98eebacb097d0aa92c13d48b98f8a6245f (diff) |
ENGR00225708 Use switch_class as audio plugin/plugout interface in jb
Use the switch_class as the interface, which will set the state and
report the uevent of plugin and plugout for wm8962, hdmi.
Signed-off-by: b02247 <b02247@freescale.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/imx/imx-wm8962.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/sound/soc/imx/imx-wm8962.c b/sound/soc/imx/imx-wm8962.c index b13f68f2647b..87124802095a 100644 --- a/sound/soc/imx/imx-wm8962.c +++ b/sound/soc/imx/imx-wm8962.c @@ -27,6 +27,8 @@ #include <linux/fsl_devices.h> #include <linux/slab.h> #include <linux/clk.h> +#include <linux/switch.h> + #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -52,6 +54,7 @@ struct imx_priv { int amic_irq; int amic_status; struct platform_device *pdev; + struct switch_dev sdev; }; unsigned int sample_format = SNDRV_PCM_FMTBIT_S16_LE; static struct imx_priv card_priv; @@ -191,11 +194,13 @@ static void headphone_detect_handler(struct work_struct *wor) return; } - if (priv->hp_status != plat->hp_active_low) + if (priv->hp_status != plat->hp_active_low) { + switch_set_state(&priv->sdev, 2); snprintf(buf, 32, "STATE=%d", 2); - else + } else { + switch_set_state(&priv->sdev, 0); snprintf(buf, 32, "STATE=%d", 0); - + } envp[0] = "NAME=headphone"; envp[1] = buf; envp[2] = NULL; @@ -222,6 +227,9 @@ static ssize_t show_headphone(struct device_driver *dev, char *buf) struct platform_device *pdev = priv->pdev; struct mxc_audio_platform_data *plat = pdev->dev.platform_data; + if (plat->hp_gpio == -1) + return 0; + /* determine whether hp is plugged in */ priv->hp_status = gpio_get_value(plat->hp_gpio); @@ -289,7 +297,7 @@ static ssize_t show_amic(struct device_driver *dev, char *buf) struct mxc_audio_platform_data *plat = pdev->dev.platform_data; /* determine whether amic is plugged in */ - priv->amic_status = gpio_get_value(plat->hp_gpio); + priv->amic_status = gpio_get_value(plat->mic_gpio); if (priv->amic_status != plat->mic_active_low) strcpy(buf, "amic\n"); @@ -441,18 +449,34 @@ static int __devinit imx_wm8962_probe(struct platform_device *pdev) priv->sysclk = plat->sysclk; + priv->sdev.name = "h2w"; + ret = switch_dev_register(&priv->sdev); + if (ret < 0) { + ret = -EINVAL; + return ret; + } + + if (plat->hp_gpio != -1) { + priv->hp_status = gpio_get_value(plat->hp_gpio); + if (priv->hp_status != plat->hp_active_low) + switch_set_state(&priv->sdev, 2); + else + switch_set_state(&priv->sdev, 0); + } return ret; } static int __devexit imx_wm8962_remove(struct platform_device *pdev) { struct mxc_audio_platform_data *plat = pdev->dev.platform_data; + struct imx_priv *priv = &card_priv; plat->clock_enable(0); if (plat->finit) plat->finit(); + switch_dev_unregister(&priv->sdev); return 0; } |