.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * C-Media CMI8788 driver - PCM code |
---|
3 | 4 | * |
---|
4 | 5 | * 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 |
---|
18 | 6 | */ |
---|
19 | 7 | |
---|
20 | 8 | #include <linux/pci.h> |
---|
.. | .. |
---|
149 | 137 | SNDRV_PCM_RATE_64000); |
---|
150 | 138 | runtime->hw.rate_min = 44100; |
---|
151 | 139 | } |
---|
152 | | - /* fall through */ |
---|
| 140 | + fallthrough; |
---|
153 | 141 | case PCM_A: |
---|
154 | 142 | case PCM_B: |
---|
155 | 143 | runtime->hw.fifo_size = 0; |
---|
.. | .. |
---|
316 | 304 | { |
---|
317 | 305 | struct oxygen *chip = snd_pcm_substream_chip(substream); |
---|
318 | 306 | 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; |
---|
325 | 307 | |
---|
326 | 308 | oxygen_write32(chip, channel_base_registers[channel], |
---|
327 | 309 | (u32)substream->runtime->dma_addr); |
---|
.. | .. |
---|
541 | 523 | oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); |
---|
542 | 524 | spin_unlock_irq(&chip->reg_lock); |
---|
543 | 525 | |
---|
544 | | - return snd_pcm_lib_free_pages(substream); |
---|
| 526 | + return 0; |
---|
545 | 527 | } |
---|
546 | 528 | |
---|
547 | 529 | static int oxygen_spdif_hw_free(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
634 | 616 | static const struct snd_pcm_ops oxygen_rec_a_ops = { |
---|
635 | 617 | .open = oxygen_rec_a_open, |
---|
636 | 618 | .close = oxygen_close, |
---|
637 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
638 | 619 | .hw_params = oxygen_rec_a_hw_params, |
---|
639 | 620 | .hw_free = oxygen_hw_free, |
---|
640 | 621 | .prepare = oxygen_prepare, |
---|
.. | .. |
---|
645 | 626 | static const struct snd_pcm_ops oxygen_rec_b_ops = { |
---|
646 | 627 | .open = oxygen_rec_b_open, |
---|
647 | 628 | .close = oxygen_close, |
---|
648 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
649 | 629 | .hw_params = oxygen_rec_b_hw_params, |
---|
650 | 630 | .hw_free = oxygen_hw_free, |
---|
651 | 631 | .prepare = oxygen_prepare, |
---|
.. | .. |
---|
656 | 636 | static const struct snd_pcm_ops oxygen_rec_c_ops = { |
---|
657 | 637 | .open = oxygen_rec_c_open, |
---|
658 | 638 | .close = oxygen_close, |
---|
659 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
660 | 639 | .hw_params = oxygen_rec_c_hw_params, |
---|
661 | 640 | .hw_free = oxygen_hw_free, |
---|
662 | 641 | .prepare = oxygen_prepare, |
---|
.. | .. |
---|
667 | 646 | static const struct snd_pcm_ops oxygen_spdif_ops = { |
---|
668 | 647 | .open = oxygen_spdif_open, |
---|
669 | 648 | .close = oxygen_close, |
---|
670 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
671 | 649 | .hw_params = oxygen_spdif_hw_params, |
---|
672 | 650 | .hw_free = oxygen_spdif_hw_free, |
---|
673 | 651 | .prepare = oxygen_prepare, |
---|
.. | .. |
---|
678 | 656 | static const struct snd_pcm_ops oxygen_multich_ops = { |
---|
679 | 657 | .open = oxygen_multich_open, |
---|
680 | 658 | .close = oxygen_close, |
---|
681 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
682 | 659 | .hw_params = oxygen_multich_hw_params, |
---|
683 | 660 | .hw_free = oxygen_hw_free, |
---|
684 | 661 | .prepare = oxygen_prepare, |
---|
.. | .. |
---|
689 | 666 | static const struct snd_pcm_ops oxygen_ac97_ops = { |
---|
690 | 667 | .open = oxygen_ac97_open, |
---|
691 | 668 | .close = oxygen_close, |
---|
692 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
693 | 669 | .hw_params = oxygen_hw_params, |
---|
694 | 670 | .hw_free = oxygen_hw_free, |
---|
695 | 671 | .prepare = oxygen_prepare, |
---|
.. | .. |
---|
723 | 699 | pcm->private_data = chip; |
---|
724 | 700 | strcpy(pcm->name, "Multichannel"); |
---|
725 | 701 | 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); |
---|
731 | 707 | 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); |
---|
737 | 713 | } |
---|
738 | 714 | |
---|
739 | 715 | outs = !!(chip->model.device_config & PLAYBACK_1_TO_SPDIF); |
---|
.. | .. |
---|
750 | 726 | &oxygen_rec_c_ops); |
---|
751 | 727 | pcm->private_data = chip; |
---|
752 | 728 | 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); |
---|
757 | 733 | } |
---|
758 | 734 | |
---|
759 | 735 | if (chip->has_ac97_1) { |
---|
.. | .. |
---|
780 | 756 | &oxygen_rec_b_ops); |
---|
781 | 757 | pcm->private_data = chip; |
---|
782 | 758 | 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); |
---|
787 | 763 | } |
---|
788 | 764 | |
---|
789 | 765 | ins = !!(chip->model.device_config & CAPTURE_3_FROM_I2S_3); |
---|
.. | .. |
---|
798 | 774 | OXYGEN_REC_C_ROUTE_MASK); |
---|
799 | 775 | pcm->private_data = chip; |
---|
800 | 776 | 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); |
---|
805 | 781 | } |
---|
806 | 782 | return 0; |
---|
807 | 783 | } |
---|