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

Modified Files:
        mixart.c mixart.h mixart_hwdep.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: mixart.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/mixart/mixart.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- mixart.c    24 Feb 2004 12:08:03 -0000      1.4
+++ mixart.c    2 Mar 2004 15:32:38 -0000       1.5
@@ -263,6 +263,9 @@
 
                for (i=0; i<stream_count; i++) {
                        int j;
+                       struct mixart_flowinfo *flowinfo;
+                       struct mixart_bufferinfo *bufferinfo;
+                       
                        /* we don't yet know the format, so config 16 bit pcm audio 
for instance */
                        streaming_group_req.stream_info[i].size_max_byte_frame = 1024;
                        streaming_group_req.stream_info[i].size_max_sample_frame = 256;
@@ -274,16 +277,18 @@
 
                        streaming_group_req.flow_entry[i] = j;
 
-                       chip->mgr->flowinfo_array[j].bufferinfo_array_phy_address = 
(u32)chip->mgr->bufferinfo_physaddr + (j * sizeof(mixart_bufferinfo_t));
-                       chip->mgr->flowinfo_array[j].bufferinfo_count = 1;             
  /* 1 will set the miXart to ring-buffer mode ! */
-
-                       chip->mgr->bufferinfo_array[j].buffer_address = 0;             
  /* buffer is not yet allocated */
-                       chip->mgr->bufferinfo_array[j].available_length = 0;           
  /* buffer is not yet allocated */
+                       flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area;
+                       flowinfo[j].bufferinfo_array_phy_address = 
(u32)chip->mgr->bufferinfo.addr + (j * sizeof(mixart_bufferinfo_t));
+                       flowinfo[j].bufferinfo_count = 1;               /* 1 will set 
the miXart to ring-buffer mode ! */
+
+                       bufferinfo = (struct mixart_bufferinfo 
*)chip->mgr->bufferinfo.area;
+                       bufferinfo[j].buffer_address = 0;               /* buffer is 
not yet allocated */
+                       bufferinfo[j].available_length = 0;             /* buffer is 
not yet allocated */
 
                        /* construct the identifier of the stream buffer received in 
the interrupts ! */
-                       chip->mgr->bufferinfo_array[j].buffer_id = (chip->chip_idx << 
MIXART_NOTIFY_CARD_OFFSET) + (pcm_number << MIXART_NOTIFY_PCM_OFFSET ) + i;
+                       bufferinfo[j].buffer_id = (chip->chip_idx << 
MIXART_NOTIFY_CARD_OFFSET) + (pcm_number << MIXART_NOTIFY_PCM_OFFSET ) + i;
                        if(capture) {
-                               chip->mgr->bufferinfo_array[j].buffer_id |= 
MIXART_NOTIFY_CAPT_MASK;
+                               bufferinfo[j].buffer_id |= MIXART_NOTIFY_CAPT_MASK;
                        }
                }
 
@@ -602,13 +607,16 @@
        err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw));
 
        if (err > 0) {
+               struct mixart_bufferinfo *bufferinfo;
                int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + 
(stream->pcm_number * (MIXART_PLAYBACK_STREAMS+MIXART_CAPTURE_STREAMS)) + subs->number;
                if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) {
                        i += MIXART_PLAYBACK_STREAMS; /* in array capture is behind 
playback */
                }
-               mgr->bufferinfo_array[i].buffer_address = subs->runtime->dma_addr;
-               mgr->bufferinfo_array[i].available_length = subs->runtime->dma_bytes;
-               /* mgr->bufferinfo_array[i].buffer_id  is already defined */
+               
+               bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area;
+               bufferinfo[i].buffer_address = subs->runtime->dma_addr;
+               bufferinfo[i].available_length = subs->runtime->dma_bytes;
+               /* bufferinfo[i].buffer_id  is already defined */
 
                snd_printdd("snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) 
subs-number(%d)\n", i, subs->runtime->dma_addr, subs->runtime->dma_bytes, 
subs->number);
        }
@@ -902,7 +910,8 @@
                                subs->stream << 8 | (subs->number + 1) |
                                (chip->chip_idx + 1) << 24;
        }
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->mgr->pci, pcm, 32*1024, 
32*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             chip->mgr->pci, 32*1024, 32*1024);
 }
 
 /*
@@ -1070,14 +1079,14 @@
        }
 
        /* free flowarray */
