Update of /cvsroot/alsa/alsa-kernel/pci
In directory sc8-pr-cvs1:/tmp/cvs-serv22165

Modified Files:
        es1968.c 
Log Message:
- use the new buffer-preservation API.



Index: es1968.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/es1968.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- es1968.c    28 Feb 2003 14:29:24 -0000      1.36
+++ es1968.c    3 Mar 2003 16:46:34 -0000       1.37
@@ -555,9 +555,8 @@
        unsigned int clock;             /* clock */
 
        /* buffer */
-       void *dma_buf;
-       dma_addr_t dma_buf_addr;
-       size_t dma_buf_size;
+       struct snd_dma_device dma_dev;
+       struct snd_dma_buffer dma;
 
        /* Resources... */
        int irq;
@@ -1076,7 +1075,7 @@
 
                /* Offset to PCMBAR */
                pa = es->memory->addr;
-               pa -= chip->dma_buf_addr;
+               pa -= chip->dma.addr;
                pa >>= 1;       /* words */
 
                pa |= 0x00400000;       /* System RAM (Bit 22) */
@@ -1222,7 +1221,7 @@
                snd_es1968_program_wavecache(chip, es, channel, pa, 1);
 
                /* Offset to PCMBAR */
-               pa -= chip->dma_buf_addr;
+               pa -= chip->dma.addr;
                pa >>= 1;       /* words */
 
                /* base offset of dma calcs when reading the pointer
@@ -1499,9 +1498,9 @@
 {
        struct list_head *p;
 
-       if (! chip->dma_buf)
+       if (! chip->dma.area)
                return;
-       snd_free_pci_pages(chip->pci, chip->dma_buf_size, chip->dma_buf, 
chip->dma_buf_addr);
+       snd_dma_free_reserved(&chip->dma_dev);
        while ((p = chip->buf_list.next) != &chip->buf_list) {
                esm_memory_t *chunk = list_entry(p, esm_memory_t, list);
                list_del(p);
@@ -1513,18 +1512,22 @@
 snd_es1968_init_dmabuf(es1968_t *chip)
 {
        esm_memory_t *chunk;
-       chip->dma_buf = snd_malloc_pci_pages_fallback(chip->pci, chip->total_bufsize,
-                                                     &chip->dma_buf_addr, 
&chip->dma_buf_size);
-       //snd_printd("es1968: allocated buffer size %ld at %p\n", chip->dma_buf_size, 
chip->dma_buf);
-       if (chip->dma_buf == NULL) {
-               snd_printk("es1968: can't allocate dma pages for size %d\n",
-                          chip->total_bufsize);
-               return -ENOMEM;
-       }
-       if ((chip->dma_buf_addr + chip->dma_buf_size - 1) & ~((1 << 28) - 1)) {
-               snd_es1968_free_dmabuf(chip);
-               snd_printk("es1968: DMA buffer beyond 256MB.\n");
-               return -ENOMEM;
+
+       snd_dma_device_pci(&chip->dma_dev, chip->pci, 0);
+       if (! snd_dma_get_reserved(&chip->dma_dev, &chip->dma)) {
+               chip->dma.area = snd_malloc_pci_pages_fallback(chip->pci, 
chip->total_bufsize,
+                                                              &chip->dma.addr, 
&chip->dma.bytes);
+               if (chip->dma.area == NULL) {
+                       snd_printk("es1968: can't allocate dma pages for size %d\n",
+                                  chip->total_bufsize);
+                       return -ENOMEM;
+               }
+               if ((chip->dma.addr + chip->dma.bytes - 1) & ~((1 << 28) - 1)) {
+                       snd_dma_free_pages(&chip->dma_dev, &chip->dma);
+                       snd_printk("es1968: DMA buffer beyond 256MB.\n");
+                       return -ENOMEM;
+               }
+               snd_dma_set_reserved(&chip->dma_dev, &chip->dma);
        }
 
        INIT_LIST_HEAD(&chip->buf_list);
@@ -1534,10 +1537,10 @@
                snd_es1968_free_dmabuf(chip);
                return -ENOMEM;
        }
-       memset(chip->dma_buf, 0, 512);
-       chunk->buf = chip->dma_buf + 512;
-       chunk->addr = chip->dma_buf_addr + 512;
-       chunk->size = chip->dma_buf_size - 512;
+       memset(chip->dma.area, 0, 512);
+       chunk->buf = chip->dma.area + 512;
+       chunk->addr = chip->dma.addr + 512;
+       chunk->size = chip->dma.bytes - 512;
        chunk->empty = 1;
        list_add(&chunk->list, &chip->buf_list);
 
@@ -1812,7 +1815,7 @@
 
        wave_set_register(chip, apu << 3, (memory->addr - 0x10) & 0xfff8);
 
-       pa = (unsigned int)((memory->addr - chip->dma_buf_addr) >> 1);
+       pa = (unsigned int)((memory->addr - chip->dma.addr) >> 1);
        pa |= 0x00400000;       /* System RAM (Bit 22) */
 
        /* initialize apu */
@@ -1902,10 +1905,10 @@
                return err;
 
        /* set PCMBAR */
-       wave_set_register(chip, 0x01FC, chip->dma_buf_addr >> 12);
-       wave_set_register(chip, 0x01FD, chip->dma_buf_addr >> 12);
-       wave_set_register(chip, 0x01FE, chip->dma_buf_addr >> 12);
-       wave_set_register(chip, 0x01FF, chip->dma_buf_addr >> 12);
+       wave_set_register(chip, 0x01FC, chip->dma.addr >> 12);
+       wave_set_register(chip, 0x01FD, chip->dma.addr >> 12);
+       wave_set_register(chip, 0x01FE, chip->dma.addr >> 12);
+       wave_set_register(chip, 0x01FF, chip->dma.addr >> 12);
 
        if ((err = snd_pcm_new(chip->card, "ESS Maestro", device,
                               chip->playback_streams,
@@ -2443,9 +2446,9 @@
        snd_es1968_chip_init(chip);
 
        /* need to restore the base pointers.. */ 
-       if (chip->dma_buf_addr) {
+       if (chip->dma.addr) {
                /* set PCMBAR */
-               wave_set_register(chip, 0x01FC, chip->dma_buf_addr >> 12);
+               wave_set_register(chip, 0x01FC, chip->dma.addr >> 12);
        }
 
        /* restore ac97 state */



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to