Update of /cvsroot/alsa/alsa-driver/pci
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18820/alsa-driver/pci

Modified Files:
        atiixp.c hdspm.c intel8x0m.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: atiixp.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/pci/atiixp.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- atiixp.c    24 Feb 2004 15:23:10 -0000      1.1
+++ atiixp.c    2 Mar 2004 15:32:35 -0000       1.2
@@ -220,7 +220,6 @@
        u32 next;       /* address of the next packet descriptor */
 } atiixp_dma_desc_t;
 
-
 /*
  * stream enum
  */
@@ -242,8 +241,8 @@
  */
 struct snd_atiixp_dma {
        const atiixp_dma_ops_t *ops;
-       atiixp_dma_desc_t *desc;        /* packets buffer */
-       dma_addr_t desc_addr;           /* physical address of packets buffer */
+       struct snd_dma_device desc_dev;
+       struct snd_dma_buffer desc_buf;
        snd_pcm_substream_t *substream; /* assigned PCM substream */
        unsigned int buf_addr, buf_bytes;       /* DMA buffer address, bytes */
        unsigned int period_bytes, periods;
@@ -359,9 +358,11 @@
        if (periods > ATI_MAX_DESCRIPTORS)
                return -ENOMEM;
 
-       if (! dma->desc) {
-               dma->desc = snd_malloc_pci_pages(chip->pci, ATI_DESC_LIST_SIZE, 
&dma->desc_addr);
-               if (! dma->desc)
+       if (dma->desc_buf.area == NULL) {
+               memset(&dma->desc_dev, 0, sizeof(dma->desc_dev));
+               dma->desc_dev.type = SNDRV_DMA_TYPE_PCI;
+               dma->desc_dev.dev.pci = chip->pci;
+               if (snd_dma_alloc_pages(&dma->desc_dev, ATI_DESC_LIST_SIZE, 
&dma->desc_buf) < 0)
                        return -ENOMEM;
                dma->period_bytes = dma->periods = 0; /* clear */
        }
@@ -378,20 +379,21 @@
 
        /* fill the entries */
        addr = (u32)substream->runtime->dma_addr;
-       desc_addr = (u32)dma->desc_addr;
+       desc_addr = (u32)dma->desc_buf.addr;
        for (i = 0; i < periods; i++) {
-               dma->desc[i].addr = cpu_to_le32(addr);
-               dma->desc[i].status = 0;
-               dma->desc[i].size = period_bytes >> 2; /* in dwords */
+               atiixp_dma_desc_t *desc = &((atiixp_dma_desc_t 
*)dma->desc_buf.area)[i];
+               desc->addr = cpu_to_le32(addr);
+               desc->status = 0;
+               desc->size = period_bytes >> 2; /* in dwords */
                desc_addr += sizeof(atiixp_dma_desc_t);
                if (i == periods - 1)
-                       dma->desc[i].next = cpu_to_le32((u32)dma->desc_addr);
+                       desc->next = cpu_to_le32((u32)dma->desc_buf.addr);
                else
-                       dma->desc[i].next = cpu_to_le32(desc_addr);
+                       desc->next = cpu_to_le32(desc_addr);
                addr += period_bytes;
        }
 
-       writel(cpu_to_le32((u32)dma->desc_addr | ATI_REG_LINKPTR_EN),
+       writel(cpu_to_le32((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN),
               chip->remap_addr + dma->ops->llp_offset);
 
        dma->period_bytes = period_bytes;
@@ -405,10 +407,10 @@
  */
 static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, 
snd_pcm_substream_t *substream)
 {
-       if (dma->desc) {
+       if (dma->desc_buf.area) {
                writel(0, chip->remap_addr + dma->ops->llp_offset);
-               snd_free_pci_pages(chip->pci, ATI_DESC_LIST_SIZE, dma->desc, 
dma->desc_addr);
-               dma->desc = NULL;
+               snd_dma_free_pages(&dma->desc_dev, &dma->desc_buf);
+               dma->desc_buf.area = NULL;
        }
 }
 
@@ -1219,7 +1221,8 @@
        pcm->private_data = chip;
        strcpy(pcm->name, "ATI IXP AC97");
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 128*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             chip->pci, 64*1024, 128*1024);
 
        /* no SPDIF support on codec? */
        if (chip->dmas[ATI_DMA_SPDIF].pcm && ! chip->dmas[ATI_DMA_SPDIF].pcm->rates)
@@ -1233,7 +1236,8 @@
        pcm->private_data = chip;
        strcpy(pcm->name, "ATI IXP IEC958");
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 128*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI, chip->pci,
+                                             64*1024, 128*1024);
 
        /* pre-select AC97 SPDIF slots 10/11 */
        for (i = 0; i < 3; i++) {

Index: hdspm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/pci/hdspm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hdspm.c     30 Jan 2004 11:52:29 -0000      1.1
+++ hdspm.c     2 Mar 2004 15:32:35 -0000       1.2
@@ -3417,9 +3417,11 @@
        wanted = HDSPM_DMA_AREA_BYTES + 4096;   /* dont know why, but it works */
 
        if ((err =
-            snd_pcm_lib_preallocate_sg_pages_for_all(hdspm->pci, pcm,
-                                                     wanted,
-                                                     wanted)) < 0) {
+            snd_pcm_lib_preallocate_pages_for_all(pcm,
+                                                  SNDRV_DMA_TYPE_PCI_SG,
+                                                  hdspm->pci,
+                                                  wanted,
+                                                  wanted)) < 0) {
                snd_printdd("Could not preallocate %d  Bytes\n", wanted);
 
                return err;

Index: intel8x0m.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/pci/intel8x0m.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- intel8x0m.c 21 Jan 2004 18:33:32 -0000      1.2
+++ intel8x0m.c 2 Mar 2004 15:32:35 -0000       1.3
@@ -260,9 +260,9 @@
        spinlock_t reg_lock;
        spinlock_t ac97_lock;
        
+       struct snd_dma_device dma_dev;
+       struct snd_dma_buffer bdbars;
        u32 bdbars_count;
-       u32 *bdbars;
-       dma_addr_t bdbars_addr;
        u32 int_sta_reg;                /* interrupt status register */
        u32 int_sta_mask;               /* interrupt status mask */
        unsigned int pcm_pos_shift;
@@ -808,8 +808,10 @@
                strcpy(pcm->name, chip->card->shortname);
        chip->pcm[device] = pcm;
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, rec->prealloc_size,
-                                                 rec->prealloc_max_size);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             chip->pci,
+                                             rec->prealloc_size,
+                                             rec->prealloc_max_size);
 
        return 0;
 }
