aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorChris Kelly <c-kelly@ti.com>2011-10-06 14:14:51 -0500
committerDan Murphy <dmurphy@ti.com>2011-10-09 09:06:15 -0500
commitcfc0c52770c4d3a69cdd75b3e16289255d97cb19 (patch)
tree16e3223f981a377cdd2afe6286d0dbffab908d2a /sound/usb
parent3d2ebc5521e4a2cf0dcb831befff2f0072045827 (diff)
downloadkernel_samsung_espresso10-cfc0c52770c4d3a69cdd75b3e16289255d97cb19.zip
kernel_samsung_espresso10-cfc0c52770c4d3a69cdd75b3e16289255d97cb19.tar.gz
kernel_samsung_espresso10-cfc0c52770c4d3a69cdd75b3e16289255d97cb19.tar.bz2
OMAP4: USB Audio: Add switch based device reporting
A switch class instance is registered to report the state of the USB Audio device as connected or disconnected. Change-Id: I6a637acc87063059032adea6c23723f545d015ff Signed-off-by: Chris Kelly <c-kelly@ti.com> Signed-off-by: Igor Nedashkivskyi <igor.nedashkivskyi@globallogic.com>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/card.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 220c616..0b713bf 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -47,6 +47,7 @@
#include <linux/mutex.h>
#include <linux/usb/audio.h>
#include <linux/usb/audio-v2.h>
+#include <linux/switch.h>
#include <sound/control.h>
#include <sound/core.h>
@@ -116,6 +117,18 @@ static struct snd_usb_audio *usb_chip[SNDRV_CARDS];
static struct usb_driver usb_audio_driver;
/*
+ * use a switch to report to userspace what type of device
+ * is most recently connected.
+ */
+enum switch_state {
+ STATE_CONNECTED_UNKNOWN = -1,
+ STATE_DISCONNECTED = 0,
+ STATE_CONNECTED = 1
+};
+
+static struct switch_dev sdev;
+
+/*
* disconnect streams
* called from snd_usb_audio_disconnect()
*/
@@ -522,6 +535,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
goto __error;
}
+ /*
+ * not sure how to distinguish analog/digital/unknown,
+ * assume digital for now
+ */
+ switch_set_state(&sdev, STATE_CONNECTED);
+
usb_chip[chip->index] = chip;
chip->num_interfaces++;
chip->probing = 0;
@@ -555,6 +574,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)
mutex_lock(&chip->shutdown_mutex);
chip->shutdown = 1;
chip->num_interfaces--;
+ switch_set_state(&sdev, STATE_DISCONNECTED);
if (chip->num_interfaces <= 0) {
snd_card_disconnect(card);
/* release the pcm resources */
@@ -709,15 +729,27 @@ 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);
+ err = usb_register(&usb_audio_driver);
+ if (!err) {
+ sdev.name = "usb_audio";
+ if (switch_dev_register(&sdev)) {
+ snd_printk(KERN_ERR "error registering switch device");
+ usb_deregister(&usb_audio_driver);
+ return -EINVAL;
+ }
+ }
+ return err;
}
static void __exit snd_usb_audio_cleanup(void)
{
+ switch_dev_unregister(&sdev);
usb_deregister(&usb_audio_driver);
}