diff options
author | fang hui <hui.fang@freescale.com> | 2016-06-20 16:26:01 +0800 |
---|---|---|
committer | fang hui <hui.fang@freescale.com> | 2016-07-21 14:39:16 +0800 |
commit | a9095629d2d96e0ecfb725a55d4cd5d0bd876a38 (patch) | |
tree | f6b3a53ba3ebe92ad3dbc42c0709afa1b90ac550 | |
parent | a8d135faed24b98123e8cb92f9e28d30683000d8 (diff) | |
download | picoimx-3.14-master.tar.gz |
Register switch device and jack input device.
Brillo audio service will use them.
Change-Id: I95a6459e720668d99a2b28be008eca2bc6e829db
Signed-off-by: fang hui <hui.fang@freescale.com>
-rw-r--r-- | sound/soc/fsl/imx-wm8960.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sound/soc/fsl/imx-wm8960.c b/sound/soc/fsl/imx-wm8960.c index 0406d6716b6..c9b6e53d618 100644 --- a/sound/soc/fsl/imx-wm8960.c +++ b/sound/soc/fsl/imx-wm8960.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Freescale Semiconductor, Inc. + * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. * * The code contained herein is licensed under the GNU General Public * License. You may obtain a copy of the GNU General Public License @@ -25,6 +25,9 @@ #include <linux/mfd/syscon.h> #include "../codecs/wm8960.h" #include "fsl_sai.h" +#ifdef CONFIG_SWITCH +#include <linux/switch.h> +#endif #define DAI_NAME_SIZE 32 @@ -51,6 +54,9 @@ struct imx_priv { struct platform_device *pdev; struct platform_device *asrc_pdev; struct snd_card *snd_card; +#ifdef CONFIG_SWITCH + struct switch_dev sdev; +#endif }; static struct imx_priv card_priv; @@ -87,6 +93,9 @@ static int hp_set_status_check(void) } if (hp_status != priv->hp_active_low) { +#ifdef CONFIG_SWITCH + switch_set_state(&priv->sdev, 2); +#endif snprintf(buf, 32, "STATE=%d", 2); snd_soc_dapm_disable_pin(&priv->codec->dapm, "Ext Spk"); snd_soc_dapm_disable_pin(&priv->codec->dapm, "Main MIC"); @@ -100,6 +109,9 @@ static int hp_set_status_check(void) snd_kctl_jack_report(priv->snd_card, priv->headset_kctl, 1); } else { +#ifdef CONFIG_SWITCH + switch_set_state(&priv->sdev, 0); +#endif snprintf(buf, 32, "STATE=%d", 0); snd_soc_dapm_enable_pin(&priv->codec->dapm, "Ext Spk"); snd_soc_dapm_enable_pin(&priv->codec->dapm, "Main MIC"); @@ -631,6 +643,15 @@ static int imx_wm8960_probe(struct platform_device *pdev) data->card.late_probe = imx_wm8960_late_probe; +#ifdef CONFIG_SWITCH + priv->sdev.name = "h2w"; + ret = switch_dev_register(&priv->sdev); + if (ret < 0) { + dev_err(&pdev->dev, "switch_dev_register failed (%d)\n", ret); + goto fail; + } +#endif + platform_set_drvdata(pdev, &data->card); snd_soc_card_set_drvdata(&data->card, data); ret = devm_snd_soc_register_card(&pdev->dev, &data->card); @@ -665,6 +686,12 @@ static int imx_wm8960_probe(struct platform_device *pdev) goto fail; } } + + ret = snd_device_register(data->card.snd_card, imx_hp_set.jack); + if (ret) { + dev_err(&pdev->dev, "snd_device_register (%d)\n", ret); + goto fail; + } fail: if (cpu_np) of_node_put(cpu_np); |