Update of /cvsroot/alsa/alsa-driver/acore
In directory sc8-pr-cvs1:/tmp/cvs-serv31491/acore

Modified Files:
        Makefile misc.c sound.c 
Added Files:
        memalloc.c memory_wrapper.c pci_compat_22.c sgbuf.c 
Removed Files:
        pcm_sgbuf.c 
Log Message:
more unified DMA allocation:
- split memory allocator to snd-page-alloc.
- move pci-compat layer for 2.2 kernels to snd-page-alloc.
- use size_t for the size type.
- keep snd-page-alloc module loaded at stop operation of alsasound
  init script.



--- NEW FILE: memalloc.c ---
#include <linux/version.h>
#include "config.h"
#include "adriver.h"
#include "../alsa-kernel/core/memalloc.c"

/* compatible functions */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) && defined(CONFIG_PCI)
EXPORT_SYMBOL(snd_pci_compat_match_device);
EXPORT_SYMBOL(snd_pci_compat_register_driver);
EXPORT_SYMBOL(snd_pci_compat_unregister_driver);
EXPORT_SYMBOL(snd_pci_compat_get_size);
EXPORT_SYMBOL(snd_pci_compat_get_flags);
EXPORT_SYMBOL(snd_pci_compat_set_power_state);
EXPORT_SYMBOL(snd_pci_compat_enable_device);
EXPORT_SYMBOL(snd_pci_compat_find_capability);
EXPORT_SYMBOL(snd_pci_compat_alloc_consistent);
EXPORT_SYMBOL(snd_pci_compat_free_consistent);
EXPORT_SYMBOL(snd_pci_compat_dma_supported);
EXPORT_SYMBOL(snd_pci_compat_get_dma_mask);
EXPORT_SYMBOL(snd_pci_compat_set_dma_mask);
EXPORT_SYMBOL(snd_pci_compat_get_driver_data);
EXPORT_SYMBOL(snd_pci_compat_set_driver_data);
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19)
EXPORT_SYMBOL(snd_compat_vmalloc_to_page);
#endif

--- NEW FILE: memory_wrapper.c ---
#define __NO_VERSION__
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
#include "../alsa-kernel/core/memory_wrapper.c"
#else
#include "pci_compat_22.c"
#endif

/* vmalloc_to_page wrapper */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19)
struct page *snd_compat_vmalloc_to_page(void *pageptr)
{
        pgd_t *pgd;
        pmd_t *pmd;
        pte_t *pte;
        unsigned long lpage;
        struct page *page;

        lpage = VMALLOC_VMADDR(pageptr);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
        spin_lock(&init_mm.page_table_lock);
#endif
        pgd = pgd_offset(&init_mm, lpage);
        pmd = pmd_offset(pgd, lpage);
        pte = pte_offset(pmd, lpage);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
        page = virt_to_page(pte_page(*pte));
#else
        page = pte_page(*pte);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
        spin_unlock(&init_mm.page_table_lock);
#endif

        return page;
}    
#endif

--- NEW FILE: pci_compat_22.c ---
/*
 * PCI-compatible layer for 2.2 kernels
 */

#include <linux/config.h>
#include <linux/version.h>
#include <linux/pci.h>

#include "adriver.h"
#include <sound/memalloc.h>

static LIST_HEAD(pci_drivers);

struct pci_driver_mapping {
        struct pci_dev *dev;
        struct pci_driver *drv;
        unsigned long dma_mask;
        void *driver_data;
};

#define PCI_MAX_MAPPINGS 64
static struct pci_driver_mapping drvmap [PCI_MAX_MAPPINGS] = { { NULL, } , };


static struct pci_driver_mapping *get_pci_driver_mapping(struct pci_dev *dev)
{
        int i;
        
        for (i = 0; i < PCI_MAX_MAPPINGS; i++)
                if (drvmap[i].dev == dev)
                        return &drvmap[i];
        return NULL;
}

void * snd_pci_compat_get_driver_data (struct pci_dev *dev)
{
        struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
        if (map)
                return map->driver_data;
        return NULL;
}


void snd_pci_compat_set_driver_data (struct pci_dev *dev, void *driver_data)
{
        struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
        if (map)
                map->driver_data = driver_data;
}


