Changeset 70 for GPL/trunk/alsa-kernel/pci/atiixp.c
- Timestamp:
- Jan 14, 2006, 6:38:48 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/pci/atiixp.c
r32 r70 27 27 #include <linux/pci.h> 28 28 #include <linux/slab.h> 29 #include <linux/moduleparam.h> 29 30 #include <sound/core.h> 30 31 #include <sound/pcm.h> … … 39 40 MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400}}"); 40 41 41 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 42 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 43 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 44 static int ac97_clock[SNDRV_CARDS] = {48000,0,0,0,0,0,0,0}; 45 static char *ac97_quirk[SNDRV_CARDS]; 46 static int spdif_aclink[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; 47 48 //module_param_array(index, int, NULL, 0444); 42 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 43 static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 44 static int ac97_clock = 48000; 45 static char *ac97_quirk; 46 static int spdif_aclink = 1; 47 48 //module_param(index, int, 0444); 49 49 MODULE_PARM_DESC(index, "Index value for ATI IXP controller."); 50 //module_param _array(id, charp, NULL, 0444);50 //module_param(id, charp, 0444); 51 51 MODULE_PARM_DESC(id, "ID string for ATI IXP controller."); 52 //module_param_array(enable, bool, NULL, 0444); 53 MODULE_PARM_DESC(enable, "Enable audio part of ATI IXP controller."); 54 //module_param_array(ac97_clock, int, NULL, 0444); 52 //module_param(ac97_clock, int, 0444); 55 53 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); 56 //module_param _array(ac97_quirk, charp, NULL, 0444);54 //module_param(ac97_quirk, charp, 0444); 57 55 MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); 58 //module_param _array(spdif_aclink, bool, NULL, 0444);56 //module_param(spdif_aclink, bool, 0444); 59 57 MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); 58 59 /* just for backward compatibility */ 60 static int enable; 61 //module_param(enable, bool, 0444); 60 62 61 63 … … 196 198 197 199 198 /* 199 */ 200 201 typedef struct snd_atiixp atiixp_t; 202 typedef struct snd_atiixp_dma atiixp_dma_t; 203 typedef struct snd_atiixp_dma_ops atiixp_dma_ops_t; 204 200 struct atiixp; 205 201 206 202 /* … … 208 204 */ 209 205 210 typedefstruct atiixp_dma_desc {206 struct atiixp_dma_desc { 211 207 u32 addr; /* DMA buffer address */ 212 208 u16 status; /* status bits */ 213 209 u16 size; /* size of the packet in dwords */ 214 210 u32 next; /* address of the next packet descriptor */ 215 } atiixp_dma_desc_t;211 }; 216 212 217 213 /* … … 228 224 * constants and callbacks for each DMA type 229 225 */ 230 struct snd_atiixp_dma_ops {226 struct atiixp_dma_ops { 231 227 int type; /* ATI_DMA_XXX */ 232 228 unsigned int llp_offset; /* LINKPTR offset */ 233 229 unsigned int dt_cur; /* DT_CUR offset */ 234 void (*enable_dma)(atiixp_t *chip, int on); /* called from open callback */ 235 void (*enable_transfer)(atiixp_t *chip, int on); /* called from trigger (START/STOP) */ 236 void (*flush_dma)(atiixp_t *chip); /* called from trigger (STOP only) */ 230 /* called from open callback */ 231 void (*enable_dma)(struct atiixp *chip, int on); 232 /* called from trigger (START/STOP) */ 233 void (*enable_transfer)(struct atiixp *chip, int on); 234 /* called from trigger (STOP only) */ 235 void (*flush_dma)(struct atiixp *chip); 237 236 }; 238 237 … … 240 239 * DMA stream 241 240 */ 242 struct snd_atiixp_dma {243 const atiixp_dma_ops_t*ops;241 struct atiixp_dma { 242 const struct atiixp_dma_ops *ops; 244 243 struct snd_dma_buffer desc_buf; 245 s nd_pcm_substream_t*substream; /* assigned PCM substream */244 struct snd_pcm_substream *substream; /* assigned PCM substream */ 246 245 unsigned int buf_addr, buf_bytes; /* DMA buffer address, bytes */ 247 246 unsigned int period_bytes, periods; 248 247 int opened; 249 250 248 int running; 249 int suspended; 251 250 int pcm_open_flag; 252 253 251 int ac97_pcm_type; /* index # of ac97_pcm to access, -1 = not used */ 252 unsigned int saved_curptr; 254 253 }; 255 254 … … 257 256 * ATI IXP chip 258 257 */ 259 struct snd_atiixp {260 s nd_card_t*card;258 struct atiixp { 259 struct snd_card *card; 261 260 struct pci_dev *pci; 262 261 … … 264 263 void __iomem *remap_addr; 265 264 int irq; 266 267 ac97_bus_t*ac97_bus;268 ac97_t*ac97[NUM_ATI_CODECS];265 266 struct snd_ac97_bus *ac97_bus; 267 struct snd_ac97 *ac97[NUM_ATI_CODECS]; 269 268 270 269 spinlock_t reg_lock; 271 270 272 atiixp_dma_tdmas[NUM_ATI_DMAS];271 struct atiixp_dma dmas[NUM_ATI_DMAS]; 273 272 struct ac97_pcm *pcms[NUM_ATI_PCMS]; 274 s nd_pcm_t*pcmdevs[NUM_ATI_PCMDEVS];273 struct snd_pcm *pcmdevs[NUM_ATI_PCMDEVS]; 275 274 276 275 int max_channels; /* max. channels for PCM out */ … … 303 302 * return 1 if the bits changed. 304 303 */ 305 static int snd_atiixp_update_bits( atiixp_t*chip, unsigned int reg,304 static int snd_atiixp_update_bits(struct atiixp *chip, unsigned int reg, 306 305 unsigned int mask, unsigned int value) 307 306 { 308 void __iomem *addr = (char 307 void __iomem *addr = (char*)chip->remap_addr + reg; 309 308 unsigned int data, old_data; 310 309 old_data = data = readl(addr); … … 321 320 */ 322 321 #define atiixp_write(chip,reg,value) \ 323 writel(value, (char 322 writel(value, (char*)chip->remap_addr + ATI_REG_##reg) 324 323 #define atiixp_read(chip,reg) \ 325 readl((char 324 readl((char*)chip->remap_addr + ATI_REG_##reg) 326 325 #define atiixp_update(chip,reg,mask,val) \ 327 326 snd_atiixp_update_bits(chip, ATI_REG_##reg, mask, val) … … 335 334 336 335 #define ATI_DESC_LIST_SIZE \ 337 PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof( atiixp_dma_desc_t))336 PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(struct atiixp_dma_desc)) 338 337 339 338 /* … … 344 343 * a static RING of buffer descriptors is used. 345 344 * 346 * the ring is built in this function, and is set up to the hardware. 347 */ 348 static int atiixp_build_dma_packets( atiixp_t *chip, atiixp_dma_t*dma,349 snd_pcm_substream_t*substream,350 unsigned int periods,351 unsigned int period_bytes)345 * the ring is built in this function, and is set up to the hardware. 346 */ 347 static int atiixp_build_dma_packets(struct atiixp *chip, struct atiixp_dma *dma, 348 struct snd_pcm_substream *substream, 349 unsigned int periods, 350 unsigned int period_bytes) 352 351 { 353 352 unsigned int i; … … 359 358 360 359 if (dma->desc_buf.area == NULL) { 361 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 362 ATI_DESC_LIST_SIZE, &dma->desc_buf) < 0) 360 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 361 snd_dma_pci_data(chip->pci), 362 ATI_DESC_LIST_SIZE, 363 &dma->desc_buf) < 0) 363 364 return -ENOMEM; 364 365 dma->period_bytes = dma->periods = 0; /* clear */ … … 370 371 /* reset DMA before changing the descriptor table */ 371 372 spin_lock_irqsave(&chip->reg_lock, flags); 372 writel(0, (char 373 writel(0, (char*)chip->remap_addr + dma->ops->llp_offset); 373 374 dma->ops->enable_dma(chip, 0); 374 375 dma->ops->enable_dma(chip, 1); … … 379 380 desc_addr = (u32)dma->desc_buf.addr; 380 381 for (i = 0; i < periods; i++) { 381 atiixp_dma_desc_t *desc = &((atiixp_dma_desc_t *)dma->desc_buf.area)[i]; 382 struct atiixp_dma_desc *desc; 383 desc = &((struct atiixp_dma_desc *)dma->desc_buf.area)[i]; 382 384 desc->addr = cpu_to_le32(addr); 383 385 desc->status = 0; 384 386 desc->size = period_bytes >> 2; /* in dwords */ 385 desc_addr += sizeof( atiixp_dma_desc_t);387 desc_addr += sizeof(struct atiixp_dma_desc); 386 388 if (i == periods - 1) 387 389 desc->next = cpu_to_le32((u32)dma->desc_buf.addr); … … 392 394 393 395 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 394 (char 396 (char*)chip->remap_addr + dma->ops->llp_offset); 395 397 396 398 dma->period_bytes = period_bytes; … … 403 405 * remove the ring buffer and release it if assigned 404 406 */ 405 static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, snd_pcm_substream_t *substream) 407 static void atiixp_clear_dma_packets(struct atiixp *chip, struct atiixp_dma *dma, 408 struct snd_pcm_substream *substream) 406 409 { 407 410 if (dma->desc_buf.area) { 408 writel(0, (char 411 writel(0, (char*)chip->remap_addr + dma->ops->llp_offset); 409 412 snd_dma_free_pages(&dma->desc_buf); 410 413 dma->desc_buf.area = NULL; … … 415 418 * AC97 interface 416 419 */ 417 static int snd_atiixp_acquire_codec( atiixp_t*chip)420 static int snd_atiixp_acquire_codec(struct atiixp *chip) 418 421 { 419 422 int timeout = 1000; … … 429 432 } 430 433 431 static unsigned short snd_atiixp_codec_read( atiixp_t*chip, unsigned short codec, unsigned short reg)434 static unsigned short snd_atiixp_codec_read(struct atiixp *chip, unsigned short codec, unsigned short reg) 432 435 { 433 436 unsigned int data; … … 457 460 458 461 459 static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigned short reg, unsigned short val) 462 static void snd_atiixp_codec_write(struct atiixp *chip, unsigned short codec, 463 unsigned short reg, unsigned short val) 460 464 { 461 465 unsigned int data; 462 466 463 467 if (snd_atiixp_acquire_codec(chip) < 0) 464 468 return; … … 470 474 471 475 472 static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg) 473 { 474 atiixp_t *chip = ac97->private_data; 475 return snd_atiixp_codec_read(chip, ac97->num, reg); 476 } 477 478 static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) 479 { 480 atiixp_t *chip = ac97->private_data; 476 static unsigned short snd_atiixp_ac97_read(struct snd_ac97 *ac97, 477 unsigned short reg) 478 { 479 struct atiixp *chip = ac97->private_data; 480 return snd_atiixp_codec_read(chip, ac97->num, reg); 481 482 } 483 484 static void snd_atiixp_ac97_write(struct snd_ac97 *ac97, unsigned short reg, 485 unsigned short val) 486 { 487 struct atiixp *chip = ac97->private_data; 481 488 snd_atiixp_codec_write(chip, ac97->num, reg, val); 482 489 } … … 485 492 * reset AC link 486 493 */ 487 static int snd_atiixp_aclink_reset( atiixp_t*chip)494 static int snd_atiixp_aclink_reset(struct atiixp *chip) 488 495 { 489 496 int timeout; … … 498 505 udelay(10); 499 506 atiixp_update(chip, CMD, ATI_REG_CMD_AC_SOFT_RESET, 0); 500 507 501 508 timeout = 10; 502 509 while (! (atiixp_read(chip, CMD) & ATI_REG_CMD_ACLINK_ACTIVE)) { … … 505 512 ATI_REG_CMD_AC_SYNC); 506 513 atiixp_read(chip, CMD); 507 m sleep(1);514 mdelay(1); 508 515 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); 509 516 if (--timeout) { … … 521 528 522 529 #ifdef CONFIG_PM 523 static int snd_atiixp_aclink_down( atiixp_t*chip)530 static int snd_atiixp_aclink_down(struct atiixp *chip) 524 531 { 525 532 // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */ … … 546 553 #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME) 547 554 548 static int snd_atiixp_codec_detect( atiixp_t*chip)555 static int snd_atiixp_codec_detect(struct atiixp *chip) 549 556 { 550 557 int timeout; … … 555 562 timeout = 50; 556 563 while (timeout-- > 0) { 557 m sleep(1);564 mdelay(1); 558 565 if (chip->codec_not_ready_bits) 559 566 break; … … 572 579 * enable DMA and irqs 573 580 */ 574 static int snd_atiixp_chip_start( atiixp_t*chip)581 static int snd_atiixp_chip_start(struct atiixp *chip) 575 582 { 576 583 unsigned int reg; … … 602 609 * disable DMA and IRQs 603 610 */ 604 static int snd_atiixp_chip_stop( atiixp_t*chip)611 static int snd_atiixp_chip_stop(struct atiixp *chip) 605 612 { 606 613 /* clear interrupt source */ … … 621 628 * correctly... 622 629 */ 623 static snd_pcm_uframes_t snd_atiixp_pcm_pointer(s nd_pcm_substream_t*substream)624 { 625 atiixp_t*chip = snd_pcm_substream_chip(substream);626 s nd_pcm_runtime_t*runtime = substream->runtime;627 atiixp_dma_t *dma = (atiixp_dma_t *)runtime->private_data;628 629 630 631 632 curptr = readl((char*)chip->remap_addr + dma->ops->dt_cur);633 634 635 636 637 638 639 640 641 642 630 static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substream) 631 { 632 struct atiixp *chip = snd_pcm_substream_chip(substream); 633 struct snd_pcm_runtime *runtime = substream->runtime; 634 struct atiixp_dma *dma = runtime->private_data; 635 unsigned int curptr; 636 int timeout = 1000; 637 638 while (timeout--) { 639 curptr = readl((char*)chip->remap_addr + dma->ops->dt_cur); 640 if (curptr < dma->buf_addr) 641 continue; 642 curptr -= dma->buf_addr; 643 if (curptr >= dma->buf_bytes) 644 continue; 645 return bytes_to_frames(runtime, curptr); 646 } 647 snd_printd("atiixp: invalid DMA pointer read 0x%x (buf=%x)\n", 648 readl((char*)chip->remap_addr + dma->ops->dt_cur), dma->buf_addr); 649 return 0; 643 650 } 644 651 … … 646 653 * XRUN detected, and stop the PCM substream 647 654 */ 648 static void snd_atiixp_xrun_dma( atiixp_t *chip, atiixp_dma_t*dma)655 static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma) 649 656 { 650 657 if (! dma->substream || ! dma->running) … … 657 664 * the period ack. update the substream. 658 665 */ 659 static void snd_atiixp_update_dma( atiixp_t *chip, atiixp_dma_t*dma)666 static void snd_atiixp_update_dma(struct atiixp *chip, struct atiixp_dma *dma) 660 667 { 661 668 if (! dma->substream || ! dma->running) … … 666 673 /* set BUS_BUSY interrupt bit if any DMA is running */ 667 674 /* call with spinlock held */ 668 static void snd_atiixp_check_bus_busy( atiixp_t*chip)675 static void snd_atiixp_check_bus_busy(struct atiixp *chip) 669 676 { 670 677 unsigned int bus_busy; … … 681 688 * calling the lowlevel callbacks in it 682 689 */ 683 static int snd_atiixp_pcm_trigger(s nd_pcm_substream_t*substream, int cmd)684 { 685 atiixp_t*chip = snd_pcm_substream_chip(substream);686 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;690 static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 691 { 692 struct atiixp *chip = snd_pcm_substream_chip(substream); 693 struct atiixp_dma *dma = substream->runtime->private_data; 687 694 int err = 0; 688 695 … … 691 698 spin_lock(&chip->reg_lock); 692 699 switch (cmd) { 693 694 695 700 case SNDRV_PCM_TRIGGER_START: 701 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 702 case SNDRV_PCM_TRIGGER_RESUME: 696 703 dma->ops->enable_transfer(chip, 1); 697 698 704 dma->running = 1; 705 dma->suspended = 0; 699 706 break; 700 701 702 707 case SNDRV_PCM_TRIGGER_STOP: 708 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 709 case SNDRV_PCM_TRIGGER_SUSPEND: 703 710 dma->ops->enable_transfer(chip, 0); 704 705 711 dma->running = 0; 712 dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND; 706 713 break; 707 714 default: … … 728 735 729 736 /* flush FIFO of analog OUT DMA */ 730 static void atiixp_out_flush_dma( atiixp_t*chip)737 static void atiixp_out_flush_dma(struct atiixp *chip) 731 738 { 732 739 atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_OUT_FLUSH); … … 734 741 735 742 /* enable/disable analog OUT DMA */ 736 static void atiixp_out_enable_dma( atiixp_t*chip, int on)743 static void atiixp_out_enable_dma(struct atiixp *chip, int on) 737 744 { 738 745 unsigned int data; … … 749 756 750 757 /* start/stop transfer over OUT DMA */ 751 static void atiixp_out_enable_transfer( atiixp_t*chip, int on)758 static void atiixp_out_enable_transfer(struct atiixp *chip, int on) 752 759 { 753 760 atiixp_update(chip, CMD, ATI_REG_CMD_SEND_EN, … … 756 763 757 764 /* enable/disable analog IN DMA */ 758 static void atiixp_in_enable_dma( atiixp_t*chip, int on)765 static void atiixp_in_enable_dma(struct atiixp *chip, int on) 759 766 { 760 767 atiixp_update(chip, CMD, ATI_REG_CMD_IN_DMA_EN, … … 763 770 764 771 /* start/stop analog IN DMA */ 765 static void atiixp_in_enable_transfer( atiixp_t*chip, int on)772 static void atiixp_in_enable_transfer(struct atiixp *chip, int on) 766 773 { 767 774 if (on) { … … 782 789 783 790 /* flush FIFO of analog IN DMA */ 784 static void atiixp_in_flush_dma( atiixp_t*chip)791 static void atiixp_in_flush_dma(struct atiixp *chip) 785 792 { 786 793 atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_IN_FLUSH); … … 788 795 789 796 /* enable/disable SPDIF OUT DMA */ 790 static void atiixp_spdif_enable_dma( atiixp_t*chip, int on)797 static void atiixp_spdif_enable_dma(struct atiixp *chip, int on) 791 798 { 792 799 atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_DMA_EN, … … 795 802 796 803 /* start/stop SPDIF OUT DMA */ 797 static void atiixp_spdif_enable_transfer( atiixp_t*chip, int on)804 static void atiixp_spdif_enable_transfer(struct atiixp *chip, int on) 798 805 { 799 806 unsigned int data; … … 807 814 808 815 /* flush FIFO of SPDIF OUT DMA */ 809 static void atiixp_spdif_flush_dma( atiixp_t*chip)816 static void atiixp_spdif_flush_dma(struct atiixp *chip) 810 817 { 811 818 int timeout; … … 814 821 atiixp_spdif_enable_dma(chip, 0); 815 822 atiixp_spdif_enable_transfer(chip, 1); 816 823 817 824 timeout = 100; 818 825 do { … … 826 833 827 834 /* set up slots and formats for SPDIF OUT */ 828 static int snd_atiixp_spdif_prepare(s nd_pcm_substream_t*substream)829 { 830 atiixp_t*chip = snd_pcm_substream_chip(substream);835 static int snd_atiixp_spdif_prepare(struct snd_pcm_substream *substream) 836 { 837 struct atiixp *chip = snd_pcm_substream_chip(substream); 831 838 832 839 spin_lock_irq(&chip->reg_lock); … … 853 860 854 861 /* set up slots and formats for analog OUT */ 855 static int snd_atiixp_playback_prepare(s nd_pcm_substream_t*substream)856 { 857 atiixp_t*chip = snd_pcm_substream_chip(substream);862 static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream) 863 { 864 struct atiixp *chip = snd_pcm_substream_chip(substream); 858 865 unsigned int data; 859 866 … … 892 899 atiixp_update(chip, 6CH_REORDER, ATI_REG_6CH_REORDER_EN, 893 900 substream->runtime->channels >= 6 ? ATI_REG_6CH_REORDER_EN: 0); 894 901 895 902 spin_unlock_irq(&chip->reg_lock); 896 903 return 0; … … 898 905 899 906 /* set up slots and formats for analog IN */ 900 static int snd_atiixp_capture_prepare(s nd_pcm_substream_t*substream)901 { 902 atiixp_t*chip = snd_pcm_substream_chip(substream);907 static int snd_atiixp_capture_prepare(struct snd_pcm_substream *substream) 908 { 909 struct atiixp *chip = snd_pcm_substream_chip(substream); 903 910 904 911 spin_lock_irq(&chip->reg_lock); … … 913 920 * hw_params - allocate the buffer and set up buffer descriptors 914 921 */ 915 static int snd_atiixp_pcm_hw_params(s nd_pcm_substream_t*substream,916 snd_pcm_hw_params_t*hw_params)917 { 918 atiixp_t*chip = snd_pcm_substream_chip(substream);919 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;922 static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, 923 struct snd_pcm_hw_params *hw_params) 924 { 925 struct atiixp *chip = snd_pcm_substream_chip(substream); 926 struct atiixp_dma *dma = substream->runtime->private_data; 920 927 int err; 921 928 … … 951 958 } 952 959 953 static int snd_atiixp_pcm_hw_free(s nd_pcm_substream_t *substream)954 { 955 atiixp_t*chip = snd_pcm_substream_chip(substream);956 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;960 static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) 961 { 962 struct atiixp *chip = snd_pcm_substream_chip(substream); 963 struct atiixp_dma *dma = substream->runtime->private_data; 957 964 958 965 if (dma->pcm_open_flag) { … … 970 977 * pcm hardware definition, identical for all DMA types 971 978 */ 972 static s nd_pcm_hardware_tsnd_atiixp_pcm_hw =973 { 974 /*.info = */(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |975 976 979 static struct snd_pcm_hardware snd_atiixp_pcm_hw = 980 { 981 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 982 SNDRV_PCM_INFO_BLOCK_TRANSFER | 983 SNDRV_PCM_INFO_PAUSE | 977 984 SNDRV_PCM_INFO_RESUME | 978 985 SNDRV_PCM_INFO_MMAP_VALID), 979 /*.formats = */SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 980 /*.rates = */SNDRV_PCM_RATE_48000, 981 /*.rate_min = */48000, 982 /*.rate_max = */48000, 983 /*.channels_min = */ 2, 984 /*.channels_max = */ 2, 985 /*.buffer_bytes_max = */256 * 1024, 986 /*.period_bytes_min = */32, 987 /*.period_bytes_max = */128 * 1024, 988 /*.periods_min = */ 2, 989 /*.periods_max = */ ATI_MAX_DESCRIPTORS, 990 0 986 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 987 .rates = SNDRV_PCM_RATE_48000, 988 .rate_min = 48000, 989 .rate_max = 48000, 990 .channels_min = 2, 991 .channels_max = 2, 992 .buffer_bytes_max = 256 * 1024, 993 .period_bytes_min = 32, 994 .period_bytes_max = 128 * 1024, 995 .periods_min = 2, 996 .periods_max = ATI_MAX_DESCRIPTORS, 991 997 }; 992 998 993 static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma, int pcm_type) 994 { 995 atiixp_t *chip = snd_pcm_substream_chip(substream); 996 snd_pcm_runtime_t *runtime = substream->runtime; 999 static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, 1000 struct atiixp_dma *dma, int pcm_type) 1001 { 1002 struct atiixp *chip = snd_pcm_substream_chip(substream); 1003 struct snd_pcm_runtime *runtime = substream->runtime; 997 1004 int err; 998 1005 … … 1024 1031 } 1025 1032 1026 static int snd_atiixp_pcm_close(snd_pcm_substream_t *substream, atiixp_dma_t *dma) 1027 { 1028 atiixp_t *chip = snd_pcm_substream_chip(substream); 1033 static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream, 1034 struct atiixp_dma *dma) 1035 { 1036 struct atiixp *chip = snd_pcm_substream_chip(substream); 1029 1037 /* disable DMA bits */ 1030 1038 snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); … … 1039 1047 /* 1040 1048 */ 1041 static int snd_atiixp_playback_open(s nd_pcm_substream_t*substream)1042 { 1043 atiixp_t*chip = snd_pcm_substream_chip(substream);1049 static int snd_atiixp_playback_open(struct snd_pcm_substream *substream) 1050 { 1051 struct atiixp *chip = snd_pcm_substream_chip(substream); 1044 1052 int err; 1045 1053 … … 1057 1065 } 1058 1066 1059 static int snd_atiixp_playback_close(s nd_pcm_substream_t*substream)1060 { 1061 atiixp_t*chip = snd_pcm_substream_chip(substream);1067 static int snd_atiixp_playback_close(struct snd_pcm_substream *substream) 1068 { 1069 struct atiixp *chip = snd_pcm_substream_chip(substream); 1062 1070 int err; 1063 1071 down(&chip->open_mutex); … … 1067 1075 } 1068 1076 1069 static int snd_atiixp_capture_open(s nd_pcm_substream_t*substream)1070 { 1071 atiixp_t*chip = snd_pcm_substream_chip(substream);1077 static int snd_atiixp_capture_open(struct snd_pcm_substream *substream) 1078 { 1079 struct atiixp *chip = snd_pcm_substream_chip(substream); 1072 1080 return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_CAPTURE], 1); 1073 1081 } 1074 1082 1075 static int snd_atiixp_capture_close(s nd_pcm_substream_t*substream)1076 { 1077 atiixp_t*chip = snd_pcm_substream_chip(substream);1083 static int snd_atiixp_capture_close(struct snd_pcm_substream *substream) 1084 { 1085 struct atiixp *chip = snd_pcm_substream_chip(substream); 1078 1086 return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_CAPTURE]); 1079 1087 } 1080 1088 1081 static int snd_atiixp_spdif_open(s nd_pcm_substream_t*substream)1082 { 1083 atiixp_t*chip = snd_pcm_substream_chip(substream);1089 static int snd_atiixp_spdif_open(struct snd_pcm_substream *substream) 1090 { 1091 struct atiixp *chip = snd_pcm_substream_chip(substream); 1084 1092 int err; 1085 1093 down(&chip->open_mutex); … … 1092 1100 } 1093 1101 1094 static int snd_atiixp_spdif_close(s nd_pcm_substream_t*substream)1095 { 1096 atiixp_t*chip = snd_pcm_substream_chip(substream);1102 static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream) 1103 { 1104 struct atiixp *chip = snd_pcm_substream_chip(substream); 1097 1105 int err; 1098 1106 down(&chip->open_mutex); … … 1106 1114 1107 1115 /* AC97 playback */ 1108 static snd_pcm_ops_t snd_atiixp_playback_ops = { 1109 /*.open = */ snd_atiixp_playback_open, 1110 /*.close = */ snd_atiixp_playback_close, 1111 /*.ioctl = */ snd_pcm_lib_ioctl, 1112 /*.hw_params = */ snd_atiixp_pcm_hw_params, 1113 /*.hw_free = */ snd_atiixp_pcm_hw_free, 1114 /*.prepare = */ snd_atiixp_playback_prepare, 1115 /*.trigger = */ snd_atiixp_pcm_trigger, 1116 /*.pointer = */ snd_atiixp_pcm_pointer, 1117 0,0,0,0 1116 static struct snd_pcm_ops snd_atiixp_playback_ops = { 1117 .open = snd_atiixp_playback_open, 1118 .close = snd_atiixp_playback_close, 1119 .ioctl = snd_pcm_lib_ioctl, 1120 .hw_params = snd_atiixp_pcm_hw_params, 1121 .hw_free = snd_atiixp_pcm_hw_free, 1122 .prepare = snd_atiixp_playback_prepare, 1123 .trigger = snd_atiixp_pcm_trigger, 1124 .pointer = snd_atiixp_pcm_pointer, 1118 1125 }; 1119 1126 1120 1127 /* AC97 capture */ 1121 static snd_pcm_ops_t snd_atiixp_capture_ops = { 1122 /*.open = */ snd_atiixp_capture_open, 1123 /*.close = */ snd_atiixp_capture_close, 1124 /*.ioctl = */ snd_pcm_lib_ioctl, 1125 /*.hw_params = */ snd_atiixp_pcm_hw_params, 1126 /*.hw_free = */ snd_atiixp_pcm_hw_free, 1127 /*.prepare = */ snd_atiixp_capture_prepare, 1128 /*.trigger = */ snd_atiixp_pcm_trigger, 1129 /*.pointer = */ snd_atiixp_pcm_pointer, 1130 0,0,0,0 1128 static struct snd_pcm_ops snd_atiixp_capture_ops = { 1129 .open = snd_atiixp_capture_open, 1130 .close = snd_atiixp_capture_close, 1131 .ioctl = snd_pcm_lib_ioctl, 1132 .hw_params = snd_atiixp_pcm_hw_params, 1133 .hw_free = snd_atiixp_pcm_hw_free, 1134 .prepare = snd_atiixp_capture_prepare, 1135 .trigger = snd_atiixp_pcm_trigger, 1136 .pointer = snd_atiixp_pcm_pointer, 1131 1137 }; 1132 1138 1133 1139 /* SPDIF playback */ 1134 static snd_pcm_ops_t snd_atiixp_spdif_ops = { 1135 /*.open = */ snd_atiixp_spdif_open, 1136 /*.close = */ snd_atiixp_spdif_close, 1137 /*.ioctl = */ snd_pcm_lib_ioctl, 1138 /*.hw_params = */ snd_atiixp_pcm_hw_params, 1139 /*.hw_free = */ snd_atiixp_pcm_hw_free, 1140 /*.prepare = */ snd_atiixp_spdif_prepare, 1141 /*.trigger = */ snd_atiixp_pcm_trigger, 1142 /*.pointer = */ snd_atiixp_pcm_pointer, 1143 0,0,0,0 1140 static struct snd_pcm_ops snd_atiixp_spdif_ops = { 1141 .open = snd_atiixp_spdif_open, 1142 .close = snd_atiixp_spdif_close, 1143 .ioctl = snd_pcm_lib_ioctl, 1144 .hw_params = snd_atiixp_pcm_hw_params, 1145 .hw_free = snd_atiixp_pcm_hw_free, 1146 .prepare = snd_atiixp_spdif_prepare, 1147 .trigger = snd_atiixp_pcm_trigger, 1148 .pointer = snd_atiixp_pcm_pointer, 1144 1149 }; 1145 1150 1146 1151 static struct ac97_pcm atiixp_pcm_defs[] __devinitdata = { 1147 /* front PCM */ 1148 { 1149 0,0, 1150 /*.exclusive = */1, 1151 0,0,0,0, 1152 /*.r = */{{ 1153 /*.slots = */(1 << AC97_SLOT_PCM_LEFT) | 1154 (1 << AC97_SLOT_PCM_RIGHT) | 1155 (1 << AC97_SLOT_PCM_CENTER) | 1156 (1 << AC97_SLOT_PCM_SLEFT) | 1157 (1 << AC97_SLOT_PCM_SRIGHT) | 1158 (1 << AC97_SLOT_LFE), 1159 {0}, 1160 {0}, 1161 0 1162 }, {0} 1163 }, 1164 0 1165 }, 1166 /* PCM IN #1 */ 1167 { 1168 0, 1169 /*.stream = */1, 1170 /*.exclusive = */1, 1171 0,0,0,0, 1172 /*.r = */{ { 1173 /*.slots =*/ (1 << AC97_SLOT_PCM_LEFT) | 1174 (1 << AC97_SLOT_PCM_RIGHT), 1175 {0}, 1176 {0}, 1177 0 1178 },{0} 1179 }, 0 1180 }, 1181 /* S/PDIF OUT (optional) */ 1182 { 1183 0, 0, 1184 /*.exclusive = */1, 1185 0, 1186 /*.spdif = */1, 1187 0,0, 1188 /*.r = */{ { 1189 /*.slots =*/ (1 << AC97_SLOT_SPDIF_LEFT2) | 1190 (1 << AC97_SLOT_SPDIF_RIGHT2), 1191 {0}, 1192 {0}, 1193 0 1194 1195 }, {0} 1196 }, 0 1197 }, 1152 /* front PCM */ 1153 { 1154 .exclusive = 1, 1155 .r = { { 1156 .slots = (1 << AC97_SLOT_PCM_LEFT) | 1157 (1 << AC97_SLOT_PCM_RIGHT) | 1158 (1 << AC97_SLOT_PCM_CENTER) | 1159 (1 << AC97_SLOT_PCM_SLEFT) | 1160 (1 << AC97_SLOT_PCM_SRIGHT) | 1161 (1 << AC97_SLOT_LFE) 1162 } 1163 } 1164 }, 1165 /* PCM IN #1 */ 1166 { 1167 .stream = 1, 1168 .exclusive = 1, 1169 .r = { { 1170 .slots = (1 << AC97_SLOT_PCM_LEFT) | 1171 (1 << AC97_SLOT_PCM_RIGHT) 1172 } 1173 } 1174 }, 1175 /* S/PDIF OUT (optional) */ 1176 { 1177 .exclusive = 1, 1178 .spdif = 1, 1179 .r = { { 1180 .slots = (1 << AC97_SLOT_SPDIF_LEFT2) | 1181 (1 << AC97_SLOT_SPDIF_RIGHT2) 1182 } 1183 } 1184 }, 1198 1185 }; 1199 1186 1200 static atiixp_dma_ops_tsnd_atiixp_playback_dma_ops = {1201 /*.type = */ATI_DMA_PLAYBACK,1202 /*.llp_offset = */ATI_REG_OUT_DMA_LINKPTR,1203 /*.dt_cur = */ATI_REG_OUT_DMA_DT_CUR,1204 /*.enable_dma = */atiixp_out_enable_dma,1205 /*.enable_transfer = */atiixp_out_enable_transfer,1206 /*.flush_dma = */atiixp_out_flush_dma,1187 static struct atiixp_dma_ops snd_atiixp_playback_dma_ops = { 1188 .type = ATI_DMA_PLAYBACK, 1189 .llp_offset = ATI_REG_OUT_DMA_LINKPTR, 1190 .dt_cur = ATI_REG_OUT_DMA_DT_CUR, 1191 .enable_dma = atiixp_out_enable_dma, 1192 .enable_transfer = atiixp_out_enable_transfer, 1193 .flush_dma = atiixp_out_flush_dma, 1207 1194 }; 1208 1209 static atiixp_dma_ops_tsnd_atiixp_capture_dma_ops = {1210 /*.type = */ATI_DMA_CAPTURE,1211 /*.llp_offset = */ATI_REG_IN_DMA_LINKPTR,1212 /*.dt_cur = */ATI_REG_IN_DMA_DT_CUR,1213 /*.enable_dma = */atiixp_in_enable_dma,1214 /*.enable_transfer = */atiixp_in_enable_transfer,1215 /*.flush_dma = */atiixp_in_flush_dma,1195 1196 static struct atiixp_dma_ops snd_atiixp_capture_dma_ops = { 1197 .type = ATI_DMA_CAPTURE, 1198 .llp_offset = ATI_REG_IN_DMA_LINKPTR, 1199 .dt_cur = ATI_REG_IN_DMA_DT_CUR, 1200 .enable_dma = atiixp_in_enable_dma, 1201 .enable_transfer = atiixp_in_enable_transfer, 1202 .flush_dma = atiixp_in_flush_dma, 1216 1203 }; 1217 1218 static atiixp_dma_ops_tsnd_atiixp_spdif_dma_ops = {1219 /*.type = */ATI_DMA_SPDIF,1220 /*.llp_offset = */ATI_REG_SPDF_DMA_LINKPTR,1221 /*.dt_cur = */ATI_REG_SPDF_DMA_DT_CUR,1222 /*.enable_dma = */atiixp_spdif_enable_dma,1223 /*.enable_transfer = */atiixp_spdif_enable_transfer,1224 /*.flush_dma = */atiixp_spdif_flush_dma,1204 1205 static struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = { 1206 .type = ATI_DMA_SPDIF, 1207 .llp_offset = ATI_REG_SPDF_DMA_LINKPTR, 1208 .dt_cur = ATI_REG_SPDF_DMA_DT_CUR, 1209 .enable_dma = atiixp_spdif_enable_dma, 1210 .enable_transfer = atiixp_spdif_enable_transfer, 1211 .flush_dma = atiixp_spdif_flush_dma, 1225 1212 }; 1226 1227 1228 static int __devinit snd_atiixp_pcm_new( atiixp_t*chip)1229 { 1230 s nd_pcm_t*pcm;1231 ac97_bus_t*pbus = chip->ac97_bus;1213 1214 1215 static int __devinit snd_atiixp_pcm_new(struct atiixp *chip) 1216 { 1217 struct snd_pcm *pcm; 1218 struct snd_ac97_bus *pbus = chip->ac97_bus; 1232 1219 int err, i, num_pcms; 1233 1220 … … 1258 1245 1259 1246 /* PCM #0: analog I/O */ 1260 err = snd_pcm_new(chip->card, "ATI IXP AC97", ATI_PCMDEV_ANALOG, 1, 1, &pcm); 1247 err = snd_pcm_new(chip->card, "ATI IXP AC97", 1248 ATI_PCMDEV_ANALOG, 1, 1, &pcm); 1261 1249 if (err < 0) 1262 1250 return err; … … 1268 1256 1269 1257 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1270 snd_dma_pci_data(chip->pci), 64*1024, 128*1024); 1258 snd_dma_pci_data(chip->pci), 1259 64*1024, 128*1024); 1271 1260 1272 1261 /* no SPDIF support on codec? */ 1273 1262 if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates) 1274 1263 return 0; 1275 1264 1276 1265 /* FIXME: non-48k sample rate doesn't work on my test machine with AD1888 */ 1277 1266 if (chip->pcms[ATI_PCM_SPDIF]) … … 1279 1268 1280 1269 /* PCM #1: spdif playback */ 1281 err = snd_pcm_new(chip->card, "ATI IXP IEC958", ATI_PCMDEV_DIGITAL, 1, 0, &pcm); 1270 err = snd_pcm_new(chip->card, "ATI IXP IEC958", 1271 ATI_PCMDEV_DIGITAL, 1, 0, &pcm); 1282 1272 if (err < 0) 1283 1273 return err; … … 1291 1281 1292 1282 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1293 snd_dma_pci_data(chip->pci), 64*1024, 128*1024); 1283 snd_dma_pci_data(chip->pci), 1284 64*1024, 128*1024); 1294 1285 1295 1286 /* pre-select AC97 SPDIF slots 10/11 */ 1296 1287 for (i = 0; i < NUM_ATI_CODECS; i++) { 1297 1288 if (chip->ac97[i]) 1298 snd_ac97_update_bits(chip->ac97[i], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); 1289 snd_ac97_update_bits(chip->ac97[i], 1290 AC97_EXTENDED_STATUS, 1291 0x03 << 4, 0x03 << 4); 1299 1292 } 1300 1293 … … 1309 1302 static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1310 1303 { 1311 atiixp_t*chip = dev_id;1312 1304 struct atiixp *chip = dev_id; 1305 unsigned int status; 1313 1306 1314 1307 status = atiixp_read(chip, ISR); … … 1346 1339 atiixp_write(chip, ISR, status); 1347 1340 1348 #ifdef TARGET_OS21349 eoi_irq(irq);1350 #endif //TARGET_OS21351 1352 1341 return IRQ_HANDLED; 1353 1342 } … … 1359 1348 1360 1349 static struct ac97_quirk ac97_quirks[] __devinitdata = { 1361 { 1362 0x103c, 1363 0x006b,0,0, 1364 "HP Pavilion ZV5030US", 1365 AC97_TUNE_MUTE_LED 1366 }, 1367 {0} /* terminator */ 1350 { 1351 .subvendor = 0x103c, 1352 .subdevice = 0x006b, 1353 .name = "HP Pavilion ZV5030US", 1354 .type = AC97_TUNE_MUTE_LED 1355 }, 1356 { 1357 .subvendor = 0x103c, 1358 .subdevice = 0x308b, 1359 .name = "HP nx6125", 1360 .type = AC97_TUNE_MUTE_LED 1361 }, 1362 {0} /* terminator */ 1368 1363 }; 1369 1364 1370 static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock, const char *quirk_override) 1371 { 1372 ac97_bus_t *pbus; 1373 ac97_template_t ac97; 1365 static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock, 1366 const char *quirk_override) 1367 { 1368 struct snd_ac97_bus *pbus; 1369 struct snd_ac97_template ac97; 1374 1370 int i, err; 1375 1371 int codec_count; 1376 static ac97_bus_ops_t ops = { 1377 0, 1378 /*.write = */snd_atiixp_ac97_write, 1379 /*.read = */snd_atiixp_ac97_read, 0,0 1372 static struct snd_ac97_bus_ops ops = { 1373 .write = snd_atiixp_ac97_write, 1374 .read = snd_atiixp_ac97_read, 1380 1375 }; 1381 1376 static unsigned int codec_skip[NUM_ATI_CODECS] = { … … 1391 1386 return err; 1392 1387 pbus->clock = clock; 1393 pbus->shared_type = AC97_SHARED_TYPE_ATIIXP; /* shared with modem driver */1394 1388 chip->ac97_bus = pbus; 1395 1389 … … 1403 1397 ac97.num = i; 1404 1398 ac97.scaps = AC97_SCAP_SKIP_MODEM; 1399 if (! chip->spdif_over_aclink) 1400 ac97.scaps |= AC97_SCAP_NO_SPDIF; 1405 1401 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { 1406 1402 chip->ac97[i] = NULL; /* to be sure */ … … 1416 1412 } 1417 1413 1418 1414 snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override); 1419 1415 1420 1416 return 0; … … 1426 1422 * power management 1427 1423 */ 1428 static int snd_atiixp_suspend(snd_card_t *card, unsigned int state) 1429 { 1430 atiixp_t *chip = card->pm_private_data; 1424 static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state) 1425 { 1426 struct snd_card *card = pci_get_drvdata(pci); 1427 struct atiixp *chip = card->private_data; 1431 1428 int i; 1432 1429 1433 for (i = 0; i < NUM_ATI_PCMDEVS; i++) 1434 if (chip->pcmdevs[i]) { 1435 atiixp_dma_t *dma = &chip->dmas[i]; 1436 if (dma->substream && dma->running) 1437 dma->saved_curptr = readl((char*)chip->remap_addr + dma->ops->dt_cur); 1438 snd_pcm_suspend_all(chip->pcmdevs[i]); 1439 } 1430 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1431 for (i = 0; i < NUM_ATI_PCMDEVS; i++) 1432 if (chip->pcmdevs[i]) { 1433 struct atiixp_dma *dma = &chip->dmas[i]; 1434 if (dma->substream && dma->running) 1435 dma->saved_curptr = readl((char*)chip->remap_addr + 1436 dma->ops->dt_cur); 1437 snd_pcm_suspend_all(chip->pcmdevs[i]); 1438 } 1440 1439 for (i = 0; i < NUM_ATI_CODECS; i++) 1441 if (chip->ac97[i]) 1442 snd_ac97_suspend(chip->ac97[i]); 1440 snd_ac97_suspend(chip->ac97[i]); 1443 1441 snd_atiixp_aclink_down(chip); 1444 1442 snd_atiixp_chip_stop(chip); 1445 1443 1446 pci_set_power_state(chip->pci, 3); 1447 pci_disable_device(chip->pci); 1448 return 0; 1449 } 1450 1451 static int snd_atiixp_resume(snd_card_t *card, unsigned int state) 1452 { 1453 atiixp_t *chip = card->pm_private_data; 1444 pci_set_power_state(pci, PCI_D3hot); 1445 pci_disable_device(pci); 1446 pci_save_state(pci); 1447 return 0; 1448 } 1449 1450 static int snd_atiixp_resume(struct pci_dev *pci) 1451 { 1452 struct snd_card *card = pci_get_drvdata(pci); 1453 struct atiixp *chip = card->private_data; 1454 1454 int i; 1455 1455 1456 pci_enable_device(chip->pci); 1457 pci_set_power_state(chip->pci, 0); 1458 pci_set_master(chip->pci); 1456 pci_restore_state(pci); 1457 pci_enable_device(pci); 1458 pci_set_power_state(pci, PCI_D0); 1459 pci_set_master(pci); 1459 1460 1460 1461 snd_atiixp_aclink_reset(chip); … … 1462 1463 1463 1464 for (i = 0; i < NUM_ATI_CODECS; i++) 1464 if (chip->ac97[i]) 1465 snd_ac97_resume(chip->ac97[i]); 1466 for (i = 0; i < NUM_ATI_PCMDEVS; i++) 1467 if (chip->pcmdevs[i]) { 1468 atiixp_dma_t *dma = &chip->dmas[i]; 1469 if (dma->substream && dma->suspended) { 1470 dma->ops->enable_dma(chip, 1); 1471 dma->substream->ops->prepare(dma->substream); 1472 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 1473 (char*)chip->remap_addr + dma->ops->llp_offset); 1474 writel(dma->saved_curptr, (char*)chip->remap_addr + dma->ops->dt_cur); 1475 } 1476 } 1477 1478 return 0; 1465 snd_ac97_resume(chip->ac97[i]); 1466 1467 for (i = 0; i < NUM_ATI_PCMDEVS; i++) 1468 if (chip->pcmdevs[i]) { 1469 struct atiixp_dma *dma = &chip->dmas[i]; 1470 if (dma->substream && dma->suspended) { 1471 dma->ops->enable_dma(chip, 1); 1472 dma->substream->ops->prepare(dma->substream); 1473 writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, 1474 (char*)chip->remap_addr + dma->ops->llp_offset); 1475 writel(dma->saved_curptr, (char*)chip->remap_addr + 1476 dma->ops->dt_cur); 1477 } 1478 } 1479 1480 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 1481 return 0; 1479 1482 } 1480 1483 #endif /* CONFIG_PM */ 1481 1484 1482 1485 1486 #ifdef CONFIG_PROC_FS 1483 1487 /* 1484 1488 * proc interface for register dump 1485 1489 */ 1486 1490 1487 static void snd_atiixp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) 1488 { 1489 atiixp_t *chip = entry->private_data; 1491 static void snd_atiixp_proc_read(struct snd_info_entry *entry, 1492 struct snd_info_buffer *buffer) 1493 { 1494 struct atiixp *chip = entry->private_data; 1490 1495 int i; 1491 1496 … … 1494 1499 } 1495 1500 1496 static void __devinit snd_atiixp_proc_init( atiixp_t*chip)1497 { 1498 s nd_info_entry_t*entry;1501 static void __devinit snd_atiixp_proc_init(struct atiixp *chip) 1502 { 1503 struct snd_info_entry *entry; 1499 1504 1500 1505 if (! snd_card_proc_new(chip->card, "atiixp", &entry)) 1501 1506 snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read); 1502 1507 } 1503 1508 #else /* !CONFIG_PROC_FS */ 1509 #define snd_atiixp_proc_init(chip) 1510 #endif 1504 1511 1505 1512 … … 1508 1515 */ 1509 1516 1510 static int snd_atiixp_free( atiixp_t*chip)1517 static int snd_atiixp_free(struct atiixp *chip) 1511 1518 { 1512 1519 if (chip->irq < 0) … … 1516 1523 __hw_end: 1517 1524 if (chip->irq >= 0) 1518 free_irq(chip->irq, (void *)chip);1525 free_irq(chip->irq, chip); 1519 1526 if (chip->remap_addr) 1520 1527 iounmap(chip->remap_addr); … … 1525 1532 } 1526 1533 1527 static int snd_atiixp_dev_free(s nd_device_t*device)1528 { 1529 atiixp_t*chip = device->device_data;1534 static int snd_atiixp_dev_free(struct snd_device *device) 1535 { 1536 struct atiixp *chip = device->device_data; 1530 1537 return snd_atiixp_free(chip); 1531 1538 } … … 1534 1541 * constructor for chip instance 1535 1542 */ 1536 static int __devinit snd_atiixp_create(s nd_card_t*card,1543 static int __devinit snd_atiixp_create(struct snd_card *card, 1537 1544 struct pci_dev *pci, 1538 atiixp_t**r_chip)1539 { 1540 static s nd_device_ops_tops = {1541 snd_atiixp_dev_free,0,0,01545 struct atiixp **r_chip) 1546 { 1547 static struct snd_device_ops ops = { 1548 .dev_free = snd_atiixp_dev_free, 1542 1549 }; 1543 atiixp_t*chip;1550 struct atiixp *chip; 1544 1551 int err; 1545 1552 … … 1547 1554 return err; 1548 1555 1549 chip = k calloc(1,sizeof(*chip), GFP_KERNEL);1556 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1550 1557 if (chip == NULL) { 1551 1558 pci_disable_device(pci); … … 1571 1578 } 1572 1579 1573 if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) { 1580 if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, 1581 card->shortname, chip)) { 1574 1582 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1575 1583 snd_atiixp_free(chip); … … 1595 1603 const struct pci_device_id *pci_id) 1596 1604 { 1597 static int dev; 1598 snd_card_t *card; 1599 atiixp_t *chip; 1605 struct snd_card *card; 1606 struct atiixp *chip; 1600 1607 unsigned char revision; 1601 1608 int err; 1602 1609 1603 if (dev >= SNDRV_CARDS) 1604 return -ENODEV; 1605 if (!enable[dev]) { 1606 dev++; 1607 return -ENOENT; 1608 } 1609 1610 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 1610 card = snd_card_new(index, id, THIS_MODULE, 0); 1611 1611 if (card == NULL) 1612 1612 return -ENOMEM; … … 1614 1614 pci_read_config_byte(pci, PCI_REVISION_ID, &revision); 1615 1615 1616 strcpy(card->driver, spdif_aclink [dev]? "ATIIXP" : "ATIIXP-SPDMA");1616 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); 1617 1617 strcpy(card->shortname, "ATI IXP"); 1618 1618 if ((err = snd_atiixp_create(card, pci, &chip)) < 0) 1619 1619 goto __error; 1620 card->private_data = chip; 1620 1621 1621 1622 if ((err = snd_atiixp_aclink_reset(chip)) < 0) 1622 1623 goto __error; 1623 1624 1624 chip->spdif_over_aclink = spdif_aclink [dev];1625 1626 if ((err = snd_atiixp_mixer_new(chip, ac97_clock[dev], ac97_quirk[dev])) < 0)1625 chip->spdif_over_aclink = spdif_aclink; 1626 1627 if ((err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk)) < 0) 1627 1628 goto __error; 1628 1629 1629 1630 if ((err = snd_atiixp_pcm_new(chip)) < 0) 1630 1631 goto __error; 1631 1632 1632 1633 snd_atiixp_proc_init(chip); 1633 1634 … … 1639 1640 chip->addr, chip->irq); 1640 1641 1641 snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip);1642 1643 1642 if ((err = snd_card_register(card)) < 0) 1644 1643 goto __error; 1645 1644 1646 1645 pci_set_drvdata(pci, card); 1647 dev++;1648 1646 return 0; 1649 1647 … … 1660 1658 1661 1659 static struct pci_driver driver = { 1662 0,0,0, 1663 "ATI IXP AC97 controller", 1664 snd_atiixp_ids, 1665 snd_atiixp_probe, 1666 snd_atiixp_remove, 1667 SND_PCI_PM_CALLBACKS 1660 .name = "ATI IXP AC97 controller", 1661 .id_table = snd_atiixp_ids, 1662 .probe = snd_atiixp_probe, 1663 .remove = __devexit_p(snd_atiixp_remove), 1664 #ifdef CONFIG_PM 1665 .suspend = snd_atiixp_suspend, 1666 .resume = snd_atiixp_resume, 1667 #endif 1668 1668 }; 1669 1669 … … 1671 1671 static int __init alsa_card_atiixp_init(void) 1672 1672 { 1673 return pci_ module_init(&driver);1673 return pci_register_driver(&driver); 1674 1674 } 1675 1675
Note:
See TracChangeset
for help on using the changeset viewer.