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

Modified Files:
        cs46xx_lib.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: cs46xx_lib.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/cs46xx/cs46xx_lib.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- cs46xx_lib.c        21 Jan 2004 18:32:47 -0000      1.68
+++ cs46xx_lib.c        2 Mar 2004 15:32:37 -0000       1.69
@@ -699,7 +699,7 @@
                        bytes = hw_to_end;
                if (sw_to_end < bytes)
                        bytes = sw_to_end;
-               memcpy(cpcm->hw_area + cpcm->hw_data,
+               memcpy(cpcm->hw_buf.area + cpcm->hw_data,
                       runtime->dma_area + cpcm->sw_data,
                       bytes);
                cpcm->hw_data += bytes;
@@ -740,7 +740,7 @@
                if (sw_to_end < bytes)
                        bytes = sw_to_end;
                memcpy(runtime->dma_area + chip->capt.sw_data,
-                      chip->capt.hw_area + chip->capt.hw_data,
+                      chip->capt.hw_buf.area + chip->capt.hw_data,
                       bytes);
                chip->capt.hw_data += bytes;
                if ((int)chip->capt.hw_data == buffer_size)
@@ -766,7 +766,7 @@
 #else
        ptr = snd_cs46xx_peek(chip, BA1_PBA);
 #endif
-       ptr -= cpcm->hw_addr;
+       ptr -= cpcm->hw_buf.addr;
        return ptr >> cpcm->shift;
 }
 
@@ -784,7 +784,7 @@
 #else
        ptr = snd_cs46xx_peek(chip, BA1_PBA);
 #endif
-       ptr -= cpcm->hw_addr;
+       ptr -= cpcm->hw_buf.addr;
 
        bytes = ptr - cpcm->hw_io;
 
