Changeset 615 for GPL/branches/uniaud32-next/alsa-kernel/pci/sonicvibes.c
- Timestamp:
- Jan 1, 2021, 5:31:48 AM (5 years ago)
- Location:
- GPL/branches/uniaud32-next
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/alsa-kernel/pci/sonicvibes.c
r612 r615 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for S3 SonicVibes soundcard … … 6 7 * It looks like 86c617 rev 3 doesn't supports DDMA buffers above 16MB? 7 8 * Driver sometimes hangs... Nobody knows why at this moment... 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 9 */ 24 10 … … 31 17 #include <linux/module.h> 32 18 #include <linux/dma-mapping.h> 19 #include <linux/io.h> 33 20 34 21 #include <sound/core.h> … … 40 27 #include <sound/initval.h> 41 28 42 #include <asm/io.h>43 44 29 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 45 30 MODULE_DESCRIPTION("S3 SonicVibes PCI"); … … 47 32 MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}"); 48 33 49 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))34 #if IS_REACHABLE(CONFIG_GAMEPORT) 50 35 #define SUPPORT_JOYSTICK 1 51 36 #endif … … 53 38 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 54 39 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 55 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */56 static intreverb[SNDRV_CARDS];57 static intmge[SNDRV_CARDS];40 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 41 static bool reverb[SNDRV_CARDS]; 42 static bool mge[SNDRV_CARDS]; 58 43 static unsigned int dmaio = 0x7a00; /* DDMA i/o address */ 59 44 … … 68 53 module_param_array(mge, bool, NULL, 0444); 69 54 MODULE_PARM_DESC(mge, "MIC Gain Enable for S3 SonicVibes soundcard."); 70 module_param (dmaio, uint, 0444);55 module_param_hw(dmaio, uint, ioport, 0444); 71 56 MODULE_PARM_DESC(dmaio, "DDMA i/o base address for S3 SonicVibes soundcard."); 72 57 … … 243 228 }; 244 229 245 static DEFINE_PCI_DEVICE_TABLE(snd_sonic_ids)= {230 static const struct pci_device_id snd_sonic_ids[] = { 246 231 { PCI_VDEVICE(S3, 0xca00), 0, }, 247 232 { 0, } … … 250 235 MODULE_DEVICE_TABLE(pci, snd_sonic_ids); 251 236 252 static struct snd_ratden sonicvibes_adc_clock = {237 static const struct snd_ratden sonicvibes_adc_clock = { 253 238 .num_min = 4000 * 65536, 254 239 .num_max = 48000UL * 65536, … … 256 241 .den = 65536, 257 242 }; 258 static struct snd_pcm_hw_constraint_ratdens snd_sonicvibes_hw_constraints_adc_clock = {243 static const struct snd_pcm_hw_constraint_ratdens snd_sonicvibes_hw_constraints_adc_clock = { 259 244 .nrats = 1, 260 245 .rats = &sonicvibes_adc_clock, … … 274 259 outb(0x18, sonic->dmaa_port + SV_DMA_MODE); 275 260 #if 0 276 printk(KERN_DEBUG"program dmaa: addr = 0x%x, paddr = 0x%x\n",261 dev_dbg(sonic->card->dev, "program dmaa: addr = 0x%x, paddr = 0x%x\n", 277 262 addr, inl(sonic->dmaa_port + SV_DMA_ADDR0)); 278 263 #endif … … 290 275 outb(0x14, sonic->dmac_port + SV_DMA_MODE); 291 276 #if 0 292 printk(KERN_DEBUG"program dmac: addr = 0x%x, paddr = 0x%x\n",277 dev_dbg(sonic->card->dev, "program dmac: addr = 0x%x, paddr = 0x%x\n", 293 278 addr, inl(sonic->dmac_port + SV_DMA_ADDR0)); 294 279 #endif … … 358 343 static void snd_sonicvibes_debug(struct sonicvibes * sonic) 359 344 { 360 printk(KERN_DEBUG361 "SV REGS: INDEX = 0x%02x ", inb(SV_REG(sonic, INDEX)));362 printk(" STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS)));363 printk(KERN_DEBUG364 " 0x00: left input = 0x%02x ", snd_sonicvibes_in(sonic, 0x00));365 printk(" 0x20: synth rate low = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20));366 printk(KERN_DEBUG367 " 0x01: right input = 0x%02x ", snd_sonicvibes_in(sonic, 0x01));368 printk(" 0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21));369 printk(KERN_DEBUG370 " 0x02: left AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x02));371 printk(" 0x22: ADC clock = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22));372 printk(KERN_DEBUG373 " 0x03: right AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x03));374 printk(" 0x23: ADC alt rate = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23));375 printk(KERN_DEBUG376 " 0x04: left CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x04));377 printk(" 0x24: ADC pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24));378 printk(KERN_DEBUG379 " 0x05: right CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x05));380 printk(" 0x25: ADC pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25));381 printk(KERN_DEBUG382 " 0x06: left line = 0x%02x ", snd_sonicvibes_in(sonic, 0x06));383 printk(" 0x26: Synth pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26));384 printk(KERN_DEBUG385 " 0x07: right line = 0x%02x ", snd_sonicvibes_in(sonic, 0x07));386 printk(" 0x27: Synth pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27));387 printk(KERN_DEBUG388 " 0x08: MIC = 0x%02x ", snd_sonicvibes_in(sonic, 0x08));389 printk(" 0x28: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28));390 printk(KERN_DEBUG391 " 0x09: Game port = 0x%02x ", snd_sonicvibes_in(sonic, 0x09));392 printk(" 0x29: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29));393 printk(KERN_DEBUG394 " 0x0a: left synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0a));395 printk(" 0x2a: MPU401 = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a));396 printk(KERN_DEBUG397 " 0x0b: right synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0b));398 printk(" 0x2b: drive ctrl = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b));399 printk(KERN_DEBUG400 " 0x0c: left AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0c));401 printk(" 0x2c: SRS space = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c));402 printk(KERN_DEBUG403 " 0x0d: right AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0d));404 printk(" 0x2d: SRS center = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d));405 printk(KERN_DEBUG406 " 0x0e: left analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0e));407 printk(" 0x2e: wave source = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e));408 printk(KERN_DEBUG409 " 0x0f: right analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0f));410 printk(" 0x2f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f));411 printk(KERN_DEBUG412 " 0x10: left PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x10));413 printk(" 0x30: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30));414 printk(KERN_DEBUG415 " 0x11: right PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x11));416 printk(" 0x31: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31));417 printk(KERN_DEBUG418 " 0x12: DMA data format = 0x%02x ", snd_sonicvibes_in(sonic, 0x12));419 printk(" 0x32: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32));420 printk(KERN_DEBUG421 " 0x13: P/C enable = 0x%02x ", snd_sonicvibes_in(sonic, 0x13));422 printk(" 0x33: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33));423 printk(KERN_DEBUG424 " 0x14: U/D button = 0x%02x ", snd_sonicvibes_in(sonic, 0x14));425 printk(" 0x34: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34));426 printk(KERN_DEBUG427 " 0x15: revision = 0x%02x ", snd_sonicvibes_in(sonic, 0x15));428 printk(" 0x35: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35));429 printk(KERN_DEBUG430 " 0x16: ADC output ctrl = 0x%02x ", snd_sonicvibes_in(sonic, 0x16));431 printk(" 0x36: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36));432 printk(KERN_DEBUG433 " 0x17: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x17));434 printk(" 0x37: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37));435 printk(KERN_DEBUG436 " 0x18: DMA A upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x18));437 printk(" 0x38: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38));438 printk(KERN_DEBUG439 " 0x19: DMA A lower cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x19));440 printk(" 0x39: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39));441 printk(KERN_DEBUG442 " 0x1a: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1a));443 printk(" 0x3a: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a));444 printk(KERN_DEBUG445 " 0x1b: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1b));446 printk(" 0x3b: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b));447 printk(KERN_DEBUG448 " 0x1c: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1c));449 printk(" 0x3c: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c));450 printk(KERN_DEBUG451 " 0x1d: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1d));452 printk(" 0x3d: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d));453 printk(KERN_DEBUG454 " 0x1e: PCM rate low = 0x%02x ", snd_sonicvibes_in(sonic, 0x1e));455 printk(" 0x3e: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e));456 printk(KERN_DEBUG457 " 0x1f: PCM rate high = 0x%02x ", snd_sonicvibes_in(sonic, 0x1f));458 printk(" 0x3f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f));345 dev_dbg(sonic->card->dev, 346 "SV REGS: INDEX = 0x%02x STATUS = 0x%02x\n", 347 inb(SV_REG(sonic, INDEX)), inb(SV_REG(sonic, STATUS))); 348 dev_dbg(sonic->card->dev, 349 " 0x00: left input = 0x%02x 0x20: synth rate low = 0x%02x\n", 350 snd_sonicvibes_in(sonic, 0x00), snd_sonicvibes_in(sonic, 0x20)); 351 dev_dbg(sonic->card->dev, 352 " 0x01: right input = 0x%02x 0x21: synth rate high = 0x%02x\n", 353 snd_sonicvibes_in(sonic, 0x01), snd_sonicvibes_in(sonic, 0x21)); 354 dev_dbg(sonic->card->dev, 355 " 0x02: left AUX1 = 0x%02x 0x22: ADC clock = 0x%02x\n", 356 snd_sonicvibes_in(sonic, 0x02), snd_sonicvibes_in(sonic, 0x22)); 357 dev_dbg(sonic->card->dev, 358 " 0x03: right AUX1 = 0x%02x 0x23: ADC alt rate = 0x%02x\n", 359 snd_sonicvibes_in(sonic, 0x03), snd_sonicvibes_in(sonic, 0x23)); 360 dev_dbg(sonic->card->dev, 361 " 0x04: left CD = 0x%02x 0x24: ADC pll M = 0x%02x\n", 362 snd_sonicvibes_in(sonic, 0x04), snd_sonicvibes_in(sonic, 0x24)); 363 dev_dbg(sonic->card->dev, 364 " 0x05: right CD = 0x%02x 0x25: ADC pll N = 0x%02x\n", 365 snd_sonicvibes_in(sonic, 0x05), snd_sonicvibes_in(sonic, 0x25)); 366 dev_dbg(sonic->card->dev, 367 " 0x06: left line = 0x%02x 0x26: Synth pll M = 0x%02x\n", 368 snd_sonicvibes_in(sonic, 0x06), snd_sonicvibes_in(sonic, 0x26)); 369 dev_dbg(sonic->card->dev, 370 " 0x07: right line = 0x%02x 0x27: Synth pll N = 0x%02x\n", 371 snd_sonicvibes_in(sonic, 0x07), snd_sonicvibes_in(sonic, 0x27)); 372 dev_dbg(sonic->card->dev, 373 " 0x08: MIC = 0x%02x 0x28: --- = 0x%02x\n", 374 snd_sonicvibes_in(sonic, 0x08), snd_sonicvibes_in(sonic, 0x28)); 375 dev_dbg(sonic->card->dev, 376 " 0x09: Game port = 0x%02x 0x29: --- = 0x%02x\n", 377 snd_sonicvibes_in(sonic, 0x09), snd_sonicvibes_in(sonic, 0x29)); 378 dev_dbg(sonic->card->dev, 379 " 0x0a: left synth = 0x%02x 0x2a: MPU401 = 0x%02x\n", 380 snd_sonicvibes_in(sonic, 0x0a), snd_sonicvibes_in(sonic, 0x2a)); 381 dev_dbg(sonic->card->dev, 382 " 0x0b: right synth = 0x%02x 0x2b: drive ctrl = 0x%02x\n", 383 snd_sonicvibes_in(sonic, 0x0b), snd_sonicvibes_in(sonic, 0x2b)); 384 dev_dbg(sonic->card->dev, 385 " 0x0c: left AUX2 = 0x%02x 0x2c: SRS space = 0x%02x\n", 386 snd_sonicvibes_in(sonic, 0x0c), snd_sonicvibes_in(sonic, 0x2c)); 387 dev_dbg(sonic->card->dev, 388 " 0x0d: right AUX2 = 0x%02x 0x2d: SRS center = 0x%02x\n", 389 snd_sonicvibes_in(sonic, 0x0d), snd_sonicvibes_in(sonic, 0x2d)); 390 dev_dbg(sonic->card->dev, 391 " 0x0e: left analog = 0x%02x 0x2e: wave source = 0x%02x\n", 392 snd_sonicvibes_in(sonic, 0x0e), snd_sonicvibes_in(sonic, 0x2e)); 393 dev_dbg(sonic->card->dev, 394 " 0x0f: right analog = 0x%02x 0x2f: --- = 0x%02x\n", 395 snd_sonicvibes_in(sonic, 0x0f), snd_sonicvibes_in(sonic, 0x2f)); 396 dev_dbg(sonic->card->dev, 397 " 0x10: left PCM = 0x%02x 0x30: analog power = 0x%02x\n", 398 snd_sonicvibes_in(sonic, 0x10), snd_sonicvibes_in(sonic, 0x30)); 399 dev_dbg(sonic->card->dev, 400 " 0x11: right PCM = 0x%02x 0x31: analog power = 0x%02x\n", 401 snd_sonicvibes_in(sonic, 0x11), snd_sonicvibes_in(sonic, 0x31)); 402 dev_dbg(sonic->card->dev, 403 " 0x12: DMA data format = 0x%02x 0x32: --- = 0x%02x\n", 404 snd_sonicvibes_in(sonic, 0x12), snd_sonicvibes_in(sonic, 0x32)); 405 dev_dbg(sonic->card->dev, 406 " 0x13: P/C enable = 0x%02x 0x33: --- = 0x%02x\n", 407 snd_sonicvibes_in(sonic, 0x13), snd_sonicvibes_in(sonic, 0x33)); 408 dev_dbg(sonic->card->dev, 409 " 0x14: U/D button = 0x%02x 0x34: --- = 0x%02x\n", 410 snd_sonicvibes_in(sonic, 0x14), snd_sonicvibes_in(sonic, 0x34)); 411 dev_dbg(sonic->card->dev, 412 " 0x15: revision = 0x%02x 0x35: --- = 0x%02x\n", 413 snd_sonicvibes_in(sonic, 0x15), snd_sonicvibes_in(sonic, 0x35)); 414 dev_dbg(sonic->card->dev, 415 " 0x16: ADC output ctrl = 0x%02x 0x36: --- = 0x%02x\n", 416 snd_sonicvibes_in(sonic, 0x16), snd_sonicvibes_in(sonic, 0x36)); 417 dev_dbg(sonic->card->dev, 418 " 0x17: --- = 0x%02x 0x37: --- = 0x%02x\n", 419 snd_sonicvibes_in(sonic, 0x17), snd_sonicvibes_in(sonic, 0x37)); 420 dev_dbg(sonic->card->dev, 421 " 0x18: DMA A upper cnt = 0x%02x 0x38: --- = 0x%02x\n", 422 snd_sonicvibes_in(sonic, 0x18), snd_sonicvibes_in(sonic, 0x38)); 423 dev_dbg(sonic->card->dev, 424 " 0x19: DMA A lower cnt = 0x%02x 0x39: --- = 0x%02x\n", 425 snd_sonicvibes_in(sonic, 0x19), snd_sonicvibes_in(sonic, 0x39)); 426 dev_dbg(sonic->card->dev, 427 " 0x1a: --- = 0x%02x 0x3a: --- = 0x%02x\n", 428 snd_sonicvibes_in(sonic, 0x1a), snd_sonicvibes_in(sonic, 0x3a)); 429 dev_dbg(sonic->card->dev, 430 " 0x1b: --- = 0x%02x 0x3b: --- = 0x%02x\n", 431 snd_sonicvibes_in(sonic, 0x1b), snd_sonicvibes_in(sonic, 0x3b)); 432 dev_dbg(sonic->card->dev, 433 " 0x1c: DMA C upper cnt = 0x%02x 0x3c: --- = 0x%02x\n", 434 snd_sonicvibes_in(sonic, 0x1c), snd_sonicvibes_in(sonic, 0x3c)); 435 dev_dbg(sonic->card->dev, 436 " 0x1d: DMA C upper cnt = 0x%02x 0x3d: --- = 0x%02x\n", 437 snd_sonicvibes_in(sonic, 0x1d), snd_sonicvibes_in(sonic, 0x3d)); 438 dev_dbg(sonic->card->dev, 439 " 0x1e: PCM rate low = 0x%02x 0x3e: --- = 0x%02x\n", 440 snd_sonicvibes_in(sonic, 0x1e), snd_sonicvibes_in(sonic, 0x3e)); 441 dev_dbg(sonic->card->dev, 442 " 0x1f: PCM rate high = 0x%02x 0x3f: --- = 0x%02x\n", 443 snd_sonicvibes_in(sonic, 0x1f), snd_sonicvibes_in(sonic, 0x3f)); 459 444 } 460 445 … … 512 497 *res_n = n; 513 498 #if 0 514 printk(KERN_DEBUG "metric = %i, xm = %i, xn = %i\n", metric, xm, xn); 515 printk(KERN_DEBUG "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n); 499 dev_dbg(sonic->card->dev, 500 "metric = %i, xm = %i, xn = %i\n", metric, xm, xn); 501 dev_dbg(sonic->card->dev, 502 "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n); 516 503 #endif 517 504 } … … 625 612 if (status == 0xff) { /* failure */ 626 613 outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK)); 627 snd_printk(KERN_ERR "IRQ failure - interrupts disabled!!\n"); 614 dev_err(sonic->card->dev, 615 "IRQ failure - interrupts disabled!!\n"); 628 616 return IRQ_HANDLED; 629 617 } … … 775 763 } 776 764 777 static struct snd_pcm_hardware snd_sonicvibes_playback =765 static const struct snd_pcm_hardware snd_sonicvibes_playback = 778 766 { 779 767 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 794 782 }; 795 783 796 static struct snd_pcm_hardware snd_sonicvibes_capture =784 static const struct snd_pcm_hardware snd_sonicvibes_capture = 797 785 { 798 786 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 856 844 } 857 845 858 static struct snd_pcm_ops snd_sonicvibes_playback_ops = {846 static const struct snd_pcm_ops snd_sonicvibes_playback_ops = { 859 847 .open = snd_sonicvibes_playback_open, 860 848 .close = snd_sonicvibes_playback_close, … … 867 855 }; 868 856 869 static struct snd_pcm_ops snd_sonicvibes_capture_ops = {857 static const struct snd_pcm_ops snd_sonicvibes_capture_ops = { 870 858 .open = snd_sonicvibes_capture_open, 871 859 .close = snd_sonicvibes_capture_close, … … 878 866 }; 879 867 880 static int __devinit snd_sonicvibes_pcm(struct sonicvibes * sonic, int device, struct snd_pcm ** rpcm)868 static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) 881 869 { 882 870 struct snd_pcm *pcm; … … 899 887 snd_dma_pci_data(sonic->pci), 64*1024, 128*1024); 900 888 901 if (rpcm)902 *rpcm = pcm;903 889 return 0; 904 890 } … … 915 901 static int snd_sonicvibes_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 916 902 { 917 static c har *texts[7] = {903 static const char * const texts[7] = { 918 904 "CD", "PCM", "Aux1", "Line", "Aux0", "Mic", "Mix" 919 905 }; 920 906 921 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 922 uinfo->count = 2; 923 uinfo->value.enumerated.items = 7; 924 if (uinfo->value.enumerated.item >= 7) 925 uinfo->value.enumerated.item = 6; 926 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 927 return 0; 907 return snd_ctl_enum_info(uinfo, 2, 7, texts); 928 908 } 929 909 … … 1088 1068 } 1089 1069 1090 static struct snd_kcontrol_new snd_sonicvibes_controls[] __devinitdata= {1070 static struct snd_kcontrol_new snd_sonicvibes_controls[] = { 1091 1071 SONICVIBES_DOUBLE("Capture Volume", 0, SV_IREG_LEFT_ADC, SV_IREG_RIGHT_ADC, 0, 0, 15, 0), 1092 1072 SONICVIBES_DOUBLE("Aux Playback Switch", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 7, 7, 1, 1), … … 1119 1099 } 1120 1100 1121 static int __devinit snd_sonicvibes_mixer(struct sonicvibes *sonic)1101 static int snd_sonicvibes_mixer(struct sonicvibes *sonic) 1122 1102 { 1123 1103 struct snd_card *card; … … 1176 1156 } 1177 1157 1178 static void __devinit snd_sonicvibes_proc_init(struct sonicvibes * sonic) 1179 { 1180 struct snd_info_entry *entry; 1181 1182 if (! snd_card_proc_new(sonic->card, "sonicvibes", &entry)) 1183 snd_info_set_text_ops(entry, sonic, snd_sonicvibes_proc_read); 1158 static void snd_sonicvibes_proc_init(struct sonicvibes *sonic) 1159 { 1160 snd_card_ro_proc_new(sonic->card, "sonicvibes", sonic, 1161 snd_sonicvibes_proc_read); 1184 1162 } 1185 1163 … … 1189 1167 1190 1168 #ifdef SUPPORT_JOYSTICK 1191 static struct snd_kcontrol_new snd_sonicvibes_game_control __devinitdata=1169 static struct snd_kcontrol_new snd_sonicvibes_game_control = 1192 1170 SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); 1193 1171 1194 static int __devinitsnd_sonicvibes_create_gameport(struct sonicvibes *sonic)1172 static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) 1195 1173 { 1196 1174 struct gameport *gp; 1175 int err; 1197 1176 1198 1177 sonic->gameport = gp = gameport_allocate_port(); 1199 1178 if (!gp) { 1200 printk(KERN_ERR "sonicvibes: cannot allocate memory for gameport\n"); 1179 dev_err(sonic->card->dev, 1180 "sonicvibes: cannot allocate memory for gameport\n"); 1201 1181 return -ENOMEM; 1202 1182 } … … 1209 1189 gameport_register_port(gp); 1210 1190 1211 snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); 1191 err = snd_ctl_add(sonic->card, 1192 snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); 1193 if (err < 0) 1194 return err; 1212 1195 1213 1196 return 0; … … 1247 1230 } 1248 1231 1249 static int __devinitsnd_sonicvibes_create(struct snd_card *card,1250 1251 1252 1253 struct sonicvibes **rsonic)1232 static int snd_sonicvibes_create(struct snd_card *card, 1233 struct pci_dev *pci, 1234 int reverb, 1235 int mge, 1236 struct sonicvibes **rsonic) 1254 1237 { 1255 1238 struct sonicvibes *sonic; … … 1265 1248 return err; 1266 1249 /* check, if we can restrict PCI DMA transfers to 24 bits */ 1267 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 || 1268 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) { 1269 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 1250 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 || 1251 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) { 1252 dev_err(card->dev, 1253 "architecture does not support 24bit PCI busmaster DMA\n"); 1270 1254 pci_disable_device(pci); 1271 1255 return -ENXIO; … … 1296 1280 if (request_irq(pci->irq, snd_sonicvibes_interrupt, IRQF_SHARED, 1297 1281 KBUILD_MODNAME, sonic)) { 1298 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);1282 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1299 1283 snd_sonicvibes_free(sonic); 1300 1284 return -EBUSY; … … 1310 1294 dmaa = dmaio; 1311 1295 dmaio += 0x10; 1312 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", dmaa); 1296 dev_info(card->dev, 1297 "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", 1298 dmaa); 1313 1299 } 1314 1300 if (!dmac) { 1315 1301 dmac = dmaio; 1316 1302 dmaio += 0x10; 1317 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", dmac); 1303 dev_info(card->dev, 1304 "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", 1305 dmac); 1318 1306 } 1319 1307 pci_write_config_dword(pci, 0x40, dmaa); … … 1322 1310 if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) { 1323 1311 snd_sonicvibes_free(sonic); 1324 snd_printk(KERN_ERR "unable to grab DDMA-A port at 0x%x-0x%x\n", dmaa, dmaa + 0x10 - 1); 1312 dev_err(card->dev, 1313 "unable to grab DDMA-A port at 0x%x-0x%x\n", 1314 dmaa, dmaa + 0x10 - 1); 1325 1315 return -EBUSY; 1326 1316 } 1327 1317 if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) { 1328 1318 snd_sonicvibes_free(sonic); 1329 snd_printk(KERN_ERR "unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1); 1319 dev_err(card->dev, 1320 "unable to grab DDMA-C port at 0x%x-0x%x\n", 1321 dmac, dmac + 0x10 - 1); 1330 1322 return -EBUSY; 1331 1323 } … … 1392 1384 snd_sonicvibes_proc_init(sonic); 1393 1385 1394 snd_card_set_dev(card, &pci->dev);1395 1396 1386 *rsonic = sonic; 1397 1387 return 0; … … 1402 1392 */ 1403 1393 1404 static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] __devinitdata= {1394 static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] = { 1405 1395 SONICVIBES_SINGLE("SonicVibes Wave Source RAM", 0, SV_IREG_WAVE_SOURCE, 0, 1, 0), 1406 1396 SONICVIBES_SINGLE("SonicVibes Wave Source RAM+ROM", 0, SV_IREG_WAVE_SOURCE, 1, 1, 0), … … 1423 1413 } 1424 1414 1425 static int __devinit snd_sonicvibes_midi(struct sonicvibes *sonic,1426 1415 static int snd_sonicvibes_midi(struct sonicvibes *sonic, 1416 struct snd_rawmidi *rmidi) 1427 1417 { 1428 1418 struct snd_mpu401 * mpu = rmidi->private_data; 1429 1419 struct snd_card *card = sonic->card; 1430 struct snd_rawmidi_str *dir;1431 1420 unsigned int idx; 1432 1421 int err; … … 1435 1424 mpu->open_input = snd_sonicvibes_midi_input_open; 1436 1425 mpu->close_input = snd_sonicvibes_midi_input_close; 1437 dir = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT];1438 1426 for (idx = 0; idx < ARRAY_SIZE(snd_sonicvibes_midi_controls); idx++) 1439 1427 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_midi_controls[idx], sonic))) < 0) … … 1442 1430 } 1443 1431 1444 static int __devinitsnd_sonic_probe(struct pci_dev *pci,1445 1432 static int snd_sonic_probe(struct pci_dev *pci, 1433 const struct pci_device_id *pci_id) 1446 1434 { 1447 1435 static int dev; … … 1459 1447 } 1460 1448 1461 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1449 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1450 0, &card); 1462 1451 if (err < 0) 1463 1452 return err; … … 1485 1474 sonic->irq); 1486 1475 1487 if ((err = snd_sonicvibes_pcm(sonic, 0 , NULL)) < 0) {1476 if ((err = snd_sonicvibes_pcm(sonic, 0)) < 0) { 1488 1477 snd_card_free(card); 1489 1478 return err; … … 1513 1502 } 1514 1503 1515 snd_sonicvibes_create_gameport(sonic); 1504 err = snd_sonicvibes_create_gameport(sonic); 1505 if (err < 0) { 1506 snd_card_free(card); 1507 return err; 1508 } 1516 1509 1517 1510 if ((err = snd_card_register(card)) < 0) { … … 1525 1518 } 1526 1519 1527 static void __devexitsnd_sonic_remove(struct pci_dev *pci)1520 static void snd_sonic_remove(struct pci_dev *pci) 1528 1521 { 1529 1522 snd_card_free(pci_get_drvdata(pci)); 1530 pci_set_drvdata(pci, NULL); 1531 } 1532 1533 static struct pci_driver driver = { 1523 } 1524 1525 static struct pci_driver sonicvibes_driver = { 1534 1526 .name = KBUILD_MODNAME, 1535 1527 .id_table = snd_sonic_ids, 1536 1528 .probe = snd_sonic_probe, 1537 .remove = __devexit_p(snd_sonic_remove),1529 .remove = snd_sonic_remove, 1538 1530 }; 1539 1531 1540 static int __init alsa_card_sonicvibes_init(void) 1541 { 1542 return pci_register_driver(&driver); 1543 } 1544 1545 static void __exit alsa_card_sonicvibes_exit(void) 1546 { 1547 pci_unregister_driver(&driver); 1548 } 1549 1550 module_init(alsa_card_sonicvibes_init) 1551 module_exit(alsa_card_sonicvibes_exit) 1532 module_pci_driver(sonicvibes_driver);
Note:
See TracChangeset
for help on using the changeset viewer.