Changeset 222 for GPL/branches


Ignore:
Timestamp:
Jul 18, 2007, 5:31:21 AM (18 years ago)
Author:
Brendan Oakley
Message:

Merged to Alsa 0.9.0rc7

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

Legend:

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

    r210 r222  
    3232#include <sound/version.h>
    3333#include <linux/proc_fs.h>
    34 #ifdef CONFIG_DEVFS_FS
     34#ifndef TARGET_OS2
    3535#include <linux/devfs_fs_kernel.h>
    36 #endif
     36#endif /* !TARGET_OS2 */
    3737#include <stdarg.h>
    3838
     
    286286        return -ENODEV;
    287287    }
    288 #ifdef LINUX_2_2
    289     MOD_INC_USE_COUNT;
    290 #endif
    291     if (entry->module && !try_inc_mod_count(entry->module)) {
     288        if (!try_module_get(entry->module)) {
    292289        err = -EFAULT;
    293290        goto __error1;
     
    394391
    395392__error:
    396     dec_mod_count(entry->module);
     393        module_put(entry->module);
    397394__error1:
    398 #ifndef LINUX_2_3
    399     MOD_DEC_USE_COUNT;
    400 #endif
    401395    up(&info_mutex);
    402396    return err;
     
    873867    entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
    874868    if (entry->name == NULL) {
    875         kfree(entry);
     869                snd_magic_kfree(entry);
    876870        return NULL;
    877871    }
     
    10911085                    "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n"
    10921086                "Compiled on " __DATE__ " for kernel %s"
    1093 #ifdef __SMP__
     1087#ifdef CONFIG_SMP
    10941088                " (SMP)"
    10951089#endif
  • GPL/branches/alsa-resync1/alsa-kernel/core/init.c

    r210 r222  
    2222#include <sound/driver.h>
    2323#include <linux/init.h>
     24#include <linux/sched.h>
     25#include <linux/file.h>
    2426#include <linux/slab.h>
    2527#include <linux/time.h>
    2628#include <linux/ctype.h>
     29#ifndef TARGET_OS2 // TODO: implement linux/workqueue.h
     30#include <linux/workqueue.h>
     31#endif /* !TARGET_OS2 */
    2732#include <sound/core.h>
    2833#include <sound/control.h>
  • GPL/branches/alsa-resync1/alsa-kernel/core/isadma.c

    r212 r222  
    3131#include <asm/dma.h>
    3232
    33 /*
     33/**
     34 * snd_dma_program - program an ISA DMA transfer
     35 * @dma: the dma number
     36 * @addr: the physical address of the buffer
     37 * @size: the DMA transfer size
     38 * @mode: the DMA transfer mode, DMA_MODE_XXX
    3439 *
     40 * Programs an ISA DMA transfer for the given buffer.
    3541 */
    3642 
     
    5258}
    5359
     60/**
     61 * snd_dma_disable - stop the ISA DMA transfer
     62 * @dma: the dma number
     63 *
     64 * Stops the ISA DMA transfer.
     65 */
    5466void snd_dma_disable(unsigned long dma)
    5567{
     
    6274}
    6375
     76/**
     77 * snd_dma_residue - return the residue count of the given DMA
     78 * @dma: the dma number
     79 *
     80 * Returns the residue count of the given DMA transfer.
     81 */
    6482unsigned int snd_dma_residue(unsigned long dma)
    6583{
  • GPL/branches/alsa-resync1/alsa-kernel/core/pcm_memory.c

    r210 r222  
    2727#include <sound/info.h>
    2828#include <sound/initval.h>
     29#ifdef CONFIG_PCI
     30#include <sound/pcm_sgbuf.h>
     31#endif
    2932
    3033static int preallocate_dma = 1;
  • GPL/branches/alsa-resync1/alsa-kernel/core/pcm_native.c

    r210 r222  
    2525#include <linux/slab.h>
    2626#include <linux/time.h>
     27#ifndef TARGET_OS2 // TODO: Using OpenWatcom uio.h conflicts with asound.h ?
     28#include <linux/uio.h>
     29#endif /* !TARGET_OS2 */
    2730#include <sound/core.h>
    2831#include <sound/control.h>
  • GPL/branches/alsa-resync1/alsa-kernel/core/pcm_sgbuf.c

    r215 r222  
    2222#include <sound/driver.h>
    2323#include <linux/slab.h>
     24#include <linux/vmalloc.h>
    2425#include <sound/core.h>
    2526#include <sound/pcm.h>
     
    3132#define sgbuf_align_table(tbl)  ((((tbl) + SGBUF_TBL_ALIGN - 1) / SGBUF_TBL_ALIGN) * SGBUF_TBL_ALIGN)
    3233
    33 /*
    34  * shrink to the given pages.
    35  * free the unused pages
    36  */
    37 static void sgbuf_shrink(struct snd_sg_buf *sgbuf, int pages)
    38 {
    39         snd_assert(sgbuf, return);
     34
     35/*
     36 * snd_pcm_sgbuf_new - constructor of the sgbuf instance
     37 * @pci: pci device pointer
     38 *
     39 * Initializes the SG-buffer instance to be assigned to
     40 * substream->dma_private.
     41 *
     42 * Returns the pointer of the instance, or NULL at error.
     43 */
     44struct snd_sg_buf *snd_pcm_sgbuf_new(struct pci_dev *pci)
     45{
     46        struct snd_sg_buf *sgbuf;
     47
     48        sgbuf = snd_magic_kcalloc(snd_pcm_sgbuf_t, 0, GFP_KERNEL);
     49        if (! sgbuf)
     50                return NULL;
     51        sgbuf->pci = pci;
     52        sgbuf->pages = 0;
     53        sgbuf->tblsize = 0;
     54
     55        return sgbuf;
     56}
     57
     58/*
     59 * snd_pcm_sgbuf_delete - destructor of sgbuf instance
     60 * @sgbuf: the SG-buffer instance
     61 *
     62 * Destructor Releaes all pages and free the sgbuf instance.
     63 */
     64void snd_pcm_sgbuf_delete(struct snd_sg_buf *sgbuf)
     65{
     66        snd_pcm_sgbuf_free_pages(sgbuf, NULL);
     67        snd_magic_kfree(sgbuf);
     68}
     69
     70/**
     71 * snd_pcm_sgbuf_alloc_pages - allocate the pages for the SG buffer
     72 * @sgbuf: the sgbuf instance
     73 * @size: the requested buffer size in bytes
     74 *
     75 * Allocates the buffer pages for the given size and updates the
     76 * sg buffer table.  The pages are mapped to the virtually continuous
     77 * memory.
     78 *
     79 * This function is usually called from snd_pcm_lib_malloc_pages().
     80 *
     81 * Returns the mapped virtual address of the buffer if allocation was
     82 * successful, or NULL at error.
     83 */
     84void *snd_pcm_sgbuf_alloc_pages(struct snd_sg_buf *sgbuf, size_t size)
     85{
     86        unsigned int i, pages;
     87        void *vmaddr;
     88
     89        pages = snd_pcm_sgbuf_pages(size);
     90        sgbuf->tblsize = sgbuf_align_table(pages);
     91        sgbuf->table = snd_kcalloc(sizeof(*sgbuf->table) * sgbuf->tblsize, GFP_KERNEL);
    4092        if (! sgbuf->table)
    41                 return;
    42         while (sgbuf->pages > pages) {
     93                goto _failed;
     94        sgbuf->page_table = snd_kcalloc(sizeof(*sgbuf->page_table) * sgbuf->tblsize, GFP_KERNEL);
     95        if (! sgbuf->page_table)
     96                goto _failed;
     97
     98        /* allocate each page */
     99        for (i = 0; i < pages; i++) {
     100                void *ptr;
     101                dma_addr_t addr;
     102                ptr = snd_malloc_pci_page(sgbuf->pci, &addr);
     103                if (! ptr)
     104                        goto _failed;
     105                sgbuf->table[i].buf = ptr;
     106                sgbuf->table[i].addr = addr;
     107                sgbuf->page_table[i] = virt_to_page(ptr);
     108                sgbuf->pages++;
     109        }
     110
     111        sgbuf->size = size;
     112        vmaddr = vmap(sgbuf->page_table, sgbuf->pages);
     113        if (! vmaddr)
     114                goto _failed;
     115        return vmaddr;
     116
     117 _failed:
     118        snd_pcm_sgbuf_free_pages(sgbuf, NULL); /* free the table */
     119        return NULL;
     120}
     121
     122/**
     123 * snd_pcm_sgbuf_free_pages - free the sg buffer
     124 * @sgbuf: the sgbuf instance
     125 * @vmaddr: the mapped virtual address
     126 *
     127 * Releases the pages and the mapped tables.
     128 *
     129 * This function is called usually from snd_pcm_lib_free_pages().
     130 *
     131 * Returns zero if successful, or a negative error code on failure.
     132 */
     133int snd_pcm_sgbuf_free_pages(struct snd_sg_buf *sgbuf, void *vmaddr)
     134{
     135        if (vmaddr)
     136                vunmap(vmaddr);
     137
     138        while (sgbuf->pages > 0) {
    43139                sgbuf->pages--;
    44                 snd_free_pci_pages(sgbuf->pci, PAGE_SIZE,
    45                                    sgbuf->table[sgbuf->pages].buf,
     140                snd_free_pci_page(sgbuf->pci, sgbuf->table[sgbuf->pages].buf,
    46141                                   sgbuf->table[sgbuf->pages].addr);
    47142        }
    48 }
    49 
    50 /*
    51  * initialize the sg buffer
    52  * assigned to substream->dma_private.
    53  * initialize the table with the given size.
    54  */
    55 int snd_pcm_sgbuf_init(snd_pcm_substream_t *substream, struct pci_dev *pci, int tblsize)
    56 {
    57         struct snd_sg_buf *sgbuf;
    58 
    59         tblsize = sgbuf_align_table(tblsize);
    60         sgbuf = snd_magic_kcalloc(snd_pcm_sgbuf_t, 0, GFP_KERNEL);
    61         if (! sgbuf)
    62                 return -ENOMEM;
    63         substream->dma_private = sgbuf;
    64         sgbuf->pci = pci;
    65         sgbuf->pages = 0;
    66         sgbuf->tblsize = tblsize;
    67         sgbuf->table = kmalloc(sizeof(struct snd_sg_page) * tblsize, GFP_KERNEL);
    68         if (! sgbuf->table) {
    69                 snd_pcm_sgbuf_delete(substream);
    70                 return -ENOMEM;
    71         }
    72         memset(sgbuf->table, 0, sizeof(struct snd_sg_page) * tblsize);
    73         return 0;
    74 }
    75 
    76 /*
    77  * release all pages and free the sgbuf instance
    78  */
    79 int snd_pcm_sgbuf_delete(snd_pcm_substream_t *substream)
    80 {
    81         struct snd_sg_buf *sgbuf;
    82 
    83         /* return in case, when sgbuf is not initialized */
    84         if (substream->dma_private == NULL)
    85                 return -EINVAL;
    86         sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return -EINVAL);
    87         sgbuf_shrink(sgbuf, 0);
    88143        if (sgbuf->table)
    89144                kfree(sgbuf->table);
    90         snd_magic_kfree(sgbuf);
    91         substream->dma_private = NULL;
     145        sgbuf->table = NULL;
     146        if (sgbuf->page_table)
     147                kfree(sgbuf->page_table);
     148        sgbuf->page_table = NULL;
     149        sgbuf->tblsize = 0;
     150        sgbuf->pages = 0;
     151        sgbuf->size = 0;
     152       
    92153        return 0;
    93154}
    94155
    95 /*
    96  * allocate sg buffer table with the given byte size.
    97  * if the buffer table already exists, try to resize it.
    98  * call this from hw_params callback.
    99  */
    100 int snd_pcm_sgbuf_alloc(snd_pcm_substream_t *substream, size_t size)
    101 {
    102         struct snd_sg_buf *sgbuf;
    103         unsigned int pages;
    104         unsigned int tblsize;
    105         int changed = 0;
    106 
    107         sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return -EINVAL);
    108         pages = snd_pcm_sgbuf_pages(size);
    109         tblsize = sgbuf_align_table(pages);
    110         if (pages < sgbuf->pages) {
    111                 /* release unsed pages */
    112                 sgbuf_shrink(sgbuf, pages);
    113                 if (substream->runtime)
    114                 substream->runtime->dma_bytes = size;
    115                 return 1; /* changed */
    116         } else if (pages > sgbuf->tblsize) {
    117                 /* bigger than existing one.  reallocate the table. */
    118                 struct snd_sg_page *table;
    119                 table = kmalloc(sizeof(*table) * tblsize, GFP_KERNEL);
    120                 if (! table)
    121                         return -ENOMEM;
    122                 memcpy(table, sgbuf->table, sizeof(*table) * sgbuf->tblsize);
    123                 kfree(sgbuf->table);
    124                 sgbuf->table = table;
    125                 sgbuf->tblsize = tblsize;
    126         }
    127         /* allocate each page */
    128         while (sgbuf->pages < pages) {
    129                 void *ptr;
    130                 dma_addr_t addr;
    131                 ptr = snd_malloc_pci_pages(sgbuf->pci, PAGE_SIZE, &addr);
    132                 if (! ptr)
    133                         return -ENOMEM;
    134                 sgbuf->table[sgbuf->pages].buf = ptr;
    135                 sgbuf->table[sgbuf->pages].addr = addr;
    136                 sgbuf->pages++;
    137                 changed = 1;
    138         }
    139         sgbuf->size = size;
    140         if (substream->runtime)
    141         substream->runtime->dma_bytes = size;
    142         return changed;
    143 }
    144 
    145 /*
    146  * free the sg buffer
    147  * the table is kept.
    148  * call this from hw_free callback.
    149  */
    150 int snd_pcm_sgbuf_free(snd_pcm_substream_t *substream)
    151 {
    152         struct snd_sg_buf *sgbuf;
    153 
    154         sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return -EINVAL);
    155         sgbuf_shrink(sgbuf, 0);
     156/**
     157 * snd_pcm_sgbuf_ops_page - get the page struct at the given offset
     158 * @substream: the pcm substream instance
     159 * @offset: the buffer offset
     160 *
     161 * Returns the page struct at the given buffer offset.
     162 * Used as the page callback of PCM ops.
     163 */
     164struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset)
     165{
     166        struct snd_sg_buf *sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return NULL);
     167
     168        unsigned int idx = offset >> PAGE_SHIFT;
     169        if (idx >= sgbuf->pages)
     170                return NULL;
     171        return sgbuf->page_table[idx];
     172}
     173
     174
     175/**
     176 * snd_pcm_lib_preallocate_sg_pages - initialize SG-buffer for the PCI bus
     177 *
     178 * @pci: pci device
     179 * @substream: substream to assign the buffer
     180 *
     181 * Initializes SG-buffer for the PCI bus.
     182 *
     183 * Returns zero if successful, or a negative error code on failure.
     184 */
     185int snd_pcm_lib_preallocate_sg_pages(struct pci_dev *pci,
     186                                     snd_pcm_substream_t *substream)
     187{
     188        if ((substream->dma_private = snd_pcm_sgbuf_new(pci)) == NULL)
     189                return -ENOMEM;
     190        substream->dma_type = SNDRV_PCM_DMA_TYPE_PCI_SG;
     191        substream->dma_area = 0;
     192        substream->dma_addr = 0;
     193        substream->dma_bytes = 0;
     194        substream->buffer_bytes_max = UINT_MAX;
     195        substream->dma_max = 0;
    156196        return 0;
    157197}
    158 #if 1
    159 /*
    160  * get the page pointer on the given offset
    161  */
    162 static void *sgbuf_get_addr(snd_pcm_substream_t *substream, unsigned long offset)
    163 {
    164         struct snd_sg_buf *sgbuf;
    165         unsigned int idx;
    166 
    167         sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return NULL);
    168         idx = offset >> PAGE_SHIFT;
    169         if (idx >= sgbuf->pages)
    170                 return 0;
    171         return sgbuf->table[idx].buf;
    172 }
    173 
    174 /*
    175  * get the page struct at the given offset
    176  * used as the page callback of pcm ops
    177  */
    178 struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset)
    179 {
    180         void *addr = sgbuf_get_addr(substream, offset);
    181         if (addr)
    182                 return virt_to_page(addr);
    183         else
    184                 return 0;
    185 }
    186 #endif
    187 
    188 /*
    189  * do copy_from_user to the sg buffer
    190  */
    191 static int copy_from_user_sg_buf(snd_pcm_substream_t *substream,
    192                                  char *buf, size_t hwoff, ssize_t bytes)
    193 {
    194         int len;
    195         char *addr;
    196         size_t p = (hwoff >> PAGE_SHIFT) << PAGE_SHIFT;
    197         hwoff -= p;
    198         len = PAGE_SIZE - hwoff;
    199         for (;;) {
    200                 addr = sgbuf_get_addr(substream, p);
    201                 if (! addr)
    202                         return -EFAULT;
    203                 if (len > bytes)
    204                         len = bytes;
    205                 if (copy_from_user(addr + hwoff, buf, len))
    206                         return -EFAULT;
    207                 bytes -= len;
    208                 if (bytes <= 0)
    209                         break;
    210                 buf += len;
    211                 p += PAGE_SIZE;
    212                 len = PAGE_SIZE;
    213                 hwoff = 0;
    214         }
     198
     199/*
     200 * FIXME: the function name is too long for docbook!
     201 *
     202 * snd_pcm_lib_preallocate_sg_pages_for_all - initialize SG-buffer for the PCI bus (all substreams)
     203 * @pci: pci device
     204 * @pcm: pcm to assign the buffer
     205 *
     206 * Initialize the SG-buffer to all substreams of the given pcm for the
     207 * PCI bus.
     208 *
     209 * Returns zero if successful, or a negative error code on failure.
     210 */
     211int snd_pcm_lib_preallocate_sg_pages_for_all(struct pci_dev *pci,
     212                                             snd_pcm_t *pcm)
     213{
     214        snd_pcm_substream_t *substream;
     215        int stream, err;
     216
     217        for (stream = 0; stream < 2; stream++)
     218                for (substream = pcm->streams[stream].substream; substream; substream = substream->next)
     219                        if ((err = snd_pcm_lib_preallocate_sg_pages(pci, substream)) < 0)
     220                                return err;
    215221        return 0;
    216222}
    217223
    218 /*
    219  * do copy_to_user from the sg buffer
    220  */
    221 static int copy_to_user_sg_buf(snd_pcm_substream_t *substream,
    222                                char *buf, size_t hwoff, ssize_t bytes)
    223 {
    224         int len;
    225         char *addr;
    226         size_t p = (hwoff >> PAGE_SHIFT) << PAGE_SHIFT;
    227         hwoff -= p;
    228         len = PAGE_SIZE - hwoff;
    229         for (;;) {
    230                 addr = sgbuf_get_addr(substream, p);
    231                 if (! addr)
    232                         return -EFAULT;
    233                 if (len > bytes)
    234                         len = bytes;
    235                 if (copy_to_user(buf, addr + hwoff, len))
    236                         return -EFAULT;
    237                 bytes -= len;
    238                 if (bytes <= 0)
    239                         break;
    240                 buf += len;
    241                 p += PAGE_SIZE;
    242                 len = PAGE_SIZE;
    243                 hwoff = 0;
    244         }
    245         return 0;
    246 }
    247 
    248 /*
    249  * set silence on the sg buffer
    250  */
    251 static int set_silence_sg_buf(snd_pcm_substream_t *substream,
    252                               size_t hwoff, ssize_t samples)
    253 {
    254         snd_pcm_runtime_t *runtime = substream->runtime;
    255         int len, page_len;
    256         char *addr;
    257         size_t p = (hwoff >> PAGE_SHIFT) << PAGE_SHIFT;
    258         hwoff -= p;
    259         len = bytes_to_samples(substream->runtime, PAGE_SIZE - hwoff);
    260         page_len = bytes_to_samples(substream->runtime, PAGE_SIZE);
    261         for (;;) {
    262                 addr = sgbuf_get_addr(substream, p);
    263                 if (! addr)
    264                         return -EFAULT;
    265                 if (len > samples)
    266                         len = samples;
    267                 snd_pcm_format_set_silence(runtime->format, addr + hwoff, len);
    268                 samples -= len;
    269                 if (samples <= 0)
    270                         break;
    271                 p += PAGE_SIZE;
    272                 len = page_len;
    273                 hwoff = 0;
    274         }
    275         return 0;
    276 }
    277 
    278 /*
    279  * copy callback for playback pcm ops
    280  */
    281 int snd_pcm_sgbuf_ops_copy_playback(snd_pcm_substream_t *substream, int channel,
    282                                     snd_pcm_uframes_t hwoff, void *buf, snd_pcm_uframes_t count)
    283 {
    284         snd_pcm_runtime_t *runtime = substream->runtime;
    285         if (channel < 0) {
    286                 return copy_from_user_sg_buf(substream, buf, frames_to_bytes(runtime, hwoff), frames_to_bytes(runtime, count));
    287         } else {
    288                 size_t dma_csize = runtime->dma_bytes / runtime->channels;
    289                 size_t c_ofs = (channel * dma_csize) + samples_to_bytes(runtime, hwoff);
    290                 return copy_from_user_sg_buf(substream, buf, c_ofs, samples_to_bytes(runtime, count));
    291         }
    292 }
    293 
    294 /*
    295  * copy callback for capture pcm ops
    296  */
    297 int snd_pcm_sgbuf_ops_copy_capture(snd_pcm_substream_t *substream, int channel,
    298                                    snd_pcm_uframes_t hwoff, void *buf, snd_pcm_uframes_t count)
    299 {
    300         snd_pcm_runtime_t *runtime = substream->runtime;
    301         if (channel < 0) {
    302                 return copy_to_user_sg_buf(substream, buf, frames_to_bytes(runtime, hwoff), frames_to_bytes(runtime, count));
    303         } else {
    304                 size_t dma_csize = runtime->dma_bytes / runtime->channels;
    305                 size_t c_ofs = (channel * dma_csize) + samples_to_bytes(runtime, hwoff);
    306                 return copy_to_user_sg_buf(substream, buf, c_ofs, samples_to_bytes(runtime, count));
    307         }
    308 }
    309 
    310 /*
    311  * silence callback for pcm ops
    312  */
    313 int snd_pcm_sgbuf_ops_silence(snd_pcm_substream_t *substream, int channel,
    314                               snd_pcm_uframes_t hwoff, snd_pcm_uframes_t count)
    315 {
    316         snd_pcm_runtime_t *runtime = substream->runtime;
    317         if (channel < 0) {
    318                 return set_silence_sg_buf(substream, frames_to_bytes(runtime, hwoff),
    319                                           frames_to_bytes(runtime, count));
    320         } else {
    321                 size_t dma_csize = runtime->dma_bytes / runtime->channels;
    322                 size_t c_ofs = (channel * dma_csize) + samples_to_bytes(runtime, hwoff);
    323                 return set_silence_sg_buf(substream, c_ofs, samples_to_bytes(runtime, count));
    324         }
    325 }
    326 
    327224
    328225/*
    329226 *  Exported symbols
    330227 */
    331 EXPORT_SYMBOL(snd_pcm_sgbuf_init);
    332 EXPORT_SYMBOL(snd_pcm_sgbuf_delete);
    333 EXPORT_SYMBOL(snd_pcm_sgbuf_alloc);
    334 EXPORT_SYMBOL(snd_pcm_sgbuf_free);
    335 EXPORT_SYMBOL(snd_pcm_sgbuf_ops_copy_playback);
    336 EXPORT_SYMBOL(snd_pcm_sgbuf_ops_copy_capture);
    337 EXPORT_SYMBOL(snd_pcm_sgbuf_ops_silence);
     228EXPORT_SYMBOL(snd_pcm_lib_preallocate_sg_pages);
     229EXPORT_SYMBOL(snd_pcm_lib_preallocate_sg_pages_for_all);
    338230EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page);
  • GPL/branches/alsa-resync1/alsa-kernel/core/rtctimer.c

    r210 r222  
    8080                return err;
    8181        t->private_data = &rtc_task;
    82         MOD_INC_USE_COUNT;
    8382        return 0;
    8483}
     
    9291                t->private_data = NULL;
    9392        }
    94         MOD_DEC_USE_COUNT;
    9593        return 0;
    9694}
  • GPL/branches/alsa-resync1/alsa-kernel/core/sound.c

    r210 r222  
    3131#include <sound/initval.h>
    3232#include <linux/kmod.h>
    33 #ifdef CONFIG_DEVFS_FS
     33#ifndef TARGET_OS2
    3434#include <linux/devfs_fs_kernel.h>
    35 #endif
     35#endif /* !TARGET_OS2 */
    3636
    3737#define SNDRV_OS_MINORS 256
     
    407407static void __exit alsa_sound_exit(void)
    408408{
    409 #ifdef CONFIG_DEVFS_FS
     409#ifndef TARGET_OS2
    410410    short controlnum;
    411411
     
    414414        class_simple_device_remove(MKDEV(major, controlnum<<5));
    415415    }
    416 #endif
     416#endif /* !TARGET_OS2 */
    417417
    418418#ifdef CONFIG_SND_OSSEMUL
  • GPL/branches/alsa-resync1/alsa-kernel/core/timer.c

    r210 r222  
    8686
    8787static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left);
    88 
    89 #ifndef TARGET_OS2
    90 static inline void dec_mod_count(struct module *module)
    91 {
    92         if (module)
    93                 __MOD_DEC_USE_COUNT(module);
    94 }
    95 #else /* TARGET_OS2 */
    96 #define dec_mod_count(a)        (*(unsigned long *)a)--
    97 #endif /* TARGET_OS2 */
    9888
    9989/*
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/ad1848.h

    r210 r222  
    2323 */
    2424
    25 #include "control.h"
    2625#include "pcm.h"
    2726
     
    164163
    165164int snd_ad1848_pcm(ad1848_t * chip, int device, snd_pcm_t **rpcm);
     165const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction);
    166166int snd_ad1848_mixer(ad1848_t * chip);
    167167void snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs);
    168168
     169/* exported mixer stuffs */
     170enum { AD1848_MIX_SINGLE, AD1848_MIX_DOUBLE, AD1848_MIX_CAPTURE };
     171
     172#define AD1848_MIXVAL_SINGLE(reg, shift, mask, invert) \
     173        ((reg) | ((shift) << 8) | ((mask) << 16) | ((invert) << 24))
     174#define AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert) \
     175        ((left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22))
     176
     177int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value);
     178
     179/* for ease of use */
     180struct ad1848_mix_elem {
     181        const char *name;
     182        int index;
     183        int type;
     184        unsigned long private_value;
     185};
     186
    169187#define AD1848_SINGLE(xname, xindex, reg, shift, mask, invert) \
    170 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
    171   .info = snd_ad1848_info_single, \
    172   .get = snd_ad1848_get_single, .put = snd_ad1848_put_single, \
    173   .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
    174 
    175 int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo);
    176 int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
    177 int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
     188{ .name = xname, \
     189  .index = xindex, \
     190  .type = AD1848_MIX_SINGLE, \
     191  .private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert) }
    178192
    179193#define AD1848_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
    180 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
    181   .info = snd_ad1848_info_double, \
    182   .get = snd_ad1848_get_double, .put = snd_ad1848_put_double, \
    183   .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
    184 
    185 int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo);
    186 int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
    187 int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol);
     194{ .name = xname, \
     195  .index = xindex, \
     196  .type = AD1848_MIX_DOUBLE, \
     197  .private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert) }
     198
     199static inline int snd_ad1848_add_ctl_elem(ad1848_t *chip, const struct ad1848_mix_elem *c)
     200{
     201        return snd_ad1848_add_ctl(chip, c->name, c->index, c->type, c->private_value);
     202}
    188203
    189204#ifdef CONFIG_SND_DEBUG
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/core.h

    r215 r222  
    2525#include <linux/sched.h>                /* wake_up() */
    2626#include <asm/semaphore.h>
     27#ifndef TARGET_OS2 //TODO: implement linux/rwsem.h
     28#include <linux/rwsem.h>                /* struct rw_semaphore */
     29#endif /* !TARGET_OS2 */
    2730#include <sound/typedefs.h>
    2831
     
    193196#endif
    194197#else
    195 #define snd_power_lock(card) do { ; } while (0)
    196 #define snd_power_unlock(card) do { ; } while (0)
    197 #define snd_power_wait(card) do { ; } while (0)
     198#define snd_power_lock(card)            do { (void)(card); } while (0)
     199#define snd_power_unlock(card)          do { (void)(card); } while (0)
     200#define snd_power_wait(card)            do { (void)(card); } while (0)
    198201#define snd_power_get_state(card) SNDRV_CTL_POWER_D0
    199 #define snd_power_change_state(card, state) do { ; } while (0)
     202#define snd_power_change_state(card, state)     do { (void)(card); } while (0)
    200203#define snd_card_set_pm_callback(card,suspend,resume,data) -EINVAL
    201204#define snd_card_set_isa_pm_callback(card,suspend,resume,data) -EINVAL
     
    286289
    287290extern int snd_cards_count;
     291extern unsigned int snd_cards_lock;
    288292extern struct snd_card *snd_cards[SNDRV_CARDS];
    289293extern rwlock_t snd_card_rwlock;
     
    296300int snd_card_disconnect(struct snd_card *card);
    297301int snd_card_free(struct snd_card *card);
     302int snd_card_free_in_thread(snd_card_t *card);
    298303int snd_card_register(struct snd_card *card);
    299304int snd_card_info_init(void);
     
    309314int snd_device_register(struct snd_card *card, void *device_data);
    310315int snd_device_register_all(struct snd_card *card);
     316int snd_device_disconnect(snd_card_t *card, void *device_data);
    311317int snd_device_disconnect_all(struct snd_card *card);
    312318int snd_device_free(struct snd_card *card, void *device_data);
     
    329335#if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK)
    330336void snd_verbose_printd(const char *file, int line, const char *format, ...);
    331 #endif
    332 #if defined(CONFIG_SND_DEBUG) && !defined(CONFIG_SND_VERBOSE_PRINTK)
    333 void snd_printd(const char *format, ...);
    334337#endif
    335338
     
    373376
    374377#ifdef CONFIG_SND_VERBOSE_PRINTK
     378/**
     379 * snd_printk - printk wrapper
     380 * @fmt: format string
     381 *
     382 * Works like print() but prints the file and the line of the caller
     383 * when configured with CONFIG_SND_VERBOSE_PRINTK.
     384 */
    375385#define snd_printk(fmt, args...) \
    376386        snd_verbose_printk(__FILE__, __LINE__, fmt ,##args)
     
    385395
    386396#ifdef CONFIG_SND_VERBOSE_PRINTK
     397/**
     398 * snd_printd - debug printk
     399 * @format: format string
     400 *
     401 * Compiled only when Works like snd_printk() for debugging purpose.
     402 * Ignored when CONFIG_SND_DEBUG is not set.
     403 */
    387404#define snd_printd(fmt, args...) \
    388405        snd_verbose_printd(__FILE__, __LINE__, fmt ,##args)
    389 #endif
     406#else
     407#define snd_printd(fmt, args...) \
     408        printk(fmt ,##args)
     409#endif
     410/**
     411 * snd_assert - run-time assersion macro
     412 * @expr: expression
     413 * @args...: the action
     414 *
     415 * This macro checks the expression in run-time and invokes the commands
     416 * given in the rest arguments if the assertion is failed.
     417 * When CONFIG_SND_DEBUG is not set, the expression is executed but
     418 * not checked.
     419 */
    390420#define snd_assert(expr, args...) do {\
    391421        if (!(expr)) {\
     
    394424        }\
    395425} while (0)
     426/**
     427 * snd_runtime_check - run-time assersion macro
     428 * @expr: expression
     429 * @args...: the action
     430 *
     431 * This macro checks the expression in run-time and invokes the commands
     432 * given in the rest arguments if the assertion is failed.
     433 * Unlike snd_assert(), the action commands are executed even if
     434 * CONFIG_SND_DEBUG is not set but without any error messages.
     435 */
    396436#define snd_runtime_check(expr, args...) do {\
    397437        if (!(expr)) {\
     
    410450
    411451#ifdef CONFIG_SND_DEBUG_DETECT
     452/**
     453 * snd_printdd - debug printk
     454 * @format: format string
     455 *
     456 * Compiled only when Works like snd_printk() for debugging purpose.
     457 * Ignored when CONFIG_SND_DEBUG_DETECT is not set.
     458 */
    412459#define snd_printdd(format, args...) snd_printk(format, ##args)
    413460#else
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/gus.h

    r96 r222  
    211211        snd_gf1_mem_block_t *first;
    212212        snd_gf1_mem_block_t *last;
    213         snd_info_entry_t *info_entry;
    214213        struct semaphore memory_mutex;
    215214} snd_gf1_mem_t;
     
    333332
    334333        snd_gf1_mem_t mem_alloc;
    335         snd_info_entry_t *ram_entries[4];
    336         snd_info_entry_t *rom_entries[4];
    337334
    338335        /* registers */
     
    453450
    454451        struct _snd_gf1 gf1;    /* gf1 specific variables */
    455 #ifdef CONFIG_SND_DEBUG
    456         snd_info_entry_t *irq_entry;
    457 #endif
    458452        snd_pcm_t *pcm;
    459453        snd_pcm_substream_t *pcm_cap_substream;
     
    602596
    603597int snd_gf1_mem_proc_init(snd_gus_card_t * gus);
    604 int snd_gf1_mem_proc_done(snd_gus_card_t * gus);
    605598
    606599/* gus_dma.c */
     
    677670#ifdef CONFIG_SND_DEBUG
    678671void snd_gus_irq_profile_init(snd_gus_card_t *gus);
    679 void snd_gus_irq_profile_done(snd_gus_card_t *gus);
    680672#endif
    681673
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/initval.h

    r210 r222  
    132132#endif
    133133
    134 #ifdef SNDRV_LEGACY_FIND_FREE_IOPORT
    135 static long snd_legacy_find_free_ioport(long *port_table, long size)
    136 {
    137         while (*port_table != -1) {
    138                 if (!check_region(*port_table, size))
    139                         return *port_table;
    140                 port_table++;
    141         }
    142         return -1;
    143 }
    144 #endif
     134#ifdef SNDRV_LEGACY_FIND_FREE_IRQ
     135#include <linux/interrupt.h>
    145136
    146 #ifdef SNDRV_LEGACY_FIND_FREE_IRQ
    147137static void snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
    148138{
     
    188178        for (s = *str; isalpha(*s) || isdigit(*s) || *s == '_'; s++);
    189179        if (s != *str) {
    190                 *dst = (char *)kmalloc(s - *str, GFP_KERNEL);
    191                 if ((d = *dst) != NULL) {
    192                         s = *str;
    193                         while (isalpha(*s) || isdigit(*s) || *s == '_')
    194                                 *d++ = *s++;
     180                *dst = (char *)kmalloc((s - *str) + 1, GFP_KERNEL);
     181                s = *str; d = *dst;
     182                while (isalpha(*s) || isdigit(*s) || *s == '_') {
     183                        if (d != NULL)
     184                                *d++ = *s;
     185                        s++;
    195186                }
     187                if (d != NULL)
     188                        *d = '\0';
    196189        }
    197190        *str = s;
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/memalloc.h

    r32 r222  
    4545    int type;                       /* SNDRV_DMA_TYPE_XXX */
    4646    struct device *dev;
     47    unsigned int id;            /* a unique ID */
    4748};
    4849
     
    6162#define SNDRV_DMA_TYPE_DEV              2       /* generic device continuous */
    6263#define SNDRV_DMA_TYPE_DEV_SG           3       /* generic device SG-buffer */
     64#ifdef TARGET_OS2 // Provide old types until 1.0.4
     65#define SNDRV_DMA_TYPE_ISA              2       /* ISA continuous */
     66#define SNDRV_DMA_TYPE_PCI              3       /* PCI continuous */
     67#endif /* TARGET_OS2 */
    6368#define SNDRV_DMA_TYPE_SBUS             4       /* SBUS continuous */
    6469#define SNDRV_DMA_TYPE_PCI_SG           5       /* PCI SG-buffer */
     70
     71#ifdef CONFIG_PCI
     72#if 0
     73/*
     74 * compose a snd_dma_device struct for the PCI device
     75 */
     76static inline void snd_dma_device_pci(struct snd_dma_device *dev, struct pci_dev *pci, unsigned int id)
     77{
     78        memset(dev, 0, sizeof(*dev));
     79        dev->type = SNDRV_DMA_TYPE_PCI;
     80        dev->dev.pci = pci;
     81        dev->id = id;
     82}
     83#endif
     84#endif
    6585
    6686#define __GFP_NOWARN    0
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/mixer_oss.h

    r212 r222  
    6262        struct semaphore reg_mutex;
    6363        snd_info_entry_t *proc_entry;
     64        int oss_dev_alloc;
    6465        /* --- */
    6566        int oss_recsrc;
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/pcm_oss.h

    r96 r222  
    7878typedef struct _snd_pcm_oss {
    7979        int reg;
     80        unsigned int reg_mask;
    8081} snd_pcm_oss_t;
    8182
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/pcm_sgbuf.h

    r215 r222  
    1 #ifndef __SOUND_PCM_SGBUF_H
     1#if ! defined __SOUND_PCM_SGBUF_H && ! defined __SOUND_MEMALLOC_H
    22#define __SOUND_PCM_SGBUF_H
    33
     
    2222 *
    2323 */
    24 /*
    25  * buffer device info
    26  */
    27 struct snd_dma_device {
    28         int type;                       /* SNDRV_MEM_TYPE_XXX */
    29         union {
    30                 struct pci_dev *pci;    /* for PCI and PCI-SG types */
    31                 unsigned int flags;     /* GFP_XXX for continous and ISA types */
    32 #ifdef CONFIG_SBUS
    33                 struct sbus_dev *sbus;  /* for SBUS type */
    34 #endif
    35         } dev;
    36         unsigned int id;                /* a unique ID */
    37 };
    38 
    39 /*
    40  * buffer types
    41  */
    42 #define SNDRV_DMA_TYPE_UNKNOWN          0       /* not defined */
    43 #define SNDRV_DMA_TYPE_CONTINUOUS       1       /* continuous no-DMA memory */
    44 #define SNDRV_DMA_TYPE_ISA              2       /* ISA continuous */
    45 #define SNDRV_DMA_TYPE_PCI              3       /* PCI continuous */
    46 #define SNDRV_DMA_TYPE_SBUS             4       /* SBUS continuous */
    47 #define SNDRV_DMA_TYPE_PCI_SG           5       /* PCI SG-buffer */
    48 
    49 #ifdef CONFIG_PCI
    50 /*
    51  * compose a snd_dma_device struct for the PCI device
    52  */
    53 static inline void snd_dma_device_pci(struct snd_dma_device *dev, struct pci_dev *pci, unsigned int id)
    54 {
    55         memset(dev, 0, sizeof(*dev));
    56         dev->type = SNDRV_DMA_TYPE_PCI;
    57         dev->dev.pci = pci;
    58         dev->id = id;
    59 }
    60 #endif
    61 
    62 
    63 /*
    64  * info for buffer allocation
    65  */
    66 struct snd_dma_buffer {
    67         unsigned char *area;    /* virtual pointer */
    68         dma_addr_t addr;        /* physical address */
    69         size_t bytes;           /* buffer size in bytes */
    70         void *private_data;     /* private for allocator; don't touch */
    71 };
    7224
    7325struct snd_sg_page {
     
    8133        int tblsize;    /* allocated table size */
    8234        struct snd_sg_page *table;
     35        struct page **page_table;
    8336        struct pci_dev *pci;
    8437};
     
    10255}
    10356
    104 int snd_pcm_sgbuf_init(snd_pcm_substream_t *substream, struct pci_dev *pci, int tblsize);
    105 int snd_pcm_sgbuf_delete(snd_pcm_substream_t *substream);
    106 int snd_pcm_sgbuf_alloc(snd_pcm_substream_t *substream, size_t size);
    107 int snd_pcm_sgbuf_free(snd_pcm_substream_t *substream);
     57struct snd_sg_buf *snd_pcm_sgbuf_init(struct pci_dev *pci);
     58void snd_pcm_sgbuf_delete(struct snd_sg_buf *sgbuf);
     59void *snd_pcm_sgbuf_alloc_pages(struct snd_sg_buf *sgbuf, size_t size);
     60int snd_pcm_sgbuf_free_pages(struct snd_sg_buf *sgbuf, void *vmaddr);
    10861
    109 int snd_pcm_sgbuf_ops_copy_playback(snd_pcm_substream_t *substream, int channel, snd_pcm_uframes_t hwoff, void *buf, snd_pcm_uframes_t count);
    110 int snd_pcm_sgbuf_ops_copy_capture(snd_pcm_substream_t *substream, int channel, snd_pcm_uframes_t hwoff, void *buf, snd_pcm_uframes_t count);
    111 int snd_pcm_sgbuf_ops_silence(snd_pcm_substream_t *substream, int channel, snd_pcm_uframes_t hwoff, snd_pcm_uframes_t count);
     62int snd_pcm_lib_preallocate_sg_pages(struct pci_dev *pci, snd_pcm_substream_t *substream);
     63int snd_pcm_lib_preallocate_sg_pages_for_all(struct pci_dev *pci, snd_pcm_t *pcm);
     64
     65#define _snd_pcm_substream_sgbuf(substream) ((substream)->dma_private)
     66#define snd_pcm_substream_sgbuf(substream) snd_magic_cast(snd_pcm_sgbuf_t, _snd_pcm_substream_sgbuf(substream), return -ENXIO)
     67
    11268struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset);
    11369
    114 
    11570#endif /* __SOUND_PCM_SGBUF_H */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/sb16_csp.h

    r96 r222  
    160160
    161161        struct semaphore access_mutex;  /* locking */
    162         snd_info_entry_t *proc; /* proc interface */
    163162};
    164163
Note: See TracChangeset for help on using the changeset viewer.