unsigned long snd_pci_compat_get_dma_mask (struct pci_dev *dev)
{
        if (dev) {
                struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
                if (map)
                        return map->dma_mask;
                return 0;
        } else
                return 0xffffff; /* ISA - 16MB */
}


int snd_pci_compat_set_dma_mask (struct pci_dev *dev, unsigned long mask)
{
        if (dev) {
                struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
                if (map)
                        map->dma_mask = mask;
        }
        return 0;
}


const struct pci_device_id * snd_pci_compat_match_device(const struct pci_device_id 
*ids, struct pci_dev *dev)
{
        u16 subsystem_vendor, subsystem_device;

        pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
        pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &subsystem_device);

        while (ids->vendor || ids->subvendor || ids->class_mask) {
                if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) &&
                    (ids->device == PCI_ANY_ID || ids->device == dev->device) &&
                    (ids->subvendor == PCI_ANY_ID || ids->subvendor == 
subsystem_vendor) &&
                    (ids->subdevice == PCI_ANY_ID || ids->subdevice == 
subsystem_device) &&
                    !((ids->class ^ dev->class) & ids->class_mask))
                        return ids;
                ids++;
        }
        return NULL;
}

static int snd_pci_announce_device(struct pci_driver *drv, struct pci_dev *dev)
{
        int i;
        const struct pci_device_id *id;

        if (drv->id_table) {
                id = snd_pci_compat_match_device(drv->id_table, dev);
                if (!id)
                        return 0;
        } else {
                id = NULL;
        }
        for (i = 0; i < PCI_MAX_MAPPINGS; i++) {
                if (drvmap[i].dev == NULL) {
                        drvmap[i].dev = dev;
                        drvmap[i].drv = drv;
                        drvmap[i].dma_mask = ~0UL;
                        break;
                }
        }
        if (i >= PCI_MAX_MAPPINGS)
                return 0;
        if (drv->probe(dev, id) < 0) {
                 drvmap[i].dev = NULL;
                 return 0;
        }
        return 1;
}

int snd_pci_compat_register_driver(struct pci_driver *drv)
{
        struct pci_dev *dev;
        int count = 0;

        list_add_tail(&drv->node, &pci_drivers);
        pci_for_each_dev(dev) {
                struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
                if (! map)
                        count += snd_pci_announce_device(drv, dev);
        }
        return count;
}

void snd_pci_compat_unregister_driver(struct pci_driver *drv)
{
        struct pci_dev *dev;

        list_del(&drv->node);
        pci_for_each_dev(dev) {
                struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
                if (map && map->drv == drv) {
                        if (drv->remove)
                                drv->remove(dev);
                        map->dev = NULL;
                        map->drv = NULL;
                }
        }
}

unsigned long snd_pci_compat_get_size (struct pci_dev *dev, int n_base)
{
        u32 l, sz;
        int reg = PCI_BASE_ADDRESS_0 + (n_base << 2);

        pci_read_config_dword (dev, reg, &l);
        if (l == 0xffffffff)
                return 0;

        pci_write_config_dword (dev, reg, ~0);
        pci_read_config_dword (dev, reg, &sz);
        pci_write_config_dword (dev, reg, l);

        if (!sz || sz == 0xffffffff)
                return 0;
        if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) {
                sz = ~(sz & PCI_BASE_ADDRESS_MEM_MASK);
        } else {
                sz = ~(sz & PCI_BASE_ADDRESS_IO_MASK) & 0xffff;
        }
        
        return sz;
}

int snd_pci_compat_get_flags (struct pci_dev *dev, int n_base)
{
        unsigned long foo = dev->base_address[n_base] & PCI_BASE_ADDRESS_SPACE;
        int flags = 0;
        
        if (foo == 0)
                flags |= IORESOURCE_MEM;
        if (foo == 1)
                flags |= IORESOURCE_IO;
        
        return flags;
}

/*
 *  Set power management state of a device.  For transitions from state D3
 *  it isn't as straightforward as one could assume since many devices forget
 *  their configuration space during wakeup.  Returns old power state.
 */
