Changeset 366


Ignore:
Timestamp:
Aug 30, 2008, 9:18:38 PM (17 years ago)
Author:
Brendan Oakley
Message:

Missed stuff in 1.0.4

Location:
GPL/branches/alsa-resync1/alsa-kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/alsa-resync1/alsa-kernel/core/memalloc.c

    r348 r366  
    2626#include <sound/info.h>
    2727#include <linux/proc_fs.h>
     28#include <linux/pci.h>
     29#include <linux/dma-mapping.h>
    2830#include <sound/memalloc.h>
    2931#ifdef CONFIG_SBUS
     
    6668#define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1
    6769
    68 #ifdef CONFIG_PCI
     70/*
     71 *  Hacks
     72 */
     73
    6974#if defined(__i386__) || defined(__ppc__) || defined(__x86_64__)
    70 
    7175/*
    7276 * A hack to allocate large buffers via dma_alloc_coherent()
     
    121125#define dma_free_coherent(dev,size,ptr,addr) pci_free_consistent((struct pci_dev *)(dev),size,ptr,addr)
    122126
    123 #endif /* CONFIG_PCI */
     127/*
     128 *
     129 *  Generic memory allocators
     130 *
     131 */
     132
     133static long snd_allocated_pages; /* holding the number of allocated pages */
     134
     135static inline void inc_snd_pages(int order)
     136{
     137        snd_allocated_pages += 1 << order;
     138}
     139
     140static inline void dec_snd_pages(int order)
     141{
     142        snd_allocated_pages -= 1 << order;
     143}
     144
     145/**
     146 * snd_malloc_pages - allocate pages with the given size
     147 * @size: the size to allocate in bytes
     148 * @gfp_flags: the allocation conditions, GFP_XXX
     149 *
     150 * Allocates the physically contiguous pages with the given size.
     151 *
     152 * Returns the pointer of the buffer, or NULL if no enoguh memory.
     153 */
     154void *snd_malloc_pages(size_t size, unsigned int dma_flags)
     155{
     156    int pg;
     157    void *res;
     158
     159    snd_assert(size > 0, return NULL);
     160    snd_assert(dma_flags != 0, return NULL);
     161    pg = get_order(size);
     162    if ((res = (void *) __get_free_pages(dma_flags, pg)) != NULL) {
     163        inc_snd_pages(pg);
     164    }
     165    return res;
     166}
     167
     168/**
     169 * snd_malloc_pages_fallback - allocate pages with the given size with fallback
     170 * @size: the requested size to allocate in bytes
     171 * @gfp_flags: the allocation conditions, GFP_XXX
     172 * @res_size: the pointer to store the size of buffer actually allocated
     173 *
     174 * Allocates the physically contiguous pages with the given request
     175 * size.  When no space is left, this function reduces the size and
     176 * tries to allocate again.  The size actually allocated is stored in
     177 * res_size argument.
     178 *
     179 * Returns the pointer of the buffer, or NULL if no enoguh memory.
     180 */           
     181void *snd_malloc_pages_fallback(size_t size, unsigned int gfp_flags, size_t *res_size)
     182{
     183        void *res;
     184
     185        snd_assert(size > 0, return NULL);
     186        snd_assert(res_size != NULL, return NULL);
     187        do {
     188                if ((res = snd_malloc_pages(size, gfp_flags)) != NULL) {
     189                        *res_size = size;
     190                        return res;
     191                }
     192                size >>= 1;
     193        } while (size >= PAGE_SIZE);
     194        return NULL;
     195}
     196
     197/**
     198 * snd_free_pages - release the pages
     199 * @ptr: the buffer pointer to release
     200 * @size: the allocated buffer size
     201 *
     202 * Releases the buffer allocated via snd_malloc_pages().
     203 */
     204void snd_free_pages(void *ptr, size_t size)
     205{
     206    int pg;
     207    struct page *page, *last_page;
     208
     209    if (ptr == NULL)
     210        return;
     211    pg = get_order(size);
     212    dec_snd_pages(pg);
     213    free_pages((unsigned long) ptr, pg);
     214}
     215
     216/*
     217 *
     218 *  Bus-specific memory allocators
     219 *
     220 */
    124221
    125222/* allocate the coherent DMA pages */
     
    156253        dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
    157254}
     255
     256#ifdef CONFIG_SBUS
     257
     258static void *snd_malloc_sbus_pages(struct device *dev, size_t size,
     259                            dma_addr_t *dma_addr)
     260{
     261        struct sbus_dev *sdev = (struct sbus_dev *)dev;
     262        int pg;
     263        void *res;
     264
     265        snd_assert(size > 0, return NULL);
     266        snd_assert(dma_addr != NULL, return NULL);
     267        pg = get_order(size);
     268        res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr);
     269        if (res != NULL)
     270            inc_snd_pages(pg);
     271        return res;
     272}
     273
     274static void *snd_malloc_sbus_pages_fallback(struct device *dev, size_t size,
     275                                            dma_addr_t *dma_addr, size_t *res_size)
     276{
     277        void *res;
     278
     279        snd_assert(res_size != NULL, return NULL);
     280        do {
     281                if ((res = snd_malloc_sbus_pages(dev, size, dma_addr)) != NULL) {
     282                        *res_size = size;
     283                        return res;
     284                }
     285                size >>= 1;
     286        } while (size >= PAGE_SIZE);
     287        return NULL;
     288}
     289
     290static void snd_free_sbus_pages(struct device *dev, size_t size,
     291                                void *ptr, dma_addr_t dma_addr)
     292{
     293        int pg;
     294
     295        if (ptr == NULL)
     296            return;
     297        pg = get_order(size);
     298        dec_snd_pages(pg);
     299        sbus_free_consistent(sdev, PAGE_SIZE * (1 << pg), ptr, dma_addr);
     300}
     301
     302#endif /* CONFIG_SBUS */
     303
     304/*
     305 *
     306 *  ALSA generic memory management
     307 *
     308 */
    158309
    159310#if ! defined(__arm__)
     
    247398}
    248399
     400
    249401/**
    250402 * snd_dma_free_pages - release the allocated buffer
     
    353505
    354506
    355 /*
    356  *
    357  *  Generic memory allocators
    358  *
    359  */
    360 
    361507/* Pure 2^n version of get_order */
    362508static inline int get_order(unsigned int size)
     
    373519}
    374520
    375 static long snd_allocated_pages; /* holding the number of allocated pages */
    376 
    377 static inline void inc_snd_pages(int order)
    378 {
    379         snd_allocated_pages += 1 << order;
    380 }
    381 
    382 static inline void dec_snd_pages(int order)
    383 {
    384         snd_allocated_pages -= 1 << order;
    385 }
    386 
    387 
    388 /**
    389  * snd_malloc_pages - allocate pages with the given size
    390  * @size: the size to allocate in bytes
    391  * @gfp_flags: the allocation conditions, GFP_XXX
    392  *
    393  * Allocates the physically contiguous pages with the given size.
    394  *
    395  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    396  */
    397 void *snd_malloc_pages(size_t size, unsigned int dma_flags)
    398 {
    399     int pg;
    400     void *res;
    401 
    402     snd_assert(size > 0, return NULL);
    403     snd_assert(dma_flags != 0, return NULL);
    404     pg = get_order(size);
    405     if ((res = (void *) __get_free_pages(dma_flags, pg)) != NULL) {
    406         inc_snd_pages(pg);
    407     }
    408     return res;
    409 }
    410 
    411 /**
    412  * snd_free_pages - release the pages
    413  * @ptr: the buffer pointer to release
    414  * @size: the allocated buffer size
    415  *
    416  * Releases the buffer allocated via snd_malloc_pages().
    417  */
    418 void snd_free_pages(void *ptr, size_t size)
    419 {
    420     int pg;
    421     struct page *page, *last_page;
    422 
    423     if (ptr == NULL)
    424         return;
    425     pg = get_order(size);
    426     dec_snd_pages(pg);
    427     free_pages((unsigned long) ptr, pg);
    428 }
    429 
    430 #if defined(CONFIG_ISA) && ! defined(CONFIG_PCI)
    431 
    432 /**
    433  * snd_malloc_isa_pages - allocate pages for ISA bus with the given size
    434  * @size: the size to allocate in bytes
    435  * @dma_addr: the pointer to store the physical address of the buffer
    436  *
    437  * Allocates the physically contiguous pages with the given size for
    438  * ISA bus.
    439  *
    440  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    441  */
    442 void *snd_malloc_isa_pages(size_t size, dma_addr_t *dma_addr)
    443 {
    444         void *dma_area;
    445         dma_area = snd_malloc_pages(size, GFP_ATOMIC|GFP_DMA);
    446         *dma_addr = dma_area ? isa_virt_to_bus(dma_area) : 0UL;
    447         return dma_area;
    448 }
    449 
    450 /**
    451  * snd_malloc_isa_pages_fallback - allocate pages with the given size with fallback for ISA bus
    452  * @size: the requested size to allocate in bytes
    453  * @dma_addr: the pointer to store the physical address of the buffer
    454  * @res_size: the pointer to store the size of buffer actually allocated
    455  *
    456  * Allocates the physically contiguous pages with the given request
    457  * size for PCI bus.  When no space is left, this function reduces the size and
    458  * tries to allocate again.  The size actually allocated is stored in
    459  * res_size argument.
    460  *
    461  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    462  */
    463 void *snd_malloc_isa_pages_fallback(size_t size,
    464                                     dma_addr_t *dma_addr,
    465                                     size_t *res_size)
    466 {
    467         void *dma_area;
    468         dma_area = snd_malloc_pages_fallback(size, GFP_ATOMIC|GFP_DMA, res_size);
    469         *dma_addr = dma_area ? isa_virt_to_bus(dma_area) : 0UL;
    470         return dma_area;
    471 }
    472 
    473 #endif /* CONFIG_ISA && !CONFIG_PCI */
    474 
    475 #ifdef CONFIG_PCI
    476 
    477 /**
    478  * snd_malloc_pci_pages - allocate pages for PCI bus with the given size
    479  * @pci: the pci device pointer
    480  * @size: the size to allocate in bytes
    481  * @dma_addr: the pointer to store the physical address of the buffer
    482  *
    483  * Allocates the physically contiguous pages with the given size for
    484  * PCI bus.
    485  *
    486  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    487  */
    488 void *snd_malloc_pci_pages(struct pci_dev *pci,
    489                            size_t size,
    490                            dma_addr_t *dmaaddr)
    491 {
    492         int pg;
    493         void *res;
    494 #ifdef DEBUG
    495         dprintf(("snd_malloc_pci_pages. size = %d",size));
    496 #endif
    497         snd_assert(size > 0, return NULL);
    498         snd_assert(dmaaddr != NULL, return NULL);
    499         for (pg = 0; PAGE_SIZE * (1 << pg) < size; pg++);
    500         res = pci_alloc_consistent(pci, PAGE_SIZE * (1 << pg), dmaaddr);
    501         if (res != NULL) {
    502             inc_snd_pages(pg);
    503         }
    504         return res;
    505 }
    506 
    507 /**
    508  * snd_malloc_pci_pages_fallback - allocate pages with the given size with fallback for PCI bus
    509  * @pci: pci device pointer
    510  * @size: the requested size to allocate in bytes
    511  * @dma_addr: the pointer to store the physical address of the buffer
    512  * @res_size: the pointer to store the size of buffer actually allocated
    513  *
    514  * Allocates the physically contiguous pages with the given request
    515  * size for PCI bus.  When no space is left, this function reduces the size and
    516  * tries to allocate again.  The size actually allocated is stored in
    517  * res_size argument.
    518  *
    519  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    520  */
    521 void *snd_malloc_pci_pages_fallback(struct pci_dev *pci, size_t size,
    522                                     dma_addr_t *dmaaddr,
    523                                     size_t *res_size)
    524 {
    525         void *res;
    526 
    527         snd_assert(res_size != NULL, return NULL);
    528         do {
    529                 if ((res = snd_malloc_pci_pages(pci, size, dmaaddr)) != NULL) {
    530                         *res_size = size;
    531                         return res;
    532                 }
    533                 size >>= 1;
    534         } while (size >= PAGE_SIZE);
    535         return NULL;
    536 }
    537 
    538 /**
    539  * snd_free_pci_pages - release the pages
    540  * @pci: pci device pointer
    541  * @size: the allocated buffer size
    542  * @ptr: the buffer pointer to release
    543  * @dma_addr: the physical address of the buffer
    544  *
    545  * Releases the buffer allocated via snd_malloc_pci_pages().
    546  */
    547 void snd_free_pci_pages(struct pci_dev *pci, size_t size, void *ptr, dma_addr_t dmaaddr)
    548 {
    549         int pg;
    550         mem_map_t *page, *last_page;
    551 
    552         if (ptr == NULL)
    553                 return;
    554         for (pg = 0; PAGE_SIZE * (1 << pg) < size; pg++);
    555         dec_snd_pages(pg);
    556         pci_free_consistent(pci, PAGE_SIZE * (1 << pg), ptr, dmaaddr);
    557 }
    558 
    559 #if defined(__i386__)
    560 /*
    561  * on ix86, we allocate a page with GFP_KERNEL to assure the
    562  * allocation.  the code is almost same with kernel/i386/pci-dma.c but
    563  * it allocates only a single page and checks the validity of the
    564  * page address with the given pci dma mask.
    565  */
    566 
    567 /**
    568  * snd_malloc_pci_page - allocate a page in the valid pci dma mask
    569  * @pci: pci device pointer
    570  * @addrp: the pointer to store the physical address of the buffer
    571  *
    572  * Allocates a single page for the given PCI device and returns
    573  * the virtual address and stores the physical address on addrp.
    574  *
    575  * This function cannot be called from interrupt handlers or
    576  * within spinlocks.
    577  */
    578 void *snd_malloc_pci_page(struct pci_dev *pci, dma_addr_t *addrp)
    579 {
    580         void *ptr;
    581         dma_addr_t addr;
    582         unsigned long mask;
    583 
    584         mask = pci ? (unsigned long)pci->consistent_dma_mask : 0x00ffffffUL;
    585         ptr = (void *)__get_free_page(GFP_KERNEL);
    586         if (ptr) {
    587                 addr = virt_to_phys(ptr);
    588                 if (((unsigned long)addr + PAGE_SIZE - 1) & ~mask) {
    589                         /* try to reallocate with the GFP_DMA */
    590                         free_page((unsigned long)ptr);
    591                         /* use GFP_ATOMIC for the DMA zone to avoid stall */
    592                         ptr = (void *)__get_free_page(GFP_ATOMIC | GFP_DMA);
    593                         if (ptr) /* ok, the address must be within lower 16MB... */
    594                                 addr = virt_to_phys(ptr);
    595                         else
    596                                 addr = 0;
    597                 }
    598         } else
    599                 addr = 0;
    600         if (ptr) {
    601                 memset(ptr, 0, PAGE_SIZE);
    602         }
    603         *addrp = addr;
    604         return ptr;
    605 }
    606 #else
    607 
    608 /* on other architectures, call snd_malloc_pci_pages() helper function
    609  * which uses pci_alloc_consistent().
    610  */
    611 void *snd_malloc_pci_page(struct pci_dev *pci, dma_addr_t *addrp)
    612 {
    613         return snd_malloc_pci_pages(pci, PAGE_SIZE, addrp);
    614 }
    615 
    616 #endif
    617 
    618 #endif /* CONFIG_PCI */
    619 
    620 #ifdef CONFIG_SBUS
    621 
    622 /**
    623  * snd_malloc_sbus_pages - allocate pages for SBUS with the given size
    624  * @sdev: sbus device pointer
    625  * @size: the size to allocate in bytes
    626  * @dma_addr: the pointer to store the physical address of the buffer
    627  *
    628  * Allocates the physically contiguous pages with the given size for
    629  * SBUS.
    630  *
    631  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    632  */
    633 void *snd_malloc_sbus_pages(struct sbus_dev *sdev,
    634                             size_t size,
    635                             dma_addr_t *dma_addr)
    636 {
    637         int pg;
    638         void *res;
    639 
    640         snd_assert(size > 0, return NULL);
    641         snd_assert(dma_addr != NULL, return NULL);
    642         pg = get_order(size);
    643         res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr);
    644         if (res != NULL)
    645             inc_snd_pages(pg);
    646         return res;
    647 }
    648 
    649 /**
    650  * snd_malloc_pci_pages_fallback - allocate pages with the given size with fallback for SBUS
    651  * @sdev: sbus device pointer
    652  * @size: the requested size to allocate in bytes
    653  * @dma_addr: the pointer to store the physical address of the buffer
    654  * @res_size: the pointer to store the size of buffer actually allocated
    655  *
    656  * Allocates the physically contiguous pages with the given request
    657  * size for SBUS.  When no space is left, this function reduces the size and
    658  * tries to allocate again.  The size actually allocated is stored in
    659  * res_size argument.
    660  *
    661  * Returns the pointer of the buffer, or NULL if no enoguh memory.
    662  */
    663 /**
    664  * snd_free_sbus_pages - release the pages
    665  * @sdev: sbus device pointer
    666  * @size: the allocated buffer size
    667  * @ptr: the buffer pointer to release
    668  * @dma_addr: the physical address of the buffer
    669  *
    670  * Releases the buffer allocated via snd_malloc_pci_pages().
    671  */
    672 void snd_free_sbus_pages(struct sbus_dev *sdev,
    673                          size_t size,
    674                          void *ptr,
    675                          dma_addr_t dma_addr)
    676 {
    677         int pg;
    678 
    679         if (ptr == NULL)
    680             return;
    681         pg = get_order(size);
    682         dec_snd_pages(pg);
    683         sbus_free_consistent(sdev, PAGE_SIZE * (1 << pg), ptr, dma_addr);
    684 }
    685 
    686 #endif /* CONFIG_SBUS */
     521
    687522
    688523/*
  • GPL/branches/alsa-resync1/alsa-kernel/core/seq/seq_clientmgr.c

    r300 r366  
    567567
    568568/*
    569  * expand a quoted event.
    570  */
    571 static int expand_quoted_event(snd_seq_event_t *event)
    572 {
    573         snd_seq_event_t *quoted;
    574 
    575         quoted = event->data.quote.event;
    576         if (quoted == NULL) {
    577                 snd_printd("seq: quoted event is NULL\n");
    578                 return -EINVAL;
    579         }
    580 
    581         event->type = quoted->type;
    582         event->tag = quoted->tag;
    583         event->source = quoted->source;
    584         /* don't use quoted destination */
    585         event->data = quoted->data;
    586         /* use quoted timestamp only if subscription/port didn't update it */
    587         if (event->queue == SNDRV_SEQ_QUEUE_DIRECT) {
    588                 event->flags = quoted->flags;
    589                 event->queue = quoted->queue;
    590                 event->time = quoted->time;
    591         } else {
    592                 event->flags = (event->flags & SNDRV_SEQ_TIME_STAMP_MASK)
    593                         | (quoted->flags & ~SNDRV_SEQ_TIME_STAMP_MASK);
    594         }
    595         return 0;
    596 }
    597 
    598 /*
    599569 * deliver an event to the specified destination.
    600570 * if filter is non-zero, client filter bitmap is tested.
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/adriver.h

    r348 r366  
    3737#endif
    3838
    39 #ifdef ALSA_BUILD
     39#if defined(ALSA_BUILD) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
    4040#if defined(CONFIG_MODVERSIONS) && !defined(__GENKSYMS__) && !defined(__DEPEND__)
    4141#define MODVERSIONS
     
    4747#undef _set_ver
    4848#endif
    49 #endif /* ALSA_BUILD */
     49#endif /* ALSA_BUILD && KERNEL < 2.6.0 */
    5050
    5151#include <linux/module.h>
  • GPL/branches/alsa-resync1/alsa-kernel/pci/ac97/ac97_pcm.c

    r302 r366  
    213213                snd_ac97_update_bits_nolock(ac97, reg, mask, bits);
    214214                /* update the internal spdif bits */
    215                 sbits = ac97->spdif_status;
    216                 if (sbits & IEC958_AES0_PROFESSIONAL) {
    217                         sbits &= ~IEC958_AES0_PRO_FS;
    218                         switch (rate) {
    219                         case 44100: sbits |= IEC958_AES0_PRO_FS_44100; break;
    220                         case 48000: sbits |= IEC958_AES0_PRO_FS_48000; break;
    221                         case 32000: sbits |= IEC958_AES0_PRO_FS_32000; break;
    222                         }
    223                 } else {
    224                         sbits &= ~(IEC958_AES3_CON_FS << 24);
    225                         switch (rate) {
    226                         case 44100: sbits |= IEC958_AES3_CON_FS_44100<<24; break;
    227                         case 48000: sbits |= IEC958_AES3_CON_FS_48000<<24; break;
    228                         case 32000: sbits |= IEC958_AES3_CON_FS_32000<<24; break;
    229                         }
    230                 }
    231                 ac97->spdif_status = sbits;
    232                 /* update the internal spdif bits */
    233215#ifndef TARGET_OS2
    234216                spin_lock(&ac97->reg_lock);
  • GPL/branches/alsa-resync1/alsa-kernel/pci/cmipci.c

    r300 r366  
    26272627 */
    26282628
    2629 static void snd_cmipci_proc_read(struct snd_info_entry *entry,
     2629#ifdef CONFIG_PROC_FS
     2630static void snd_cmipci_proc_read(struct snd_info_entry *entry,
    26302631                                 struct snd_info_buffer *buffer)
    26312632{
     
    26492650{
    26502651    struct snd_info_entry *entry;
     2652
    26512653    if (! snd_card_proc_new(cm->card, "cmipci", &entry))
    26522654        snd_info_set_text_ops(entry, cm, 1024, snd_cmipci_proc_read);
    26532655}
     2656#else /* !CONFIG_PROC_FS */
     2657static inline void snd_cmipci_proc_init(struct cmipci *cm) {}
     2658#endif
     2659
    26542660
    26552661static struct pci_device_id snd_cmipci_ids[] = {
  • GPL/branches/alsa-resync1/alsa-kernel/pci/intel8x0.c

    r348 r366  
    4242#define SNDRV_GET_ID
    4343#include <sound/initval.h>
     44/* for 440MX workaround */
     45#include <asm/pgtable.h>
     46#include <asm/cacheflush.h>
    4447
    4548#define I810_DEBUG
     
    8285#else
    8386static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
     87static int ac97_quirk[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = AC97_TUNE_DEFAULT};
    8488#endif
    8589#ifdef SUPPORT_JOYSTICK
     
    865869            /* ack */
    866870            iputdword(chip, chip->int_sta_reg, status);
    867             /* FIXME: on some ICH5 board shows the same
    868              *        problem.  So we return IRQ_HANDLED
    869              *        in any cases.
    870              * (or, maybe add a new module param to control this?)
    871              */
    872 #if 0
    873             if (chip->device_type != DEVICE_NFORCE)
    874                 status ^= igetdword(chip, chip->int_sta_reg);
    875 #endif
    876         }
    877         return IRQ_NONE/*RETVAL(status)*/;
     871                        /* some Nforce[2] boards have problems when
     872                           IRQ_NONE is returned here.
     873                        */
     874                        if (chip->device_type != DEVICE_NFORCE)
     875                                status = 0;
     876        }
     877                spin_unlock(&chip->reg_lock);
     878        return IRQ_RETVAL(status);
    878879    }
    879880#ifdef TARGET_OS2
Note: See TracChangeset for help on using the changeset viewer.