Changeset 679 for GPL/trunk/alsa-kernel/pci/trident
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (5 years ago)
- Location:
- GPL/trunk
- Files:
-
- 4 edited
- 1 copied
-
. (modified) (1 prop)
-
alsa-kernel/pci/trident/trident.c (modified) (12 diffs)
-
alsa-kernel/pci/trident/trident.h (copied) (copied from GPL/branches/uniaud32-next/alsa-kernel/pci/trident/trident.h )
-
alsa-kernel/pci/trident/trident_main.c (modified) (68 diffs)
-
alsa-kernel/pci/trident/trident_memory.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/trident/trident.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for Trident 4DWave DX/NX & SiS SI7018 Audio PCI soundcard … … 4 5 * Driver was originated by Trident <audio@tridentmicro.com> 5 6 * Fri Feb 19 15:55:28 MST 1999 6 *7 *8 * This program is free software; you can redistribute it and/or modify9 * it under the terms of the GNU General Public License as published by10 * the Free Software Foundation; either version 2 of the License, or11 * (at your option) any later version.12 *13 * This program is distributed in the hope that it will be useful,14 * but WITHOUT ANY WARRANTY; without even the implied warranty of15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 * GNU General Public License for more details.17 *18 * You should have received a copy of the GNU General Public License19 * along with this program; if not, write to the Free Software20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21 *22 7 */ 23 8 … … 25 10 #include <linux/pci.h> 26 11 #include <linux/time.h> 27 #include <linux/module param.h>12 #include <linux/module.h> 28 13 #include <sound/core.h> 29 #include <sound/trident.h>14 #include "trident.h" 30 15 #include <sound/initval.h> 16 17 #ifdef TARGET_OS2 18 #define KBUILD_MODNAME "trident" 19 #endif 31 20 32 21 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>"); … … 48 37 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 49 38 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 50 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */39 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 51 40 #ifndef TARGET_OS2 52 41 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; … … 68 57 MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); 69 58 70 static DEFINE_PCI_DEVICE_TABLE(snd_trident_ids)= {59 static const struct pci_device_id snd_trident_ids[] = { 71 60 {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX), 72 61 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, … … 79 68 MODULE_DEVICE_TABLE(pci, snd_trident_ids); 80 69 81 static int __devinitsnd_trident_probe(struct pci_dev *pci,82 const struct pci_device_id *pci_id)70 static int snd_trident_probe(struct pci_dev *pci, 71 const struct pci_device_id *pci_id) 83 72 { 84 73 static int dev; … … 95 84 } 96 85 97 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 86 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 87 0, &card); 98 88 if (err < 0) 99 89 return err; … … 128 118 strcpy(card->shortname, "Trident "); 129 119 } 130 strcat(card->shortname, card->driver);120 strcat(card->shortname, str); 131 121 sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d", 132 122 card->shortname, trident->port, trident->irq); 133 123 134 if ((err = snd_trident_pcm(trident, pcm_dev++ , NULL)) < 0) {124 if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) { 135 125 snd_card_free(card); 136 126 return err; … … 139 129 case TRIDENT_DEVICE_ID_DX: 140 130 case TRIDENT_DEVICE_ID_NX: 141 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++ , NULL)) < 0) {131 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) { 142 132 snd_card_free(card); 143 133 return err; … … 146 136 } 147 137 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { 148 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++ , NULL)) < 0) {138 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) { 149 139 snd_card_free(card); 150 140 return err; … … 154 144 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, 155 145 trident->midi_port, 156 MPU401_INFO_INTEGRATED, 157 trident->irq, 0, &trident->rmidi)) < 0) { 146 MPU401_INFO_INTEGRATED | 147 MPU401_INFO_IRQ_HOOK, 148 -1, &trident->rmidi)) < 0) { 158 149 snd_card_free(card); 159 150 return err; … … 171 162 } 172 163 173 static void __devexitsnd_trident_remove(struct pci_dev *pci)164 static void snd_trident_remove(struct pci_dev *pci) 174 165 { 175 166 snd_card_free(pci_get_drvdata(pci)); 176 pci_set_drvdata(pci, NULL);177 167 } 178 168 179 static struct pci_driver driver = {180 .name = "Trident4DWaveAudio",169 static struct pci_driver trident_driver = { 170 .name = KBUILD_MODNAME, 181 171 .id_table = snd_trident_ids, 182 172 .probe = snd_trident_probe, 183 .remove = __devexit_p(snd_trident_remove), 184 #ifdef CONFIG_PM 185 .suspend = snd_trident_suspend, 186 .resume = snd_trident_resume, 173 .remove = snd_trident_remove, 174 #ifdef CONFIG_PM_SLEEP 175 .driver = { 176 .pm = &snd_trident_pm, 177 }, 187 178 #endif 188 179 }; 189 180 190 static int __init alsa_card_trident_init(void) 191 { 192 return pci_register_driver(&driver); 193 } 194 195 static void __exit alsa_card_trident_exit(void) 196 { 197 pci_unregister_driver(&driver); 198 } 199 200 module_init(alsa_card_trident_init) 201 module_exit(alsa_card_trident_exit) 181 module_pci_driver(trident_driver); -
GPL/trunk/alsa-kernel/pci/trident/trident_main.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Maintained by Jaroslav Kysela <perex@perex.cz> … … 10 11 * --- 11 12 * 12 * This program is free software; you can redistribute it and/or modify13 * it under the terms of the GNU General Public License as published by14 * the Free Software Foundation; either version 2 of the License, or15 * (at your option) any later version.16 *17 * This program is distributed in the hope that it will be useful,18 * but WITHOUT ANY WARRANTY; without even the implied warranty of19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 * GNU General Public License for more details.21 *22 * You should have received a copy of the GNU General Public License23 * along with this program; if not, write to the Free Software24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA25 *26 *27 13 * SiS7018 S/PDIF support by Thomas Winischhofer <thomas@winischhofer.net> 28 14 */ 15 16 #ifdef TARGET_OS2 17 #define KBUILD_MODNAME "trident" 18 #endif 29 19 30 20 #include <linux/delay.h> … … 36 26 #include <linux/gameport.h> 37 27 #include <linux/dma-mapping.h> 28 #include <linux/export.h> 29 #include <linux/io.h> 38 30 39 31 #include <sound/core.h> … … 41 33 #include <sound/control.h> 42 34 #include <sound/tlv.h> 43 #include <sound/trident.h>35 #include "trident.h" 44 36 #include <sound/asoundef.h> 45 46 #include <asm/io.h>47 37 48 38 static int snd_trident_pcm_mixer_build(struct snd_trident *trident, … … 69 59 unsigned int val, tmp; 70 60 71 printk(KERN_DEBUG"Trident voice %i:\n", voice);61 dev_dbg(trident->card->dev, "Trident voice %i:\n", voice); 72 62 outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR)); 73 63 val = inl(TRID_REG(trident, CH_LBA)); 74 printk(KERN_DEBUG"LBA: 0x%x\n", val);64 dev_dbg(trident->card->dev, "LBA: 0x%x\n", val); 75 65 val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); 76 printk(KERN_DEBUG"GVSel: %i\n", val >> 31);77 printk(KERN_DEBUG"Pan: 0x%x\n", (val >> 24) & 0x7f);78 printk(KERN_DEBUG"Vol: 0x%x\n", (val >> 16) & 0xff);79 printk(KERN_DEBUG"CTRL: 0x%x\n", (val >> 12) & 0x0f);80 printk(KERN_DEBUG"EC: 0x%x\n", val & 0x0fff);66 dev_dbg(trident->card->dev, "GVSel: %i\n", val >> 31); 67 dev_dbg(trident->card->dev, "Pan: 0x%x\n", (val >> 24) & 0x7f); 68 dev_dbg(trident->card->dev, "Vol: 0x%x\n", (val >> 16) & 0xff); 69 dev_dbg(trident->card->dev, "CTRL: 0x%x\n", (val >> 12) & 0x0f); 70 dev_dbg(trident->card->dev, "EC: 0x%x\n", val & 0x0fff); 81 71 if (trident->device != TRIDENT_DEVICE_ID_NX) { 82 72 val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS)); 83 printk(KERN_DEBUG"CSO: 0x%x\n", val >> 16);84 printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff);85 printk(KERN_DEBUG"FMS: 0x%x\n", val & 0x0f);73 dev_dbg(trident->card->dev, "CSO: 0x%x\n", val >> 16); 74 dev_dbg(trident->card->dev, "Alpha: 0x%x\n", (val >> 4) & 0x0fff); 75 dev_dbg(trident->card->dev, "FMS: 0x%x\n", val & 0x0f); 86 76 val = inl(TRID_REG(trident, CH_DX_ESO_DELTA)); 87 printk(KERN_DEBUG"ESO: 0x%x\n", val >> 16);88 printk(KERN_DEBUG"Delta: 0x%x\n", val & 0xffff);77 dev_dbg(trident->card->dev, "ESO: 0x%x\n", val >> 16); 78 dev_dbg(trident->card->dev, "Delta: 0x%x\n", val & 0xffff); 89 79 val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL)); 90 80 } else { // TRIDENT_DEVICE_ID_NX 91 81 val = inl(TRID_REG(trident, CH_NX_DELTA_CSO)); 92 82 tmp = (val >> 24) & 0xff; 93 printk(KERN_DEBUG"CSO: 0x%x\n", val & 0x00ffffff);83 dev_dbg(trident->card->dev, "CSO: 0x%x\n", val & 0x00ffffff); 94 84 val = inl(TRID_REG(trident, CH_NX_DELTA_ESO)); 95 85 tmp |= (val >> 16) & 0xff00; 96 printk(KERN_DEBUG"Delta: 0x%x\n", tmp);97 printk(KERN_DEBUG"ESO: 0x%x\n", val & 0x00ffffff);86 dev_dbg(trident->card->dev, "Delta: 0x%x\n", tmp); 87 dev_dbg(trident->card->dev, "ESO: 0x%x\n", val & 0x00ffffff); 98 88 val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL)); 99 printk(KERN_DEBUG"Alpha: 0x%x\n", val >> 20);100 printk(KERN_DEBUG"FMS: 0x%x\n", (val >> 16) & 0x0f);101 } 102 printk(KERN_DEBUG"FMC: 0x%x\n", (val >> 14) & 3);103 printk(KERN_DEBUG"RVol: 0x%x\n", (val >> 7) & 0x7f);104 printk(KERN_DEBUG"CVol: 0x%x\n", val & 0x7f);89 dev_dbg(trident->card->dev, "Alpha: 0x%x\n", val >> 20); 90 dev_dbg(trident->card->dev, "FMS: 0x%x\n", (val >> 16) & 0x0f); 91 } 92 dev_dbg(trident->card->dev, "FMC: 0x%x\n", (val >> 14) & 3); 93 dev_dbg(trident->card->dev, "RVol: 0x%x\n", (val >> 7) & 0x7f); 94 dev_dbg(trident->card->dev, "CVol: 0x%x\n", val & 0x7f); 105 95 } 106 96 #endif … … 156 146 157 147 if (count == 0 && !trident->ac97_detect) { 158 snd_printk(KERN_ERR "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n", 148 dev_err(trident->card->dev, 149 "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n", 159 150 reg, data); 160 151 data = 0; … … 497 488 498 489 #if 0 499 printk(KERN_DEBUG"written %i channel:\n", voice->number);500 printk(KERN_DEBUG" regs[0] = 0x%x/0x%x\n",490 dev_dbg(trident->card->dev, "written %i channel:\n", voice->number); 491 dev_dbg(trident->card->dev, " regs[0] = 0x%x/0x%x\n", 501 492 regs[0], inl(TRID_REG(trident, CH_START + 0))); 502 printk(KERN_DEBUG" regs[1] = 0x%x/0x%x\n",493 dev_dbg(trident->card->dev, " regs[1] = 0x%x/0x%x\n", 503 494 regs[1], inl(TRID_REG(trident, CH_START + 4))); 504 printk(KERN_DEBUG" regs[2] = 0x%x/0x%x\n",495 dev_dbg(trident->card->dev, " regs[2] = 0x%x/0x%x\n", 505 496 regs[2], inl(TRID_REG(trident, CH_START + 8))); 506 printk(KERN_DEBUG" regs[3] = 0x%x/0x%x\n",497 dev_dbg(trident->card->dev, " regs[3] = 0x%x/0x%x\n", 507 498 regs[3], inl(TRID_REG(trident, CH_START + 12))); 508 printk(KERN_DEBUG" regs[4] = 0x%x/0x%x\n",499 dev_dbg(trident->card->dev, " regs[4] = 0x%x/0x%x\n", 509 500 regs[4], inl(TRID_REG(trident, CH_START + 16))); 510 501 #endif … … 589 580 break; 590 581 case TRIDENT_DEVICE_ID_SI7018: 591 /* printk(KERN_DEBUG"voice->Vol = 0x%x\n", voice->Vol); */582 /* dev_dbg(trident->card->dev, "voice->Vol = 0x%x\n", voice->Vol); */ 592 583 outw((voice->CTRL << 12) | voice->Vol, 593 584 TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); … … 782 773 783 774 /*--------------------------------------------------------------------------- 784 snd_trident_ioctl785 786 Description: Device I/O control handler for playback/capture parameters.787 788 Parameters: substream - PCM substream class789 cmd - what ioctl message to process790 arg - additional message infoarg791 792 Returns: Error status793 794 ---------------------------------------------------------------------------*/795 796 static int snd_trident_ioctl(struct snd_pcm_substream *substream,797 unsigned int cmd,798 void *arg)799 {800 /* FIXME: it seems that with small periods the behaviour of801 trident hardware is unpredictable and interrupt generator802 is broken */803 return snd_pcm_lib_ioctl(substream, cmd, arg);804 }805 806 /*---------------------------------------------------------------------------807 775 snd_trident_allocate_pcm_mem 808 776 … … 822 790 struct snd_pcm_runtime *runtime = substream->runtime; 823 791 struct snd_trident_voice *voice = runtime->private_data; 824 int err; 825 826 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) 827 return err; 792 828 793 if (trident->tlb.entries) { 829 if ( err > 0) { /* change */794 if (runtime->buffer_changed) { 830 795 if (voice->memblk) 831 796 snd_trident_free_pages(trident, voice->memblk); … … 925 890 } 926 891 } 927 snd_pcm_lib_free_pages(substream);928 892 if (evoice != NULL) { 929 893 snd_trident_free_voice(trident, evoice); … … 1142 1106 struct snd_pcm_hw_params *hw_params) 1143 1107 { 1144 int err;1145 1146 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)1147 return err;1148 1149 1108 return snd_trident_allocate_evoice(substream, hw_params); 1150 1109 } … … 1168 1127 struct snd_trident_voice *evoice = voice ? voice->extra : NULL; 1169 1128 1170 snd_pcm_lib_free_pages(substream);1171 1129 if (evoice != NULL) { 1172 1130 snd_trident_free_voice(trident, evoice); … … 1727 1685 */ 1728 1686 1729 static struct snd_pcm_hardware snd_trident_playback =1687 static const struct snd_pcm_hardware snd_trident_playback = 1730 1688 { 1731 1689 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1752 1710 */ 1753 1711 1754 static struct snd_pcm_hardware snd_trident_capture =1712 static const struct snd_pcm_hardware snd_trident_capture = 1755 1713 { 1756 1714 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1777 1735 */ 1778 1736 1779 static struct snd_pcm_hardware snd_trident_foldback =1737 static const struct snd_pcm_hardware snd_trident_foldback = 1780 1738 { 1781 1739 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1801 1759 */ 1802 1760 1803 static struct snd_pcm_hardware snd_trident_spdif =1761 static const struct snd_pcm_hardware snd_trident_spdif = 1804 1762 { 1805 1763 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1822 1780 }; 1823 1781 1824 static struct snd_pcm_hardware snd_trident_spdif_7018 =1782 static const struct snd_pcm_hardware snd_trident_spdif_7018 = 1825 1783 { 1826 1784 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 2070 2028 ---------------------------------------------------------------------------*/ 2071 2029 2072 static struct snd_pcm_ops snd_trident_playback_ops = {2030 static const struct snd_pcm_ops snd_trident_playback_ops = { 2073 2031 .open = snd_trident_playback_open, 2074 2032 .close = snd_trident_playback_close, 2075 .ioctl = snd_trident_ioctl,2076 2033 .hw_params = snd_trident_hw_params, 2077 2034 .hw_free = snd_trident_hw_free, … … 2081 2038 }; 2082 2039 2083 static struct snd_pcm_ops snd_trident_nx_playback_ops = {2040 static const struct snd_pcm_ops snd_trident_nx_playback_ops = { 2084 2041 .open = snd_trident_playback_open, 2085 2042 .close = snd_trident_playback_close, 2086 .ioctl = snd_trident_ioctl,2087 2043 .hw_params = snd_trident_hw_params, 2088 2044 .hw_free = snd_trident_hw_free, … … 2090 2046 .trigger = snd_trident_trigger, 2091 2047 .pointer = snd_trident_playback_pointer, 2092 .page = snd_pcm_sgbuf_ops_page,2093 2048 }; 2094 2049 2095 static struct snd_pcm_ops snd_trident_capture_ops = {2050 static const struct snd_pcm_ops snd_trident_capture_ops = { 2096 2051 .open = snd_trident_capture_open, 2097 2052 .close = snd_trident_capture_close, 2098 .ioctl = snd_trident_ioctl,2099 2053 .hw_params = snd_trident_capture_hw_params, 2100 2054 .hw_free = snd_trident_hw_free, … … 2104 2058 }; 2105 2059 2106 static struct snd_pcm_ops snd_trident_si7018_capture_ops = {2060 static const struct snd_pcm_ops snd_trident_si7018_capture_ops = { 2107 2061 .open = snd_trident_capture_open, 2108 2062 .close = snd_trident_capture_close, 2109 .ioctl = snd_trident_ioctl,2110 2063 .hw_params = snd_trident_si7018_capture_hw_params, 2111 2064 .hw_free = snd_trident_si7018_capture_hw_free, … … 2115 2068 }; 2116 2069 2117 static struct snd_pcm_ops snd_trident_foldback_ops = {2070 static const struct snd_pcm_ops snd_trident_foldback_ops = { 2118 2071 .open = snd_trident_foldback_open, 2119 2072 .close = snd_trident_foldback_close, 2120 .ioctl = snd_trident_ioctl,2121 2073 .hw_params = snd_trident_hw_params, 2122 2074 .hw_free = snd_trident_hw_free, … … 2126 2078 }; 2127 2079 2128 static struct snd_pcm_ops snd_trident_nx_foldback_ops = {2080 static const struct snd_pcm_ops snd_trident_nx_foldback_ops = { 2129 2081 .open = snd_trident_foldback_open, 2130 2082 .close = snd_trident_foldback_close, 2131 .ioctl = snd_trident_ioctl,2132 2083 .hw_params = snd_trident_hw_params, 2133 2084 .hw_free = snd_trident_hw_free, … … 2135 2086 .trigger = snd_trident_trigger, 2136 2087 .pointer = snd_trident_playback_pointer, 2137 .page = snd_pcm_sgbuf_ops_page,2138 2088 }; 2139 2089 2140 static struct snd_pcm_ops snd_trident_spdif_ops = {2090 static const struct snd_pcm_ops snd_trident_spdif_ops = { 2141 2091 .open = snd_trident_spdif_open, 2142 2092 .close = snd_trident_spdif_close, 2143 .ioctl = snd_trident_ioctl,2144 2093 .hw_params = snd_trident_spdif_hw_params, 2145 2094 .hw_free = snd_trident_hw_free, … … 2149 2098 }; 2150 2099 2151 static struct snd_pcm_ops snd_trident_spdif_7018_ops = {2100 static const struct snd_pcm_ops snd_trident_spdif_7018_ops = { 2152 2101 .open = snd_trident_spdif_open, 2153 2102 .close = snd_trident_spdif_close, 2154 .ioctl = snd_trident_ioctl,2155 2103 .hw_params = snd_trident_spdif_hw_params, 2156 2104 .hw_free = snd_trident_hw_free, … … 2171 2119 ---------------------------------------------------------------------------*/ 2172 2120 2173 int __devinit snd_trident_pcm(struct snd_trident * trident, 2174 int device, struct snd_pcm ** rpcm) 2121 int snd_trident_pcm(struct snd_trident *trident, int device) 2175 2122 { 2176 2123 struct snd_pcm *pcm; 2177 2124 int err; 2178 2125 2179 if (rpcm)2180 *rpcm = NULL;2181 2126 if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm)) < 0) 2182 2127 return err; … … 2202 2147 struct snd_pcm_substream *substream; 2203 2148 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 2204 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, 2205 snd_dma_pci_data(trident->pci), 2206 64*1024, 128*1024); 2207 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 2208 SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 2209 64*1024, 128*1024); 2149 snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV_SG, 2150 &trident->pci->dev, 2151 64*1024, 128*1024); 2152 snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 2153 SNDRV_DMA_TYPE_DEV, 2154 &trident->pci->dev, 2155 64*1024, 128*1024); 2210 2156 } else { 2211 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 2212 snd_dma_pci_data(trident->pci), 64*1024, 128*1024); 2213 } 2214 2215 if (rpcm) 2216 *rpcm = pcm; 2157 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 2158 &trident->pci->dev, 2159 64*1024, 128*1024); 2160 } 2161 2217 2162 return 0; 2218 2163 } … … 2229 2174 ---------------------------------------------------------------------------*/ 2230 2175 2231 int __devinit snd_trident_foldback_pcm(struct snd_trident * trident, 2232 int device, struct snd_pcm ** rpcm) 2176 int snd_trident_foldback_pcm(struct snd_trident *trident, int device) 2233 2177 { 2234 2178 struct snd_pcm *foldback; … … 2237 2181 struct snd_pcm_substream *substream; 2238 2182 2239 if (rpcm)2240 *rpcm = NULL;2241 2183 if (trident->device == TRIDENT_DEVICE_ID_NX) 2242 2184 num_chan = 4; … … 2264 2206 2265 2207 if (trident->tlb.entries) 2266 snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV_SG, 2267 snd_dma_pci_data(trident->pci), 0, 128*1024); 2208 snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV_SG, 2209 &trident->pci->dev, 2210 0, 128*1024); 2268 2211 else 2269 snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV, 2270 snd_dma_pci_data(trident->pci), 64*1024, 128*1024); 2271 2272 if (rpcm) 2273 *rpcm = foldback; 2212 snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV, 2213 &trident->pci->dev, 2214 64*1024, 128*1024); 2215 2274 2216 return 0; 2275 2217 } … … 2286 2228 ---------------------------------------------------------------------------*/ 2287 2229 2288 int __devinit snd_trident_spdif_pcm(struct snd_trident * trident, 2289 int device, struct snd_pcm ** rpcm) 2230 int snd_trident_spdif_pcm(struct snd_trident *trident, int device) 2290 2231 { 2291 2232 struct snd_pcm *spdif; 2292 2233 int err; 2293 2234 2294 if (rpcm)2295 *rpcm = NULL;2296 2235 if ((err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif)) < 0) 2297 2236 return err; … … 2307 2246 trident->spdif = spdif; 2308 2247 2309 snd_pcm_lib_preallocate_pages_for_all(spdif, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 64*1024, 128*1024); 2310 2311 if (rpcm) 2312 *rpcm = spdif; 2248 snd_pcm_set_managed_buffer_all(spdif, SNDRV_DMA_TYPE_DEV, 2249 &trident->pci->dev, 64*1024, 128*1024); 2250 2313 2251 return 0; 2314 2252 } … … 2371 2309 } 2372 2310 2373 static struct snd_kcontrol_new snd_trident_spdif_control __devinitdata=2311 static const struct snd_kcontrol_new snd_trident_spdif_control = 2374 2312 { 2375 2313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2434 2372 } 2435 2373 2436 static struct snd_kcontrol_new snd_trident_spdif_default __devinitdata=2374 static const struct snd_kcontrol_new snd_trident_spdif_default = 2437 2375 { 2438 2376 .iface = SNDRV_CTL_ELEM_IFACE_PCM, … … 2467 2405 } 2468 2406 2469 static struct snd_kcontrol_new snd_trident_spdif_mask __devinitdata=2407 static const struct snd_kcontrol_new snd_trident_spdif_mask = 2470 2408 { 2471 2409 .access = SNDRV_CTL_ELEM_ACCESS_READ, … … 2529 2467 } 2530 2468 2531 static struct snd_kcontrol_new snd_trident_spdif_stream __devinitdata=2469 static const struct snd_kcontrol_new snd_trident_spdif_stream = 2532 2470 { 2533 2471 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 2579 2517 } 2580 2518 2581 static struct snd_kcontrol_new snd_trident_ac97_rear_control __devinitdata=2519 static const struct snd_kcontrol_new snd_trident_ac97_rear_control = 2582 2520 { 2583 2521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2637 2575 } 2638 2576 2639 static struct snd_kcontrol_new snd_trident_vol_music_control __devinitdata=2577 static const struct snd_kcontrol_new snd_trident_vol_music_control = 2640 2578 { 2641 2579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2648 2586 }; 2649 2587 2650 static struct snd_kcontrol_new snd_trident_vol_wave_control __devinitdata=2588 static const struct snd_kcontrol_new snd_trident_vol_wave_control = 2651 2589 { 2652 2590 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2715 2653 } 2716 2654 2717 static struct snd_kcontrol_new snd_trident_pcm_vol_control __devinitdata=2655 static const struct snd_kcontrol_new snd_trident_pcm_vol_control = 2718 2656 { 2719 2657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2779 2717 } 2780 2718 2781 static struct snd_kcontrol_new snd_trident_pcm_pan_control __devinitdata=2719 static const struct snd_kcontrol_new snd_trident_pcm_pan_control = 2782 2720 { 2783 2721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2836 2774 static const DECLARE_TLV_DB_SCALE(db_scale_crvol, -3175, 25, 1); 2837 2775 2838 static struct snd_kcontrol_new snd_trident_pcm_rvol_control __devinitdata=2776 static const struct snd_kcontrol_new snd_trident_pcm_rvol_control = 2839 2777 { 2840 2778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2892 2830 } 2893 2831 2894 static struct snd_kcontrol_new snd_trident_pcm_cvol_control __devinitdata=2832 static const struct snd_kcontrol_new snd_trident_pcm_cvol_control = 2895 2833 { 2896 2834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 2972 2910 ---------------------------------------------------------------------------*/ 2973 2911 2974 static int __devinit snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)2912 static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) 2975 2913 { 2976 2914 struct snd_ac97_template _ac97; … … 2979 2917 struct snd_ctl_elem_value *uctl; 2980 2918 int idx, err, retries = 2; 2981 static struct snd_ac97_bus_ops ops = {2919 static const struct snd_ac97_bus_ops ops = { 2982 2920 .write = snd_trident_codec_write, 2983 2921 .read = snd_trident_codec_read, … … 3013 2951 err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97_sec); 3014 2952 if (err < 0) 3015 snd_printk(KERN_ERR "SI7018: the secondary codec - invalid access\n"); 2953 dev_err(trident->card->dev, 2954 "SI7018: the secondary codec - invalid access\n"); 3016 2955 #if 0 // only for my testing purpose --jk 3017 2956 { … … 3019 2958 err = snd_ac97_modem(trident->card, &_ac97, &mc97); 3020 2959 if (err < 0) 3021 snd_printk(KERN_ERR "snd_ac97_modem returned error %i\n", err); 2960 dev_err(trident->card->dev, 2961 "snd_ac97_modem returned error %i\n", err); 3022 2962 } 3023 2963 #endif … … 3133 3073 */ 3134 3074 3135 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))3075 #if IS_REACHABLE(CONFIG_GAMEPORT) 3136 3076 3137 3077 static unsigned char snd_trident_gameport_read(struct gameport *gameport) … … 3191 3131 } 3192 3132 3193 int __devinitsnd_trident_create_gameport(struct snd_trident *chip)3133 int snd_trident_create_gameport(struct snd_trident *chip) 3194 3134 { 3195 3135 struct gameport *gp; … … 3197 3137 chip->gameport = gp = gameport_allocate_port(); 3198 3138 if (!gp) { 3199 printk(KERN_ERR "trident: cannot allocate memory for gameport\n"); 3139 dev_err(chip->card->dev, 3140 "cannot allocate memory for gameport\n"); 3200 3141 return -ENOMEM; 3201 3142 } … … 3225 3166 } 3226 3167 #else 3227 int __devinitsnd_trident_create_gameport(struct snd_trident *chip) { return -ENOSYS; }3168 int snd_trident_create_gameport(struct snd_trident *chip) { return -ENOSYS; } 3228 3169 static inline void snd_trident_free_gameport(struct snd_trident *chip) { } 3229 3170 #endif /* CONFIG_GAMEPORT */ … … 3270 3211 do_delay(trident); 3271 3212 } while (time_after_eq(end_time, jiffies)); 3272 snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL))); 3213 dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n", 3214 inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL))); 3273 3215 if (r-- > 0) { 3274 3216 end_time = jiffies + HZ; … … 3329 3271 } 3330 3272 3331 static void __devinit snd_trident_proc_init(struct snd_trident * trident) 3332 { 3333 struct snd_info_entry *entry; 3273 static void snd_trident_proc_init(struct snd_trident *trident) 3274 { 3334 3275 const char *s = "trident"; 3335 3276 3336 3277 if (trident->device == TRIDENT_DEVICE_ID_SI7018) 3337 3278 s = "sis7018"; 3338 if (! snd_card_proc_new(trident->card, s, &entry)) 3339 snd_info_set_text_ops(entry, trident, snd_trident_proc_read); 3279 snd_card_ro_proc_new(trident->card, s, trident, snd_trident_proc_read); 3340 3280 } 3341 3281 … … 3358 3298 ---------------------------------------------------------------------------*/ 3359 3299 3360 static int __devinitsnd_trident_tlb_alloc(struct snd_trident *trident)3300 static int snd_trident_tlb_alloc(struct snd_trident *trident) 3361 3301 { 3362 3302 int i; … … 3365 3305 32kB region and correct offset when necessary */ 3366 3306 3367 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),3307 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev, 3368 3308 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) { 3369 snd_printk(KERN_ERR "trident:unable to allocate TLB buffer\n");3309 dev_err(trident->card->dev, "unable to allocate TLB buffer\n"); 3370 3310 return -ENOMEM; 3371 3311 } 3372 trident->tlb.entries = ( unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);3312 trident->tlb.entries = (__le32 *)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4); 3373 3313 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); 3374 3314 /* allocate shadow TLB page table (virtual addresses) */ 3375 trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); 3376 if (trident->tlb.shadow_entries == NULL) { 3377 snd_printk(KERN_ERR "trident: unable to allocate shadow TLB entries\n"); 3315 trident->tlb.shadow_entries = 3316 vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES, 3317 sizeof(unsigned long))); 3318 if (!trident->tlb.shadow_entries) 3378 3319 return -ENOMEM; 3379 } 3320 3380 3321 /* allocate and setup silent page and initialise TLB entries */ 3381 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),3322 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev, 3382 3323 SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) { 3383 snd_printk(KERN_ERR "trident:unable to allocate silent page\n");3324 dev_err(trident->card->dev, "unable to allocate silent page\n"); 3384 3325 return -ENOMEM; 3385 3326 } … … 3439 3380 do_delay(trident); 3440 3381 } while (time_after_eq(end_time, jiffies)); 3441 snd_printk(KERN_ERR"AC'97 codec ready error\n");3382 dev_err(trident->card->dev, "AC'97 codec ready error\n"); 3442 3383 return -EIO; 3443 3384 … … 3477 3418 do_delay(trident); 3478 3419 } while (time_after_eq(end_time, jiffies)); 3479 snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT))); 3420 dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n", 3421 inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT))); 3480 3422 return -EIO; 3481 3423 … … 3539 3481 ---------------------------------------------------------------------------*/ 3540 3482 3541 int __devinitsnd_trident_create(struct snd_card *card,3483 int snd_trident_create(struct snd_card *card, 3542 3484 struct pci_dev *pci, 3543 3485 int pcm_streams, … … 3550 3492 struct snd_trident_voice *voice; 3551 3493 struct snd_trident_pcm_mixer *tmix; 3552 static struct snd_device_ops ops = {3494 static const struct snd_device_ops ops = { 3553 3495 .dev_free = snd_trident_dev_free, 3554 3496 }; … … 3560 3502 return err; 3561 3503 /* check, if we can restrict PCI DMA transfers to 30 bits */ 3562 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 || 3563 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) { 3564 snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n"); 3504 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 || 3505 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) { 3506 dev_err(card->dev, 3507 "architecture does not support 30bit PCI busmaster DMA\n"); 3565 3508 pci_disable_device(pci); 3566 3509 return -ENXIO; … … 3599 3542 3600 3543 if (request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED, 3601 "Trident Audio", trident)) {3602 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);3544 KBUILD_MODNAME, trident)) { 3545 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 3603 3546 snd_trident_free(trident); 3604 3547 return -EBUSY; 3605 3548 } 3606 3549 trident->irq = pci->irq; 3550 card->sync_irq = trident->irq; 3607 3551 3608 3552 /* allocate 16k-aligned TLB for NX cards */ … … 3664 3608 3665 3609 snd_trident_proc_init(trident); 3666 snd_card_set_dev(card, &pci->dev);3667 3610 *rtrident = trident; 3668 3611 return 0; … … 3695 3638 if (trident->tlb.buffer.area) { 3696 3639 outl(0, TRID_REG(trident, NX_TLBC)); 3697 if (trident->tlb.memhdr) 3698 snd_util_memhdr_free(trident->tlb.memhdr); 3640 snd_util_memhdr_free(trident->tlb.memhdr); 3699 3641 if (trident->tlb.silent_page.area) 3700 3642 snd_dma_free_pages(&trident->tlb.silent_page); … … 3873 3815 unsigned long flags; 3874 3816 void (*private_free)(struct snd_trident_voice *); 3875 void *private_data;3876 3817 3877 3818 if (voice == NULL || !voice->use) … … 3880 3821 spin_lock_irqsave(&trident->voice_alloc, flags); 3881 3822 private_free = voice->private_free; 3882 private_data = voice->private_data;3883 3823 voice->private_free = NULL; 3884 3824 voice->private_data = NULL; … … 3919 3859 } 3920 3860 3921 #ifdef CONFIG_PM 3922 int snd_trident_suspend(struct pci_dev *pci, pm_message_t state)3923 { 3924 struct snd_card *card = pci_get_drvdata(pci);3861 #ifdef CONFIG_PM_SLEEP 3862 static int snd_trident_suspend(struct device *dev) 3863 { 3864 struct snd_card *card = dev_get_drvdata(dev); 3925 3865 struct snd_trident *trident = card->private_data; 3926 3866 3927 3867 trident->in_suspend = 1; 3928 3868 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3929 snd_pcm_suspend_all(trident->pcm);3930 snd_pcm_suspend_all(trident->foldback);3931 snd_pcm_suspend_all(trident->spdif);3932 3933 3869 snd_ac97_suspend(trident->ac97); 3934 3870 snd_ac97_suspend(trident->ac97_sec); 3935 3936 pci_disable_device(pci); 3937 pci_save_state(pci); 3938 pci_set_power_state(pci, pci_choose_state(pci, state)); 3939 return 0; 3940 } 3941 3942 int snd_trident_resume(struct pci_dev *pci) 3943 { 3944 struct snd_card *card = pci_get_drvdata(pci); 3871 return 0; 3872 } 3873 3874 static int snd_trident_resume(struct device *dev) 3875 { 3876 struct snd_card *card = dev_get_drvdata(dev); 3945 3877 struct snd_trident *trident = card->private_data; 3946 3947 pci_set_power_state(pci, PCI_D0);3948 pci_restore_state(pci);3949 if (pci_enable_device(pci) < 0) {3950 printk(KERN_ERR "trident: pci_enable_device failed, "3951 "disabling device\n");3952 snd_card_disconnect(card);3953 return -EIO;3954 }3955 pci_set_master(pci);3956 3878 3957 3879 switch (trident->device) { … … 3979 3901 return 0; 3980 3902 } 3981 #endif /* CONFIG_PM */ 3903 3904 SIMPLE_DEV_PM_OPS(snd_trident_pm, snd_trident_suspend, snd_trident_resume); 3905 #endif /* CONFIG_PM_SLEEP */ -
GPL/trunk/alsa-kernel/pci/trident/trident_memory.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 6 7 * Trident 4DWave-NX memory page allocation (TLB area) 7 8 * Trident chip can handle only 16MByte of the memory at the same time. 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 */ 25 26 #include <asm/io.h> 9 */ 10 11 #include <linux/io.h> 27 12 #include <linux/pci.h> 28 13 #include <linux/time.h> … … 30 15 31 16 #include <sound/core.h> 32 #include <sound/trident.h>17 #include "trident.h" 33 18 34 19 /* page arguments of these two macros are Trident page (4096 bytes), not like … … 140 125 search_empty(struct snd_util_memhdr *hdr, int size) 141 126 { 142 struct snd_util_memblk *blk , *prev;127 struct snd_util_memblk *blk; 143 128 int page, psize; 144 129 struct list_head *p; 145 130 146 131 psize = get_aligned_page(size + ALIGN_PAGE_SIZE -1); 147 prev = NULL;148 132 page = 0; 149 133 list_for_each(p, &hdr->block) { … … 214 198 return NULL; 215 199 } 216 200 217 201 /* set TLB entries */ 218 202 idx = 0; … … 263 247 return NULL; 264 248 } 265 249 266 250 /* set TLB entries */ 267 251 addr = runtime->dma_addr;
Note:
See TracChangeset
for help on using the changeset viewer.
