diff options
author | Pradeep Kumar <pgoudagunta@nvidia.com> | 2012-08-06 23:01:18 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2012-08-07 15:23:08 -0700 |
commit | b8b641f5e81434ebb721b3998218645b5190bc25 (patch) | |
tree | d82cd59ef84d3ddde0478abb38b2f329db87b4da /sound/usb/card.c | |
parent | e3c885a945febae6e9b2bc1c82863494d5db9a79 (diff) |
Merge commit 'main-jb-2012.08.03-B4' into t114-0806
Conflicts:
arch/arm/boot/compressed/Makefile
arch/arm/boot/compressed/atags_to_fdt.c
arch/arm/boot/compressed/head.S
arch/arm/boot/dts/tegra30.dtsi
arch/arm/include/asm/bug.h
arch/arm/kernel/traps.c
arch/arm/mach-tegra/Makefile.boot
arch/arm/mach-tegra/board-cardhu-sdhci.c
arch/arm/mach-tegra/board-cardhu.c
arch/arm/mach-tegra/board-enterprise-sdhci.c
arch/arm/mach-tegra/board-enterprise.c
arch/arm/mach-tegra/board-harmony.c
arch/arm/mach-tegra/board-kai-sdhci.c
arch/arm/mach-tegra/board-ventana.c
arch/arm/mach-tegra/board-whistler.c
arch/arm/mach-tegra/clock.h
arch/arm/mach-tegra/fuse.h
arch/arm/mach-tegra/tegra2_usb_phy.c
arch/arm/mach-tegra/tegra3_clocks.c
arch/arm/mach-tegra/tegra3_dvfs.c
arch/arm/mach-tegra/tegra3_speedo.c
arch/arm/mach-tegra/timer.c
arch/arm/mach-tegra/usb_phy.c
arch/arm/mach-tegra/wakeups-t3.c
drivers/cpufreq/cpufreq_interactive.c
drivers/input/touchscreen/atmel_mxt_ts.c
drivers/mfd/tps65090.c
drivers/mmc/core/mmc.c
drivers/mmc/host/sdhci-tegra.c
drivers/mmc/host/sdhci.c
drivers/net/wireless/bcmdhd/bcmsdh_sdmmc_linux.c
drivers/regulator/Kconfig
drivers/regulator/core.c
drivers/regulator/tps80031-regulator.c
drivers/spi/Makefile
drivers/staging/nvec/nvec.c
drivers/tty/serial/Makefile
include/linux/mmc/card.h
sound/soc/tegra/tegra_max98095.c
sound/usb/card.c
Change-Id: I65043bc6ce9e97d0592683462215a39e50f403fd
Reviewed-on: http://git-master/r/121392
Reviewed-by: Bo Yan <byan@nvidia.com>
Tested-by: Bo Yan <byan@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'sound/usb/card.c')
-rw-r--r-- | sound/usb/card.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c index 4a7be7b98331..223e4fe8e284 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -35,7 +35,6 @@ * indeed an AC3 stream packed in SPDIF frames (i.e. no real AC3 stream). */ - #include <linux/bitops.h> #include <linux/init.h> #include <linux/list.h> @@ -48,6 +47,9 @@ #include <linux/usb/audio.h> #include <linux/usb/audio-v2.h> #include <linux/module.h> +#ifdef CONFIG_SWITCH +#include <linux/switch.h> +#endif #include <sound/control.h> #include <sound/core.h> @@ -116,6 +118,18 @@ static DEFINE_MUTEX(register_mutex); static struct snd_usb_audio *usb_chip[SNDRV_CARDS]; static struct usb_driver usb_audio_driver; +#ifdef CONFIG_SWITCH +enum switch_state { + STATE_CONNECTED_UNKNOWN = -1, + STATE_DISCONNECTED = 0, + STATE_CONNECTED = 1 +}; + +static struct switch_dev usb_switch_dev = { + .name = "usb_audio", +}; +#endif + /* * disconnect streams * called from snd_usb_audio_disconnect() @@ -524,10 +538,15 @@ snd_usb_audio_probe(struct usb_device *dev, goto __error; } +#ifdef CONFIG_SWITCH + switch_set_state(&usb_switch_dev, STATE_CONNECTED); +#endif + usb_chip[chip->index] = chip; chip->num_interfaces++; chip->probing = 0; mutex_unlock(®ister_mutex); + return chip; __error: @@ -538,6 +557,7 @@ snd_usb_audio_probe(struct usb_device *dev, } mutex_unlock(®ister_mutex); __err_val: + return NULL; } @@ -559,6 +579,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, mutex_lock(&chip->shutdown_mutex); chip->shutdown = 1; chip->num_interfaces--; + +#ifdef CONFIG_SWITCH + switch_set_state(&usb_switch_dev, STATE_DISCONNECTED); +#endif + if (chip->num_interfaces <= 0) { snd_card_disconnect(card); /* release the pcm resources */ @@ -713,15 +738,37 @@ static struct usb_driver usb_audio_driver = { static int __init snd_usb_audio_init(void) { + int err = 0; + if (nrpacks < 1 || nrpacks > MAX_PACKS) { printk(KERN_WARNING "invalid nrpacks value.\n"); return -EINVAL; } - return usb_register(&usb_audio_driver); + +#ifdef CONFIG_SWITCH + /* Add usb_audio swith class support */ + err = switch_dev_register(&usb_switch_dev); + if (err < 0){ + printk(KERN_ERR "failed to register switch device"); + return -EINVAL; + } +#endif + + err = usb_register(&usb_audio_driver); + if (err) { +#ifdef CONFIG_SWITCH + switch_dev_unregister(&usb_switch_dev); +#endif + } + + return err; } static void __exit snd_usb_audio_cleanup(void) { +#ifdef CONFIG_SWITCH + switch_dev_unregister(&usb_switch_dev); +#endif usb_deregister(&usb_audio_driver); } |