@@ -1060,8 +1062,8 @@
        /* --- */
        synchronize_irq(chip->irq);
       __hw_end:
-       if (chip->bdbars)
-               snd_free_pci_pages(chip->pci, chip->bdbars_count * sizeof(u32) * 
ICH_MAX_FRAGS * 2, chip->bdbars, chip->bdbars_addr);
+       if (chip->bdbars.area)
+               snd_dma_free_pages(&chip->dma_dev, &chip->bdbars);
        if (chip->remap_addr)
                iounmap((void *) chip->remap_addr);
        if (chip->remap_bmaddr)
@@ -1319,8 +1321,10 @@
 
        /* allocate buffer descriptor lists */
        /* the start of each lists must be aligned to 8 bytes */
-       chip->bdbars = (u32 *)snd_malloc_pci_pages(pci, chip->bdbars_count * 
sizeof(u32) * ICH_MAX_FRAGS * 2, &chip->bdbars_addr);
-       if (chip->bdbars == NULL) {
+       memset(&chip->dma_dev, 0, sizeof(chip->dma_dev));
+       chip->dma_dev.type = SNDRV_DMA_TYPE_PCI;
+       chip->dma_dev.dev.pci = pci;
+       if (snd_dma_alloc_pages(&chip->dma_dev, chip->bdbars_count * sizeof(u32) * 
ICH_MAX_FRAGS * 2, &chip->bdbars) < 0) {
                snd_intel8x0_free(chip);
                return -ENOMEM;
        }
@@ -1329,8 +1333,8 @@
        int_sta_masks = 0;
        for (i = 0; i < chip->bdbars_count; i++) {
                ichdev = &chip->ichd[i];
-               ichdev->bdbar = chip->bdbars + (i * ICH_MAX_FRAGS * 2);
-               ichdev->bdbar_addr = chip->bdbars_addr + (i * sizeof(u32) * 
ICH_MAX_FRAGS * 2);
+               ichdev->bdbar = ((u32 *)chip->bdbars.area) + (i * ICH_MAX_FRAGS * 2);
+               ichdev->bdbar_addr = chip->bdbars.addr + (i * sizeof(u32) * 
ICH_MAX_FRAGS * 2);
                int_sta_masks |= ichdev->int_sta_mask;
        }
        chip->int_sta_reg = ICH_REG_GLOB_STA;



-------------------------------------------------------
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

Reply via email to