forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/usb/caiaq/audio.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2006-2008 Daniel Mack, Karsten Wiese
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
174 */
185
196 #include <linux/device.h>
....@@ -43,7 +30,7 @@
4330 #define MAKE_CHECKBYTE(cdev,stream,i) \
4431 (stream << 1) | (~(i / (cdev->n_streams * BYTES_PER_SAMPLE_USB)) & 1)
4532
46
-static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
33
+static const struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
4734 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
4835 SNDRV_PCM_INFO_BLOCK_TRANSFER),
4936 .formats = SNDRV_PCM_FMTBIT_S24_3BE,
....@@ -180,18 +167,11 @@
180167 return 0;
181168 }
182169
183
-static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
184
- struct snd_pcm_hw_params *hw_params)
185
-{
186
- return snd_pcm_lib_alloc_vmalloc_buffer(sub,
187
- params_buffer_bytes(hw_params));
188
-}
189
-
190170 static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
191171 {
192172 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
193173 deactivate_substream(cdev, sub);
194
- return snd_pcm_lib_free_vmalloc_buffer(sub);
174
+ return 0;
195175 }
196176
197177 /* this should probably go upstream */
....@@ -199,7 +179,7 @@
199179 #error "Change this table"
200180 #endif
201181
202
-static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
182
+static const unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
203183 48000, 64000, 88200, 96000, 176400, 192000 };
204184
205185 static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
....@@ -341,13 +321,10 @@
341321 static const struct snd_pcm_ops snd_usb_caiaq_ops = {
342322 .open = snd_usb_caiaq_substream_open,
343323 .close = snd_usb_caiaq_substream_close,
344
- .ioctl = snd_pcm_lib_ioctl,
345
- .hw_params = snd_usb_caiaq_pcm_hw_params,
346324 .hw_free = snd_usb_caiaq_pcm_hw_free,
347325 .prepare = snd_usb_caiaq_pcm_prepare,
348326 .trigger = snd_usb_caiaq_pcm_trigger,
349327 .pointer = snd_usb_caiaq_pcm_pointer,
350
- .page = snd_pcm_lib_get_vmalloc_page,
351328 };
352329
353330 static void check_for_elapsed_periods(struct snd_usb_caiaqdev *cdev,
....@@ -843,7 +820,7 @@
843820 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO):
844821 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE):
845822 cdev->samplerates |= SNDRV_PCM_RATE_192000;
846
- /* fall thru */
823
+ fallthrough;
847824 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ):
848825 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
849826 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
....@@ -856,6 +833,8 @@
856833 &snd_usb_caiaq_ops);
857834 snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_CAPTURE,
858835 &snd_usb_caiaq_ops);
836
+ snd_pcm_set_managed_buffer_all(cdev->pcm, SNDRV_DMA_TYPE_VMALLOC,
837
+ NULL, 0, 0);
859838
860839 cdev->data_cb_info =
861840 kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info),