forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/usb/usx2y/usX2Yhwdep.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Tascam US-X2Y USB soundcards
34 *
45 * FPGA Loader + ALSA Startup
56 *
67 * 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
218 */
229
2310 #include <linux/interrupt.h>
....@@ -42,7 +29,7 @@
4229 vmf->pgoff);
4330
4431 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;
4633 page = virt_to_page(vaddr);
4734 get_page(page);
4835 vmf->page = page;
....@@ -60,7 +47,7 @@
6047 static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area)
6148 {
6249 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;
6451
6552 // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs?
6653 // so as long as the device isn't fully initialised yet we return -EBUSY here.
....@@ -75,10 +62,11 @@
7562
7663 if (!us428->us428ctls_sharedmem) {
7764 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)
7967 return -ENOMEM;
8068 memset(us428->us428ctls_sharedmem, -1, sizeof(struct us428ctls_sharedmem));
81
- us428->us428ctls_sharedmem->CtlSnapShotLast = -2;
69
+ us428->us428ctls_sharedmem->ctl_snapshot_last = -2;
8270 }
8371 area->vm_ops = &us428ctls_vm_ops;
8472 area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
....@@ -89,29 +77,29 @@
8977 static __poll_t snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait)
9078 {
9179 __poll_t mask = 0;
92
- struct usX2Ydev *us428 = hw->private_data;
80
+ struct usx2ydev *us428 = hw->private_data;
9381 struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem;
9482 if (us428->chip_status & USX2Y_STAT_CHIP_HUP)
9583 return EPOLLHUP;
9684
9785 poll_wait(file, &us428->us428ctls_wait_queue_head, wait);
9886
99
- if (shm != NULL && shm->CtlSnapShotLast != shm->CtlSnapShotRed)
87
+ if (shm != NULL && shm->ctl_snapshot_last != shm->ctl_snapshot_red)
10088 mask |= EPOLLIN;
10189
10290 return mask;
10391 }
10492
10593
106
-static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw,
94
+static int snd_usx2y_hwdep_dsp_status(struct snd_hwdep *hw,
10795 struct snd_hwdep_dsp_status *info)
10896 {
109
- static char *type_ids[USX2Y_TYPE_NUMS] = {
97
+ static const char * const type_ids[USX2Y_TYPE_NUMS] = {
11098 [USX2Y_TYPE_122] = "us122",
11199 [USX2Y_TYPE_224] = "us224",
112100 [USX2Y_TYPE_428] = "us428",
113101 };
114
- struct usX2Ydev *us428 = hw->private_data;
102
+ struct usx2ydev *us428 = hw->private_data;
115103 int id = -1;
116104
117105 switch (le16_to_cpu(us428->dev->descriptor.idProduct)) {
....@@ -136,56 +124,56 @@
136124 }
137125
138126
139
-static int usX2Y_create_usbmidi(struct snd_card *card)
127
+static int usx2y_create_usbmidi(struct snd_card *card)
140128 {
141
- static struct snd_usb_midi_endpoint_info quirk_data_1 = {
129
+ static const struct snd_usb_midi_endpoint_info quirk_data_1 = {
142130 .out_ep = 0x06,
143131 .in_ep = 0x06,
144132 .out_cables = 0x001,
145133 .in_cables = 0x001
146134 };
147
- static struct snd_usb_audio_quirk quirk_1 = {
135
+ static const struct snd_usb_audio_quirk quirk_1 = {
148136 .vendor_name = "TASCAM",
149137 .product_name = NAME_ALLCAPS,
150138 .ifnum = 0,
151139 .type = QUIRK_MIDI_FIXED_ENDPOINT,
152140 .data = &quirk_data_1
153141 };
154
- static struct snd_usb_midi_endpoint_info quirk_data_2 = {
142
+ static const struct snd_usb_midi_endpoint_info quirk_data_2 = {
155143 .out_ep = 0x06,
156144 .in_ep = 0x06,
157145 .out_cables = 0x003,
158146 .in_cables = 0x003
159147 };
160
- static struct snd_usb_audio_quirk quirk_2 = {
148
+ static const struct snd_usb_audio_quirk quirk_2 = {
161149 .vendor_name = "TASCAM",
162150 .product_name = "US428",
163151 .ifnum = 0,
164152 .type = QUIRK_MIDI_FIXED_ENDPOINT,
165153 .data = &quirk_data_2
166154 };
167
- struct usb_device *dev = usX2Y(card)->dev;
155
+ struct usb_device *dev = usx2y(card)->dev;
168156 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 =
170158 le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ?
171159 &quirk_2 : &quirk_1;
172160
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);
175163 }
176164
177
-static int usX2Y_create_alsa_devices(struct snd_card *card)
165
+static int usx2y_create_alsa_devices(struct snd_card *card)
178166 {
179167 int err;
180168
181169 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);
184172 break;
185173 }
186
- if ((err = usX2Y_audio_create(card)) < 0)
174
+ if ((err = usx2y_audio_create(card)) < 0)
187175 break;
188
- if ((err = usX2Y_hwdep_pcm_new(card)) < 0)
176
+ if ((err = usx2y_hwdep_pcm_new(card)) < 0)
189177 break;
190178 if ((err = snd_card_register(card)) < 0)
191179 break;
....@@ -194,10 +182,10 @@
194182 return err;
195183 }
196184
197
-static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,
185
+static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
198186 struct snd_hwdep_dsp_image *dsp)
199187 {
200
- struct usX2Ydev *priv = hw->private_data;
188
+ struct usx2ydev *priv = hw->private_data;
201189 struct usb_device* dev = priv->dev;
202190 int lret, err;
203191 char *buf;
....@@ -218,19 +206,19 @@
218206 return err;
219207 if (dsp->index == 1) {
220208 msleep(250); // give the device some time
221
- err = usX2Y_AsyncSeq04_init(priv);
209
+ err = usx2y_async_seq04_init(priv);
222210 if (err) {
223
- snd_printk(KERN_ERR "usX2Y_AsyncSeq04_init error \n");
211
+ snd_printk(KERN_ERR "usx2y_async_seq04_init error \n");
224212 return err;
225213 }
226
- err = usX2Y_In04_init(priv);
214
+ err = usx2y_in04_init(priv);
227215 if (err) {
228
- snd_printk(KERN_ERR "usX2Y_In04_init error \n");
216
+ snd_printk(KERN_ERR "usx2y_in04_init error \n");
229217 return err;
230218 }
231
- err = usX2Y_create_alsa_devices(hw->card);
219
+ err = usx2y_create_alsa_devices(hw->card);
232220 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);
234222 snd_card_free(hw->card);
235223 return err;
236224 }
....@@ -241,7 +229,7 @@
241229 }
242230
243231
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)
245233 {
246234 int err;
247235 struct snd_hwdep *hw;
....@@ -250,9 +238,9 @@
250238 return err;
251239
252240 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;
256244 hw->ops.mmap = snd_us428ctls_mmap;
257245 hw->ops.poll = snd_us428ctls_poll;
258246 hw->exclusive = 1;