int snd_pci_compat_set_power_state(struct pci_dev *dev, int new_state)
{
        u32 base[5], romaddr;
        u16 pci_command, pwr_command;
        u8  pci_latency, pci_cacheline;
        int i, old_state;
        int pm = snd_pci_compat_find_capability(dev, PCI_CAP_ID_PM);

        if (!pm)
                return 0;
        pci_read_config_word(dev, pm + PCI_PM_CTRL, &pwr_command);
        old_state = pwr_command & PCI_PM_CTRL_STATE_MASK;
        if (old_state == new_state)
                return old_state;
        if (old_state == 3) {
                pci_read_config_word(dev, PCI_COMMAND, &pci_command);
                pci_write_config_word(dev, PCI_COMMAND, pci_command & ~(PCI_COMMAND_IO 
| PCI_COMMAND_MEMORY));
                for (i = 0; i < 5; i++)
                        pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, &base[i]);
                pci_read_config_dword(dev, PCI_ROM_ADDRESS, &romaddr);
                pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
                pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_cacheline);
                pci_write_config_word(dev, pm + PCI_PM_CTRL, new_state);
                for (i = 0; i < 5; i++)
                        pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, base[i]);
                pci_write_config_dword(dev, PCI_ROM_ADDRESS, romaddr);
                pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
                pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cacheline);
                pci_write_config_byte(dev, PCI_LATENCY_TIMER, pci_latency);
                pci_write_config_word(dev, PCI_COMMAND, pci_command);
        } else
                pci_write_config_word(dev, pm + PCI_PM_CTRL, (pwr_command & 
~PCI_PM_CTRL_STATE_MASK) | new_state);
        return old_state;
}

/*
 *  Initialize device before it's used by a driver. Ask low-level code
 *  to enable I/O and memory. Wake up the device if it was suspended.
 *  Beware, this function can fail.
 */
int snd_pci_compat_enable_device(struct pci_dev *dev)
{
        u16 pci_command;

        pci_read_config_word(dev, PCI_COMMAND, &pci_command);
        pci_write_config_word(dev, PCI_COMMAND, pci_command | (PCI_COMMAND_IO | 
PCI_COMMAND_MEMORY));
        snd_pci_compat_set_power_state(dev, 0);
        return 0;
}

int snd_pci_compat_find_capability(struct pci_dev *dev, int cap)
{
        u16 status;
        u8 pos, id;
        int ttl = 48;

        pci_read_config_word(dev, PCI_STATUS, &status);
        if (!(status & PCI_STATUS_CAP_LIST))
                return 0;
        pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos);
        while (ttl-- && pos >= 0x40) {
                pos &= ~3;
                pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id);
                if (id == 0xff)
                        break;
                if (id == cap)
                        return pos;
                pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos);
        }
        return 0;
}

static void *snd_pci_compat_alloc_consistent1(unsigned long dma_mask,
                                              unsigned long size,
                                              int hop)
{
        void *res;

        if (++hop > 10)
                return NULL;
        res = snd_malloc_pages(size, GFP_KERNEL | (dma_mask <= 0x00ffffff ? GFP_DMA : 
0));
        if (res == NULL)
                return NULL;
        if ((virt_to_bus(res) & ~dma_mask) ||
            ((virt_to_bus(res) + size - 1) & ~dma_mask)) {
                void *res1 = snd_pci_compat_alloc_consistent1(dma_mask, size, hop);
                snd_free_pages(res, size);
                return res1;
        }
        return res;
}

void *snd_pci_compat_alloc_consistent(struct pci_dev *dev,
                                      long size,
                                      dma_addr_t *dmaaddr)
{
        unsigned long dma_mask = snd_pci_compat_get_dma_mask(dev);
        void *res = snd_pci_compat_alloc_consistent1(dma_mask, size, 0);
        if (res != NULL)
                *dmaaddr = (dma_addr_t)virt_to_bus(res);
        return res;
}

