forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/usb/hiface/pcm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Linux driver for M2Tech hiFace compatible devices
34 *
....@@ -7,11 +8,6 @@
78 * Antonio Ospite <ao2@amarulasolutions.com>
89 *
910 * The driver is based on the work done in TerraTec DMX 6Fire USB
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
1511 */
1612
1713 #include <linux/slab.h>
....@@ -160,16 +156,14 @@
160156 * This control message doesn't have any ack from the
161157 * other side
162158 */
163
- ret = usb_control_msg(device, usb_sndctrlpipe(device, 0),
164
- HIFACE_SET_RATE_REQUEST,
165
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
166
- rate_value, 0, NULL, 0, 100);
167
- if (ret < 0) {
159
+ ret = usb_control_msg_send(device, 0,
160
+ HIFACE_SET_RATE_REQUEST,
161
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
162
+ rate_value, 0, NULL, 0, 100, GFP_KERNEL);
163
+ if (ret)
168164 dev_err(&device->dev, "Error setting samplerate %d.\n", rate);
169
- return ret;
170
- }
171165
172
- return 0;
166
+ return ret;
173167 }
174168
175169 static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream
....@@ -419,18 +413,6 @@
419413 return 0;
420414 }
421415
422
-static int hiface_pcm_hw_params(struct snd_pcm_substream *alsa_sub,
423
- struct snd_pcm_hw_params *hw_params)
424
-{
425
- return snd_pcm_lib_alloc_vmalloc_buffer(alsa_sub,
426
- params_buffer_bytes(hw_params));
427
-}
428
-
429
-static int hiface_pcm_hw_free(struct snd_pcm_substream *alsa_sub)
430
-{
431
- return snd_pcm_lib_free_vmalloc_buffer(alsa_sub);
432
-}
433
-
434416 static int hiface_pcm_prepare(struct snd_pcm_substream *alsa_sub)
435417 {
436418 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub);
....@@ -516,13 +498,9 @@
516498 static const struct snd_pcm_ops pcm_ops = {
517499 .open = hiface_pcm_open,
518500 .close = hiface_pcm_close,
519
- .ioctl = snd_pcm_lib_ioctl,
520
- .hw_params = hiface_pcm_hw_params,
521
- .hw_free = hiface_pcm_hw_free,
522501 .prepare = hiface_pcm_prepare,
523502 .trigger = hiface_pcm_trigger,
524503 .pointer = hiface_pcm_pointer,
525
- .page = snd_pcm_lib_get_vmalloc_page,
526504 };
527505
528506 static int hiface_pcm_init_urb(struct pcm_urb *urb,
....@@ -618,6 +596,8 @@
618596
619597 strlcpy(pcm->name, "USB-SPDIF Audio", sizeof(pcm->name));
620598 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops);
599
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
600
+ NULL, 0, 0);
621601
622602 rt->instance = pcm;
623603