Changeset 679 for GPL/trunk/alsa-kernel/pci/sonicvibes.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/sonicvibes.c
r598 r679 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 … … 29 15 #include <linux/slab.h> 30 16 #include <linux/gameport.h> 31 #include <linux/module param.h>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 } … … 694 682 } 695 683 696 static int snd_sonicvibes_hw_params(struct snd_pcm_substream *substream,697 struct snd_pcm_hw_params *hw_params)698 {699 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));700 }701 702 static int snd_sonicvibes_hw_free(struct snd_pcm_substream *substream)703 {704 return snd_pcm_lib_free_pages(substream);705 }706 707 684 static int snd_sonicvibes_playback_prepare(struct snd_pcm_substream *substream) 708 685 { … … 775 752 } 776 753 777 static struct snd_pcm_hardware snd_sonicvibes_playback =754 static const struct snd_pcm_hardware snd_sonicvibes_playback = 778 755 { 779 756 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 794 771 }; 795 772 796 static struct snd_pcm_hardware snd_sonicvibes_capture =773 static const struct snd_pcm_hardware snd_sonicvibes_capture = 797 774 { 798 775 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 856 833 } 857 834 858 static struct snd_pcm_ops snd_sonicvibes_playback_ops = {835 static const struct snd_pcm_ops snd_sonicvibes_playback_ops = { 859 836 .open = snd_sonicvibes_playback_open, 860 837 .close = snd_sonicvibes_playback_close, 861 .ioctl = snd_pcm_lib_ioctl,862 .hw_params = snd_sonicvibes_hw_params,863 .hw_free = snd_sonicvibes_hw_free,864 838 .prepare = snd_sonicvibes_playback_prepare, 865 839 .trigger = snd_sonicvibes_playback_trigger, … … 867 841 }; 868 842 869 static struct snd_pcm_ops snd_sonicvibes_capture_ops = {843 static const struct snd_pcm_ops snd_sonicvibes_capture_ops = { 870 844 .open = snd_sonicvibes_capture_open, 871 845 .close = snd_sonicvibes_capture_close, 872 .ioctl = snd_pcm_lib_ioctl,873 .hw_params = snd_sonicvibes_hw_params,874 .hw_free = snd_sonicvibes_hw_free,875 846 .prepare = snd_sonicvibes_capture_prepare, 876 847 .trigger = snd_sonicvibes_capture_trigger, … … 878 849 }; 879 850 880 static int __devinit snd_sonicvibes_pcm(struct sonicvibes * sonic, int device, struct snd_pcm ** rpcm)851 static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) 881 852 { 882 853 struct snd_pcm *pcm; … … 896 867 sonic->pcm = pcm; 897 868 898 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 899 snd_dma_pci_data(sonic->pci), 64*1024, 128*1024); 900 901 if (rpcm) 902 *rpcm = pcm; 869 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 870 &sonic->pci->dev, 64*1024, 128*1024); 871 903 872 return 0; 904 873 } … … 915 884 static int snd_sonicvibes_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 916 885 { 917 static c har *texts[7] = {886 static const char * const texts[7] = { 918 887 "CD", "PCM", "Aux1", "Line", "Aux0", "Mic", "Mix" 919 888 }; 920 889 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; 890 return snd_ctl_enum_info(uinfo, 2, 7, texts); 928 891 } 929 892 … … 1088 1051 } 1089 1052 1090 static struct snd_kcontrol_new snd_sonicvibes_controls[] __devinitdata= {1053 static const struct snd_kcontrol_new snd_sonicvibes_controls[] = { 1091 1054 SONICVIBES_DOUBLE("Capture Volume", 0, SV_IREG_LEFT_ADC, SV_IREG_RIGHT_ADC, 0, 0, 15, 0), 1092 1055 SONICVIBES_DOUBLE("Aux Playback Switch", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 7, 7, 1, 1), … … 1119 1082 } 1120 1083 1121 static int __devinit snd_sonicvibes_mixer(struct sonicvibes *sonic)1084 static int snd_sonicvibes_mixer(struct sonicvibes *sonic) 1122 1085 { 1123 1086 struct snd_card *card; … … 1176 1139 } 1177 1140 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); 1141 static void snd_sonicvibes_proc_init(struct sonicvibes *sonic) 1142 { 1143 snd_card_ro_proc_new(sonic->card, "sonicvibes", sonic, 1144 snd_sonicvibes_proc_read); 1184 1145 } 1185 1146 … … 1189 1150 1190 1151 #ifdef SUPPORT_JOYSTICK 1191 static struct snd_kcontrol_new snd_sonicvibes_game_control __devinitdata=1152 static const struct snd_kcontrol_new snd_sonicvibes_game_control = 1192 1153 SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); 1193 1154 1194 static int __devinitsnd_sonicvibes_create_gameport(struct sonicvibes *sonic)1155 static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) 1195 1156 { 1196 1157 struct gameport *gp; 1158 int err; 1197 1159 1198 1160 sonic->gameport = gp = gameport_allocate_port(); 1199 1161 if (!gp) { 1200 printk(KERN_ERR "sonicvibes: cannot allocate memory for gameport\n"); 1162 dev_err(sonic->card->dev, 1163 "sonicvibes: cannot allocate memory for gameport\n"); 1201 1164 return -ENOMEM; 1202 1165 } … … 1209 1172 gameport_register_port(gp); 1210 1173 1211 snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); 1174 err = snd_ctl_add(sonic->card, 1175 snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); 1176 if (err < 0) 1177 return err; 1212 1178 1213 1179 return 0; … … 1247 1213 } 1248 1214 1249 static int __devinitsnd_sonicvibes_create(struct snd_card *card,1250 1251 1252 1253 struct sonicvibes **rsonic)1215 static int snd_sonicvibes_create(struct snd_card *card, 1216 struct pci_dev *pci, 1217 int reverb, 1218 int mge, 1219 struct sonicvibes **rsonic) 1254 1220 { 1255 1221 struct sonicvibes *sonic; 1256 1222 unsigned int dmaa, dmac; 1257 1223 int err; 1258 static struct snd_device_ops ops = {1224 static const struct snd_device_ops ops = { 1259 1225 .dev_free = snd_sonicvibes_dev_free, 1260 1226 }; … … 1265 1231 return err; 1266 1232 /* 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"); 1233 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 || 1234 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) { 1235 dev_err(card->dev, 1236 "architecture does not support 24bit PCI busmaster DMA\n"); 1270 1237 pci_disable_device(pci); 1271 1238 return -ENXIO; … … 1295 1262 1296 1263 if (request_irq(pci->irq, snd_sonicvibes_interrupt, IRQF_SHARED, 1297 "S3 SonicVibes", sonic)) {1298 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);1264 KBUILD_MODNAME, sonic)) { 1265 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1299 1266 snd_sonicvibes_free(sonic); 1300 1267 return -EBUSY; 1301 1268 } 1302 1269 sonic->irq = pci->irq; 1270 card->sync_irq = sonic->irq; 1303 1271 1304 1272 pci_read_config_dword(pci, 0x40, &dmaa); … … 1310 1278 dmaa = dmaio; 1311 1279 dmaio += 0x10; 1312 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", dmaa); 1280 dev_info(card->dev, 1281 "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", 1282 dmaa); 1313 1283 } 1314 1284 if (!dmac) { 1315 1285 dmac = dmaio; 1316 1286 dmaio += 0x10; 1317 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", dmac); 1287 dev_info(card->dev, 1288 "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", 1289 dmac); 1318 1290 } 1319 1291 pci_write_config_dword(pci, 0x40, dmaa); … … 1322 1294 if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) { 1323 1295 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); 1296 dev_err(card->dev, 1297 "unable to grab DDMA-A port at 0x%x-0x%x\n", 1298 dmaa, dmaa + 0x10 - 1); 1325 1299 return -EBUSY; 1326 1300 } 1327 1301 if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) { 1328 1302 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); 1303 dev_err(card->dev, 1304 "unable to grab DDMA-C port at 0x%x-0x%x\n", 1305 dmac, dmac + 0x10 - 1); 1330 1306 return -EBUSY; 1331 1307 } … … 1392 1368 snd_sonicvibes_proc_init(sonic); 1393 1369 1394 snd_card_set_dev(card, &pci->dev);1395 1396 1370 *rsonic = sonic; 1397 1371 return 0; … … 1402 1376 */ 1403 1377 1404 static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] __devinitdata= {1378 static const struct snd_kcontrol_new snd_sonicvibes_midi_controls[] = { 1405 1379 SONICVIBES_SINGLE("SonicVibes Wave Source RAM", 0, SV_IREG_WAVE_SOURCE, 0, 1, 0), 1406 1380 SONICVIBES_SINGLE("SonicVibes Wave Source RAM+ROM", 0, SV_IREG_WAVE_SOURCE, 1, 1, 0), … … 1423 1397 } 1424 1398 1425 static int __devinit snd_sonicvibes_midi(struct sonicvibes *sonic,1426 1399 static int snd_sonicvibes_midi(struct sonicvibes *sonic, 1400 struct snd_rawmidi *rmidi) 1427 1401 { 1428 1402 struct snd_mpu401 * mpu = rmidi->private_data; 1429 1403 struct snd_card *card = sonic->card; 1430 struct snd_rawmidi_str *dir;1431 1404 unsigned int idx; 1432 1405 int err; … … 1435 1408 mpu->open_input = snd_sonicvibes_midi_input_open; 1436 1409 mpu->close_input = snd_sonicvibes_midi_input_close; 1437 dir = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT];1438 1410 for (idx = 0; idx < ARRAY_SIZE(snd_sonicvibes_midi_controls); idx++) 1439 1411 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_midi_controls[idx], sonic))) < 0) … … 1442 1414 } 1443 1415 1444 static int __devinitsnd_sonic_probe(struct pci_dev *pci,1445 1416 static int snd_sonic_probe(struct pci_dev *pci, 1417 const struct pci_device_id *pci_id) 1446 1418 { 1447 1419 static int dev; … … 1459 1431 } 1460 1432 1461 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1433 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1434 0, &card); 1462 1435 if (err < 0) 1463 1436 return err; … … 1485 1458 sonic->irq); 1486 1459 1487 if ((err = snd_sonicvibes_pcm(sonic, 0 , NULL)) < 0) {1460 if ((err = snd_sonicvibes_pcm(sonic, 0)) < 0) { 1488 1461 snd_card_free(card); 1489 1462 return err; … … 1494 1467 } 1495 1468 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SONICVIBES, 1496 sonic->midi_port, MPU401_INFO_INTEGRATED, 1497 sonic->irq, 0, 1498 &midi_uart)) < 0) { 1469 sonic->midi_port, 1470 MPU401_INFO_INTEGRATED | 1471 MPU401_INFO_IRQ_HOOK, 1472 -1, &midi_uart)) < 0) { 1499 1473 snd_card_free(card); 1500 1474 return err; … … 1512 1486 } 1513 1487 1514 snd_sonicvibes_create_gameport(sonic); 1488 err = snd_sonicvibes_create_gameport(sonic); 1489 if (err < 0) { 1490 snd_card_free(card); 1491 return err; 1492 } 1515 1493 1516 1494 if ((err = snd_card_register(card)) < 0) { … … 1524 1502 } 1525 1503 1526 static void __devexitsnd_sonic_remove(struct pci_dev *pci)1504 static void snd_sonic_remove(struct pci_dev *pci) 1527 1505 { 1528 1506 snd_card_free(pci_get_drvdata(pci)); 1529 pci_set_drvdata(pci, NULL); 1530 } 1531 1532 static struct pci_driver driver = { 1533 .name = "S3 SonicVibes", 1507 } 1508 1509 static struct pci_driver sonicvibes_driver = { 1510 .name = KBUILD_MODNAME, 1534 1511 .id_table = snd_sonic_ids, 1535 1512 .probe = snd_sonic_probe, 1536 .remove = __devexit_p(snd_sonic_remove),1513 .remove = snd_sonic_remove, 1537 1514 }; 1538 1515 1539 static int __init alsa_card_sonicvibes_init(void) 1540 { 1541 return pci_register_driver(&driver); 1542 } 1543 1544 static void __exit alsa_card_sonicvibes_exit(void) 1545 { 1546 pci_unregister_driver(&driver); 1547 } 1548 1549 module_init(alsa_card_sonicvibes_init) 1550 module_exit(alsa_card_sonicvibes_exit) 1516 module_pci_driver(sonicvibes_driver);
Note:
See TracChangeset
for help on using the changeset viewer.