Update of /cvsroot/alsa/alsa-kernel/pci In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18820/alsa-kernel/pci
Modified Files: als4000.c azt3328.c bt87x.c cmipci.c cs4281.c ens1370.c es1938.c fm801.c maestro3.c rme32.c rme96.c sonicvibes.c via82xx.c Log Message: Big DMA cleanup originated by Russell King <[EMAIL PROTECTED]> * Russel - introduced 'struct device' support for 2.6 dma_alloc_coherent() * Jaroslav - removed all bus-specific allocation functions - extended snd_dma_alloc_pages/snd_dma_free_pages to handle all bus types - recoded all (or almost all) device drivers - sgbuf functions are bus independent now Index: als4000.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/als4000.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- als4000.c 24 Feb 2004 12:03:51 -0000 1.29 +++ als4000.c 2 Mar 2004 15:32:37 -0000 1.30 @@ -523,7 +523,8 @@ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_als4000_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_als4000_capture_ops); - snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 64*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, chip->pci, + 64*1024, 64*1024); chip->pcm = pcm; Index: azt3328.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/azt3328.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- azt3328.c 21 Jan 2004 18:32:47 -0000 1.9 +++ azt3328.c 2 Mar 2004 15:32:37 -0000 1.10 @@ -1253,7 +1253,8 @@ strcpy(pcm->name, chip->card->shortname); chip->pcm = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 64*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + chip->pci, 64*1024, 64*1024); snd_azf3328_dbgcallleave(); return 0; Index: bt87x.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/bt87x.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- bt87x.c 28 Jan 2004 18:55:20 -0000 1.1 +++ bt87x.c 2 Mar 2004 15:32:37 -0000 1.2 @@ -167,8 +167,8 @@ long opened; snd_pcm_substream_t *substream; - u32 *risc; - dma_addr_t risc_dma; + struct snd_dma_device dma_dev; + struct snd_dma_buffer dma_risc; unsigned int line_bytes; unsigned int lines; @@ -195,13 +195,14 @@ unsigned int i, offset; u32 *risc; - if (!chip->risc) { - chip->risc = (u32*)snd_malloc_pci_pages - (chip->pci, PAGE_ALIGN(MAX_RISC_SIZE), &chip->risc_dma); - if (!chip->risc) + if (chip->dma_risc.area == NULL) { + memset(&chip->dma_dev, 0, sizeof(chip->dma_dev)); + chip->dma_dev.type = SNDRV_DMA_TYPE_PCI; + chip->dma_dev.dev.pci = chip->pci; + if (snd_dma_alloc_pages(&chip->dma_dev, PAGE_ALIGN(MAX_RISC_SIZE), &chip->dma_risc) < 0) return -ENOMEM; } - risc = chip->risc; + risc = (u32 *)chip->dma_risc.area; offset = 0; *risc++ = cpu_to_le32(RISC_SYNC | RISC_SYNC_FM1); *risc++ = cpu_to_le32(0); @@ -233,7 +234,7 @@ *risc++ = cpu_to_le32(RISC_SYNC | RISC_SYNC_VRO); *risc++ = cpu_to_le32(0); *risc++ = cpu_to_le32(RISC_JUMP); - *risc++ = cpu_to_le32(chip->risc_dma); + *risc++ = cpu_to_le32(chip->dma_risc.addr); chip->line_bytes = period_bytes; chip->lines = periods; return 0; @@ -241,10 +242,9 @@ static void snd_bt87x_free_risc(bt87x_t *chip) { - if (chip->risc) { - snd_free_pci_pages(chip->pci, PAGE_ALIGN(MAX_RISC_SIZE), - chip->risc, chip->risc_dma); - chip->risc = NULL; + if (chip->dma_risc.area) { + snd_dma_free_pages(&chip->dma_dev, &chip->dma_risc); + chip->dma_risc.area = NULL; } } @@ -459,7 +459,7 @@ spin_lock_irqsave(&chip->reg_lock, flags); chip->current_line = 0; chip->reg_control |= CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN; - snd_bt87x_writel(chip, REG_RISC_STRT_ADD, chip->risc_dma); + snd_bt87x_writel(chip, REG_RISC_STRT_ADD, chip->dma_risc.addr); snd_bt87x_writel(chip, REG_PACKET_LEN, chip->line_bytes | (chip->lines << 16)); snd_bt87x_writel(chip, REG_INT_MASK, MY_INTERRUPTS); @@ -681,7 +681,9 @@ pcm->private_data = chip; strcpy(pcm->name, name); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); - return snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm, + return snd_pcm_lib_preallocate_pages_for_all(pcm, + SNDRV_DMA_TYPE_PCI_SG, + chip->pci, 128 * 1024, (255 * 4092 + 1023) & ~1023); } Index: cmipci.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/cmipci.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- cmipci.c 24 Feb 2004 12:04:14 -0000 1.59 +++ cmipci.c 2 Mar 2004 15:32:37 -0000 1.60 @@ -2087,7 +2087,8 @@ strcpy(pcm->name, "C-Media PCI DAC/ADC"); cm->pcm = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(cm->pci, pcm, 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + cm->pci, 64*1024, 128*1024); return 0; } @@ -2109,7 +2110,8 @@ strcpy(pcm->name, "C-Media PCI 2nd DAC"); cm->pcm2 = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(cm->pci, pcm, 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + cm->pci, 64*1024, 128*1024); return 0; } @@ -2139,7 +2141,8 @@ strcpy(pcm->name, "C-Media PCI IEC958"); cm->pcm_spdif = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(cm->pci, pcm, 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + cm->pci, 64*1024, 128*1024); return 0; } Index: cs4281.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/cs4281.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- cs4281.c 21 Jan 2004 18:32:47 -0000 1.47 +++ cs4281.c 2 Mar 2004 15:32:37 -0000 1.48 @@ -1039,7 +1039,8 @@ strcpy(pcm->name, "CS4281"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 512*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + chip->pci, 64*1024, 512*1024); if (rpcm) *rpcm = pcm; Index: ens1370.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/ens1370.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- ens1370.c 21 Jan 2004 18:32:47 -0000 1.56 +++ ens1370.c 2 Mar 2004 15:32:37 -0000 1.57 @@ -434,8 +434,8 @@ unsigned int spdif_stream; #ifdef CHIP1370 - unsigned char *bugbuf; - dma_addr_t bugbuf_addr; + struct snd_dma_device dma_dev; + struct snd_dma_buffer dma_bug; #endif #ifdef SUPPORT_JOYSTICK @@ -1250,7 +1250,8 @@ #endif ensoniq->pcm1 = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(ensoniq->pci, pcm, 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + ensoniq->pci, 64*1024, 128*1024); if (rpcm) *rpcm = pcm; @@ -1294,7 +1295,8 @@ #endif ensoniq->pcm2 = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(ensoniq->pci, pcm, 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + ensoniq->pci, 64*1024, 128*1024); if (rpcm) *rpcm = pcm; @@ -1829,8 +1831,8 @@ pci_set_power_state(ensoniq->pci, 3); __hw_end: #ifdef CHIP1370 - if (ensoniq->bugbuf) - snd_free_pci_pages(ensoniq->pci, 16, ensoniq->bugbuf, ensoniq->bugbuf_addr); + if (ensoniq->dma_bug.area) + snd_dma_free_pages(&ensoniq->dma_dev, &ensoniq->dma_bug); #endif if (ensoniq->res_port) { release_resource(ensoniq->res_port); @@ -1911,8 +1913,11 @@ } ensoniq->irq = pci->irq; #ifdef CHIP1370 - if ((ensoniq->bugbuf = snd_malloc_pci_pages(pci, 16, &ensoniq->bugbuf_addr)) == NULL) { - snd_printk("unable to allocate space for phantom area - bugbuf\n"); + memset(&ensoniq->dma_dev, 0, sizeof(ensoniq->dma_dev)); + ensoniq->dma_dev.type = SNDRV_DMA_TYPE_PCI; + ensoniq->dma_dev.dev.pci = pci; + if (snd_dma_alloc_pages(&ensoniq->dma_dev, 16, &ensoniq->dma_bug) < 0) { + snd_printk("unable to allocate space for phantom area - dma_bug\n"); snd_ensoniq_free(ensoniq); return -EBUSY; } @@ -1936,7 +1941,7 @@ outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); - outl(ensoniq->bugbuf_addr, ES_REG(ensoniq, PHANTOM_FRAME)); + outl(ensoniq->dma_bug.addr, ES_REG(ensoniq, PHANTOM_FRAME)); outl(0, ES_REG(ensoniq, PHANTOM_COUNT)); #else ensoniq->ctrl = 0; Index: es1938.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/es1938.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- es1938.c 26 Jan 2004 14:27:13 -0000 1.31 +++ es1938.c 2 Mar 2004 15:32:37 -0000 1.32 @@ -946,17 +946,14 @@ static int snd_es1938_capture_close(snd_pcm_substream_t * substream) { es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; chip->capture_substream = NULL; - snd_free_pci_pages(chip->pci, runtime->dma_bytes, runtime->dma_area, runtime->dma_addr); return 0; } static int snd_es1938_playback_close(snd_pcm_substream_t * substream) { es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; switch (substream->number) { case 0: @@ -969,7 +966,6 @@ snd_BUG(); return -EINVAL; } - snd_free_pci_pages(chip->pci, runtime->dma_bytes, runtime->dma_area, runtime->dma_addr); return 0; } @@ -1018,7 +1014,8 @@ pcm->info_flags = 0; strcpy(pcm->name, "ESS Solo-1"); - snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 64*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + chip->pci, 64*1024, 64*1024); if (rpcm) *rpcm = pcm; Index: fm801.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/fm801.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- fm801.c 1 Mar 2004 15:23:16 -0000 1.41 +++ fm801.c 2 Mar 2004 15:32:37 -0000 1.42 @@ -703,7 +703,8 @@ strcpy(pcm->name, "FM801"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, chip->multichannel ? 128*1024 : 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + chip->pci, chip->multichannel ? 128*1024 : 64*1024, 128*1024); if (rpcm) *rpcm = pcm; Index: maestro3.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/maestro3.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- maestro3.c 21 Jan 2004 18:32:47 -0000 1.46 +++ maestro3.c 2 Mar 2004 15:32:37 -0000 1.47 @@ -1816,7 +1816,8 @@ strcpy(pcm->name, chip->card->driver); chip->pcm = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 64*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + chip->pci, 64*1024, 64*1024); return 0; } Index: rme32.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/rme32.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- rme32.c 21 Jan 2004 18:32:47 -0000 1.29 +++ rme32.c 2 Mar 2004 15:32:37 -0000 1.30 @@ -1378,9 +1378,10 @@ rme32->spdif_pcm->info_flags = 0; snd_pcm_lib_preallocate_pages_for_all(rme32->spdif_pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + snd_pcm_dma_flags(GFP_KERNEL), RME32_BUFFER_SIZE, - RME32_BUFFER_SIZE, - GFP_KERNEL); + RME32_BUFFER_SIZE); /* set up ALSA pcm device for ADAT */ if ((pci->device == PCI_DEVICE_ID_DIGI32) || @@ -1405,9 +1406,10 @@ rme32->adat_pcm->info_flags = 0; snd_pcm_lib_preallocate_pages_for_all(rme32->adat_pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + snd_pcm_dma_flags(GFP_KERNEL), RME32_BUFFER_SIZE, - RME32_BUFFER_SIZE, - GFP_KERNEL); + RME32_BUFFER_SIZE); } Index: rme96.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/rme96.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- rme96.c 21 Jan 2004 18:32:47 -0000 1.31 +++ rme96.c 2 Mar 2004 15:32:37 -0000 1.32 @@ -1718,7 +1718,11 @@ rme96->spdif_pcm->info_flags = 0; - snd_pcm_lib_preallocate_pages_for_all(rme96->spdif_pcm, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE, GFP_KERNEL); + snd_pcm_lib_preallocate_pages_for_all(rme96->spdif_pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + snd_pcm_dma_flags(GFP_KERNEL), + RME96_BUFFER_SIZE, + RME96_BUFFER_SIZE); /* set up ALSA pcm device for ADAT */ if (pci->device == PCI_DEVICE_ID_DIGI96) { @@ -1738,7 +1742,11 @@ rme96->adat_pcm->info_flags = 0; - snd_pcm_lib_preallocate_pages_for_all(rme96->adat_pcm, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE, GFP_KERNEL); + snd_pcm_lib_preallocate_pages_for_all(rme96->adat_pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + snd_pcm_dma_flags(GFP_KERNEL), + RME96_BUFFER_SIZE, + RME96_BUFFER_SIZE); } rme96->playback_periodsize = 0; Index: sonicvibes.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/sonicvibes.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- sonicvibes.c 26 Jan 2004 14:27:13 -0000 1.31 +++ sonicvibes.c 2 Mar 2004 15:32:37 -0000 1.32 @@ -886,7 +886,8 @@ strcpy(pcm->name, "S3 SonicVibes"); sonic->pcm = pcm; - snd_pcm_lib_preallocate_pci_pages_for_all(sonic->pci, pcm, 64*1024, 128*1024); + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, + sonic->pci, 64*1024, 128*1024); if (rpcm) *rpcm = pcm; Index: via82xx.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- via82xx.c 25 Feb 2004 15:15:21 -0000 1.88 +++ via82xx.c 2 Mar 2004 15:32:37 -0000 1.89 @@ -337,8 +337,7 @@ snd_pcm_substream_t *substream; int running; unsigned int tbl_entries; /* # descriptors */ - u32 *table; /* physical address + flag */ - dma_addr_t table_addr; + struct snd_dma_buffer table; struct snd_via_sg_table *idx_table; /* for recovery from the unexpected pointer */ unsigned int lastpos; @@ -347,6 +346,73 @@ }; +enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; +enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; + +#define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ + +struct via_rate_lock { + spinlock_t lock; + int rate; + int used; +}; + +struct _snd_via82xx { + int irq; + + unsigned long port; + struct resource *res_port; + struct resource *mpu_res; + int chip_type; + unsigned char revision; + + unsigned char old_legacy; + unsigned char old_legacy_cfg; + + unsigned char playback_volume[4][2]; /* for VIA8233/C/8235; default = 0 */ + + unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ + + struct pci_dev *pci; + snd_card_t *card; + + unsigned int num_devs; + unsigned int playback_devno, multi_devno, capture_devno; + viadev_t devs[VIA_MAX_DEVS]; + struct via_rate_lock rates[2]; /* playback and capture */ + unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ + unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ + + snd_rawmidi_t *rmidi; + + ac97_bus_t *ac97_bus; + ac97_t *ac97; + unsigned int ac97_clock; + unsigned int ac97_secondary; /* secondary AC'97 codec is present */ + + spinlock_t reg_lock; + spinlock_t ac97_lock; + snd_info_entry_t *proc_entry; + + struct snd_dma_device dma_dev; + +#ifdef SUPPORT_JOYSTICK + struct gameport gameport; + struct resource *res_joystick; +#endif +}; + +static struct pci_device_id snd_via82xx_ids[] = { + { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ + { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, snd_via82xx_ids); + +/* + */ + /* * allocate and initialize the descriptor buffers * periods = number of periods @@ -357,14 +423,14 @@ unsigned int periods, unsigned int fragsize) { unsigned int i, idx, ofs, rest; + via82xx_t *chip = snd_pcm_substream_chip(substream); struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); - if (! dev->table) { + if (dev->table.area == NULL) { /* the start of each lists must be aligned to 8 bytes, * but the kernel pages are much bigger, so we don't care */ - dev->table = (u32*)snd_malloc_pci_pages(pci, PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8), &dev->table_addr); - if (! dev->table) + if (snd_dma_alloc_pages(&chip->dma_dev, PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8), &dev->table) < 0) return -ENOMEM; } if (! dev->idx_table) { @@ -390,7 +456,7 @@ snd_printk(KERN_ERR "via82xx: too much table size!\n"); return -EINVAL; } - dev->table[idx << 1] = cpu_to_le32((u32)snd_pcm_sgbuf_get_addr(sgbuf, ofs)); + ((u32 *)dev->table.area)[idx << 1] = cpu_to_le32((u32)snd_pcm_sgbuf_get_addr(sgbuf, ofs)); r = PAGE_SIZE - (ofs % PAGE_SIZE); if (rest < r) r = rest; @@ -403,7 +469,7 @@ } else flag = 0; /* period continues to the next */ // printk("via: tbl %d: at %d size %d (rest %d)\n", idx, ofs, r, rest); - dev->table[(idx<<1) + 1] = cpu_to_le32(r | flag); + ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); dev->idx_table[idx].offset = ofs; dev->idx_table[idx].size = r; ofs += r; @@ -417,85 +483,21 @@ } -static void clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, - struct pci_dev *pci) +static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, + struct pci_dev *pci) { - if (dev->table) { - snd_free_pci_pages(pci, PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8), dev->table, dev->table_addr); - dev->table = NULL; + via82xx_t *chip = snd_pcm_substream_chip(substream); + if (dev->table.area) { + snd_dma_free_pages(&chip->dma_dev, &dev->table); + dev->table.area = NULL; } if (dev->idx_table) { kfree(dev->idx_table); dev->idx_table = NULL; } + return 0; } - -/* - */ - -enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; -enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; - -#define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ - -struct via_rate_lock { - spinlock_t lock; - int rate; - int used; -}; - -struct _snd_via82xx { - int irq; - - unsigned long port; - struct resource *res_port; - struct resource *mpu_res; - int chip_type; - unsigned char revision; - - unsigned char old_legacy; - unsigned char old_legacy_cfg; - - unsigned char playback_volume[4][2]; /* for VIA8233/C/8235; default = 0 */ - - unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ - - struct pci_dev *pci; - snd_card_t *card; - - unsigned int num_devs; - unsigned int playback_devno, multi_devno, capture_devno; - viadev_t devs[VIA_MAX_DEVS]; - struct via_rate_lock rates[2]; /* playback and capture */ - unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ - unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ - - snd_rawmidi_t *rmidi; - - ac97_bus_t *ac97_bus; - ac97_t *ac97; - unsigned int ac97_clock; - unsigned int ac97_secondary; /* secondary AC'97 codec is present */ - - spinlock_t reg_lock; - spinlock_t ac97_lock; - snd_info_entry_t *proc_entry; - -#ifdef SUPPORT_JOYSTICK - struct gameport gameport; - struct resource *res_joystick; -#endif -}; - -static struct pci_device_id snd_via82xx_ids[] = { - { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ - { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, snd_via82xx_ids); - /* * Basic I/O */ @@ -756,10 +758,10 @@ * so we need to calculate the index from CURR_PTR. */ ptr = inl(VIADEV_REG(viadev, OFFSET_CURR_PTR)); - if (ptr <= (unsigned int)viadev->table_addr) + if (ptr <= (unsigned int)viadev->table.addr) idx = 0; else /* CURR_PTR holds the address + 8 */ - idx = ((ptr - (unsigned int)viadev->table_addr) / 8 - 1) % viadev->tbl_entries; + idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); @@ -840,7 +842,7 @@ static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) { snd_via82xx_codec_ready(chip, 0); - outl((u32)viadev->table_addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); + outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); udelay(20); snd_via82xx_codec_ready(chip, 0); } @@ -1288,7 +1290,8 @@ /* capture */ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 1); - if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm, 64*1024, 128*1024)) < 0) + if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI_SG, + chip->pci, 64*1024, 128*1024)) < 0) return err; /* PCM #1: multi-channel playback and 2nd capture */ @@ -1304,7 +1307,8 @@ /* set up capture */ init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 1); - if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm, 64*1024, 128*1024)) < 0) + if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI_SG, + chip->pci, 64*1024, 128*1024)) < 0) return err; return 0; @@ -1337,7 +1341,8 @@ /* capture */ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 1); - if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm, 64*1024, 128*1024)) < 0) + if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI_SG, + chip->pci, 64*1024, 128*1024)) < 0) return err; /* PCM #1: DXS3 playback (for spdif) */ @@ -1350,7 +1355,8 @@ /* set up playback */ init_viadev(chip, chip->playback_devno, 0x30, 0); - if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm, 64*1024, 128*1024)) < 0) + if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI_SG, + chip->pci, 64*1024, 128*1024)) < 0) return err; return 0; @@ -1379,7 +1385,8 @@ init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0); init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 1); - if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm, 64*1024, 128*1024)) < 0) + if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI_SG, + chip->pci, 64*1024, 128*1024)) < 0) return err; return 0; @@ -1911,6 +1918,10 @@ chip->pci = pci; chip->irq = -1; + memset(&chip->dma_dev, 0, sizeof(chip->dma_dev)); + chip->dma_dev.type = SNDRV_DMA_TYPE_PCI; + chip->dma_dev.dev.pci = pci; + pci_read_config_byte(pci, VIA_FUNC_ENABLE, &chip->old_legacy); pci_read_config_byte(pci, VIA_PNP_CONTROL, &chip->old_legacy_cfg); ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog