| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ALSA modem driver for Intel ICH (i8x0) chipsets |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * This is modified (by Sasha Khapyorsky <sashak@alsa-project.org>) version |
|---|
| 7 | 8 | * of ALSA ICH sound driver intel8x0.c . |
|---|
| 8 | | - * |
|---|
| 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 as published by |
|---|
| 12 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | | - * (at your option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - * GNU General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; if not, write to the Free Software |
|---|
| 22 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 23 | | - * |
|---|
| 24 | 9 | */ |
|---|
| 25 | 10 | |
|---|
| 26 | 11 | #include <linux/io.h> |
|---|
| .. | .. |
|---|
| 303 | 288 | /* return the GLOB_STA bit for the corresponding codec */ |
|---|
| 304 | 289 | static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec) |
|---|
| 305 | 290 | { |
|---|
| 306 | | - static unsigned int codec_bit[3] = { |
|---|
| 291 | + static const unsigned int codec_bit[3] = { |
|---|
| 307 | 292 | ICH_PCR, ICH_SCR, ICH_TCR |
|---|
| 308 | 293 | }; |
|---|
| 309 | 294 | if (snd_BUG_ON(codec >= 3)) |
|---|
| .. | .. |
|---|
| 568 | 553 | return 0; |
|---|
| 569 | 554 | } |
|---|
| 570 | 555 | |
|---|
| 571 | | -static int snd_intel8x0m_hw_params(struct snd_pcm_substream *substream, |
|---|
| 572 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 573 | | -{ |
|---|
| 574 | | - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
|---|
| 575 | | -} |
|---|
| 576 | | - |
|---|
| 577 | | -static int snd_intel8x0m_hw_free(struct snd_pcm_substream *substream) |
|---|
| 578 | | -{ |
|---|
| 579 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 580 | | -} |
|---|
| 581 | | - |
|---|
| 582 | 556 | static snd_pcm_uframes_t snd_intel8x0m_pcm_pointer(struct snd_pcm_substream *substream) |
|---|
| 583 | 557 | { |
|---|
| 584 | 558 | struct intel8x0m *chip = snd_pcm_substream_chip(substream); |
|---|
| .. | .. |
|---|
| 688 | 662 | static const struct snd_pcm_ops snd_intel8x0m_playback_ops = { |
|---|
| 689 | 663 | .open = snd_intel8x0m_playback_open, |
|---|
| 690 | 664 | .close = snd_intel8x0m_playback_close, |
|---|
| 691 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 692 | | - .hw_params = snd_intel8x0m_hw_params, |
|---|
| 693 | | - .hw_free = snd_intel8x0m_hw_free, |
|---|
| 694 | 665 | .prepare = snd_intel8x0m_pcm_prepare, |
|---|
| 695 | 666 | .trigger = snd_intel8x0m_pcm_trigger, |
|---|
| 696 | 667 | .pointer = snd_intel8x0m_pcm_pointer, |
|---|
| .. | .. |
|---|
| 699 | 670 | static const struct snd_pcm_ops snd_intel8x0m_capture_ops = { |
|---|
| 700 | 671 | .open = snd_intel8x0m_capture_open, |
|---|
| 701 | 672 | .close = snd_intel8x0m_capture_close, |
|---|
| 702 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 703 | | - .hw_params = snd_intel8x0m_hw_params, |
|---|
| 704 | | - .hw_free = snd_intel8x0m_hw_free, |
|---|
| 705 | 673 | .prepare = snd_intel8x0m_pcm_prepare, |
|---|
| 706 | 674 | .trigger = snd_intel8x0m_pcm_trigger, |
|---|
| 707 | 675 | .pointer = snd_intel8x0m_pcm_pointer, |
|---|
| .. | .. |
|---|
| 718 | 686 | }; |
|---|
| 719 | 687 | |
|---|
| 720 | 688 | static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device, |
|---|
| 721 | | - struct ich_pcm_table *rec) |
|---|
| 689 | + const struct ich_pcm_table *rec) |
|---|
| 722 | 690 | { |
|---|
| 723 | 691 | struct snd_pcm *pcm; |
|---|
| 724 | 692 | int err; |
|---|
| .. | .. |
|---|
| 748 | 716 | strcpy(pcm->name, chip->card->shortname); |
|---|
| 749 | 717 | chip->pcm[device] = pcm; |
|---|
| 750 | 718 | |
|---|
| 751 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 752 | | - snd_dma_pci_data(chip->pci), |
|---|
| 753 | | - rec->prealloc_size, |
|---|
| 754 | | - rec->prealloc_max_size); |
|---|
| 719 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 720 | + &chip->pci->dev, |
|---|
| 721 | + rec->prealloc_size, |
|---|
| 722 | + rec->prealloc_max_size); |
|---|
| 755 | 723 | |
|---|
| 756 | 724 | return 0; |
|---|
| 757 | 725 | } |
|---|
| 758 | 726 | |
|---|
| 759 | | -static struct ich_pcm_table intel_pcms[] = { |
|---|
| 727 | +static const struct ich_pcm_table intel_pcms[] = { |
|---|
| 760 | 728 | { |
|---|
| 761 | 729 | .suffix = "Modem", |
|---|
| 762 | 730 | .playback_ops = &snd_intel8x0m_playback_ops, |
|---|
| .. | .. |
|---|
| 769 | 737 | static int snd_intel8x0m_pcm(struct intel8x0m *chip) |
|---|
| 770 | 738 | { |
|---|
| 771 | 739 | int i, tblsize, device, err; |
|---|
| 772 | | - struct ich_pcm_table *tbl, *rec; |
|---|
| 740 | + const struct ich_pcm_table *tbl, *rec; |
|---|
| 773 | 741 | |
|---|
| 774 | 742 | #if 1 |
|---|
| 775 | 743 | tbl = intel_pcms; |
|---|
| .. | .. |
|---|
| 833 | 801 | struct snd_ac97 *x97; |
|---|
| 834 | 802 | int err; |
|---|
| 835 | 803 | unsigned int glob_sta = 0; |
|---|
| 836 | | - static struct snd_ac97_bus_ops ops = { |
|---|
| 804 | + static const struct snd_ac97_bus_ops ops = { |
|---|
| 837 | 805 | .write = snd_intel8x0m_codec_write, |
|---|
| 838 | 806 | .read = snd_intel8x0m_codec_read, |
|---|
| 839 | 807 | }; |
|---|
| .. | .. |
|---|
| 1025 | 993 | { |
|---|
| 1026 | 994 | struct snd_card *card = dev_get_drvdata(dev); |
|---|
| 1027 | 995 | struct intel8x0m *chip = card->private_data; |
|---|
| 1028 | | - int i; |
|---|
| 1029 | 996 | |
|---|
| 1030 | 997 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
|---|
| 1031 | | - for (i = 0; i < chip->pcm_devs; i++) |
|---|
| 1032 | | - snd_pcm_suspend_all(chip->pcm[i]); |
|---|
| 1033 | 998 | snd_ac97_suspend(chip->ac97); |
|---|
| 1034 | 999 | if (chip->irq >= 0) { |
|---|
| 1035 | 1000 | free_irq(chip->irq, chip); |
|---|
| 1036 | 1001 | chip->irq = -1; |
|---|
| 1002 | + card->sync_irq = -1; |
|---|
| 1037 | 1003 | } |
|---|
| 1038 | 1004 | return 0; |
|---|
| 1039 | 1005 | } |
|---|
| .. | .. |
|---|
| 1052 | 1018 | return -EIO; |
|---|
| 1053 | 1019 | } |
|---|
| 1054 | 1020 | chip->irq = pci->irq; |
|---|
| 1021 | + card->sync_irq = chip->irq; |
|---|
| 1055 | 1022 | snd_intel8x0m_chip_init(chip, 0); |
|---|
| 1056 | 1023 | snd_ac97_resume(chip->ac97); |
|---|
| 1057 | 1024 | |
|---|
| .. | .. |
|---|
| 1087 | 1054 | |
|---|
| 1088 | 1055 | static void snd_intel8x0m_proc_init(struct intel8x0m *chip) |
|---|
| 1089 | 1056 | { |
|---|
| 1090 | | - struct snd_info_entry *entry; |
|---|
| 1091 | | - |
|---|
| 1092 | | - if (! snd_card_proc_new(chip->card, "intel8x0m", &entry)) |
|---|
| 1093 | | - snd_info_set_text_ops(entry, chip, snd_intel8x0m_proc_read); |
|---|
| 1057 | + snd_card_ro_proc_new(chip->card, "intel8x0m", chip, |
|---|
| 1058 | + snd_intel8x0m_proc_read); |
|---|
| 1094 | 1059 | } |
|---|
| 1095 | 1060 | |
|---|
| 1096 | 1061 | static int snd_intel8x0m_dev_free(struct snd_device *device) |
|---|
| .. | .. |
|---|
| 1114 | 1079 | unsigned int i; |
|---|
| 1115 | 1080 | unsigned int int_sta_masks; |
|---|
| 1116 | 1081 | struct ichdev *ichdev; |
|---|
| 1117 | | - static struct snd_device_ops ops = { |
|---|
| 1082 | + static const struct snd_device_ops ops = { |
|---|
| 1118 | 1083 | .dev_free = snd_intel8x0m_dev_free, |
|---|
| 1119 | 1084 | }; |
|---|
| 1120 | | - static struct ich_reg_info intel_regs[2] = { |
|---|
| 1085 | + static const struct ich_reg_info intel_regs[2] = { |
|---|
| 1121 | 1086 | { ICH_MIINT, 0 }, |
|---|
| 1122 | 1087 | { ICH_MOINT, 0x10 }, |
|---|
| 1123 | 1088 | }; |
|---|
| 1124 | | - struct ich_reg_info *tbl; |
|---|
| 1089 | + const struct ich_reg_info *tbl; |
|---|
| 1125 | 1090 | |
|---|
| 1126 | 1091 | *r_intel8x0m = NULL; |
|---|
| 1127 | 1092 | |
|---|
| .. | .. |
|---|
| 1196 | 1161 | |
|---|
| 1197 | 1162 | /* allocate buffer descriptor lists */ |
|---|
| 1198 | 1163 | /* the start of each lists must be aligned to 8 bytes */ |
|---|
| 1199 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
|---|
| 1164 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, |
|---|
| 1200 | 1165 | chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, |
|---|
| 1201 | 1166 | &chip->bdbars) < 0) { |
|---|
| 1202 | 1167 | snd_intel8x0m_free(chip); |
|---|
| .. | .. |
|---|
| 1228 | 1193 | return -EBUSY; |
|---|
| 1229 | 1194 | } |
|---|
| 1230 | 1195 | chip->irq = pci->irq; |
|---|
| 1196 | + card->sync_irq = chip->irq; |
|---|
| 1231 | 1197 | |
|---|
| 1232 | 1198 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
|---|
| 1233 | 1199 | snd_intel8x0m_free(chip); |
|---|