void snd_pci_compat_free_consistent(struct pci_dev *dev, long size, void *ptr, 
dma_addr_t dmaaddr)
{
        if (bus_to_virt(dmaaddr) != ptr) {
                printk(KERN_ERR "invalid address given %p != %lx to 
snd_pci_compat_free_consistent\n", ptr, (unsigned long)dmaaddr);
                return;
        }
        snd_free_pages(ptr, size);
}

int snd_pci_compat_dma_supported(struct pci_dev *dev, dma_addr_t mask)
{
        return 1;
}


--- NEW FILE: sgbuf.c ---
#define __NO_VERSION__
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
#include "../alsa-kernel/core/sgbuf.c"
#else
#include "adriver.h"

/*
 * we don't have vmap/vunmap, so use vmalloc_32 and vmalloc_dma instead
 */

#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <asm/io.h>
#include <sound/memalloc.h>

/* table entries are align to 32 */
#define SGBUF_TBL_ALIGN         32
#define sgbuf_align_table(tbl)  ((((tbl) + SGBUF_TBL_ALIGN - 1) / SGBUF_TBL_ALIGN) * 
SGBUF_TBL_ALIGN)

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
/* get the virtual address of the given vmalloc'ed pointer */
static void *get_vmalloc_addr(void *pageptr)
{
        pgd_t *pgd;
        pmd_t *pmd;
        pte_t *pte;
        unsigned long lpage;

        lpage = VMALLOC_VMADDR(pageptr);
        pgd = pgd_offset_k(lpage);
        pmd = pmd_offset(pgd, lpage);
        pte = pte_offset(pmd, lpage);
        return (void *)pte_page(*pte);
}    
#endif

/* set up the page table from the given vmalloc'ed buffer pointer.
 * return a negative error if the page is out of the pci address mask.
 */
static int store_page_tables(struct snd_sg_buf *sgbuf, void *vmaddr, unsigned int 
pages)
{
        unsigned int i;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
        unsigned long rmask;
        if (sgbuf->pci)
                rmask = ~((unsigned long)sgbuf->pci->dma_mask);
        else
                rmask = ~0xffffffUL;
#endif

        sgbuf->pages = 0;
        for (i = 0; i < pages; i++) {
                struct page *page;
                void *ptr;
                dma_addr_t addr;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
                page = vmalloc_to_page(vmaddr + (i << PAGE_SHIFT));
                ptr = page_address(page);
                addr = virt_to_bus(ptr);
                if (addr & rmask)
                        return -EINVAL;
#else
                ptr = get_vmalloc_addr(vmaddr + (i << PAGE_SHIFT));
                addr = virt_to_bus(ptr);
                page = virt_to_page(ptr);
#endif
                sgbuf->table[i].buf = ptr;
                sgbuf->table[i].addr = addr;
                sgbuf->page_table[i] = page;
                SetPageReserved(page);
                sgbuf->pages++;
        }
        return 0;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18)
#define vmalloc_32(x) vmalloc(x)
#endif

/* remove all vmalloced pages */
static void release_vm_buffer(struct snd_sg_buf *sgbuf, void *vmaddr)
{
        int i;

        for (i = 0; i < sgbuf->pages; i++)
                if (sgbuf->page_table[i]) {
                        ClearPageReserved(sgbuf->page_table[i]);
                        sgbuf->page_table[i] = NULL;
                }
        sgbuf->pages = 0;
        if (vmaddr)
                vfree(vmaddr); /* don't use wrapper */
}

void *snd_malloc_sgbuf_pages(struct pci_dev *pci, size_t size, struct snd_dma_buffer 
*dmab)
{
        struct snd_sg_buf *sgbuf;
        unsigned int pages;

        dmab->area = NULL;
        dmab->addr = 0;
        dmab->private_data = sgbuf = kmalloc(sizeof(*sgbuf), GFP_KERNEL);
        if (! sgbuf)
                return NULL;
        memset(sgbuf, 0, sizeof(*sgbuf));
        sgbuf->pci = pci;
        pages = snd_sgbuf_aligned_pages(size);
        sgbuf->tblsize = sgbuf_align_table(pages);
        sgbuf->table = kmalloc(sizeof(*sgbuf->table) * sgbuf->tblsize, GFP_KERNEL);
        if (! sgbuf->table)
                goto _failed;
        memset(sgbuf->table, 0, sizeof(*sgbuf->table) * sgbuf->tblsize);
        sgbuf->page_table = kmalloc(sizeof(*sgbuf->page_table) * sgbuf->tblsize, 
GFP_KERNEL);
        if (! sgbuf->page_table)
                goto _failed;
        memset(sgbuf->page_table, 0, sizeof(*sgbuf->page_table) * sgbuf->tblsize);

        sgbuf->size = size;
        dmab->area = vmalloc_32(pages << PAGE_SHIFT);
        if (! dmab->area || store_page_tables(sgbuf, dmab->area, pages) < 0) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
                /* reallocate with DMA flag */
                release_vm_buffer(sgbuf, dmab->area);
                dmab->area = vmalloc_dma(pages << PAGE_SHIFT);
                if (! dmab->area || store_page_tables(sgbuf, dmab->area, pages) < 0)
                        goto _failed;
                
#else
                goto _failed;
#endif
        }

        memset(dmab->area, 0, size);
        return dmab->area;

 _failed:
        snd_free_sgbuf_pages(dmab); /* free the table */
        return NULL;
}