-       if(mgr->flowinfo_array) {
-               snd_free_pci_pages(mgr->pci, PAGE_ALIGN(MIXART_MAX_STREAM_PER_CARD * 
MIXART_MAX_CARDS * sizeof(mixart_flowinfo_t)),
-                                  mgr->flowinfo_array, mgr->flowinfo_physaddr);
+       if(mgr->flowinfo.area) {
+               snd_dma_free_pages(&mgr->dma_dev, &mgr->flowinfo);
+               mgr->flowinfo.area = NULL;
        }
        /* free bufferarray */
-       if(mgr->bufferinfo_array) {
-               snd_free_pci_pages(mgr->pci, PAGE_ALIGN(MIXART_MAX_STREAM_PER_CARD * 
MIXART_MAX_CARDS * sizeof(mixart_bufferinfo_t)),
-                                  mgr->bufferinfo_array, mgr->bufferinfo_physaddr);
+       if(mgr->bufferinfo.area) {
+               snd_dma_free_pages(&mgr->dma_dev, &mgr->bufferinfo);
+               mgr->bufferinfo.area = NULL;
        }
 
        snd_magic_kfree(mgr);
@@ -1380,25 +1389,27 @@
        /* init firmware status (mgr->hwdep->dsp_loaded reset in hwdep_new) */
        mgr->board_type = MIXART_DAUGHTER_TYPE_NONE;
 
+       memset(&mgr->dma_dev, 0, sizeof(mgr->dma_dev));
+       mgr->dma_dev.type = SNDRV_DMA_TYPE_PCI;
+       mgr->dma_dev.dev.pci = mgr->pci;
+
        /* create array of streaminfo */
        size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * 
sizeof(mixart_flowinfo_t)) );
-       mgr->flowinfo_array = snd_malloc_pci_pages(mgr->pci, size, 
&mgr->flowinfo_physaddr);
-       if(!mgr->flowinfo_array) {
+       if (snd_dma_alloc_pages(&mgr->dma_dev, size, &mgr->flowinfo) < 0) {
                snd_mixart_free(mgr);
                return -ENOMEM;
        }
        /* init streaminfo_array */
-       memset(mgr->flowinfo_array, 0, size);
+       memset(mgr->flowinfo.area, 0, size);
 
        /* create array of bufferinfo */
        size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * 
sizeof(mixart_bufferinfo_t)) );
-       mgr->bufferinfo_array = snd_malloc_pci_pages(mgr->pci, size, 
&mgr->bufferinfo_physaddr);
-       if(!mgr->bufferinfo_array) {
+       if (snd_dma_alloc_pages(&mgr->dma_dev, size, &mgr->bufferinfo) < 0) {
                snd_mixart_free(mgr);
                return -ENOMEM;
        }
        /* init bufferinfo_array */
-       memset(mgr->bufferinfo_array, 0, size);
+       memset(mgr->bufferinfo.area, 0, size);
 
        pci_set_drvdata(pci, mgr);
        dev++;

Index: mixart.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/mixart/mixart.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mixart.h    24 Feb 2004 12:08:03 -0000      1.2
+++ mixart.h    2 Mar 2004 15:32:38 -0000       1.3
@@ -114,10 +114,9 @@
        snd_hwdep_t *hwdep;
        unsigned int board_type;      /* read from embedded once elf file is loaded, 
250 = miXart8, 251 = with AES, 252 = with Cobranet */
 
-       mixart_flowinfo_t*   flowinfo_array;
-       dma_addr_t           flowinfo_physaddr;
-       mixart_bufferinfo_t* bufferinfo_array;
-       dma_addr_t           bufferinfo_physaddr;
+       struct snd_dma_device dma_dev;
+       struct snd_dma_buffer flowinfo;
+       struct snd_dma_buffer bufferinfo;
 
        mixart_uid_t         uid_console_manager;
        int sample_rate;

Index: mixart_hwdep.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/mixart/mixart_hwdep.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mixart_hwdep.c      23 Feb 2004 18:18:24 -0000      1.3
+++ mixart_hwdep.c      2 Mar 2004 15:32:38 -0000       1.4
@@ -441,7 +441,7 @@
                }
 
                /* miXart waits at this point on the pointer to the flow table */
-               writel_be( (u32)mgr->flowinfo_physaddr, MIXART_MEM( mgr, 
MIXART_FLOWTABLE_PTR ) ); /* give pointer of flow table to miXart */
+               writel_be( (u32)mgr->flowinfo.addr, MIXART_MEM( mgr, 
MIXART_FLOWTABLE_PTR ) ); /* give pointer of flow table to miXart */
 
                return 0;  /* return, another xilinx file has to be loaded before */
 



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