@@ -802,14 +802,14 @@
 static snd_pcm_uframes_t snd_cs46xx_capture_direct_pointer(snd_pcm_substream_t * 
substream)
 {
        cs46xx_t *chip = snd_pcm_substream_chip(substream);
-       size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_addr;
+       size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr;
        return ptr >> chip->capt.shift;
 }
 
 static snd_pcm_uframes_t snd_cs46xx_capture_indirect_pointer(snd_pcm_substream_t * 
substream)
 {
        cs46xx_t *chip = snd_pcm_substream_chip(substream);
-       size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_addr;
+       size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr;
        ssize_t bytes = ptr - chip->capt.hw_io;
        int buffer_size = substream->runtime->period_size * CS46XX_FRAGS << 
chip->capt.shift;
 
@@ -933,7 +933,7 @@
        /* If PCMReaderSCB and SrcTaskSCB not created yet ... */
        if ( cpcm->pcm_channel == NULL) {
                cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, 
-                                                                  cpcm, 
cpcm->hw_addr,cpcm->pcm_channel_id);
+                                                                  cpcm, 
cpcm->hw_buf.addr,cpcm->pcm_channel_id);
                if (cpcm->pcm_channel == NULL) {
                        snd_printk(KERN_ERR "cs46xx: failed to create virtual PCM 
channel\n");
                        return -ENOMEM;
@@ -946,7 +946,7 @@
                cs46xx_dsp_destroy_pcm_channel (chip,cpcm->pcm_channel);
 
                if ( (cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, 
sample_rate, cpcm, 
-                                                                        cpcm->hw_addr,
+                                                                        
cpcm->hw_buf.addr,
                                                                         
cpcm->pcm_channel_id)) == NULL) {
                        snd_printk(KERN_ERR "cs46xx: failed to re-create virtual PCM 
channel\n");
                        return -ENOMEM;
@@ -1002,11 +1002,11 @@
 #endif
 
        if (params_periods(hw_params) == CS46XX_FRAGS) {
-               if (runtime->dma_area != cpcm->hw_area)
+               if (runtime->dma_area != cpcm->hw_buf.area)
                        snd_pcm_lib_free_pages(substream);
-               runtime->dma_area = cpcm->hw_area;
-               runtime->dma_addr = cpcm->hw_addr;
-               runtime->dma_bytes = cpcm->hw_size;
+               runtime->dma_area = cpcm->hw_buf.area;
+               runtime->dma_addr = cpcm->hw_buf.addr;
+               runtime->dma_bytes = cpcm->hw_buf.bytes;
 
 
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
@@ -1026,7 +1026,7 @@
 #endif
 
        } else {
-               if (runtime->dma_area == cpcm->hw_area) {
+               if (runtime->dma_area == cpcm->hw_buf.area) {
                        runtime->dma_area = NULL;
                        runtime->dma_addr = 0;
                        runtime->dma_bytes = 0;
@@ -1075,7 +1075,7 @@
           is called and cpcm can actually be NULL here */
        if (!cpcm) return -ENXIO;
 
-       if (runtime->dma_area != cpcm->hw_area)
+       if (runtime->dma_area != cpcm->hw_buf.area)
                snd_pcm_lib_free_pages(substream);
     
        runtime->dma_area = NULL;
@@ -1144,7 +1144,7 @@
        /* playback format && interrupt enable */
        snd_cs46xx_poke(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2, 
pfie | cpcm->pcm_channel->pcm_slot);
 #else
-       snd_cs46xx_poke(chip, BA1_PBA, cpcm->hw_addr);
+       snd_cs46xx_poke(chip, BA1_PBA, cpcm->hw_buf.addr);
        tmp = snd_cs46xx_peek(chip, BA1_PDTC);
        tmp &= ~0x000003ff;
        tmp |= (4 << cpcm->shift) - 1;
@@ -1167,14 +1167,14 @@
        cs46xx_dsp_pcm_ostream_set_period (chip, params_period_bytes(hw_params));
 #endif
        if (runtime->periods == CS46XX_FRAGS) {
-               if (runtime->dma_area != chip->capt.hw_area)
+               if (runtime->dma_area != chip->capt.hw_buf.area)
                        snd_pcm_lib_free_pages(substream);
-               runtime->dma_area = chip->capt.hw_area;
-               runtime->dma_addr = chip->capt.hw_addr;
-               runtime->dma_bytes = chip->capt.hw_size;
+               runtime->dma_area = chip->capt.hw_buf.area;
+               runtime->dma_addr = chip->capt.hw_buf.addr;
+               runtime->dma_bytes = chip->capt.hw_buf.bytes;
                substream->ops = &snd_cs46xx_capture_ops;
        } else {
-               if (runtime->dma_area == chip->capt.hw_area) {
+               if (runtime->dma_area == chip->capt.hw_buf.area) {
                        runtime->dma_area = NULL;
                        runtime->dma_addr = 0;
                        runtime->dma_bytes = 0;
@@ -1192,7 +1192,7 @@
        cs46xx_t *chip = snd_pcm_substream_chip(substream);
        snd_pcm_runtime_t *runtime = substream->runtime;
 
-       if (runtime->dma_area != chip->capt.hw_area)
+       if (runtime->dma_area != chip->capt.hw_buf.area)
                snd_pcm_lib_free_pages(substream);
        runtime->dma_area = NULL;
        runtime->dma_addr = 0;
@@ -1206,7 +1206,7 @@
        cs46xx_t *chip = snd_pcm_substream_chip(substream);
        snd_pcm_runtime_t *runtime = substream->runtime;
 
-       snd_cs46xx_poke(chip, BA1_CBA, chip->capt.hw_addr);
+       snd_cs46xx_poke(chip, BA1_CBA, chip->capt.hw_buf.addr);
        chip->capt.shift = 2;
        chip->capt.sw_bufsize = snd_pcm_lib_buffer_bytes(substream);
        chip->capt.sw_data = chip->capt.sw_io = chip->capt.sw_ready = 0;
@@ -1382,8 +1382,7 @@
        cpcm = snd_magic_kcalloc(cs46xx_pcm_t, 0, GFP_KERNEL);
        if (cpcm == NULL)
                return -ENOMEM;
-       cpcm->hw_size = PAGE_SIZE;
-       if ((cpcm->hw_area = snd_malloc_pci_pages(chip->pci, cpcm->hw_size, 
&cpcm->hw_addr)) == NULL) {
+       if (snd_dma_alloc_pages(&chip->dma_dev, PAGE_SIZE, &cpcm->hw_buf) < 0) {
                snd_magic_kfree(cpcm);
                return -ENOMEM;
        }
@@ -1472,7 +1471,7 @@
 {
        cs46xx_t *chip = snd_pcm_substream_chip(substream);
 
-       if ((chip->capt.hw_area = snd_malloc_pci_pages(chip->pci, chip->capt.hw_size, 
&chip->capt.hw_addr)) == NULL)
+       if (snd_dma_alloc_pages(&chip->dma_dev, PAGE_SIZE, &chip->capt.hw_buf) < 0)
                return -ENOMEM;
        chip->capt.substream = substream;
        substream->runtime->hw = snd_cs46xx_capture;
@@ -1513,7 +1512,7 @@
 #endif
 
        cpcm->substream = NULL;
-       snd_free_pci_pages(chip->pci, cpcm->hw_size, cpcm->hw_area, cpcm->hw_addr);
+       snd_dma_free_pages(&chip->dma_dev, &cpcm->hw_buf);
        chip->active_ctrl(chip, -1);
 
        return 0;
@@ -1524,7 +1523,7 @@
        cs46xx_t *chip = snd_pcm_substream_chip(substream);
 
        chip->capt.substream = NULL;
-       snd_free_pci_pages(chip->pci, chip->capt.hw_size, chip->capt.hw_area, 
chip->capt.hw_addr);
+       snd_dma_free_pages(&chip->dma_dev, &chip->capt.hw_buf);
        chip->active_ctrl(chip, -1);
 
        return 0;
@@ -1703,7 +1702,8 @@
        strcpy(pcm->name, "CS46xx");
        chip->pcm = pcm;
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 256*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             chip->pci, 64*1024, 256*1024);
 
        if (rpcm)
                *rpcm = pcm;
@@ -1734,7 +1734,8 @@
        strcpy(pcm->name, "CS46xx - Rear");
        chip->pcm_rear = pcm;
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 256*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             pcm, 64*1024, 256*1024);
 
        if (rpcm)
                *rpcm = pcm;
@@ -1763,7 +1764,8 @@
        strcpy(pcm->name, "CS46xx - Center LFE");
        chip->pcm_center_lfe = pcm;
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 256*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             chip->pci, 64*1024, 256*1024);
 
        if (rpcm)
                *rpcm = pcm;
@@ -1792,7 +1794,8 @@
        strcpy(pcm->name, "CS46xx - IEC958");
        chip->pcm_rear = pcm;
 
-       snd_pcm_lib_preallocate_pci_pages_for_all(chip->pci, pcm, 64*1024, 256*1024);
+       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_PCI,
+                                             chip->pci, 64*1024, 256*1024);
 
        if (rpcm)
                *rpcm = pcm;
@@ -3877,7 +3880,6 @@
 #endif
        chip->card = card;
        chip->pci = pci;
-       chip->capt.hw_size = PAGE_SIZE;
        chip->irq = -1;
        chip->ba0_addr = pci_resource_start(pci, 0);
        chip->ba1_addr = pci_resource_start(pci, 1);
@@ -3913,6 +3915,10 @@
        region->base = chip->ba1_addr + BA1_SP_REG;
        region->size = CS46XX_BA1_REG_SIZE;
 
+       memset(&chip->dma_dev, 0, sizeof(chip->dma_dev));
+       chip->dma_dev.type = SNDRV_DMA_TYPE_PCI;
+       chip->dma_dev.dev.pci = pci;
+
        /* set up amp and clkrun hack */
        pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &ss_vendor);
        pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &ss_card);



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