AUDIO: add support for external USB attached DAC devices

file:57a8e2d0139f252cee9797d9e788691609e56f73 -> file:21efe8eaf9416d3b17e979abc5d58f111d65988f
--- 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>
@@ -85,6 +86,7 @@ static int nrpacks = 8; /* max. number
static int async_unlink = 1;
static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
static int ignore_ctl_error;
+struct switch_dev *usbaudiosdev;
module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
@@ -418,6 +420,7 @@ static int snd_usb_audio_create(struct u
}
snd_usb_audio_create_proc(chip);
+ switch_set_state(usbaudiosdev, 1);
*rchip = chip;
return 0;
@@ -580,6 +583,7 @@ static void snd_usb_audio_disconnect(str
mutex_unlock(&chip->shutdown_mutex);
mutex_unlock(&register_mutex);
}
+ switch_set_state(usbaudiosdev, 0);
}
/*
@@ -712,16 +716,26 @@ static struct usb_driver usb_audio_drive
static int __init snd_usb_audio_init(void)
{
+ int err;
if (nrpacks < 1 || nrpacks > MAX_PACKS) {
printk(KERN_WARNING "invalid nrpacks value.\n");
return -EINVAL;
}
+
+ usbaudiosdev = kzalloc(sizeof(usbaudiosdev), GFP_KERNEL);
+ usbaudiosdev->name = "usb_audio";
+ err = switch_dev_register(usbaudiosdev);
+ if (err)
+ pr_err("Usb-audio switch registration failed\n");
+ else
+ pr_debug("usb hs_detected\n");
return usb_register(&usb_audio_driver);
}
static void __exit snd_usb_audio_cleanup(void)
{
usb_deregister(&usb_audio_driver);
+ kfree(usbaudiosdev);
}
module_init(snd_usb_audio_init);