forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/pci/oxygen/oxygen_pcm.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * C-Media CMI8788 driver - PCM code
34 *
45 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5
- *
6
- *
7
- * This driver is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License, version 2.
9
- *
10
- * This driver is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this driver; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
186 */
197
208 #include <linux/pci.h>
....@@ -149,7 +137,7 @@
149137 SNDRV_PCM_RATE_64000);
150138 runtime->hw.rate_min = 44100;
151139 }
152
- /* fall through */
140
+ fallthrough;
153141 case PCM_A:
154142 case PCM_B:
155143 runtime->hw.fifo_size = 0;
....@@ -316,12 +304,6 @@
316304 {
317305 struct oxygen *chip = snd_pcm_substream_chip(substream);
318306 unsigned int channel = oxygen_substream_channel(substream);
319
- int err;
320
-
321
- err = snd_pcm_lib_malloc_pages(substream,
322
- params_buffer_bytes(hw_params));
323
- if (err < 0)
324
- return err;
325307
326308 oxygen_write32(chip, channel_base_registers[channel],
327309 (u32)substream->runtime->dma_addr);
....@@ -541,7 +523,7 @@
541523 oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask);
542524 spin_unlock_irq(&chip->reg_lock);
543525
544
- return snd_pcm_lib_free_pages(substream);
526
+ return 0;
545527 }
546528
547529 static int oxygen_spdif_hw_free(struct snd_pcm_substream *substream)
....@@ -634,7 +616,6 @@
634616 static const struct snd_pcm_ops oxygen_rec_a_ops = {
635617 .open = oxygen_rec_a_open,
636618 .close = oxygen_close,
637
- .ioctl = snd_pcm_lib_ioctl,
638619 .hw_params = oxygen_rec_a_hw_params,
639620 .hw_free = oxygen_hw_free,
640621 .prepare = oxygen_prepare,
....@@ -645,7 +626,6 @@
645626 static const struct snd_pcm_ops oxygen_rec_b_ops = {
646627 .open = oxygen_rec_b_open,
647628 .close = oxygen_close,
648
- .ioctl = snd_pcm_lib_ioctl,
649629 .hw_params = oxygen_rec_b_hw_params,
650630 .hw_free = oxygen_hw_free,
651631 .prepare = oxygen_prepare,
....@@ -656,7 +636,6 @@
656636 static const struct snd_pcm_ops oxygen_rec_c_ops = {
657637 .open = oxygen_rec_c_open,
658638 .close = oxygen_close,
659
- .ioctl = snd_pcm_lib_ioctl,
660639 .hw_params = oxygen_rec_c_hw_params,
661640 .hw_free = oxygen_hw_free,
662641 .prepare = oxygen_prepare,
....@@ -667,7 +646,6 @@
667646 static const struct snd_pcm_ops oxygen_spdif_ops = {
668647 .open = oxygen_spdif_open,
669648 .close = oxygen_close,
670
- .ioctl = snd_pcm_lib_ioctl,
671649 .hw_params = oxygen_spdif_hw_params,
672650 .hw_free = oxygen_spdif_hw_free,
673651 .prepare = oxygen_prepare,
....@@ -678,7 +656,6 @@
678656 static const struct snd_pcm_ops oxygen_multich_ops = {
679657 .open = oxygen_multich_open,
680658 .close = oxygen_close,
681
- .ioctl = snd_pcm_lib_ioctl,
682659 .hw_params = oxygen_multich_hw_params,
683660 .hw_free = oxygen_hw_free,
684661 .prepare = oxygen_prepare,
....@@ -689,7 +666,6 @@
689666 static const struct snd_pcm_ops oxygen_ac97_ops = {
690667 .open = oxygen_ac97_open,
691668 .close = oxygen_close,
692
- .ioctl = snd_pcm_lib_ioctl,
693669 .hw_params = oxygen_hw_params,
694670 .hw_free = oxygen_hw_free,
695671 .prepare = oxygen_prepare,
....@@ -723,17 +699,17 @@
723699 pcm->private_data = chip;
724700 strcpy(pcm->name, "Multichannel");
725701 if (outs)
726
- snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
727
- SNDRV_DMA_TYPE_DEV,
728
- snd_dma_pci_data(chip->pci),
729
- DEFAULT_BUFFER_BYTES_MULTICH,
730
- BUFFER_BYTES_MAX_MULTICH);
702
+ snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
703
+ SNDRV_DMA_TYPE_DEV,
704
+ &chip->pci->dev,
705
+ DEFAULT_BUFFER_BYTES_MULTICH,
706
+ BUFFER_BYTES_MAX_MULTICH);
731707 if (ins)
732
- snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
733
- SNDRV_DMA_TYPE_DEV,
734
- snd_dma_pci_data(chip->pci),
735
- DEFAULT_BUFFER_BYTES,
736
- BUFFER_BYTES_MAX);
708
+ snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
709
+ SNDRV_DMA_TYPE_DEV,
710
+ &chip->pci->dev,
711
+ DEFAULT_BUFFER_BYTES,
712
+ BUFFER_BYTES_MAX);
737713 }
738714
739715 outs = !!(chip->model.device_config & PLAYBACK_1_TO_SPDIF);
....@@ -750,10 +726,10 @@
750726 &oxygen_rec_c_ops);
751727 pcm->private_data = chip;
752728 strcpy(pcm->name, "Digital");
753
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
754
- snd_dma_pci_data(chip->pci),
755
- DEFAULT_BUFFER_BYTES,
756
- BUFFER_BYTES_MAX);
729
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
730
+ &chip->pci->dev,
731
+ DEFAULT_BUFFER_BYTES,
732
+ BUFFER_BYTES_MAX);
757733 }
758734
759735 if (chip->has_ac97_1) {
....@@ -780,10 +756,10 @@
780756 &oxygen_rec_b_ops);
781757 pcm->private_data = chip;
782758 strcpy(pcm->name, outs ? "Front Panel" : "Analog 2");
783
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
784
- snd_dma_pci_data(chip->pci),
785
- DEFAULT_BUFFER_BYTES,
786
- BUFFER_BYTES_MAX);
759
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
760
+ &chip->pci->dev,
761
+ DEFAULT_BUFFER_BYTES,
762
+ BUFFER_BYTES_MAX);
787763 }
788764
789765 ins = !!(chip->model.device_config & CAPTURE_3_FROM_I2S_3);
....@@ -798,10 +774,10 @@
798774 OXYGEN_REC_C_ROUTE_MASK);
799775 pcm->private_data = chip;
800776 strcpy(pcm->name, "Analog 3");
801
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
802
- snd_dma_pci_data(chip->pci),
803
- DEFAULT_BUFFER_BYTES,
804
- BUFFER_BYTES_MAX);
777
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
778
+ &chip->pci->dev,
779
+ DEFAULT_BUFFER_BYTES,
780
+ BUFFER_BYTES_MAX);
805781 }
806782 return 0;
807783 }