aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 09:06:15 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:19:49 -0500
commite437e3d7c7fb656010f8f767d20215e67b847685 (patch)
tree807b22db635295cded8ccb5af23f491b22a2a2e6 /sound/pci
parent016e401c2e64ce5c440b1f68eae4a53273aa0bc2 (diff)
[ALSA] Remove xxx_t typedefs: PCI VIA82xx
Modules: VIA82xx driver,VIA82xx-modem driver Remove xxx_t typedefs from the PCI VIA82xx and modem drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/via82xx.c390
-rw-r--r--sound/pci/via82xx_modem.c217
2 files changed, 328 insertions, 279 deletions
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index f0d8c7f24f27..c87000130dd2 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -303,12 +303,6 @@ DEFINE_VIA_REGSET(CAPTURE_8233, 0x60);
303 303
304 304
305/* 305/*
306 */
307
308typedef struct _snd_via82xx via82xx_t;
309typedef struct via_dev viadev_t;
310
311/*
312 * pcm stream 306 * pcm stream
313 */ 307 */
314 308
@@ -319,11 +313,11 @@ struct snd_via_sg_table {
319 313
320#define VIA_TABLE_SIZE 255 314#define VIA_TABLE_SIZE 255
321 315
322struct via_dev { 316struct viadev {
323 unsigned int reg_offset; 317 unsigned int reg_offset;
324 unsigned long port; 318 unsigned long port;
325 int direction; /* playback = 0, capture = 1 */ 319 int direction; /* playback = 0, capture = 1 */
326 snd_pcm_substream_t *substream; 320 struct snd_pcm_substream *substream;
327 int running; 321 int running;
328 unsigned int tbl_entries; /* # descriptors */ 322 unsigned int tbl_entries; /* # descriptors */
329 struct snd_dma_buffer table; 323 struct snd_dma_buffer table;
@@ -350,7 +344,7 @@ struct via_rate_lock {
350 int used; 344 int used;
351}; 345};
352 346
353struct _snd_via82xx { 347struct via82xx {
354 int irq; 348 int irq;
355 349
356 unsigned long port; 350 unsigned long port;
@@ -374,27 +368,27 @@ struct _snd_via82xx {
374 unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ 368 unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */
375 369
376 struct pci_dev *pci; 370 struct pci_dev *pci;
377 snd_card_t *card; 371 struct snd_card *card;
378 372
379 unsigned int num_devs; 373 unsigned int num_devs;
380 unsigned int playback_devno, multi_devno, capture_devno; 374 unsigned int playback_devno, multi_devno, capture_devno;
381 viadev_t devs[VIA_MAX_DEVS]; 375 struct viadev devs[VIA_MAX_DEVS];
382 struct via_rate_lock rates[2]; /* playback and capture */ 376 struct via_rate_lock rates[2]; /* playback and capture */
383 unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ 377 unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */
384 unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ 378 unsigned int no_vra: 1; /* no need to set VRA on DXS channels */
385 unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */ 379 unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */
386 unsigned int spdif_on: 1; /* only spdif rates work to external DACs */ 380 unsigned int spdif_on: 1; /* only spdif rates work to external DACs */
387 381
388 snd_pcm_t *pcms[2]; 382 struct snd_pcm *pcms[2];
389 snd_rawmidi_t *rmidi; 383 struct snd_rawmidi *rmidi;
390 384
391 ac97_bus_t *ac97_bus; 385 struct snd_ac97_bus *ac97_bus;
392 ac97_t *ac97; 386 struct snd_ac97 *ac97;
393 unsigned int ac97_clock; 387 unsigned int ac97_clock;
394 unsigned int ac97_secondary; /* secondary AC'97 codec is present */ 388 unsigned int ac97_secondary; /* secondary AC'97 codec is present */
395 389
396 spinlock_t reg_lock; 390 spinlock_t reg_lock;
397 snd_info_entry_t *proc_entry; 391 struct snd_info_entry *proc_entry;
398 392
399#ifdef SUPPORT_JOYSTICK 393#ifdef SUPPORT_JOYSTICK
400 struct gameport *gameport; 394 struct gameport *gameport;
@@ -419,12 +413,12 @@ MODULE_DEVICE_TABLE(pci, snd_via82xx_ids);
419 * periods = number of periods 413 * periods = number of periods
420 * fragsize = period size in bytes 414 * fragsize = period size in bytes
421 */ 415 */
422static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream, 416static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream,
423 struct pci_dev *pci, 417 struct pci_dev *pci,
424 unsigned int periods, unsigned int fragsize) 418 unsigned int periods, unsigned int fragsize)
425{ 419{
426 unsigned int i, idx, ofs, rest; 420 unsigned int i, idx, ofs, rest;
427 via82xx_t *chip = snd_pcm_substream_chip(substream); 421 struct via82xx *chip = snd_pcm_substream_chip(substream);
428 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); 422 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
429 423
430 if (dev->table.area == NULL) { 424 if (dev->table.area == NULL) {
@@ -487,7 +481,7 @@ static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
487} 481}
488 482
489 483
490static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, 484static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream,
491 struct pci_dev *pci) 485 struct pci_dev *pci)
492{ 486{
493 if (dev->table.area) { 487 if (dev->table.area) {
@@ -503,17 +497,17 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
503 * Basic I/O 497 * Basic I/O
504 */ 498 */
505 499
506static inline unsigned int snd_via82xx_codec_xread(via82xx_t *chip) 500static inline unsigned int snd_via82xx_codec_xread(struct via82xx *chip)
507{ 501{
508 return inl(VIAREG(chip, AC97)); 502 return inl(VIAREG(chip, AC97));
509} 503}
510 504
511static inline void snd_via82xx_codec_xwrite(via82xx_t *chip, unsigned int val) 505static inline void snd_via82xx_codec_xwrite(struct via82xx *chip, unsigned int val)
512{ 506{
513 outl(val, VIAREG(chip, AC97)); 507 outl(val, VIAREG(chip, AC97));
514} 508}
515 509
516static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary) 510static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary)
517{ 511{
518 unsigned int timeout = 1000; /* 1ms */ 512 unsigned int timeout = 1000; /* 1ms */
519 unsigned int val; 513 unsigned int val;
@@ -523,11 +517,12 @@ static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary)
523 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) 517 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY))
524 return val & 0xffff; 518 return val & 0xffff;
525 } 519 }
526 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_via82xx_codec_xread(chip)); 520 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n",
521 secondary, snd_via82xx_codec_xread(chip));
527 return -EIO; 522 return -EIO;
528} 523}
529 524
530static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary) 525static int snd_via82xx_codec_valid(struct via82xx *chip, int secondary)
531{ 526{
532 unsigned int timeout = 1000; /* 1ms */ 527 unsigned int timeout = 1000; /* 1ms */
533 unsigned int val, val1; 528 unsigned int val, val1;
@@ -544,20 +539,20 @@ static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary)
544 return -EIO; 539 return -EIO;
545} 540}
546 541
547static void snd_via82xx_codec_wait(ac97_t *ac97) 542static void snd_via82xx_codec_wait(struct snd_ac97 *ac97)
548{ 543{
549 via82xx_t *chip = ac97->private_data; 544 struct via82xx *chip = ac97->private_data;
550 int err; 545 int err;
551 err = snd_via82xx_codec_ready(chip, ac97->num); 546 err = snd_via82xx_codec_ready(chip, ac97->num);
552 /* here we need to wait fairly for long time.. */ 547 /* here we need to wait fairly for long time.. */
553 msleep(500); 548 msleep(500);
554} 549}
555 550
556static void snd_via82xx_codec_write(ac97_t *ac97, 551static void snd_via82xx_codec_write(struct snd_ac97 *ac97,
557 unsigned short reg, 552 unsigned short reg,
558 unsigned short val) 553 unsigned short val)
559{ 554{
560 via82xx_t *chip = ac97->private_data; 555 struct via82xx *chip = ac97->private_data;
561 unsigned int xval; 556 unsigned int xval;
562 557
563 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; 558 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY;
@@ -568,9 +563,9 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
568 snd_via82xx_codec_ready(chip, ac97->num); 563 snd_via82xx_codec_ready(chip, ac97->num);
569} 564}
570 565
571static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) 566static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned short reg)
572{ 567{
573 via82xx_t *chip = ac97->private_data; 568 struct via82xx *chip = ac97->private_data;
574 unsigned int xval, val = 0xffff; 569 unsigned int xval, val = 0xffff;
575 int again = 0; 570 int again = 0;
576 571
@@ -580,7 +575,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
580 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; 575 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
581 while (1) { 576 while (1) {
582 if (again++ > 3) { 577 if (again++ > 3) {
583 snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip)); 578 snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n",
579 ac97->num, snd_via82xx_codec_xread(chip));
584 return 0xffff; 580 return 0xffff;
585 } 581 }
586 snd_via82xx_codec_xwrite(chip, xval); 582 snd_via82xx_codec_xwrite(chip, xval);
@@ -594,7 +590,7 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
594 return val & 0xffff; 590 return val & 0xffff;
595} 591}
596 592
597static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev) 593static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev)
598{ 594{
599 outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET, 595 outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET,
600 VIADEV_REG(viadev, OFFSET_CONTROL)); 596 VIADEV_REG(viadev, OFFSET_CONTROL));
@@ -617,7 +613,7 @@ static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev)
617 */ 613 */
618static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *regs) 614static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *regs)
619{ 615{
620 via82xx_t *chip = dev_id; 616 struct via82xx *chip = dev_id;
621 unsigned int status; 617 unsigned int status;
622 unsigned int i; 618 unsigned int i;
623 619
@@ -632,7 +628,7 @@ static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *r
632 /* check status for each stream */ 628 /* check status for each stream */
633 spin_lock(&chip->reg_lock); 629 spin_lock(&chip->reg_lock);
634 for (i = 0; i < chip->num_devs; i++) { 630 for (i = 0; i < chip->num_devs; i++) {
635 viadev_t *viadev = &chip->devs[i]; 631 struct viadev *viadev = &chip->devs[i];
636 unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); 632 unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS));
637 if (! (c_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED))) 633 if (! (c_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED)))
638 continue; 634 continue;
@@ -663,7 +659,7 @@ static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *r
663 */ 659 */
664static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs *regs) 660static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs *regs)
665{ 661{
666 via82xx_t *chip = dev_id; 662 struct via82xx *chip = dev_id;
667 unsigned int status; 663 unsigned int status;
668 unsigned int i; 664 unsigned int i;
669 int irqreturn = 0; 665 int irqreturn = 0;
@@ -673,8 +669,8 @@ static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs *
673 status = inl(VIAREG(chip, SGD_SHADOW)); 669 status = inl(VIAREG(chip, SGD_SHADOW));
674 670
675 for (i = 0; i < chip->num_devs; i++) { 671 for (i = 0; i < chip->num_devs; i++) {
676 viadev_t *viadev = &chip->devs[i]; 672 struct viadev *viadev = &chip->devs[i];
677 snd_pcm_substream_t *substream; 673 struct snd_pcm_substream *substream;
678 unsigned char c_status, shadow_status; 674 unsigned char c_status, shadow_status;
679 675
680 shadow_status = (status >> viadev->shadow_shift) & 676 shadow_status = (status >> viadev->shadow_shift) &
@@ -719,10 +715,10 @@ static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs *
719/* 715/*
720 * trigger callback 716 * trigger callback
721 */ 717 */
722static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) 718static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
723{ 719{
724 via82xx_t *chip = snd_pcm_substream_chip(substream); 720 struct via82xx *chip = snd_pcm_substream_chip(substream);
725 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 721 struct viadev *viadev = substream->runtime->private_data;
726 unsigned char val; 722 unsigned char val;
727 723
728 if (chip->chip_type != TYPE_VIA686) 724 if (chip->chip_type != TYPE_VIA686)
@@ -766,9 +762,11 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
766 */ 762 */
767 763
768#define check_invalid_pos(viadev,pos) \ 764#define check_invalid_pos(viadev,pos) \
769 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) 765 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
766 viadev->lastpos < viadev->bufsize2))
770 767
771static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) 768static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx,
769 unsigned int count)
772{ 770{
773 unsigned int size, base, res; 771 unsigned int size, base, res;
774 772
@@ -780,7 +778,8 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
780 778
781 /* check the validity of the calculated position */ 779 /* check the validity of the calculated position */
782 if (size < count) { 780 if (size < count) {
783 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", (int)size, (int)count); 781 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
782 (int)size, (int)count);
784 res = viadev->lastpos; 783 res = viadev->lastpos;
785 } else { 784 } else {
786 if (! count) { 785 if (! count) {
@@ -796,12 +795,18 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
796 } 795 }
797 if (check_invalid_pos(viadev, res)) { 796 if (check_invalid_pos(viadev, res)) {
798#ifdef POINTER_DEBUG 797#ifdef POINTER_DEBUG
799 printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); 798 printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, "
799 "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, "
800 "count = 0x%x\n", idx, viadev->tbl_entries,
801 viadev->lastpos, viadev->bufsize2,
802 viadev->idx_table[idx].offset,
803 viadev->idx_table[idx].size, count);
800#endif 804#endif
801 /* count register returns full size when end of buffer is reached */ 805 /* count register returns full size when end of buffer is reached */
802 res = base + size; 806 res = base + size;
803 if (check_invalid_pos(viadev, res)) { 807 if (check_invalid_pos(viadev, res)) {
804 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); 808 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), "
809 "using last valid pointer\n");
805 res = viadev->lastpos; 810 res = viadev->lastpos;
806 } 811 }
807 } 812 }
@@ -812,10 +817,10 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
812/* 817/*
813 * get the current pointer on via686 818 * get the current pointer on via686
814 */ 819 */
815static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) 820static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substream)
816{ 821{
817 via82xx_t *chip = snd_pcm_substream_chip(substream); 822 struct via82xx *chip = snd_pcm_substream_chip(substream);
818 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 823 struct viadev *viadev = substream->runtime->private_data;
819 unsigned int idx, ptr, count, res; 824 unsigned int idx, ptr, count, res;
820 825
821 snd_assert(viadev->tbl_entries, return 0); 826 snd_assert(viadev->tbl_entries, return 0);
@@ -842,10 +847,10 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream)
842/* 847/*
843 * get the current pointer on via823x 848 * get the current pointer on via823x
844 */ 849 */
845static snd_pcm_uframes_t snd_via8233_pcm_pointer(snd_pcm_substream_t *substream) 850static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *substream)
846{ 851{
847 via82xx_t *chip = snd_pcm_substream_chip(substream); 852 struct via82xx *chip = snd_pcm_substream_chip(substream);
848 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 853 struct viadev *viadev = substream->runtime->private_data;
849 unsigned int idx, count, res; 854 unsigned int idx, count, res;
850 int status; 855 int status;
851 856
@@ -865,7 +870,8 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(snd_pcm_substream_t *substream)
865 idx = count >> 24; 870 idx = count >> 24;
866 if (idx >= viadev->tbl_entries) { 871 if (idx >= viadev->tbl_entries) {
867#ifdef POINTER_DEBUG 872#ifdef POINTER_DEBUG
868 printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx, viadev->tbl_entries); 873 printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx,
874 viadev->tbl_entries);
869#endif 875#endif
870 res = viadev->lastpos; 876 res = viadev->lastpos;
871 } else { 877 } else {
@@ -895,11 +901,11 @@ unlock:
895 * hw_params callback: 901 * hw_params callback:
896 * allocate the buffer and build up the buffer description table 902 * allocate the buffer and build up the buffer description table
897 */ 903 */
898static int snd_via82xx_hw_params(snd_pcm_substream_t * substream, 904static int snd_via82xx_hw_params(struct snd_pcm_substream *substream,
899 snd_pcm_hw_params_t * hw_params) 905 struct snd_pcm_hw_params *hw_params)
900{ 906{
901 via82xx_t *chip = snd_pcm_substream_chip(substream); 907 struct via82xx *chip = snd_pcm_substream_chip(substream);
902 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 908 struct viadev *viadev = substream->runtime->private_data;
903 int err; 909 int err;
904 910
905 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 911 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
@@ -918,10 +924,10 @@ static int snd_via82xx_hw_params(snd_pcm_substream_t * substream,
918 * hw_free callback: 924 * hw_free callback:
919 * clean up the buffer description table and release the buffer 925 * clean up the buffer description table and release the buffer
920 */ 926 */
921static int snd_via82xx_hw_free(snd_pcm_substream_t * substream) 927static int snd_via82xx_hw_free(struct snd_pcm_substream *substream)
922{ 928{
923 via82xx_t *chip = snd_pcm_substream_chip(substream); 929 struct via82xx *chip = snd_pcm_substream_chip(substream);
924 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 930 struct viadev *viadev = substream->runtime->private_data;
925 931
926 clean_via_table(viadev, substream, chip->pci); 932 clean_via_table(viadev, substream, chip->pci);
927 snd_pcm_lib_free_pages(substream); 933 snd_pcm_lib_free_pages(substream);
@@ -932,7 +938,7 @@ static int snd_via82xx_hw_free(snd_pcm_substream_t * substream)
932/* 938/*
933 * set up the table pointer 939 * set up the table pointer
934 */ 940 */
935static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) 941static void snd_via82xx_set_table_ptr(struct via82xx *chip, struct viadev *viadev)
936{ 942{
937 snd_via82xx_codec_ready(chip, 0); 943 snd_via82xx_codec_ready(chip, 0);
938 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); 944 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR));
@@ -943,7 +949,8 @@ static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev)
943/* 949/*
944 * prepare callback for playback and capture on via686 950 * prepare callback for playback and capture on via686
945 */ 951 */
946static void via686_setup_format(via82xx_t *chip, viadev_t *viadev, snd_pcm_runtime_t *runtime) 952static void via686_setup_format(struct via82xx *chip, struct viadev *viadev,
953 struct snd_pcm_runtime *runtime)
947{ 954{
948 snd_via82xx_channel_reset(chip, viadev); 955 snd_via82xx_channel_reset(chip, viadev);
949 /* this must be set after channel_reset */ 956 /* this must be set after channel_reset */
@@ -956,11 +963,11 @@ static void via686_setup_format(via82xx_t *chip, viadev_t *viadev, snd_pcm_runti
956 VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE)); 963 VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE));
957} 964}
958 965
959static int snd_via686_playback_prepare(snd_pcm_substream_t *substream) 966static int snd_via686_playback_prepare(struct snd_pcm_substream *substream)
960{ 967{
961 via82xx_t *chip = snd_pcm_substream_chip(substream); 968 struct via82xx *chip = snd_pcm_substream_chip(substream);
962 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 969 struct viadev *viadev = substream->runtime->private_data;
963 snd_pcm_runtime_t *runtime = substream->runtime; 970 struct snd_pcm_runtime *runtime = substream->runtime;
964 971
965 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); 972 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate);
966 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); 973 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate);
@@ -968,11 +975,11 @@ static int snd_via686_playback_prepare(snd_pcm_substream_t *substream)
968 return 0; 975 return 0;
969} 976}
970 977
971static int snd_via686_capture_prepare(snd_pcm_substream_t *substream) 978static int snd_via686_capture_prepare(struct snd_pcm_substream *substream)
972{ 979{
973 via82xx_t *chip = snd_pcm_substream_chip(substream); 980 struct via82xx *chip = snd_pcm_substream_chip(substream);
974 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 981 struct viadev *viadev = substream->runtime->private_data;
975 snd_pcm_runtime_t *runtime = substream->runtime; 982 struct snd_pcm_runtime *runtime = substream->runtime;
976 983
977 snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); 984 snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
978 via686_setup_format(chip, viadev, runtime); 985 via686_setup_format(chip, viadev, runtime);
@@ -1002,11 +1009,11 @@ static int via_lock_rate(struct via_rate_lock *rec, int rate)
1002/* 1009/*
1003 * prepare callback for DSX playback on via823x 1010 * prepare callback for DSX playback on via823x
1004 */ 1011 */
1005static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream) 1012static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream)
1006{ 1013{
1007 via82xx_t *chip = snd_pcm_substream_chip(substream); 1014 struct via82xx *chip = snd_pcm_substream_chip(substream);
1008 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 1015 struct viadev *viadev = substream->runtime->private_data;
1009 snd_pcm_runtime_t *runtime = substream->runtime; 1016 struct snd_pcm_runtime *runtime = substream->runtime;
1010 int ac97_rate = chip->dxs_src ? 48000 : runtime->rate; 1017 int ac97_rate = chip->dxs_src ? 48000 : runtime->rate;
1011 int rate_changed; 1018 int rate_changed;
1012 u32 rbits; 1019 u32 rbits;
@@ -1022,12 +1029,15 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream)
1022 if (runtime->rate == 48000) 1029 if (runtime->rate == 48000)
1023 rbits = 0xfffff; 1030 rbits = 0xfffff;
1024 else 1031 else
1025 rbits = (0x100000 / 48000) * runtime->rate + ((0x100000 % 48000) * runtime->rate) / 48000; 1032 rbits = (0x100000 / 48000) * runtime->rate +
1033 ((0x100000 % 48000) * runtime->rate) / 48000;
1026 snd_assert((rbits & ~0xfffff) == 0, return -EINVAL); 1034 snd_assert((rbits & ~0xfffff) == 0, return -EINVAL);
1027 snd_via82xx_channel_reset(chip, viadev); 1035 snd_via82xx_channel_reset(chip, viadev);
1028 snd_via82xx_set_table_ptr(chip, viadev); 1036 snd_via82xx_set_table_ptr(chip, viadev);
1029 outb(chip->playback_volume[viadev->reg_offset / 0x10][0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L)); 1037 outb(chip->playback_volume[viadev->reg_offset / 0x10][0],
1030 outb(chip->playback_volume[viadev->reg_offset / 0x10][1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R)); 1038 VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L));
1039 outb(chip->playback_volume[viadev->reg_offset / 0x10][1],
1040 VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R));
1031 outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */ 1041 outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */
1032 (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */ 1042 (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */
1033 rbits | /* rate */ 1043 rbits | /* rate */
@@ -1041,11 +1051,11 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream)
1041/* 1051/*
1042 * prepare callback for multi-channel playback on via823x 1052 * prepare callback for multi-channel playback on via823x
1043 */ 1053 */
1044static int snd_via8233_multi_prepare(snd_pcm_substream_t *substream) 1054static int snd_via8233_multi_prepare(struct snd_pcm_substream *substream)
1045{ 1055{
1046 via82xx_t *chip = snd_pcm_substream_chip(substream); 1056 struct via82xx *chip = snd_pcm_substream_chip(substream);
1047 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 1057 struct viadev *viadev = substream->runtime->private_data;
1048 snd_pcm_runtime_t *runtime = substream->runtime; 1058 struct snd_pcm_runtime *runtime = substream->runtime;
1049 unsigned int slots; 1059 unsigned int slots;
1050 int fmt; 1060 int fmt;
1051 1061
@@ -1058,7 +1068,8 @@ static int snd_via8233_multi_prepare(snd_pcm_substream_t *substream)
1058 snd_via82xx_channel_reset(chip, viadev); 1068 snd_via82xx_channel_reset(chip, viadev);
1059 snd_via82xx_set_table_ptr(chip, viadev); 1069 snd_via82xx_set_table_ptr(chip, viadev);
1060 1070
1061 fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT; 1071 fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ?
1072 VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT;
1062 fmt |= runtime->channels << 4; 1073 fmt |= runtime->channels << 4;
1063 outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT)); 1074 outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT));
1064#if 0 1075#if 0
@@ -1089,11 +1100,11 @@ static int snd_via8233_multi_prepare(snd_pcm_substream_t *substream)
1089/* 1100/*
1090 * prepare callback for capture on via823x 1101 * prepare callback for capture on via823x
1091 */ 1102 */
1092static int snd_via8233_capture_prepare(snd_pcm_substream_t *substream) 1103static int snd_via8233_capture_prepare(struct snd_pcm_substream *substream)
1093{ 1104{
1094 via82xx_t *chip = snd_pcm_substream_chip(substream); 1105 struct via82xx *chip = snd_pcm_substream_chip(substream);
1095 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 1106 struct viadev *viadev = substream->runtime->private_data;
1096 snd_pcm_runtime_t *runtime = substream->runtime; 1107 struct snd_pcm_runtime *runtime = substream->runtime;
1097 1108
1098 if (via_lock_rate(&chip->rates[1], runtime->rate) < 0) 1109 if (via_lock_rate(&chip->rates[1], runtime->rate) < 0)
1099 return -EINVAL; 1110 return -EINVAL;
@@ -1114,7 +1125,7 @@ static int snd_via8233_capture_prepare(snd_pcm_substream_t *substream)
1114/* 1125/*
1115 * pcm hardware definition, identical for both playback and capture 1126 * pcm hardware definition, identical for both playback and capture
1116 */ 1127 */
1117static snd_pcm_hardware_t snd_via82xx_hw = 1128static struct snd_pcm_hardware snd_via82xx_hw =
1118{ 1129{
1119 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1130 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1120 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1131 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -1139,9 +1150,10 @@ static snd_pcm_hardware_t snd_via82xx_hw =
1139/* 1150/*
1140 * open callback skeleton 1151 * open callback skeleton
1141 */ 1152 */
1142static int snd_via82xx_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_substream_t * substream) 1153static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev,
1154 struct snd_pcm_substream *substream)
1143{ 1155{
1144 snd_pcm_runtime_t *runtime = substream->runtime; 1156 struct snd_pcm_runtime *runtime = substream->runtime;
1145 int err; 1157 int err;
1146 struct via_rate_lock *ratep; 1158 struct via_rate_lock *ratep;
1147 1159
@@ -1191,10 +1203,10 @@ static int snd_via82xx_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_subst
1191/* 1203/*
1192 * open callback for playback on via686 and via823x DSX 1204 * open callback for playback on via686 and via823x DSX
1193 */ 1205 */
1194static int snd_via82xx_playback_open(snd_pcm_substream_t * substream) 1206static int snd_via82xx_playback_open(struct snd_pcm_substream *substream)
1195{ 1207{
1196 via82xx_t *chip = snd_pcm_substream_chip(substream); 1208 struct via82xx *chip = snd_pcm_substream_chip(substream);
1197 viadev_t *viadev = &chip->devs[chip->playback_devno + substream->number]; 1209 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number];
1198 int err; 1210 int err;
1199 1211
1200 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) 1212 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0)
@@ -1205,10 +1217,10 @@ static int snd_via82xx_playback_open(snd_pcm_substream_t * substream)
1205/* 1217/*
1206 * open callback for playback on via823x multi-channel 1218 * open callback for playback on via823x multi-channel
1207 */ 1219 */
1208static int snd_via8233_multi_open(snd_pcm_substream_t * substream) 1220static int snd_via8233_multi_open(struct snd_pcm_substream *substream)
1209{ 1221{
1210 via82xx_t *chip = snd_pcm_substream_chip(substream); 1222 struct via82xx *chip = snd_pcm_substream_chip(substream);
1211 viadev_t *viadev = &chip->devs[chip->multi_devno]; 1223 struct viadev *viadev = &chip->devs[chip->multi_devno];
1212 int err; 1224 int err;
1213 /* channels constraint for VIA8233A 1225 /* channels constraint for VIA8233A
1214 * 3 and 5 channels are not supported 1226 * 3 and 5 channels are not supported
@@ -1216,7 +1228,7 @@ static int snd_via8233_multi_open(snd_pcm_substream_t * substream)
1216 static unsigned int channels[] = { 1228 static unsigned int channels[] = {
1217 1, 2, 4, 6 1229 1, 2, 4, 6
1218 }; 1230 };
1219 static snd_pcm_hw_constraint_list_t hw_constraints_channels = { 1231 static struct snd_pcm_hw_constraint_list hw_constraints_channels = {
1220 .count = ARRAY_SIZE(channels), 1232 .count = ARRAY_SIZE(channels),
1221 .list = channels, 1233 .list = channels,
1222 .mask = 0, 1234 .mask = 0,
@@ -1226,17 +1238,19 @@ static int snd_via8233_multi_open(snd_pcm_substream_t * substream)
1226 return err; 1238 return err;
1227 substream->runtime->hw.channels_max = 6; 1239 substream->runtime->hw.channels_max = 6;
1228 if (chip->revision == VIA_REV_8233A) 1240 if (chip->revision == VIA_REV_8233A)
1229 snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); 1241 snd_pcm_hw_constraint_list(substream->runtime, 0,
1242 SNDRV_PCM_HW_PARAM_CHANNELS,
1243 &hw_constraints_channels);
1230 return 0; 1244 return 0;
1231} 1245}
1232 1246
1233/* 1247/*
1234 * open callback for capture on via686 and via823x 1248 * open callback for capture on via686 and via823x
1235 */ 1249 */
1236static int snd_via82xx_capture_open(snd_pcm_substream_t * substream) 1250static int snd_via82xx_capture_open(struct snd_pcm_substream *substream)
1237{ 1251{
1238 via82xx_t *chip = snd_pcm_substream_chip(substream); 1252 struct via82xx *chip = snd_pcm_substream_chip(substream);
1239 viadev_t *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; 1253 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device];
1240 1254
1241 return snd_via82xx_pcm_open(chip, viadev, substream); 1255 return snd_via82xx_pcm_open(chip, viadev, substream);
1242} 1256}
@@ -1244,10 +1258,10 @@ static int snd_via82xx_capture_open(snd_pcm_substream_t * substream)
1244/* 1258/*
1245 * close callback 1259 * close callback
1246 */ 1260 */
1247static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream) 1261static int snd_via82xx_pcm_close(struct snd_pcm_substream *substream)
1248{ 1262{
1249 via82xx_t *chip = snd_pcm_substream_chip(substream); 1263 struct via82xx *chip = snd_pcm_substream_chip(substream);
1250 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 1264 struct viadev *viadev = substream->runtime->private_data;
1251 struct via_rate_lock *ratep; 1265 struct via_rate_lock *ratep;
1252 1266
1253 /* release the rate lock */ 1267 /* release the rate lock */
@@ -1264,7 +1278,7 @@ static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream)
1264 1278
1265 1279
1266/* via686 playback callbacks */ 1280/* via686 playback callbacks */
1267static snd_pcm_ops_t snd_via686_playback_ops = { 1281static struct snd_pcm_ops snd_via686_playback_ops = {
1268 .open = snd_via82xx_playback_open, 1282 .open = snd_via82xx_playback_open,
1269 .close = snd_via82xx_pcm_close, 1283 .close = snd_via82xx_pcm_close,
1270 .ioctl = snd_pcm_lib_ioctl, 1284 .ioctl = snd_pcm_lib_ioctl,
@@ -1277,7 +1291,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = {
1277}; 1291};
1278 1292
1279/* via686 capture callbacks */ 1293/* via686 capture callbacks */
1280static snd_pcm_ops_t snd_via686_capture_ops = { 1294static struct snd_pcm_ops snd_via686_capture_ops = {
1281 .open = snd_via82xx_capture_open, 1295 .open = snd_via82xx_capture_open,
1282 .close = snd_via82xx_pcm_close, 1296 .close = snd_via82xx_pcm_close,
1283 .ioctl = snd_pcm_lib_ioctl, 1297 .ioctl = snd_pcm_lib_ioctl,
@@ -1290,7 +1304,7 @@ static snd_pcm_ops_t snd_via686_capture_ops = {
1290}; 1304};
1291 1305
1292/* via823x DSX playback callbacks */ 1306/* via823x DSX playback callbacks */
1293static snd_pcm_ops_t snd_via8233_playback_ops = { 1307static struct snd_pcm_ops snd_via8233_playback_ops = {
1294 .open = snd_via82xx_playback_open, 1308 .open = snd_via82xx_playback_open,
1295 .close = snd_via82xx_pcm_close, 1309 .close = snd_via82xx_pcm_close,
1296 .ioctl = snd_pcm_lib_ioctl, 1310 .ioctl = snd_pcm_lib_ioctl,
@@ -1303,7 +1317,7 @@ static snd_pcm_ops_t snd_via8233_playback_ops = {
1303}; 1317};
1304 1318
1305/* via823x multi-channel playback callbacks */ 1319/* via823x multi-channel playback callbacks */
1306static snd_pcm_ops_t snd_via8233_multi_ops = { 1320static struct snd_pcm_ops snd_via8233_multi_ops = {
1307 .open = snd_via8233_multi_open, 1321 .open = snd_via8233_multi_open,
1308 .close = snd_via82xx_pcm_close, 1322 .close = snd_via82xx_pcm_close,
1309 .ioctl = snd_pcm_lib_ioctl, 1323 .ioctl = snd_pcm_lib_ioctl,
@@ -1316,7 +1330,7 @@ static snd_pcm_ops_t snd_via8233_multi_ops = {
1316}; 1330};
1317 1331
1318/* via823x capture callbacks */ 1332/* via823x capture callbacks */
1319static snd_pcm_ops_t snd_via8233_capture_ops = { 1333static struct snd_pcm_ops snd_via8233_capture_ops = {
1320 .open = snd_via82xx_capture_open, 1334 .open = snd_via82xx_capture_open,
1321 .close = snd_via82xx_pcm_close, 1335 .close = snd_via82xx_pcm_close,
1322 .ioctl = snd_pcm_lib_ioctl, 1336 .ioctl = snd_pcm_lib_ioctl,
@@ -1329,7 +1343,8 @@ static snd_pcm_ops_t snd_via8233_capture_ops = {
1329}; 1343};
1330 1344
1331 1345
1332static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int shadow_pos, int direction) 1346static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset,
1347 int shadow_pos, int direction)
1333{ 1348{
1334 chip->devs[idx].reg_offset = reg_offset; 1349 chip->devs[idx].reg_offset = reg_offset;
1335 chip->devs[idx].shadow_shift = shadow_pos * 4; 1350 chip->devs[idx].shadow_shift = shadow_pos * 4;
@@ -1340,9 +1355,9 @@ static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int s
1340/* 1355/*
1341 * create pcm instances for VIA8233, 8233C and 8235 (not 8233A) 1356 * create pcm instances for VIA8233, 8233C and 8235 (not 8233A)
1342 */ 1357 */
1343static int __devinit snd_via8233_pcm_new(via82xx_t *chip) 1358static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
1344{ 1359{
1345 snd_pcm_t *pcm; 1360 struct snd_pcm *pcm;
1346 int i, err; 1361 int i, err;
1347 1362
1348 chip->playback_devno = 0; /* x 4 */ 1363 chip->playback_devno = 0; /* x 4 */
@@ -1367,7 +1382,8 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip)
1367 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); 1382 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
1368 1383
1369 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1384 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1370 snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) 1385 snd_dma_pci_data(chip->pci),
1386 64*1024, 128*1024)) < 0)
1371 return err; 1387 return err;
1372 1388
1373 /* PCM #1: multi-channel playback and 2nd capture */ 1389 /* PCM #1: multi-channel playback and 2nd capture */
@@ -1385,7 +1401,8 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip)
1385 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); 1401 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1);
1386 1402
1387 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1403 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1388 snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) 1404 snd_dma_pci_data(chip->pci),
1405 64*1024, 128*1024)) < 0)
1389 return err; 1406 return err;
1390 1407
1391 return 0; 1408 return 0;
@@ -1394,9 +1411,9 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip)
1394/* 1411/*
1395 * create pcm instances for VIA8233A 1412 * create pcm instances for VIA8233A
1396 */ 1413 */
1397static int __devinit snd_via8233a_pcm_new(via82xx_t *chip) 1414static int __devinit snd_via8233a_pcm_new(struct via82xx *chip)
1398{ 1415{
1399 snd_pcm_t *pcm; 1416 struct snd_pcm *pcm;
1400 int err; 1417 int err;
1401 1418
1402 chip->multi_devno = 0; 1419 chip->multi_devno = 0;
@@ -1420,7 +1437,8 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip)
1420 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); 1437 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
1421 1438
1422 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1439 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1423 snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) 1440 snd_dma_pci_data(chip->pci),
1441 64*1024, 128*1024)) < 0)
1424 return err; 1442 return err;
1425 1443
1426 /* SPDIF supported? */ 1444 /* SPDIF supported? */
@@ -1439,7 +1457,8 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip)
1439 init_viadev(chip, chip->playback_devno, 0x30, 3, 0); 1457 init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
1440 1458
1441 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1459 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1442 snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) 1460 snd_dma_pci_data(chip->pci),
1461 64*1024, 128*1024)) < 0)
1443 return err; 1462 return err;
1444 1463
1445 return 0; 1464 return 0;
@@ -1448,9 +1467,9 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip)
1448/* 1467/*
1449 * create a pcm instance for via686a/b 1468 * create a pcm instance for via686a/b
1450 */ 1469 */
1451static int __devinit snd_via686_pcm_new(via82xx_t *chip) 1470static int __devinit snd_via686_pcm_new(struct via82xx *chip)
1452{ 1471{
1453 snd_pcm_t *pcm; 1472 struct snd_pcm *pcm;
1454 int err; 1473 int err;
1455 1474
1456 chip->playback_devno = 0; 1475 chip->playback_devno = 0;
@@ -1470,7 +1489,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip)
1470 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); 1489 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
1471 1490
1472 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1491 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1473 snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) 1492 snd_dma_pci_data(chip->pci),
1493 64*1024, 128*1024)) < 0)
1474 return err; 1494 return err;
1475 1495
1476 return 0; 1496 return 0;
@@ -1481,7 +1501,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip)
1481 * Mixer part 1501 * Mixer part
1482 */ 1502 */
1483 1503
1484static int snd_via8233_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 1504static int snd_via8233_capture_source_info(struct snd_kcontrol *kcontrol,
1505 struct snd_ctl_elem_info *uinfo)
1485{ 1506{
1486 /* formerly they were "Line" and "Mic", but it looks like that they 1507 /* formerly they were "Line" and "Mic", but it looks like that they
1487 * have nothing to do with the actual physical connections... 1508 * have nothing to do with the actual physical connections...
@@ -1498,17 +1519,19 @@ static int snd_via8233_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_ele
1498 return 0; 1519 return 0;
1499} 1520}
1500 1521
1501static int snd_via8233_capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1522static int snd_via8233_capture_source_get(struct snd_kcontrol *kcontrol,
1523 struct snd_ctl_elem_value *ucontrol)
1502{ 1524{
1503 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1525 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1504 unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL); 1526 unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL);
1505 ucontrol->value.enumerated.item[0] = inb(port) & VIA_REG_CAPTURE_CHANNEL_MIC ? 1 : 0; 1527 ucontrol->value.enumerated.item[0] = inb(port) & VIA_REG_CAPTURE_CHANNEL_MIC ? 1 : 0;
1506 return 0; 1528 return 0;
1507} 1529}
1508 1530
1509static int snd_via8233_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1531static int snd_via8233_capture_source_put(struct snd_kcontrol *kcontrol,
1532 struct snd_ctl_elem_value *ucontrol)
1510{ 1533{
1511 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1534 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1512 unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL); 1535 unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL);
1513 u8 val, oval; 1536 u8 val, oval;
1514 1537
@@ -1523,7 +1546,7 @@ static int snd_via8233_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem
1523 return val != oval; 1546 return val != oval;
1524} 1547}
1525 1548
1526static snd_kcontrol_new_t snd_via8233_capture_source __devinitdata = { 1549static struct snd_kcontrol_new snd_via8233_capture_source __devinitdata = {
1527 .name = "Input Source Select", 1550 .name = "Input Source Select",
1528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1551 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1529 .info = snd_via8233_capture_source_info, 1552 .info = snd_via8233_capture_source_info,
@@ -1531,7 +1554,8 @@ static snd_kcontrol_new_t snd_via8233_capture_source __devinitdata = {
1531 .put = snd_via8233_capture_source_put, 1554 .put = snd_via8233_capture_source_put,
1532}; 1555};
1533 1556
1534static int snd_via8233_dxs3_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 1557static int snd_via8233_dxs3_spdif_info(struct snd_kcontrol *kcontrol,
1558 struct snd_ctl_elem_info *uinfo)
1535{ 1559{
1536 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1560 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1537 uinfo->count = 1; 1561 uinfo->count = 1;
@@ -1540,9 +1564,10 @@ static int snd_via8233_dxs3_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in
1540 return 0; 1564 return 0;
1541} 1565}
1542 1566
1543static int snd_via8233_dxs3_spdif_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1567static int snd_via8233_dxs3_spdif_get(struct snd_kcontrol *kcontrol,
1568 struct snd_ctl_elem_value *ucontrol)
1544{ 1569{
1545 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1570 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1546 u8 val; 1571 u8 val;
1547 1572
1548 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); 1573 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val);
@@ -1550,9 +1575,10 @@ static int snd_via8233_dxs3_spdif_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val
1550 return 0; 1575 return 0;
1551} 1576}
1552 1577
1553static int snd_via8233_dxs3_spdif_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1578static int snd_via8233_dxs3_spdif_put(struct snd_kcontrol *kcontrol,
1579 struct snd_ctl_elem_value *ucontrol)
1554{ 1580{
1555 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1581 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1556 u8 val, oval; 1582 u8 val, oval;
1557 1583
1558 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval); 1584 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval);
@@ -1568,7 +1594,7 @@ static int snd_via8233_dxs3_spdif_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val
1568 return 0; 1594 return 0;
1569} 1595}
1570 1596
1571static snd_kcontrol_new_t snd_via8233_dxs3_spdif_control __devinitdata = { 1597static struct snd_kcontrol_new snd_via8233_dxs3_spdif_control __devinitdata = {
1572 .name = SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), 1598 .name = SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH),
1573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1574 .info = snd_via8233_dxs3_spdif_info, 1600 .info = snd_via8233_dxs3_spdif_info,
@@ -1576,7 +1602,8 @@ static snd_kcontrol_new_t snd_via8233_dxs3_spdif_control __devinitdata = {
1576 .put = snd_via8233_dxs3_spdif_put, 1602 .put = snd_via8233_dxs3_spdif_put,
1577}; 1603};
1578 1604
1579static int snd_via8233_dxs_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 1605static int snd_via8233_dxs_volume_info(struct snd_kcontrol *kcontrol,
1606 struct snd_ctl_elem_info *uinfo)
1580{ 1607{
1581 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1608 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1582 uinfo->count = 2; 1609 uinfo->count = 2;
@@ -1585,9 +1612,10 @@ static int snd_via8233_dxs_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in
1585 return 0; 1612 return 0;
1586} 1613}
1587 1614
1588static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1615static int snd_via8233_dxs_volume_get(struct snd_kcontrol *kcontrol,
1616 struct snd_ctl_elem_value *ucontrol)
1589{ 1617{
1590 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1618 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1591 unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id); 1619 unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
1592 1620
1593 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0]; 1621 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0];
@@ -1595,17 +1623,19 @@ static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val
1595 return 0; 1623 return 0;
1596} 1624}
1597 1625
1598static int snd_via8233_pcmdxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1626static int snd_via8233_pcmdxs_volume_get(struct snd_kcontrol *kcontrol,
1627 struct snd_ctl_elem_value *ucontrol)
1599{ 1628{
1600 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1629 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1601 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0]; 1630 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0];
1602 ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1]; 1631 ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1];
1603 return 0; 1632 return 0;
1604} 1633}
1605 1634
1606static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1635static int snd_via8233_dxs_volume_put(struct snd_kcontrol *kcontrol,
1636 struct snd_ctl_elem_value *ucontrol)
1607{ 1637{
1608 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1638 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1609 unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id); 1639 unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
1610 unsigned long port = chip->port + 0x10 * idx; 1640 unsigned long port = chip->port + 0x10 * idx;
1611 unsigned char val; 1641 unsigned char val;
@@ -1625,9 +1655,10 @@ static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val
1625 return change; 1655 return change;
1626} 1656}
1627 1657
1628static int snd_via8233_pcmdxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1658static int snd_via8233_pcmdxs_volume_put(struct snd_kcontrol *kcontrol,
1659 struct snd_ctl_elem_value *ucontrol)
1629{ 1660{
1630 via82xx_t *chip = snd_kcontrol_chip(kcontrol); 1661 struct via82xx *chip = snd_kcontrol_chip(kcontrol);
1631 unsigned int idx; 1662 unsigned int idx;
1632 unsigned char val; 1663 unsigned char val;
1633 int i, change = 0; 1664 int i, change = 0;
@@ -1650,7 +1681,7 @@ static int snd_via8233_pcmdxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_
1650 return change; 1681 return change;
1651} 1682}
1652 1683
1653static snd_kcontrol_new_t snd_via8233_pcmdxs_volume_control __devinitdata = { 1684static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = {
1654 .name = "PCM Playback Volume", 1685 .name = "PCM Playback Volume",
1655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1656 .info = snd_via8233_dxs_volume_info, 1687 .info = snd_via8233_dxs_volume_info,
@@ -1658,7 +1689,7 @@ static snd_kcontrol_new_t snd_via8233_pcmdxs_volume_control __devinitdata = {
1658 .put = snd_via8233_pcmdxs_volume_put, 1689 .put = snd_via8233_pcmdxs_volume_put,
1659}; 1690};
1660 1691
1661static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = { 1692static struct snd_kcontrol_new snd_via8233_dxs_volume_control __devinitdata = {
1662 .name = "VIA DXS Playback Volume", 1693 .name = "VIA DXS Playback Volume",
1663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1694 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1664 .count = 4, 1695 .count = 4,
@@ -1670,15 +1701,15 @@ static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = {
1670/* 1701/*
1671 */ 1702 */
1672 1703
1673static void snd_via82xx_mixer_free_ac97_bus(ac97_bus_t *bus) 1704static void snd_via82xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus)
1674{ 1705{
1675 via82xx_t *chip = bus->private_data; 1706 struct via82xx *chip = bus->private_data;
1676 chip->ac97_bus = NULL; 1707 chip->ac97_bus = NULL;
1677} 1708}
1678 1709
1679static void snd_via82xx_mixer_free_ac97(ac97_t *ac97) 1710static void snd_via82xx_mixer_free_ac97(struct snd_ac97 *ac97)
1680{ 1711{
1681 via82xx_t *chip = ac97->private_data; 1712 struct via82xx *chip = ac97->private_data;
1682 chip->ac97 = NULL; 1713 chip->ac97 = NULL;
1683} 1714}
1684 1715
@@ -1735,11 +1766,11 @@ static struct ac97_quirk ac97_quirks[] = {
1735 { } /* terminator */ 1766 { } /* terminator */
1736}; 1767};
1737 1768
1738static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, const char *quirk_override) 1769static int __devinit snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_override)
1739{ 1770{
1740 ac97_template_t ac97; 1771 struct snd_ac97_template ac97;
1741 int err; 1772 int err;
1742 static ac97_bus_ops_t ops = { 1773 static struct snd_ac97_bus_ops ops = {
1743 .write = snd_via82xx_codec_write, 1774 .write = snd_via82xx_codec_write,
1744 .read = snd_via82xx_codec_read, 1775 .read = snd_via82xx_codec_read,
1745 .wait = snd_via82xx_codec_wait, 1776 .wait = snd_via82xx_codec_wait,
@@ -1770,7 +1801,7 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, const char *quirk_ov
1770 1801
1771#ifdef SUPPORT_JOYSTICK 1802#ifdef SUPPORT_JOYSTICK
1772#define JOYSTICK_ADDR 0x200 1803#define JOYSTICK_ADDR 0x200
1773static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) 1804static int __devinit snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy)
1774{ 1805{
1775 struct gameport *gp; 1806 struct gameport *gp;
1776 struct resource *r; 1807 struct resource *r;
@@ -1780,7 +1811,8 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *
1780 1811
1781 r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); 1812 r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport");
1782 if (!r) { 1813 if (!r) {
1783 printk(KERN_WARNING "via82xx: cannot reserve joystick port 0x%#x\n", JOYSTICK_ADDR); 1814 printk(KERN_WARNING "via82xx: cannot reserve joystick port 0x%#x\n",
1815 JOYSTICK_ADDR);
1784 return -EBUSY; 1816 return -EBUSY;
1785 } 1817 }
1786 1818
@@ -1806,7 +1838,7 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *
1806 return 0; 1838 return 0;
1807} 1839}
1808 1840
1809static void snd_via686_free_gameport(via82xx_t *chip) 1841static void snd_via686_free_gameport(struct via82xx *chip)
1810{ 1842{
1811 if (chip->gameport) { 1843 if (chip->gameport) {
1812 struct resource *r = gameport_get_port_data(chip->gameport); 1844 struct resource *r = gameport_get_port_data(chip->gameport);
@@ -1817,11 +1849,11 @@ static void snd_via686_free_gameport(via82xx_t *chip)
1817 } 1849 }
1818} 1850}
1819#else 1851#else
1820static inline int snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) 1852static inline int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy)
1821{ 1853{
1822 return -ENOSYS; 1854 return -ENOSYS;
1823} 1855}
1824static inline void snd_via686_free_gameport(via82xx_t *chip) { } 1856static inline void snd_via686_free_gameport(struct via82xx *chip) { }
1825#endif 1857#endif
1826 1858
1827 1859
@@ -1829,7 +1861,7 @@ static inline void snd_via686_free_gameport(via82xx_t *chip) { }
1829 * 1861 *
1830 */ 1862 */
1831 1863
1832static int __devinit snd_via8233_init_misc(via82xx_t *chip) 1864static int __devinit snd_via8233_init_misc(struct via82xx *chip)
1833{ 1865{
1834 int i, err, caps; 1866 int i, err, caps;
1835 unsigned char val; 1867 unsigned char val;
@@ -1850,7 +1882,7 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip)
1850 /* when no h/w PCM volume control is found, use DXS volume control 1882 /* when no h/w PCM volume control is found, use DXS volume control
1851 * as the PCM vol control 1883 * as the PCM vol control
1852 */ 1884 */
1853 snd_ctl_elem_id_t sid; 1885 struct snd_ctl_elem_id sid;
1854 memset(&sid, 0, sizeof(sid)); 1886 memset(&sid, 0, sizeof(sid));
1855 strcpy(sid.name, "PCM Playback Volume"); 1887 strcpy(sid.name, "PCM Playback Volume");
1856 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1888 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
@@ -1877,7 +1909,7 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip)
1877 return 0; 1909 return 0;
1878} 1910}
1879 1911
1880static int __devinit snd_via686_init_misc(via82xx_t *chip) 1912static int __devinit snd_via686_init_misc(struct via82xx *chip)
1881{ 1913{
1882 unsigned char legacy, legacy_cfg; 1914 unsigned char legacy, legacy_cfg;
1883 int rev_h = 0; 1915 int rev_h = 0;
@@ -1954,9 +1986,10 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip)
1954/* 1986/*
1955 * proc interface 1987 * proc interface
1956 */ 1988 */
1957static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) 1989static void snd_via82xx_proc_read(struct snd_info_entry *entry,
1990 struct snd_info_buffer *buffer)
1958{ 1991{
1959 via82xx_t *chip = entry->private_data; 1992 struct via82xx *chip = entry->private_data;
1960 int i; 1993 int i;
1961 1994
1962 snd_iprintf(buffer, "%s\n\n", chip->card->longname); 1995 snd_iprintf(buffer, "%s\n\n", chip->card->longname);
@@ -1965,9 +1998,9 @@ static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *bu
1965 } 1998 }
1966} 1999}
1967 2000
1968static void __devinit snd_via82xx_proc_init(via82xx_t *chip) 2001static void __devinit snd_via82xx_proc_init(struct via82xx *chip)
1969{ 2002{
1970 snd_info_entry_t *entry; 2003 struct snd_info_entry *entry;
1971 2004
1972 if (! snd_card_proc_new(chip->card, "via82xx", &entry)) 2005 if (! snd_card_proc_new(chip->card, "via82xx", &entry))
1973 snd_info_set_text_ops(entry, chip, 1024, snd_via82xx_proc_read); 2006 snd_info_set_text_ops(entry, chip, 1024, snd_via82xx_proc_read);
@@ -1977,7 +2010,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip)
1977 * 2010 *
1978 */ 2011 */
1979 2012
1980static int snd_via82xx_chip_init(via82xx_t *chip) 2013static int snd_via82xx_chip_init(struct via82xx *chip)
1981{ 2014{
1982 unsigned int val; 2015 unsigned int val;
1983 unsigned long end_time; 2016 unsigned long end_time;
@@ -2080,7 +2113,8 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
2080 unsigned long port = chip->port + 0x10 * idx; 2113 unsigned long port = chip->port + 0x10 * idx;
2081 for (i = 0; i < 2; i++) { 2114 for (i = 0; i < 2; i++) {
2082 chip->playback_volume[idx][i]=chip->playback_volume_c[i]; 2115 chip->playback_volume[idx][i]=chip->playback_volume_c[i];
2083 outb(chip->playback_volume_c[i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i); 2116 outb(chip->playback_volume_c[i],
2117 port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
2084 } 2118 }
2085 } 2119 }
2086 } 2120 }
@@ -2092,9 +2126,9 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
2092/* 2126/*
2093 * power management 2127 * power management
2094 */ 2128 */
2095static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state) 2129static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state)
2096{ 2130{
2097 via82xx_t *chip = card->pm_private_data; 2131 struct via82xx *chip = card->pm_private_data;
2098 int i; 2132 int i;
2099 2133
2100 for (i = 0; i < 2; i++) 2134 for (i = 0; i < 2; i++)
@@ -2117,9 +2151,9 @@ static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state)
2117 return 0; 2151 return 0;
2118} 2152}
2119 2153
2120static int snd_via82xx_resume(snd_card_t *card) 2154static int snd_via82xx_resume(struct snd_card *card)
2121{ 2155{
2122 via82xx_t *chip = card->pm_private_data; 2156 struct via82xx *chip = card->pm_private_data;
2123 int i; 2157 int i;
2124 2158
2125 pci_enable_device(chip->pci); 2159 pci_enable_device(chip->pci);
@@ -2147,7 +2181,7 @@ static int snd_via82xx_resume(snd_card_t *card)
2147} 2181}
2148#endif /* CONFIG_PM */ 2182#endif /* CONFIG_PM */
2149 2183
2150static int snd_via82xx_free(via82xx_t *chip) 2184static int snd_via82xx_free(struct via82xx *chip)
2151{ 2185{
2152 unsigned int i; 2186 unsigned int i;
2153 2187
@@ -2159,7 +2193,7 @@ static int snd_via82xx_free(via82xx_t *chip)
2159 synchronize_irq(chip->irq); 2193 synchronize_irq(chip->irq);
2160 __end_hw: 2194 __end_hw:
2161 if (chip->irq >= 0) 2195 if (chip->irq >= 0)
2162 free_irq(chip->irq, (void *)chip); 2196 free_irq(chip->irq, chip);
2163 release_and_free_resource(chip->mpu_res); 2197 release_and_free_resource(chip->mpu_res);
2164 pci_release_regions(chip->pci); 2198 pci_release_regions(chip->pci);
2165 2199
@@ -2173,22 +2207,22 @@ static int snd_via82xx_free(via82xx_t *chip)
2173 return 0; 2207 return 0;
2174} 2208}
2175 2209
2176static int snd_via82xx_dev_free(snd_device_t *device) 2210static int snd_via82xx_dev_free(struct snd_device *device)
2177{ 2211{
2178 via82xx_t *chip = device->device_data; 2212 struct via82xx *chip = device->device_data;
2179 return snd_via82xx_free(chip); 2213 return snd_via82xx_free(chip);
2180} 2214}
2181 2215
2182static int __devinit snd_via82xx_create(snd_card_t * card, 2216static int __devinit snd_via82xx_create(struct snd_card *card,
2183 struct pci_dev *pci, 2217 struct pci_dev *pci,
2184 int chip_type, 2218 int chip_type,
2185 int revision, 2219 int revision,
2186 unsigned int ac97_clock, 2220 unsigned int ac97_clock,
2187 via82xx_t ** r_via) 2221 struct via82xx ** r_via)
2188{ 2222{
2189 via82xx_t *chip; 2223 struct via82xx *chip;
2190 int err; 2224 int err;
2191 static snd_device_ops_t ops = { 2225 static struct snd_device_ops ops = {
2192 .dev_free = snd_via82xx_dev_free, 2226 .dev_free = snd_via82xx_dev_free,
2193 }; 2227 };
2194 2228
@@ -2225,7 +2259,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
2225 chip_type == TYPE_VIA8233 ? 2259 chip_type == TYPE_VIA8233 ?
2226 snd_via8233_interrupt : snd_via686_interrupt, 2260 snd_via8233_interrupt : snd_via686_interrupt,
2227 SA_INTERRUPT|SA_SHIRQ, 2261 SA_INTERRUPT|SA_SHIRQ,
2228 card->driver, (void *)chip)) { 2262 card->driver, chip)) {
2229 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2263 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2230 snd_via82xx_free(chip); 2264 snd_via82xx_free(chip);
2231 return -EBUSY; 2265 return -EBUSY;
@@ -2363,8 +2397,8 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2363static int __devinit snd_via82xx_probe(struct pci_dev *pci, 2397static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2364 const struct pci_device_id *pci_id) 2398 const struct pci_device_id *pci_id)
2365{ 2399{
2366 snd_card_t *card; 2400 struct snd_card *card;
2367 via82xx_t *chip; 2401 struct via82xx *chip;
2368 unsigned char revision; 2402 unsigned char revision;
2369 int chip_type = 0, card_type; 2403 int chip_type = 0, card_type;
2370 unsigned int i; 2404 unsigned int i;
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index b83660bd05b0..55ef69a8d2de 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -206,9 +206,6 @@ DEFINE_VIA_REGSET(MI, 0x50);
206 VIA_MC97_CTRL_SECONDARY) 206 VIA_MC97_CTRL_SECONDARY)
207 207
208 208
209typedef struct _snd_via82xx_modem via82xx_t;
210typedef struct via_dev viadev_t;
211
212/* 209/*
213 * pcm stream 210 * pcm stream
214 */ 211 */
@@ -220,11 +217,11 @@ struct snd_via_sg_table {
220 217
221#define VIA_TABLE_SIZE 255 218#define VIA_TABLE_SIZE 255
222 219
223struct via_dev { 220struct viadev {
224 unsigned int reg_offset; 221 unsigned int reg_offset;
225 unsigned long port; 222 unsigned long port;
226 int direction; /* playback = 0, capture = 1 */ 223 int direction; /* playback = 0, capture = 1 */
227 snd_pcm_substream_t *substream; 224 struct snd_pcm_substream *substream;
228 int running; 225 int running;
229 unsigned int tbl_entries; /* # descriptors */ 226 unsigned int tbl_entries; /* # descriptors */
230 struct snd_dma_buffer table; 227 struct snd_dma_buffer table;
@@ -239,7 +236,7 @@ enum { TYPE_CARD_VIA82XX_MODEM = 1 };
239 236
240#define VIA_MAX_MODEM_DEVS 2 237#define VIA_MAX_MODEM_DEVS 2
241 238
242struct _snd_via82xx_modem { 239struct via82xx_modem {
243 int irq; 240 int irq;
244 241
245 unsigned long port; 242 unsigned long port;
@@ -247,21 +244,21 @@ struct _snd_via82xx_modem {
247 unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ 244 unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */
248 245
249 struct pci_dev *pci; 246 struct pci_dev *pci;
250 snd_card_t *card; 247 struct snd_card *card;
251 248
252 unsigned int num_devs; 249 unsigned int num_devs;
253 unsigned int playback_devno, capture_devno; 250 unsigned int playback_devno, capture_devno;
254 viadev_t devs[VIA_MAX_MODEM_DEVS]; 251 struct viadev devs[VIA_MAX_MODEM_DEVS];
255 252
256 snd_pcm_t *pcms[2]; 253 struct snd_pcm *pcms[2];
257 254
258 ac97_bus_t *ac97_bus; 255 struct snd_ac97_bus *ac97_bus;
259 ac97_t *ac97; 256 struct snd_ac97 *ac97;
260 unsigned int ac97_clock; 257 unsigned int ac97_clock;
261 unsigned int ac97_secondary; /* secondary AC'97 codec is present */ 258 unsigned int ac97_secondary; /* secondary AC'97 codec is present */
262 259
263 spinlock_t reg_lock; 260 spinlock_t reg_lock;
264 snd_info_entry_t *proc_entry; 261 struct snd_info_entry *proc_entry;
265}; 262};
266 263
267static struct pci_device_id snd_via82xx_modem_ids[] = { 264static struct pci_device_id snd_via82xx_modem_ids[] = {
@@ -279,12 +276,12 @@ MODULE_DEVICE_TABLE(pci, snd_via82xx_modem_ids);
279 * periods = number of periods 276 * periods = number of periods
280 * fragsize = period size in bytes 277 * fragsize = period size in bytes
281 */ 278 */
282static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream, 279static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream,
283 struct pci_dev *pci, 280 struct pci_dev *pci,
284 unsigned int periods, unsigned int fragsize) 281 unsigned int periods, unsigned int fragsize)
285{ 282{
286 unsigned int i, idx, ofs, rest; 283 unsigned int i, idx, ofs, rest;
287 via82xx_t *chip = snd_pcm_substream_chip(substream); 284 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
288 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); 285 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
289 286
290 if (dev->table.area == NULL) { 287 if (dev->table.area == NULL) {
@@ -346,7 +343,7 @@ static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
346} 343}
347 344
348 345
349static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, 346static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream,
350 struct pci_dev *pci) 347 struct pci_dev *pci)
351{ 348{
352 if (dev->table.area) { 349 if (dev->table.area) {
@@ -362,17 +359,17 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
362 * Basic I/O 359 * Basic I/O
363 */ 360 */
364 361
365static inline unsigned int snd_via82xx_codec_xread(via82xx_t *chip) 362static inline unsigned int snd_via82xx_codec_xread(struct via82xx_modem *chip)
366{ 363{
367 return inl(VIAREG(chip, AC97)); 364 return inl(VIAREG(chip, AC97));
368} 365}
369 366
370static inline void snd_via82xx_codec_xwrite(via82xx_t *chip, unsigned int val) 367static inline void snd_via82xx_codec_xwrite(struct via82xx_modem *chip, unsigned int val)
371{ 368{
372 outl(val, VIAREG(chip, AC97)); 369 outl(val, VIAREG(chip, AC97));
373} 370}
374 371
375static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary) 372static int snd_via82xx_codec_ready(struct via82xx_modem *chip, int secondary)
376{ 373{
377 unsigned int timeout = 1000; /* 1ms */ 374 unsigned int timeout = 1000; /* 1ms */
378 unsigned int val; 375 unsigned int val;
@@ -382,11 +379,12 @@ static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary)
382 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) 379 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY))
383 return val & 0xffff; 380 return val & 0xffff;
384 } 381 }
385 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_via82xx_codec_xread(chip)); 382 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n",
383 secondary, snd_via82xx_codec_xread(chip));
386 return -EIO; 384 return -EIO;
387} 385}
388 386
389static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary) 387static int snd_via82xx_codec_valid(struct via82xx_modem *chip, int secondary)
390{ 388{
391 unsigned int timeout = 1000; /* 1ms */ 389 unsigned int timeout = 1000; /* 1ms */
392 unsigned int val, val1; 390 unsigned int val, val1;
@@ -403,20 +401,20 @@ static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary)
403 return -EIO; 401 return -EIO;
404} 402}
405 403
406static void snd_via82xx_codec_wait(ac97_t *ac97) 404static void snd_via82xx_codec_wait(struct snd_ac97 *ac97)
407{ 405{
408 via82xx_t *chip = ac97->private_data; 406 struct via82xx_modem *chip = ac97->private_data;
409 int err; 407 int err;
410 err = snd_via82xx_codec_ready(chip, ac97->num); 408 err = snd_via82xx_codec_ready(chip, ac97->num);
411 /* here we need to wait fairly for long time.. */ 409 /* here we need to wait fairly for long time.. */
412 msleep(500); 410 msleep(500);
413} 411}
414 412
415static void snd_via82xx_codec_write(ac97_t *ac97, 413static void snd_via82xx_codec_write(struct snd_ac97 *ac97,
416 unsigned short reg, 414 unsigned short reg,
417 unsigned short val) 415 unsigned short val)
418{ 416{
419 via82xx_t *chip = ac97->private_data; 417 struct via82xx_modem *chip = ac97->private_data;
420 unsigned int xval; 418 unsigned int xval;
421 if(reg == AC97_GPIO_STATUS) { 419 if(reg == AC97_GPIO_STATUS) {
422 outl(val, VIAREG(chip, GPI_STATUS)); 420 outl(val, VIAREG(chip, GPI_STATUS));
@@ -430,9 +428,9 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
430 snd_via82xx_codec_ready(chip, ac97->num); 428 snd_via82xx_codec_ready(chip, ac97->num);
431} 429}
432 430
433static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) 431static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned short reg)
434{ 432{
435 via82xx_t *chip = ac97->private_data; 433 struct via82xx_modem *chip = ac97->private_data;
436 unsigned int xval, val = 0xffff; 434 unsigned int xval, val = 0xffff;
437 int again = 0; 435 int again = 0;
438 436
@@ -442,7 +440,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
442 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; 440 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
443 while (1) { 441 while (1) {
444 if (again++ > 3) { 442 if (again++ > 3) {
445 snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip)); 443 snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n",
444 ac97->num, snd_via82xx_codec_xread(chip));
446 return 0xffff; 445 return 0xffff;
447 } 446 }
448 snd_via82xx_codec_xwrite(chip, xval); 447 snd_via82xx_codec_xwrite(chip, xval);
@@ -456,7 +455,7 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
456 return val & 0xffff; 455 return val & 0xffff;
457} 456}
458 457
459static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev) 458static void snd_via82xx_channel_reset(struct via82xx_modem *chip, struct viadev *viadev)
460{ 459{
461 outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET, 460 outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET,
462 VIADEV_REG(viadev, OFFSET_CONTROL)); 461 VIADEV_REG(viadev, OFFSET_CONTROL));
@@ -478,7 +477,7 @@ static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev)
478 477
479static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 478static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
480{ 479{
481 via82xx_t *chip = dev_id; 480 struct via82xx_modem *chip = dev_id;
482 unsigned int status; 481 unsigned int status;
483 unsigned int i; 482 unsigned int i;
484 483
@@ -491,7 +490,7 @@ static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *
491 /* check status for each stream */ 490 /* check status for each stream */
492 spin_lock(&chip->reg_lock); 491 spin_lock(&chip->reg_lock);
493 for (i = 0; i < chip->num_devs; i++) { 492 for (i = 0; i < chip->num_devs; i++) {
494 viadev_t *viadev = &chip->devs[i]; 493 struct viadev *viadev = &chip->devs[i];
495 unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); 494 unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS));
496 c_status &= (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED); 495 c_status &= (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED);
497 if (! c_status) 496 if (! c_status)
@@ -514,10 +513,10 @@ static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *
514/* 513/*
515 * trigger callback 514 * trigger callback
516 */ 515 */
517static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) 516static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
518{ 517{
519 via82xx_t *chip = snd_pcm_substream_chip(substream); 518 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
520 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 519 struct viadev *viadev = substream->runtime->private_data;
521 unsigned char val = 0; 520 unsigned char val = 0;
522 521
523 switch (cmd) { 522 switch (cmd) {
@@ -555,9 +554,11 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
555 */ 554 */
556 555
557#define check_invalid_pos(viadev,pos) \ 556#define check_invalid_pos(viadev,pos) \
558 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) 557 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
558 viadev->lastpos < viadev->bufsize2))
559 559
560static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) 560static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx,
561 unsigned int count)
561{ 562{
562 unsigned int size, res; 563 unsigned int size, res;
563 564
@@ -566,24 +567,33 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
566 567
567 /* check the validity of the calculated position */ 568 /* check the validity of the calculated position */
568 if (size < count) { 569 if (size < count) {
569 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", (int)size, (int)count); 570 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
571 (int)size, (int)count);
570 res = viadev->lastpos; 572 res = viadev->lastpos;
571 } else if (check_invalid_pos(viadev, res)) { 573 } else if (check_invalid_pos(viadev, res)) {
572#ifdef POINTER_DEBUG 574#ifdef POINTER_DEBUG
573 printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); 575 printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, "
576 "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, "
577 "count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos,
578 viadev->bufsize2, viadev->idx_table[idx].offset,
579 viadev->idx_table[idx].size, count);
574#endif 580#endif
575 if (count && size < count) { 581 if (count && size < count) {
576 snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); 582 snd_printd(KERN_ERR "invalid via82xx_cur_ptr, "
583 "using last valid pointer\n");
577 res = viadev->lastpos; 584 res = viadev->lastpos;
578 } else { 585 } else {
579 if (! count) 586 if (! count)
580 /* bogus count 0 on the DMA boundary? */ 587 /* bogus count 0 on the DMA boundary? */
581 res = viadev->idx_table[idx].offset; 588 res = viadev->idx_table[idx].offset;
582 else 589 else
583 /* count register returns full size when end of buffer is reached */ 590 /* count register returns full size
591 * when end of buffer is reached
592 */
584 res = viadev->idx_table[idx].offset + size; 593 res = viadev->idx_table[idx].offset + size;
585 if (check_invalid_pos(viadev, res)) { 594 if (check_invalid_pos(viadev, res)) {
586 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); 595 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), "
596 "using last valid pointer\n");
587 res = viadev->lastpos; 597 res = viadev->lastpos;
588 } 598 }
589 } 599 }
@@ -597,10 +607,10 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
597/* 607/*
598 * get the current pointer on via686 608 * get the current pointer on via686
599 */ 609 */
600static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) 610static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substream)
601{ 611{
602 via82xx_t *chip = snd_pcm_substream_chip(substream); 612 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
603 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 613 struct viadev *viadev = substream->runtime->private_data;
604 unsigned int idx, ptr, count, res; 614 unsigned int idx, ptr, count, res;
605 615
606 snd_assert(viadev->tbl_entries, return 0); 616 snd_assert(viadev->tbl_entries, return 0);
@@ -616,7 +626,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream)
616 if (ptr <= (unsigned int)viadev->table.addr) 626 if (ptr <= (unsigned int)viadev->table.addr)
617 idx = 0; 627 idx = 0;
618 else /* CURR_PTR holds the address + 8 */ 628 else /* CURR_PTR holds the address + 8 */
619 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; 629 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) %
630 viadev->tbl_entries;
620 res = calc_linear_pos(viadev, idx, count); 631 res = calc_linear_pos(viadev, idx, count);
621 spin_unlock(&chip->reg_lock); 632 spin_unlock(&chip->reg_lock);
622 633
@@ -627,11 +638,11 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream)
627 * hw_params callback: 638 * hw_params callback:
628 * allocate the buffer and build up the buffer description table 639 * allocate the buffer and build up the buffer description table
629 */ 640 */
630static int snd_via82xx_hw_params(snd_pcm_substream_t * substream, 641static int snd_via82xx_hw_params(struct snd_pcm_substream *substream,
631 snd_pcm_hw_params_t * hw_params) 642 struct snd_pcm_hw_params *hw_params)
632{ 643{
633 via82xx_t *chip = snd_pcm_substream_chip(substream); 644 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
634 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 645 struct viadev *viadev = substream->runtime->private_data;
635 int err; 646 int err;
636 647
637 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 648 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
@@ -653,10 +664,10 @@ static int snd_via82xx_hw_params(snd_pcm_substream_t * substream,
653 * hw_free callback: 664 * hw_free callback:
654 * clean up the buffer description table and release the buffer 665 * clean up the buffer description table and release the buffer
655 */ 666 */
656static int snd_via82xx_hw_free(snd_pcm_substream_t * substream) 667static int snd_via82xx_hw_free(struct snd_pcm_substream *substream)
657{ 668{
658 via82xx_t *chip = snd_pcm_substream_chip(substream); 669 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
659 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 670 struct viadev *viadev = substream->runtime->private_data;
660 671
661 clean_via_table(viadev, substream, chip->pci); 672 clean_via_table(viadev, substream, chip->pci);
662 snd_pcm_lib_free_pages(substream); 673 snd_pcm_lib_free_pages(substream);
@@ -667,7 +678,7 @@ static int snd_via82xx_hw_free(snd_pcm_substream_t * substream)
667/* 678/*
668 * set up the table pointer 679 * set up the table pointer
669 */ 680 */
670static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) 681static void snd_via82xx_set_table_ptr(struct via82xx_modem *chip, struct viadev *viadev)
671{ 682{
672 snd_via82xx_codec_ready(chip, chip->ac97_secondary); 683 snd_via82xx_codec_ready(chip, chip->ac97_secondary);
673 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); 684 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR));
@@ -678,10 +689,10 @@ static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev)
678/* 689/*
679 * prepare callback for playback and capture 690 * prepare callback for playback and capture
680 */ 691 */
681static int snd_via82xx_pcm_prepare(snd_pcm_substream_t *substream) 692static int snd_via82xx_pcm_prepare(struct snd_pcm_substream *substream)
682{ 693{
683 via82xx_t *chip = snd_pcm_substream_chip(substream); 694 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
684 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 695 struct viadev *viadev = substream->runtime->private_data;
685 696
686 snd_via82xx_channel_reset(chip, viadev); 697 snd_via82xx_channel_reset(chip, viadev);
687 /* this must be set after channel_reset */ 698 /* this must be set after channel_reset */
@@ -694,7 +705,7 @@ static int snd_via82xx_pcm_prepare(snd_pcm_substream_t *substream)
694/* 705/*
695 * pcm hardware definition, identical for both playback and capture 706 * pcm hardware definition, identical for both playback and capture
696 */ 707 */
697static snd_pcm_hardware_t snd_via82xx_hw = 708static struct snd_pcm_hardware snd_via82xx_hw =
698{ 709{
699 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 710 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
700 SNDRV_PCM_INFO_BLOCK_TRANSFER | 711 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -719,12 +730,13 @@ static snd_pcm_hardware_t snd_via82xx_hw =
719/* 730/*
720 * open callback skeleton 731 * open callback skeleton
721 */ 732 */
722static int snd_via82xx_modem_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_substream_t * substream) 733static int snd_via82xx_modem_pcm_open(struct via82xx_modem *chip, struct viadev *viadev,
734 struct snd_pcm_substream *substream)
723{ 735{
724 snd_pcm_runtime_t *runtime = substream->runtime; 736 struct snd_pcm_runtime *runtime = substream->runtime;
725 int err; 737 int err;
726 static unsigned int rates[] = { 8000, 9600, 12000, 16000 }; 738 static unsigned int rates[] = { 8000, 9600, 12000, 16000 };
727 static snd_pcm_hw_constraint_list_t hw_constraints_rates = { 739 static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
728 .count = ARRAY_SIZE(rates), 740 .count = ARRAY_SIZE(rates),
729 .list = rates, 741 .list = rates,
730 .mask = 0, 742 .mask = 0,
@@ -732,7 +744,8 @@ static int snd_via82xx_modem_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm
732 744
733 runtime->hw = snd_via82xx_hw; 745 runtime->hw = snd_via82xx_hw;
734 746
735 if ((err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates)) < 0) 747 if ((err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
748 &hw_constraints_rates)) < 0)
736 return err; 749 return err;
737 750
738 /* we may remove following constaint when we modify table entries 751 /* we may remove following constaint when we modify table entries
@@ -750,10 +763,10 @@ static int snd_via82xx_modem_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm
750/* 763/*
751 * open callback for playback 764 * open callback for playback
752 */ 765 */
753static int snd_via82xx_playback_open(snd_pcm_substream_t * substream) 766static int snd_via82xx_playback_open(struct snd_pcm_substream *substream)
754{ 767{
755 via82xx_t *chip = snd_pcm_substream_chip(substream); 768 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
756 viadev_t *viadev = &chip->devs[chip->playback_devno + substream->number]; 769 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number];
757 770
758 return snd_via82xx_modem_pcm_open(chip, viadev, substream); 771 return snd_via82xx_modem_pcm_open(chip, viadev, substream);
759} 772}
@@ -761,10 +774,10 @@ static int snd_via82xx_playback_open(snd_pcm_substream_t * substream)
761/* 774/*
762 * open callback for capture 775 * open callback for capture
763 */ 776 */
764static int snd_via82xx_capture_open(snd_pcm_substream_t * substream) 777static int snd_via82xx_capture_open(struct snd_pcm_substream *substream)
765{ 778{
766 via82xx_t *chip = snd_pcm_substream_chip(substream); 779 struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
767 viadev_t *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; 780 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device];
768 781
769 return snd_via82xx_modem_pcm_open(chip, viadev, substream); 782 return snd_via82xx_modem_pcm_open(chip, viadev, substream);
770} 783}
@@ -772,9 +785,9 @@ static int snd_via82xx_capture_open(snd_pcm_substream_t * substream)
772/* 785/*
773 * close callback 786 * close callback
774 */ 787 */
775static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream) 788static int snd_via82xx_pcm_close(struct snd_pcm_substream *substream)
776{ 789{
777 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 790 struct viadev *viadev = substream->runtime->private_data;
778 791
779 viadev->substream = NULL; 792 viadev->substream = NULL;
780 return 0; 793 return 0;
@@ -782,7 +795,7 @@ static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream)
782 795
783 796
784/* via686 playback callbacks */ 797/* via686 playback callbacks */
785static snd_pcm_ops_t snd_via686_playback_ops = { 798static struct snd_pcm_ops snd_via686_playback_ops = {
786 .open = snd_via82xx_playback_open, 799 .open = snd_via82xx_playback_open,
787 .close = snd_via82xx_pcm_close, 800 .close = snd_via82xx_pcm_close,
788 .ioctl = snd_pcm_lib_ioctl, 801 .ioctl = snd_pcm_lib_ioctl,
@@ -795,7 +808,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = {
795}; 808};
796 809
797/* via686 capture callbacks */ 810/* via686 capture callbacks */
798static snd_pcm_ops_t snd_via686_capture_ops = { 811static struct snd_pcm_ops snd_via686_capture_ops = {
799 .open = snd_via82xx_capture_open, 812 .open = snd_via82xx_capture_open,
800 .close = snd_via82xx_pcm_close, 813 .close = snd_via82xx_pcm_close,
801 .ioctl = snd_pcm_lib_ioctl, 814 .ioctl = snd_pcm_lib_ioctl,
@@ -808,7 +821,8 @@ static snd_pcm_ops_t snd_via686_capture_ops = {
808}; 821};
809 822
810 823
811static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int direction) 824static void init_viadev(struct via82xx_modem *chip, int idx, unsigned int reg_offset,
825 int direction)
812{ 826{
813 chip->devs[idx].reg_offset = reg_offset; 827 chip->devs[idx].reg_offset = reg_offset;
814 chip->devs[idx].direction = direction; 828 chip->devs[idx].direction = direction;
@@ -818,9 +832,9 @@ static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int d
818/* 832/*
819 * create a pcm instance for via686a/b 833 * create a pcm instance for via686a/b
820 */ 834 */
821static int __devinit snd_via686_pcm_new(via82xx_t *chip) 835static int __devinit snd_via686_pcm_new(struct via82xx_modem *chip)
822{ 836{
823 snd_pcm_t *pcm; 837 struct snd_pcm *pcm;
824 int err; 838 int err;
825 839
826 chip->playback_devno = 0; 840 chip->playback_devno = 0;
@@ -841,7 +855,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip)
841 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); 855 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
842 856
843 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 857 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
844 snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) 858 snd_dma_pci_data(chip->pci),
859 64*1024, 128*1024)) < 0)
845 return err; 860 return err;
846 861
847 return 0; 862 return 0;
@@ -853,24 +868,24 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip)
853 */ 868 */
854 869
855 870
856static void snd_via82xx_mixer_free_ac97_bus(ac97_bus_t *bus) 871static void snd_via82xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus)
857{ 872{
858 via82xx_t *chip = bus->private_data; 873 struct via82xx_modem *chip = bus->private_data;
859 chip->ac97_bus = NULL; 874 chip->ac97_bus = NULL;
860} 875}
861 876
862static void snd_via82xx_mixer_free_ac97(ac97_t *ac97) 877static void snd_via82xx_mixer_free_ac97(struct snd_ac97 *ac97)
863{ 878{
864 via82xx_t *chip = ac97->private_data; 879 struct via82xx_modem *chip = ac97->private_data;
865 chip->ac97 = NULL; 880 chip->ac97 = NULL;
866} 881}
867 882
868 883
869static int __devinit snd_via82xx_mixer_new(via82xx_t *chip) 884static int __devinit snd_via82xx_mixer_new(struct via82xx_modem *chip)
870{ 885{
871 ac97_template_t ac97; 886 struct snd_ac97_template ac97;
872 int err; 887 int err;
873 static ac97_bus_ops_t ops = { 888 static struct snd_ac97_bus_ops ops = {
874 .write = snd_via82xx_codec_write, 889 .write = snd_via82xx_codec_write,
875 .read = snd_via82xx_codec_read, 890 .read = snd_via82xx_codec_read,
876 .wait = snd_via82xx_codec_wait, 891 .wait = snd_via82xx_codec_wait,
@@ -898,9 +913,9 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip)
898/* 913/*
899 * proc interface 914 * proc interface
900 */ 915 */
901static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) 916static void snd_via82xx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
902{ 917{
903 via82xx_t *chip = entry->private_data; 918 struct via82xx_modem *chip = entry->private_data;
904 int i; 919 int i;
905 920
906 snd_iprintf(buffer, "%s\n\n", chip->card->longname); 921 snd_iprintf(buffer, "%s\n\n", chip->card->longname);
@@ -909,9 +924,9 @@ static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *bu
909 } 924 }
910} 925}
911 926
912static void __devinit snd_via82xx_proc_init(via82xx_t *chip) 927static void __devinit snd_via82xx_proc_init(struct via82xx_modem *chip)
913{ 928{
914 snd_info_entry_t *entry; 929 struct snd_info_entry *entry;
915 930
916 if (! snd_card_proc_new(chip->card, "via82xx", &entry)) 931 if (! snd_card_proc_new(chip->card, "via82xx", &entry))
917 snd_info_set_text_ops(entry, chip, 1024, snd_via82xx_proc_read); 932 snd_info_set_text_ops(entry, chip, 1024, snd_via82xx_proc_read);
@@ -921,7 +936,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip)
921 * 936 *
922 */ 937 */
923 938
924static int snd_via82xx_chip_init(via82xx_t *chip) 939static int snd_via82xx_chip_init(struct via82xx_modem *chip)
925{ 940{
926 unsigned int val; 941 unsigned int val;
927 unsigned long end_time; 942 unsigned long end_time;
@@ -1004,9 +1019,9 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
1004/* 1019/*
1005 * power management 1020 * power management
1006 */ 1021 */
1007static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state) 1022static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state)
1008{ 1023{
1009 via82xx_t *chip = card->pm_private_data; 1024 struct via82xx_modem *chip = card->pm_private_data;
1010 int i; 1025 int i;
1011 1026
1012 for (i = 0; i < 2; i++) 1027 for (i = 0; i < 2; i++)
@@ -1021,9 +1036,9 @@ static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state)
1021 return 0; 1036 return 0;
1022} 1037}
1023 1038
1024static int snd_via82xx_resume(snd_card_t *card) 1039static int snd_via82xx_resume(struct snd_card *card)
1025{ 1040{
1026 via82xx_t *chip = card->pm_private_data; 1041 struct via82xx_modem *chip = card->pm_private_data;
1027 int i; 1042 int i;
1028 1043
1029 pci_enable_device(chip->pci); 1044 pci_enable_device(chip->pci);
@@ -1041,7 +1056,7 @@ static int snd_via82xx_resume(snd_card_t *card)
1041} 1056}
1042#endif /* CONFIG_PM */ 1057#endif /* CONFIG_PM */
1043 1058
1044static int snd_via82xx_free(via82xx_t *chip) 1059static int snd_via82xx_free(struct via82xx_modem *chip)
1045{ 1060{
1046 unsigned int i; 1061 unsigned int i;
1047 1062
@@ -1053,29 +1068,29 @@ static int snd_via82xx_free(via82xx_t *chip)
1053 synchronize_irq(chip->irq); 1068 synchronize_irq(chip->irq);
1054 __end_hw: 1069 __end_hw:
1055 if (chip->irq >= 0) 1070 if (chip->irq >= 0)
1056 free_irq(chip->irq, (void *)chip); 1071 free_irq(chip->irq, chip);
1057 pci_release_regions(chip->pci); 1072 pci_release_regions(chip->pci);
1058 pci_disable_device(chip->pci); 1073 pci_disable_device(chip->pci);
1059 kfree(chip); 1074 kfree(chip);
1060 return 0; 1075 return 0;
1061} 1076}
1062 1077
1063static int snd_via82xx_dev_free(snd_device_t *device) 1078static int snd_via82xx_dev_free(struct snd_device *device)
1064{ 1079{
1065 via82xx_t *chip = device->device_data; 1080 struct via82xx_modem *chip = device->device_data;
1066 return snd_via82xx_free(chip); 1081 return snd_via82xx_free(chip);
1067} 1082}
1068 1083
1069static int __devinit snd_via82xx_create(snd_card_t * card, 1084static int __devinit snd_via82xx_create(struct snd_card *card,
1070 struct pci_dev *pci, 1085 struct pci_dev *pci,
1071 int chip_type, 1086 int chip_type,
1072 int revision, 1087 int revision,
1073 unsigned int ac97_clock, 1088 unsigned int ac97_clock,
1074 via82xx_t ** r_via) 1089 struct via82xx_modem ** r_via)
1075{ 1090{
1076 via82xx_t *chip; 1091 struct via82xx_modem *chip;
1077 int err; 1092 int err;
1078 static snd_device_ops_t ops = { 1093 static struct snd_device_ops ops = {
1079 .dev_free = snd_via82xx_dev_free, 1094 .dev_free = snd_via82xx_dev_free,
1080 }; 1095 };
1081 1096
@@ -1099,7 +1114,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
1099 } 1114 }
1100 chip->port = pci_resource_start(pci, 0); 1115 chip->port = pci_resource_start(pci, 0);
1101 if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ, 1116 if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ,
1102 card->driver, (void *)chip)) { 1117 card->driver, chip)) {
1103 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1118 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
1104 snd_via82xx_free(chip); 1119 snd_via82xx_free(chip);
1105 return -EBUSY; 1120 return -EBUSY;
@@ -1134,8 +1149,8 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
1134static int __devinit snd_via82xx_probe(struct pci_dev *pci, 1149static int __devinit snd_via82xx_probe(struct pci_dev *pci,
1135 const struct pci_device_id *pci_id) 1150 const struct pci_device_id *pci_id)
1136{ 1151{
1137 snd_card_t *card; 1152 struct snd_card *card;
1138 via82xx_t *chip; 1153 struct via82xx_modem *chip;
1139 unsigned char revision; 1154 unsigned char revision;
1140 int chip_type = 0, card_type; 1155 int chip_type = 0, card_type;
1141 unsigned int i; 1156 unsigned int i;