int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
{
        struct snd_sg_buf *sgbuf = dmab->private_data;

        if (dmab->area)
                release_vm_buffer(sgbuf, dmab->area);
        dmab->area = NULL;
        if (sgbuf->table)
                kfree(sgbuf->table);
        sgbuf->table = NULL;
        if (sgbuf->page_table)
                kfree(sgbuf->page_table);
        kfree(sgbuf);
        dmab->private_data = NULL;
        
        return 0;
}

#endif /* < 2.5.0 */

Index: Makefile
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/acore/Makefile,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Makefile    18 Feb 2003 16:17:35 -0000      1.12
+++ Makefile    28 Feb 2003 14:32:08 -0000      1.13
@@ -4,19 +4,15 @@
 include $(TOPDIR)/Makefile.conf
 
 obj-$(CONFIG_SND_SERIALMIDI) += snd-rawmidi.o snd.o
-obj-$(CONFIG_SND_SSCAPE) += snd-pcm.o snd-timer.o snd.o snd-rawmidi.o snd-hwdep.o
-obj-$(CONFIG_SND_MSND_PINNACLE) += snd-pcm.o snd-timer.o snd.o snd-rawmidi.o
-obj-$(CONFIG_SND_AZT3328) += snd-pcm.o snd-timer.o snd.o snd-rawmidi.o snd-hwdep.o
-obj-$(CONFIG_SND_VXPOCKET) += snd-pcm.o snd-timer.o snd.o
-obj-$(CONFIG_SND_VXP440) += snd-pcm.o snd-timer.o snd.o
-obj-$(CONFIG_SND_VX222) += snd-pcm.o snd-timer.o snd.o
-obj-$(CONFIG_SND_HARMONY) += snd-pcm.o snd-timer.o snd.o
+obj-$(CONFIG_SND_SSCAPE) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o 
snd-rawmidi.o snd-hwdep.o
+obj-$(CONFIG_SND_MSND_PINNACLE) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o 
snd-rawmidi.o
+obj-$(CONFIG_SND_AZT3328) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o 
snd-rawmidi.o snd-hwdep.o
+obj-$(CONFIG_SND_VXPOCKET) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o
+obj-$(CONFIG_SND_VXP440) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o
+obj-$(CONFIG_SND_VX222) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o
+obj-$(CONFIG_SND_HARMONY) += snd-pcm.o snd-timer.o snd-page-alloc.o snd.o
 
-export-objs := sound.o pcm.o pcm_lib.o rawmidi.o timer.o hwdep.o
-
-ifeq ($(CONFIG_PCI),y)
-export-objs += pcm_sgbuf.o
-endif
+export-objs := sound.o pcm.o pcm_lib.o rawmidi.o timer.o hwdep.o memalloc.o
 
 TOPDIR = $(MAINSRCDIR)
 include $(TOPDIR)/alsa-kernel/core/Makefile

