Changeset 679 for GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
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 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);
Note:
See TracChangeset
for help on using the changeset viewer.