Changeset 34 for GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c
- Timestamp:
- Dec 11, 2005, 5:57:39 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c
r33 r34 196 196 */ 197 197 198 typedef struct snd_emu10k1x_voice emu10k1x_voice_t; 199 typedef struct snd_emu10k1x emu10k1x_t; 200 typedef struct snd_emu10k1x_pcm emu10k1x_pcm_t; 201 202 struct snd_emu10k1x_voice { 203 emu10k1x_t *emu; 198 struct emu10k1x_voice { 199 struct emu10k1x *emu; 204 200 int number; 205 201 int use; 206 202 207 emu10k1x_pcm_t*epcm;203 struct emu10k1x_pcm *epcm; 208 204 }; 209 205 210 struct snd_emu10k1x_pcm {211 emu10k1x_t*emu;212 s nd_pcm_substream_t*substream;213 emu10k1x_voice_t*voice;206 struct emu10k1x_pcm { 207 struct emu10k1x *emu; 208 struct snd_pcm_substream *substream; 209 struct emu10k1x_voice *voice; 214 210 unsigned short running; 215 211 }; 216 212 217 typedef struct{218 struct snd_emu10k1x *emu;219 s nd_rawmidi_t*rmidi;220 s nd_rawmidi_substream_t*substream_input;221 s nd_rawmidi_substream_t*substream_output;213 struct emu10k1x_midi { 214 struct emu10k1x *emu; 215 struct snd_rawmidi *rmidi; 216 struct snd_rawmidi_substream *substream_input; 217 struct snd_rawmidi_substream *substream_output; 222 218 unsigned int midi_mode; 223 219 spinlock_t input_lock; … … 227 223 int port; 228 224 int ipr_tx, ipr_rx; 229 void (*interrupt)( emu10k1x_t*emu, unsigned int status);230 } emu10k1x_midi_t;225 void (*interrupt)(struct emu10k1x *emu, unsigned int status); 226 }; 231 227 232 228 // definition of the chip-specific record 233 struct snd_emu10k1x {234 s nd_card_t*card;229 struct emu10k1x { 230 struct snd_card *card; 235 231 struct pci_dev *pci; 236 232 … … 246 242 spinlock_t voice_lock; 247 243 248 ac97_t*ac97;249 s nd_pcm_t*pcm;250 251 emu10k1x_voice_tvoices[3];252 emu10k1x_voice_tcapture_voice;244 struct snd_ac97 *ac97; 245 struct snd_pcm *pcm; 246 247 struct emu10k1x_voice voices[3]; 248 struct emu10k1x_voice capture_voice; 253 249 u32 spdif_bits[3]; // SPDIF out setup 254 250 255 251 struct snd_dma_buffer dma_buffer; 256 252 257 emu10k1x_midi_tmidi;253 struct emu10k1x_midi midi; 258 254 }; 259 255 260 256 /* hardware definition */ 261 static s nd_pcm_hardware_tsnd_emu10k1x_playback_hw = {262 /*.info = */ (SNDRV_PCM_INFO_MMAP |257 static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { 258 .info = (SNDRV_PCM_INFO_MMAP | 263 259 SNDRV_PCM_INFO_INTERLEAVED | 264 260 SNDRV_PCM_INFO_BLOCK_TRANSFER | 265 261 SNDRV_PCM_INFO_MMAP_VALID), 266 /*.formats = */SNDRV_PCM_FMTBIT_S16_LE,267 /*.rates = */SNDRV_PCM_RATE_48000,268 /*.rate_min = */48000,269 /*.rate_max = */48000,270 /*.channels_min = */2,271 /*.channels_max = */2,272 /*.buffer_bytes_max = */(32*1024),273 /*.period_bytes_min = */64,274 /*.period_bytes_max = */(16*1024),275 /*.periods_min = */2,276 /*.periods_max = */8,277 /*.fifo_size = */ 0262 .formats = SNDRV_PCM_FMTBIT_S16_LE, 263 .rates = SNDRV_PCM_RATE_48000, 264 .rate_min = 48000, 265 .rate_max = 48000, 266 .channels_min = 2, 267 .channels_max = 2, 268 .buffer_bytes_max = (32*1024), 269 .period_bytes_min = 64, 270 .period_bytes_max = (16*1024), 271 .periods_min = 2, 272 .periods_max = 8, 273 .fifo_size = 0, 278 274 }; 279 275 280 static s nd_pcm_hardware_tsnd_emu10k1x_capture_hw = {281 /*.info = */(SNDRV_PCM_INFO_MMAP |276 static struct snd_pcm_hardware snd_emu10k1x_capture_hw = { 277 .info = (SNDRV_PCM_INFO_MMAP | 282 278 SNDRV_PCM_INFO_INTERLEAVED | 283 279 SNDRV_PCM_INFO_BLOCK_TRANSFER | 284 280 SNDRV_PCM_INFO_MMAP_VALID), 285 /*.formats = */SNDRV_PCM_FMTBIT_S16_LE,286 /*.rates = */SNDRV_PCM_RATE_48000,287 /*.rate_min = */48000,288 /*.rate_max = */48000,289 /*.channels_min = */2,290 /*.channels_max = */2,291 /*.buffer_bytes_max = */(32*1024),292 /*.period_bytes_min = */64,293 /*.period_bytes_max = */(16*1024),294 /*.periods_min = */2,295 /*.periods_max = */2,296 /*.fifo_size = */ 0281 .formats = SNDRV_PCM_FMTBIT_S16_LE, 282 .rates = SNDRV_PCM_RATE_48000, 283 .rate_min = 48000, 284 .rate_max = 48000, 285 .channels_min = 2, 286 .channels_max = 2, 287 .buffer_bytes_max = (32*1024), 288 .period_bytes_min = 64, 289 .period_bytes_max = (16*1024), 290 .periods_min = 2, 291 .periods_max = 2, 292 .fifo_size = 0, 297 293 }; 298 294 299 static unsigned int snd_emu10k1x_ptr_read( emu10k1x_t* emu,295 static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, 300 296 unsigned int reg, 301 297 unsigned int chn) … … 313 309 } 314 310 315 static void snd_emu10k1x_ptr_write( emu10k1x_t*emu,311 static void snd_emu10k1x_ptr_write(struct emu10k1x *emu, 316 312 unsigned int reg, 317 313 unsigned int chn, … … 329 325 } 330 326 331 static void snd_emu10k1x_intr_enable( emu10k1x_t*emu, unsigned int intrenb)327 static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) 332 328 { 333 329 unsigned long flags; … … 340 336 } 341 337 342 static void snd_emu10k1x_intr_disable( emu10k1x_t*emu, unsigned int intrenb)338 static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) 343 339 { 344 340 unsigned long flags; … … 351 347 } 352 348 353 static void snd_emu10k1x_gpio_write( emu10k1x_t*emu, unsigned int value)349 static void snd_emu10k1x_gpio_write(struct emu10k1x *emu, unsigned int value) 354 350 { 355 351 unsigned long flags; … … 360 356 } 361 357 362 static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) 363 { 364 emu10k1x_pcm_t *epcm = runtime->private_data; 365 366 if (epcm) 367 kfree(epcm); 368 } 369 370 static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) 371 { 372 emu10k1x_pcm_t *epcm; 358 static void snd_emu10k1x_pcm_free_substream(struct snd_pcm_runtime *runtime) 359 { 360 kfree(runtime->private_data); 361 } 362 363 static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voice *voice) 364 { 365 struct emu10k1x_pcm *epcm; 373 366 374 367 if ((epcm = voice->epcm) == NULL) … … 386 379 387 380 /* open callback */ 388 static int snd_emu10k1x_playback_open(s nd_pcm_substream_t*substream)389 { 390 emu10k1x_t*chip = snd_pcm_substream_chip(substream);391 emu10k1x_pcm_t*epcm;392 s nd_pcm_runtime_t*runtime = substream->runtime;381 static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream) 382 { 383 struct emu10k1x *chip = snd_pcm_substream_chip(substream); 384 struct emu10k1x_pcm *epcm; 385 struct snd_pcm_runtime *runtime = substream->runtime; 393 386 int err; 394 387 … … 399 392 return err; 400 393 401 epcm =kzalloc(sizeof(*epcm), GFP_KERNEL);394 epcm = (struct emu10k1x_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 402 395 if (epcm == NULL) 403 396 return -ENOMEM; … … 414 407 415 408 /* close callback */ 416 static int snd_emu10k1x_playback_close(s nd_pcm_substream_t*substream)409 static int snd_emu10k1x_playback_close(struct snd_pcm_substream *substream) 417 410 { 418 411 return 0; … … 420 413 421 414 /* hw_params callback */ 422 static int snd_emu10k1x_pcm_hw_params(s nd_pcm_substream_t*substream,423 s nd_pcm_hw_params_t *hw_params)424 { 425 s nd_pcm_runtime_t*runtime = substream->runtime;426 emu10k1x_pcm_t*epcm = runtime->private_data;415 static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, 416 struct snd_pcm_hw_params *hw_params) 417 { 418 struct snd_pcm_runtime *runtime = substream->runtime; 419 struct emu10k1x_pcm *epcm = runtime->private_data; 427 420 428 421 if (! epcm->voice) { … … 437 430 438 431 /* hw_free callback */ 439 static int snd_emu10k1x_pcm_hw_free(s nd_pcm_substream_t*substream)440 { 441 s nd_pcm_runtime_t*runtime = substream->runtime;442 emu10k1x_pcm_t*epcm;432 static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) 433 { 434 struct snd_pcm_runtime *runtime = substream->runtime; 435 struct emu10k1x_pcm *epcm; 443 436 444 437 if (runtime->private_data == NULL) … … 457 450 458 451 /* prepare callback */ 459 static int snd_emu10k1x_pcm_prepare(s nd_pcm_substream_t*substream)460 { 461 emu10k1x_t*emu = snd_pcm_substream_chip(substream);462 s nd_pcm_runtime_t*runtime = substream->runtime;463 emu10k1x_pcm_t*epcm = runtime->private_data;452 static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream) 453 { 454 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 455 struct snd_pcm_runtime *runtime = substream->runtime; 456 struct emu10k1x_pcm *epcm = runtime->private_data; 464 457 int voice = epcm->voice->number; 465 458 u32 *table_base = (u32 *)(emu->dma_buffer.area+1024*voice); … … 486 479 487 480 /* trigger callback */ 488 static int snd_emu10k1x_pcm_trigger(s nd_pcm_substream_t*substream,481 static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream, 489 482 int cmd) 490 483 { 491 emu10k1x_t*emu = snd_pcm_substream_chip(substream);492 s nd_pcm_runtime_t*runtime = substream->runtime;493 emu10k1x_pcm_t*epcm = runtime->private_data;484 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 485 struct snd_pcm_runtime *runtime = substream->runtime; 486 struct emu10k1x_pcm *epcm = runtime->private_data; 494 487 int channel = epcm->voice->number; 495 488 int result = 0; … … 520 513 /* pointer callback */ 521 514 static snd_pcm_uframes_t 522 snd_emu10k1x_pcm_pointer(s nd_pcm_substream_t*substream)523 { 524 emu10k1x_t*emu = snd_pcm_substream_chip(substream);525 s nd_pcm_runtime_t*runtime = substream->runtime;526 emu10k1x_pcm_t*epcm = runtime->private_data;515 snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream) 516 { 517 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 518 struct snd_pcm_runtime *runtime = substream->runtime; 519 struct emu10k1x_pcm *epcm = runtime->private_data; 527 520 int channel = epcm->voice->number; 528 521 snd_pcm_uframes_t ptr = 0, ptr1 = 0, ptr2= 0,ptr3 = 0,ptr4 = 0; … … 551 544 552 545 /* operators */ 553 static snd_pcm_ops_t snd_emu10k1x_playback_ops = { 554 /*.open = */ snd_emu10k1x_playback_open, 555 /*.close = */ snd_emu10k1x_playback_close, 556 /*.ioctl = */ snd_pcm_lib_ioctl, 557 /*.hw_params = */ snd_emu10k1x_pcm_hw_params, 558 /*.hw_free = */ snd_emu10k1x_pcm_hw_free, 559 /*.prepare = */ snd_emu10k1x_pcm_prepare, 560 /*.trigger = */ snd_emu10k1x_pcm_trigger, 561 /*.pointer = */ snd_emu10k1x_pcm_pointer, 562 0,0,0,0 546 static struct snd_pcm_ops snd_emu10k1x_playback_ops = { 547 .open = snd_emu10k1x_playback_open, 548 .close = snd_emu10k1x_playback_close, 549 .ioctl = snd_pcm_lib_ioctl, 550 .hw_params = snd_emu10k1x_pcm_hw_params, 551 .hw_free = snd_emu10k1x_pcm_hw_free, 552 .prepare = snd_emu10k1x_pcm_prepare, 553 .trigger = snd_emu10k1x_pcm_trigger, 554 .pointer = snd_emu10k1x_pcm_pointer, 563 555 }; 564 556 565 557 /* open_capture callback */ 566 static int snd_emu10k1x_pcm_open_capture(s nd_pcm_substream_t*substream)567 { 568 emu10k1x_t*chip = snd_pcm_substream_chip(substream);569 emu10k1x_pcm_t*epcm;570 s nd_pcm_runtime_t*runtime = substream->runtime;558 static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream) 559 { 560 struct emu10k1x *chip = snd_pcm_substream_chip(substream); 561 struct emu10k1x_pcm *epcm; 562 struct snd_pcm_runtime *runtime = substream->runtime; 571 563 int err; 572 564 … … 576 568 return err; 577 569 578 epcm =kzalloc(sizeof(*epcm), GFP_KERNEL);570 epcm = (struct emu10k1x_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 579 571 if (epcm == NULL) 580 572 return -ENOMEM; … … 592 584 593 585 /* close callback */ 594 static int snd_emu10k1x_pcm_close_capture(s nd_pcm_substream_t*substream)586 static int snd_emu10k1x_pcm_close_capture(struct snd_pcm_substream *substream) 595 587 { 596 588 return 0; … … 598 590 599 591 /* hw_params callback */ 600 static int snd_emu10k1x_pcm_hw_params_capture(s nd_pcm_substream_t*substream,601 s nd_pcm_hw_params_t *hw_params)602 { 603 s nd_pcm_runtime_t*runtime = substream->runtime;604 emu10k1x_pcm_t*epcm = runtime->private_data;592 static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substream, 593 struct snd_pcm_hw_params *hw_params) 594 { 595 struct snd_pcm_runtime *runtime = substream->runtime; 596 struct emu10k1x_pcm *epcm = runtime->private_data; 605 597 606 598 if (! epcm->voice) { … … 617 609 618 610 /* hw_free callback */ 619 static int snd_emu10k1x_pcm_hw_free_capture(s nd_pcm_substream_t*substream)620 { 621 s nd_pcm_runtime_t*runtime = substream->runtime;622 623 emu10k1x_pcm_t*epcm;611 static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) 612 { 613 struct snd_pcm_runtime *runtime = substream->runtime; 614 615 struct emu10k1x_pcm *epcm; 624 616 625 617 if (runtime->private_data == NULL) … … 637 629 638 630 /* prepare capture callback */ 639 static int snd_emu10k1x_pcm_prepare_capture(s nd_pcm_substream_t*substream)640 { 641 emu10k1x_t*emu = snd_pcm_substream_chip(substream);642 s nd_pcm_runtime_t*runtime = substream->runtime;631 static int snd_emu10k1x_pcm_prepare_capture(struct snd_pcm_substream *substream) 632 { 633 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 634 struct snd_pcm_runtime *runtime = substream->runtime; 643 635 644 636 snd_emu10k1x_ptr_write(emu, CAPTURE_DMA_ADDR, 0, runtime->dma_addr); … … 651 643 652 644 /* trigger_capture callback */ 653 static int snd_emu10k1x_pcm_trigger_capture(s nd_pcm_substream_t*substream,645 static int snd_emu10k1x_pcm_trigger_capture(struct snd_pcm_substream *substream, 654 646 int cmd) 655 647 { 656 emu10k1x_t*emu = snd_pcm_substream_chip(substream);657 s nd_pcm_runtime_t*runtime = substream->runtime;658 emu10k1x_pcm_t*epcm = runtime->private_data;648 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 649 struct snd_pcm_runtime *runtime = substream->runtime; 650 struct emu10k1x_pcm *epcm = runtime->private_data; 659 651 int result = 0; 660 652 … … 681 673 /* pointer_capture callback */ 682 674 static snd_pcm_uframes_t 683 snd_emu10k1x_pcm_pointer_capture(s nd_pcm_substream_t*substream)684 { 685 emu10k1x_t*emu = snd_pcm_substream_chip(substream);686 s nd_pcm_runtime_t*runtime = substream->runtime;687 emu10k1x_pcm_t*epcm = runtime->private_data;675 snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream) 676 { 677 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 678 struct snd_pcm_runtime *runtime = substream->runtime; 679 struct emu10k1x_pcm *epcm = runtime->private_data; 688 680 snd_pcm_uframes_t ptr; 689 681 … … 698 690 } 699 691 700 static snd_pcm_ops_t snd_emu10k1x_capture_ops = { 701 /*.open = */ snd_emu10k1x_pcm_open_capture, 702 /*.close = */ snd_emu10k1x_pcm_close_capture, 703 /*.ioctl = */ snd_pcm_lib_ioctl, 704 /*.hw_params = */ snd_emu10k1x_pcm_hw_params_capture, 705 /*.hw_free = */ snd_emu10k1x_pcm_hw_free_capture, 706 /*.prepare = */ snd_emu10k1x_pcm_prepare_capture, 707 /*.trigger = */ snd_emu10k1x_pcm_trigger_capture, 708 /*.pointer = */ snd_emu10k1x_pcm_pointer_capture, 709 0,0,0,0 692 static struct snd_pcm_ops snd_emu10k1x_capture_ops = { 693 .open = snd_emu10k1x_pcm_open_capture, 694 .close = snd_emu10k1x_pcm_close_capture, 695 .ioctl = snd_pcm_lib_ioctl, 696 .hw_params = snd_emu10k1x_pcm_hw_params_capture, 697 .hw_free = snd_emu10k1x_pcm_hw_free_capture, 698 .prepare = snd_emu10k1x_pcm_prepare_capture, 699 .trigger = snd_emu10k1x_pcm_trigger_capture, 700 .pointer = snd_emu10k1x_pcm_pointer_capture, 710 701 }; 711 702 712 static unsigned short snd_emu10k1x_ac97_read( ac97_t*ac97,703 static unsigned short snd_emu10k1x_ac97_read(struct snd_ac97 *ac97, 713 704 unsigned short reg) 714 705 { 715 emu10k1x_t*emu = ac97->private_data;706 struct emu10k1x *emu = ac97->private_data; 716 707 unsigned long flags; 717 708 unsigned short val; … … 724 715 } 725 716 726 static void snd_emu10k1x_ac97_write( ac97_t*ac97,717 static void snd_emu10k1x_ac97_write(struct snd_ac97 *ac97, 727 718 unsigned short reg, unsigned short val) 728 719 { 729 emu10k1x_t*emu = ac97->private_data;720 struct emu10k1x *emu = ac97->private_data; 730 721 unsigned long flags; 731 722 … … 736 727 } 737 728 738 static int snd_emu10k1x_ac97( emu10k1x_t*chip)739 { 740 ac97_bus_t*pbus;741 ac97_template_tac97;729 static int snd_emu10k1x_ac97(struct emu10k1x *chip) 730 { 731 struct snd_ac97_bus *pbus; 732 struct snd_ac97_template ac97; 742 733 int err; 743 static ac97_bus_ops_t ops = { 744 0, 745 /*.write = */snd_emu10k1x_ac97_write, 746 /*.read = */snd_emu10k1x_ac97_read, 0,0 734 static struct snd_ac97_bus_ops ops = { 735 .write = snd_emu10k1x_ac97_write, 736 .read = snd_emu10k1x_ac97_read, 747 737 }; 748 738 … … 757 747 } 758 748 759 static int snd_emu10k1x_free( emu10k1x_t*chip)749 static int snd_emu10k1x_free(struct emu10k1x *chip) 760 750 { 761 751 snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0); … … 766 756 767 757 // release the i/o port 768 if (chip->res_port) { 769 release_resource(chip->res_port); 770 kfree_nocheck(chip->res_port); 771 } 758 release_and_free_resource(chip->res_port); 759 772 760 // release the irq 773 761 if (chip->irq >= 0) … … 786 774 } 787 775 788 static int snd_emu10k1x_dev_free(s nd_device_t*device)789 { 790 emu10k1x_t*chip = device->device_data;776 static int snd_emu10k1x_dev_free(struct snd_device *device) 777 { 778 struct emu10k1x *chip = device->device_data; 791 779 return snd_emu10k1x_free(chip); 792 780 } … … 797 785 unsigned int status; 798 786 799 emu10k1x_t*chip = dev_id;800 emu10k1x_voice_t*pvoice = chip->voices;787 struct emu10k1x *chip = dev_id; 788 struct emu10k1x_voice *pvoice = chip->voices; 801 789 int i; 802 790 int mask; … … 804 792 status = inl(chip->port + IPR); 805 793 806 if(status) { 807 // capture interrupt 808 if(status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { 809 emu10k1x_voice_t *pvoice = &chip->capture_voice; 810 if(pvoice->use) 794 if (! status) 795 return IRQ_NONE; 796 797 // capture interrupt 798 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { 799 struct emu10k1x_voice *pvoice = &chip->capture_voice; 800 if (pvoice->use) 801 snd_emu10k1x_pcm_interrupt(chip, pvoice); 802 else 803 snd_emu10k1x_intr_disable(chip, 804 INTE_CAP_0_LOOP | 805 INTE_CAP_0_HALF_LOOP); 806 } 807 808 mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; 809 for (i = 0; i < 3; i++) { 810 if (status & mask) { 811 if (pvoice->use) 811 812 snd_emu10k1x_pcm_interrupt(chip, pvoice); 812 else 813 snd_emu10k1x_intr_disable(chip, 814 INTE_CAP_0_LOOP | 815 INTE_CAP_0_HALF_LOOP); 813 else 814 snd_emu10k1x_intr_disable(chip, mask); 816 815 } 816 pvoice++; 817 mask <<= 1; 818 } 817 819 818 mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; 819 for(i = 0; i < 3; i++) { 820 if(status & mask) { 821 if(pvoice->use) 822 snd_emu10k1x_pcm_interrupt(chip, pvoice); 823 else 824 snd_emu10k1x_intr_disable(chip, mask); 825 } 826 pvoice++; 827 mask <<= 1; 828 } 820 if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { 821 if (chip->midi.interrupt) 822 chip->midi.interrupt(chip, status); 823 else 824 snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); 825 } 829 826 830 if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { 831 if (chip->midi.interrupt) 832 chip->midi.interrupt(chip, status); 833 else 834 snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); 835 } 836 837 // acknowledge the interrupt if necessary 838 if(status) 839 outl(status, chip->port+IPR); 840 841 // snd_printk(KERN_INFO "interrupt %08x\n", status); 842 } 843 827 // acknowledge the interrupt if necessary 828 outl(status, chip->port + IPR); 829 830 // snd_printk(KERN_INFO "interrupt %08x\n", status); 844 831 return IRQ_HANDLED; 845 832 } 846 833 847 static void snd_emu10k1x_pcm_free(snd_pcm_t *pcm) 848 { 849 emu10k1x_t *emu = pcm->private_data; 850 emu->pcm = NULL; 851 snd_pcm_lib_preallocate_free_for_all(pcm); 852 } 853 854 static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **rpcm) 855 { 856 snd_pcm_t *pcm; 834 static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) 835 { 836 struct snd_pcm *pcm; 857 837 int err; 858 838 int capture = 0; … … 867 847 868 848 pcm->private_data = emu; 869 pcm->private_free = snd_emu10k1x_pcm_free;870 849 871 850 switch(device) { … … 905 884 } 906 885 907 static int __devinit snd_emu10k1x_create(s nd_card_t*card,886 static int __devinit snd_emu10k1x_create(struct snd_card *card, 908 887 struct pci_dev *pci, 909 emu10k1x_t**rchip)910 { 911 emu10k1x_t*chip;888 struct emu10k1x **rchip) 889 { 890 struct emu10k1x *chip; 912 891 int err; 913 892 int ch; 914 static s nd_device_ops_tops = {915 /*.dev_free = */snd_emu10k1x_dev_free,0,0,0893 static struct snd_device_ops ops = { 894 .dev_free = snd_emu10k1x_dev_free, 916 895 }; 917 896 … … 920 899 if ((err = pci_enable_device(pci)) < 0) 921 900 return err; 922 923 924 chip =kzalloc(sizeof(*chip), GFP_KERNEL);901 pci_set_dma_mask(pci, 0x0fffffff); 902 903 chip = (struct emu10k1x *)kzalloc(sizeof(*chip), GFP_KERNEL); 925 904 if (chip == NULL) { 926 905 pci_disable_device(pci); … … 1021 1000 } 1022 1001 1023 static void snd_emu10k1x_proc_reg_read(s nd_info_entry_t*entry,1024 s nd_info_buffer_t *buffer)1025 { 1026 emu10k1x_t*emu = entry->private_data;1002 static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, 1003 struct snd_info_buffer *buffer) 1004 { 1005 struct emu10k1x *emu = entry->private_data; 1027 1006 unsigned long value,value1,value2; 1028 1007 unsigned long flags; … … 1049 1028 } 1050 1029 1051 static void snd_emu10k1x_proc_reg_write(s nd_info_entry_t*entry,1052 s nd_info_buffer_t*buffer)1053 { 1054 emu10k1x_t*emu = entry->private_data;1030 static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, 1031 struct snd_info_buffer *buffer) 1032 { 1033 struct emu10k1x *emu = entry->private_data; 1055 1034 char line[64]; 1056 1035 unsigned int reg, channel_id , val; 1057 1036 #if 0 1058 1037 while (!snd_info_get_line(buffer, line, sizeof(line))) { 1059 1038 if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) … … 1063 1042 && (channel_id >=0) && (channel_id <= 2) ) 1064 1043 snd_emu10k1x_ptr_write(emu, reg, channel_id, val); 1065 } 1066 } 1067 1068 static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) 1069 { 1070 snd_info_entry_t *entry; 1044 } 1045 #endif 1046 } 1047 1048 static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) 1049 { 1050 struct snd_info_entry *entry; 1071 1051 1072 1052 if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { … … 1074 1054 entry->c.text.write_size = 64; 1075 1055 entry->c.text.write = snd_emu10k1x_proc_reg_write; 1056 entry->mode |= S_IWUSR; 1076 1057 entry->private_data = emu; 1077 1058 } … … 1080 1061 } 1081 1062 1082 static int snd_emu10k1x_shared_spdif_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)1063 static int snd_emu10k1x_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1083 1064 { 1084 1065 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; … … 1089 1070 } 1090 1071 1091 static int snd_emu10k1x_shared_spdif_get(s nd_kcontrol_t *kcontrol,1092 s nd_ctl_elem_value_t *ucontrol)1093 { 1094 emu10k1x_t*emu = snd_kcontrol_chip(kcontrol);1072 static int snd_emu10k1x_shared_spdif_get(struct snd_kcontrol *kcontrol, 1073 struct snd_ctl_elem_value *ucontrol) 1074 { 1075 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1095 1076 1096 1077 ucontrol->value.integer.value[0] = (snd_emu10k1x_ptr_read(emu, SPDIF_SELECT, 0) == 0x700) ? 0 : 1; … … 1099 1080 } 1100 1081 1101 static int snd_emu10k1x_shared_spdif_put(s nd_kcontrol_t *kcontrol,1102 s nd_ctl_elem_value_t *ucontrol)1103 { 1104 emu10k1x_t*emu = snd_kcontrol_chip(kcontrol);1082 static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, 1083 struct snd_ctl_elem_value *ucontrol) 1084 { 1085 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1105 1086 unsigned int val; 1106 1087 int change = 0; … … 1122 1103 } 1123 1104 1124 static s nd_kcontrol_new_tsnd_emu10k1x_shared_spdif __devinitdata =1125 { 1126 /*.iface = */ SNDRV_CTL_ELEM_IFACE_MIXER,0,0,1127 /*.name = */ "Analog/Digital Output Jack",0,0,0,1128 /*.info = */snd_emu10k1x_shared_spdif_info,1129 /*.get = */snd_emu10k1x_shared_spdif_get,1130 /*.put = */ snd_emu10k1x_shared_spdif_put,01105 static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata = 1106 { 1107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1108 .name = "Analog/Digital Output Jack", 1109 .info = snd_emu10k1x_shared_spdif_info, 1110 .get = snd_emu10k1x_shared_spdif_get, 1111 .put = snd_emu10k1x_shared_spdif_put 1131 1112 }; 1132 1113 1133 static int snd_emu10k1x_spdif_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)1114 static int snd_emu10k1x_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1134 1115 { 1135 1116 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; … … 1138 1119 } 1139 1120 1140 static int snd_emu10k1x_spdif_get(s nd_kcontrol_t *kcontrol,1141 s nd_ctl_elem_value_t *ucontrol)1142 { 1143 emu10k1x_t*emu = snd_kcontrol_chip(kcontrol);1121 static int snd_emu10k1x_spdif_get(struct snd_kcontrol *kcontrol, 1122 struct snd_ctl_elem_value *ucontrol) 1123 { 1124 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1144 1125 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1145 1126 … … 1151 1132 } 1152 1133 1153 static int snd_emu10k1x_spdif_get_mask(s nd_kcontrol_t *kcontrol,1154 s nd_ctl_elem_value_t *ucontrol)1134 static int snd_emu10k1x_spdif_get_mask(struct snd_kcontrol *kcontrol, 1135 struct snd_ctl_elem_value *ucontrol) 1155 1136 { 1156 1137 ucontrol->value.iec958.status[0] = 0xff; … … 1161 1142 } 1162 1143 1163 static int snd_emu10k1x_spdif_put(s nd_kcontrol_t *kcontrol,1164 s nd_ctl_elem_value_t *ucontrol)1165 { 1166 emu10k1x_t*emu = snd_kcontrol_chip(kcontrol);1144 static int snd_emu10k1x_spdif_put(struct snd_kcontrol *kcontrol, 1145 struct snd_ctl_elem_value *ucontrol) 1146 { 1147 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1167 1148 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1168 1149 int change; … … 1181 1162 } 1182 1163 1183 static s nd_kcontrol_new_tsnd_emu10k1x_spdif_mask_control =1184 { 1185 /*.iface = */ SNDRV_CTL_ELEM_IFACE_MIXER,0,0,1186 /*.name = */ SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),0,1187 /*.access =*/ SNDRV_CTL_ELEM_ACCESS_READ,1188 /*.count = */3,1189 /*.info = */snd_emu10k1x_spdif_info,1190 /*.get = */ snd_emu10k1x_spdif_get_mask,0,01164 static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control = 1165 { 1166 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1167 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1168 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), 1169 .count = 3, 1170 .info = snd_emu10k1x_spdif_info, 1171 .get = snd_emu10k1x_spdif_get_mask 1191 1172 }; 1192 1173 1193 static s nd_kcontrol_new_tsnd_emu10k1x_spdif_control =1194 { 1195 /*.iface = */ SNDRV_CTL_ELEM_IFACE_MIXER,0,0,1196 /*.name = */ SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),0,0,1197 /*.count = */3,1198 /*.info = */snd_emu10k1x_spdif_info,1199 /*.get = */snd_emu10k1x_spdif_get,1200 /*.put = */ snd_emu10k1x_spdif_put,01174 static struct snd_kcontrol_new snd_emu10k1x_spdif_control = 1175 { 1176 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1177 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1178 .count = 3, 1179 .info = snd_emu10k1x_spdif_info, 1180 .get = snd_emu10k1x_spdif_get, 1181 .put = snd_emu10k1x_spdif_put 1201 1182 }; 1202 1183 1203 static int __devinit snd_emu10k1x_mixer( emu10k1x_t*emu)1184 static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu) 1204 1185 { 1205 1186 int err; 1206 s nd_kcontrol_t*kctl;1207 s nd_card_t*card = emu->card;1187 struct snd_kcontrol *kctl; 1188 struct snd_card *card = emu->card; 1208 1189 1209 1190 if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL) … … 1226 1207 #define EMU10K1X_MIDI_MODE_OUTPUT (1<<1) 1227 1208 1228 static inline unsigned char mpu401_read( emu10k1x_t *emu, emu10k1x_midi_t*mpu, int idx)1209 static inline unsigned char mpu401_read(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int idx) 1229 1210 { 1230 1211 return (unsigned char)snd_emu10k1x_ptr_read(emu, mpu->port + idx, 0); 1231 1212 } 1232 1213 1233 static inline void mpu401_write( emu10k1x_t *emu, emu10k1x_midi_t*mpu, int data, int idx)1214 static inline void mpu401_write(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int data, int idx) 1234 1215 { 1235 1216 snd_emu10k1x_ptr_write(emu, mpu->port + idx, 0, data); … … 1248 1229 #define MPU401_ACK 0xfe 1249 1230 1250 static void mpu401_clear_rx( emu10k1x_t *emu, emu10k1x_midi_t*mpu)1231 static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu) 1251 1232 { 1252 1233 int timeout = 100000; … … 1263 1244 */ 1264 1245 1265 static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, unsigned int status) 1246 static void do_emu10k1x_midi_interrupt(struct emu10k1x *emu, 1247 struct emu10k1x_midi *midi, unsigned int status) 1266 1248 { 1267 1249 unsigned char byte; … … 1296 1278 } 1297 1279 1298 static void snd_emu10k1x_midi_interrupt( emu10k1x_t*emu, unsigned int status)1280 static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int status) 1299 1281 { 1300 1282 do_emu10k1x_midi_interrupt(emu, &emu->midi, status); 1301 1283 } 1302 1284 1303 static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsigned char cmd, int ack) 1285 static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, 1286 struct emu10k1x_midi *midi, unsigned char cmd, int ack) 1304 1287 { 1305 1288 unsigned long flags; … … 1333 1316 } 1334 1317 1335 static int snd_emu10k1x_midi_input_open(s nd_rawmidi_substream_t *substream)1336 { 1337 emu10k1x_t*emu;1338 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;1318 static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) 1319 { 1320 struct emu10k1x *emu; 1321 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1339 1322 unsigned long flags; 1340 1323 … … 1354 1337 } 1355 1338 1356 static int snd_emu10k1x_midi_output_open(s nd_rawmidi_substream_t *substream)1357 { 1358 emu10k1x_t*emu;1359 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;1339 static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) 1340 { 1341 struct emu10k1x *emu; 1342 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1360 1343 unsigned long flags; 1361 1344 … … 1375 1358 } 1376 1359 1377 static int snd_emu10k1x_midi_input_close(s nd_rawmidi_substream_t *substream)1378 { 1379 emu10k1x_t*emu;1380 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;1360 static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) 1361 { 1362 struct emu10k1x *emu; 1363 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1381 1364 unsigned long flags; 1382 1365 … … 1396 1379 } 1397 1380 1398 static int snd_emu10k1x_midi_output_close(s nd_rawmidi_substream_t *substream)1399 { 1400 emu10k1x_t*emu;1401 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;1381 static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) 1382 { 1383 struct emu10k1x *emu; 1384 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1402 1385 unsigned long flags; 1403 1386 … … 1417 1400 } 1418 1401 1419 static void snd_emu10k1x_midi_input_trigger(s nd_rawmidi_substream_t *substream, int up)1420 { 1421 emu10k1x_t*emu;1422 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;1402 static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 1403 { 1404 struct emu10k1x *emu; 1405 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1423 1406 emu = midi->emu; 1424 1407 snd_assert(emu, return); … … 1430 1413 } 1431 1414 1432 static void snd_emu10k1x_midi_output_trigger(s nd_rawmidi_substream_t *substream, int up)1433 { 1434 emu10k1x_t*emu;1435 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;1415 static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) 1416 { 1417 struct emu10k1x *emu; 1418 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1436 1419 unsigned long flags; 1437 1420 … … 1470 1453 */ 1471 1454 1472 static s nd_rawmidi_ops_tsnd_emu10k1x_midi_output =1473 { 1474 snd_emu10k1x_midi_output_open,1475 snd_emu10k1x_midi_output_close,1476 snd_emu10k1x_midi_output_trigger,01455 static struct snd_rawmidi_ops snd_emu10k1x_midi_output = 1456 { 1457 .open = snd_emu10k1x_midi_output_open, 1458 .close = snd_emu10k1x_midi_output_close, 1459 .trigger = snd_emu10k1x_midi_output_trigger, 1477 1460 }; 1478 1461 1479 static s nd_rawmidi_ops_tsnd_emu10k1x_midi_input =1480 { 1481 snd_emu10k1x_midi_input_open,1482 snd_emu10k1x_midi_input_close,1483 snd_emu10k1x_midi_input_trigger,01462 static struct snd_rawmidi_ops snd_emu10k1x_midi_input = 1463 { 1464 .open = snd_emu10k1x_midi_input_open, 1465 .close = snd_emu10k1x_midi_input_close, 1466 .trigger = snd_emu10k1x_midi_input_trigger, 1484 1467 }; 1485 1468 1486 static void snd_emu10k1x_midi_free(s nd_rawmidi_t*rmidi)1487 { 1488 emu10k1x_midi_t *midi = (emu10k1x_midi_t *)rmidi->private_data;1469 static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi) 1470 { 1471 struct emu10k1x_midi *midi = rmidi->private_data; 1489 1472 midi->interrupt = NULL; 1490 1473 midi->rmidi = NULL; 1491 1474 } 1492 1475 1493 static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, int device, char *name) 1494 { 1495 snd_rawmidi_t *rmidi; 1476 static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, 1477 struct emu10k1x_midi *midi, int device, char *name) 1478 { 1479 struct snd_rawmidi *rmidi; 1496 1480 int err; 1497 1481 … … 1514 1498 } 1515 1499 1516 static int __devinit snd_emu10k1x_midi( emu10k1x_t*emu)1517 { 1518 emu10k1x_midi_t*midi = &emu->midi;1500 static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu) 1501 { 1502 struct emu10k1x_midi *midi = &emu->midi; 1519 1503 int err; 1520 1504 … … 1535 1519 { 1536 1520 static int dev; 1537 s nd_card_t*card;1538 emu10k1x_t*chip;1521 struct snd_card *card; 1522 struct emu10k1x *chip; 1539 1523 int err; 1540 1524 … … 1615 1599 // pci_driver definition 1616 1600 static struct pci_driver driver = { 1617 0,0,0, 1618 /*.name = */"EMU10K1X", 1619 /*.id_table = */snd_emu10k1x_ids, 1620 /*.probe = */snd_emu10k1x_probe, 1621 /*.remove = */snd_emu10k1x_remove, 1622 0,0 1601 .name = "EMU10K1X", 1602 .id_table = snd_emu10k1x_ids, 1603 .probe = snd_emu10k1x_probe, 1604 .remove = snd_emu10k1x_remove, 1623 1605 }; 1624 1606 … … 1628 1610 int err; 1629 1611 1630 if ((err = pci_ module_init(&driver)) > 0)1612 if ((err = pci_register_driver(&driver)) > 0) 1631 1613 return err; 1632 1614
Note:
See TracChangeset
for help on using the changeset viewer.