diff options
Diffstat (limited to 'sound/usb/usx2y/usX2Yhwdep.c')
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 8abe08611df6..4b52d18dcd53 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "usbusx2y.h" | 31 | #include "usbusx2y.h" |
32 | #include "usX2Yhwdep.h" | 32 | #include "usX2Yhwdep.h" |
33 | 33 | ||
34 | int usX2Y_hwdep_pcm_new(snd_card_t* card); | 34 | int usX2Y_hwdep_pcm_new(struct snd_card *card); |
35 | 35 | ||
36 | 36 | ||
37 | static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type) | 37 | static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type) |
@@ -49,7 +49,7 @@ static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsign | |||
49 | offset = area->vm_pgoff << PAGE_SHIFT; | 49 | offset = area->vm_pgoff << PAGE_SHIFT; |
50 | offset += address - area->vm_start; | 50 | offset += address - area->vm_start; |
51 | snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); | 51 | snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); |
52 | vaddr = (char*)((usX2Ydev_t*)area->vm_private_data)->us428ctls_sharedmem + offset; | 52 | vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset; |
53 | page = virt_to_page(vaddr); | 53 | page = virt_to_page(vaddr); |
54 | get_page(page); | 54 | get_page(page); |
55 | snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset); | 55 | snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset); |
@@ -64,27 +64,27 @@ static struct vm_operations_struct us428ctls_vm_ops = { | |||
64 | .nopage = snd_us428ctls_vm_nopage, | 64 | .nopage = snd_us428ctls_vm_nopage, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) | 67 | static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) |
68 | { | 68 | { |
69 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); | 69 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); |
70 | usX2Ydev_t *us428 = (usX2Ydev_t*)hw->private_data; | 70 | struct usX2Ydev *us428 = hw->private_data; |
71 | 71 | ||
72 | // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? | 72 | // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? |
73 | // so as long as the device isn't fully initialised yet we return -EBUSY here. | 73 | // so as long as the device isn't fully initialised yet we return -EBUSY here. |
74 | if (!(((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT)) | 74 | if (!(us428->chip_status & USX2Y_STAT_CHIP_INIT)) |
75 | return -EBUSY; | 75 | return -EBUSY; |
76 | 76 | ||
77 | /* if userspace tries to mmap beyond end of our buffer, fail */ | 77 | /* if userspace tries to mmap beyond end of our buffer, fail */ |
78 | if (size > ((PAGE_SIZE - 1 + sizeof(us428ctls_sharedmem_t)) / PAGE_SIZE) * PAGE_SIZE) { | 78 | if (size > PAGE_ALIGN(sizeof(struct us428ctls_sharedmem))) { |
79 | snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(us428ctls_sharedmem_t)); | 79 | snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(struct us428ctls_sharedmem)); |
80 | return -EINVAL; | 80 | return -EINVAL; |
81 | } | 81 | } |
82 | 82 | ||
83 | if (!us428->us428ctls_sharedmem) { | 83 | if (!us428->us428ctls_sharedmem) { |
84 | init_waitqueue_head(&us428->us428ctls_wait_queue_head); | 84 | init_waitqueue_head(&us428->us428ctls_wait_queue_head); |
85 | if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(us428ctls_sharedmem_t), GFP_KERNEL))) | 85 | if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(struct us428ctls_sharedmem), GFP_KERNEL))) |
86 | return -ENOMEM; | 86 | return -ENOMEM; |
87 | memset(us428->us428ctls_sharedmem, -1, sizeof(us428ctls_sharedmem_t)); | 87 | memset(us428->us428ctls_sharedmem, -1, sizeof(struct us428ctls_sharedmem)); |
88 | us428->us428ctls_sharedmem->CtlSnapShotLast = -2; | 88 | us428->us428ctls_sharedmem->CtlSnapShotLast = -2; |
89 | } | 89 | } |
90 | area->vm_ops = &us428ctls_vm_ops; | 90 | area->vm_ops = &us428ctls_vm_ops; |
@@ -93,11 +93,11 @@ static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_are | |||
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_table *wait) | 96 | static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) |
97 | { | 97 | { |
98 | unsigned int mask = 0; | 98 | unsigned int mask = 0; |
99 | usX2Ydev_t *us428 = (usX2Ydev_t*)hw->private_data; | 99 | struct usX2Ydev *us428 = hw->private_data; |
100 | us428ctls_sharedmem_t *shm = us428->us428ctls_sharedmem; | 100 | struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem; |
101 | if (us428->chip_status & USX2Y_STAT_CHIP_HUP) | 101 | if (us428->chip_status & USX2Y_STAT_CHIP_HUP) |
102 | return POLLHUP; | 102 | return POLLHUP; |
103 | 103 | ||
@@ -110,26 +110,28 @@ static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_ | |||
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | static int snd_usX2Y_hwdep_open(snd_hwdep_t *hw, struct file *file) | 113 | static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file) |
114 | { | 114 | { |
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static int snd_usX2Y_hwdep_release(snd_hwdep_t *hw, struct file *file) | 118 | static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file) |
119 | { | 119 | { |
120 | return 0; | 120 | return 0; |
121 | } | 121 | } |
122 | 122 | ||
123 | static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) | 123 | static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, |
124 | struct snd_hwdep_dsp_status *info) | ||
124 | { | 125 | { |
125 | static char *type_ids[USX2Y_TYPE_NUMS] = { | 126 | static char *type_ids[USX2Y_TYPE_NUMS] = { |
126 | [USX2Y_TYPE_122] = "us122", | 127 | [USX2Y_TYPE_122] = "us122", |
127 | [USX2Y_TYPE_224] = "us224", | 128 | [USX2Y_TYPE_224] = "us224", |
128 | [USX2Y_TYPE_428] = "us428", | 129 | [USX2Y_TYPE_428] = "us428", |
129 | }; | 130 | }; |
131 | struct usX2Ydev *us428 = hw->private_data; | ||
130 | int id = -1; | 132 | int id = -1; |
131 | 133 | ||
132 | switch (le16_to_cpu(((usX2Ydev_t*)hw->private_data)->chip.dev->descriptor.idProduct)) { | 134 | switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { |
133 | case USB_ID_US122: | 135 | case USB_ID_US122: |
134 | id = USX2Y_TYPE_122; | 136 | id = USX2Y_TYPE_122; |
135 | break; | 137 | break; |
@@ -144,35 +146,35 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i | |||
144 | return -ENODEV; | 146 | return -ENODEV; |
145 | strcpy(info->id, type_ids[id]); | 147 | strcpy(info->id, type_ids[id]); |
146 | info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code | 148 | info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code |
147 | if (((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT) | 149 | if (us428->chip_status & USX2Y_STAT_CHIP_INIT) |
148 | info->chip_ready = 1; | 150 | info->chip_ready = 1; |
149 | info->version = USX2Y_DRIVER_VERSION; | 151 | info->version = USX2Y_DRIVER_VERSION; |
150 | return 0; | 152 | return 0; |
151 | } | 153 | } |
152 | 154 | ||
153 | 155 | ||
154 | static int usX2Y_create_usbmidi(snd_card_t* card ) | 156 | static int usX2Y_create_usbmidi(struct snd_card *card) |
155 | { | 157 | { |
156 | static snd_usb_midi_endpoint_info_t quirk_data_1 = { | 158 | static struct snd_usb_midi_endpoint_info quirk_data_1 = { |
157 | .out_ep =0x06, | 159 | .out_ep = 0x06, |
158 | .in_ep = 0x06, | 160 | .in_ep = 0x06, |
159 | .out_cables = 0x001, | 161 | .out_cables = 0x001, |
160 | .in_cables = 0x001 | 162 | .in_cables = 0x001 |
161 | }; | 163 | }; |
162 | static snd_usb_audio_quirk_t quirk_1 = { | 164 | static struct snd_usb_audio_quirk quirk_1 = { |
163 | .vendor_name = "TASCAM", | 165 | .vendor_name = "TASCAM", |
164 | .product_name = NAME_ALLCAPS, | 166 | .product_name = NAME_ALLCAPS, |
165 | .ifnum = 0, | 167 | .ifnum = 0, |
166 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 168 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
167 | .data = &quirk_data_1 | 169 | .data = &quirk_data_1 |
168 | }; | 170 | }; |
169 | static snd_usb_midi_endpoint_info_t quirk_data_2 = { | 171 | static struct snd_usb_midi_endpoint_info quirk_data_2 = { |
170 | .out_ep =0x06, | 172 | .out_ep = 0x06, |
171 | .in_ep = 0x06, | 173 | .in_ep = 0x06, |
172 | .out_cables = 0x003, | 174 | .out_cables = 0x003, |
173 | .in_cables = 0x003 | 175 | .in_cables = 0x003 |
174 | }; | 176 | }; |
175 | static snd_usb_audio_quirk_t quirk_2 = { | 177 | static struct snd_usb_audio_quirk quirk_2 = { |
176 | .vendor_name = "TASCAM", | 178 | .vendor_name = "TASCAM", |
177 | .product_name = "US428", | 179 | .product_name = "US428", |
178 | .ifnum = 0, | 180 | .ifnum = 0, |
@@ -181,13 +183,15 @@ static int usX2Y_create_usbmidi(snd_card_t* card ) | |||
181 | }; | 183 | }; |
182 | struct usb_device *dev = usX2Y(card)->chip.dev; | 184 | struct usb_device *dev = usX2Y(card)->chip.dev; |
183 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); | 185 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); |
184 | snd_usb_audio_quirk_t *quirk = le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? &quirk_2 : &quirk_1; | 186 | struct snd_usb_audio_quirk *quirk = |
187 | le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? | ||
188 | &quirk_2 : &quirk_1; | ||
185 | 189 | ||
186 | snd_printdd("usX2Y_create_usbmidi \n"); | 190 | snd_printdd("usX2Y_create_usbmidi \n"); |
187 | return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); | 191 | return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); |
188 | } | 192 | } |
189 | 193 | ||
190 | static int usX2Y_create_alsa_devices(snd_card_t* card) | 194 | static int usX2Y_create_alsa_devices(struct snd_card *card) |
191 | { | 195 | { |
192 | int err; | 196 | int err; |
193 | 197 | ||
@@ -207,9 +211,10 @@ static int usX2Y_create_alsa_devices(snd_card_t* card) | |||
207 | return err; | 211 | return err; |
208 | } | 212 | } |
209 | 213 | ||
210 | static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) | 214 | static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, |
215 | struct snd_hwdep_dsp_image *dsp) | ||
211 | { | 216 | { |
212 | usX2Ydev_t *priv = hw->private_data; | 217 | struct usX2Ydev *priv = hw->private_data; |
213 | int lret, err = -EINVAL; | 218 | int lret, err = -EINVAL; |
214 | snd_printdd( "dsp_load %s\n", dsp->name); | 219 | snd_printdd( "dsp_load %s\n", dsp->name); |
215 | 220 | ||
@@ -256,10 +261,10 @@ static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) | |||
256 | } | 261 | } |
257 | 262 | ||
258 | 263 | ||
259 | int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device) | 264 | int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device) |
260 | { | 265 | { |
261 | int err; | 266 | int err; |
262 | snd_hwdep_t *hw; | 267 | struct snd_hwdep *hw; |
263 | 268 | ||
264 | if ((err = snd_hwdep_new(card, SND_USX2Y_LOADER_ID, 0, &hw)) < 0) | 269 | if ((err = snd_hwdep_new(card, SND_USX2Y_LOADER_ID, 0, &hw)) < 0) |
265 | return err; | 270 | return err; |