Changeset 679 for GPL/trunk/alsa-kernel/pci/emu10k1
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (5 years ago)
- Location:
- GPL/trunk
- Files:
-
- 22 edited
-
. (modified) (1 prop)
-
alsa-kernel/pci/emu10k1/emu10k1.c (modified) (18 diffs)
-
alsa-kernel/pci/emu10k1/emu10k1_callback.c (modified) (10 diffs)
-
alsa-kernel/pci/emu10k1/emu10k1_main.c (modified) (45 diffs)
-
alsa-kernel/pci/emu10k1/emu10k1_patch.c (modified) (7 diffs)
-
alsa-kernel/pci/emu10k1/emu10k1_synth.c (modified) (4 diffs)
-
alsa-kernel/pci/emu10k1/emu10k1_synth_local.h (modified) (2 diffs)
-
alsa-kernel/pci/emu10k1/emu10k1x.c (modified) (57 diffs)
-
alsa-kernel/pci/emu10k1/emufx.c (modified) (76 diffs)
-
alsa-kernel/pci/emu10k1/emumixer.c (modified) (52 diffs)
-
alsa-kernel/pci/emu10k1/emumpu401.c (modified) (8 diffs)
-
alsa-kernel/pci/emu10k1/emupcm.c (modified) (46 diffs)
-
alsa-kernel/pci/emu10k1/emuproc.c (modified) (16 diffs)
-
alsa-kernel/pci/emu10k1/io.c (modified) (11 diffs)
-
alsa-kernel/pci/emu10k1/irq.c (modified) (7 diffs)
-
alsa-kernel/pci/emu10k1/memory.c (modified) (21 diffs)
-
alsa-kernel/pci/emu10k1/p16v.c (modified) (30 diffs)
-
alsa-kernel/pci/emu10k1/p16v.h (modified) (4 diffs)
-
alsa-kernel/pci/emu10k1/p17v.h (modified) (1 diff)
-
alsa-kernel/pci/emu10k1/timer.c (modified) (4 diffs)
-
alsa-kernel/pci/emu10k1/tina2.h (modified) (1 diff)
-
alsa-kernel/pci/emu10k1/voice.c (modified) (5 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/emu10k1/emu10k1.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * The driver for the EMU10K1 (SB Live!) based soundcards … … 5 6 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> 6 7 * Added support for Audigy 2 Value. 7 *8 *9 * This program is free software; you can redistribute it and/or modify10 * it under the terms of the GNU General Public License as published by11 * the Free Software Foundation; either version 2 of the License, or12 * (at your option) any later version.13 *14 * This program is distributed in the hope that it will be useful,15 * but WITHOUT ANY WARRANTY; without even the implied warranty of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU General Public License for more details.18 *19 * You should have received a copy of the GNU General Public License20 * along with this program; if not, write to the Free Software21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA22 *23 *24 8 */ 25 9 … … 27 11 #include <linux/pci.h> 28 12 #include <linux/time.h> 29 #include <linux/module param.h>13 #include <linux/module.h> 30 14 #include <sound/core.h> 31 15 #include <sound/emu10k1.h> 32 16 #include <sound/initval.h> 17 18 #ifdef TARGET_OS2 19 #define KBUILD_MODNAME "emu10k1" 20 #endif 33 21 34 22 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); … … 38 26 "{Creative Labs,SB Audigy}}"); 39 27 40 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))28 #if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER) 41 29 #define ENABLE_SYNTH 42 30 #include <sound/emu10k1_synth.h> … … 45 33 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 46 34 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 47 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */35 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 48 36 static int extin[SNDRV_CARDS]; 49 37 static int extout[SNDRV_CARDS]; … … 57 45 static int max_buffer_size[SNDRV_CARDS] = {128,128,128,128,128,128,128,128}; 58 46 #endif 59 static intenable_ir[SNDRV_CARDS];47 static bool enable_ir[SNDRV_CARDS]; 60 48 static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */ 61 49 #ifndef TARGET_OS2 … … 90 78 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 91 79 */ 92 static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1_ids)= {80 static const struct pci_device_id snd_emu10k1_ids[] = { 93 81 { PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */ 94 82 { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */ … … 110 98 MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids); 111 99 112 static int __devinitsnd_card_emu10k1_probe(struct pci_dev *pci,113 const struct pci_device_id *pci_id)100 static int snd_card_emu10k1_probe(struct pci_dev *pci, 101 const struct pci_device_id *pci_id) 114 102 { 115 103 static int dev; … … 128 116 } 129 117 130 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 118 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 119 0, &card); 131 120 if (err < 0) 132 121 return err; … … 142 131 card->private_data = emu; 143 132 emu->delay_pcm_irq = delay_pcm_irq[dev] & 0x1f; 144 if ((err = snd_emu10k1_pcm(emu, 0 , NULL)) < 0)145 goto error; 146 if ((err = snd_emu10k1_pcm_mic(emu, 1 , NULL)) < 0)147 goto error; 148 if ((err = snd_emu10k1_pcm_efx(emu, 2 , NULL)) < 0)133 if ((err = snd_emu10k1_pcm(emu, 0)) < 0) 134 goto error; 135 if ((err = snd_emu10k1_pcm_mic(emu, 1)) < 0) 136 goto error; 137 if ((err = snd_emu10k1_pcm_efx(emu, 2)) < 0) 149 138 goto error; 150 139 /* This stores the periods table. */ 151 140 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 152 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 153 1024, &emu->p16v_buffer)) < 0) 141 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 142 1024, &emu->p16v_buffer); 143 if (err < 0) 154 144 goto error; 155 145 } … … 161 151 goto error; 162 152 163 if ((err = snd_emu10k1_pcm_multi(emu, 3 , NULL)) < 0)153 if ((err = snd_emu10k1_pcm_multi(emu, 3)) < 0) 164 154 goto error; 165 155 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 166 if ((err = snd_p16v_pcm(emu, 4 , NULL)) < 0)156 if ((err = snd_p16v_pcm(emu, 4)) < 0) 167 157 goto error; 168 158 } … … 174 164 goto error; 175 165 } 176 if ((err = snd_emu10k1_fx8010_new(emu, 0 , NULL)) < 0)166 if ((err = snd_emu10k1_fx8010_new(emu, 0)) < 0) 177 167 goto error; 178 168 #ifdef ENABLE_SYNTH … … 180 170 sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 || 181 171 wave == NULL) { 182 snd_printk(KERN_WARNING "can't initialize Emu10k1 wavetable synth\n"); 172 dev_warn(emu->card->dev, 173 "can't initialize Emu10k1 wavetable synth\n"); 183 174 } else { 184 175 struct snd_emu10k1_synth_arg *arg; … … 192 183 #endif 193 184 194 strcpy(card->driver, emu->card_capabilities->driver); 195 strcpy(card->shortname, emu->card_capabilities->name); 185 strlcpy(card->driver, emu->card_capabilities->driver, 186 sizeof(card->driver)); 187 strlcpy(card->shortname, emu->card_capabilities->name, 188 sizeof(card->shortname)); 196 189 snprintf(card->longname, sizeof(card->longname), 197 190 "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i", … … 201 194 goto error; 202 195 196 if (emu->card_capabilities->emu_model) 197 schedule_delayed_work(&emu->emu1010.firmware_work, 0); 198 203 199 pci_set_drvdata(pci, card); 204 200 dev++; … … 210 206 } 211 207 212 static void __devexitsnd_card_emu10k1_remove(struct pci_dev *pci)208 static void snd_card_emu10k1_remove(struct pci_dev *pci) 213 209 { 214 210 snd_card_free(pci_get_drvdata(pci)); 215 pci_set_drvdata(pci, NULL); 216 } 217 218 219 #ifdef CONFIG_PM 220 static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state) 221 { 222 struct snd_card *card = pci_get_drvdata(pci); 211 } 212 213 214 #ifdef CONFIG_PM_SLEEP 215 static int snd_emu10k1_suspend(struct device *dev) 216 { 217 struct snd_card *card = dev_get_drvdata(dev); 223 218 struct snd_emu10k1 *emu = card->private_data; 224 219 225 220 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 226 221 227 snd_pcm_suspend_all(emu->pcm); 228 snd_pcm_suspend_all(emu->pcm_mic); 229 snd_pcm_suspend_all(emu->pcm_efx); 230 snd_pcm_suspend_all(emu->pcm_multi); 231 snd_pcm_suspend_all(emu->pcm_p16v); 222 emu->suspend = 1; 223 224 cancel_delayed_work_sync(&emu->emu1010.firmware_work); 232 225 233 226 snd_ac97_suspend(emu->ac97); … … 239 232 240 233 snd_emu10k1_done(emu); 241 242 pci_disable_device(pci);243 pci_save_state(pci);244 pci_set_power_state(pci, pci_choose_state(pci, state));245 234 return 0; 246 235 } 247 236 248 static int snd_emu10k1_resume(struct pci_dev *pci)249 { 250 struct snd_card *card = pci_get_drvdata(pci);237 static int snd_emu10k1_resume(struct device *dev) 238 { 239 struct snd_card *card = dev_get_drvdata(dev); 251 240 struct snd_emu10k1 *emu = card->private_data; 252 253 pci_set_power_state(pci, PCI_D0);254 pci_restore_state(pci);255 if (pci_enable_device(pci) < 0) {256 printk(KERN_ERR "emu10k1: pci_enable_device failed, "257 "disabling device\n");258 snd_card_disconnect(card);259 return -EIO;260 }261 pci_set_master(pci);262 241 263 242 snd_emu10k1_resume_init(emu); … … 269 248 snd_p16v_resume(emu); 270 249 250 emu->suspend = 0; 251 271 252 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 253 254 if (emu->card_capabilities->emu_model) 255 schedule_delayed_work(&emu->emu1010.firmware_work, 0); 256 272 257 return 0; 273 258 } 274 #endif 275 276 static struct pci_driver driver = { 277 .name = "EMU10K1_Audigy", 259 260 static SIMPLE_DEV_PM_OPS(snd_emu10k1_pm, snd_emu10k1_suspend, snd_emu10k1_resume); 261 #define SND_EMU10K1_PM_OPS &snd_emu10k1_pm 262 #else 263 #define SND_EMU10K1_PM_OPS NULL 264 #endif /* CONFIG_PM_SLEEP */ 265 266 static struct pci_driver emu10k1_driver = { 267 .name = KBUILD_MODNAME, 278 268 .id_table = snd_emu10k1_ids, 279 269 .probe = snd_card_emu10k1_probe, 280 .remove = __devexit_p(snd_card_emu10k1_remove), 281 #ifdef CONFIG_PM 282 .suspend = snd_emu10k1_suspend, 283 .resume = snd_emu10k1_resume, 284 #endif 270 .remove = snd_card_emu10k1_remove, 271 .driver = { 272 .pm = SND_EMU10K1_PM_OPS, 273 }, 285 274 }; 286 275 287 static int __init alsa_card_emu10k1_init(void) 288 { 289 return pci_register_driver(&driver); 290 } 291 292 static void __exit alsa_card_emu10k1_exit(void) 293 { 294 pci_unregister_driver(&driver); 295 } 296 297 module_init(alsa_card_emu10k1_init) 298 module_exit(alsa_card_emu10k1_exit) 276 module_pci_driver(emu10k1_driver); -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_callback.c
r426 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * synth callback routines for Emu10k1 3 4 * 4 5 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 6 */ 7 8 #include <linux/export.h> 21 9 #include "emu10k1_synth_local.h" 22 10 #include <sound/asoundef.h> … … 61 49 * set up operators 62 50 */ 63 static struct snd_emux_operators emu10k1_ops = {51 static const struct snd_emux_operators emu10k1_ops = { 64 52 .owner = THIS_MODULE, 65 53 .get_voice = get_voice, … … 85 73 * 86 74 * terminate most inactive voice and give it as a pcm voice. 75 * 76 * voice_lock is already held. 87 77 */ 88 78 int … … 92 82 struct snd_emux_voice *vp; 93 83 struct best_voice best[V_END]; 94 unsigned long flags;95 84 int i; 96 85 97 86 emu = hw->synth; 98 87 99 spin_lock_irqsave(&emu->voice_lock, flags);100 88 lookup_voices(emu, hw, best, 1); /* no OFF voices */ 101 89 for (i = 0; i < V_END; i++) { … … 105 93 if ((ch = vp->ch) < 0) { 106 94 /* 107 printk(KERN_WARNING95 dev_warn(emu->card->dev, 108 96 "synth_get_voice: ch < 0 (%d) ??", i); 109 97 */ … … 113 101 vp->ch = -1; 114 102 vp->state = SNDRV_EMUX_ST_OFF; 115 spin_unlock_irqrestore(&emu->voice_lock, flags);116 103 return ch; 117 104 } 118 105 } 119 spin_unlock_irqrestore(&emu->voice_lock, flags);120 106 121 107 /* not found */ … … 228 214 229 215 for (i = 0; i < V_END; i++) { 230 best[i].time = (unsigned int)-1; /* XXX MAX_?INT really */ ;216 best[i].time = (unsigned int)-1; /* XXX MAX_?INT really */ 231 217 best[i].voice = -1; 232 218 } … … 339 325 emem->map_locked++; 340 326 if (snd_emu10k1_memblk_map(hw, emem) < 0) { 341 /* printk(KERN_ERR"emu: cannot map!\n"); */327 /* dev_err(hw->card->devK, "emu: cannot map!\n"); */ 342 328 return -ENOMEM; 343 329 } … … 417 403 418 404 /* invalidate maps */ 419 temp = (hw->silent_page.addr << 1) | MAP_PTI_MASK;405 temp = (hw->silent_page.addr << hw->address_mode) | (hw->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0); 420 406 snd_emu10k1_ptr_write(hw, MAPA, ch, temp); 421 407 snd_emu10k1_ptr_write(hw, MAPB, ch, temp); … … 438 424 439 425 /* invalidate maps */ 440 temp = ((unsigned int)hw->silent_page.addr << 1) | MAP_PTI_MASK;426 temp = ((unsigned int)hw->silent_page.addr << hw_address_mode) | (hw->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0); 441 427 snd_emu10k1_ptr_write(hw, MAPA, ch, temp); 442 428 snd_emu10k1_ptr_write(hw, MAPB, ch, temp); -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_main.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 9 10 * General bug fixes and enhancements. 10 11 * 11 *12 12 * BUGS: 13 13 * -- … … 15 15 * TODO: 16 16 * -- 17 *18 * This program is free software; you can redistribute it and/or modify19 * it under the terms of the GNU General Public License as published by20 * the Free Software Foundation; either version 2 of the License, or21 * (at your option) any later version.22 *23 * This program is distributed in the hope that it will be useful,24 * but WITHOUT ANY WARRANTY; without even the implied warranty of25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the26 * GNU General Public License for more details.27 *28 * You should have received a copy of the GNU General Public License29 * along with this program; if not, write to the Free Software30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA31 *32 17 */ 33 18 19 #ifdef TARGET_OS2 20 #define KBUILD_MODNAME "emu10k1" 21 #include <linux/dma-mapping.h> 22 #endif 23 34 24 #include <linux/sched.h> 35 #include <linux/kthread.h>36 25 #include <linux/delay.h> 37 26 #include <linux/init.h> 27 #include <linux/module.h> 38 28 #include <linux/interrupt.h> 29 #include <linux/iommu.h> 39 30 #include <linux/pci.h> 40 31 #include <linux/slab.h> … … 118 109 } 119 110 120 static unsigned int spi_dac_init[] = {111 static const unsigned int spi_dac_init[] = { 121 112 0x00ff, 122 113 0x02ff, … … 142 133 }; 143 134 144 static unsigned int i2c_adc_init[][2] = {135 static const unsigned int i2c_adc_init[][2] = { 145 136 { 0x17, 0x00 }, /* Reset */ 146 137 { 0x07, 0x00 }, /* Timeout */ … … 220 211 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ 221 212 /* Hacks for Alice3 to work independent of haP16V driver */ 222 snd_printk(KERN_INFO"Audigy2 value: Special config.\n");213 dev_info(emu->card->dev, "Audigy2 value: Special config.\n"); 223 214 /* Setup SRCMulti_I2S SamplingRate */ 224 215 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); … … 285 276 snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ 286 277 287 silent_page = (emu->silent_page.addr << 1) | MAP_PTI_MASK;278 silent_page = (emu->silent_page.addr << emu->address_mode) | (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0); 288 279 for (ch = 0; ch < NUM_G; ch++) { 289 280 snd_emu10k1_ptr_write(emu, MAPA, ch, silent_page); … … 351 342 } 352 343 344 if (emu->address_mode == 0) { 345 /* use 16M in 4G */ 346 outl(inl(emu->port + HCFG) | HCFG_EXPANDED_MEM, emu->port + HCFG); 347 } 348 353 349 return 0; 354 350 } … … 636 632 { 637 633 unsigned long special_port; 638 unsigned int value;634 __always_unused unsigned int value; 639 635 640 636 /* Special initialisation routine … … 660 656 } 661 657 662 static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, const char *filename) 658 static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, 659 const struct firmware *fw_entry) 663 660 { 664 int err;665 661 int n, i; 666 662 int reg; 667 663 int value; 668 unsigned int write_post;664 __always_unused unsigned int write_post; 669 665 unsigned long flags; 670 const struct firmware *fw_entry; 671 672 err = request_firmware(&fw_entry, filename, &emu->pci->dev); 673 if (err != 0) { 674 snd_printk(KERN_ERR "firmware: %s not found. Err = %d\n", filename, err); 675 return err; 676 } 677 snd_printk(KERN_INFO "firmware size = 0x%zx\n", fw_entry->size); 666 667 if (!fw_entry) 668 return -EIO; 678 669 679 670 /* The FPGA is a Xilinx Spartan IIE XC2S50E */ … … 708 699 spin_unlock_irqrestore(&emu->emu_lock, flags); 709 700 710 release_firmware(fw_entry);711 701 return 0; 712 702 } 713 703 714 #if kthread_create != 0 /* DAZ to stop compiler warning */ 715 static int emu1010_firmware_thread(void *data) 704 /* firmware file names, per model, init-fw and dock-fw (optional) */ 705 static const char * const firmware_names[5][2] = { 706 [EMU_MODEL_EMU1010] = { 707 HANA_FILENAME, DOCK_FILENAME 708 }, 709 [EMU_MODEL_EMU1010B] = { 710 EMU1010B_FILENAME, MICRO_DOCK_FILENAME 711 }, 712 [EMU_MODEL_EMU1616] = { 713 EMU1010_NOTEBOOK_FILENAME, MICRO_DOCK_FILENAME 714 }, 715 [EMU_MODEL_EMU0404] = { 716 EMU0404_FILENAME, NULL 717 }, 718 }; 719 720 static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, 721 const struct firmware **fw) 716 722 { 717 struct snd_emu10k1 *emu = data; 723 const char *filename; 724 int err; 725 726 if (!*fw) { 727 filename = firmware_names[emu->card_capabilities->emu_model][dock]; 728 if (!filename) 729 return 0; 730 err = request_firmware(fw, filename, &emu->pci->dev); 731 if (err) 732 return err; 733 } 734 735 return snd_emu1010_load_firmware_entry(emu, *fw); 736 } 737 738 static void emu1010_firmware_work(struct work_struct *work) 739 { 740 struct snd_emu10k1 *emu; 718 741 u32 tmp, tmp2, reg; 719 742 int err; 720 743 721 for (;;) { 722 /* Delay to allow Audio Dock to settle */ 723 msleep_interruptible(1000); 724 if (kthread_should_stop()) 725 break; 726 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp); /* IRQ Status */ 727 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); /* OPTIONS: Which cards are attached to the EMU */ 728 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { 729 /* Audio Dock attached */ 730 /* Return to Audio Dock programming mode */ 731 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 732 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK); 733 if (emu->card_capabilities->emu_model == 734 EMU_MODEL_EMU1010) { 735 err = snd_emu1010_load_firmware(emu, DOCK_FILENAME); 736 if (err != 0) 737 continue; 738 } else if (emu->card_capabilities->emu_model == 739 EMU_MODEL_EMU1010B) { 740 err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME); 741 if (err != 0) 742 continue; 743 } else if (emu->card_capabilities->emu_model == 744 EMU_MODEL_EMU1616) { 745 err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME); 746 if (err != 0) 747 continue; 748 } 749 750 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); 751 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ®); 752 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", reg); 753 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 754 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); 755 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg); 756 if ((reg & 0x1f) != 0x15) { 757 /* FPGA failed to be programmed */ 758 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg); 759 continue; 760 } 761 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); 762 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); 763 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); 764 snd_printk(KERN_INFO "Audio Dock ver: %u.%u\n", 765 tmp, tmp2); 766 /* Sync clocking between 1010 and Dock */ 767 /* Allow DLL to settle */ 768 msleep(10); 769 /* Unmute all. Default is muted after a firmware load */ 770 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); 744 emu = container_of(work, struct snd_emu10k1, 745 emu1010.firmware_work.work); 746 if (emu->card->shutdown) 747 return; 748 #ifdef CONFIG_PM_SLEEP 749 if (emu->suspend) 750 return; 751 #endif 752 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp); /* IRQ Status */ 753 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); /* OPTIONS: Which cards are attached to the EMU */ 754 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { 755 /* Audio Dock attached */ 756 /* Return to Audio Dock programming mode */ 757 dev_info(emu->card->dev, 758 "emu1010: Loading Audio Dock Firmware\n"); 759 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 760 EMU_HANA_FPGA_CONFIG_AUDIODOCK); 761 err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); 762 if (err < 0) 763 goto next; 764 765 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); 766 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp); 767 dev_info(emu->card->dev, 768 "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", tmp); 769 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 770 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &tmp); 771 dev_info(emu->card->dev, 772 "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", tmp); 773 if ((tmp & 0x1f) != 0x15) { 774 /* FPGA failed to be programmed */ 775 dev_info(emu->card->dev, 776 "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", 777 tmp); 778 goto next; 771 779 } 772 } 773 snd_printk(KERN_INFO "emu1010: firmware thread stopping\n"); 774 return 0; 780 dev_info(emu->card->dev, 781 "emu1010: Audio Dock Firmware loaded\n"); 782 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); 783 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); 784 dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2); 785 /* Sync clocking between 1010 and Dock */ 786 /* Allow DLL to settle */ 787 msleep(10); 788 /* Unmute all. Default is muted after a firmware load */ 789 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); 790 } else if (!reg && emu->emu1010.last_reg) { 791 /* Audio Dock removed */ 792 dev_info(emu->card->dev, "emu1010: Audio Dock detached\n"); 793 /* Unmute all */ 794 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); 795 } 796 797 next: 798 emu->emu1010.last_reg = reg; 799 if (!emu->card->shutdown) 800 schedule_delayed_work(&emu->emu1010.firmware_work, 801 msecs_to_jiffies(1000)); 775 802 } 776 #endif803 //#endif 777 804 778 805 /* … … 812 839 u32 tmp, tmp2, reg; 813 840 int err; 814 const char *filename = NULL; 815 816 snd_printk(KERN_INFO "emu1010: Special config.\n"); 841 842 dev_info(emu->card->dev, "emu1010: Special config.\n"); 817 843 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 818 844 * Lock Sound Memory Cache, Lock Tank Memory Cache, … … 839 865 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 840 866 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); 841 snd_printdd("reg1 = 0x%x\n", reg);867 dev_dbg(emu->card->dev, "reg1 = 0x%x\n", reg); 842 868 if ((reg & 0x3f) == 0x15) { 843 869 /* FPGA netlist already present so clear it */ … … 847 873 } 848 874 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); 849 snd_printdd("reg2 = 0x%x\n", reg);875 dev_dbg(emu->card->dev, "reg2 = 0x%x\n", reg); 850 876 if ((reg & 0x3f) == 0x15) { 851 877 /* FPGA failed to return to programming mode */ 852 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n"); 878 dev_info(emu->card->dev, 879 "emu1010: FPGA failed to return to programming mode\n"); 853 880 return -ENODEV; 854 881 } 855 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID = 0x%x\n", reg); 856 switch (emu->card_capabilities->emu_model) { 857 case EMU_MODEL_EMU1010: 858 filename = HANA_FILENAME; 859 break; 860 case EMU_MODEL_EMU1010B: 861 filename = EMU1010B_FILENAME; 862 break; 863 case EMU_MODEL_EMU1616: 864 filename = EMU1010_NOTEBOOK_FILENAME; 865 break; 866 case EMU_MODEL_EMU0404: 867 filename = EMU0404_FILENAME; 868 break; 869 default: 870 filename = NULL; 871 return -ENODEV; 872 break; 873 } 874 snd_printk(KERN_INFO "emu1010: filename %s testing\n", filename); 875 err = snd_emu1010_load_firmware(emu, filename); 876 if (err != 0) { 877 snd_printk( 878 KERN_INFO "emu1010: Loading Firmware file %s failed\n", 879 filename); 882 dev_info(emu->card->dev, "emu1010: EMU_HANA_ID = 0x%x\n", reg); 883 884 err = snd_emu1010_load_firmware(emu, 0, &emu->firmware); 885 if (err < 0) { 886 dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); 880 887 return err; 881 888 } … … 885 892 if ((reg & 0x3f) != 0x15) { 886 893 /* FPGA failed to be programmed */ 887 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg); 894 dev_info(emu->card->dev, 895 "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", 896 reg); 888 897 return -ENODEV; 889 898 } 890 899 891 snd_printk(KERN_INFO"emu1010: Hana Firmware loaded\n");900 dev_info(emu->card->dev, "emu1010: Hana Firmware loaded\n"); 892 901 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp); 893 902 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2); 894 snd_printk(KERN_INFO"emu1010: Hana version: %u.%u\n", tmp, tmp2);903 dev_info(emu->card->dev, "emu1010: Hana version: %u.%u\n", tmp, tmp2); 895 904 /* Enable 48Volt power to Audio Dock */ 896 905 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON); 897 906 898 907 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); 899 snd_printk(KERN_INFO"emu1010: Card options = 0x%x\n", reg);908 dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg); 900 909 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); 901 snd_printk(KERN_INFO"emu1010: Card options = 0x%x\n", reg);910 dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg); 902 911 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp); 903 912 /* Optical -> ADAT I/O */ … … 932 941 /* Unknown. */ 933 942 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c); 934 /* IRQ Enable: All lon */943 /* IRQ Enable: All on */ 935 944 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); */ 936 945 /* IRQ Enable: All off */ … … 938 947 939 948 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); 940 snd_printk(KERN_INFO"emu1010: Card options3 = 0x%x\n", reg);949 dev_info(emu->card->dev, "emu1010: Card options3 = 0x%x\n", reg); 941 950 /* Default WCLK set to 48kHz. */ 942 951 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00); … … 1096 1105 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp); 1097 1106 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ 1098 1099 /* Start Micro/Audio Dock firmware loader thread */1100 if (!emu->emu1010.firmware_thread) {1101 emu->emu1010.firmware_thread =1102 kthread_create(emu1010_firmware_thread, emu,1103 "emu1010_firmware");1104 wake_up_process(emu->emu1010.firmware_thread);1105 }1106 1107 1107 1108 #if 0 … … 1246 1247 */ 1247 1248 1248 #ifdef CONFIG_PM 1249 #ifdef CONFIG_PM_SLEEP 1249 1250 static int alloc_pm_buffer(struct snd_emu10k1 *emu); 1250 1251 static void free_pm_buffer(struct snd_emu10k1 *emu); … … 1262 1263 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0); 1263 1264 } 1264 if (emu->emu1010.firmware_thread) 1265 kthread_stop(emu->emu1010.firmware_thread); 1265 cancel_delayed_work_sync(&emu->emu1010.firmware_work); 1266 release_firmware(emu->firmware); 1267 release_firmware(emu->dock_fw); 1266 1268 if (emu->irq >= 0) 1267 1269 free_irq(emu->irq, emu); 1268 /* remove reserved page */ 1269 if (emu->reserved_page) { 1270 snd_emu10k1_synth_free(emu, 1271 (struct snd_util_memblk *)emu->reserved_page); 1272 emu->reserved_page = NULL; 1273 } 1274 if (emu->memhdr) 1275 snd_util_memhdr_free(emu->memhdr); 1270 snd_util_memhdr_free(emu->memhdr); 1276 1271 if (emu->silent_page.area) 1277 1272 snd_dma_free_pages(&emu->silent_page); … … 1280 1275 vfree(emu->page_ptr_table); 1281 1276 vfree(emu->page_addr_table); 1282 #ifdef CONFIG_PM 1277 #ifdef CONFIG_PM_SLEEP 1283 1278 free_pm_buffer(emu); 1284 1279 #endif … … 1298 1293 } 1299 1294 1300 static struct snd_emu_chip_details emu_chip_details[] = { 1295 static const struct snd_emu_chip_details emu_chip_details[] = { 1296 /* Audigy 5/Rx SB1550 */ 1297 /* Tested by michael@gernoth.net 28 Mar 2015 */ 1298 /* DSP: CA10300-IAT LF 1299 * DAC: Cirrus Logic CS4382-KQZ 1300 * ADC: Philips 1361T 1301 * AC97: Sigmatel STAC9750 1302 * CA0151: None 1303 */ 1304 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10241102, 1305 .driver = "Audigy2", .name = "SB Audigy 5/Rx [SB1550]", 1306 .id = "Audigy2", 1307 .emu10k2_chip = 1, 1308 .ca0108_chip = 1, 1309 .spk71 = 1, 1310 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1311 .ac97_chip = 1}, 1301 1312 /* Audigy4 (Not PRO) SB0610 */ 1302 1313 /* Tested by James@superbug.co.uk 4th April 2006 */ … … 1395 1406 */ 1396 1407 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, 1397 .driver = "Audigy2", .name = " SBAudigy 2 ZS Notebook [SB0530]",1408 .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", 1398 1409 .id = "Audigy2", 1399 1410 .emu10k2_chip = 1, … … 1421 1432 .spk71 = 1, 1422 1433 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */ 1434 /* Tested by Maxim Kachur <mcdebugger@duganet.ru> 17th Oct 2012. */ 1435 /* This is MAEM8986, 0202 is MAEM8980 */ 1436 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40071102, 1437 .driver = "Audigy2", .name = "E-mu 1010 PCIe [MAEM8986]", 1438 .id = "EMU1010", 1439 .emu10k2_chip = 1, 1440 .ca0108_chip = 1, 1441 .spk71 = 1, 1442 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 PCIe */ 1423 1443 /* Tested by James@superbug.co.uk 8th July 2005. */ 1424 1444 /* This is MAEM8810, 0202 is MAEM8820 */ … … 1446 1466 .spk71 = 1, 1447 1467 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ 1468 /* EMU0404 PCIe */ 1469 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40051102, 1470 .driver = "Audigy2", .name = "E-mu 0404 PCIe [MAEM8984]", 1471 .id = "EMU0404", 1472 .emu10k2_chip = 1, 1473 .ca0108_chip = 1, 1474 .spk71 = 1, 1475 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 PCIe ver_03 */ 1448 1476 /* Note that all E-mu cards require kernel 2.6 or newer. */ 1449 1477 {.vendor = 0x1102, .device = 0x0008, … … 1469 1497 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, 1470 1498 .driver = "Audigy2", .name = "SB Audigy 2 [SB0350b]", 1499 .id = "Audigy2", 1500 .emu10k2_chip = 1, 1501 .ca0102_chip = 1, 1502 .ca0151_chip = 1, 1503 .spk71 = 1, 1504 .spdif_bug = 1, 1505 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1506 .ac97_chip = 1} , 1507 /* 0x20051102 also has SB0350 written on it, treated as Audigy 2 ZS by 1508 Creative's Windows driver */ 1509 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20051102, 1510 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350a]", 1471 1511 .id = "Audigy2", 1472 1512 .emu10k2_chip = 1, … … 1516 1556 .ac97_chip = 1} , 1517 1557 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 1518 .driver = "Audigy2", .name = " SBAudigy 2 Platinum EX [SB0280]",1558 .driver = "Audigy2", .name = "Audigy 2 Platinum EX [SB0280]", 1519 1559 .id = "Audigy2", 1520 1560 .emu10k2_chip = 1, … … 1714 1754 }; 1715 1755 1716 int __devinit snd_emu10k1_create(struct snd_card *card, 1756 /* 1757 * The chip (at least the Audigy 2 CA0102 chip, but most likely others, too) 1758 * has a problem that from time to time it likes to do few DMA reads a bit 1759 * beyond its normal allocation and gets very confused if these reads get 1760 * blocked by a IOMMU. 1761 * 1762 * This behaviour has been observed for the first (reserved) page 1763 * (for which it happens multiple times at every playback), often for various 1764 * synth pages and sometimes for PCM playback buffers and the page table 1765 * memory itself. 1766 * 1767 * As a workaround let's widen these DMA allocations by an extra page if we 1768 * detect that the device is behind a non-passthrough IOMMU. 1769 */ 1770 static void snd_emu10k1_detect_iommu(struct snd_emu10k1 *emu) 1771 { 1772 struct iommu_domain *domain; 1773 1774 emu->iommu_workaround = false; 1775 1776 if (!iommu_present(emu->card->dev->bus)) 1777 return; 1778 1779 domain = iommu_get_domain_for_dev(emu->card->dev); 1780 if (domain && domain->type == IOMMU_DOMAIN_IDENTITY) 1781 return; 1782 1783 dev_notice(emu->card->dev, 1784 "non-passthrough IOMMU detected, widening DMA allocations"); 1785 emu->iommu_workaround = true; 1786 } 1787 1788 int snd_emu10k1_create(struct snd_card *card, 1717 1789 struct pci_dev *pci, 1718 1790 unsigned short extin_mask, … … 1726 1798 int idx, err; 1727 1799 int is_audigy; 1800 size_t page_table_size; 1801 __le32 *pgtbl; 1728 1802 unsigned int silent_page; 1729 1803 const struct snd_emu_chip_details *c; 1730 static struct snd_device_ops ops = {1804 static const struct snd_device_ops ops = { 1731 1805 .dev_free = snd_emu10k1_dev_free, 1732 1806 }; … … 1759 1833 emu->synth = NULL; 1760 1834 emu->get_synth_voice = NULL; 1835 INIT_DELAYED_WORK(&emu->emu1010.firmware_work, emu1010_firmware_work); 1761 1836 /* read revision & serial */ 1762 1837 #ifndef TARGET_OS2 … … 1767 1842 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1768 1843 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1769 snd_printdd("vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", pci->vendor, pci->device, emu->serial, emu->model); 1844 dev_dbg(card->dev, 1845 "vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", 1846 pci->vendor, pci->device, emu->serial, emu->model); 1770 1847 1771 1848 for (c = emu_chip_details; c->vendor; c++) { … … 1786 1863 } 1787 1864 if (c->vendor == 0) { 1788 snd_printk(KERN_ERR"emu10k1: Card not recognised\n");1865 dev_err(card->dev, "emu10k1: Card not recognised\n"); 1789 1866 kfree(emu); 1790 1867 pci_disable_device(pci); … … 1793 1870 emu->card_capabilities = c; 1794 1871 if (c->subsystem && !subsystem) 1795 snd_printdd("Sound card name = %s\n", c->name);1872 dev_dbg(card->dev, "Sound card name = %s\n", c->name); 1796 1873 else if (subsystem) 1797 snd_printdd("Sound card name = %s, "1874 dev_dbg(card->dev, "Sound card name = %s, " 1798 1875 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. " 1799 1876 "Forced to subsystem = 0x%x\n", c->name, 1800 1877 pci->vendor, pci->device, emu->serial, c->subsystem); 1801 1878 else 1802 snd_printdd("Sound card name = %s, "1879 dev_dbg(card->dev, "Sound card name = %s, " 1803 1880 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n", 1804 1881 c->name, pci->vendor, pci->device, 1805 1882 emu->serial); 1806 1883 1807 if (!*card->id && c->id) { 1808 int i, n = 0; 1884 if (!*card->id && c->id) 1809 1885 strlcpy(card->id, c->id, sizeof(card->id)); 1810 for (;;) {1811 for (i = 0; i < snd_ecards_limit; i++) {1812 if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id))1813 break;1814 }1815 if (i >= snd_ecards_limit)1816 break;1817 n++;1818 if (n >= SNDRV_CARDS)1819 break;1820 snprintf(card->id, sizeof(card->id), "%s_%d", c->id, n);1821 }1822 }1823 1886 1824 1887 is_audigy = emu->audigy = c->emu10k2_chip; 1825 1888 1889 snd_emu10k1_detect_iommu(emu); 1890 1891 /* set addressing mode */ 1892 emu->address_mode = is_audigy ? 0 : 1; 1826 1893 /* set the DMA transfer mask */ 1827 emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK; 1828 if (pci_set_dma_mask(pci, emu->dma_mask) < 0 || 1829 pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) { 1830 snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask); 1894 emu->dma_mask = emu->address_mode ? EMU10K1_DMA_MASK : AUDIGY_DMA_MASK; 1895 if (dma_set_mask_and_coherent(&pci->dev, emu->dma_mask) < 0) { 1896 dev_err(card->dev, 1897 "architecture does not support PCI busmaster DMA with mask 0x%lx\n", 1898 emu->dma_mask); 1831 1899 kfree(emu); 1832 1900 pci_disable_device(pci); … … 1847 1915 1848 1916 emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT; 1849 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1850 32 * 1024, &emu->ptb_pages) < 0) { 1917 1918 page_table_size = sizeof(u32) * (emu->address_mode ? MAXPAGES1 : 1919 MAXPAGES0); 1920 if (snd_emu10k1_alloc_pages_maybe_wider(emu, page_table_size, 1921 &emu->ptb_pages) < 0) { 1851 1922 err = -ENOMEM; 1852 1923 goto error; 1853 1924 } 1854 1925 dev_dbg(card->dev, "page table address range is %.8lx:%.8lx\n", 1926 (unsigned long)emu->ptb_pages.addr, 1927 (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes)); 1928 1929 #ifdef TARGET_OS2 1930 emu->page_ptr_table = vmalloc(array_size(sizeof(void *), 1931 emu->max_cache_pages)); 1932 emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long), 1933 emu->max_cache_pages)); 1934 #else 1855 1935 emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *)); 1856 1936 emu->page_addr_table = vmalloc(emu->max_cache_pages * 1857 1937 sizeof(unsigned long)); 1938 #endif 1858 1939 if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { 1859 1940 err = -ENOMEM; … … 1861 1942 } 1862 1943 1863 if (snd_ dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),1864 EMUPAGESIZE,&emu->silent_page) < 0) {1944 if (snd_emu10k1_alloc_pages_maybe_wider(emu, EMUPAGESIZE, 1945 &emu->silent_page) < 0) { 1865 1946 err = -ENOMEM; 1866 1947 goto error; 1867 1948 } 1949 dev_dbg(card->dev, "silent page range is %.8lx:%.8lx\n", 1950 (unsigned long)emu->silent_page.addr, 1951 (unsigned long)(emu->silent_page.addr + 1952 emu->silent_page.bytes)); 1953 1868 1954 emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); 1869 1955 if (emu->memhdr == NULL) { … … 1914 2000 /* irq handler must be registered after I/O ports are activated */ 1915 2001 if (request_irq(pci->irq, snd_emu10k1_interrupt, IRQF_SHARED, 1916 "EMU10K1", emu)) {2002 KBUILD_MODNAME, emu)) { 1917 2003 err = -EBUSY; 1918 2004 goto error; 1919 2005 } 1920 2006 emu->irq = pci->irq; 2007 card->sync_irq = emu->irq; 1921 2008 1922 2009 /* … … 1940 2027 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; 1941 2028 1942 emu->reserved_page = (struct snd_emu10k1_memblk *)1943 snd_emu10k1_synth_alloc(emu, 4096);1944 if (emu->reserved_page)1945 emu->reserved_page->map_locked = 1;1946 1947 2029 /* Clear silent pages and set up pointers */ 1948 memset(emu->silent_page.area, 0, PAGE_SIZE); 1949 silent_page = emu->silent_page.addr << 1; 1950 for (idx = 0; idx < MAXPAGES; idx++) 1951 ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); 2030 memset(emu->silent_page.area, 0, emu->silent_page.bytes); 2031 silent_page = emu->silent_page.addr << emu->address_mode; 2032 pgtbl = (__le32 *)emu->ptb_pages.area; 2033 for (idx = 0; idx < (emu->address_mode ? MAXPAGES1 : MAXPAGES0); idx++) 2034 pgtbl[idx] = cpu_to_le32(silent_page | idx); 1952 2035 1953 2036 /* set up voice indices */ … … 1960 2043 if (err < 0) 1961 2044 goto error; 1962 #ifdef CONFIG_PM 2045 #ifdef CONFIG_PM_SLEEP 1963 2046 err = alloc_pm_buffer(emu); 1964 2047 if (err < 0) … … 1976 2059 goto error; 1977 2060 1978 #ifdef CONFIG_ PROC_FS2061 #ifdef CONFIG_SND_PROC_FS 1979 2062 snd_emu10k1_proc_init(emu); 1980 2063 #endif 1981 2064 1982 snd_card_set_dev(card, &pci->dev);1983 2065 *remu = emu; 1984 2066 return 0; … … 1989 2071 } 1990 2072 1991 #ifdef CONFIG_PM 1992 static unsigned char saved_regs[] = {2073 #ifdef CONFIG_PM_SLEEP 2074 static const unsigned char saved_regs[] = { 1993 2075 CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, 1994 2076 FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, … … 1999 2081 0xff /* end */ 2000 2082 }; 2001 static unsigned char saved_regs_audigy[] = {2083 static const unsigned char saved_regs_audigy[] = { 2002 2084 A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE, 2003 2085 A_FXRT2, A_SENDAMOUNTS, A_FXRT1, … … 2005 2087 }; 2006 2088 2007 static int __devinitalloc_pm_buffer(struct snd_emu10k1 *emu)2089 static int alloc_pm_buffer(struct snd_emu10k1 *emu) 2008 2090 { 2009 2091 int size; … … 2012 2094 if (emu->audigy) 2013 2095 size += ARRAY_SIZE(saved_regs_audigy); 2096 #ifdef TARGET_OS2 2097 emu->saved_ptr = vmalloc(array3_size(4, NUM_G, size)); 2098 #else 2014 2099 emu->saved_ptr = vmalloc(4 * NUM_G * size); 2100 #endif 2015 2101 if (!emu->saved_ptr) 2016 2102 return -ENOMEM; … … 2034 2120 { 2035 2121 int i; 2036 unsigned char *reg;2122 const unsigned char *reg; 2037 2123 unsigned int *val; 2038 2124 … … 2067 2153 { 2068 2154 int i; 2069 unsigned char *reg;2155 const unsigned char *reg; 2070 2156 unsigned int *val; 2071 2157 -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_patch.c
r399 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Patch transfer callback for Emu10k1 3 4 * 4 5 * Copyright (C) 2000 Takashi iwai <tiwai@suse.de> 5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 6 */ 20 7 /* … … 32 19 #define BLANK_HEAD_SIZE 32 33 20 21 #ifdef TARGET_OS2 22 #define swap(a, b) \ 23 do { int __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 24 #endif 34 25 /* 35 26 * allocate a sample block and copy data from userspace … … 41 32 { 42 33 int offset; 43 int truesize, size, loopsize, blocksize; 34 int truesize, size, blocksize; 35 __maybe_unused int loopsize; 44 36 int loopend, sampleend; 45 37 unsigned int start_addr; … … 51 43 52 44 if (sp->v.size == 0) { 53 snd_printd("emu: rom font for sample %d\n", sp->v.sample); 45 dev_dbg(emu->card->dev, 46 "emu: rom font for sample %d\n", sp->v.sample); 54 47 return 0; 55 48 } … … 70 63 71 64 /* be sure loop points start < end */ 72 if (sp->v.loopstart >= sp->v.loopend) { 73 int tmp = sp->v.loopstart; 74 sp->v.loopstart = sp->v.loopend; 75 sp->v.loopend = tmp; 76 } 65 if (sp->v.loopstart >= sp->v.loopend) 66 swap(sp->v.loopstart, sp->v.loopend); 77 67 78 68 /* compute true data size to be loaded */ … … 93 83 sp->block = snd_emu10k1_synth_alloc(emu, blocksize); 94 84 if (sp->block == NULL) { 95 snd_printd("emu10k1: synth malloc failed (size=%d)\n", blocksize); 85 dev_dbg(emu->card->dev, 86 "synth malloc failed (size=%d)\n", blocksize); 96 87 /* not ENOMEM (for compatibility with OSS) */ 97 88 return -ENOSPC; … … 124 115 data += size; 125 116 126 #if 0 /* not supp ported yet */117 #if 0 /* not supported yet */ 127 118 /* handle reverse (or bidirectional) loop */ 128 119 if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP|SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) { -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_synth.c
r305 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de> 3 4 * 4 5 * Routines for control of EMU10K1 WaveTable synth 5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 6 */ 20 7 21 8 #include "emu10k1_synth_local.h" 22 9 #include <linux/init.h> 10 #include <linux/module.h> 23 11 24 12 MODULE_AUTHOR("Takashi Iwai"); … … 26 14 MODULE_LICENSE("GPL"); 27 15 16 #ifdef TARGET_OS2 17 #define KBUILD_MODNAME "emu10k1_synth" 18 #endif 19 28 20 /* 29 21 * create a new hardware dependent device for Emu10k1 30 22 */ 31 static int snd_emu10k1_synth_ new_device(struct snd_seq_device *dev)23 static int snd_emu10k1_synth_probe(struct device *_dev) 32 24 { 25 struct snd_seq_device *dev = to_seq_dev(_dev); 33 26 struct snd_emux *emux; 34 27 struct snd_emu10k1 *hw; … … 79 72 } 80 73 81 static int snd_emu10k1_synth_ delete_device(struct snd_seq_device *dev)74 static int snd_emu10k1_synth_remove(struct device *_dev) 82 75 { 76 struct snd_seq_device *dev = to_seq_dev(_dev); 83 77 struct snd_emux *emux; 84 78 struct snd_emu10k1 *hw; … … 104 98 */ 105 99 106 static int __init alsa_emu10k1_synth_init(void) 107 { 108 109 static struct snd_seq_dev_ops ops = { 110 snd_emu10k1_synth_new_device, 111 snd_emu10k1_synth_delete_device, 112 }; 113 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, 114 sizeof(struct snd_emu10k1_synth_arg)); 115 } 100 static struct snd_seq_driver emu10k1_synth_driver = { 101 .driver = { 102 .name = KBUILD_MODNAME, 103 .probe = snd_emu10k1_synth_probe, 104 .remove = snd_emu10k1_synth_remove, 105 }, 106 .id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, 107 .argsize = sizeof(struct snd_emu10k1_synth_arg), 108 }; 116 109 117 static void __exit alsa_emu10k1_synth_exit(void) 118 { 119 snd_seq_device_unregister_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH); 120 } 121 122 module_init(alsa_emu10k1_synth_init) 123 module_exit(alsa_emu10k1_synth_exit) 110 module_snd_seq_driver(emu10k1_synth_driver); -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_synth_local.h
r305 r679 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 1 2 #ifndef __EMU10K1_SYNTH_LOCAL_H 2 3 #define __EMU10K1_SYNTH_LOCAL_H … … 5 6 * 6 7 * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de> 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 8 */ 22 9 -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> … … 14 15 * - EMU10K1X-DBQ 15 16 * - STAC 9708T 16 *17 * This program is free software; you can redistribute it and/or modify18 * it under the terms of the GNU General Public License as published by19 * the Free Software Foundation; either version 2 of the License, or20 * (at your option) any later version.21 *22 * This program is distributed in the hope that it will be useful,23 * but WITHOUT ANY WARRANTY; without even the implied warranty of24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the25 * GNU General Public License for more details.26 *27 * You should have received a copy of the GNU General Public License28 * along with this program; if not, write to the Free Software29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA30 *31 17 */ 18 #ifdef TARGET_OS2 19 #define KBUILD_MODNAME "emu10k1" 20 #endif 32 21 #include <linux/init.h> 33 22 #include <linux/interrupt.h> … … 35 24 #include <linux/dma-mapping.h> 36 25 #include <linux/slab.h> 37 #include <linux/module param.h>26 #include <linux/module.h> 38 27 #include <sound/core.h> 39 28 #include <sound/initval.h> … … 51 40 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 52 41 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 53 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;42 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 54 43 55 44 module_param_array(index, int, NULL, 0444); … … 108 97 /********************************************************************************************************/ 109 98 #define PLAYBACK_LIST_ADDR 0x00 /* Base DMA address of a list of pointers to each period/size */ 110 /* One list entry: 4 bytes for DMA address, 99 /* One list entry: 4 bytes for DMA address, 111 100 * 4 bytes for period_size << 16. 112 101 * One list entry is 8 bytes long. … … 181 170 /* From 0x50 - 0x5f, last samples captured */ 182 171 183 /* *172 /* 184 173 * The hardware has 3 channels for playback and 1 for capture. 185 174 * - channel 0 is the front channel … … 187 176 * - channel 2 is the center/lfe channel 188 177 * Volume is controlled by the AC97 for the front and rear channels by 189 * the PCM Playback Volume, Sigmatel Surround Playback Volume and 178 * the PCM Playback Volume, Sigmatel Surround Playback Volume and 190 179 * Surround Playback Volume. The Sigmatel 4-Speaker Stereo switch affects 191 180 * the front/rear channel mixing in the REAR OUT jack. When using the … … 200 189 int number; 201 190 int use; 202 191 203 192 struct emu10k1x_pcm *epcm; 204 193 }; … … 255 244 256 245 /* hardware definition */ 257 static struct snd_pcm_hardware snd_emu10k1x_playback_hw = {258 .info = (SNDRV_PCM_INFO_MMAP | 246 static const struct snd_pcm_hardware snd_emu10k1x_playback_hw = { 247 .info = (SNDRV_PCM_INFO_MMAP | 259 248 SNDRV_PCM_INFO_INTERLEAVED | 260 249 SNDRV_PCM_INFO_BLOCK_TRANSFER | … … 274 263 }; 275 264 276 static struct snd_pcm_hardware snd_emu10k1x_capture_hw = {277 .info = (SNDRV_PCM_INFO_MMAP | 265 static const struct snd_pcm_hardware snd_emu10k1x_capture_hw = { 266 .info = (SNDRV_PCM_INFO_MMAP | 278 267 SNDRV_PCM_INFO_INTERLEAVED | 279 268 SNDRV_PCM_INFO_BLOCK_TRANSFER | … … 293 282 }; 294 283 295 static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, 296 unsigned int reg, 284 static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, 285 unsigned int reg, 297 286 unsigned int chn) 298 287 { 299 288 unsigned long flags; 300 289 unsigned int regptr, val; 301 290 302 291 regptr = (reg << 16) | chn; 303 292 … … 370 359 return; 371 360 #if 0 372 snd_printk(KERN_INFO "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 361 dev_info(emu->card->dev, 362 "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 373 363 epcm->substream->ops->pointer(epcm->substream), 374 364 snd_pcm_lib_period_bytes(epcm->substream), … … 397 387 epcm->emu = chip; 398 388 epcm->substream = substream; 399 389 400 390 runtime->private_data = epcm; 401 391 runtime->private_free = snd_emu10k1x_pcm_free_substream; 402 392 403 393 runtime->hw = snd_emu10k1x_playback_hw; 404 394 … … 425 415 } 426 416 427 return snd_pcm_lib_malloc_pages(substream, 428 params_buffer_bytes(hw_params)); 417 return 0; 429 418 } 430 419 … … 446 435 } 447 436 448 return snd_pcm_lib_free_pages(substream);437 return 0; 449 438 } 450 439 … … 488 477 int result = 0; 489 478 490 // snd_printk(KERN_INFO "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", (int)emu, cmd, (int)substream->ops->pointer(substream)); 479 /* 480 dev_dbg(emu->card->dev, 481 "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", 482 (int)emu, cmd, (int)substream->ops->pointer(substream)); 483 */ 491 484 492 485 switch (cmd) { … … 531 524 return 0; 532 525 533 if (ptr3 != ptr4) 526 if (ptr3 != ptr4) 534 527 ptr1 = snd_emu10k1x_ptr_read(emu, PLAYBACK_POINTER, channel); 535 528 ptr2 = bytes_to_frames(runtime, ptr1); … … 544 537 545 538 /* operators */ 546 static struct snd_pcm_ops snd_emu10k1x_playback_ops = {539 static const struct snd_pcm_ops snd_emu10k1x_playback_ops = { 547 540 .open = snd_emu10k1x_playback_open, 548 541 .close = snd_emu10k1x_playback_close, 549 .ioctl = snd_pcm_lib_ioctl,550 542 .hw_params = snd_emu10k1x_pcm_hw_params, 551 543 .hw_free = snd_emu10k1x_pcm_hw_free, … … 604 596 } 605 597 606 return snd_pcm_lib_malloc_pages(substream, 607 params_buffer_bytes(hw_params)); 598 return 0; 608 599 } 609 600 … … 625 616 } 626 617 627 return snd_pcm_lib_free_pages(substream);618 return 0; 628 619 } 629 620 … … 653 644 switch (cmd) { 654 645 case SNDRV_PCM_TRIGGER_START: 655 snd_emu10k1x_intr_enable(emu, INTE_CAP_0_LOOP | 646 snd_emu10k1x_intr_enable(emu, INTE_CAP_0_LOOP | 656 647 INTE_CAP_0_HALF_LOOP); 657 648 snd_emu10k1x_ptr_write(emu, TRIGGER_CHANNEL, 0, snd_emu10k1x_ptr_read(emu, TRIGGER_CHANNEL, 0)|TRIGGER_CAPTURE); … … 660 651 case SNDRV_PCM_TRIGGER_STOP: 661 652 epcm->running = 0; 662 snd_emu10k1x_intr_disable(emu, INTE_CAP_0_LOOP | 653 snd_emu10k1x_intr_disable(emu, INTE_CAP_0_LOOP | 663 654 INTE_CAP_0_HALF_LOOP); 664 655 snd_emu10k1x_ptr_write(emu, TRIGGER_CHANNEL, 0, snd_emu10k1x_ptr_read(emu, TRIGGER_CHANNEL, 0) & ~(TRIGGER_CAPTURE)); … … 690 681 } 691 682 692 static struct snd_pcm_ops snd_emu10k1x_capture_ops = {683 static const struct snd_pcm_ops snd_emu10k1x_capture_ops = { 693 684 .open = snd_emu10k1x_pcm_open_capture, 694 685 .close = snd_emu10k1x_pcm_close_capture, 695 .ioctl = snd_pcm_lib_ioctl,696 686 .hw_params = snd_emu10k1x_pcm_hw_params_capture, 697 687 .hw_free = snd_emu10k1x_pcm_hw_free_capture, … … 707 697 unsigned long flags; 708 698 unsigned short val; 709 699 710 700 spin_lock_irqsave(&emu->emu_lock, flags); 711 701 outb(reg, emu->port + AC97ADDRESS); … … 720 710 struct emu10k1x *emu = ac97->private_data; 721 711 unsigned long flags; 722 712 723 713 spin_lock_irqsave(&emu->emu_lock, flags); 724 714 outb(reg, emu->port + AC97ADDRESS); … … 732 722 struct snd_ac97_template ac97; 733 723 int err; 734 static struct snd_ac97_bus_ops ops = {724 static const struct snd_ac97_bus_ops ops = { 735 725 .write = snd_emu10k1x_ac97_write, 736 726 .read = snd_emu10k1x_ac97_read, 737 727 }; 738 728 739 729 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) 740 730 return err; … … 799 789 if (cap_voice->use) 800 790 snd_emu10k1x_pcm_interrupt(chip, cap_voice); 801 else 802 snd_emu10k1x_intr_disable(chip, 791 else 792 snd_emu10k1x_intr_disable(chip, 803 793 INTE_CAP_0_LOOP | 804 794 INTE_CAP_0_HALF_LOOP); … … 827 817 outl(status, chip->port + IPR); 828 818 829 / / snd_printk(KERN_INFO "interrupt %08x\n", status);819 /* dev_dbg(chip->card->dev, "interrupt %08x\n", status); */ 830 820 return IRQ_HANDLED; 831 821 } 832 822 833 static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) 823 static const struct snd_pcm_chmap_elem surround_map[] = { 824 { .channels = 2, 825 .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, 826 {0} 827 }; 828 829 static const struct snd_pcm_chmap_elem clfe_map[] = { 830 { .channels = 2, 831 .map = { SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, 832 {0} 833 }; 834 835 static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device) 834 836 { 835 837 struct snd_pcm *pcm; 838 const struct snd_pcm_chmap_elem *map = NULL; 836 839 int err; 837 840 int capture = 0; 838 839 if (rpcm) 840 *rpcm = NULL; 841 841 842 if (device == 0) 842 843 capture = 1; … … 844 845 if ((err = snd_pcm_new(emu->card, "emu10k1x", device, 1, capture, &pcm)) < 0) 845 846 return err; 846 847 847 848 pcm->private_data = emu; 848 849 … … 862 863 case 0: 863 864 strcpy(pcm->name, "EMU10K1X Front"); 865 map = snd_pcm_std_chmaps; 864 866 break; 865 867 case 1: 866 868 strcpy(pcm->name, "EMU10K1X Rear"); 869 map = surround_map; 867 870 break; 868 871 case 2: 869 872 strcpy(pcm->name, "EMU10K1X Center/LFE"); 873 map = clfe_map; 870 874 break; 871 875 } 872 876 emu->pcm = pcm; 873 877 874 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 875 snd_dma_pci_data(emu->pci), 876 32*1024, 32*1024); 877 878 if (rpcm) 879 *rpcm = pcm; 880 881 return 0; 882 } 883 884 static int __devinit snd_emu10k1x_create(struct snd_card *card, 885 struct pci_dev *pci, 886 struct emu10k1x **rchip) 878 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 879 &emu->pci->dev, 32*1024, 32*1024); 880 881 return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, 882 1 << 2, NULL); 883 } 884 885 static int snd_emu10k1x_create(struct snd_card *card, 886 struct pci_dev *pci, 887 struct emu10k1x **rchip) 887 888 { 888 889 struct emu10k1x *chip; 889 890 int err; 890 891 int ch; 891 static struct snd_device_ops ops = {892 static const struct snd_device_ops ops = { 892 893 .dev_free = snd_emu10k1x_dev_free, 893 894 }; … … 899 900 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 900 901 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 901 snd_printk(KERN_ERR"error to set 28bit mask DMA\n");902 dev_err(card->dev, "error to set 28bit mask DMA\n"); 902 903 pci_disable_device(pci); 903 904 return -ENXIO; … … 916 917 spin_lock_init(&chip->emu_lock); 917 918 spin_lock_init(&chip->voice_lock); 918 919 919 920 chip->port = pci_resource_start(pci, 0); 920 921 if ((chip->res_port = request_region(chip->port, 8, 921 "EMU10K1X")) == NULL) { 922 snd_printk(KERN_ERR "emu10k1x: cannot allocate the port 0x%lx\n", chip->port); 922 "EMU10K1X")) == NULL) { 923 dev_err(card->dev, "cannot allocate the port 0x%lx\n", 924 chip->port); 923 925 snd_emu10k1x_free(chip); 924 926 return -EBUSY; … … 926 928 927 929 if (request_irq(pci->irq, snd_emu10k1x_interrupt, 928 IRQF_SHARED, "EMU10K1X", chip)) {929 snd_printk(KERN_ERR "emu10k1x:cannot grab irq %d\n", pci->irq);930 IRQF_SHARED, KBUILD_MODNAME, chip)) { 931 dev_err(card->dev, "cannot grab irq %d\n", pci->irq); 930 932 snd_emu10k1x_free(chip); 931 933 return -EBUSY; 932 934 } 933 935 chip->irq = pci->irq; 934 935 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 936 4 * 1024, &chip->dma_buffer) < 0) { 936 card->sync_irq = chip->irq; 937 938 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 939 4 * 1024, &chip->dma_buffer) < 0) { 937 940 snd_emu10k1x_free(chip); 938 941 return -ENOMEM; … … 948 951 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 949 952 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 950 snd_printk(KERN_INFO"Model %04x Rev %08x Serial %08x\n", chip->model,953 dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n", chip->model, 951 954 chip->revision, chip->serial); 952 955 … … 973 976 */ 974 977 snd_emu10k1x_ptr_write(chip, SPCS0, 0, 975 chip->spdif_bits[0] = 978 chip->spdif_bits[0] = 976 979 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 977 980 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | … … 979 982 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 980 983 snd_emu10k1x_ptr_write(chip, SPCS1, 0, 981 chip->spdif_bits[1] = 984 chip->spdif_bits[1] = 982 985 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 983 986 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | … … 985 988 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 986 989 snd_emu10k1x_ptr_write(chip, SPCS2, 0, 987 chip->spdif_bits[2] = 990 chip->spdif_bits[2] = 988 991 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 989 992 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | … … 1006 1009 } 1007 1010 1008 static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, 1011 static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, 1009 1012 struct snd_info_buffer *buffer) 1010 1013 { … … 1034 1037 } 1035 1038 1036 static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, 1039 static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, 1037 1040 struct snd_info_buffer *buffer) 1038 1041 { … … 1045 1048 continue; 1046 1049 1047 if (reg < 0x49 && /* val <= 0xffffffff && DAZ */channel_id <= 2)1050 if (reg < 0x49 && channel_id <= 2) 1048 1051 snd_emu10k1x_ptr_write(emu, reg, channel_id, val); 1049 1052 } 1050 1053 } 1051 1054 1052 static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) 1053 { 1054 struct snd_info_entry *entry; 1055 1056 if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { 1057 snd_info_set_text_ops(entry, emu, snd_emu10k1x_proc_reg_read); 1058 entry->c.text.write = snd_emu10k1x_proc_reg_write; 1059 entry->mode |= S_IWUSR; 1060 entry->private_data = emu; 1061 } 1062 1055 static int snd_emu10k1x_proc_init(struct emu10k1x *emu) 1056 { 1057 snd_card_rw_proc_new(emu->card, "emu10k1x_regs", emu, 1058 snd_emu10k1x_proc_reg_read, 1059 snd_emu10k1x_proc_reg_write); 1063 1060 return 0; 1064 1061 } … … 1081 1078 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1082 1079 unsigned int val; 1083 int change = 0;1084 1080 1085 1081 val = ucontrol->value.integer.value[0] ; … … 1096 1092 snd_emu10k1x_gpio_write(emu, 0x1080); 1097 1093 } 1098 return change;1099 } 1100 1101 static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata=1094 return 0; 1095 } 1096 1097 static const struct snd_kcontrol_new snd_emu10k1x_shared_spdif = 1102 1098 { 1103 1099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1158 1154 } 1159 1155 1160 static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control =1156 static const struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control = 1161 1157 { 1162 1158 .access = SNDRV_CTL_ELEM_ACCESS_READ, … … 1168 1164 }; 1169 1165 1170 static struct snd_kcontrol_new snd_emu10k1x_spdif_control =1166 static const struct snd_kcontrol_new snd_emu10k1x_spdif_control = 1171 1167 { 1172 1168 .iface = SNDRV_CTL_ELEM_IFACE_PCM, … … 1178 1174 }; 1179 1175 1180 static int __devinitsnd_emu10k1x_mixer(struct emu10k1x *emu)1176 static int snd_emu10k1x_mixer(struct emu10k1x *emu) 1181 1177 { 1182 1178 int err; … … 1232 1228 #ifdef CONFIG_SND_DEBUG 1233 1229 if (timeout <= 0) 1234 snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); 1230 dev_err(emu->card->dev, 1231 "cmd: clear rx timeout (status = 0x%x)\n", 1232 mpu401_read_stat(emu, mpu)); 1235 1233 #endif 1236 1234 } … … 1306 1304 spin_unlock_irqrestore(&midi->input_lock, flags); 1307 1305 if (!ok) { 1308 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 1306 dev_err(emu->card->dev, 1307 "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 1309 1308 cmd, emu->port, 1310 1309 mpu401_read_stat(emu, midi), … … 1470 1469 */ 1471 1470 1472 static struct snd_rawmidi_ops snd_emu10k1x_midi_output =1471 static const struct snd_rawmidi_ops snd_emu10k1x_midi_output = 1473 1472 { 1474 1473 .open = snd_emu10k1x_midi_output_open, … … 1477 1476 }; 1478 1477 1479 static struct snd_rawmidi_ops snd_emu10k1x_midi_input =1478 static const struct snd_rawmidi_ops snd_emu10k1x_midi_input = 1480 1479 { 1481 1480 .open = snd_emu10k1x_midi_input_open, … … 1491 1490 } 1492 1491 1493 static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, 1494 struct emu10k1x_midi *midi, int device, char *name) 1492 static int emu10k1x_midi_init(struct emu10k1x *emu, 1493 struct emu10k1x_midi *midi, int device, 1494 char *name) 1495 1495 { 1496 1496 struct snd_rawmidi *rmidi; … … 1515 1515 } 1516 1516 1517 static int __devinitsnd_emu10k1x_midi(struct emu10k1x *emu)1517 static int snd_emu10k1x_midi(struct emu10k1x *emu) 1518 1518 { 1519 1519 struct emu10k1x_midi *midi = &emu->midi; … … 1532 1532 } 1533 1533 1534 static int __devinitsnd_emu10k1x_probe(struct pci_dev *pci,1535 const struct pci_device_id *pci_id)1534 static int snd_emu10k1x_probe(struct pci_dev *pci, 1535 const struct pci_device_id *pci_id) 1536 1536 { 1537 1537 static int dev; … … 1547 1547 } 1548 1548 1549 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1549 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1550 0, &card); 1550 1551 if (err < 0) 1551 1552 return err; … … 1556 1557 } 1557 1558 1558 if ((err = snd_emu10k1x_pcm(chip, 0 , NULL)) < 0) {1559 if ((err = snd_emu10k1x_pcm(chip, 0)) < 0) { 1559 1560 snd_card_free(card); 1560 1561 return err; 1561 1562 } 1562 if ((err = snd_emu10k1x_pcm(chip, 1 , NULL)) < 0) {1563 if ((err = snd_emu10k1x_pcm(chip, 1)) < 0) { 1563 1564 snd_card_free(card); 1564 1565 return err; 1565 1566 } 1566 if ((err = snd_emu10k1x_pcm(chip, 2 , NULL)) < 0) {1567 if ((err = snd_emu10k1x_pcm(chip, 2)) < 0) { 1567 1568 snd_card_free(card); 1568 1569 return err; … … 1591 1592 card->shortname, chip->port, chip->irq); 1592 1593 1593 snd_card_set_dev(card, &pci->dev);1594 1595 1594 if ((err = snd_card_register(card)) < 0) { 1596 1595 snd_card_free(card); … … 1603 1602 } 1604 1603 1605 static void __devexitsnd_emu10k1x_remove(struct pci_dev *pci)1604 static void snd_emu10k1x_remove(struct pci_dev *pci) 1606 1605 { 1607 1606 snd_card_free(pci_get_drvdata(pci)); 1608 pci_set_drvdata(pci, NULL);1609 1607 } 1610 1608 1611 1609 // PCI IDs 1612 static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1x_ids)= {1610 static const struct pci_device_id snd_emu10k1x_ids[] = { 1613 1611 { PCI_VDEVICE(CREATIVE, 0x0006), 0 }, /* Dell OEM version (EMU10K1) */ 1614 1612 { 0, } … … 1617 1615 1618 1616 // pci_driver definition 1619 static struct pci_driver driver = {1620 .name = "EMU10K1X",1617 static struct pci_driver emu10k1x_driver = { 1618 .name = KBUILD_MODNAME, 1621 1619 .id_table = snd_emu10k1x_ids, 1622 1620 .probe = snd_emu10k1x_probe, 1623 .remove = __devexit_p(snd_emu10k1x_remove),1621 .remove = snd_emu10k1x_remove, 1624 1622 }; 1625 1623 1626 // initialization of the module 1627 static int __init alsa_card_emu10k1x_init(void) 1628 { 1629 return pci_register_driver(&driver); 1630 } 1631 1632 // clean up the module 1633 static void __exit alsa_card_emu10k1x_exit(void) 1634 { 1635 pci_unregister_driver(&driver); 1636 } 1637 1638 module_init(alsa_card_emu10k1x_init) 1639 module_exit(alsa_card_emu10k1x_exit) 1624 module_pci_driver(emu10k1x_driver); -
GPL/trunk/alsa-kernel/pci/emu10k1/emufx.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 12 13 * TODO: 13 14 * -- 14 *15 * This program is free software; you can redistribute it and/or modify16 * it under the terms of the GNU General Public License as published by17 * the Free Software Foundation; either version 2 of the License, or18 * (at your option) any later version.19 *20 * This program is distributed in the hope that it will be useful,21 * but WITHOUT ANY WARRANTY; without even the implied warranty of22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the23 * GNU General Public License for more details.24 *25 * You should have received a copy of the GNU General Public License26 * along with this program; if not, write to the Free Software27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA28 *29 15 */ 30 16 … … 37 23 #include <linux/mutex.h> 38 24 #include <linux/moduleparam.h> 25 #include <linux/nospec.h> 39 26 40 27 #include <sound/core.h> … … 59 46 /* 60 47 * Tables 61 */ 62 63 static c har *fxbuses[16] = {48 */ 49 50 static const char * const fxbuses[16] = { 64 51 /* 0x00 */ "PCM Left", 65 52 /* 0x01 */ "PCM Right", … … 80 67 }; 81 68 82 static c har *creative_ins[16] = {69 static const char * const creative_ins[16] = { 83 70 /* 0x00 */ "AC97 Left", 84 71 /* 0x01 */ "AC97 Right", … … 99 86 }; 100 87 101 static c har *audigy_ins[16] = {88 static const char * const audigy_ins[16] = { 102 89 /* 0x00 */ "AC97 Left", 103 90 /* 0x01 */ "AC97 Right", … … 118 105 }; 119 106 120 static c har *creative_outs[32] = {107 static const char * const creative_outs[32] = { 121 108 /* 0x00 */ "AC97 Left", 122 109 /* 0x01 */ "AC97 Right", … … 153 140 }; 154 141 155 static c har *audigy_outs[32] = {142 static const char * const audigy_outs[32] = { 156 143 /* 0x00 */ "Digital Front Left", 157 144 /* 0x01 */ "Digital Front Right", … … 172 159 /* 0x10 */ "AC97 Front Left", 173 160 /* 0x11 */ "AC97 Front Right", 174 /* 0x12 */ "ADC Cap utre Left",161 /* 0x12 */ "ADC Capture Left", 175 162 /* 0x13 */ "ADC Capture Right", 176 163 /* 0x14 */ NULL, … … 305 292 static const DECLARE_TLV_DB_LINEAR(snd_emu10k1_db_linear, TLV_DB_GAIN_MUTE, 0); 306 293 294 /* EMU10K1 bass/treble db gain */ 295 static const DECLARE_TLV_DB_SCALE(snd_emu10k1_bass_treble_db_scale, -1200, 60, 0); 296 307 297 static const u32 onoff_table[2] = { 308 298 0x00000000, 0x00000001 309 299 }; 310 311 /*312 */313 314 static inline mm_segment_t snd_enter_user(void)315 {316 mm_segment_t fs = get_fs();317 set_fs(get_ds());318 return fs;319 }320 321 static inline void snd_leave_user(mm_segment_t fs)322 {323 set_fs(fs);324 }325 300 326 301 /* … … 435 410 unsigned char gpr_running, 436 411 void *private_data, 437 struct snd_emu10k1_fx8010_irq **r_irq) 438 { 439 struct snd_emu10k1_fx8010_irq *irq; 412 struct snd_emu10k1_fx8010_irq *irq) 413 { 440 414 unsigned long flags; 441 415 442 irq = kmalloc(sizeof(*irq), GFP_ATOMIC);443 if (irq == NULL)444 return -ENOMEM;445 416 irq->handler = handler; 446 417 irq->gpr_running = gpr_running; … … 457 428 } 458 429 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags); 459 if (r_irq)460 *r_irq = irq;461 430 return 0; 462 431 } … … 482 451 } 483 452 spin_unlock_irqrestore(&emu->fx8010.irq_lock, flags); 484 kfree(irq);485 453 return 0; 486 454 } … … 497 465 if (snd_BUG_ON(*ptr >= 512)) 498 466 return; 499 code = (u_int32_t __force *)icode->code + (*ptr) * 2;467 code = icode->code + (*ptr) * 2; 500 468 set_bit(*ptr, icode->code_valid); 501 469 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); … … 514 482 if (snd_BUG_ON(*ptr >= 1024)) 515 483 return; 516 code = (u_int32_t __force *)icode->code + (*ptr) * 2;484 code = icode->code + (*ptr) * 2; 517 485 set_bit(*ptr, icode->code_valid); 518 486 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); … … 537 505 538 506 static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, 539 struct snd_emu10k1_fx8010_code *icode) 507 struct snd_emu10k1_fx8010_code *icode, 508 bool in_kernel) 540 509 { 541 510 int gpr; … … 545 514 if (!test_bit(gpr, icode->gpr_valid)) 546 515 continue; 547 if (get_user(val, &icode->gpr_map[gpr])) 516 if (in_kernel) 517 val = icode->gpr_map[gpr]; 518 else if (get_user(val, (__user u32 *)&icode->gpr_map[gpr])) 548 519 return -EFAULT; 549 520 snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val); … … 561 532 set_bit(gpr, icode->gpr_valid); 562 533 val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0); 563 if (put_user(val, &icode->gpr_map[gpr]))534 if (put_user(val, (__user u32 *)&icode->gpr_map[gpr])) 564 535 return -EFAULT; 565 536 } … … 568 539 569 540 static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, 570 struct snd_emu10k1_fx8010_code *icode) 541 struct snd_emu10k1_fx8010_code *icode, 542 bool in_kernel) 571 543 { 572 544 int tram; … … 576 548 if (!test_bit(tram, icode->tram_valid)) 577 549 continue; 578 if (get_user(val, &icode->tram_data_map[tram]) || 579 get_user(addr, &icode->tram_addr_map[tram])) 580 return -EFAULT; 550 if (in_kernel) { 551 val = icode->tram_data_map[tram]; 552 addr = icode->tram_addr_map[tram]; 553 } else { 554 if (get_user(val, (__user __u32 *)&icode->tram_data_map[tram]) || 555 get_user(addr, (__user __u32 *)&icode->tram_addr_map[tram])) 556 return -EFAULT; 557 } 581 558 snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + tram, 0, val); 582 559 if (!emu->audigy) { … … 606 583 addr |= snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + tram, 0) << 20; 607 584 } 608 if (put_user(val, &icode->tram_data_map[tram]) ||609 put_user(addr, &icode->tram_addr_map[tram]))585 if (put_user(val, (__user u32 *)&icode->tram_data_map[tram]) || 586 put_user(addr, (__user u32 *)&icode->tram_addr_map[tram])) 610 587 return -EFAULT; 611 588 } … … 614 591 615 592 static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, 616 struct snd_emu10k1_fx8010_code *icode) 593 struct snd_emu10k1_fx8010_code *icode, 594 bool in_kernel) 617 595 { 618 596 u32 pc, lo, hi; … … 621 599 if (!test_bit(pc / 2, icode->code_valid)) 622 600 continue; 623 if (get_user(lo, &icode->code[pc + 0]) || 624 get_user(hi, &icode->code[pc + 1])) 625 return -EFAULT; 601 if (in_kernel) { 602 lo = icode->code[pc + 0]; 603 hi = icode->code[pc + 1]; 604 } else { 605 if (get_user(lo, (__user u32 *)&icode->code[pc + 0]) || 606 get_user(hi, (__user u32 *)&icode->code[pc + 1])) 607 return -EFAULT; 608 } 626 609 snd_emu10k1_efx_write(emu, pc + 0, lo); 627 610 snd_emu10k1_efx_write(emu, pc + 1, hi); … … 638 621 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { 639 622 set_bit(pc / 2, icode->code_valid); 640 if (put_user(snd_emu10k1_efx_read(emu, pc + 0), &icode->code[pc + 0])) 623 if (put_user(snd_emu10k1_efx_read(emu, pc + 0), 624 (__user u32 *)&icode->code[pc + 0])) 641 625 return -EFAULT; 642 if (put_user(snd_emu10k1_efx_read(emu, pc + 1), &icode->code[pc + 1])) 626 if (put_user(snd_emu10k1_efx_read(emu, pc + 1), 627 (__user u32 *)&icode->code[pc + 1])) 643 628 return -EFAULT; 644 629 } … … 647 632 648 633 static struct snd_emu10k1_fx8010_ctl * 649 snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id) 650 { 634 snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, 635 struct emu10k1_ctl_elem_id *_id) 636 { 637 struct snd_ctl_elem_id *id = (struct snd_ctl_elem_id *)_id; 651 638 struct snd_emu10k1_fx8010_ctl *ctl; 652 639 struct snd_kcontrol *kcontrol; … … 664 651 #define MAX_TLV_SIZE 256 665 652 666 static unsigned int *copy_tlv(const unsigned int __user *_tlv )653 static unsigned int *copy_tlv(const unsigned int __user *_tlv, bool in_kernel) 667 654 { 668 655 unsigned int data[2]; … … 671 658 if (!_tlv) 672 659 return NULL; 673 if (copy_from_user(data, _tlv, sizeof(data))) 660 if (in_kernel) 661 memcpy(data, (__force void *)_tlv, sizeof(data)); 662 else if (copy_from_user(data, _tlv, sizeof(data))) 674 663 return NULL; 675 664 if (data[1] >= MAX_TLV_SIZE) … … 679 668 return NULL; 680 669 memcpy(tlv, data, sizeof(data)); 681 if (copy_from_user(tlv + 2, _tlv + 2, data[1])) { 670 if (in_kernel) { 671 memcpy(tlv + 2, (__force void *)(_tlv + 2), data[1]); 672 } else if (copy_from_user(tlv + 2, _tlv + 2, data[1])) { 682 673 kfree(tlv); 683 674 return NULL; … … 687 678 688 679 static int copy_gctl(struct snd_emu10k1 *emu, 689 struct snd_emu10k1_fx8010_control_gpr *gctl, 690 struct snd_emu10k1_fx8010_control_gpr __user *_gctl, 680 struct snd_emu10k1_fx8010_control_gpr *dst, 681 struct snd_emu10k1_fx8010_control_gpr *src, 682 int idx, bool in_kernel) 683 { 684 struct snd_emu10k1_fx8010_control_gpr __user *_src; 685 struct snd_emu10k1_fx8010_control_old_gpr *octl; 686 struct snd_emu10k1_fx8010_control_old_gpr __user *_octl; 687 688 _src = (struct snd_emu10k1_fx8010_control_gpr __user *)src; 689 if (emu->support_tlv) { 690 if (in_kernel) 691 *dst = src[idx]; 692 else if (copy_from_user(dst, &_src[idx], sizeof(*src))) 693 return -EFAULT; 694 return 0; 695 } 696 697 octl = (struct snd_emu10k1_fx8010_control_old_gpr *)src; 698 _octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)octl; 699 if (in_kernel) 700 memcpy(dst, &octl[idx], sizeof(*octl)); 701 else if (copy_from_user(dst, &_octl[idx], sizeof(*octl))) 702 return -EFAULT; 703 dst->tlv = NULL; 704 return 0; 705 } 706 707 static int copy_gctl_to_user(struct snd_emu10k1 *emu, 708 struct snd_emu10k1_fx8010_control_gpr *dst, 709 struct snd_emu10k1_fx8010_control_gpr *src, 691 710 int idx) 692 711 { 712 struct snd_emu10k1_fx8010_control_gpr __user *_dst; 693 713 struct snd_emu10k1_fx8010_control_old_gpr __user *octl; 694 714 715 _dst = (struct snd_emu10k1_fx8010_control_gpr __user *)dst; 695 716 if (emu->support_tlv) 696 return copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)); 697 octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; 698 if (copy_from_user(gctl, &octl[idx], sizeof(*octl))) 717 return copy_to_user(&_dst[idx], src, sizeof(*src)); 718 719 octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)dst; 720 return copy_to_user(&octl[idx], src, sizeof(*octl)); 721 } 722 723 static int copy_ctl_elem_id(const struct emu10k1_ctl_elem_id *list, int i, 724 struct emu10k1_ctl_elem_id *ret, bool in_kernel) 725 { 726 struct emu10k1_ctl_elem_id __user *_id = 727 (struct emu10k1_ctl_elem_id __user *)&list[i]; 728 729 if (in_kernel) 730 *ret = list[i]; 731 else if (copy_from_user(ret, _id, sizeof(*ret))) 699 732 return -EFAULT; 700 gctl->tlv = NULL;701 733 return 0; 702 734 } 703 735 704 static int copy_gctl_to_user(struct snd_emu10k1 *emu,705 struct snd_emu10k1_fx8010_control_gpr __user *_gctl,706 struct snd_emu10k1_fx8010_control_gpr *gctl,707 int idx)708 {709 struct snd_emu10k1_fx8010_control_old_gpr __user *octl;710 711 if (emu->support_tlv)712 return copy_to_user(&_gctl[idx], gctl, sizeof(*gctl));713 714 octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;715 return copy_to_user(&octl[idx], gctl, sizeof(*octl));716 }717 718 736 static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, 719 struct snd_emu10k1_fx8010_code *icode) 737 struct snd_emu10k1_fx8010_code *icode, 738 bool in_kernel) 720 739 { 721 740 unsigned int i; 722 struct snd_ctl_elem_id __user *_id; 723 struct snd_ctl_elem_id id; 741 struct emu10k1_ctl_elem_id id; 724 742 struct snd_emu10k1_fx8010_control_gpr *gctl; 743 struct snd_ctl_elem_id *gctl_id; 725 744 int err; 726 745 727 for (i = 0, _id = icode->gpr_del_controls; 728 i < icode->gpr_del_control_count; i++, _id++) { 729 if (copy_from_user(&id, _id, sizeof(id))) 730 return -EFAULT; 746 for (i = 0; i < icode->gpr_del_control_count; i++) { 747 err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, 748 in_kernel); 749 if (err < 0) 750 return err; 731 751 if (snd_emu10k1_look_for_ctl(emu, &id) == NULL) 732 752 return -ENOENT; … … 737 757 err = 0; 738 758 for (i = 0; i < icode->gpr_add_control_count; i++) { 739 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i)) { 759 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i, 760 in_kernel)) { 740 761 err = -EFAULT; 741 762 goto __error; … … 743 764 if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) 744 765 continue; 766 gctl_id = (struct snd_ctl_elem_id *)&gctl->id; 745 767 down_read(&emu->card->controls_rwsem); 746 if (snd_ctl_find_id(emu->card, &gctl->id) != NULL) {768 if (snd_ctl_find_id(emu->card, gctl_id)) { 747 769 up_read(&emu->card->controls_rwsem); 748 770 err = -EEXIST; … … 750 772 } 751 773 up_read(&emu->card->controls_rwsem); 752 if (gctl ->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER &&753 gctl ->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) {774 if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && 775 gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { 754 776 err = -EINVAL; 755 777 goto __error; … … 758 780 for (i = 0; i < icode->gpr_list_control_count; i++) { 759 781 /* FIXME: we need to check the WRITE access */ 760 if (copy_gctl(emu, gctl, icode->gpr_list_controls, i)) { 782 if (copy_gctl(emu, gctl, icode->gpr_list_controls, i, 783 in_kernel)) { 761 784 err = -EFAULT; 762 785 goto __error; … … 776 799 list_del(&ctl->list); 777 800 kfree(ctl); 778 if (kctl->tlv.p) 779 kfree(kctl->tlv.p); 801 kfree(kctl->tlv.p); 780 802 } 781 803 782 804 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, 783 struct snd_emu10k1_fx8010_code *icode) 805 struct snd_emu10k1_fx8010_code *icode, 806 bool in_kernel) 784 807 { 785 808 unsigned int i, j; 786 809 struct snd_emu10k1_fx8010_control_gpr *gctl; 810 struct snd_ctl_elem_id *gctl_id; 787 811 struct snd_emu10k1_fx8010_ctl *ctl, *nctl; 788 812 struct snd_kcontrol_new knew; … … 800 824 801 825 for (i = 0; i < icode->gpr_add_control_count; i++) { 802 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i)) { 826 if (copy_gctl(emu, gctl, icode->gpr_add_controls, i, 827 in_kernel)) { 803 828 err = -EFAULT; 804 829 goto __error; 805 830 } 806 if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && 807 gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { 831 gctl_id = (struct snd_ctl_elem_id *)&gctl->id; 832 if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && 833 gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { 808 834 err = -EINVAL; 809 835 goto __error; 810 836 } 811 if (! gctl->id.name[0]) {837 if (!*gctl_id->name) { 812 838 err = -EINVAL; 813 839 goto __error; … … 815 841 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); 816 842 memset(&knew, 0, sizeof(knew)); 817 knew.iface = gctl ->id.iface;818 knew.name = gctl ->id.name;819 knew.index = gctl ->id.index;820 knew.device = gctl ->id.device;821 knew.subdevice = gctl ->id.subdevice;843 knew.iface = gctl_id->iface; 844 knew.name = gctl_id->name; 845 knew.index = gctl_id->index; 846 knew.device = gctl_id->device; 847 knew.subdevice = gctl_id->subdevice; 822 848 knew.info = snd_emu10k1_gpr_ctl_info; 823 knew.tlv.p = copy_tlv( gctl->tlv);849 knew.tlv.p = copy_tlv((const unsigned int __user *)gctl->tlv, in_kernel); 824 850 if (knew.tlv.p) 825 851 knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | … … 873 899 874 900 static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, 875 struct snd_emu10k1_fx8010_code *icode) 901 struct snd_emu10k1_fx8010_code *icode, 902 bool in_kernel) 876 903 { 877 904 unsigned int i; 878 struct snd_ctl_elem_id id; 879 struct snd_ctl_elem_id __user *_id; 905 struct emu10k1_ctl_elem_id id; 880 906 struct snd_emu10k1_fx8010_ctl *ctl; 881 907 struct snd_card *card = emu->card; 882 883 for (i = 0, _id = icode->gpr_del_controls; 884 i < icode->gpr_del_control_count; i++, _id++) { 885 if (copy_from_user(&id, _id, sizeof(id))) 886 return -EFAULT; 908 int err; 909 910 for (i = 0; i < icode->gpr_del_control_count; i++) { 911 err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, 912 in_kernel); 913 if (err < 0) 914 return err; 887 915 down_write(&card->controls_rwsem); 888 916 ctl = snd_emu10k1_look_for_ctl(emu, &id); … … 913 941 memset(gctl, 0, sizeof(*gctl)); 914 942 id = &ctl->kcontrol->id; 915 gctl->id.iface = id->iface;943 gctl->id.iface = (__force int)id->iface; 916 944 strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name)); 917 945 gctl->id.index = id->index; … … 941 969 942 970 static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, 943 struct snd_emu10k1_fx8010_code *icode) 971 struct snd_emu10k1_fx8010_code *icode, 972 bool in_kernel) 944 973 { 945 974 int err = 0; 946 975 947 976 mutex_lock(&emu->fx8010.lock); 948 if ((err = snd_emu10k1_verify_controls(emu, icode)) < 0) 977 err = snd_emu10k1_verify_controls(emu, icode, in_kernel); 978 if (err < 0) 949 979 goto __error; 950 980 strlcpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name)); … … 956 986 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); 957 987 /* ok, do the main job */ 958 if ((err = snd_emu10k1_del_controls(emu, icode)) < 0 || 959 (err = snd_emu10k1_gpr_poke(emu, icode)) < 0 || 960 (err = snd_emu10k1_tram_poke(emu, icode)) < 0 || 961 (err = snd_emu10k1_code_poke(emu, icode)) < 0 || 962 (err = snd_emu10k1_add_controls(emu, icode)) < 0) 988 err = snd_emu10k1_del_controls(emu, icode, in_kernel); 989 if (err < 0) 990 goto __error; 991 err = snd_emu10k1_gpr_poke(emu, icode, in_kernel); 992 if (err < 0) 993 goto __error; 994 err = snd_emu10k1_tram_poke(emu, icode, in_kernel); 995 if (err < 0) 996 goto __error; 997 err = snd_emu10k1_code_poke(emu, icode, in_kernel); 998 if (err < 0) 999 goto __error; 1000 err = snd_emu10k1_add_controls(emu, icode, in_kernel); 1001 if (err < 0) 963 1002 goto __error; 964 1003 /* start FX processor when the DSP code is updated */ … … 1000 1039 if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) 1001 1040 return -EINVAL; 1041 ipcm->substream = array_index_nospec(ipcm->substream, 1042 EMU10K1_FX8010_PCM_COUNT); 1002 1043 if (ipcm->channels > 32) 1003 1044 return -EINVAL; … … 1046 1087 if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) 1047 1088 return -EINVAL; 1089 ipcm->substream = array_index_nospec(ipcm->substream, 1090 EMU10K1_FX8010_PCM_COUNT); 1048 1091 pcm = &emu->fx8010.pcm[ipcm->substream]; 1049 1092 mutex_lock(&emu->fx8010.lock); … … 1072 1115 #define SND_EMU10K1_CAPTURE_CHANNELS 4 1073 1116 1074 static void __devinit1117 static void 1075 1118 snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1076 1119 const char *name, int gpr, int defval) 1077 1120 { 1078 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;1121 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 1079 1122 strcpy(ctl->id.name, name); 1080 1123 ctl->vcount = ctl->count = 1; … … 1093 1136 } 1094 1137 1095 static void __devinit1138 static void 1096 1139 snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1097 1140 const char *name, int gpr, int defval) 1098 1141 { 1099 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;1142 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 1100 1143 strcpy(ctl->id.name, name); 1101 1144 ctl->vcount = ctl->count = 2; … … 1115 1158 } 1116 1159 1117 static void __devinit1160 static void 1118 1161 snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1119 1162 const char *name, int gpr, int defval) 1120 1163 { 1121 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;1164 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 1122 1165 strcpy(ctl->id.name, name); 1123 1166 ctl->vcount = ctl->count = 1; … … 1128 1171 } 1129 1172 1130 static void __devinit1173 static void 1131 1174 snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1132 1175 const char *name, int gpr, int defval) 1133 1176 { 1134 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;1177 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 1135 1178 strcpy(ctl->id.name, name); 1136 1179 ctl->vcount = ctl->count = 2; … … 1167 1210 */ 1168 1211 1169 static int _ _devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)1212 static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) 1170 1213 { 1171 1214 int err, i, z, gpr, nctl; … … 1179 1222 struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; 1180 1223 u32 *gpr_map; 1181 mm_segment_t seg; 1182 1183 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || 1184 (icode->gpr_map = (u_int32_t __user *) 1185 kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), 1186 GFP_KERNEL)) == NULL || 1187 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1188 sizeof(*controls), GFP_KERNEL)) == NULL) { 1189 err = -ENOMEM; 1190 goto __err; 1191 } 1192 gpr_map = (u32 __force *)icode->gpr_map; 1224 1225 err = -ENOMEM; 1226 icode = kzalloc(sizeof(*icode), GFP_KERNEL); 1227 if (!icode) 1228 return err; 1229 1230 icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024, 1231 sizeof(u_int32_t), GFP_KERNEL); 1232 if (!icode->gpr_map) 1233 goto __err_gpr; 1234 controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1235 sizeof(*controls), GFP_KERNEL); 1236 if (!controls) 1237 goto __err_ctrls; 1238 1239 gpr_map = icode->gpr_map; 1193 1240 1194 1241 icode->tram_data_map = icode->gpr_map + 512; … … 1277 1324 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0); 1278 1325 gpr += 2; 1279 1326 1280 1327 /* 1281 1328 * inputs … … 1353 1400 gpr, 0); 1354 1401 gpr += 2; 1355 1402 1356 1403 /* Philips ADC Playback Volume */ 1357 1404 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_ADC_L); … … 1445 1492 1446 1493 ctl = &controls[nctl + 0]; 1447 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;1494 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 1448 1495 strcpy(ctl->id.name, "Tone Control - Bass"); 1449 1496 ctl->vcount = 2; … … 1454 1501 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; 1455 1502 ctl = &controls[nctl + 1]; 1456 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;1503 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 1457 1504 strcpy(ctl->id.name, "Tone Control - Treble"); 1458 1505 ctl->vcount = 2; … … 1541 1588 if (emu->card_capabilities->emu_model) { 1542 1589 /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */ 1543 snd_printk(KERN_INFO"EMU outputs on\n");1590 dev_info(emu->card->dev, "EMU outputs on\n"); 1544 1591 for (z = 0; z < 8; z++) { 1545 1592 if (emu->card_capabilities->ca0108_chip) { … … 1551 1598 } 1552 1599 1553 /* IEC958 Optical Raw Playback Switch */ 1600 /* IEC958 Optical Raw Playback Switch */ 1554 1601 gpr_map[gpr++] = 0; 1555 1602 gpr_map[gpr++] = 0x1008; … … 1565 1612 if ((z==1) && (emu->card_capabilities->spdif_bug)) { 1566 1613 /* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ 1567 snd_printk(KERN_INFO "Installing spdif_bug patch: %s\n", emu->card_capabilities->name); 1614 dev_info(emu->card->dev, 1615 "Installing spdif_bug patch: %s\n", 1616 emu->card_capabilities->name); 1568 1617 A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_00000000); 1569 1618 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000); … … 1589 1638 if (emu->card_capabilities->emu_model) { 1590 1639 if (emu->card_capabilities->ca0108_chip) { 1591 snd_printk(KERN_INFO"EMU2 inputs on\n");1640 dev_info(emu->card->dev, "EMU2 inputs on\n"); 1592 1641 for (z = 0; z < 0x10; z++) { 1593 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, 1642 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, 1594 1643 bit_shifter16, 1595 1644 A3_EMU32IN(z), … … 1597 1646 } 1598 1647 } else { 1599 snd_printk(KERN_INFO"EMU inputs on\n");1648 dev_info(emu->card->dev, "EMU inputs on\n"); 1600 1649 /* Capture 16 (originally 8) channels of S32_LE sound */ 1601 1650 1602 1651 /* 1603 printk(KERN_DEBUG"emufx.c: gpr=0x%x, tmp=0x%x\n",1652 dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n", 1604 1653 gpr, tmp); 1605 1654 */ … … 1732 1781 A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0); 1733 1782 1734 seg = snd_enter_user();1735 1783 icode->gpr_add_control_count = nctl; 1736 icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;1784 icode->gpr_add_controls = controls; 1737 1785 emu->support_tlv = 1; /* support TLV */ 1738 err = snd_emu10k1_icode_poke(emu, icode );1786 err = snd_emu10k1_icode_poke(emu, icode, true); 1739 1787 emu->support_tlv = 0; /* clear again */ 1740 snd_leave_user(seg); 1741 1742 __err: 1788 1789 __err: 1743 1790 kfree(controls); 1744 if (icode != NULL) { 1745 kfree((void __force *)icode->gpr_map);1746 kfree(icode); 1747 }1791 __err_ctrls: 1792 kfree(icode->gpr_map); 1793 __err_gpr: 1794 kfree(icode); 1748 1795 return err; 1749 1796 } … … 1756 1803 /* when volume = max, then copy only to avoid volume modification */ 1757 1804 /* with iMAC0 (negative values) */ 1758 static void _ _devinit _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)1805 static void _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) 1759 1806 { 1760 1807 OP(icode, ptr, iMAC0, dst, C_00000000, src, vol); … … 1763 1810 OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000); 1764 1811 } 1765 static void _ _devinit _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)1812 static void _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) 1766 1813 { 1767 1814 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); … … 1771 1818 OP(icode, ptr, iMAC0, dst, dst, src, vol); 1772 1819 } 1773 static void _ _devinit _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)1820 static void _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) 1774 1821 { 1775 1822 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); … … 1802 1849 1803 1850 1804 static int _ _devinit _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)1851 static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) 1805 1852 { 1806 1853 int err, i, z, gpr, tmp, playback, capture; … … 1810 1857 struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; 1811 1858 u32 *gpr_map; 1812 mm_segment_t seg; 1813 1814 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) 1815 return -ENOMEM; 1816 if ((icode->gpr_map = (u_int32_t __user *) 1817 kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), 1818 GFP_KERNEL)) == NULL || 1819 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1820 sizeof(struct snd_emu10k1_fx8010_control_gpr), 1821 GFP_KERNEL)) == NULL || 1822 (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { 1823 err = -ENOMEM; 1824 goto __err; 1825 } 1826 gpr_map = (u32 __force *)icode->gpr_map; 1859 1860 err = -ENOMEM; 1861 icode = kzalloc(sizeof(*icode), GFP_KERNEL); 1862 if (!icode) 1863 return err; 1864 1865 icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, 1866 sizeof(u_int32_t), GFP_KERNEL); 1867 if (!icode->gpr_map) 1868 goto __err_gpr; 1869 1870 controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1871 sizeof(struct snd_emu10k1_fx8010_control_gpr), 1872 GFP_KERNEL); 1873 if (!controls) 1874 goto __err_ctrls; 1875 1876 ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); 1877 if (!ipcm) 1878 goto __err_ipcm; 1879 1880 gpr_map = icode->gpr_map; 1827 1881 1828 1882 icode->tram_data_map = icode->gpr_map + 256; … … 2158 2212 2159 2213 ctl = &controls[i + 0]; 2160 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;2214 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 2161 2215 strcpy(ctl->id.name, "Tone Control - Bass"); 2162 2216 ctl->vcount = 2; … … 2165 2219 ctl->max = 40; 2166 2220 ctl->value[0] = ctl->value[1] = 20; 2221 ctl->tlv = snd_emu10k1_bass_treble_db_scale; 2167 2222 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; 2168 2223 ctl = &controls[i + 1]; 2169 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;2224 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; 2170 2225 strcpy(ctl->id.name, "Tone Control - Treble"); 2171 2226 ctl->vcount = 2; … … 2174 2229 ctl->max = 40; 2175 2230 ctl->value[0] = ctl->value[1] = 20; 2231 ctl->tlv = snd_emu10k1_bass_treble_db_scale; 2176 2232 ctl->translation = EMU10K1_GPR_TRANSLATION_TREBLE; 2177 2233 … … 2316 2372 * and EXTOUT_ALFE, so we can't connect inputs to them for multitrack recording. 2317 2373 * 2318 * Since only 14 of the 16 EXTINs are used, this is not a big problem. 2319 * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture 2320 * 0 and 3, then the rest of the EXTINs to the corresponding FX capture 2321 * channel. Multitrack recorders will still see the center/lfe output signal 2374 * Since only 14 of the 16 EXTINs are used, this is not a big problem. 2375 * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture 2376 * 0 and 3, then the rest of the EXTINs to the corresponding FX capture 2377 * channel. Multitrack recorders will still see the center/lfe output signal 2322 2378 * on the second and third channels. 2323 2379 */ … … 2332 2388 OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z)); 2333 2389 } 2334 2390 2335 2391 2336 2392 if (gpr > tmp) { … … 2351 2407 if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0) 2352 2408 goto __err; 2353 seg = snd_enter_user();2354 2409 icode->gpr_add_control_count = i; 2355 icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;2410 icode->gpr_add_controls = controls; 2356 2411 emu->support_tlv = 1; /* support TLV */ 2357 err = snd_emu10k1_icode_poke(emu, icode );2412 err = snd_emu10k1_icode_poke(emu, icode, true); 2358 2413 emu->support_tlv = 0; /* clear again */ 2359 snd_leave_user(seg);2360 2414 if (err >= 0) 2361 2415 err = snd_emu10k1_ipcm_poke(emu, ipcm); 2362 __err:2416 __err: 2363 2417 kfree(ipcm); 2418 __err_ipcm: 2364 2419 kfree(controls); 2365 if (icode != NULL) { 2366 kfree((void __force *)icode->gpr_map);2367 kfree(icode); 2368 }2420 __err_ctrls: 2421 kfree(icode->gpr_map); 2422 __err_gpr: 2423 kfree(icode); 2369 2424 return err; 2370 2425 } 2371 2426 2372 int __devinitsnd_emu10k1_init_efx(struct snd_emu10k1 *emu)2427 int snd_emu10k1_init_efx(struct snd_emu10k1 *emu) 2373 2428 { 2374 2429 spin_lock_init(&emu->fx8010.irq_lock); … … 2435 2490 2436 2491 if (size > 0) { 2437 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),2492 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &emu->pci->dev, 2438 2493 size * 2, &emu->fx8010.etram_pages) < 0) 2439 2494 return -ENOMEM; … … 2454 2509 } 2455 2510 2456 static void copy_string(char *dst, c har *src,char *null, int idx)2511 static void copy_string(char *dst, const char *src, const char *null, int idx) 2457 2512 { 2458 2513 if (src == NULL) … … 2465 2520 struct snd_emu10k1_fx8010_info *info) 2466 2521 { 2467 c har **fxbus, **extin, **extout;2522 const char * const *fxbus, * const *extin, * const *extout; 2468 2523 unsigned short fxbus_mask, extin_mask, extout_mask; 2469 2524 int res; … … 2502 2557 return put_user(SNDRV_EMU10K1_VERSION, (int __user *)argp); 2503 2558 case SNDRV_EMU10K1_IOCTL_INFO: 2504 info = k malloc(sizeof(*info), GFP_KERNEL);2559 info = kzalloc(sizeof(*info), GFP_KERNEL); 2505 2560 if (!info) 2506 2561 return -ENOMEM; … … 2519 2574 if (IS_ERR(icode)) 2520 2575 return PTR_ERR(icode); 2521 res = snd_emu10k1_icode_poke(emu, icode );2576 res = snd_emu10k1_icode_poke(emu, icode, false); 2522 2577 kfree(icode); 2523 2578 return res; … … 2623 2678 } 2624 2679 2625 int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep)2680 int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device) 2626 2681 { 2627 2682 struct snd_hwdep *hw; 2628 2683 int err; 2629 2684 2630 if (rhwdep)2631 *rhwdep = NULL;2632 2685 if ((err = snd_hwdep_new(emu->card, "FX8010", device, &hw)) < 0) 2633 2686 return err; … … 2638 2691 hw->ops.release = snd_emu10k1_fx8010_release; 2639 2692 hw->private_data = emu; 2640 if (rhwdep)2641 *rhwdep = hw;2642 2693 return 0; 2643 2694 } 2644 2695 2645 #ifdef CONFIG_PM 2646 int __devinitsnd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu)2696 #ifdef CONFIG_PM_SLEEP 2697 int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) 2647 2698 { 2648 2699 int len; 2649 2700 2650 2701 len = emu->audigy ? 0x200 : 0x100; 2651 emu->saved_gpr = kmalloc (len *4, GFP_KERNEL);2702 emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL); 2652 2703 if (! emu->saved_gpr) 2653 2704 return -ENOMEM; 2654 2705 len = emu->audigy ? 0x100 : 0xa0; 2655 emu->tram_val_saved = kmalloc (len *4, GFP_KERNEL);2656 emu->tram_addr_saved = kmalloc (len *4, GFP_KERNEL);2706 emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL); 2707 emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL); 2657 2708 if (! emu->tram_val_saved || ! emu->tram_addr_saved) 2658 2709 return -ENOMEM; 2659 2710 len = emu->audigy ? 2 * 1024 : 2 * 512; 2711 #ifdef TARGET_OS2 2712 emu->saved_icode = vmalloc(array_size(len, 4)); 2713 #else 2660 2714 emu->saved_icode = vmalloc(len * 4); 2715 #endif 2661 2716 if (! emu->saved_icode) 2662 2717 return -ENOMEM; -
GPL/trunk/alsa-kernel/pci/emu10k1/emumixer.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>, … … 14 15 * TODO: 15 16 * -- 16 *17 * This program is free software; you can redistribute it and/or modify18 * it under the terms of the GNU General Public License as published by19 * the Free Software Foundation; either version 2 of the License, or20 * (at your option) any later version.21 *22 * This program is distributed in the hope that it will be useful,23 * but WITHOUT ANY WARRANTY; without even the implied warranty of24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the25 * GNU General Public License for more details.26 *27 * You should have received a copy of the GNU General Public License28 * along with this program; if not, write to the Free Software29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA30 *31 17 */ 32 18 … … 84 70 * each destination 85 71 */ 86 static c har *emu1010_src_texts[] = {72 static const char * const emu1010_src_texts[] = { 87 73 "Silence", 88 74 "Dock Mic A", … … 142 128 /* 1616(m) cardbus */ 143 129 144 static c har *emu1616_src_texts[] = {130 static const char * const emu1616_src_texts[] = { 145 131 "Silence", 146 132 "Dock Mic A", … … 198 184 * List of data sources available for each destination 199 185 */ 200 static unsigned int emu1010_src_regs[] = {186 static const unsigned int emu1010_src_regs[] = { 201 187 EMU_SRC_SILENCE,/* 0 */ 202 188 EMU_SRC_DOCK_MIC_A1, /* 1 */ … … 255 241 256 242 /* 1616(m) cardbus */ 257 static unsigned int emu1616_src_regs[] = {243 static const unsigned int emu1616_src_regs[] = { 258 244 EMU_SRC_SILENCE, 259 245 EMU_SRC_DOCK_MIC_A1, … … 311 297 * Each destination has an enum mixer control to choose a data source 312 298 */ 313 static unsigned int emu1010_output_dst[] = {299 static const unsigned int emu1010_output_dst[] = { 314 300 EMU_DST_DOCK_DAC1_LEFT1, /* 0 */ 315 301 EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */ … … 339 325 340 326 /* 1616(m) cardbus */ 341 static unsigned int emu1616_output_dst[] = {327 static const unsigned int emu1616_output_dst[] = { 342 328 EMU_DST_DOCK_DAC1_LEFT1, 343 329 EMU_DST_DOCK_DAC1_RIGHT1, … … 365 351 * Each destination has an enum mixer control to choose a data source 366 352 */ 367 static unsigned int emu1010_input_dst[] = {353 static const unsigned int emu1010_input_dst[] = { 368 354 EMU_DST_ALICE2_EMU32_0, 369 355 EMU_DST_ALICE2_EMU32_1, … … 394 380 { 395 381 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 396 char **items; 397 398 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 399 uinfo->count = 1; 400 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) { 401 uinfo->value.enumerated.items = 49; 402 items = emu1616_src_texts; 403 } else { 404 uinfo->value.enumerated.items = 53; 405 items = emu1010_src_texts; 406 } 407 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 408 uinfo->value.enumerated.item = 409 uinfo->value.enumerated.items - 1; 410 strcpy(uinfo->value.enumerated.name, 411 items[uinfo->value.enumerated.item]); 412 return 0; 382 383 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) 384 return snd_ctl_enum_info(uinfo, 1, 49, emu1616_src_texts); 385 else 386 return snd_ctl_enum_info(uinfo, 1, 53, emu1010_src_texts); 413 387 } 414 388 … … 511 485 } 512 486 513 static struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] __devinitdata= {487 static const struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] = { 514 488 EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0), 515 489 EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1), … … 540 514 541 515 /* 1616(m) cardbus */ 542 static struct snd_kcontrol_new snd_emu1616_output_enum_ctls[] __devinitdata= {516 static const struct snd_kcontrol_new snd_emu1616_output_enum_ctls[] = { 543 517 EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0), 544 518 EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1), … … 572 546 } 573 547 574 static struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] __devinitdata= {548 static const struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] = { 575 549 EMU1010_SOURCE_INPUT("DSP 0 Capture Enum", 0), 576 550 EMU1010_SOURCE_INPUT("DSP 1 Capture Enum", 1), … … 640 614 } 641 615 642 static struct snd_kcontrol_new snd_emu1010_adc_pads[] __devinitdata= {616 static const struct snd_kcontrol_new snd_emu1010_adc_pads[] = { 643 617 EMU1010_ADC_PADS("ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1), 644 618 EMU1010_ADC_PADS("ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2), … … 688 662 } 689 663 690 static struct snd_kcontrol_new snd_emu1010_dac_pads[] __devinitdata= {664 static const struct snd_kcontrol_new snd_emu1010_dac_pads[] = { 691 665 EMU1010_DAC_PADS("DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1), 692 666 EMU1010_DAC_PADS("DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2), … … 700 674 struct snd_ctl_elem_info *uinfo) 701 675 { 702 static c har *texts[4] = {676 static const char * const texts[4] = { 703 677 "44100", "48000", "SPDIF", "ADAT" 704 678 }; 705 679 706 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 707 uinfo->count = 1; 708 uinfo->value.enumerated.items = 4; 709 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 710 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 711 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 712 return 0; 713 714 680 return snd_ctl_enum_info(uinfo, 1, 4, texts); 715 681 } 716 682 … … 816 782 } 817 783 818 static struct snd_kcontrol_new snd_emu1010_internal_clock =784 static const struct snd_kcontrol_new snd_emu1010_internal_clock = 819 785 { 820 786 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, … … 827 793 }; 828 794 795 static int snd_emu1010_optical_out_info(struct snd_kcontrol *kcontrol, 796 struct snd_ctl_elem_info *uinfo) 797 { 798 static const char * const texts[2] = { 799 "SPDIF", "ADAT" 800 }; 801 802 return snd_ctl_enum_info(uinfo, 1, 2, texts); 803 } 804 805 static int snd_emu1010_optical_out_get(struct snd_kcontrol *kcontrol, 806 struct snd_ctl_elem_value *ucontrol) 807 { 808 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 809 810 ucontrol->value.enumerated.item[0] = emu->emu1010.optical_out; 811 return 0; 812 } 813 814 static int snd_emu1010_optical_out_put(struct snd_kcontrol *kcontrol, 815 struct snd_ctl_elem_value *ucontrol) 816 { 817 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 818 unsigned int val; 819 u32 tmp; 820 int change = 0; 821 822 val = ucontrol->value.enumerated.item[0]; 823 /* Limit: uinfo->value.enumerated.items = 2; */ 824 if (val >= 2) 825 return -EINVAL; 826 change = (emu->emu1010.optical_out != val); 827 if (change) { 828 emu->emu1010.optical_out = val; 829 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) | 830 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0); 831 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp); 832 } 833 return change; 834 } 835 836 static const struct snd_kcontrol_new snd_emu1010_optical_out = { 837 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 839 .name = "Optical Output Mode", 840 .count = 1, 841 .info = snd_emu1010_optical_out_info, 842 .get = snd_emu1010_optical_out_get, 843 .put = snd_emu1010_optical_out_put 844 }; 845 846 static int snd_emu1010_optical_in_info(struct snd_kcontrol *kcontrol, 847 struct snd_ctl_elem_info *uinfo) 848 { 849 static const char * const texts[2] = { 850 "SPDIF", "ADAT" 851 }; 852 853 return snd_ctl_enum_info(uinfo, 1, 2, texts); 854 } 855 856 static int snd_emu1010_optical_in_get(struct snd_kcontrol *kcontrol, 857 struct snd_ctl_elem_value *ucontrol) 858 { 859 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 860 861 ucontrol->value.enumerated.item[0] = emu->emu1010.optical_in; 862 return 0; 863 } 864 865 static int snd_emu1010_optical_in_put(struct snd_kcontrol *kcontrol, 866 struct snd_ctl_elem_value *ucontrol) 867 { 868 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 869 unsigned int val; 870 u32 tmp; 871 int change = 0; 872 873 val = ucontrol->value.enumerated.item[0]; 874 /* Limit: uinfo->value.enumerated.items = 2; */ 875 if (val >= 2) 876 return -EINVAL; 877 change = (emu->emu1010.optical_in != val); 878 if (change) { 879 emu->emu1010.optical_in = val; 880 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) | 881 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0); 882 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp); 883 } 884 return change; 885 } 886 887 static const struct snd_kcontrol_new snd_emu1010_optical_in = { 888 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 889 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 890 .name = "Optical Input Mode", 891 .count = 1, 892 .info = snd_emu1010_optical_in_info, 893 .get = snd_emu1010_optical_in_get, 894 .put = snd_emu1010_optical_in_put 895 }; 896 829 897 static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol *kcontrol, 830 898 struct snd_ctl_elem_info *uinfo) 831 899 { 832 900 #if 0 833 static c har *texts[4] = {901 static const char * const texts[4] = { 834 902 "Unknown1", "Unknown2", "Mic", "Line" 835 903 }; 836 904 #endif 837 static c har *texts[2] = {905 static const char * const texts[2] = { 838 906 "Mic", "Line" 839 907 }; 840 908 841 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 842 uinfo->count = 1; 843 uinfo->value.enumerated.items = 2; 844 if (uinfo->value.enumerated.item > 1) 845 uinfo->value.enumerated.item = 1; 846 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 847 return 0; 909 return snd_ctl_enum_info(uinfo, 1, 2, texts); 848 910 } 849 911 … … 903 965 } 904 966 905 static struct snd_kcontrol_new snd_audigy_i2c_capture_source =967 static const struct snd_kcontrol_new snd_audigy_i2c_capture_source = 906 968 { 907 969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 990 1052 991 1053 992 static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] __devinitdata= {1054 static const struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] = { 993 1055 I2C_VOLUME("Mic Capture Volume", 0), 994 1056 I2C_VOLUME("Line Capture Volume", 0) … … 998 1060 static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 999 1061 { 1000 static char *texts[] = {"44100", "48000", "96000"}; 1001 1002 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1003 uinfo->count = 1; 1004 uinfo->value.enumerated.items = 3; 1005 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1006 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1007 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1008 return 0; 1062 static const char * const texts[] = {"44100", "48000", "96000"}; 1063 1064 return snd_ctl_enum_info(uinfo, 1, 3, texts); 1009 1065 } 1010 1066 … … 1070 1126 } 1071 1127 1072 static struct snd_kcontrol_new snd_audigy_spdif_output_rate =1128 static const struct snd_kcontrol_new snd_audigy_spdif_output_rate = 1073 1129 { 1074 1130 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, … … 1108 1164 } 1109 1165 1110 static struct snd_kcontrol_new snd_emu10k1_spdif_mask_control =1166 static const struct snd_kcontrol_new snd_emu10k1_spdif_mask_control = 1111 1167 { 1112 1168 .access = SNDRV_CTL_ELEM_ACCESS_READ, … … 1118 1174 }; 1119 1175 1120 static struct snd_kcontrol_new snd_emu10k1_spdif_control =1176 static const struct snd_kcontrol_new snd_emu10k1_spdif_control = 1121 1177 { 1122 1178 .iface = SNDRV_CTL_ELEM_IFACE_PCM, … … 1224 1280 } 1225 1281 1226 static struct snd_kcontrol_new snd_emu10k1_send_routing_control =1282 static const struct snd_kcontrol_new snd_emu10k1_send_routing_control = 1227 1283 { 1228 1284 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1295 1351 } 1296 1352 1297 static struct snd_kcontrol_new snd_emu10k1_send_volume_control =1353 static const struct snd_kcontrol_new snd_emu10k1_send_volume_control = 1298 1354 { 1299 1355 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1360 1416 } 1361 1417 1362 static struct snd_kcontrol_new snd_emu10k1_attn_control =1418 static const struct snd_kcontrol_new snd_emu10k1_attn_control = 1363 1419 { 1364 1420 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1432 1488 } 1433 1489 1434 static struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control =1490 static const struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control = 1435 1491 { 1436 1492 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1499 1555 1500 1556 1501 static struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control =1557 static const struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control = 1502 1558 { 1503 1559 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1557 1613 } 1558 1614 1559 static struct snd_kcontrol_new snd_emu10k1_efx_attn_control =1615 static const struct snd_kcontrol_new snd_emu10k1_efx_attn_control = 1560 1616 { 1561 1617 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1622 1678 } 1623 1679 1624 static struct snd_kcontrol_new snd_emu10k1_shared_spdif __devinitdata=1680 static const struct snd_kcontrol_new snd_emu10k1_shared_spdif = 1625 1681 { 1626 1682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1631 1687 }; 1632 1688 1633 static struct snd_kcontrol_new snd_audigy_shared_spdif __devinitdata=1689 static const struct snd_kcontrol_new snd_audigy_shared_spdif = 1634 1690 { 1635 1691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1669 1725 } 1670 1726 1671 static struct snd_kcontrol_new snd_audigy_capture_boost __devinitdata=1727 static const struct snd_kcontrol_new snd_audigy_capture_boost = 1672 1728 { 1673 1729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1674 .name = " Analog CaptureBoost",1730 .name = "Mic Extra Boost", 1675 1731 .info = snd_audigy_capture_boost_info, 1676 1732 .get = snd_audigy_capture_boost_get, … … 1717 1773 } 1718 1774 1719 int __devinitsnd_emu10k1_mixer(struct snd_emu10k1 *emu,1720 int pcm_device, int multi_device)1775 int snd_emu10k1_mixer(struct snd_emu10k1 *emu, 1776 int pcm_device, int multi_device) 1721 1777 { 1722 1778 int err, pcm; 1723 1779 struct snd_kcontrol *kctl; 1724 1780 struct snd_card *card = emu->card; 1725 c har **c;1726 static c har *emu10k1_remove_ctls[] = {1781 const char * const *c; 1782 static const char * const emu10k1_remove_ctls[] = { 1727 1783 /* no AC97 mono, surround, center/lfe */ 1728 1784 "Master Mono Playback Switch", … … 1730 1786 "PCM Out Path & Mute", 1731 1787 "Mono Output Select", 1732 "Front Playback Switch",1733 "Front Playback Volume",1734 1788 "Surround Playback Switch", 1735 1789 "Surround Playback Volume", … … 1740 1794 NULL 1741 1795 }; 1742 static c har *emu10k1_rename_ctls[] = {1796 static const char * const emu10k1_rename_ctls[] = { 1743 1797 "Surround Digital Playback Volume", "Surround Playback Volume", 1744 1798 "Center Digital Playback Volume", "Center Playback Volume", … … 1746 1800 NULL 1747 1801 }; 1748 static c har *audigy_remove_ctls[] = {1802 static const char * const audigy_remove_ctls[] = { 1749 1803 /* Master/PCM controls on ac97 of Audigy has no effect */ 1750 1804 /* On the Audigy2 the AC97 playback is piped into … … 1752 1806 "PCM Playback Switch", 1753 1807 "PCM Playback Volume", 1754 "Master Mono Playback Switch",1755 "Master Mono Playback Volume",1756 1808 "Master Playback Switch", 1757 1809 "Master Playback Volume", … … 1763 1815 "Capture Volume", 1764 1816 "Mic Select", 1817 "Headphone Playback Switch", 1818 "Headphone Playback Volume", 1819 "3D Control - Center", 1820 "3D Control - Depth", 1821 "3D Control - Switch", 1765 1822 "Video Playback Switch", 1766 1823 "Video Playback Volume", 1767 1824 "Mic Playback Switch", 1768 1825 "Mic Playback Volume", 1826 "External Amplifier", 1769 1827 NULL 1770 1828 }; 1771 static c har *audigy_rename_ctls[] = {1829 static const char * const audigy_rename_ctls[] = { 1772 1830 /* use conventional names */ 1773 1831 "Wave Playback Volume", "PCM Playback Volume", … … 1775 1833 "Wave Master Playback Volume", "Master Playback Volume", 1776 1834 "AMic Playback Volume", "Mic Playback Volume", 1835 "Master Mono Playback Switch", "Phone Output Playback Switch", 1836 "Master Mono Playback Volume", "Phone Output Playback Volume", 1777 1837 NULL 1778 1838 }; 1779 static c har *audigy_rename_ctls_i2c_adc[] = {1839 static const char * const audigy_rename_ctls_i2c_adc[] = { 1780 1840 //"Analog Mix Capture Volume","OLD Analog Mix Capture Volume", 1781 1841 "Line Capture Volume", "Analog Mix Capture Volume", … … 1786 1846 NULL 1787 1847 }; 1788 static c har *audigy_remove_ctls_i2c_adc[] = {1848 static const char * const audigy_remove_ctls_i2c_adc[] = { 1789 1849 /* On the Audigy2 ZS Notebook 1790 1850 * Capture via WM8775 */ … … 1795 1855 NULL 1796 1856 }; 1797 static c har *audigy_remove_ctls_1361t_adc[] = {1857 static const char * const audigy_remove_ctls_1361t_adc[] = { 1798 1858 /* On the Audigy2 the AC97 playback is piped into 1799 1859 * the Philips ADC for 24bit capture */ 1800 1860 "PCM Playback Switch", 1801 1861 "PCM Playback Volume", 1802 "Master Mono Playback Switch",1803 "Master Mono Playback Volume",1804 1862 "Capture Source", 1805 1863 "Capture Switch", … … 1815 1873 NULL 1816 1874 }; 1817 static c har *audigy_rename_ctls_1361t_adc[] = {1875 static const char * const audigy_rename_ctls_1361t_adc[] = { 1818 1876 "Master Playback Switch", "Master Capture Switch", 1819 1877 "Master Playback Volume", "Master Capture Volume", … … 1833 1891 "Video Playback Switch", "Video Capture Switch", 1834 1892 "Video Playback Volume", "Video Capture Volume", 1835 1893 "Master Mono Playback Switch", "Phone Output Playback Switch", 1894 "Master Mono Playback Volume", "Phone Output Playback Volume", 1836 1895 NULL 1837 1896 }; … … 1840 1899 struct snd_ac97_bus *pbus; 1841 1900 struct snd_ac97_template ac97; 1842 static struct snd_ac97_bus_ops ops = {1901 static const struct snd_ac97_bus_ops ops = { 1843 1902 .write = snd_emu10k1_ac97_write, 1844 1903 .read = snd_emu10k1_ac97_read, … … 1856 1915 if (emu->card_capabilities->ac97_chip == 1) 1857 1916 return err; 1858 snd_printd(KERN_INFO "emu10k1: AC97 is optional on this board\n"); 1859 snd_printd(KERN_INFO" Proceeding without ac97 mixers...\n"); 1917 dev_info(emu->card->dev, 1918 "AC97 is optional on this board\n"); 1919 dev_info(emu->card->dev, 1920 "Proceeding without ac97 mixers...\n"); 1860 1921 snd_device_free(emu->card, pbus); 1861 1922 goto no_ac97; /* FIXME: get rid of ugly gotos.. */ … … 1866 1927 /* set capture source to mic */ 1867 1928 snd_ac97_write_cache(emu->ac97, AC97_REC_SEL, 0x0000); 1929 /* set mono output (TAD) to mic */ 1930 snd_ac97_update_bits(emu->ac97, AC97_GENERAL_PURPOSE, 1931 0x0200, 0x0200); 1868 1932 if (emu->card_capabilities->adc_1361t) 1869 1933 c = audigy_remove_ctls_1361t_adc; … … 1880 1944 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT); 1881 1945 snd_ac97_write_cache(emu->ac97, AC97_HEADPHONE, 0x0202); 1946 remove_ctl(card,"Front Playback Volume"); 1947 remove_ctl(card,"Front Playback Switch"); 1882 1948 } 1883 1949 /* remove unused AC97 controls */ … … 1914 1980 rename_ctl(card, c[0], c[1]); 1915 1981 1982 if (emu->card_capabilities->subsystem == 0x80401102) { /* SB Live! Platinum CT4760P */ 1983 remove_ctl(card, "Center Playback Volume"); 1984 remove_ctl(card, "LFE Playback Volume"); 1985 remove_ctl(card, "Wave Center Playback Volume"); 1986 remove_ctl(card, "Wave LFE Playback Volume"); 1987 } 1916 1988 if (emu->card_capabilities->subsystem == 0x20071102) { /* Audigy 4 Pro */ 1917 1989 rename_ctl(card, "Line2 Capture Volume", "Line1/Mic Capture Volume"); … … 1919 1991 rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume"); 1920 1992 rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume"); 1921 remove_ctl(card, "Headphone Playback Switch");1922 remove_ctl(card, "Headphone Playback Volume");1923 remove_ctl(card, "3D Control - Center");1924 remove_ctl(card, "3D Control - Depth");1925 remove_ctl(card, "3D Control - Switch");1926 1993 } 1927 1994 if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL) … … 2076 2143 if (err < 0) 2077 2144 return err; 2145 err = snd_ctl_add(card, 2146 snd_ctl_new1(&snd_emu1010_optical_out, emu)); 2147 if (err < 0) 2148 return err; 2149 err = snd_ctl_add(card, 2150 snd_ctl_new1(&snd_emu1010_optical_in, emu)); 2151 if (err < 0) 2152 return err; 2078 2153 2079 2154 } else if (emu->card_capabilities->emu_model) { … … 2111 2186 if (err < 0) 2112 2187 return err; 2188 err = snd_ctl_add(card, 2189 snd_ctl_new1(&snd_emu1010_optical_out, emu)); 2190 if (err < 0) 2191 return err; 2192 err = snd_ctl_add(card, 2193 snd_ctl_new1(&snd_emu1010_optical_in, emu)); 2194 if (err < 0) 2195 return err; 2113 2196 } 2114 2197 -
GPL/trunk/alsa-kernel/pci/emu10k1/emumpu401.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 3 4 * Routines for control of EMU10K1 MPU-401 in UART mode 4 *5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 *20 5 */ 21 6 … … 65 50 #ifdef CONFIG_SND_DEBUG 66 51 if (timeout <= 0) 67 snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); 52 dev_err(emu->card->dev, 53 "cmd: clear rx timeout (status = 0x%x)\n", 54 mpu401_read_stat(emu, mpu)); 68 55 #endif 69 56 } … … 142 129 spin_unlock_irqrestore(&midi->input_lock, flags); 143 130 if (!ok) { 144 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 131 dev_err(emu->card->dev, 132 "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 145 133 cmd, emu->port, 146 134 mpu401_read_stat(emu, midi), … … 306 294 */ 307 295 308 static struct snd_rawmidi_ops snd_emu10k1_midi_output =296 static const struct snd_rawmidi_ops snd_emu10k1_midi_output = 309 297 { 310 298 .open = snd_emu10k1_midi_output_open, … … 313 301 }; 314 302 315 static struct snd_rawmidi_ops snd_emu10k1_midi_input =303 static const struct snd_rawmidi_ops snd_emu10k1_midi_input = 316 304 { 317 305 .open = snd_emu10k1_midi_input_open, … … 327 315 } 328 316 329 static int __devinitemu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, char *name)317 static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, char *name) 330 318 { 331 319 struct snd_rawmidi *rmidi; … … 350 338 } 351 339 352 int __devinitsnd_emu10k1_midi(struct snd_emu10k1 *emu)340 int snd_emu10k1_midi(struct snd_emu10k1 *emu) 353 341 { 354 342 struct snd_emu10k1_midi *midi = &emu->midi; … … 367 355 } 368 356 369 int __devinitsnd_emu10k1_audigy_midi(struct snd_emu10k1 *emu)357 int snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu) 370 358 { 371 359 struct snd_emu10k1_midi *midi; -
GPL/trunk/alsa-kernel/pci/emu10k1/emupcm.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 10 11 * TODO: 11 12 * -- 12 *13 * This program is free software; you can redistribute it and/or modify14 * it under the terms of the GNU General Public License as published by15 * the Free Software Foundation; either version 2 of the License, or16 * (at your option) any later version.17 *18 * This program is distributed in the hope that it will be useful,19 * but WITHOUT ANY WARRANTY; without even the implied warranty of20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the21 * GNU General Public License for more details.22 *23 * You should have received a copy of the GNU General Public License24 * along with this program; if not, write to the Free Software25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA26 *27 13 */ 28 14 … … 45 31 return; 46 32 #if 0 47 printk(KERN_DEBUG "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 33 dev_dbg(emu->card->dev, 34 "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 48 35 epcm->substream->runtime->hw->pointer(emu, epcm->substream), 49 36 snd_pcm_lib_period_bytes(epcm->substream), … … 148 135 if (err < 0) { 149 136 /* 150 printk(KERN_DEBUG"pcm_channel_alloc: "137 dev_dbg(emu->card->dev, "pcm_channel_alloc: " 151 138 "failed extra: voices=%d, frame=%d\n", 152 139 voices, frame); … … 164 151 } 165 152 166 static unsigned int capture_period_sizes[31] = {153 static const unsigned int capture_period_sizes[31] = { 167 154 384, 448, 512, 640, 168 155 384*2, 448*2, 512*2, 640*2, … … 175 162 }; 176 163 177 static struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes = {164 static const struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes = { 178 165 .count = 31, 179 166 .list = capture_period_sizes, … … 181 168 }; 182 169 183 static unsigned int capture_rates[8] = {170 static const unsigned int capture_rates[8] = { 184 171 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 185 172 }; 186 173 187 static struct snd_pcm_hw_constraint_list hw_constraints_capture_rates = {174 static const struct snd_pcm_hw_constraint_list hw_constraints_capture_rates = { 188 175 .count = 8, 189 176 .list = capture_rates, … … 290 277 unsigned int silent_page, tmp; 291 278 int voice, stereo, w_16; 292 unsigned char attn,send_amount[8];279 unsigned char send_amount[8]; 293 280 unsigned char send_routing[8]; 294 281 unsigned long flags; … … 313 300 /* volume parameters */ 314 301 if (extra) { 315 attn = 0;316 302 memset(send_routing, 0, sizeof(send_routing)); 317 303 send_routing[0] = 0; … … 380 366 snd_emu10k1_ptr_write(emu, Z2, voice, 0); 381 367 /* invalidate maps */ 382 silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK;368 silent_page = ((unsigned int)emu->silent_page.addr << emu->address_mode) | (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0); 383 369 snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page); 384 370 snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page); … … 411 397 struct snd_pcm_runtime *runtime = substream->runtime; 412 398 struct snd_emu10k1_pcm *epcm = runtime->private_data; 399 size_t alloc_size; 413 400 int err; 414 401 415 402 if ((err = snd_emu10k1_pcm_channel_alloc(epcm, params_channels(hw_params))) < 0) 416 403 return err; 417 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) 404 405 alloc_size = params_buffer_bytes(hw_params); 406 if (emu->iommu_workaround) 407 alloc_size += EMUPAGESIZE; 408 err = snd_pcm_lib_malloc_pages(substream, alloc_size); 409 if (err < 0) 418 410 return err; 411 if (emu->iommu_workaround && runtime->dma_bytes >= EMUPAGESIZE) 412 runtime->dma_bytes -= EMUPAGESIZE; 419 413 if (err > 0) { /* change */ 420 414 int mapped; … … 556 550 } 557 551 558 static struct snd_pcm_hardware snd_emu10k1_efx_playback =552 static const struct snd_pcm_hardware snd_emu10k1_efx_playback = 559 553 { 560 554 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | … … 575 569 .fifo_size = 0, 576 570 }; 577 578 static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream,579 struct snd_pcm_hw_params *hw_params)580 {581 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));582 }583 584 static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream)585 {586 return snd_pcm_lib_free_pages(substream);587 }588 571 589 572 static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) … … 762 745 763 746 /* 764 printk(KERN_DEBUG "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", 747 dev_dbg(emu->card->dev, 748 "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", 765 749 (int)emu, cmd, substream->ops->pointer(substream)) 766 750 */ … … 770 754 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* do we need this? */ 771 755 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); 772 /* follow thru */756 fallthrough; 773 757 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 774 758 case SNDRV_PCM_TRIGGER_RESUME: … … 816 800 snd_emu10k1_intr_enable(emu, epcm->capture_inte); 817 801 /* 818 printk(KERN_DEBUG"adccr = 0x%x, adcbs = 0x%x\n",802 dev_dbg(emu->card->dev, "adccr = 0x%x, adcbs = 0x%x\n", 819 803 epcm->adccr, epcm->adcbs); 820 804 */ … … 827 811 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val); 828 812 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2); 829 snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2); 813 dev_dbg(emu->card->dev, 814 "cr_val=0x%x, cr_val2=0x%x\n", 815 epcm->capture_cr_val, 816 epcm->capture_cr_val2); 830 817 } else 831 818 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); … … 890 877 #endif 891 878 /* 892 printk(KERN_DEBUG879 dev_dbg(emu->card->dev, 893 880 "ptr = 0x%lx, buffer_size = 0x%lx, period_size = 0x%lx\n", 894 881 (long)ptr, (long)runtime->buffer_size, … … 916 903 } 917 904 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); 918 919 /* follow thru */ 905 fallthrough; 920 906 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 921 907 case SNDRV_PCM_TRIGGER_RESUME: … … 971 957 */ 972 958 973 static struct snd_pcm_hardware snd_emu10k1_playback =959 static const struct snd_pcm_hardware snd_emu10k1_playback = 974 960 { 975 961 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 995 981 */ 996 982 997 static struct snd_pcm_hardware snd_emu10k1_capture =983 static const struct snd_pcm_hardware snd_emu10k1_capture = 998 984 { 999 985 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1015 1001 }; 1016 1002 1017 static struct snd_pcm_hardware snd_emu10k1_capture_efx =1003 static const struct snd_pcm_hardware snd_emu10k1_capture_efx = 1018 1004 { 1019 1005 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1128 1114 struct snd_emu10k1_pcm_mixer *mix; 1129 1115 struct snd_pcm_runtime *runtime = substream->runtime; 1130 int i, err ;1116 int i, err, sample_rate; 1131 1117 1132 1118 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); … … 1144 1130 } 1145 1131 if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0) { 1132 kfree(epcm); 1133 return err; 1134 } 1135 if (emu->card_capabilities->emu_model && emu->emu1010.internal_clock == 0) 1136 sample_rate = 44100; 1137 else 1138 sample_rate = 48000; 1139 err = snd_pcm_hw_rule_noresample(runtime, sample_rate); 1140 if (err < 0) { 1146 1141 kfree(epcm); 1147 1142 return err; … … 1306 1301 runtime->hw.channels_max = 16; 1307 1302 break; 1308 } ;1303 } 1309 1304 #endif 1310 1305 #if 0 … … 1351 1346 } 1352 1347 1353 static struct snd_pcm_ops snd_emu10k1_playback_ops = {1348 static const struct snd_pcm_ops snd_emu10k1_playback_ops = { 1354 1349 .open = snd_emu10k1_playback_open, 1355 1350 .close = snd_emu10k1_playback_close, 1356 .ioctl = snd_pcm_lib_ioctl,1357 1351 .hw_params = snd_emu10k1_playback_hw_params, 1358 1352 .hw_free = snd_emu10k1_playback_hw_free, … … 1360 1354 .trigger = snd_emu10k1_playback_trigger, 1361 1355 .pointer = snd_emu10k1_playback_pointer, 1362 .page = snd_pcm_sgbuf_ops_page,1363 1356 }; 1364 1357 1365 static struct snd_pcm_ops snd_emu10k1_capture_ops = {1358 static const struct snd_pcm_ops snd_emu10k1_capture_ops = { 1366 1359 .open = snd_emu10k1_capture_open, 1367 1360 .close = snd_emu10k1_capture_close, 1368 .ioctl = snd_pcm_lib_ioctl,1369 .hw_params = snd_emu10k1_capture_hw_params,1370 .hw_free = snd_emu10k1_capture_hw_free,1371 1361 .prepare = snd_emu10k1_capture_prepare, 1372 1362 .trigger = snd_emu10k1_capture_trigger, … … 1375 1365 1376 1366 /* EFX playback */ 1377 static struct snd_pcm_ops snd_emu10k1_efx_playback_ops = {1367 static const struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { 1378 1368 .open = snd_emu10k1_efx_playback_open, 1379 1369 .close = snd_emu10k1_efx_playback_close, 1380 .ioctl = snd_pcm_lib_ioctl,1381 1370 .hw_params = snd_emu10k1_playback_hw_params, 1382 1371 .hw_free = snd_emu10k1_efx_playback_hw_free, … … 1384 1373 .trigger = snd_emu10k1_efx_playback_trigger, 1385 1374 .pointer = snd_emu10k1_efx_playback_pointer, 1386 .page = snd_pcm_sgbuf_ops_page,1387 1375 }; 1388 1376 1389 int __devinit snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm)1377 int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device) 1390 1378 { 1391 1379 struct snd_pcm *pcm; 1392 1380 struct snd_pcm_substream *substream; 1393 1381 int err; 1394 1395 if (rpcm)1396 *rpcm = NULL;1397 1382 1398 1383 if ((err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm)) < 0) … … 1409 1394 emu->pcm = pcm; 1410 1395 1396 /* playback substream can't use managed buffers due to alignment */ 1411 1397 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1412 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1413 return err; 1398 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, 1399 &emu->pci->dev, 1400 64*1024, 64*1024); 1414 1401 1415 1402 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) 1416 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1417 1418 if (rpcm) 1419 *rpcm = pcm; 1420 1421 return 0; 1422 } 1423 1424 int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) 1403 snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, 1404 &emu->pci->dev, 64*1024, 64*1024); 1405 1406 return 0; 1407 } 1408 1409 int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device) 1425 1410 { 1426 1411 struct snd_pcm *pcm; 1427 1412 struct snd_pcm_substream *substream; 1428 1413 int err; 1429 1430 if (rpcm)1431 *rpcm = NULL;1432 1414 1433 1415 if ((err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm)) < 0) … … 1444 1426 1445 1427 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1446 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1447 return err; 1448 1449 if (rpcm) 1450 *rpcm = pcm; 1451 1452 return 0; 1453 } 1454 1455 1456 static struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { 1428 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, 1429 &emu->pci->dev, 1430 64*1024, 64*1024); 1431 1432 return 0; 1433 } 1434 1435 1436 static const struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { 1457 1437 .open = snd_emu10k1_capture_mic_open, 1458 1438 .close = snd_emu10k1_capture_mic_close, 1459 .ioctl = snd_pcm_lib_ioctl,1460 .hw_params = snd_emu10k1_capture_hw_params,1461 .hw_free = snd_emu10k1_capture_hw_free,1462 1439 .prepare = snd_emu10k1_capture_prepare, 1463 1440 .trigger = snd_emu10k1_capture_trigger, … … 1465 1442 }; 1466 1443 1467 int __devinit snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm)1444 int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device) 1468 1445 { 1469 1446 struct snd_pcm *pcm; 1470 1447 int err; 1471 1472 if (rpcm)1473 *rpcm = NULL;1474 1448 1475 1449 if ((err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm)) < 0) … … 1484 1458 emu->pcm_mic = pcm; 1485 1459 1486 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1487 1488 if (rpcm) 1489 *rpcm = pcm; 1460 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, 1461 64*1024, 64*1024); 1462 1490 1463 return 0; 1491 1464 } … … 1546 1519 } 1547 1520 1548 static struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = {1521 static const struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = { 1549 1522 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1550 1523 .name = "Captured FX8010 Outputs", … … 1554 1527 }; 1555 1528 1556 static struct snd_pcm_ops snd_emu10k1_capture_efx_ops = {1529 static const struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { 1557 1530 .open = snd_emu10k1_capture_efx_open, 1558 1531 .close = snd_emu10k1_capture_efx_close, 1559 .ioctl = snd_pcm_lib_ioctl,1560 .hw_params = snd_emu10k1_capture_hw_params,1561 .hw_free = snd_emu10k1_capture_hw_free,1562 1532 .prepare = snd_emu10k1_capture_prepare, 1563 1533 .trigger = snd_emu10k1_capture_trigger, … … 1584 1554 { 1585 1555 /* 1586 printk(KERN_DEBUG "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, " 1556 dev_dbg(emu->card->dev, 1557 "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, " 1587 1558 "src = 0x%p, count = 0x%x\n", 1588 1559 dst_left, dst_right, src, count); … … 1635 1606 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1636 1607 1637 snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, fx8010_pb_trans_copy); 1638 return 0; 1639 } 1640 1641 static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream, 1642 struct snd_pcm_hw_params *hw_params) 1643 { 1644 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1608 return snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, 1609 fx8010_pb_trans_copy); 1645 1610 } 1646 1611 … … 1653 1618 for (i = 0; i < pcm->channels; i++) 1654 1619 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0); 1655 snd_pcm_lib_free_pages(substream);1656 1620 return 0; 1657 1621 } … … 1665 1629 1666 1630 /* 1667 printk(KERN_DEBUG"prepare: etram_pages = 0x%p, dma_area = 0x%x, "1631 dev_dbg(emu->card->dev, "prepare: etram_pages = 0x%p, dma_area = 0x%x, " 1668 1632 "buffer_size = 0x%x (0x%x)\n", 1669 1633 emu->fx8010.etram_pages, runtime->dma_area, … … 1719 1683 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1720 1684 case SNDRV_PCM_TRIGGER_SUSPEND: 1721 snd_emu10k1_fx8010_unregister_irq_handler(emu, pcm->irq); pcm->irq = NULL;1685 snd_emu10k1_fx8010_unregister_irq_handler(emu, &pcm->irq); 1722 1686 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); 1723 1687 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); … … 1745 1709 } 1746 1710 1747 static struct snd_pcm_hardware snd_emu10k1_fx8010_playback =1711 static const struct snd_pcm_hardware snd_emu10k1_fx8010_playback = 1748 1712 { 1749 1713 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1750 1714 SNDRV_PCM_INFO_RESUME | 1751 /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE), 1715 /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE | 1716 SNDRV_PCM_INFO_SYNC_APPLPTR), 1752 1717 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 1753 1718 .rates = SNDRV_PCM_RATE_48000, … … 1794 1759 } 1795 1760 1796 static struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = {1761 static const struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { 1797 1762 .open = snd_emu10k1_fx8010_playback_open, 1798 1763 .close = snd_emu10k1_fx8010_playback_close, 1799 .ioctl = snd_pcm_lib_ioctl,1800 .hw_params = snd_emu10k1_fx8010_playback_hw_params,1801 1764 .hw_free = snd_emu10k1_fx8010_playback_hw_free, 1802 1765 .prepare = snd_emu10k1_fx8010_playback_prepare, … … 1806 1769 }; 1807 1770 1808 int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm)1771 int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device) 1809 1772 { 1810 1773 struct snd_pcm *pcm; … … 1812 1775 int err; 1813 1776 1814 if (rpcm)1815 *rpcm = NULL;1816 1817 1777 if ((err = snd_pcm_new(emu->card, "emu10k1 efx", device, 8, 1, &pcm)) < 0) 1818 1778 return err; … … 1826 1786 strcpy(pcm->name, "Multichannel Capture/PT Playback"); 1827 1787 emu->pcm_efx = pcm; 1828 if (rpcm)1829 *rpcm = pcm;1830 1788 1831 1789 /* EFX capture - record the "FXBUS2" channels, by default we connect the EXTINs … … 1858 1816 return -ENOMEM; 1859 1817 kctl->id.device = device; 1860 snd_ctl_add(emu->card, kctl); 1861 1862 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1863 1864 return 0; 1865 } 1818 err = snd_ctl_add(emu->card, kctl); 1819 if (err < 0) 1820 return err; 1821 1822 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, 1823 64*1024, 64*1024); 1824 1825 return 0; 1826 } -
GPL/trunk/alsa-kernel/pci/emu10k1/emuproc.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 12 13 * TODO: 13 14 * -- 14 *15 * This program is free software; you can redistribute it and/or modify16 * it under the terms of the GNU General Public License as published by17 * the Free Software Foundation; either version 2 of the License, or18 * (at your option) any later version.19 *20 * This program is distributed in the hope that it will be useful,21 * but WITHOUT ANY WARRANTY; without even the implied warranty of22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the23 * GNU General Public License for more details.24 *25 * You should have received a copy of the GNU General Public License26 * along with this program; if not, write to the Free Software27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA28 *29 15 */ 30 16 … … 35 21 #include "p16v.h" 36 22 37 #ifdef CONFIG_PROC_FS38 23 static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, 39 24 struct snd_info_buffer *buffer, … … 42 27 int rate_reg) 43 28 { 44 static c har *clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };45 static int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };46 static c har *channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };47 static c har *emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };29 static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" }; 30 static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; 31 static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; 32 static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" }; 48 33 unsigned int status, rate = 0; 49 34 … … 83 68 { 84 69 /* FIXME - output names are in emufx.c too */ 85 static c har *creative_outs[32] = {70 static const char * const creative_outs[32] = { 86 71 /* 00 */ "AC97 Left", 87 72 /* 01 */ "AC97 Right", … … 118 103 }; 119 104 120 static c har *audigy_outs[64] = {105 static const char * const audigy_outs[64] = { 121 106 /* 00 */ "Digital Front Left", 122 107 /* 01 */ "Digital Front Right", … … 137 122 /* 16 */ "AC97 Front Left", 138 123 /* 17 */ "AC97 Front Right", 139 /* 18 */ "ADC Cap utre Left",124 /* 18 */ "ADC Capture Left", 140 125 /* 19 */ "ADC Capture Right", 141 126 /* 20 */ "???", … … 188 173 unsigned int val, val1; 189 174 int nefx = emu->audigy ? 64 : 32; 190 c har **outputs = emu->audigy ? audigy_outs : creative_outs;175 const char * const *outputs = emu->audigy ? audigy_outs : creative_outs; 191 176 int idx; 192 177 … … 242 227 u32 value; 243 228 u32 value2; 244 unsigned long flags;245 229 u32 rate; 246 230 247 231 if (emu->card_capabilities->emu_model) { 248 spin_lock_irqsave(&emu->emu_lock, flags);249 232 snd_emu1010_fpga_read(emu, 0x38, &value); 250 spin_unlock_irqrestore(&emu->emu_lock, flags);251 233 if ((value & 0x1) == 0) { 252 spin_lock_irqsave(&emu->emu_lock, flags);253 234 snd_emu1010_fpga_read(emu, 0x2a, &value); 254 235 snd_emu1010_fpga_read(emu, 0x2b, &value2); 255 spin_unlock_irqrestore(&emu->emu_lock, flags);256 236 rate = 0x1770000 / (((value << 5) | value2)+1); 257 237 snd_iprintf(buffer, "ADAT Locked : %u\n", rate); … … 259 239 snd_iprintf(buffer, "ADAT Unlocked\n"); 260 240 } 261 spin_lock_irqsave(&emu->emu_lock, flags);262 241 snd_emu1010_fpga_read(emu, 0x20, &value); 263 spin_unlock_irqrestore(&emu->emu_lock, flags);264 242 if ((value & 0x4) == 0) { 265 spin_lock_irqsave(&emu->emu_lock, flags);266 243 snd_emu1010_fpga_read(emu, 0x28, &value); 267 244 snd_emu1010_fpga_read(emu, 0x29, &value2); 268 spin_unlock_irqrestore(&emu->emu_lock, flags);269 245 rate = 0x1770000 / (((value << 5) | value2)+1); 270 246 snd_iprintf(buffer, "SPDIF Locked : %d\n", rate); … … 287 263 struct snd_info_buffer *buffer) 288 264 { 289 static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };265 static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; 290 266 struct snd_emu10k1 *emu = entry->private_data; 291 267 unsigned int val, tmp, n; 292 268 val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); 293 tmp = (val >> 16) & 0x8;294 269 for (n = 0; n < 4; n++) { 295 270 tmp = val >> (16 + (n*4)); … … 411 386 struct snd_emu10k1 *emu = entry->private_data; 412 387 u32 value; 413 unsigned long flags;414 388 int i; 415 389 snd_iprintf(buffer, "EMU1010 Registers:\n\n"); 416 390 417 391 for(i = 0; i < 0x40; i+=1) { 418 spin_lock_irqsave(&emu->emu_lock, flags);419 392 snd_emu1010_fpga_read(emu, i, &value); 420 spin_unlock_irqrestore(&emu->emu_lock, flags);421 393 snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f); 422 394 } … … 574 546 #endif 575 547 576 static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {548 static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { 577 549 .read = snd_emu10k1_fx8010_read, 578 550 }; 579 551 580 int __devinit snd_emu10k1_proc_init(struct snd_emu10k1 *emu)552 int snd_emu10k1_proc_init(struct snd_emu10k1 *emu) 581 553 { 582 554 struct snd_info_entry *entry; 583 555 #ifdef CONFIG_SND_DEBUG 584 556 if (emu->card_capabilities->emu_model) { 585 if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry)) 586 snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read); 587 } 588 if (! snd_card_proc_new(emu->card, "io_regs", &entry)) { 589 snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read); 590 entry->c.text.write = snd_emu_proc_io_reg_write; 591 entry->mode |= S_IWUSR; 592 } 593 if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) { 594 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a); 595 entry->c.text.write = snd_emu_proc_ptr_reg_write00; 596 entry->mode |= S_IWUSR; 597 } 598 if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) { 599 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b); 600 entry->c.text.write = snd_emu_proc_ptr_reg_write00; 601 entry->mode |= S_IWUSR; 602 } 603 if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) { 604 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a); 605 entry->c.text.write = snd_emu_proc_ptr_reg_write20; 606 entry->mode |= S_IWUSR; 607 } 608 if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) { 609 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b); 610 entry->c.text.write = snd_emu_proc_ptr_reg_write20; 611 entry->mode |= S_IWUSR; 612 } 613 if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) { 614 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c); 615 entry->c.text.write = snd_emu_proc_ptr_reg_write20; 616 entry->mode |= S_IWUSR; 617 } 557 snd_card_ro_proc_new(emu->card, "emu1010_regs", 558 emu, snd_emu_proc_emu1010_reg_read); 559 } 560 snd_card_rw_proc_new(emu->card, "io_regs", emu, 561 snd_emu_proc_io_reg_read, 562 snd_emu_proc_io_reg_write); 563 snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu, 564 snd_emu_proc_ptr_reg_read00a, 565 snd_emu_proc_ptr_reg_write00); 566 snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu, 567 snd_emu_proc_ptr_reg_read00b, 568 snd_emu_proc_ptr_reg_write00); 569 snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu, 570 snd_emu_proc_ptr_reg_read20a, 571 snd_emu_proc_ptr_reg_write20); 572 snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu, 573 snd_emu_proc_ptr_reg_read20b, 574 snd_emu_proc_ptr_reg_write20); 575 snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu, 576 snd_emu_proc_ptr_reg_read20c, 577 snd_emu_proc_ptr_reg_write20); 618 578 #endif 619 579 620 if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) 621 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read); 622 623 if (emu->card_capabilities->emu10k2_chip) { 624 if (! snd_card_proc_new(emu->card, "spdif-in", &entry)) 625 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read); 626 } 627 if (emu->card_capabilities->ca0151_chip) { 628 if (! snd_card_proc_new(emu->card, "capture-rates", &entry)) 629 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read); 630 } 631 632 if (! snd_card_proc_new(emu->card, "voices", &entry)) 633 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read); 580 snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read); 581 582 if (emu->card_capabilities->emu10k2_chip) 583 snd_card_ro_proc_new(emu->card, "spdif-in", emu, 584 snd_emu10k1_proc_spdif_read); 585 if (emu->card_capabilities->ca0151_chip) 586 snd_card_ro_proc_new(emu->card, "capture-rates", emu, 587 snd_emu10k1_proc_rates_read); 588 589 snd_card_ro_proc_new(emu->card, "voices", emu, 590 snd_emu10k1_proc_voices_read); 634 591 635 592 if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) { 636 593 entry->content = SNDRV_INFO_CONTENT_DATA; 637 594 entry->private_data = emu; 638 entry->mode = S_IFREG | S_IRUGO/*| S_IWUSR*/;595 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 639 596 entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR; 640 597 entry->c.ops = &snd_emu10k1_proc_ops_fx8010; … … 643 600 entry->content = SNDRV_INFO_CONTENT_DATA; 644 601 entry->private_data = emu; 645 entry->mode = S_IFREG | S_IRUGO/*| S_IWUSR*/;602 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 646 603 entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ; 647 604 entry->c.ops = &snd_emu10k1_proc_ops_fx8010; … … 650 607 entry->content = SNDRV_INFO_CONTENT_DATA; 651 608 entry->private_data = emu; 652 entry->mode = S_IFREG | S_IRUGO/*| S_IWUSR*/;609 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 653 610 entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ; 654 611 entry->c.ops = &snd_emu10k1_proc_ops_fx8010; … … 657 614 entry->content = SNDRV_INFO_CONTENT_DATA; 658 615 entry->private_data = emu; 659 entry->mode = S_IFREG | S_IRUGO/*| S_IWUSR*/;616 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 660 617 entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE; 661 618 entry->c.ops = &snd_emu10k1_proc_ops_fx8010; 662 619 } 663 if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) { 664 entry->content = SNDRV_INFO_CONTENT_TEXT; 665 entry->private_data = emu; 666 entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/; 667 entry->c.text.read = snd_emu10k1_proc_acode_read; 668 } 620 snd_card_ro_proc_new(emu->card, "fx8010_acode", emu, 621 snd_emu10k1_proc_acode_read); 669 622 return 0; 670 623 } 671 #endif /* CONFIG_PROC_FS */ -
GPL/trunk/alsa-kernel/pci/emu10k1/io.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 9 10 * TODO: 10 11 * -- 11 *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 12 */ 27 13 … … 30 16 #include <sound/emu10k1.h> 31 17 #include <linux/delay.h> 18 #include <linux/export.h> 32 19 #include "p17v.h" 33 20 … … 71 58 unsigned int mask; 72 59 73 if (!emu) { 74 snd_printk(KERN_ERR "ptr_write: emu is null!\n"); 75 dump_stack(); 60 if (snd_BUG_ON(!emu)) 76 61 return; 77 }78 62 mask = emu->audigy ? A_PTR_ADDRESS_MASK : PTR_ADDRESS_MASK; 79 63 regptr = ((reg << 16) & mask) | (chn & PTR_CHANNELNUM_MASK); … … 102 86 EXPORT_SYMBOL(snd_emu10k1_ptr_write); 103 87 104 unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, 105 unsigned int reg, 88 unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, 89 unsigned int reg, 106 90 unsigned int chn) 107 91 { 108 92 unsigned long flags; 109 93 unsigned int regptr, val; 110 94 111 95 regptr = (reg << 16) | chn; 112 96 … … 118 102 } 119 103 120 void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, 121 unsigned int reg, 122 unsigned int chn, 104 void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, 105 unsigned int reg, 106 unsigned int chn, 123 107 unsigned int data) 124 108 { … … 199 183 200 184 if ((reg > 0x7f) || (value > 0x1ff)) { 201 snd_printk(KERN_ERR"i2c_write: invalid values.\n");185 dev_err(emu->card->dev, "i2c_write: invalid values.\n"); 202 186 return -EINVAL; 203 187 } … … 227 211 228 212 if (timeout > 1000) { 229 snd_printk(KERN_WARNING 213 dev_warn(emu->card->dev, 230 214 "emu10k1:I2C:timeout status=0x%x\n", 231 215 status); … … 239 223 240 224 if (retry == 10) { 241 snd_printk(KERN_ERR"Writing to ADC failed!\n");242 snd_printk(KERN_ERR"status=0x%x, reg=%d, value=%d\n",225 dev_err(emu->card->dev, "Writing to ADC failed!\n"); 226 dev_err(emu->card->dev, "status=0x%x, reg=%d, value=%d\n", 243 227 status, reg, value); 244 228 /* dump_stack(); */ 245 229 err = -EINVAL; 246 230 } 247 231 248 232 spin_unlock(&emu->i2c_lock); 249 233 return err; … … 527 511 unsigned int snd_emu10k1_rate_to_pitch(unsigned int rate) 528 512 { 529 static u32 logMagTable[128] = {513 static const u32 logMagTable[128] = { 530 514 0x00000, 0x02dfc, 0x05b9e, 0x088e6, 0x0b5d6, 0x0e26f, 0x10eb3, 0x13aa2, 531 515 0x1663f, 0x1918a, 0x1bc84, 0x1e72e, 0x2118b, 0x23b9a, 0x2655d, 0x28ed5, … … 545 529 0xf4463, 0xf5c2a, 0xf73da, 0xf8b71, 0xfa2f0, 0xfba57, 0xfd1a7, 0xfe8df 546 530 }; 547 static c har logSlopeTable[128] = {531 static const char logSlopeTable[128] = { 548 532 0x5c, 0x5c, 0x5b, 0x5a, 0x5a, 0x59, 0x58, 0x58, 549 533 0x57, 0x56, 0x56, 0x55, 0x55, 0x54, 0x53, 0x53, -
GPL/trunk/alsa-kernel/pci/emu10k1/irq.c
r305 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 9 10 * TODO: 10 11 * -- 11 *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 12 */ 27 13 … … 42 28 handled = 1; 43 29 if ((status & 0xffffffff) == 0xffffffff) { 44 snd_printk(KERN_INFO "snd-emu10k1: Suspected sound card removal\n"); 30 dev_info(emu->card->dev, 31 "Suspected sound card removal\n"); 45 32 break; 46 33 } 47 34 if (status & IPR_PCIERROR) { 48 snd_printk(KERN_ERR"interrupt: PCI error\n");35 dev_err(emu->card->dev, "interrupt: PCI error\n"); 49 36 snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE); 50 37 status &= ~IPR_PCIERROR; … … 158 145 struct snd_emu10k1_voice *cvoice = &(emu->p16v_capture_voice); 159 146 160 / /printk(KERN_INFO "status2=0x%x\n", status2);147 /* dev_dbg(emu->card->dev, "status2=0x%x\n", status2); */ 161 148 orig_status2 = status2; 162 149 if(status2 & mask) { … … 164 151 snd_pcm_period_elapsed(pvoice->epcm->substream); 165 152 } else { 166 snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use); 153 dev_err(emu->card->dev, 154 "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", 155 status2, mask, pvoice, 156 pvoice->use); 167 157 } 168 158 } 169 159 if(status2 & 0x110000) { 170 / /printk(KERN_INFO "capture int found\n");160 /* dev_info(emu->card->dev, "capture int found\n"); */ 171 161 if(cvoice->use) { 172 / /printk(KERN_INFO "capture period_elapsed\n");162 /* dev_info(emu->card->dev, "capture period_elapsed\n"); */ 173 163 snd_pcm_period_elapsed(cvoice->epcm->substream); 174 164 } … … 181 171 if (status) { 182 172 unsigned int bits; 183 snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status); 173 dev_err(emu->card->dev, 174 "unhandled interrupt: 0x%08x\n", status); 184 175 //make sure any interrupts we don't handle are disabled: 185 176 bits = INTE_FXDSPENABLE | … … 203 194 } 204 195 if (timeout == 1000) 205 snd_printk(KERN_INFO"emu10k1 irq routine failure\n");196 dev_info(emu->card->dev, "emu10k1 irq routine failure\n"); 206 197 207 198 return IRQ_RETVAL(handled); -
GPL/trunk/alsa-kernel/pci/emu10k1/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> … … 4 5 * 5 6 * EMU10K1 memory page allocation (PTB area) 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 … … 26 11 #include <linux/time.h> 27 12 #include <linux/mutex.h> 13 #include <linux/export.h> 28 14 29 15 #include <sound/core.h> … … 34 20 */ 35 21 #define __set_ptb_entry(emu,page,addr) \ 36 (((u32 *)(emu)->ptb_pages.area)[page] = cpu_to_le32(((addr) << 1) | (page))) 22 (((__le32 *)(emu)->ptb_pages.area)[page] = \ 23 cpu_to_le32(((addr) << (emu->address_mode)) | (page))) 24 #define __get_ptb_entry(emu, page) \ 25 (le32_to_cpu(((__le32 *)(emu)->ptb_pages.area)[page])) 37 26 38 27 #define UNIT_PAGES (PAGE_SIZE / EMUPAGESIZE) 39 #define MAX_ALIGN_PAGES (MAXPAGES / UNIT_PAGES) 28 #define MAX_ALIGN_PAGES0 (MAXPAGES0 / UNIT_PAGES) 29 #define MAX_ALIGN_PAGES1 (MAXPAGES1 / UNIT_PAGES) 40 30 /* get aligned page from offset address */ 41 31 #define get_aligned_page(offset) ((offset) >> PAGE_SHIFT) … … 43 33 #define aligned_page_offset(page) ((page) << PAGE_SHIFT) 44 34 45 #if PAGE_SIZE == 4096 46 /* page size == EMUPAGESIZE */ 35 #if PAGE_SIZE == EMUPAGESIZE && !IS_ENABLED(CONFIG_DYNAMIC_DEBUG) 47 36 /* fill PTB entrie(s) corresponding to page with addr */ 48 37 #define set_ptb_entry(emu,page,addr) __set_ptb_entry(emu,page,addr) … … 57 46 for (i = 0; i < UNIT_PAGES; i++, page++) { 58 47 __set_ptb_entry(emu, page, addr); 48 dev_dbg(emu->card->dev, "mapped page %d to entry %.8x\n", page, 49 (unsigned int)__get_ptb_entry(emu, page)); 59 50 addr += EMUPAGESIZE; 60 51 } … … 64 55 int i; 65 56 page *= UNIT_PAGES; 66 for (i = 0; i < UNIT_PAGES; i++, page++) 57 for (i = 0; i < UNIT_PAGES; i++, page++) { 67 58 /* do not increment ptr */ 68 59 __set_ptb_entry(emu, page, emu->silent_page.addr); 60 dev_dbg(emu->card->dev, "mapped silent page %d to entry %.8x\n", 61 page, (unsigned int)__get_ptb_entry(emu, page)); 62 } 69 63 } 70 64 #endif /* PAGE_SIZE */ … … 101 95 static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct list_head **nextp) 102 96 { 103 int page = 0, found_page = -ENOMEM;97 int page = 1, found_page = -ENOMEM; 104 98 int max_size = npages; 105 99 int size; … … 124 118 page = blk->mapped_page + blk->pages; 125 119 } 126 size = MAX_ALIGN_PAGES- page;120 size = (emu->address_mode ? MAX_ALIGN_PAGES1 : MAX_ALIGN_PAGES0) - page; 127 121 if (size >= max_size) { 128 122 *nextp = pos; … … 146 140 if (page < 0) /* not found */ 147 141 return page; 142 if (page == 0) { 143 dev_err(emu->card->dev, "trying to map zero (reserved) page\n"); 144 return -EINVAL; 145 } 148 146 /* insert this block in the proper position of mapped list */ 149 147 list_add_tail(&blk->mapped_link, next); … … 176 174 start_page = q->mapped_page + q->pages; 177 175 } else 178 start_page = 0;176 start_page = 1; 179 177 if ((p = blk->mapped_link.next) != &emu->mapped_link_head) { 180 178 q = get_emu10k1_memblk(p, mapped_link); 181 179 end_page = q->mapped_page; 182 180 } else 183 end_page = MAX_ALIGN_PAGES;181 end_page = (emu->address_mode ? MAX_ALIGN_PAGES1 : MAX_ALIGN_PAGES0); 184 182 185 183 /* remove links */ … … 236 234 { 237 235 if (addr & ~emu->dma_mask) { 238 snd_printk(KERN_ERR "max memory size is 0x%lx (addr = 0x%lx)!!\n", emu->dma_mask, (unsigned long)addr); 236 dev_err_ratelimited(emu->card->dev, 237 "max memory size is 0x%lx (addr = 0x%lx)!!\n", 238 emu->dma_mask, (unsigned long)addr); 239 239 return 0; 240 240 } 241 241 if (addr & (EMUPAGESIZE-1)) { 242 snd_printk(KERN_ERR"page is not aligned\n");242 dev_err_ratelimited(emu->card->dev, "page is not aligned\n"); 243 243 return 0; 244 244 } … … 249 249 * map the given memory block on PTB. 250 250 * if the block is already mapped, update the link order. 251 * if no empty pages are found, tries to release un sed memory blocks251 * if no empty pages are found, tries to release unused memory blocks 252 252 * and retry the mapping. 253 253 */ … … 263 263 if (blk->mapped_page >= 0) { 264 264 /* update order link */ 265 list_ del(&blk->mapped_order_link);266 list_add_tail(&blk->mapped_order_link,&emu->mapped_order_link_head);265 list_move_tail(&blk->mapped_order_link, 266 &emu->mapped_order_link_head); 267 267 spin_unlock_irqrestore(&emu->memblk_lock, flags); 268 268 return 0; … … 305 305 return NULL; 306 306 if (snd_BUG_ON(runtime->dma_bytes == 0 || /* DAZ was unsigned <= 0 */ 307 runtime->dma_bytes >= MAXPAGES* EMUPAGESIZE))307 runtime->dma_bytes >= (emu->address_mode ? MAXPAGES1 : MAXPAGES0) * EMUPAGESIZE)) 308 308 return NULL; 309 309 hdr = emu->memhdr; … … 326 326 unsigned long ofs = idx << PAGE_SHIFT; 327 327 dma_addr_t addr; 328 addr = snd_pcm_sgbuf_get_addr(substream, ofs); 328 if (ofs >= runtime->dma_bytes) 329 addr = emu->silent_page.addr; 330 else 331 addr = snd_pcm_sgbuf_get_addr(substream, ofs); 329 332 if (! is_valid_page(emu, addr)) { 330 printk(KERN_ERR "emu: failure page = %d\n", idx); 333 dev_err_ratelimited(emu->card->dev, 334 "emu: failure page = %d\n", idx); 331 335 mutex_unlock(&hdr->block_mutex); 332 336 return NULL; … … 359 363 } 360 364 365 /* 366 * allocate DMA pages, widening the allocation if necessary 367 * 368 * See the comment above snd_emu10k1_detect_iommu() in emu10k1_main.c why 369 * this might be needed. 370 * 371 * If you modify this function check whether __synth_free_pages() also needs 372 * changes. 373 */ 374 int snd_emu10k1_alloc_pages_maybe_wider(struct snd_emu10k1 *emu, size_t size, 375 struct snd_dma_buffer *dmab) 376 { 377 if (emu->iommu_workaround) { 378 size_t npages = (size + PAGE_SIZE - 1) / PAGE_SIZE; 379 size_t size_real = npages * PAGE_SIZE; 380 381 /* 382 * The device has been observed to accesses up to 256 extra 383 * bytes, but use 1k to be safe. 384 */ 385 if (size_real < size + 1024) 386 size += PAGE_SIZE; 387 } 388 389 return snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 390 &emu->pci->dev, size, dmab); 391 } 361 392 362 393 /* … … 443 474 int last_page) 444 475 { 476 struct snd_dma_buffer dmab; 445 477 int page; 446 478 479 dmab.dev.type = SNDRV_DMA_TYPE_DEV; 480 dmab.dev.dev = &emu->pci->dev; 481 447 482 for (page = first_page; page <= last_page; page++) { 448 free_page((unsigned long)emu->page_ptr_table[page]); 483 if (emu->page_ptr_table[page] == NULL) 484 continue; 485 dmab.area = emu->page_ptr_table[page]; 486 dmab.addr = emu->page_addr_table[page]; 487 488 /* 489 * please keep me in sync with logic in 490 * snd_emu10k1_alloc_pages_maybe_wider() 491 */ 492 dmab.bytes = PAGE_SIZE; 493 if (emu->iommu_workaround) 494 dmab.bytes *= 2; 495 496 snd_dma_free_pages(&dmab); 449 497 emu->page_addr_table[page] = 0; 450 498 emu->page_ptr_table[page] = NULL; … … 459 507 #ifndef TARGET_OS2 460 508 int page, first_page, last_page; 509 struct snd_dma_buffer dmab; 461 510 462 511 emu10k1_memblk_init(blk); … … 464 513 /* allocate kernel pages */ 465 514 for (page = first_page; page <= last_page; page++) { 466 /* first try to allocate from <4GB zone */ 467 struct page *p = alloc_page(GFP_KERNEL | GFP_DMA32 | 468 __GFP_NOWARN); 469 if (!p || (page_to_pfn(p) & ~(emu->dma_mask >> PAGE_SHIFT))) { 470 if (p) 471 __free_page(p); 472 /* try to allocate from <16MB zone */ 473 p = alloc_page(GFP_ATOMIC | GFP_DMA | 474 __GFP_NORETRY | /* no OOM-killer */ 475 __GFP_NOWARN); 515 if (snd_emu10k1_alloc_pages_maybe_wider(emu, PAGE_SIZE, 516 &dmab) < 0) 517 goto __fail; 518 if (!is_valid_page(emu, dmab.addr)) { 519 snd_dma_free_pages(&dmab); 520 goto __fail; 476 521 } 477 if (!p) { 478 __synth_free_pages(emu, first_page, page - 1); 479 return -ENOMEM; 480 } 481 emu->page_addr_table[page] = page_to_phys(p); 482 emu->page_ptr_table[page] = page_address(p); 522 emu->page_addr_table[page] = dmab.addr; 523 emu->page_ptr_table[page] = dmab.area; 483 524 } 484 525 return 0; 526 527 __fail: 528 /* release allocated pages */ 529 last_page = page - 1; 530 __synth_free_pages(emu, first_page, last_page); 531 532 return -ENOMEM; 485 533 #else 534 #define snd_dma_pci_data(pci) (&(pci)->dev) 486 535 int page, first_page, last_page; 487 536 struct snd_dma_buffer dmab; … … 539 588 ptr = emu->page_ptr_table[page]; 540 589 if (! ptr) { 541 printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page); 590 dev_err(emu->card->dev, 591 "access to NULL ptr: page = %d\n", page); 542 592 return NULL; 543 593 } -
GPL/trunk/alsa-kernel/pci/emu10k1/p16v.c
r464 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> … … 70 71 * DAC: CS4382-K (8-channel, 24bit, 192Khz) 71 72 * 72 * This code was init ally based on code from ALSA's emu10k1x.c which is: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 modify76 * it under the terms of the GNU General Public License as published by77 * the Free Software Foundation; either version 2 of the License, or78 * (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 of82 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the83 * GNU General Public License for more details.84 *85 * You should have received a copy of the GNU General Public License86 * along with this program; if not, write to the Free Software87 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA88 *89 75 */ 90 76 #include <linux/delay.h> … … 123 109 124 110 /* hardware definition */ 125 static struct snd_pcm_hardware snd_p16v_playback_hw = {111 static const struct snd_pcm_hardware snd_p16v_playback_hw = { 126 112 .info = SNDRV_PCM_INFO_MMAP | 127 113 SNDRV_PCM_INFO_INTERLEAVED | … … 144 130 }; 145 131 146 static struct snd_pcm_hardware snd_p16v_capture_hw = {132 static const struct snd_pcm_hardware snd_p16v_capture_hw = { 147 133 .info = (SNDRV_PCM_INFO_MMAP | 148 134 SNDRV_PCM_INFO_INTERLEAVED | … … 167 153 { 168 154 struct snd_emu10k1_pcm *epcm = runtime->private_data; 169 170 if (epcm) { 171 /* snd_printk(KERN_DEBUG "epcm free: %p\n", epcm); */ 172 kfree(epcm); 173 } 155 156 kfree(epcm); 174 157 } 175 158 … … 184 167 185 168 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 186 /* snd_printk(KERN_DEBUG"epcm kcalloc: %p\n", epcm); */169 /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */ 187 170 188 171 if (epcm == NULL) … … 191 174 epcm->substream = substream; 192 175 /* 193 snd_printk(KERN_DEBUG"epcm device=%d, channel_id=%d\n",176 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n", 194 177 substream->pcm->device, channel_id); 195 178 */ … … 204 187 channel->use=1; 205 188 #if 0 /* debug */ 206 snd_printk(KERN_DEBUG189 dev_dbg(emu->card->dev, 207 190 "p16v: open channel_id=%d, channel=%p, use=0x%x\n", 208 191 channel_id, channel, channel->use); 209 printk(KERN_DEBUG"open:channel_id=%d, chip=%p, channel=%p\n",192 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", 210 193 channel_id, chip, channel); 211 194 #endif /* debug */ … … 232 215 233 216 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 234 /* snd_printk(KERN_DEBUG"epcm kcalloc: %p\n", epcm); */217 /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */ 235 218 236 219 if (epcm == NULL) … … 239 222 epcm->substream = substream; 240 223 /* 241 snd_printk(KERN_DEBUG"epcm device=%d, channel_id=%d\n",224 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n", 242 225 substream->pcm->device, channel_id); 243 226 */ … … 252 235 channel->use=1; 253 236 #if 0 /* debug */ 254 snd_printk(KERN_DEBUG237 dev_dbg(emu->card->dev, 255 238 "p16v: open channel_id=%d, channel=%p, use=0x%x\n", 256 239 channel_id, channel, channel->use); 257 printk(KERN_DEBUG"open:channel_id=%d, chip=%p, channel=%p\n",240 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", 258 241 channel_id, chip, channel); 259 242 #endif /* debug */ … … 299 282 return snd_p16v_pcm_open_capture_channel(substream, 0); 300 283 } 301 302 /* hw_params callback */303 static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream,304 struct snd_pcm_hw_params *hw_params)305 {306 int result;307 result = snd_pcm_lib_malloc_pages(substream,308 params_buffer_bytes(hw_params));309 return result;310 }311 312 /* hw_params callback */313 static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream,314 struct snd_pcm_hw_params *hw_params)315 {316 int result;317 result = snd_pcm_lib_malloc_pages(substream,318 params_buffer_bytes(hw_params));319 return result;320 }321 322 323 /* hw_free callback */324 static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream)325 {326 int result;327 result = snd_pcm_lib_free_pages(substream);328 return result;329 }330 331 /* hw_free callback */332 static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream)333 {334 int result;335 result = snd_pcm_lib_free_pages(substream);336 return result;337 }338 339 284 340 285 /* prepare playback callback */ … … 350 295 351 296 #if 0 /* debug */ 352 snd_printk(KERN_DEBUG "prepare:channel_number=%d, rate=%d, " 297 dev_dbg(emu->card->dev, 298 "prepare:channel_number=%d, rate=%d, " 353 299 "format=0x%x, channels=%d, buffer_size=%ld, " 354 300 "period_size=%ld, periods=%u, frames_to_bytes=%d\n", … … 356 302 runtime->buffer_size, runtime->period_size, 357 303 runtime->periods, frames_to_bytes(runtime, 1)); 358 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n", 304 dev_dbg(emu->card->dev, 305 "dma_addr=%x, dma_area=%p, table_base=%p\n", 359 306 runtime->dma_addr, runtime->dma_area, table_base); 360 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 307 dev_dbg(emu->card->dev, 308 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 361 309 emu->p16v_buffer.addr, emu->p16v_buffer.area, 362 310 emu->p16v_buffer.bytes); … … 406 354 407 355 /* 408 printk(KERN_DEBUG"prepare capture:channel_number=%d, rate=%d, "356 dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, " 409 357 "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, " 410 358 "frames_to_bytes=%d\n", … … 492 440 epcm = runtime->private_data; 493 441 channel = substream->pcm->device-emu->p16v_device_offset; 494 /* snd_printk(KERN_DEBUG"p16v channel=%d\n", channel); */442 /* dev_dbg(emu->card->dev, "p16v channel=%d\n", channel); */ 495 443 epcm->running = running; 496 444 basic |= (0x1<<channel); … … 498 446 snd_pcm_trigger_done(s, substream); 499 447 } 500 /* snd_printk(KERN_DEBUG"basic=0x%x, inte=0x%x\n", basic, inte); */448 /* dev_dbg(emu->card->dev, "basic=0x%x, inte=0x%x\n", basic, inte); */ 501 449 502 450 switch (cmd) { … … 589 537 if (ptr >= runtime->buffer_size) { 590 538 ptr -= runtime->buffer_size; 591 printk(KERN_WARNING"buffer capture limited!\n");539 dev_warn(emu->card->dev, "buffer capture limited!\n"); 592 540 } 593 541 /* 594 printk(KERN_DEBUG"ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "542 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " 595 543 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", 596 544 ptr1, ptr2, ptr, (int)runtime->buffer_size, … … 602 550 603 551 /* operators */ 604 static struct snd_pcm_ops snd_p16v_playback_front_ops = {552 static const struct snd_pcm_ops snd_p16v_playback_front_ops = { 605 553 .open = snd_p16v_pcm_open_playback_front, 606 554 .close = snd_p16v_pcm_close_playback, 607 .ioctl = snd_pcm_lib_ioctl,608 .hw_params = snd_p16v_pcm_hw_params_playback,609 .hw_free = snd_p16v_pcm_hw_free_playback,610 555 .prepare = snd_p16v_pcm_prepare_playback, 611 556 .trigger = snd_p16v_pcm_trigger_playback, … … 613 558 }; 614 559 615 static struct snd_pcm_ops snd_p16v_capture_ops = {560 static const struct snd_pcm_ops snd_p16v_capture_ops = { 616 561 .open = snd_p16v_pcm_open_capture, 617 562 .close = snd_p16v_pcm_close_capture, 618 .ioctl = snd_pcm_lib_ioctl,619 .hw_params = snd_p16v_pcm_hw_params_capture,620 .hw_free = snd_p16v_pcm_hw_free_capture,621 563 .prepare = snd_p16v_pcm_prepare_capture, 622 564 .trigger = snd_p16v_pcm_trigger_capture, … … 631 573 snd_dma_free_pages(&chip->p16v_buffer); 632 574 /* 633 snd_printk(KERN_DEBUG"period lables free: %p\n",575 dev_dbg(chip->card->dev, "period lables free: %p\n", 634 576 &chip->p16v_buffer); 635 577 */ … … 638 580 } 639 581 640 int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)582 int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) 641 583 { 642 584 struct snd_pcm *pcm; … … 645 587 int capture=1; 646 588 647 /* snd_printk(KERN_DEBUG"snd_p16v_pcm called. device=%d\n", device); */589 /* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */ 648 590 emu->p16v_device_offset = device; 649 if (rpcm)650 *rpcm = NULL;651 591 652 592 if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0) … … 667 607 substream; 668 608 substream = substream->next) { 669 if ((err = snd_pcm_lib_preallocate_pages(substream, 670 SNDRV_DMA_TYPE_DEV, 671 snd_dma_pci_data(emu->pci), 672 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 673 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); 674 613 /* 675 snd_printk(KERN_DEBUG614 dev_dbg(emu->card->dev, 676 615 "preallocate playback substream: err=%d\n", err); 677 616 */ … … 681 620 substream; 682 621 substream = substream->next) { 683 if ((err = snd_pcm_lib_preallocate_pages(substream, 684 SNDRV_DMA_TYPE_DEV, 685 snd_dma_pci_data(emu->pci), 686 65536 - 64, 65536 - 64)) < 0) 687 return err; 622 snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, 623 &emu->pci->dev, 624 65536 - 64, 65536 - 64); 688 625 /* 689 snd_printk(KERN_DEBUG626 dev_dbg(emu->card->dev, 690 627 "preallocate capture substream: err=%d\n", err); 691 628 */ 692 629 } 693 694 if (rpcm)695 *rpcm = pcm;696 630 697 631 return 0; … … 755 689 struct snd_ctl_elem_info *uinfo) 756 690 { 757 static c har *texts[8] = {691 static const char * const texts[8] = { 758 692 "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", 759 693 "CDIF", "FX", "AC97" 760 694 }; 761 695 762 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 763 uinfo->count = 1; 764 uinfo->value.enumerated.items = 8; 765 if (uinfo->value.enumerated.item > 7) 766 uinfo->value.enumerated.item = 7; 767 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 768 return 0; 696 return snd_ctl_enum_info(uinfo, 1, 8, texts); 769 697 } 770 698 … … 803 731 struct snd_ctl_elem_info *uinfo) 804 732 { 805 static char *texts[4] = { "0", "1", "2", "3", }; 806 807 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 808 uinfo->count = 1; 809 uinfo->value.enumerated.items = 4; 810 if (uinfo->value.enumerated.item > 3) 811 uinfo->value.enumerated.item = 3; 812 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 813 return 0; 733 static const char * const texts[4] = { "0", "1", "2", "3", }; 734 735 return snd_ctl_enum_info(uinfo, 1, 4, texts); 814 736 } 815 737 … … 855 777 } 856 778 857 static struct snd_kcontrol_new p16v_mixer_controls[] __devinitdata= {779 static const struct snd_kcontrol_new p16v_mixer_controls[] = { 858 780 P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), 859 781 P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), … … 881 803 882 804 883 int __devinitsnd_p16v_mixer(struct snd_emu10k1 *emu)805 int snd_p16v_mixer(struct snd_emu10k1 *emu) 884 806 { 885 807 int i, err; … … 894 816 } 895 817 896 #ifdef CONFIG_PM 818 #ifdef CONFIG_PM_SLEEP 897 819 898 820 #define NUM_CHS 1 /* up to 4, but only first channel is used */ 899 821 900 int __devinit snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) 901 { 822 int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) 823 { 824 #ifdef TARGET_OS2 825 emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80)); 826 #else 902 827 emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); 828 #endif 903 829 if (! emu->p16v_saved) 904 830 return -ENOMEM; -
GPL/trunk/alsa-kernel/pci/emu10k1/p16v.h
r598 r679 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 1 2 /* 2 3 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> … … 41 42 * Split from p16v.c 42 43 * 43 *44 44 * BUGS: 45 45 * Some stability problems when unloading the snd-p16v kernel module. … … 60 60 * DAC: CS4382-K (8-channel, 24bit, 192Khz) 61 61 * 62 * This code was init ally based on code from ALSA's emu10k1x.c which is:62 * This code was initially based on code from ALSA's emu10k1x.c which is: 63 63 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> 64 *65 * This program is free software; you can redistribute it and/or modify66 * it under the terms of the GNU General Public License as published by67 * the Free Software Foundation; either version 2 of the License, or68 * (at your option) any later version.69 *70 * This program is distributed in the hope that it will be useful,71 * but WITHOUT ANY WARRANTY; without even the implied warranty of72 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the73 * GNU General Public License for more details.74 *75 * You should have received a copy of the GNU General Public License76 * along with this program; if not, write to the Free Software77 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA78 *79 64 */ 80 65 … … 87 72 */ 88 73 89 /* Init ally all registers from 0x00 to 0x3f have zero contents. */74 /* Initially all registers from 0x00 to 0x3f have zero contents. */ 90 75 #define PLAYBACK_LIST_ADDR 0x00 /* Base DMA address of a list of pointers to each period/size */ 91 76 /* One list entry: 4 bytes for DMA address, -
GPL/trunk/alsa-kernel/pci/emu10k1/p17v.h
r305 r679 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 p17v chips 4 5 * Version: 0.01 5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 *20 6 */ 21 7 -
GPL/trunk/alsa-kernel/pci/emu10k1/timer.c
r305 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Lee Revell <rlrevell@joe-job.com> … … 9 10 * TODO: 10 11 * -- 11 *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 12 */ 27 13 … … 67 53 } 68 54 69 static struct snd_timer_hardware snd_emu10k1_timer_hw = {55 static const struct snd_timer_hardware snd_emu10k1_timer_hw = { 70 56 .flags = SNDRV_TIMER_HW_AUTO, 71 57 .resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */ … … 76 62 }; 77 63 78 int __devinitsnd_emu10k1_timer(struct snd_emu10k1 *emu, int device)64 int snd_emu10k1_timer(struct snd_emu10k1 *emu, int device) 79 65 { 80 66 struct snd_timer *timer = NULL; -
GPL/trunk/alsa-kernel/pci/emu10k1/tina2.h
r111 r679 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 tina2 chips 4 5 * Version: 0.1 5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 *20 6 */ 21 7 -
GPL/trunk/alsa-kernel/pci/emu10k1/voice.c
r426 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> … … 12 13 * TODO: 13 14 * -- 14 *15 * This program is free software; you can redistribute it and/or modify16 * it under the terms of the GNU General Public License as published by17 * the Free Software Foundation; either version 2 of the License, or18 * (at your option) any later version.19 *20 * This program is distributed in the hope that it will be useful,21 * but WITHOUT ANY WARRANTY; without even the implied warranty of22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the23 * GNU General Public License for more details.24 *25 * You should have received a copy of the GNU General Public License26 * along with this program; if not, write to the Free Software27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA28 *29 15 */ 30 16 31 17 #include <linux/time.h> 18 #include <linux/export.h> 32 19 #include <sound/core.h> 33 20 #include <sound/emu10k1.h> … … 55 42 for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) { 56 43 /* 57 printk(KERN_DEBUG"i %d j %d next free %d!\n",44 dev_dbg(emu->card->dev, "i %d j %d next free %d!\n", 58 45 i, j, emu->next_free_voice); 59 46 */ … … 75 62 } 76 63 if (!skip) { 77 /* printk(KERN_DEBUG"allocated voice %d\n", i); */64 /* dev_dbg(emu->card->dev, "allocated voice %d\n", i); */ 78 65 first_voice = i; 79 66 last_voice = (i + number) % NUM_G; … … 89 76 voice = &emu->voices[(first_voice + i) % NUM_G]; 90 77 /* 91 printk(kERN_DEBUG"voice alloc - %i, %i of %i\n",78 dev_dbg(emu->card->dev, "voice alloc - %i, %i of %i\n", 92 79 voice->number, idx-first_voice+1, number); 93 80 */
Note:
See TracChangeset
for help on using the changeset viewer.
