.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> |
---|
3 | 4 | * Driver p16v chips |
---|
.. | .. |
---|
71 | 72 | * |
---|
72 | 73 | * This code was initially based on code from ALSA's emu10k1x.c which is: |
---|
73 | 74 | * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> |
---|
74 | | - * |
---|
75 | | - * This program is free software; you can redistribute it and/or modify |
---|
76 | | - * it under the terms of the GNU General Public License as published by |
---|
77 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
78 | | - * (at your option) any later version. |
---|
79 | | - * |
---|
80 | | - * This program is distributed in the hope that it will be useful, |
---|
81 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
82 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
83 | | - * GNU General Public License for more details. |
---|
84 | | - * |
---|
85 | | - * You should have received a copy of the GNU General Public License |
---|
86 | | - * along with this program; if not, write to the Free Software |
---|
87 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
88 | | - * |
---|
89 | 75 | */ |
---|
90 | 76 | #include <linux/delay.h> |
---|
91 | 77 | #include <linux/init.h> |
---|
.. | .. |
---|
295 | 281 | // Only using channel 0 for now, but the card has 2 channels. |
---|
296 | 282 | return snd_p16v_pcm_open_capture_channel(substream, 0); |
---|
297 | 283 | } |
---|
298 | | - |
---|
299 | | -/* hw_params callback */ |
---|
300 | | -static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream, |
---|
301 | | - struct snd_pcm_hw_params *hw_params) |
---|
302 | | -{ |
---|
303 | | - return snd_pcm_lib_malloc_pages(substream, |
---|
304 | | - params_buffer_bytes(hw_params)); |
---|
305 | | -} |
---|
306 | | - |
---|
307 | | -/* hw_params callback */ |
---|
308 | | -static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream, |
---|
309 | | - struct snd_pcm_hw_params *hw_params) |
---|
310 | | -{ |
---|
311 | | - return snd_pcm_lib_malloc_pages(substream, |
---|
312 | | - params_buffer_bytes(hw_params)); |
---|
313 | | -} |
---|
314 | | - |
---|
315 | | - |
---|
316 | | -/* hw_free callback */ |
---|
317 | | -static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream) |
---|
318 | | -{ |
---|
319 | | - return snd_pcm_lib_free_pages(substream); |
---|
320 | | -} |
---|
321 | | - |
---|
322 | | -/* hw_free callback */ |
---|
323 | | -static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream) |
---|
324 | | -{ |
---|
325 | | - return snd_pcm_lib_free_pages(substream); |
---|
326 | | -} |
---|
327 | | - |
---|
328 | 284 | |
---|
329 | 285 | /* prepare playback callback */ |
---|
330 | 286 | static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
596 | 552 | static const struct snd_pcm_ops snd_p16v_playback_front_ops = { |
---|
597 | 553 | .open = snd_p16v_pcm_open_playback_front, |
---|
598 | 554 | .close = snd_p16v_pcm_close_playback, |
---|
599 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
600 | | - .hw_params = snd_p16v_pcm_hw_params_playback, |
---|
601 | | - .hw_free = snd_p16v_pcm_hw_free_playback, |
---|
602 | 555 | .prepare = snd_p16v_pcm_prepare_playback, |
---|
603 | 556 | .trigger = snd_p16v_pcm_trigger_playback, |
---|
604 | 557 | .pointer = snd_p16v_pcm_pointer_playback, |
---|
.. | .. |
---|
607 | 560 | static const struct snd_pcm_ops snd_p16v_capture_ops = { |
---|
608 | 561 | .open = snd_p16v_pcm_open_capture, |
---|
609 | 562 | .close = snd_p16v_pcm_close_capture, |
---|
610 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
611 | | - .hw_params = snd_p16v_pcm_hw_params_capture, |
---|
612 | | - .hw_free = snd_p16v_pcm_hw_free_capture, |
---|
613 | 563 | .prepare = snd_p16v_pcm_prepare_capture, |
---|
614 | 564 | .trigger = snd_p16v_pcm_trigger_capture, |
---|
615 | 565 | .pointer = snd_p16v_pcm_pointer_capture, |
---|
.. | .. |
---|
656 | 606 | for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; |
---|
657 | 607 | substream; |
---|
658 | 608 | substream = substream->next) { |
---|
659 | | - if ((err = snd_pcm_lib_preallocate_pages(substream, |
---|
660 | | - SNDRV_DMA_TYPE_DEV, |
---|
661 | | - snd_dma_pci_data(emu->pci), |
---|
662 | | - ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) |
---|
663 | | - return err; |
---|
| 609 | + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, |
---|
| 610 | + &emu->pci->dev, |
---|
| 611 | + (65536 - 64) * 8, |
---|
| 612 | + (65536 - 64) * 8); |
---|
664 | 613 | /* |
---|
665 | 614 | dev_dbg(emu->card->dev, |
---|
666 | 615 | "preallocate playback substream: err=%d\n", err); |
---|
.. | .. |
---|
670 | 619 | for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; |
---|
671 | 620 | substream; |
---|
672 | 621 | substream = substream->next) { |
---|
673 | | - if ((err = snd_pcm_lib_preallocate_pages(substream, |
---|
674 | | - SNDRV_DMA_TYPE_DEV, |
---|
675 | | - snd_dma_pci_data(emu->pci), |
---|
676 | | - 65536 - 64, 65536 - 64)) < 0) |
---|
677 | | - return err; |
---|
| 622 | + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, |
---|
| 623 | + &emu->pci->dev, |
---|
| 624 | + 65536 - 64, 65536 - 64); |
---|
678 | 625 | /* |
---|
679 | 626 | dev_dbg(emu->card->dev, |
---|
680 | 627 | "preallocate capture substream: err=%d\n", err); |
---|
.. | .. |
---|
829 | 776 | .private_value = ((xreg) | ((xhl) << 8)) \ |
---|
830 | 777 | } |
---|
831 | 778 | |
---|
832 | | -static struct snd_kcontrol_new p16v_mixer_controls[] = { |
---|
| 779 | +static const struct snd_kcontrol_new p16v_mixer_controls[] = { |
---|
833 | 780 | P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), |
---|
834 | 781 | P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), |
---|
835 | 782 | P16V_VOL("HD Analog Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER9, 1), |
---|