| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for Tascam US-X2Y USB soundcards |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * FPGA Loader + ALSA Startup |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 10 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | | - * (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License |
|---|
| 19 | | - * along with this program; if not, write to the Free Software |
|---|
| 20 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | 8 | */ |
|---|
| 22 | 9 | |
|---|
| 23 | 10 | #include <linux/interrupt.h> |
|---|
| .. | .. |
|---|
| 42 | 29 | vmf->pgoff); |
|---|
| 43 | 30 | |
|---|
| 44 | 31 | offset = vmf->pgoff << PAGE_SHIFT; |
|---|
| 45 | | - vaddr = (char *)((struct usX2Ydev *)vmf->vma->vm_private_data)->us428ctls_sharedmem + offset; |
|---|
| 32 | + vaddr = (char *)((struct usx2ydev *)vmf->vma->vm_private_data)->us428ctls_sharedmem + offset; |
|---|
| 46 | 33 | page = virt_to_page(vaddr); |
|---|
| 47 | 34 | get_page(page); |
|---|
| 48 | 35 | vmf->page = page; |
|---|
| .. | .. |
|---|
| 60 | 47 | static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) |
|---|
| 61 | 48 | { |
|---|
| 62 | 49 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); |
|---|
| 63 | | - struct usX2Ydev *us428 = hw->private_data; |
|---|
| 50 | + struct usx2ydev *us428 = hw->private_data; |
|---|
| 64 | 51 | |
|---|
| 65 | 52 | // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? |
|---|
| 66 | 53 | // so as long as the device isn't fully initialised yet we return -EBUSY here. |
|---|
| .. | .. |
|---|
| 75 | 62 | |
|---|
| 76 | 63 | if (!us428->us428ctls_sharedmem) { |
|---|
| 77 | 64 | init_waitqueue_head(&us428->us428ctls_wait_queue_head); |
|---|
| 78 | | - if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(struct us428ctls_sharedmem), GFP_KERNEL))) |
|---|
| 65 | + us428->us428ctls_sharedmem = alloc_pages_exact(sizeof(struct us428ctls_sharedmem), GFP_KERNEL); |
|---|
| 66 | + if (!us428->us428ctls_sharedmem) |
|---|
| 79 | 67 | return -ENOMEM; |
|---|
| 80 | 68 | memset(us428->us428ctls_sharedmem, -1, sizeof(struct us428ctls_sharedmem)); |
|---|
| 81 | | - us428->us428ctls_sharedmem->CtlSnapShotLast = -2; |
|---|
| 69 | + us428->us428ctls_sharedmem->ctl_snapshot_last = -2; |
|---|
| 82 | 70 | } |
|---|
| 83 | 71 | area->vm_ops = &us428ctls_vm_ops; |
|---|
| 84 | 72 | area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; |
|---|
| .. | .. |
|---|
| 89 | 77 | static __poll_t snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) |
|---|
| 90 | 78 | { |
|---|
| 91 | 79 | __poll_t mask = 0; |
|---|
| 92 | | - struct usX2Ydev *us428 = hw->private_data; |
|---|
| 80 | + struct usx2ydev *us428 = hw->private_data; |
|---|
| 93 | 81 | struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem; |
|---|
| 94 | 82 | if (us428->chip_status & USX2Y_STAT_CHIP_HUP) |
|---|
| 95 | 83 | return EPOLLHUP; |
|---|
| 96 | 84 | |
|---|
| 97 | 85 | poll_wait(file, &us428->us428ctls_wait_queue_head, wait); |
|---|
| 98 | 86 | |
|---|
| 99 | | - if (shm != NULL && shm->CtlSnapShotLast != shm->CtlSnapShotRed) |
|---|
| 87 | + if (shm != NULL && shm->ctl_snapshot_last != shm->ctl_snapshot_red) |
|---|
| 100 | 88 | mask |= EPOLLIN; |
|---|
| 101 | 89 | |
|---|
| 102 | 90 | return mask; |
|---|
| 103 | 91 | } |
|---|
| 104 | 92 | |
|---|
| 105 | 93 | |
|---|
| 106 | | -static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, |
|---|
| 94 | +static int snd_usx2y_hwdep_dsp_status(struct snd_hwdep *hw, |
|---|
| 107 | 95 | struct snd_hwdep_dsp_status *info) |
|---|
| 108 | 96 | { |
|---|
| 109 | | - static char *type_ids[USX2Y_TYPE_NUMS] = { |
|---|
| 97 | + static const char * const type_ids[USX2Y_TYPE_NUMS] = { |
|---|
| 110 | 98 | [USX2Y_TYPE_122] = "us122", |
|---|
| 111 | 99 | [USX2Y_TYPE_224] = "us224", |
|---|
| 112 | 100 | [USX2Y_TYPE_428] = "us428", |
|---|
| 113 | 101 | }; |
|---|
| 114 | | - struct usX2Ydev *us428 = hw->private_data; |
|---|
| 102 | + struct usx2ydev *us428 = hw->private_data; |
|---|
| 115 | 103 | int id = -1; |
|---|
| 116 | 104 | |
|---|
| 117 | 105 | switch (le16_to_cpu(us428->dev->descriptor.idProduct)) { |
|---|
| .. | .. |
|---|
| 136 | 124 | } |
|---|
| 137 | 125 | |
|---|
| 138 | 126 | |
|---|
| 139 | | -static int usX2Y_create_usbmidi(struct snd_card *card) |
|---|
| 127 | +static int usx2y_create_usbmidi(struct snd_card *card) |
|---|
| 140 | 128 | { |
|---|
| 141 | | - static struct snd_usb_midi_endpoint_info quirk_data_1 = { |
|---|
| 129 | + static const struct snd_usb_midi_endpoint_info quirk_data_1 = { |
|---|
| 142 | 130 | .out_ep = 0x06, |
|---|
| 143 | 131 | .in_ep = 0x06, |
|---|
| 144 | 132 | .out_cables = 0x001, |
|---|
| 145 | 133 | .in_cables = 0x001 |
|---|
| 146 | 134 | }; |
|---|
| 147 | | - static struct snd_usb_audio_quirk quirk_1 = { |
|---|
| 135 | + static const struct snd_usb_audio_quirk quirk_1 = { |
|---|
| 148 | 136 | .vendor_name = "TASCAM", |
|---|
| 149 | 137 | .product_name = NAME_ALLCAPS, |
|---|
| 150 | 138 | .ifnum = 0, |
|---|
| 151 | 139 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
|---|
| 152 | 140 | .data = &quirk_data_1 |
|---|
| 153 | 141 | }; |
|---|
| 154 | | - static struct snd_usb_midi_endpoint_info quirk_data_2 = { |
|---|
| 142 | + static const struct snd_usb_midi_endpoint_info quirk_data_2 = { |
|---|
| 155 | 143 | .out_ep = 0x06, |
|---|
| 156 | 144 | .in_ep = 0x06, |
|---|
| 157 | 145 | .out_cables = 0x003, |
|---|
| 158 | 146 | .in_cables = 0x003 |
|---|
| 159 | 147 | }; |
|---|
| 160 | | - static struct snd_usb_audio_quirk quirk_2 = { |
|---|
| 148 | + static const struct snd_usb_audio_quirk quirk_2 = { |
|---|
| 161 | 149 | .vendor_name = "TASCAM", |
|---|
| 162 | 150 | .product_name = "US428", |
|---|
| 163 | 151 | .ifnum = 0, |
|---|
| 164 | 152 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
|---|
| 165 | 153 | .data = &quirk_data_2 |
|---|
| 166 | 154 | }; |
|---|
| 167 | | - struct usb_device *dev = usX2Y(card)->dev; |
|---|
| 155 | + struct usb_device *dev = usx2y(card)->dev; |
|---|
| 168 | 156 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); |
|---|
| 169 | | - struct snd_usb_audio_quirk *quirk = |
|---|
| 157 | + const struct snd_usb_audio_quirk *quirk = |
|---|
| 170 | 158 | le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? |
|---|
| 171 | 159 | &quirk_2 : &quirk_1; |
|---|
| 172 | 160 | |
|---|
| 173 | | - snd_printdd("usX2Y_create_usbmidi \n"); |
|---|
| 174 | | - return snd_usbmidi_create(card, iface, &usX2Y(card)->midi_list, quirk); |
|---|
| 161 | + snd_printdd("usx2y_create_usbmidi \n"); |
|---|
| 162 | + return snd_usbmidi_create(card, iface, &usx2y(card)->midi_list, quirk); |
|---|
| 175 | 163 | } |
|---|
| 176 | 164 | |
|---|
| 177 | | -static int usX2Y_create_alsa_devices(struct snd_card *card) |
|---|
| 165 | +static int usx2y_create_alsa_devices(struct snd_card *card) |
|---|
| 178 | 166 | { |
|---|
| 179 | 167 | int err; |
|---|
| 180 | 168 | |
|---|
| 181 | 169 | do { |
|---|
| 182 | | - if ((err = usX2Y_create_usbmidi(card)) < 0) { |
|---|
| 183 | | - snd_printk(KERN_ERR "usX2Y_create_alsa_devices: usX2Y_create_usbmidi error %i \n", err); |
|---|
| 170 | + if ((err = usx2y_create_usbmidi(card)) < 0) { |
|---|
| 171 | + snd_printk(KERN_ERR "usx2y_create_alsa_devices: usx2y_create_usbmidi error %i \n", err); |
|---|
| 184 | 172 | break; |
|---|
| 185 | 173 | } |
|---|
| 186 | | - if ((err = usX2Y_audio_create(card)) < 0) |
|---|
| 174 | + if ((err = usx2y_audio_create(card)) < 0) |
|---|
| 187 | 175 | break; |
|---|
| 188 | | - if ((err = usX2Y_hwdep_pcm_new(card)) < 0) |
|---|
| 176 | + if ((err = usx2y_hwdep_pcm_new(card)) < 0) |
|---|
| 189 | 177 | break; |
|---|
| 190 | 178 | if ((err = snd_card_register(card)) < 0) |
|---|
| 191 | 179 | break; |
|---|
| .. | .. |
|---|
| 194 | 182 | return err; |
|---|
| 195 | 183 | } |
|---|
| 196 | 184 | |
|---|
| 197 | | -static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, |
|---|
| 185 | +static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw, |
|---|
| 198 | 186 | struct snd_hwdep_dsp_image *dsp) |
|---|
| 199 | 187 | { |
|---|
| 200 | | - struct usX2Ydev *priv = hw->private_data; |
|---|
| 188 | + struct usx2ydev *priv = hw->private_data; |
|---|
| 201 | 189 | struct usb_device* dev = priv->dev; |
|---|
| 202 | 190 | int lret, err; |
|---|
| 203 | 191 | char *buf; |
|---|
| .. | .. |
|---|
| 218 | 206 | return err; |
|---|
| 219 | 207 | if (dsp->index == 1) { |
|---|
| 220 | 208 | msleep(250); // give the device some time |
|---|
| 221 | | - err = usX2Y_AsyncSeq04_init(priv); |
|---|
| 209 | + err = usx2y_async_seq04_init(priv); |
|---|
| 222 | 210 | if (err) { |
|---|
| 223 | | - snd_printk(KERN_ERR "usX2Y_AsyncSeq04_init error \n"); |
|---|
| 211 | + snd_printk(KERN_ERR "usx2y_async_seq04_init error \n"); |
|---|
| 224 | 212 | return err; |
|---|
| 225 | 213 | } |
|---|
| 226 | | - err = usX2Y_In04_init(priv); |
|---|
| 214 | + err = usx2y_in04_init(priv); |
|---|
| 227 | 215 | if (err) { |
|---|
| 228 | | - snd_printk(KERN_ERR "usX2Y_In04_init error \n"); |
|---|
| 216 | + snd_printk(KERN_ERR "usx2y_in04_init error \n"); |
|---|
| 229 | 217 | return err; |
|---|
| 230 | 218 | } |
|---|
| 231 | | - err = usX2Y_create_alsa_devices(hw->card); |
|---|
| 219 | + err = usx2y_create_alsa_devices(hw->card); |
|---|
| 232 | 220 | if (err) { |
|---|
| 233 | | - snd_printk(KERN_ERR "usX2Y_create_alsa_devices error %i \n", err); |
|---|
| 221 | + snd_printk(KERN_ERR "usx2y_create_alsa_devices error %i \n", err); |
|---|
| 234 | 222 | snd_card_free(hw->card); |
|---|
| 235 | 223 | return err; |
|---|
| 236 | 224 | } |
|---|
| .. | .. |
|---|
| 241 | 229 | } |
|---|
| 242 | 230 | |
|---|
| 243 | 231 | |
|---|
| 244 | | -int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device) |
|---|
| 232 | +int usx2y_hwdep_new(struct snd_card *card, struct usb_device* device) |
|---|
| 245 | 233 | { |
|---|
| 246 | 234 | int err; |
|---|
| 247 | 235 | struct snd_hwdep *hw; |
|---|
| .. | .. |
|---|
| 250 | 238 | return err; |
|---|
| 251 | 239 | |
|---|
| 252 | 240 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y; |
|---|
| 253 | | - hw->private_data = usX2Y(card); |
|---|
| 254 | | - hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; |
|---|
| 255 | | - hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; |
|---|
| 241 | + hw->private_data = usx2y(card); |
|---|
| 242 | + hw->ops.dsp_status = snd_usx2y_hwdep_dsp_status; |
|---|
| 243 | + hw->ops.dsp_load = snd_usx2y_hwdep_dsp_load; |
|---|
| 256 | 244 | hw->ops.mmap = snd_us428ctls_mmap; |
|---|
| 257 | 245 | hw->ops.poll = snd_us428ctls_poll; |
|---|
| 258 | 246 | hw->exclusive = 1; |
|---|