forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/sound/usb/misc/ua101.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Edirol UA-101/UA-1000 driver
34 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
4
- *
5
- * This driver is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License, version 2.
7
- *
8
- * This driver is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * along with this driver. If not, see <http://www.gnu.org/licenses/>.
155 */
166
177 #include <linux/init.h>
....@@ -106,7 +96,7 @@
10696 u8 rate_feedback[MAX_QUEUE_LENGTH];
10797
10898 struct list_head ready_playback_urbs;
109
- struct tasklet_struct playback_tasklet;
99
+ struct work_struct playback_work;
110100 wait_queue_head_t alsa_capture_wait;
111101 wait_queue_head_t rate_feedback_wait;
112102 wait_queue_head_t alsa_playback_wait;
....@@ -198,7 +188,7 @@
198188 spin_lock_irqsave(&ua->lock, flags);
199189 list_add_tail(&urb->ready_list, &ua->ready_playback_urbs);
200190 if (ua->rate_feedback_count > 0)
201
- tasklet_schedule(&ua->playback_tasklet);
191
+ queue_work(system_highpri_wq, &ua->playback_work);
202192 ua->playback.substream->runtime->delay -=
203193 urb->urb.iso_frame_desc[0].length /
204194 ua->playback.frame_bytes;
....@@ -257,9 +247,9 @@
257247 *value -= ua->playback.queue_length;
258248 }
259249
260
-static void playback_tasklet(unsigned long data)
250
+static void playback_work(struct work_struct *work)
261251 {
262
- struct ua101 *ua = (void *)data;
252
+ struct ua101 *ua = container_of(work, struct ua101, playback_work);
263253 unsigned long flags;
264254 unsigned int frames;
265255 struct ua101_urb *urb;
....@@ -411,7 +401,7 @@
411401 }
412402 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) &&
413403 !list_empty(&ua->ready_playback_urbs))
414
- tasklet_schedule(&ua->playback_tasklet);
404
+ queue_work(system_highpri_wq, &ua->playback_work);
415405 }
416406
417407 spin_unlock_irqrestore(&ua->lock, flags);
....@@ -542,7 +532,7 @@
542532
543533 kill_stream_urbs(&ua->playback);
544534
545
- tasklet_kill(&ua->playback_tasklet);
535
+ cancel_work_sync(&ua->playback_work);
546536
547537 disable_iso_interface(ua, INTF_PLAYBACK);
548538 }
....@@ -560,7 +550,7 @@
560550 return 0;
561551
562552 kill_stream_urbs(&ua->playback);
563
- tasklet_kill(&ua->playback_tasklet);
553
+ cancel_work_sync(&ua->playback_work);
564554
565555 err = enable_iso_interface(ua, INTF_PLAYBACK);
566556 if (err < 0)
....@@ -740,11 +730,7 @@
740730 mutex_lock(&ua->mutex);
741731 err = start_usb_capture(ua);
742732 mutex_unlock(&ua->mutex);
743
- if (err < 0)
744
- return err;
745
-
746
- return snd_pcm_lib_alloc_vmalloc_buffer(substream,
747
- params_buffer_bytes(hw_params));
733
+ return err;
748734 }
749735
750736 static int playback_pcm_hw_params(struct snd_pcm_substream *substream,
....@@ -758,16 +744,7 @@
758744 if (err >= 0)
759745 err = start_usb_playback(ua);
760746 mutex_unlock(&ua->mutex);
761
- if (err < 0)
762
- return err;
763
-
764
- return snd_pcm_lib_alloc_vmalloc_buffer(substream,
765
- params_buffer_bytes(hw_params));
766
-}
767
-
768
-static int ua101_pcm_hw_free(struct snd_pcm_substream *substream)
769
-{
770
- return snd_pcm_lib_free_vmalloc_buffer(substream);
747
+ return err;
771748 }
772749
773750 static int capture_pcm_prepare(struct snd_pcm_substream *substream)
....@@ -893,25 +870,19 @@
893870 static const struct snd_pcm_ops capture_pcm_ops = {
894871 .open = capture_pcm_open,
895872 .close = capture_pcm_close,
896
- .ioctl = snd_pcm_lib_ioctl,
897873 .hw_params = capture_pcm_hw_params,
898
- .hw_free = ua101_pcm_hw_free,
899874 .prepare = capture_pcm_prepare,
900875 .trigger = capture_pcm_trigger,
901876 .pointer = capture_pcm_pointer,
902
- .page = snd_pcm_lib_get_vmalloc_page,
903877 };
904878
905879 static const struct snd_pcm_ops playback_pcm_ops = {
906880 .open = playback_pcm_open,
907881 .close = playback_pcm_close,
908
- .ioctl = snd_pcm_lib_ioctl,
909882 .hw_params = playback_pcm_hw_params,
910
- .hw_free = ua101_pcm_hw_free,
911883 .prepare = playback_pcm_prepare,
912884 .trigger = playback_pcm_trigger,
913885 .pointer = playback_pcm_pointer,
914
- .page = snd_pcm_lib_get_vmalloc_page,
915886 };
916887
917888 static const struct uac_format_type_i_discrete_descriptor *
....@@ -1247,8 +1218,7 @@
12471218 spin_lock_init(&ua->lock);
12481219 mutex_init(&ua->mutex);
12491220 INIT_LIST_HEAD(&ua->ready_playback_urbs);
1250
- tasklet_init(&ua->playback_tasklet,
1251
- playback_tasklet, (unsigned long)ua);
1221
+ INIT_WORK(&ua->playback_work, playback_work);
12521222 init_waitqueue_head(&ua->alsa_capture_wait);
12531223 init_waitqueue_head(&ua->rate_feedback_wait);
12541224 init_waitqueue_head(&ua->alsa_playback_wait);
....@@ -1306,6 +1276,8 @@
13061276 strcpy(ua->pcm->name, name);
13071277 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops);
13081278 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops);
1279
+ snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC,
1280
+ NULL, 0, 0);
13091281
13101282 err = snd_usbmidi_create(card, ua->intf[INTF_MIDI],
13111283 &ua->midi_list, &midi_quirk);