Index: misc.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/acore/misc.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- misc.c      22 Jan 2003 09:18:02 -0000      1.16
+++ misc.c      28 Feb 2003 14:32:10 -0000      1.17
@@ -76,311 +76,6 @@
 #endif
 
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) && defined(CONFIG_PCI)
-
-/*
- *  Registration of PCI drivers and handling of hot-pluggable devices.
- */
-
-static LIST_HEAD(pci_drivers);
-
-struct pci_driver_mapping {
-       struct pci_dev *dev;
-       struct pci_driver *drv;
-       unsigned long dma_mask;
-       void *driver_data;
-};
-
-#define PCI_MAX_MAPPINGS 64
-static struct pci_driver_mapping drvmap [PCI_MAX_MAPPINGS] = { { NULL, } , };
-
-
-static struct pci_driver_mapping *get_pci_driver_mapping(struct pci_dev *dev)
-{
-       int i;
-       
-       for (i = 0; i < PCI_MAX_MAPPINGS; i++)
-               if (drvmap[i].dev == dev)
-                       return &drvmap[i];
-       return NULL;
-}
-
-void * snd_pci_compat_get_driver_data (struct pci_dev *dev)
-{
-       struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
-       if (map)
-               return map->driver_data;
-       return NULL;
-}
-
-
-void snd_pci_compat_set_driver_data (struct pci_dev *dev, void *driver_data)
-{
-       struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
-       if (map)
-               map->driver_data = driver_data;
-}
-
-
-unsigned long snd_pci_compat_get_dma_mask (struct pci_dev *dev)
-{
-       if (dev) {
-               struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
-               if (map)
-                       return map->dma_mask;
-               return 0;
-       } else
-               return 0xffffff; /* ISA - 16MB */
-}
-
-
-int snd_pci_compat_set_dma_mask (struct pci_dev *dev, unsigned long mask)
-{
-       if (dev) {
-               struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
-               if (map)
-                       map->dma_mask = mask;
-       }
-       return 0;
-}
-
-
-const struct pci_device_id * snd_pci_compat_match_device(const struct pci_device_id 
*ids, struct pci_dev *dev)
-{
-       u16 subsystem_vendor, subsystem_device;
-
-       pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
-       pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &subsystem_device);
-
-       while (ids->vendor || ids->subvendor || ids->class_mask) {
-               if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) &&
-                   (ids->device == PCI_ANY_ID || ids->device == dev->device) &&
-                   (ids->subvendor == PCI_ANY_ID || ids->subvendor == 
subsystem_vendor) &&
-                   (ids->subdevice == PCI_ANY_ID || ids->subdevice == 
subsystem_device) &&
-                   !((ids->class ^ dev->class) & ids->class_mask))
-                       return ids;
-               ids++;
-       }
-       return NULL;
-}
-
-static int snd_pci_announce_device(struct pci_driver *drv, struct pci_dev *dev)
-{
-        int i;
-       const struct pci_device_id *id;
-
-       if (drv->id_table) {
-               id = snd_pci_compat_match_device(drv->id_table, dev);
-               if (!id)
-                       return 0;
-       } else {
-               id = NULL;
-       }
-        for (i = 0; i < PCI_MAX_MAPPINGS; i++) {
-               if (drvmap[i].dev == NULL) {
-                       drvmap[i].dev = dev;
-                       drvmap[i].drv = drv;
-                       drvmap[i].dma_mask = ~0UL;
-                       break;
-               }
-        }
-        if (i >= PCI_MAX_MAPPINGS)
-               return 0;
-       if (drv->probe(dev, id) < 0) {
-                 drvmap[i].dev = NULL;
-                return 0;
-       }
-       return 1;
-}
-
-int snd_pci_compat_register_driver(struct pci_driver *drv)
-{
-       struct pci_dev *dev;
-       int count = 0;
-
-       list_add_tail(&drv->node, &pci_drivers);
-       pci_for_each_dev(dev) {
-               struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
-               if (! map)
-                       count += snd_pci_announce_device(drv, dev);
-       }
-       return count;
-}
-
-void snd_pci_compat_unregister_driver(struct pci_driver *drv)
-{
-       struct pci_dev *dev;
-
-       list_del(&drv->node);
-       pci_for_each_dev(dev) {
-               struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
-               if (map && map->drv == drv) {
-                       if (drv->remove)
-                               drv->remove(dev);
-                       map->dev = NULL;
-                       map->drv = NULL;
-               }
-       }
-}
-
-unsigned long snd_pci_compat_get_size (struct pci_dev *dev, int n_base)
-{
-       u32 l, sz;
-       int reg = PCI_BASE_ADDRESS_0 + (n_base << 2);
-
-       pci_read_config_dword (dev, reg, &l);
-       if (l == 0xffffffff)
-               return 0;
-
-       pci_write_config_dword (dev, reg, ~0);
-       pci_read_config_dword (dev, reg, &sz);
-       pci_write_config_dword (dev, reg, l);
-
-       if (!sz || sz == 0xffffffff)
-               return 0;
-       if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) {
-               sz = ~(sz & PCI_BASE_ADDRESS_MEM_MASK);
-       } else {
-               sz = ~(sz & PCI_BASE_ADDRESS_IO_MASK) & 0xffff;
-       }
-       
-       return sz;
-}
-
-int snd_pci_compat_get_flags (struct pci_dev *dev, int n_base)
-{
-       unsigned long foo = dev->base_address[n_base] & PCI_BASE_ADDRESS_SPACE;
-       int flags = 0;
-       
-       if (foo == 0)
-               flags |= IORESOURCE_MEM;
-       if (foo == 1)
-               flags |= IORESOURCE_IO;
-       
-       return flags;
-}
-
-/*
- *  Set power management state of a device.  For transitions from state D3
- *  it isn't as straightforward as one could assume since many devices forget
- *  their configuration space during wakeup.  Returns old power state.
- */
-int snd_pci_compat_set_power_state(struct pci_dev *dev, int new_state)
-{
-       u32 base[5], romaddr;
-       u16 pci_command, pwr_command;
-       u8  pci_latency, pci_cacheline;
-       int i, old_state;
-       int pm = snd_pci_compat_find_capability(dev, PCI_CAP_ID_PM);
-
-       if (!pm)
-               return 0;
-       pci_read_config_word(dev, pm + PCI_PM_CTRL, &pwr_command);
-       old_state = pwr_command & PCI_PM_CTRL_STATE_MASK;
-       if (old_state == new_state)
-               return old_state;
-       if (old_state == 3) {
-               pci_read_config_word(dev, PCI_COMMAND, &pci_command);
-               pci_write_config_word(dev, PCI_COMMAND, pci_command & ~(PCI_COMMAND_IO 
| PCI_COMMAND_MEMORY));
-               for (i = 0; i < 5; i++)
-                       pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, &base[i]);
-               pci_read_config_dword(dev, PCI_ROM_ADDRESS, &romaddr);
-               pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
-               pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_cacheline);
-               pci_write_config_word(dev, pm + PCI_PM_CTRL, new_state);
-               for (i = 0; i < 5; i++)
-                       pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, base[i]);
-               pci_write_config_dword(dev, PCI_ROM_ADDRESS, romaddr);
-               pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
-               pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cacheline);
-               pci_write_config_byte(dev, PCI_LATENCY_TIMER, pci_latency);
-               pci_write_config_word(dev, PCI_COMMAND, pci_command);
-       } else
-               pci_write_config_word(dev, pm + PCI_PM_CTRL, (pwr_command & 
~PCI_PM_CTRL_STATE_MASK) | new_state);
-       return old_state;
-}
-
-/*
- *  Initialize device before it's used by a driver. Ask low-level code
- *  to enable I/O and memory. Wake up the device if it was suspended.
- *  Beware, this function can fail.
- */
-int snd_pci_compat_enable_device(struct pci_dev *dev)
-{
-       u16 pci_command;
-
-       pci_read_config_word(dev, PCI_COMMAND, &pci_command);
-       pci_write_config_word(dev, PCI_COMMAND, pci_command | (PCI_COMMAND_IO | 
PCI_COMMAND_MEMORY));
-       snd_pci_compat_set_power_state(dev, 0);
-       return 0;
-}
-
-int snd_pci_compat_find_capability(struct pci_dev *dev, int cap)
-{
-       u16 status;
-       u8 pos, id;
-       int ttl = 48;
-
-       pci_read_config_word(dev, PCI_STATUS, &status);
-       if (!(status & PCI_STATUS_CAP_LIST))
-               return 0;
-       pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos);
-       while (ttl-- && pos >= 0x40) {
-               pos &= ~3;
-               pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id);
-               if (id == 0xff)
-                       break;
-               if (id == cap)
-                       return pos;
-               pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos);
-       }
-       return 0;
-}
-
-static void *snd_pci_compat_alloc_consistent1(unsigned long dma_mask,
-                                             unsigned long size,
-                                             int hop)
-{
-       void *res;
-
-       if (++hop > 10)
-               return NULL;
-       res = snd_malloc_pages(size, GFP_KERNEL | (dma_mask <= 0x00ffffff ? GFP_DMA : 
0));
-       if (res == NULL)
-               return NULL;
-       if ((virt_to_bus(res) & ~dma_mask) ||
-           ((virt_to_bus(res) + size - 1) & ~dma_mask)) {
-               void *res1 = snd_pci_compat_alloc_consistent1(dma_mask, size, hop);
-               snd_free_pages(res, size);
-               return res1;
-       }
-       return res;
-}
-
-void *snd_pci_compat_alloc_consistent(struct pci_dev *dev,
-                                     long size,
-                                     dma_addr_t *dmaaddr)
-{
-       unsigned long dma_mask = snd_pci_compat_get_dma_mask(dev);
-       void *res = snd_pci_compat_alloc_consistent1(dma_mask, size, 0);
-       if (res != NULL)
-               *dmaaddr = (dma_addr_t)virt_to_bus(res);
-       return res;
-}
-
-void snd_pci_compat_free_consistent(struct pci_dev *dev, long size, void *ptr, 
dma_addr_t dmaaddr)
-{
-       snd_runtime_check(bus_to_virt(dmaaddr) == ptr, return);
-       snd_free_pages(ptr, size);
-}
-
-int snd_pci_compat_dma_supported(struct pci_dev *dev, dma_addr_t mask)
-{
-       return 1;
-}
-
-#endif /* kernel version < 2.3.0 && CONFIG_PCI */
-
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) && defined(CONFIG_APM)
 
 #include <linux/apm_bios.h>
