Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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)  * Driver for Tascam US-X2Y USB soundcards
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * FPGA Loader + ALSA Startup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <sound/memalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <sound/hwdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "usx2y.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "usbusx2y.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "usX2Yhwdep.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static vm_fault_t snd_us428ctls_vm_fault(struct vm_fault *vmf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct page * page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	void *vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	snd_printdd("ENTER, start %lXh, pgoff %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		   vmf->vma->vm_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		   vmf->pgoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	offset = vmf->pgoff << PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	vaddr = (char *)((struct usx2ydev *)vmf->vma->vm_private_data)->us428ctls_sharedmem + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	page = virt_to_page(vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	get_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	vmf->page = page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	snd_printdd("vaddr=%p made us428ctls_vm_fault() page %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		    vaddr, page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static const struct vm_operations_struct us428ctls_vm_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	.fault = snd_us428ctls_vm_fault,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	unsigned long	size = (unsigned long)(area->vm_end - area->vm_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct usx2ydev	*us428 = hw->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	// FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	// so as long as the device isn't fully initialised yet we return -EBUSY here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  	if (!(us428->chip_status & USX2Y_STAT_CHIP_INIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	/* if userspace tries to mmap beyond end of our buffer, fail */ 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)         if (size > PAGE_ALIGN(sizeof(struct us428ctls_sharedmem))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(struct us428ctls_sharedmem)); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)                 return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (!us428->us428ctls_sharedmem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		init_waitqueue_head(&us428->us428ctls_wait_queue_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		us428->us428ctls_sharedmem = alloc_pages_exact(sizeof(struct us428ctls_sharedmem), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		if (!us428->us428ctls_sharedmem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		memset(us428->us428ctls_sharedmem, -1, sizeof(struct us428ctls_sharedmem));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		us428->us428ctls_sharedmem->ctl_snapshot_last = -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	area->vm_ops = &us428ctls_vm_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	area->vm_private_data = hw->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static __poll_t snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	__poll_t	mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct usx2ydev	*us428 = hw->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	if (us428->chip_status & USX2Y_STAT_CHIP_HUP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		return EPOLLHUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	poll_wait(file, &us428->us428ctls_wait_queue_head, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (shm != NULL && shm->ctl_snapshot_last != shm->ctl_snapshot_red)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		mask |= EPOLLIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static int snd_usx2y_hwdep_dsp_status(struct snd_hwdep *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 				      struct snd_hwdep_dsp_status *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	static const char * const type_ids[USX2Y_TYPE_NUMS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		[USX2Y_TYPE_122] = "us122",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		[USX2Y_TYPE_224] = "us224",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		[USX2Y_TYPE_428] = "us428",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct usx2ydev	*us428 = hw->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	int id = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	switch (le16_to_cpu(us428->dev->descriptor.idProduct)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	case USB_ID_US122:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		id = USX2Y_TYPE_122;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	case USB_ID_US224:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		id = USX2Y_TYPE_224;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	case USB_ID_US428:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		id = USX2Y_TYPE_428;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (0 > id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	strcpy(info->id, type_ids[id]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	info->num_dsps = 2;		// 0: Prepad Data, 1: FPGA Code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (us428->chip_status & USX2Y_STAT_CHIP_INIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		info->chip_ready = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	info->version = USX2Y_DRIVER_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int usx2y_create_usbmidi(struct snd_card *card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	static const struct snd_usb_midi_endpoint_info quirk_data_1 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.out_ep = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		.in_ep = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		.out_cables =	0x001,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		.in_cables =	0x001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	static const struct snd_usb_audio_quirk quirk_1 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.vendor_name =	"TASCAM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.product_name =	NAME_ALLCAPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.ifnum = 	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)        		.type = QUIRK_MIDI_FIXED_ENDPOINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		.data = &quirk_data_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	static const struct snd_usb_midi_endpoint_info quirk_data_2 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		.out_ep = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		.in_ep = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		.out_cables =	0x003,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		.in_cables =	0x003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	static const struct snd_usb_audio_quirk quirk_2 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		.vendor_name =	"TASCAM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		.product_name =	"US428",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		.ifnum = 	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)        		.type = QUIRK_MIDI_FIXED_ENDPOINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		.data = &quirk_data_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct usb_device *dev = usx2y(card)->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct usb_interface *iface = usb_ifnum_to_if(dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	const struct snd_usb_audio_quirk *quirk =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		&quirk_2 : &quirk_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	snd_printdd("usx2y_create_usbmidi \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	return snd_usbmidi_create(card, iface, &usx2y(card)->midi_list, quirk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static int usx2y_create_alsa_devices(struct snd_card *card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		if ((err = usx2y_create_usbmidi(card)) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			snd_printk(KERN_ERR "usx2y_create_alsa_devices: usx2y_create_usbmidi error %i \n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		if ((err = usx2y_audio_create(card)) < 0) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		if ((err = usx2y_hwdep_pcm_new(card)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		if ((err = snd_card_register(card)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	} while (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) } 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				    struct snd_hwdep_dsp_image *dsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	struct usx2ydev *priv = hw->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct usb_device* dev = priv->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	int lret, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	snd_printdd( "dsp_load %s\n", dsp->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	buf = memdup_user(dsp->image, dsp->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (IS_ERR(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		return PTR_ERR(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	err = usb_set_interface(dev, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		snd_printk(KERN_ERR "usb_set_interface error \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		err = usb_bulk_msg(dev, usb_sndbulkpipe(dev, 2), buf, dsp->length, &lret, 6000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (dsp->index == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		msleep(250);				// give the device some time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		err = usx2y_async_seq04_init(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			snd_printk(KERN_ERR "usx2y_async_seq04_init error \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		err = usx2y_in04_init(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			snd_printk(KERN_ERR "usx2y_in04_init error \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		err = usx2y_create_alsa_devices(hw->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			snd_printk(KERN_ERR "usx2y_create_alsa_devices error %i \n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			snd_card_free(hw->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		priv->chip_status |= USX2Y_STAT_CHIP_INIT; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		snd_printdd("%s: alsa all started\n", hw->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) int usx2y_hwdep_new(struct snd_card *card, struct usb_device* device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	struct snd_hwdep *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if ((err = snd_hwdep_new(card, SND_USX2Y_LOADER_ID, 0, &hw)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	hw->iface = SNDRV_HWDEP_IFACE_USX2Y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	hw->private_data = usx2y(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	hw->ops.dsp_status = snd_usx2y_hwdep_dsp_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	hw->ops.dsp_load = snd_usx2y_hwdep_dsp_load;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	hw->ops.mmap = snd_us428ctls_mmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	hw->ops.poll = snd_us428ctls_poll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	hw->exclusive = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	sprintf(hw->name, "/dev/bus/usb/%03d/%03d", device->bus->busnum, device->devnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)