| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* Analog Devices 1889 audio driver |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * This is a driver for the AD1889 PCI audio chipset found |
|---|
| .. | .. |
|---|
| 6 | 7 | * Copyright (C) 2004-2005, Kyle McMartin <kyle@parisc-linux.org> |
|---|
| 7 | 8 | * Copyright (C) 2005, Thibaut Varene <varenet@parisc-linux.org> |
|---|
| 8 | 9 | * Based on the OSS AD1889 driver by Randolph Chung <tausq@debian.org> |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License, version 2, as |
|---|
| 12 | | - * published by the Free Software Foundation. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program; if not, write to the Free Software |
|---|
| 21 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 22 | 10 | * |
|---|
| 23 | 11 | * TODO: |
|---|
| 24 | 12 | * Do we need to take care of CCS register? |
|---|
| .. | .. |
|---|
| 267 | 255 | dev_dbg(chip->card->dev, "[%s] ready after %d ms\n", __func__, 400 - retry); |
|---|
| 268 | 256 | |
|---|
| 269 | 257 | return 0; |
|---|
| 270 | | -} |
|---|
| 271 | | - |
|---|
| 272 | | -static int |
|---|
| 273 | | -snd_ad1889_hw_params(struct snd_pcm_substream *substream, |
|---|
| 274 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 275 | | -{ |
|---|
| 276 | | - return snd_pcm_lib_malloc_pages(substream, |
|---|
| 277 | | - params_buffer_bytes(hw_params)); |
|---|
| 278 | | -} |
|---|
| 279 | | - |
|---|
| 280 | | -static int |
|---|
| 281 | | -snd_ad1889_hw_free(struct snd_pcm_substream *substream) |
|---|
| 282 | | -{ |
|---|
| 283 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 284 | 258 | } |
|---|
| 285 | 259 | |
|---|
| 286 | 260 | static const struct snd_pcm_hardware snd_ad1889_playback_hw = { |
|---|
| .. | .. |
|---|
| 574 | 548 | static const struct snd_pcm_ops snd_ad1889_playback_ops = { |
|---|
| 575 | 549 | .open = snd_ad1889_playback_open, |
|---|
| 576 | 550 | .close = snd_ad1889_playback_close, |
|---|
| 577 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 578 | | - .hw_params = snd_ad1889_hw_params, |
|---|
| 579 | | - .hw_free = snd_ad1889_hw_free, |
|---|
| 580 | 551 | .prepare = snd_ad1889_playback_prepare, |
|---|
| 581 | 552 | .trigger = snd_ad1889_playback_trigger, |
|---|
| 582 | 553 | .pointer = snd_ad1889_playback_pointer, |
|---|
| .. | .. |
|---|
| 585 | 556 | static const struct snd_pcm_ops snd_ad1889_capture_ops = { |
|---|
| 586 | 557 | .open = snd_ad1889_capture_open, |
|---|
| 587 | 558 | .close = snd_ad1889_capture_close, |
|---|
| 588 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 589 | | - .hw_params = snd_ad1889_hw_params, |
|---|
| 590 | | - .hw_free = snd_ad1889_hw_free, |
|---|
| 591 | 559 | .prepare = snd_ad1889_capture_prepare, |
|---|
| 592 | 560 | .trigger = snd_ad1889_capture_trigger, |
|---|
| 593 | 561 | .pointer = snd_ad1889_capture_pointer, |
|---|
| .. | .. |
|---|
| 644 | 612 | chip->psubs = NULL; |
|---|
| 645 | 613 | chip->csubs = NULL; |
|---|
| 646 | 614 | |
|---|
| 647 | | - err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 648 | | - snd_dma_pci_data(chip->pci), |
|---|
| 649 | | - BUFFER_BYTES_MAX / 2, |
|---|
| 650 | | - BUFFER_BYTES_MAX); |
|---|
| 615 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, |
|---|
| 616 | + BUFFER_BYTES_MAX / 2, BUFFER_BYTES_MAX); |
|---|
| 651 | 617 | |
|---|
| 652 | | - if (err < 0) { |
|---|
| 653 | | - dev_err(chip->card->dev, "buffer allocation error: %d\n", err); |
|---|
| 654 | | - return err; |
|---|
| 655 | | - } |
|---|
| 656 | | - |
|---|
| 657 | 618 | return 0; |
|---|
| 658 | 619 | } |
|---|
| 659 | 620 | |
|---|
| .. | .. |
|---|
| 741 | 702 | static void |
|---|
| 742 | 703 | snd_ad1889_proc_init(struct snd_ad1889 *chip) |
|---|
| 743 | 704 | { |
|---|
| 744 | | - struct snd_info_entry *entry; |
|---|
| 745 | | - |
|---|
| 746 | | - if (!snd_card_proc_new(chip->card, chip->card->driver, &entry)) |
|---|
| 747 | | - snd_info_set_text_ops(entry, chip, snd_ad1889_proc_read); |
|---|
| 705 | + snd_card_ro_proc_new(chip->card, chip->card->driver, |
|---|
| 706 | + chip, snd_ad1889_proc_read); |
|---|
| 748 | 707 | } |
|---|
| 749 | 708 | |
|---|
| 750 | 709 | static const struct ac97_quirk ac97_quirks[] = { |
|---|
| .. | .. |
|---|
| 801 | 760 | { |
|---|
| 802 | 761 | int err; |
|---|
| 803 | 762 | struct snd_ac97_template ac97; |
|---|
| 804 | | - static struct snd_ac97_bus_ops ops = { |
|---|
| 763 | + static const struct snd_ac97_bus_ops ops = { |
|---|
| 805 | 764 | .write = snd_ad1889_ac97_write, |
|---|
| 806 | 765 | .read = snd_ad1889_ac97_read, |
|---|
| 807 | 766 | }; |
|---|
| .. | .. |
|---|
| 888 | 847 | int err; |
|---|
| 889 | 848 | |
|---|
| 890 | 849 | struct snd_ad1889 *chip; |
|---|
| 891 | | - static struct snd_device_ops ops = { |
|---|
| 850 | + static const struct snd_device_ops ops = { |
|---|
| 892 | 851 | .dev_free = snd_ad1889_dev_free, |
|---|
| 893 | 852 | }; |
|---|
| 894 | 853 | |
|---|
| .. | .. |
|---|
| 940 | 899 | } |
|---|
| 941 | 900 | |
|---|
| 942 | 901 | chip->irq = pci->irq; |
|---|
| 943 | | - synchronize_irq(chip->irq); |
|---|
| 902 | + card->sync_irq = chip->irq; |
|---|
| 944 | 903 | |
|---|
| 945 | 904 | /* (2) initialization of the chip hardware */ |
|---|
| 946 | 905 | if ((err = snd_ad1889_init(chip)) < 0) { |
|---|