@@ -565,34 +260,4 @@
        return kernel_thread(work_caller, wp, 0) >= 0;
 }
 
-#endif
-
-/* vmalloc_to_page wrapper */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19)
-struct page *snd_compat_vmalloc_to_page(void *pageptr)
-{
-       pgd_t *pgd;
-       pmd_t *pmd;
-       pte_t *pte;
-       unsigned long lpage;
-       struct page *page;
-
-       lpage = VMALLOC_VMADDR(pageptr);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-       spin_lock(&init_mm.page_table_lock);
-#endif
-       pgd = pgd_offset(&init_mm, lpage);
-       pmd = pmd_offset(pgd, lpage);
-       pte = pte_offset(pmd, lpage);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-       page = virt_to_page(pte_page(*pte));
-#else
-       page = pte_page(*pte);
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-       spin_unlock(&init_mm.page_table_lock);
-#endif
-
-       return page;
-}    
 #endif

Index: sound.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/acore/sound.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- sound.c     22 Jan 2003 09:17:33 -0000      1.7
+++ sound.c     28 Feb 2003 14:32:12 -0000      1.8
@@ -6,26 +6,6 @@
 EXPORT_SYMBOL(snd_compat_request_region);
 EXPORT_SYMBOL(snd_compat_release_resource);
 #endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19)
