^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * usbusy2y.c - ALSA USB US-428 Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) 2005-04-14 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Version 0.8.7.2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Call snd_card_free() instead of snd_card_free_in_thread() to prevent oops with dead keyboard symptom.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) Tested ok with kernel 2.6.12-rc2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 2004-12-14 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Version 0.8.7.1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) snd_pcm_open for rawusb pcm-devices now returns -EBUSY if called without rawusb's hwdep device being open.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 2004-12-02 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Version 0.8.7:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Use macro usb_maxpacket() for portability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 2004-10-26 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) Version 0.8.6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) wake_up() process waiting in usx2y_urbs_start() on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 2004-10-21 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) Version 0.8.5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) nrpacks is runtime or compiletime configurable now with tested values from 1 to 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 2004-10-03 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) Version 0.8.2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Avoid any possible racing while in prepare callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 2004-09-30 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Version 0.8.0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Simplified things and made ohci work again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 2004-09-20 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Version 0.7.3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Use usb_kill_urb() instead of deprecated (kernel 2.6.9) usb_unlink_urb().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 2004-07-13 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) Version 0.7.1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) Don't sleep in START/STOP callbacks anymore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) us428 channels C/D not handled just for this version, sorry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 2004-06-21 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Version 0.6.4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) Temporarely suspend midi input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) to sanely call usb_set_interface() when setting format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 2004-06-12 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) Version 0.6.3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Made it thus the following rule is enforced:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) "All pcm substreams of one usx2y have to operate at the same rate & format."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 2004-04-06 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Version 0.6.0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) Runs on 2.6.5 kernel without any "--with-debug=" things.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) us224 reported running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 2004-01-14 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Version 0.5.1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) Runs with 2.6.1 kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 2003-12-30 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) Version 0.4.1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) Fix 24Bit 4Channel capturing for the us428.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 2003-11-27 Karsten Wiese, Martin Langer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) Version 0.4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) us122 support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) us224 could be tested by uncommenting the sections containing USB_ID_US224
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 2003-11-03 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) Version 0.3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 24Bit support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) "arecord -D hw:1 -c 2 -r 48000 -M -f S24_3LE|aplay -D hw:1 -c 2 -r 48000 -M -f S24_3LE" works.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 2003-08-22 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) Version 0.0.8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) Removed EZUSB Firmware. First Stage Firmwaredownload is now done by tascam-firmware downloader.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) See:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) http://usb-midi-fw.sourceforge.net/tascam-firmware.tar.gz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 2003-06-18 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) Version 0.0.5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) changed to compile with kernel 2.4.21 and alsa 0.9.4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 2002-10-16 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) Version 0.0.4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) compiles again with alsa-current.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) USB_ISO_ASAP not used anymore (most of the time), instead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) urb->start_frame is calculated here now, some calls inside usb-driver don't need to happen anymore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) To get the best out of this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) Disable APM-support in the kernel as APM-BIOS calls (once each second) hard disable interrupt for many precious milliseconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) This helped me much on my slowish PII 400 & PIII 500.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ACPI yet untested but might cause the same bad behaviour.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) Use a kernel with lowlatency and preemptiv patches applied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) To autoload snd-usb-midi append a line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) post-install snd-usb-us428 modprobe snd-usb-midi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) to /etc/modules.conf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) known problems:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) sliders, knobs, lights not yet handled except MASTER Volume slider.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) "pcm -c 2" doesn't work. "pcm -c 2 -m direct_interleaved" does.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) KDE3: "Enable full duplex operation" deadlocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 2002-08-31 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) Version 0.0.3: audio also simplex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) simplifying: iso urbs only 1 packet, melted structs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ASYNC_UNLINK not used anymore: no more crashes so far.....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) for alsa 0.9 rc3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 2002-08-09 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) Version 0.0.2: midi works with snd-usb-midi, audio (only fullduplex now) with i.e. bristol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) The firmware has been sniffed from win2k us-428 driver 3.09.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * Copyright (c) 2002 - 2004 Karsten Wiese
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #include <sound/initval.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #include <sound/rawmidi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #include "usx2y.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #include "usbusx2y.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #include "usX2Yhwdep.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7.2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604),"NAME_ALLCAPS"(0x8001)(0x8005)(0x8007)}}");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) module_param_array(index, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS".");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) module_param_array(id, charp, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) MODULE_PARM_DESC(id, "ID string for "NAME_ALLCAPS".");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) module_param_array(enable, bool, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS".");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static int snd_usx2y_card_used[SNDRV_CARDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static void usx2y_usb_disconnect(struct usb_device* usb_device, void* ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static void snd_usx2y_card_private_free(struct snd_card *card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * pipe 4 is used for switching the lamps, setting samplerate, volumes ....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static void i_usx2y_out04_int(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #ifdef CONFIG_SND_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (urb->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct usx2ydev *usx2y = urb->context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) for (i = 0; i < 10 && usx2y->as04.urb[i] != urb; i++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) snd_printdd("i_usx2y_out04_int() urb %i status=%i\n", i, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static void i_usx2y_in04_int(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct usx2ydev *usx2y = urb->context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct us428ctls_sharedmem *us428ctls = usx2y->us428ctls_sharedmem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) usx2y->in04_int_calls++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (urb->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) snd_printdd("Interrupt Pipe 4 came back with status=%i\n", urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) // printk("%i:0x%02X ", 8, (int)((unsigned char*)usx2y->in04_buf)[8]); Master volume shows 0 here if fader is at max during boot ?!?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (us428ctls) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) int diff = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (-2 == us428ctls->ctl_snapshot_last) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) diff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) memcpy(usx2y->in04_last, usx2y->in04_buf, sizeof(usx2y->in04_last));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) us428ctls->ctl_snapshot_last = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) for (i = 0; i < 21; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (usx2y->in04_last[i] != ((char*)usx2y->in04_buf)[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (diff < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) diff = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) usx2y->in04_last[i] = ((char*)usx2y->in04_buf)[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (0 <= diff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int n = us428ctls->ctl_snapshot_last + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (n >= N_US428_CTL_BUFS || n < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) n = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) memcpy(us428ctls->ctl_snapshot + n, usx2y->in04_buf, sizeof(us428ctls->ctl_snapshot[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) us428ctls->ctl_snapshot_differs_at[n] = diff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) us428ctls->ctl_snapshot_last = n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) wake_up(&usx2y->us428ctls_wait_queue_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (usx2y->us04) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (0 == usx2y->us04->submitted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) err = usb_submit_urb(usx2y->us04->urb[usx2y->us04->submitted++], GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) } while (!err && usx2y->us04->submitted < usx2y->us04->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (us428ctls && us428ctls->p4out_last >= 0 && us428ctls->p4out_last < N_US428_P4OUT_BUFS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (us428ctls->p4out_last != us428ctls->p4out_sent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int j, send = us428ctls->p4out_sent + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (send >= N_US428_P4OUT_BUFS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) send = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) for (j = 0; j < URBS_ASYNC_SEQ && !err; ++j)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (0 == usx2y->as04.urb[j]->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more than 1 p4out is new, 1 gets lost.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) usb_fill_bulk_urb(usx2y->as04.urb[j], usx2y->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) usb_sndbulkpipe(usx2y->dev, 0x04), &p4out->val.vol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) p4out->type == ELT_LIGHT ? sizeof(struct us428_lights) : 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) i_usx2y_out04_int, usx2y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) err = usb_submit_urb(usx2y->as04.urb[j], GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) us428ctls->p4out_sent = send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) snd_printk(KERN_ERR "in04_int() usb_submit_urb err=%i\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) urb->dev = usx2y->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) usb_submit_urb(urb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * Prepare some urbs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int usx2y_async_seq04_init(struct usx2ydev *usx2y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int err = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) usx2y->as04.buffer = kmalloc_array(URBS_ASYNC_SEQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) URB_DATA_LEN_ASYNC_SEQ, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (NULL == usx2y->as04.buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) for (i = 0; i < URBS_ASYNC_SEQ; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if (NULL == (usx2y->as04.urb[i] = usb_alloc_urb(0, GFP_KERNEL))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) usb_fill_bulk_urb( usx2y->as04.urb[i], usx2y->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) usb_sndbulkpipe(usx2y->dev, 0x04),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) usx2y->as04.buffer + URB_DATA_LEN_ASYNC_SEQ*i, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) i_usx2y_out04_int, usx2y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) err = usb_urb_ep_type_check(usx2y->as04.urb[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) int usx2y_in04_init(struct usx2ydev *usx2y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (! (usx2y->in04_urb = usb_alloc_urb(0, GFP_KERNEL)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (! (usx2y->in04_buf = kmalloc(21, GFP_KERNEL)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) init_waitqueue_head(&usx2y->in04_wait_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) usb_fill_int_urb(usx2y->in04_urb, usx2y->dev, usb_rcvintpipe(usx2y->dev, 0x4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) usx2y->in04_buf, 21,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) i_usx2y_in04_int, usx2y,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (usb_urb_ep_type_check(usx2y->in04_urb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return usb_submit_urb(usx2y->in04_urb, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static void usx2y_unlinkseq(struct snd_usx2y_async_seq *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) for (i = 0; i < URBS_ASYNC_SEQ; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) usb_kill_urb(s->urb[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) usb_free_urb(s->urb[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) s->urb[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) kfree(s->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static const struct usb_device_id snd_usx2y_usb_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) .idVendor = 0x1604,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) .idProduct = USB_ID_US428
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) .idVendor = 0x1604,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) .idProduct = USB_ID_US122
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) .idVendor = 0x1604,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) .idProduct = USB_ID_US224
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) { /* terminator */ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static int usx2y_create_card(struct usb_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct usb_interface *intf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct snd_card **cardp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) int dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct snd_card * card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) for (dev = 0; dev < SNDRV_CARDS; ++dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (enable[dev] && !snd_usx2y_card_used[dev])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) if (dev >= SNDRV_CARDS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) err = snd_card_new(&intf->dev, index[dev], id[dev], THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) sizeof(struct usx2ydev), &card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) snd_usx2y_card_used[usx2y(card)->card_index = dev] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) card->private_free = snd_usx2y_card_private_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) usx2y(card)->dev = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) init_waitqueue_head(&usx2y(card)->prepare_wait_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) mutex_init(&usx2y(card)->pcm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) INIT_LIST_HEAD(&usx2y(card)->midi_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) strcpy(card->driver, "USB "NAME_ALLCAPS"");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) card->shortname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) le16_to_cpu(device->descriptor.idVendor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) le16_to_cpu(device->descriptor.idProduct),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 0,//us428(card)->usbmidi.ifnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) usx2y(card)->dev->bus->busnum, usx2y(card)->dev->devnum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) *cardp = card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static int usx2y_usb_probe(struct usb_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct usb_interface *intf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) const struct usb_device_id *device_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) struct snd_card **cardp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct snd_card * card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) *cardp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) err = usx2y_create_card(device, intf, &card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if ((err = usx2y_hwdep_new(card, device)) < 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) (err = snd_card_register(card)) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) snd_card_free(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) *cardp = card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * new 2.5 USB kernel API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) static int snd_usx2y_probe(struct usb_interface *intf, const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) err = usx2y_usb_probe(interface_to_usbdev(intf), intf, id, &card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) dev_set_drvdata(&intf->dev, card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) static void snd_usx2y_disconnect(struct usb_interface *intf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) usx2y_usb_disconnect(interface_to_usbdev(intf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) usb_get_intfdata(intf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) MODULE_DEVICE_TABLE(usb, snd_usx2y_usb_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static struct usb_driver snd_usx2y_usb_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) .name = "snd-usb-usx2y",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) .probe = snd_usx2y_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) .disconnect = snd_usx2y_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) .id_table = snd_usx2y_usb_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) static void snd_usx2y_card_private_free(struct snd_card *card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) kfree(usx2y(card)->in04_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) usb_free_urb(usx2y(card)->in04_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) if (usx2y(card)->us428ctls_sharedmem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) free_pages_exact(usx2y(card)->us428ctls_sharedmem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) sizeof(*usx2y(card)->us428ctls_sharedmem));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (usx2y(card)->card_index >= 0 && usx2y(card)->card_index < SNDRV_CARDS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) snd_usx2y_card_used[usx2y(card)->card_index] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * Frees the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) static void usx2y_usb_disconnect(struct usb_device *device, void* ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) struct snd_card *card = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct usx2ydev *usx2y = usx2y(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) struct list_head *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) usx2y->chip_status = USX2Y_STAT_CHIP_HUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) usx2y_unlinkseq(&usx2y->as04);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) usb_kill_urb(usx2y->in04_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) snd_card_disconnect(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /* release the midi resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) list_for_each(p, &usx2y->midi_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) snd_usbmidi_disconnect(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (usx2y->us428ctls_sharedmem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) wake_up(&usx2y->us428ctls_wait_queue_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) snd_card_free(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) module_usb_driver(snd_usx2y_usb_driver);