xref: /openbmc/linux/sound/usb/usx2y/us122l.c (revision 3f5d3465)
1030a07e4SKarsten Wiese /*
2030a07e4SKarsten Wiese  * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de>
3030a07e4SKarsten Wiese  *
4030a07e4SKarsten Wiese  * This program is free software; you can redistribute it and/or modify it
5030a07e4SKarsten Wiese  * under the terms of the GNU General Public License as published by the
6030a07e4SKarsten Wiese  * Free Software Foundation; either version 2 of the License, or (at your
7030a07e4SKarsten Wiese  * option) any later version.
8030a07e4SKarsten Wiese  *
9030a07e4SKarsten Wiese  * This program is distributed in the hope that it will be useful, but
10030a07e4SKarsten Wiese  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11030a07e4SKarsten Wiese  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12030a07e4SKarsten Wiese  * for more details.
13030a07e4SKarsten Wiese  *
14030a07e4SKarsten Wiese  * You should have received a copy of the GNU General Public License
15030a07e4SKarsten Wiese  * along with this program; if not, write to the Free Software Foundation,
16030a07e4SKarsten Wiese  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17030a07e4SKarsten Wiese  */
18030a07e4SKarsten Wiese 
19030a07e4SKarsten Wiese #include <sound/core.h>
20030a07e4SKarsten Wiese #include <sound/hwdep.h>
21030a07e4SKarsten Wiese #include <sound/pcm.h>
22030a07e4SKarsten Wiese #include <sound/initval.h>
23030a07e4SKarsten Wiese #define MODNAME "US122L"
24030a07e4SKarsten Wiese #include "usb_stream.c"
25030a07e4SKarsten Wiese #include "../usbaudio.h"
26030a07e4SKarsten Wiese #include "us122l.h"
27030a07e4SKarsten Wiese 
28030a07e4SKarsten Wiese MODULE_AUTHOR("Karsten Wiese <fzu@wemgehoertderstaat.de>");
29030a07e4SKarsten Wiese MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.5");
30030a07e4SKarsten Wiese MODULE_LICENSE("GPL");
31030a07e4SKarsten Wiese 
32030a07e4SKarsten Wiese static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;	/* Index 0-max */
33030a07e4SKarsten Wiese static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;	/* Id for this card */
34030a07e4SKarsten Wiese 							/* Enable this card */
35030a07e4SKarsten Wiese static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
36030a07e4SKarsten Wiese 
37030a07e4SKarsten Wiese module_param_array(index, int, NULL, 0444);
38030a07e4SKarsten Wiese MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS".");
39030a07e4SKarsten Wiese module_param_array(id, charp, NULL, 0444);
40030a07e4SKarsten Wiese MODULE_PARM_DESC(id, "ID string for "NAME_ALLCAPS".");
41030a07e4SKarsten Wiese module_param_array(enable, bool, NULL, 0444);
42030a07e4SKarsten Wiese MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS".");
43030a07e4SKarsten Wiese 
44030a07e4SKarsten Wiese static int snd_us122l_card_used[SNDRV_CARDS];
45030a07e4SKarsten Wiese 
46030a07e4SKarsten Wiese 
47030a07e4SKarsten Wiese static int us122l_create_usbmidi(struct snd_card *card)
48030a07e4SKarsten Wiese {
49030a07e4SKarsten Wiese 	static struct snd_usb_midi_endpoint_info quirk_data = {
50030a07e4SKarsten Wiese 		.out_ep = 4,
51030a07e4SKarsten Wiese 		.in_ep = 3,
52030a07e4SKarsten Wiese 		.out_cables =	0x001,
53030a07e4SKarsten Wiese 		.in_cables =	0x001
54030a07e4SKarsten Wiese 	};
55030a07e4SKarsten Wiese 	static struct snd_usb_audio_quirk quirk = {
56030a07e4SKarsten Wiese 		.vendor_name =	"US122L",
57030a07e4SKarsten Wiese 		.product_name =	NAME_ALLCAPS,
58030a07e4SKarsten Wiese 		.ifnum = 	1,
59030a07e4SKarsten Wiese 		.type = QUIRK_MIDI_US122L,
60030a07e4SKarsten Wiese 		.data = &quirk_data
61030a07e4SKarsten Wiese 	};
62030a07e4SKarsten Wiese 	struct usb_device *dev = US122L(card)->chip.dev;
63030a07e4SKarsten Wiese 	struct usb_interface *iface = usb_ifnum_to_if(dev, 1);
64030a07e4SKarsten Wiese 
65030a07e4SKarsten Wiese 	return snd_usb_create_midi_interface(&US122L(card)->chip,
66030a07e4SKarsten Wiese 					     iface, &quirk);
67030a07e4SKarsten Wiese }
68030a07e4SKarsten Wiese 
69030a07e4SKarsten Wiese /*
70030a07e4SKarsten Wiese  * Wrapper for usb_control_msg().
71030a07e4SKarsten Wiese  * Allocates a temp buffer to prevent dmaing from/to the stack.
72030a07e4SKarsten Wiese  */
73030a07e4SKarsten Wiese static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe,
74030a07e4SKarsten Wiese 			  __u8 request, __u8 requesttype,
75030a07e4SKarsten Wiese 			  __u16 value, __u16 index, void *data,
76030a07e4SKarsten Wiese 			  __u16 size, int timeout)
77030a07e4SKarsten Wiese {
78030a07e4SKarsten Wiese 	int err;
79030a07e4SKarsten Wiese 	void *buf = NULL;
80030a07e4SKarsten Wiese 
81030a07e4SKarsten Wiese 	if (size > 0) {
82030a07e4SKarsten Wiese 		buf = kmemdup(data, size, GFP_KERNEL);
83030a07e4SKarsten Wiese 		if (!buf)
84030a07e4SKarsten Wiese 			return -ENOMEM;
85030a07e4SKarsten Wiese 	}
86030a07e4SKarsten Wiese 	err = usb_control_msg(dev, pipe, request, requesttype,
87030a07e4SKarsten Wiese 			      value, index, buf, size, timeout);
88030a07e4SKarsten Wiese 	if (size > 0) {
89030a07e4SKarsten Wiese 		memcpy(data, buf, size);
90030a07e4SKarsten Wiese 		kfree(buf);
91030a07e4SKarsten Wiese 	}
92030a07e4SKarsten Wiese 	return err;
93030a07e4SKarsten Wiese }
94030a07e4SKarsten Wiese 
95030a07e4SKarsten Wiese static void pt_info_set(struct usb_device *dev, u8 v)
96030a07e4SKarsten Wiese {
97030a07e4SKarsten Wiese 	int ret;
98030a07e4SKarsten Wiese 
99030a07e4SKarsten Wiese 	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
100030a07e4SKarsten Wiese 			      'I',
101030a07e4SKarsten Wiese 			      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
102030a07e4SKarsten Wiese 			      v, 0, NULL, 0, 1000);
103030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG "%i\n", ret);
104030a07e4SKarsten Wiese }
105030a07e4SKarsten Wiese 
106030a07e4SKarsten Wiese static void usb_stream_hwdep_vm_open(struct vm_area_struct *area)
107030a07e4SKarsten Wiese {
108030a07e4SKarsten Wiese 	struct us122l *us122l = area->vm_private_data;
109030a07e4SKarsten Wiese 	atomic_inc(&us122l->mmap_count);
110030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count));
111030a07e4SKarsten Wiese }
112030a07e4SKarsten Wiese 
113030a07e4SKarsten Wiese static int usb_stream_hwdep_vm_fault(struct vm_area_struct *area,
114030a07e4SKarsten Wiese 				     struct vm_fault *vmf)
115030a07e4SKarsten Wiese {
116030a07e4SKarsten Wiese 	unsigned long offset;
117030a07e4SKarsten Wiese 	struct page *page;
118030a07e4SKarsten Wiese 	void *vaddr;
119030a07e4SKarsten Wiese 	struct us122l *us122l = area->vm_private_data;
120030a07e4SKarsten Wiese 	struct usb_stream *s;
121030a07e4SKarsten Wiese 
122030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
123030a07e4SKarsten Wiese 	s = us122l->sk.s;
124030a07e4SKarsten Wiese 	if (!s)
125428ffb71SLi Zefan 		goto unlock;
126030a07e4SKarsten Wiese 
127030a07e4SKarsten Wiese 	offset = vmf->pgoff << PAGE_SHIFT;
128030a07e4SKarsten Wiese 	if (offset < PAGE_ALIGN(s->read_size))
129030a07e4SKarsten Wiese 		vaddr = (char *)s + offset;
130030a07e4SKarsten Wiese 	else {
131030a07e4SKarsten Wiese 		offset -= PAGE_ALIGN(s->read_size);
132030a07e4SKarsten Wiese 		if (offset >= PAGE_ALIGN(s->write_size))
133428ffb71SLi Zefan 			goto unlock;
134030a07e4SKarsten Wiese 
135030a07e4SKarsten Wiese 		vaddr = us122l->sk.write_page + offset;
136030a07e4SKarsten Wiese 	}
137030a07e4SKarsten Wiese 	page = virt_to_page(vaddr);
138030a07e4SKarsten Wiese 
139030a07e4SKarsten Wiese 	get_page(page);
140030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
141030a07e4SKarsten Wiese 
142030a07e4SKarsten Wiese 	vmf->page = page;
143428ffb71SLi Zefan 
144428ffb71SLi Zefan 	return 0;
145428ffb71SLi Zefan unlock:
146428ffb71SLi Zefan 	mutex_unlock(&us122l->mutex);
147428ffb71SLi Zefan 	return VM_FAULT_SIGBUS;
148030a07e4SKarsten Wiese }
149030a07e4SKarsten Wiese 
150030a07e4SKarsten Wiese static void usb_stream_hwdep_vm_close(struct vm_area_struct *area)
151030a07e4SKarsten Wiese {
152030a07e4SKarsten Wiese 	struct us122l *us122l = area->vm_private_data;
153030a07e4SKarsten Wiese 	atomic_dec(&us122l->mmap_count);
154030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count));
155030a07e4SKarsten Wiese }
156030a07e4SKarsten Wiese 
157030a07e4SKarsten Wiese static struct vm_operations_struct usb_stream_hwdep_vm_ops = {
158030a07e4SKarsten Wiese 	.open = usb_stream_hwdep_vm_open,
159030a07e4SKarsten Wiese 	.fault = usb_stream_hwdep_vm_fault,
160030a07e4SKarsten Wiese 	.close = usb_stream_hwdep_vm_close,
161030a07e4SKarsten Wiese };
162030a07e4SKarsten Wiese 
163030a07e4SKarsten Wiese 
164030a07e4SKarsten Wiese static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file)
165030a07e4SKarsten Wiese {
166030a07e4SKarsten Wiese 	struct us122l	*us122l = hw->private_data;
167030a07e4SKarsten Wiese 	struct usb_interface *iface;
168030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
169030a07e4SKarsten Wiese 	if (hw->used >= 2)
170030a07e4SKarsten Wiese 		return -EBUSY;
171030a07e4SKarsten Wiese 
172030a07e4SKarsten Wiese 	if (!us122l->first)
173030a07e4SKarsten Wiese 		us122l->first = file;
174030a07e4SKarsten Wiese 	iface = usb_ifnum_to_if(us122l->chip.dev, 1);
175030a07e4SKarsten Wiese 	usb_autopm_get_interface(iface);
176030a07e4SKarsten Wiese 	return 0;
177030a07e4SKarsten Wiese }
178030a07e4SKarsten Wiese 
179030a07e4SKarsten Wiese static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file)
180030a07e4SKarsten Wiese {
181030a07e4SKarsten Wiese 	struct us122l	*us122l = hw->private_data;
182030a07e4SKarsten Wiese 	struct usb_interface *iface = usb_ifnum_to_if(us122l->chip.dev, 1);
183030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
184030a07e4SKarsten Wiese 	usb_autopm_put_interface(iface);
185030a07e4SKarsten Wiese 	if (us122l->first == file)
186030a07e4SKarsten Wiese 		us122l->first = NULL;
187030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
188030a07e4SKarsten Wiese 	if (us122l->master == file)
189030a07e4SKarsten Wiese 		us122l->master = us122l->slave;
190030a07e4SKarsten Wiese 
191030a07e4SKarsten Wiese 	us122l->slave = NULL;
192030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
193030a07e4SKarsten Wiese 	return 0;
194030a07e4SKarsten Wiese }
195030a07e4SKarsten Wiese 
196030a07e4SKarsten Wiese static int usb_stream_hwdep_mmap(struct snd_hwdep *hw,
197030a07e4SKarsten Wiese 				 struct file *filp, struct vm_area_struct *area)
198030a07e4SKarsten Wiese {
199030a07e4SKarsten Wiese 	unsigned long	size = area->vm_end - area->vm_start;
200030a07e4SKarsten Wiese 	struct us122l	*us122l = hw->private_data;
201030a07e4SKarsten Wiese 	unsigned long offset;
202030a07e4SKarsten Wiese 	struct usb_stream *s;
203030a07e4SKarsten Wiese 	int err = 0;
204030a07e4SKarsten Wiese 	bool read;
205030a07e4SKarsten Wiese 
206030a07e4SKarsten Wiese 	offset = area->vm_pgoff << PAGE_SHIFT;
207030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
208030a07e4SKarsten Wiese 	s = us122l->sk.s;
209030a07e4SKarsten Wiese 	read = offset < s->read_size;
210030a07e4SKarsten Wiese 	if (read && area->vm_flags & VM_WRITE) {
211030a07e4SKarsten Wiese 		err = -EPERM;
212030a07e4SKarsten Wiese 		goto out;
213030a07e4SKarsten Wiese 	}
214030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG "%lu %u\n", size,
215030a07e4SKarsten Wiese 		    read ? s->read_size : s->write_size);
216030a07e4SKarsten Wiese 	/* if userspace tries to mmap beyond end of our buffer, fail */
217030a07e4SKarsten Wiese 	if (size > PAGE_ALIGN(read ? s->read_size : s->write_size)) {
218030a07e4SKarsten Wiese 		snd_printk(KERN_WARNING "%lu > %u\n", size,
219030a07e4SKarsten Wiese 			   read ? s->read_size : s->write_size);
220030a07e4SKarsten Wiese 		err = -EINVAL;
221030a07e4SKarsten Wiese 		goto out;
222030a07e4SKarsten Wiese 	}
223030a07e4SKarsten Wiese 
224030a07e4SKarsten Wiese 	area->vm_ops = &usb_stream_hwdep_vm_ops;
225030a07e4SKarsten Wiese 	area->vm_flags |= VM_RESERVED;
226030a07e4SKarsten Wiese 	area->vm_private_data = us122l;
227030a07e4SKarsten Wiese 	atomic_inc(&us122l->mmap_count);
228030a07e4SKarsten Wiese out:
229030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
230030a07e4SKarsten Wiese 	return err;
231030a07e4SKarsten Wiese }
232030a07e4SKarsten Wiese 
233030a07e4SKarsten Wiese static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw,
234030a07e4SKarsten Wiese 					  struct file *file, poll_table *wait)
235030a07e4SKarsten Wiese {
236030a07e4SKarsten Wiese 	struct us122l	*us122l = hw->private_data;
237030a07e4SKarsten Wiese 	struct usb_stream *s = us122l->sk.s;
238030a07e4SKarsten Wiese 	unsigned	*polled;
239030a07e4SKarsten Wiese 	unsigned int	mask;
240030a07e4SKarsten Wiese 
241030a07e4SKarsten Wiese 	poll_wait(file, &us122l->sk.sleep, wait);
242030a07e4SKarsten Wiese 
243030a07e4SKarsten Wiese 	switch (s->state) {
244030a07e4SKarsten Wiese 	case usb_stream_ready:
245030a07e4SKarsten Wiese 		if (us122l->first == file)
246030a07e4SKarsten Wiese 			polled = &s->periods_polled;
247030a07e4SKarsten Wiese 		else
248030a07e4SKarsten Wiese 			polled = &us122l->second_periods_polled;
249030a07e4SKarsten Wiese 		if (*polled != s->periods_done) {
250030a07e4SKarsten Wiese 			*polled = s->periods_done;
251030a07e4SKarsten Wiese 			mask = POLLIN | POLLOUT | POLLWRNORM;
252030a07e4SKarsten Wiese 			break;
253030a07e4SKarsten Wiese 		}
254030a07e4SKarsten Wiese 		/* Fall through */
255030a07e4SKarsten Wiese 		mask = 0;
256030a07e4SKarsten Wiese 		break;
257030a07e4SKarsten Wiese 	default:
258030a07e4SKarsten Wiese 		mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR;
259030a07e4SKarsten Wiese 		break;
260030a07e4SKarsten Wiese 	}
261030a07e4SKarsten Wiese 	return mask;
262030a07e4SKarsten Wiese }
263030a07e4SKarsten Wiese 
264030a07e4SKarsten Wiese static void us122l_stop(struct us122l *us122l)
265030a07e4SKarsten Wiese {
266030a07e4SKarsten Wiese 	struct list_head *p;
267030a07e4SKarsten Wiese 	list_for_each(p, &us122l->chip.midi_list)
268030a07e4SKarsten Wiese 		snd_usbmidi_input_stop(p);
269030a07e4SKarsten Wiese 
270030a07e4SKarsten Wiese 	usb_stream_stop(&us122l->sk);
271030a07e4SKarsten Wiese 	usb_stream_free(&us122l->sk);
272030a07e4SKarsten Wiese }
273030a07e4SKarsten Wiese 
274030a07e4SKarsten Wiese static int us122l_set_sample_rate(struct usb_device *dev, int rate)
275030a07e4SKarsten Wiese {
276030a07e4SKarsten Wiese 	unsigned int ep = 0x81;
277030a07e4SKarsten Wiese 	unsigned char data[3];
278030a07e4SKarsten Wiese 	int err;
279030a07e4SKarsten Wiese 
280030a07e4SKarsten Wiese 	data[0] = rate;
281030a07e4SKarsten Wiese 	data[1] = rate >> 8;
282030a07e4SKarsten Wiese 	data[2] = rate >> 16;
283030a07e4SKarsten Wiese 	err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
284030a07e4SKarsten Wiese 			     USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
285030a07e4SKarsten Wiese 			     SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000);
286030a07e4SKarsten Wiese 	if (err < 0)
287030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n",
288030a07e4SKarsten Wiese 			   dev->devnum, rate, ep);
289030a07e4SKarsten Wiese 	return err;
290030a07e4SKarsten Wiese }
291030a07e4SKarsten Wiese 
292030a07e4SKarsten Wiese static bool us122l_start(struct us122l *us122l,
293030a07e4SKarsten Wiese 			 unsigned rate, unsigned period_frames)
294030a07e4SKarsten Wiese {
295030a07e4SKarsten Wiese 	struct list_head *p;
296030a07e4SKarsten Wiese 	int err;
297030a07e4SKarsten Wiese 	unsigned use_packsize = 0;
298030a07e4SKarsten Wiese 	bool success = false;
299030a07e4SKarsten Wiese 
300030a07e4SKarsten Wiese 	if (us122l->chip.dev->speed == USB_SPEED_HIGH) {
301030a07e4SKarsten Wiese 		/* The us-122l's descriptor defaults to iso max_packsize 78,
302030a07e4SKarsten Wiese 		   which isn't needed for samplerates <= 48000.
303030a07e4SKarsten Wiese 		   Lets save some memory:
304030a07e4SKarsten Wiese 		*/
305030a07e4SKarsten Wiese 		switch (rate) {
306030a07e4SKarsten Wiese 		case 44100:
307030a07e4SKarsten Wiese 			use_packsize = 36;
308030a07e4SKarsten Wiese 			break;
309030a07e4SKarsten Wiese 		case 48000:
310030a07e4SKarsten Wiese 			use_packsize = 42;
311030a07e4SKarsten Wiese 			break;
312030a07e4SKarsten Wiese 		case 88200:
313030a07e4SKarsten Wiese 			use_packsize = 72;
314030a07e4SKarsten Wiese 			break;
315030a07e4SKarsten Wiese 		}
316030a07e4SKarsten Wiese 	}
317030a07e4SKarsten Wiese 	if (!usb_stream_new(&us122l->sk, us122l->chip.dev, 1, 2,
318030a07e4SKarsten Wiese 			    rate, use_packsize, period_frames, 6))
319030a07e4SKarsten Wiese 		goto out;
320030a07e4SKarsten Wiese 
321030a07e4SKarsten Wiese 	err = us122l_set_sample_rate(us122l->chip.dev, rate);
322030a07e4SKarsten Wiese 	if (err < 0) {
323030a07e4SKarsten Wiese 		us122l_stop(us122l);
324030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
325030a07e4SKarsten Wiese 		goto out;
326030a07e4SKarsten Wiese 	}
327030a07e4SKarsten Wiese 	err = usb_stream_start(&us122l->sk);
328030a07e4SKarsten Wiese 	if (err < 0) {
329030a07e4SKarsten Wiese 		us122l_stop(us122l);
330030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "us122l_start error %i \n", err);
331030a07e4SKarsten Wiese 		goto out;
332030a07e4SKarsten Wiese 	}
333030a07e4SKarsten Wiese 	list_for_each(p, &us122l->chip.midi_list)
334030a07e4SKarsten Wiese 		snd_usbmidi_input_start(p);
335030a07e4SKarsten Wiese 	success = true;
336030a07e4SKarsten Wiese out:
337030a07e4SKarsten Wiese 	return success;
338030a07e4SKarsten Wiese }
339030a07e4SKarsten Wiese 
340030a07e4SKarsten Wiese static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
341030a07e4SKarsten Wiese 				  unsigned cmd, unsigned long arg)
342030a07e4SKarsten Wiese {
343030a07e4SKarsten Wiese 	struct usb_stream_config *cfg;
344030a07e4SKarsten Wiese 	struct us122l *us122l = hw->private_data;
345030a07e4SKarsten Wiese 	unsigned min_period_frames;
346030a07e4SKarsten Wiese 	int err = 0;
347030a07e4SKarsten Wiese 	bool high_speed;
348030a07e4SKarsten Wiese 
349030a07e4SKarsten Wiese 	if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS)
350030a07e4SKarsten Wiese 		return -ENOTTY;
351030a07e4SKarsten Wiese 
35285385c15SLi Zefan 	cfg = memdup_user((void *)arg, sizeof(*cfg));
35385385c15SLi Zefan 	if (IS_ERR(cfg))
35485385c15SLi Zefan 		return PTR_ERR(cfg);
355030a07e4SKarsten Wiese 
356030a07e4SKarsten Wiese 	if (cfg->version != USB_STREAM_INTERFACE_VERSION) {
357030a07e4SKarsten Wiese 		err = -ENXIO;
358030a07e4SKarsten Wiese 		goto free;
359030a07e4SKarsten Wiese 	}
360030a07e4SKarsten Wiese 	high_speed = us122l->chip.dev->speed == USB_SPEED_HIGH;
361030a07e4SKarsten Wiese 	if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000  &&
362030a07e4SKarsten Wiese 	     (!high_speed ||
363030a07e4SKarsten Wiese 	      (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) ||
364030a07e4SKarsten Wiese 	    cfg->frame_size != 6 ||
365030a07e4SKarsten Wiese 	    cfg->period_frames > 0x3000) {
366030a07e4SKarsten Wiese 		err = -EINVAL;
367030a07e4SKarsten Wiese 		goto free;
368030a07e4SKarsten Wiese 	}
369030a07e4SKarsten Wiese 	switch (cfg->sample_rate) {
370030a07e4SKarsten Wiese 	case 44100:
371030a07e4SKarsten Wiese 		min_period_frames = 48;
372030a07e4SKarsten Wiese 		break;
373030a07e4SKarsten Wiese 	case 48000:
374030a07e4SKarsten Wiese 		min_period_frames = 52;
375030a07e4SKarsten Wiese 		break;
376030a07e4SKarsten Wiese 	default:
377030a07e4SKarsten Wiese 		min_period_frames = 104;
378030a07e4SKarsten Wiese 		break;
379030a07e4SKarsten Wiese 	}
380030a07e4SKarsten Wiese 	if (!high_speed)
381030a07e4SKarsten Wiese 		min_period_frames <<= 1;
382030a07e4SKarsten Wiese 	if (cfg->period_frames < min_period_frames) {
383030a07e4SKarsten Wiese 		err = -EINVAL;
384030a07e4SKarsten Wiese 		goto free;
385030a07e4SKarsten Wiese 	}
386030a07e4SKarsten Wiese 
387030a07e4SKarsten Wiese 	snd_power_wait(hw->card, SNDRV_CTL_POWER_D0);
388030a07e4SKarsten Wiese 
389030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
390030a07e4SKarsten Wiese 	if (!us122l->master)
391030a07e4SKarsten Wiese 		us122l->master = file;
392030a07e4SKarsten Wiese 	else if (us122l->master != file) {
393030a07e4SKarsten Wiese 		if (memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg))) {
394030a07e4SKarsten Wiese 			err = -EIO;
395030a07e4SKarsten Wiese 			goto unlock;
396030a07e4SKarsten Wiese 		}
397030a07e4SKarsten Wiese 		us122l->slave = file;
398030a07e4SKarsten Wiese 	}
399030a07e4SKarsten Wiese 	if (!us122l->sk.s ||
400030a07e4SKarsten Wiese 	    memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg)) ||
401030a07e4SKarsten Wiese 	    us122l->sk.s->state == usb_stream_xrun) {
402030a07e4SKarsten Wiese 		us122l_stop(us122l);
403030a07e4SKarsten Wiese 		if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames))
404030a07e4SKarsten Wiese 			err = -EIO;
405030a07e4SKarsten Wiese 		else
406030a07e4SKarsten Wiese 			err = 1;
407030a07e4SKarsten Wiese 	}
408030a07e4SKarsten Wiese unlock:
409030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
410030a07e4SKarsten Wiese free:
411030a07e4SKarsten Wiese 	kfree(cfg);
412030a07e4SKarsten Wiese 	return err;
413030a07e4SKarsten Wiese }
414030a07e4SKarsten Wiese 
415030a07e4SKarsten Wiese #define SND_USB_STREAM_ID "USB STREAM"
416030a07e4SKarsten Wiese static int usb_stream_hwdep_new(struct snd_card *card)
417030a07e4SKarsten Wiese {
418030a07e4SKarsten Wiese 	int err;
419030a07e4SKarsten Wiese 	struct snd_hwdep *hw;
420030a07e4SKarsten Wiese 	struct usb_device *dev = US122L(card)->chip.dev;
421030a07e4SKarsten Wiese 
422030a07e4SKarsten Wiese 	err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw);
423030a07e4SKarsten Wiese 	if (err < 0)
424030a07e4SKarsten Wiese 		return err;
425030a07e4SKarsten Wiese 
426030a07e4SKarsten Wiese 	hw->iface = SNDRV_HWDEP_IFACE_USB_STREAM;
427030a07e4SKarsten Wiese 	hw->private_data = US122L(card);
428030a07e4SKarsten Wiese 	hw->ops.open = usb_stream_hwdep_open;
429030a07e4SKarsten Wiese 	hw->ops.release = usb_stream_hwdep_release;
430030a07e4SKarsten Wiese 	hw->ops.ioctl = usb_stream_hwdep_ioctl;
431030a07e4SKarsten Wiese 	hw->ops.ioctl_compat = usb_stream_hwdep_ioctl;
432030a07e4SKarsten Wiese 	hw->ops.mmap = usb_stream_hwdep_mmap;
433030a07e4SKarsten Wiese 	hw->ops.poll = usb_stream_hwdep_poll;
434030a07e4SKarsten Wiese 
435030a07e4SKarsten Wiese 	sprintf(hw->name, "/proc/bus/usb/%03d/%03d/hwdeppcm",
436030a07e4SKarsten Wiese 		dev->bus->busnum, dev->devnum);
437030a07e4SKarsten Wiese 	return 0;
438030a07e4SKarsten Wiese }
439030a07e4SKarsten Wiese 
440030a07e4SKarsten Wiese 
441030a07e4SKarsten Wiese static bool us122l_create_card(struct snd_card *card)
442030a07e4SKarsten Wiese {
443030a07e4SKarsten Wiese 	int err;
444030a07e4SKarsten Wiese 	struct us122l *us122l = US122L(card);
445030a07e4SKarsten Wiese 
446030a07e4SKarsten Wiese 	err = usb_set_interface(us122l->chip.dev, 1, 1);
447030a07e4SKarsten Wiese 	if (err) {
448030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "usb_set_interface error \n");
449030a07e4SKarsten Wiese 		return false;
450030a07e4SKarsten Wiese 	}
451030a07e4SKarsten Wiese 
452030a07e4SKarsten Wiese 	pt_info_set(us122l->chip.dev, 0x11);
453030a07e4SKarsten Wiese 	pt_info_set(us122l->chip.dev, 0x10);
454030a07e4SKarsten Wiese 
455030a07e4SKarsten Wiese 	if (!us122l_start(us122l, 44100, 256))
456030a07e4SKarsten Wiese 		return false;
457030a07e4SKarsten Wiese 
458030a07e4SKarsten Wiese 	err = us122l_create_usbmidi(card);
459030a07e4SKarsten Wiese 	if (err < 0) {
460030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err);
461030a07e4SKarsten Wiese 		us122l_stop(us122l);
462030a07e4SKarsten Wiese 		return false;
463030a07e4SKarsten Wiese 	}
464030a07e4SKarsten Wiese 	err = usb_stream_hwdep_new(card);
465030a07e4SKarsten Wiese 	if (err < 0) {
466030a07e4SKarsten Wiese /* release the midi resources */
467030a07e4SKarsten Wiese 		struct list_head *p;
468030a07e4SKarsten Wiese 		list_for_each(p, &us122l->chip.midi_list)
469030a07e4SKarsten Wiese 			snd_usbmidi_disconnect(p);
470030a07e4SKarsten Wiese 
471030a07e4SKarsten Wiese 		us122l_stop(us122l);
472030a07e4SKarsten Wiese 		return false;
473030a07e4SKarsten Wiese 	}
474030a07e4SKarsten Wiese 	return true;
475030a07e4SKarsten Wiese }
476030a07e4SKarsten Wiese 
4775d4af1beSKarsten Wiese static void snd_us122l_free(struct snd_card *card)
4785d4af1beSKarsten Wiese {
4795d4af1beSKarsten Wiese 	struct us122l	*us122l = US122L(card);
4805d4af1beSKarsten Wiese 	int		index = us122l->chip.index;
4815d4af1beSKarsten Wiese 	if (index >= 0  &&  index < SNDRV_CARDS)
4825d4af1beSKarsten Wiese 		snd_us122l_card_used[index] = 0;
4835d4af1beSKarsten Wiese }
4845d4af1beSKarsten Wiese 
48551721f70STakashi Iwai static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
486030a07e4SKarsten Wiese {
487030a07e4SKarsten Wiese 	int		dev;
488030a07e4SKarsten Wiese 	struct snd_card *card;
489bd7dd77cSTakashi Iwai 	int err;
490bd7dd77cSTakashi Iwai 
491030a07e4SKarsten Wiese 	for (dev = 0; dev < SNDRV_CARDS; ++dev)
492030a07e4SKarsten Wiese 		if (enable[dev] && !snd_us122l_card_used[dev])
493030a07e4SKarsten Wiese 			break;
494030a07e4SKarsten Wiese 	if (dev >= SNDRV_CARDS)
49551721f70STakashi Iwai 		return -ENODEV;
496bd7dd77cSTakashi Iwai 	err = snd_card_create(index[dev], id[dev], THIS_MODULE,
497bd7dd77cSTakashi Iwai 			      sizeof(struct us122l), &card);
498bd7dd77cSTakashi Iwai 	if (err < 0)
49951721f70STakashi Iwai 		return err;
500030a07e4SKarsten Wiese 	snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
5015d4af1beSKarsten Wiese 	card->private_free = snd_us122l_free;
502030a07e4SKarsten Wiese 	US122L(card)->chip.dev = device;
503030a07e4SKarsten Wiese 	US122L(card)->chip.card = card;
504030a07e4SKarsten Wiese 	mutex_init(&US122L(card)->mutex);
505030a07e4SKarsten Wiese 	init_waitqueue_head(&US122L(card)->sk.sleep);
506030a07e4SKarsten Wiese 	INIT_LIST_HEAD(&US122L(card)->chip.midi_list);
507030a07e4SKarsten Wiese 	strcpy(card->driver, "USB "NAME_ALLCAPS"");
508030a07e4SKarsten Wiese 	sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
509030a07e4SKarsten Wiese 	sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
510030a07e4SKarsten Wiese 		card->shortname,
511030a07e4SKarsten Wiese 		le16_to_cpu(device->descriptor.idVendor),
512030a07e4SKarsten Wiese 		le16_to_cpu(device->descriptor.idProduct),
513030a07e4SKarsten Wiese 		0,
514030a07e4SKarsten Wiese 		US122L(card)->chip.dev->bus->busnum,
515030a07e4SKarsten Wiese 		US122L(card)->chip.dev->devnum
516030a07e4SKarsten Wiese 		);
51751721f70STakashi Iwai 	*cardp = card;
51851721f70STakashi Iwai 	return 0;
519030a07e4SKarsten Wiese }
520030a07e4SKarsten Wiese 
52151721f70STakashi Iwai static int us122l_usb_probe(struct usb_interface *intf,
52251721f70STakashi Iwai 			    const struct usb_device_id *device_id,
52351721f70STakashi Iwai 			    struct snd_card **cardp)
524030a07e4SKarsten Wiese {
525030a07e4SKarsten Wiese 	struct usb_device *device = interface_to_usbdev(intf);
52651721f70STakashi Iwai 	struct snd_card *card;
52751721f70STakashi Iwai 	int err;
528030a07e4SKarsten Wiese 
52951721f70STakashi Iwai 	err = usx2y_create_card(device, &card);
53051721f70STakashi Iwai 	if (err < 0)
53151721f70STakashi Iwai 		return err;
532030a07e4SKarsten Wiese 
5333f5d3465STakashi Iwai 	snd_card_set_dev(card, &intf->dev);
53451721f70STakashi Iwai 	if (!us122l_create_card(card)) {
535030a07e4SKarsten Wiese 		snd_card_free(card);
53651721f70STakashi Iwai 		return -EINVAL;
53751721f70STakashi Iwai 	}
53851721f70STakashi Iwai 
53951721f70STakashi Iwai 	err = snd_card_register(card);
54051721f70STakashi Iwai 	if (err < 0) {
54151721f70STakashi Iwai 		snd_card_free(card);
54251721f70STakashi Iwai 		return err;
543030a07e4SKarsten Wiese 	}
544030a07e4SKarsten Wiese 
545030a07e4SKarsten Wiese 	usb_get_dev(device);
54651721f70STakashi Iwai 	*cardp = card;
54751721f70STakashi Iwai 	return 0;
548030a07e4SKarsten Wiese }
549030a07e4SKarsten Wiese 
550030a07e4SKarsten Wiese static int snd_us122l_probe(struct usb_interface *intf,
551030a07e4SKarsten Wiese 			    const struct usb_device_id *id)
552030a07e4SKarsten Wiese {
553030a07e4SKarsten Wiese 	struct snd_card *card;
55451721f70STakashi Iwai 	int err;
55551721f70STakashi Iwai 
556030a07e4SKarsten Wiese 	snd_printdd(KERN_DEBUG"%p:%i\n",
557030a07e4SKarsten Wiese 		    intf, intf->cur_altsetting->desc.bInterfaceNumber);
558030a07e4SKarsten Wiese 	if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
559030a07e4SKarsten Wiese 		return 0;
560030a07e4SKarsten Wiese 
56151721f70STakashi Iwai 	err = us122l_usb_probe(usb_get_intf(intf), id, &card);
56251721f70STakashi Iwai 	if (err < 0) {
56351721f70STakashi Iwai 		usb_put_intf(intf);
56451721f70STakashi Iwai 		return err;
565030a07e4SKarsten Wiese 	}
566030a07e4SKarsten Wiese 
56751721f70STakashi Iwai 	usb_set_intfdata(intf, card);
56851721f70STakashi Iwai 	return 0;
569030a07e4SKarsten Wiese }
570030a07e4SKarsten Wiese 
571030a07e4SKarsten Wiese static void snd_us122l_disconnect(struct usb_interface *intf)
572030a07e4SKarsten Wiese {
573030a07e4SKarsten Wiese 	struct snd_card *card;
574030a07e4SKarsten Wiese 	struct us122l *us122l;
575030a07e4SKarsten Wiese 	struct list_head *p;
576030a07e4SKarsten Wiese 
577030a07e4SKarsten Wiese 	card = usb_get_intfdata(intf);
578030a07e4SKarsten Wiese 	if (!card)
579030a07e4SKarsten Wiese 		return;
580030a07e4SKarsten Wiese 
581030a07e4SKarsten Wiese 	snd_card_disconnect(card);
582030a07e4SKarsten Wiese 
583030a07e4SKarsten Wiese 	us122l = US122L(card);
584030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
585030a07e4SKarsten Wiese 	us122l_stop(us122l);
586030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
587030a07e4SKarsten Wiese 	us122l->chip.shutdown = 1;
588030a07e4SKarsten Wiese 
589030a07e4SKarsten Wiese /* release the midi resources */
590030a07e4SKarsten Wiese 	list_for_each(p, &us122l->chip.midi_list) {
591030a07e4SKarsten Wiese 		snd_usbmidi_disconnect(p);
592030a07e4SKarsten Wiese 	}
593030a07e4SKarsten Wiese 
594030a07e4SKarsten Wiese 	usb_put_intf(intf);
5955d4af1beSKarsten Wiese 	usb_put_dev(us122l->chip.dev);
596030a07e4SKarsten Wiese 
597030a07e4SKarsten Wiese 	while (atomic_read(&us122l->mmap_count))
598030a07e4SKarsten Wiese 		msleep(500);
599030a07e4SKarsten Wiese 
600030a07e4SKarsten Wiese 	snd_card_free(card);
601030a07e4SKarsten Wiese }
602030a07e4SKarsten Wiese 
603030a07e4SKarsten Wiese static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message)
604030a07e4SKarsten Wiese {
605030a07e4SKarsten Wiese 	struct snd_card *card;
606030a07e4SKarsten Wiese 	struct us122l *us122l;
607030a07e4SKarsten Wiese 	struct list_head *p;
608030a07e4SKarsten Wiese 
609f4e9749fSJulia Lawall 	card = usb_get_intfdata(intf);
610030a07e4SKarsten Wiese 	if (!card)
611030a07e4SKarsten Wiese 		return 0;
612030a07e4SKarsten Wiese 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
613030a07e4SKarsten Wiese 
614030a07e4SKarsten Wiese 	us122l = US122L(card);
615030a07e4SKarsten Wiese 	if (!us122l)
616030a07e4SKarsten Wiese 		return 0;
617030a07e4SKarsten Wiese 
618030a07e4SKarsten Wiese 	list_for_each(p, &us122l->chip.midi_list)
619030a07e4SKarsten Wiese 		snd_usbmidi_input_stop(p);
620030a07e4SKarsten Wiese 
621030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
622030a07e4SKarsten Wiese 	usb_stream_stop(&us122l->sk);
623030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
624030a07e4SKarsten Wiese 
625030a07e4SKarsten Wiese 	return 0;
626030a07e4SKarsten Wiese }
627030a07e4SKarsten Wiese 
628030a07e4SKarsten Wiese static int snd_us122l_resume(struct usb_interface *intf)
629030a07e4SKarsten Wiese {
630030a07e4SKarsten Wiese 	struct snd_card *card;
631030a07e4SKarsten Wiese 	struct us122l *us122l;
632030a07e4SKarsten Wiese 	struct list_head *p;
633030a07e4SKarsten Wiese 	int err;
634030a07e4SKarsten Wiese 
635f4e9749fSJulia Lawall 	card = usb_get_intfdata(intf);
636030a07e4SKarsten Wiese 	if (!card)
637030a07e4SKarsten Wiese 		return 0;
638030a07e4SKarsten Wiese 
639030a07e4SKarsten Wiese 	us122l = US122L(card);
640030a07e4SKarsten Wiese 	if (!us122l)
641030a07e4SKarsten Wiese 		return 0;
642030a07e4SKarsten Wiese 
643030a07e4SKarsten Wiese 	mutex_lock(&us122l->mutex);
644030a07e4SKarsten Wiese 	/* needed, doesn't restart without: */
645030a07e4SKarsten Wiese 	err = usb_set_interface(us122l->chip.dev, 1, 1);
646030a07e4SKarsten Wiese 	if (err) {
647030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "usb_set_interface error \n");
648030a07e4SKarsten Wiese 		goto unlock;
649030a07e4SKarsten Wiese 	}
650030a07e4SKarsten Wiese 
651030a07e4SKarsten Wiese 	pt_info_set(us122l->chip.dev, 0x11);
652030a07e4SKarsten Wiese 	pt_info_set(us122l->chip.dev, 0x10);
653030a07e4SKarsten Wiese 
654030a07e4SKarsten Wiese 	err = us122l_set_sample_rate(us122l->chip.dev,
655030a07e4SKarsten Wiese 				     us122l->sk.s->cfg.sample_rate);
656030a07e4SKarsten Wiese 	if (err < 0) {
657030a07e4SKarsten Wiese 		snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
658030a07e4SKarsten Wiese 		goto unlock;
659030a07e4SKarsten Wiese 	}
660030a07e4SKarsten Wiese 	err = usb_stream_start(&us122l->sk);
661030a07e4SKarsten Wiese 	if (err)
662030a07e4SKarsten Wiese 		goto unlock;
663030a07e4SKarsten Wiese 
664030a07e4SKarsten Wiese 	list_for_each(p, &us122l->chip.midi_list)
665030a07e4SKarsten Wiese 		snd_usbmidi_input_start(p);
666030a07e4SKarsten Wiese unlock:
667030a07e4SKarsten Wiese 	mutex_unlock(&us122l->mutex);
668030a07e4SKarsten Wiese 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
669030a07e4SKarsten Wiese 	return err;
670030a07e4SKarsten Wiese }
671030a07e4SKarsten Wiese 
672030a07e4SKarsten Wiese static struct usb_device_id snd_us122l_usb_id_table[] = {
673030a07e4SKarsten Wiese 	{
674030a07e4SKarsten Wiese 		.match_flags =	USB_DEVICE_ID_MATCH_DEVICE,
675030a07e4SKarsten Wiese 		.idVendor =	0x0644,
676030a07e4SKarsten Wiese 		.idProduct =	USB_ID_US122L
677030a07e4SKarsten Wiese 	},
678030a07e4SKarsten Wiese /*  	{ */		/* US-144 maybe works when @USB1.1. Untested. */
679030a07e4SKarsten Wiese /* 		.match_flags =	USB_DEVICE_ID_MATCH_DEVICE, */
680030a07e4SKarsten Wiese /* 		.idVendor =	0x0644, */
681030a07e4SKarsten Wiese /* 		.idProduct =	USB_ID_US144 */
682030a07e4SKarsten Wiese /* 	}, */
683030a07e4SKarsten Wiese 	{ /* terminator */ }
684030a07e4SKarsten Wiese };
685030a07e4SKarsten Wiese 
686030a07e4SKarsten Wiese MODULE_DEVICE_TABLE(usb, snd_us122l_usb_id_table);
687030a07e4SKarsten Wiese static struct usb_driver snd_us122l_usb_driver = {
688030a07e4SKarsten Wiese 	.name =		"snd-usb-us122l",
689030a07e4SKarsten Wiese 	.probe =	snd_us122l_probe,
690030a07e4SKarsten Wiese 	.disconnect =	snd_us122l_disconnect,
691030a07e4SKarsten Wiese 	.suspend =	snd_us122l_suspend,
692030a07e4SKarsten Wiese 	.resume =	snd_us122l_resume,
693030a07e4SKarsten Wiese 	.reset_resume =	snd_us122l_resume,
694030a07e4SKarsten Wiese 	.id_table =	snd_us122l_usb_id_table,
695030a07e4SKarsten Wiese 	.supports_autosuspend = 1
696030a07e4SKarsten Wiese };
697030a07e4SKarsten Wiese 
698030a07e4SKarsten Wiese 
699030a07e4SKarsten Wiese static int __init snd_us122l_module_init(void)
700030a07e4SKarsten Wiese {
701030a07e4SKarsten Wiese 	return usb_register(&snd_us122l_usb_driver);
702030a07e4SKarsten Wiese }
703030a07e4SKarsten Wiese 
704030a07e4SKarsten Wiese static void __exit snd_us122l_module_exit(void)
705030a07e4SKarsten Wiese {
706030a07e4SKarsten Wiese 	usb_deregister(&snd_us122l_usb_driver);
707030a07e4SKarsten Wiese }
708030a07e4SKarsten Wiese 
709030a07e4SKarsten Wiese module_init(snd_us122l_module_init)
710030a07e4SKarsten Wiese module_exit(snd_us122l_module_exit)
711