-EXPORT_SYMBOL(snd_compat_vmalloc_to_page);
-#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) && defined(CONFIG_PCI)
-EXPORT_SYMBOL(snd_pci_compat_match_device);
-EXPORT_SYMBOL(snd_pci_compat_register_driver);
-EXPORT_SYMBOL(snd_pci_compat_unregister_driver);
-EXPORT_SYMBOL(snd_pci_compat_get_size);
-EXPORT_SYMBOL(snd_pci_compat_get_flags);
-EXPORT_SYMBOL(snd_pci_compat_set_power_state);
-EXPORT_SYMBOL(snd_pci_compat_enable_device);
-EXPORT_SYMBOL(snd_pci_compat_find_capability);
-EXPORT_SYMBOL(snd_pci_compat_alloc_consistent);
-EXPORT_SYMBOL(snd_pci_compat_free_consistent);
-EXPORT_SYMBOL(snd_pci_compat_dma_supported);
-EXPORT_SYMBOL(snd_pci_compat_get_dma_mask);
-EXPORT_SYMBOL(snd_pci_compat_set_dma_mask);
-EXPORT_SYMBOL(snd_pci_compat_get_driver_data);
-EXPORT_SYMBOL(snd_pci_compat_set_driver_data);
-#endif
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) && defined(CONFIG_PM)
 EXPORT_SYMBOL(pm_register);
 EXPORT_SYMBOL(pm_unregister);

--- pcm_sgbuf.c DELETED ---



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