forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/pci/aw2/aw2-alsa.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*****************************************************************************
23 *
34 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
45 * Jean-Christian Hassler <jhassler@free.fr>
56 *
67 * This file is part of the Audiowerk2 ALSA driver
7
- *
8
- * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; version 2.
11
- *
12
- * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
- * USA.
218 *
229 *****************************************************************************/
2310 #include <linux/init.h>
....@@ -122,9 +109,6 @@
122109 static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream);
123110 static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream);
124111 static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream);
125
-static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
126
- struct snd_pcm_hw_params *hw_params);
127
-static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream);
128112 static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream);
129113 static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream);
130114 static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
....@@ -182,9 +166,6 @@
182166 static const struct snd_pcm_ops snd_aw2_playback_ops = {
183167 .open = snd_aw2_pcm_playback_open,
184168 .close = snd_aw2_pcm_playback_close,
185
- .ioctl = snd_pcm_lib_ioctl,
186
- .hw_params = snd_aw2_pcm_hw_params,
187
- .hw_free = snd_aw2_pcm_hw_free,
188169 .prepare = snd_aw2_pcm_prepare_playback,
189170 .trigger = snd_aw2_pcm_trigger_playback,
190171 .pointer = snd_aw2_pcm_pointer_playback,
....@@ -194,9 +175,6 @@
194175 static const struct snd_pcm_ops snd_aw2_capture_ops = {
195176 .open = snd_aw2_pcm_capture_open,
196177 .close = snd_aw2_pcm_capture_close,
197
- .ioctl = snd_pcm_lib_ioctl,
198
- .hw_params = snd_aw2_pcm_hw_params,
199
- .hw_free = snd_aw2_pcm_hw_free,
200178 .prepare = snd_aw2_pcm_prepare_capture,
201179 .trigger = snd_aw2_pcm_trigger_capture,
202180 .pointer = snd_aw2_pcm_pointer_capture,
....@@ -245,7 +223,7 @@
245223 {
246224 struct aw2 *chip;
247225 int err;
248
- static struct snd_device_ops ops = {
226
+ static const struct snd_device_ops ops = {
249227 .dev_free = snd_aw2_dev_free,
250228 };
251229
....@@ -284,7 +262,7 @@
284262 }
285263 chip->iobase_phys = pci_resource_start(pci, 0);
286264 chip->iobase_virt =
287
- ioremap_nocache(chip->iobase_phys,
265
+ ioremap(chip->iobase_phys,
288266 pci_resource_len(pci, 0));
289267
290268 if (chip->iobase_virt == NULL) {
....@@ -309,6 +287,7 @@
309287 return -EBUSY;
310288 }
311289 chip->irq = pci->irq;
290
+ card->sync_irq = chip->irq;
312291
313292 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
314293 if (err < 0) {
....@@ -422,20 +401,6 @@
422401 {
423402 /* TODO: something to do ? */
424403 return 0;
425
-}
426
-
427
- /* hw_params callback */
428
-static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
429
- struct snd_pcm_hw_params *hw_params)
430
-{
431
- return snd_pcm_lib_malloc_pages(substream,
432
- params_buffer_bytes(hw_params));
433
-}
434
-
435
-/* hw_free callback */
436
-static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream)
437
-{
438
- return snd_pcm_lib_free_pages(substream);
439404 }
440405
441406 /* prepare callback for playback */
....@@ -624,15 +589,10 @@
624589
625590 /* pre-allocation of buffers */
626591 /* Preallocate continuous pages. */
627
- err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
628
- SNDRV_DMA_TYPE_DEV,
629
- snd_dma_pci_data
630
- (chip->pci),
631
- 64 * 1024, 64 * 1024);
632
- if (err)
633
- dev_err(chip->card->dev,
634
- "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
635
- err);
592
+ snd_pcm_set_managed_buffer_all(pcm_playback_ana,
593
+ SNDRV_DMA_TYPE_DEV,
594
+ &chip->pci->dev,
595
+ 64 * 1024, 64 * 1024);
636596
637597 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
638598 &pcm_playback_num);
....@@ -661,15 +621,10 @@
661621
662622 /* pre-allocation of buffers */
663623 /* Preallocate continuous pages. */
664
- err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
665
- SNDRV_DMA_TYPE_DEV,
666
- snd_dma_pci_data
667
- (chip->pci),
668
- 64 * 1024, 64 * 1024);
669
- if (err)
670
- dev_err(chip->card->dev,
671
- "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
672
- err);
624
+ snd_pcm_set_managed_buffer_all(pcm_playback_num,
625
+ SNDRV_DMA_TYPE_DEV,
626
+ &chip->pci->dev,
627
+ 64 * 1024, 64 * 1024);
673628
674629 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
675630 &pcm_capture);
....@@ -699,16 +654,10 @@
699654
700655 /* pre-allocation of buffers */
701656 /* Preallocate continuous pages. */
702
- err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
703
- SNDRV_DMA_TYPE_DEV,
704
- snd_dma_pci_data
705
- (chip->pci),
706
- 64 * 1024, 64 * 1024);
707
- if (err)
708
- dev_err(chip->card->dev,
709
- "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
710
- err);
711
-
657
+ snd_pcm_set_managed_buffer_all(pcm_capture,
658
+ SNDRV_DMA_TYPE_DEV,
659
+ &chip->pci->dev,
660
+ 64 * 1024, 64 * 1024);
712661
713662 /* Create control */
714663 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));