Changeset 222 for GPL/branches
- Timestamp:
- Jul 18, 2007, 5:31:21 AM (18 years ago)
- 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 32 32 #include <sound/version.h> 33 33 #include <linux/proc_fs.h> 34 #if def CONFIG_DEVFS_FS34 #ifndef TARGET_OS2 35 35 #include <linux/devfs_fs_kernel.h> 36 #endif 36 #endif /* !TARGET_OS2 */ 37 37 #include <stdarg.h> 38 38 … … 286 286 return -ENODEV; 287 287 } 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)) { 292 289 err = -EFAULT; 293 290 goto __error1; … … 394 391 395 392 __error: 396 dec_mod_count(entry->module);393 module_put(entry->module); 397 394 __error1: 398 #ifndef LINUX_2_3399 MOD_DEC_USE_COUNT;400 #endif401 395 up(&info_mutex); 402 396 return err; … … 873 867 entry->name = snd_kmalloc_strdup(name, GFP_KERNEL); 874 868 if (entry->name == NULL) { 875 869 snd_magic_kfree(entry); 876 870 return NULL; 877 871 } … … 1091 1085 "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n" 1092 1086 "Compiled on " __DATE__ " for kernel %s" 1093 #ifdef __SMP__1087 #ifdef CONFIG_SMP 1094 1088 " (SMP)" 1095 1089 #endif -
GPL/branches/alsa-resync1/alsa-kernel/core/init.c
r210 r222 22 22 #include <sound/driver.h> 23 23 #include <linux/init.h> 24 #include <linux/sched.h> 25 #include <linux/file.h> 24 26 #include <linux/slab.h> 25 27 #include <linux/time.h> 26 28 #include <linux/ctype.h> 29 #ifndef TARGET_OS2 // TODO: implement linux/workqueue.h 30 #include <linux/workqueue.h> 31 #endif /* !TARGET_OS2 */ 27 32 #include <sound/core.h> 28 33 #include <sound/control.h> -
GPL/branches/alsa-resync1/alsa-kernel/core/isadma.c
r212 r222 31 31 #include <asm/dma.h> 32 32 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 34 39 * 40 * Programs an ISA DMA transfer for the given buffer. 35 41 */ 36 42 … … 52 58 } 53 59 60 /** 61 * snd_dma_disable - stop the ISA DMA transfer 62 * @dma: the dma number 63 * 64 * Stops the ISA DMA transfer. 65 */ 54 66 void snd_dma_disable(unsigned long dma) 55 67 { … … 62 74 } 63 75 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 */ 64 82 unsigned int snd_dma_residue(unsigned long dma) 65 83 { -
GPL/branches/alsa-resync1/alsa-kernel/core/pcm_memory.c
r210 r222 27 27 #include <sound/info.h> 28 28 #include <sound/initval.h> 29 #ifdef CONFIG_PCI 30 #include <sound/pcm_sgbuf.h> 31 #endif 29 32 30 33 static int preallocate_dma = 1; -
GPL/branches/alsa-resync1/alsa-kernel/core/pcm_native.c
r210 r222 25 25 #include <linux/slab.h> 26 26 #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 */ 27 30 #include <sound/core.h> 28 31 #include <sound/control.h> -
GPL/branches/alsa-resync1/alsa-kernel/core/pcm_sgbuf.c
r215 r222 22 22 #include <sound/driver.h> 23 23 #include <linux/slab.h> 24 #include <linux/vmalloc.h> 24 25 #include <sound/core.h> 25 26 #include <sound/pcm.h> … … 31 32 #define sgbuf_align_table(tbl) ((((tbl) + SGBUF_TBL_ALIGN - 1) / SGBUF_TBL_ALIGN) * SGBUF_TBL_ALIGN) 32 33 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 */ 44 struct 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 */ 64 void 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 */ 84 void *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); 40 92 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 */ 133 int 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) { 43 139 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, 46 141 sgbuf->table[sgbuf->pages].addr); 47 142 } 48 }49 50 /*51 * initialize the sg buffer52 * 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 instance78 */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);88 143 if (sgbuf->table) 89 144 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 92 153 return 0; 93 154 } 94 155 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 */ 164 struct 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 */ 185 int 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; 156 196 return 0; 157 197 } 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 */ 211 int 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; 215 221 return 0; 216 222 } 217 223 218 /*219 * do copy_to_user from the sg buffer220 */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 buffer250 */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 ops280 */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 ops296 */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 ops312 */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 327 224 328 225 /* 329 226 * Exported symbols 330 227 */ 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); 228 EXPORT_SYMBOL(snd_pcm_lib_preallocate_sg_pages); 229 EXPORT_SYMBOL(snd_pcm_lib_preallocate_sg_pages_for_all); 338 230 EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); -
GPL/branches/alsa-resync1/alsa-kernel/core/rtctimer.c
r210 r222 80 80 return err; 81 81 t->private_data = &rtc_task; 82 MOD_INC_USE_COUNT;83 82 return 0; 84 83 } … … 92 91 t->private_data = NULL; 93 92 } 94 MOD_DEC_USE_COUNT;95 93 return 0; 96 94 } -
GPL/branches/alsa-resync1/alsa-kernel/core/sound.c
r210 r222 31 31 #include <sound/initval.h> 32 32 #include <linux/kmod.h> 33 #if def CONFIG_DEVFS_FS33 #ifndef TARGET_OS2 34 34 #include <linux/devfs_fs_kernel.h> 35 #endif 35 #endif /* !TARGET_OS2 */ 36 36 37 37 #define SNDRV_OS_MINORS 256 … … 407 407 static void __exit alsa_sound_exit(void) 408 408 { 409 #if def CONFIG_DEVFS_FS409 #ifndef TARGET_OS2 410 410 short controlnum; 411 411 … … 414 414 class_simple_device_remove(MKDEV(major, controlnum<<5)); 415 415 } 416 #endif 416 #endif /* !TARGET_OS2 */ 417 417 418 418 #ifdef CONFIG_SND_OSSEMUL -
GPL/branches/alsa-resync1/alsa-kernel/core/timer.c
r210 r222 86 86 87 87 static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left); 88 89 #ifndef TARGET_OS290 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 */98 88 99 89 /* -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/ad1848.h
r210 r222 23 23 */ 24 24 25 #include "control.h"26 25 #include "pcm.h" 27 26 … … 164 163 165 164 int snd_ad1848_pcm(ad1848_t * chip, int device, snd_pcm_t **rpcm); 165 const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction); 166 166 int snd_ad1848_mixer(ad1848_t * chip); 167 167 void snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs); 168 168 169 /* exported mixer stuffs */ 170 enum { 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 177 int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value); 178 179 /* for ease of use */ 180 struct ad1848_mix_elem { 181 const char *name; 182 int index; 183 int type; 184 unsigned long private_value; 185 }; 186 169 187 #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) } 178 192 179 193 #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 199 static 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 } 188 203 189 204 #ifdef CONFIG_SND_DEBUG -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/core.h
r215 r222 25 25 #include <linux/sched.h> /* wake_up() */ 26 26 #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 */ 27 30 #include <sound/typedefs.h> 28 31 … … 193 196 #endif 194 197 #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) 198 201 #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) 200 203 #define snd_card_set_pm_callback(card,suspend,resume,data) -EINVAL 201 204 #define snd_card_set_isa_pm_callback(card,suspend,resume,data) -EINVAL … … 286 289 287 290 extern int snd_cards_count; 291 extern unsigned int snd_cards_lock; 288 292 extern struct snd_card *snd_cards[SNDRV_CARDS]; 289 293 extern rwlock_t snd_card_rwlock; … … 296 300 int snd_card_disconnect(struct snd_card *card); 297 301 int snd_card_free(struct snd_card *card); 302 int snd_card_free_in_thread(snd_card_t *card); 298 303 int snd_card_register(struct snd_card *card); 299 304 int snd_card_info_init(void); … … 309 314 int snd_device_register(struct snd_card *card, void *device_data); 310 315 int snd_device_register_all(struct snd_card *card); 316 int snd_device_disconnect(snd_card_t *card, void *device_data); 311 317 int snd_device_disconnect_all(struct snd_card *card); 312 318 int snd_device_free(struct snd_card *card, void *device_data); … … 329 335 #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) 330 336 void snd_verbose_printd(const char *file, int line, const char *format, ...); 331 #endif332 #if defined(CONFIG_SND_DEBUG) && !defined(CONFIG_SND_VERBOSE_PRINTK)333 void snd_printd(const char *format, ...);334 337 #endif 335 338 … … 373 376 374 377 #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 */ 375 385 #define snd_printk(fmt, args...) \ 376 386 snd_verbose_printk(__FILE__, __LINE__, fmt ,##args) … … 385 395 386 396 #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 */ 387 404 #define snd_printd(fmt, args...) \ 388 405 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 */ 390 420 #define snd_assert(expr, args...) do {\ 391 421 if (!(expr)) {\ … … 394 424 }\ 395 425 } 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 */ 396 436 #define snd_runtime_check(expr, args...) do {\ 397 437 if (!(expr)) {\ … … 410 450 411 451 #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 */ 412 459 #define snd_printdd(format, args...) snd_printk(format, ##args) 413 460 #else -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/gus.h
r96 r222 211 211 snd_gf1_mem_block_t *first; 212 212 snd_gf1_mem_block_t *last; 213 snd_info_entry_t *info_entry;214 213 struct semaphore memory_mutex; 215 214 } snd_gf1_mem_t; … … 333 332 334 333 snd_gf1_mem_t mem_alloc; 335 snd_info_entry_t *ram_entries[4];336 snd_info_entry_t *rom_entries[4];337 334 338 335 /* registers */ … … 453 450 454 451 struct _snd_gf1 gf1; /* gf1 specific variables */ 455 #ifdef CONFIG_SND_DEBUG456 snd_info_entry_t *irq_entry;457 #endif458 452 snd_pcm_t *pcm; 459 453 snd_pcm_substream_t *pcm_cap_substream; … … 602 596 603 597 int snd_gf1_mem_proc_init(snd_gus_card_t * gus); 604 int snd_gf1_mem_proc_done(snd_gus_card_t * gus);605 598 606 599 /* gus_dma.c */ … … 677 670 #ifdef CONFIG_SND_DEBUG 678 671 void snd_gus_irq_profile_init(snd_gus_card_t *gus); 679 void snd_gus_irq_profile_done(snd_gus_card_t *gus);680 672 #endif 681 673 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/initval.h
r210 r222 132 132 #endif 133 133 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> 145 136 146 #ifdef SNDRV_LEGACY_FIND_FREE_IRQ147 137 static void snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs) 148 138 { … … 188 178 for (s = *str; isalpha(*s) || isdigit(*s) || *s == '_'; s++); 189 179 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++; 195 186 } 187 if (d != NULL) 188 *d = '\0'; 196 189 } 197 190 *str = s; -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/memalloc.h
r32 r222 45 45 int type; /* SNDRV_DMA_TYPE_XXX */ 46 46 struct device *dev; 47 unsigned int id; /* a unique ID */ 47 48 }; 48 49 … … 61 62 #define SNDRV_DMA_TYPE_DEV 2 /* generic device continuous */ 62 63 #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 */ 63 68 #define SNDRV_DMA_TYPE_SBUS 4 /* SBUS continuous */ 64 69 #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 */ 76 static 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 65 85 66 86 #define __GFP_NOWARN 0 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/mixer_oss.h
r212 r222 62 62 struct semaphore reg_mutex; 63 63 snd_info_entry_t *proc_entry; 64 int oss_dev_alloc; 64 65 /* --- */ 65 66 int oss_recsrc; -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/pcm_oss.h
r96 r222 78 78 typedef struct _snd_pcm_oss { 79 79 int reg; 80 unsigned int reg_mask; 80 81 } snd_pcm_oss_t; 81 82 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/pcm_sgbuf.h
r215 r222 1 #if ndef __SOUND_PCM_SGBUF_H1 #if ! defined __SOUND_PCM_SGBUF_H && ! defined __SOUND_MEMALLOC_H 2 2 #define __SOUND_PCM_SGBUF_H 3 3 … … 22 22 * 23 23 */ 24 /*25 * buffer device info26 */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_SBUS33 struct sbus_dev *sbus; /* for SBUS type */34 #endif35 } dev;36 unsigned int id; /* a unique ID */37 };38 39 /*40 * buffer types41 */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_PCI50 /*51 * compose a snd_dma_device struct for the PCI device52 */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 #endif61 62 63 /*64 * info for buffer allocation65 */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 };72 24 73 25 struct snd_sg_page { … … 81 33 int tblsize; /* allocated table size */ 82 34 struct snd_sg_page *table; 35 struct page **page_table; 83 36 struct pci_dev *pci; 84 37 }; … … 102 55 } 103 56 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);57 struct snd_sg_buf *snd_pcm_sgbuf_init(struct pci_dev *pci); 58 void snd_pcm_sgbuf_delete(struct snd_sg_buf *sgbuf); 59 void *snd_pcm_sgbuf_alloc_pages(struct snd_sg_buf *sgbuf, size_t size); 60 int snd_pcm_sgbuf_free_pages(struct snd_sg_buf *sgbuf, void *vmaddr); 108 61 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); 62 int snd_pcm_lib_preallocate_sg_pages(struct pci_dev *pci, snd_pcm_substream_t *substream); 63 int 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 112 68 struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset); 113 69 114 115 70 #endif /* __SOUND_PCM_SGBUF_H */ -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/sb16_csp.h
r96 r222 160 160 161 161 struct semaphore access_mutex; /* locking */ 162 snd_info_entry_t *proc; /* proc interface */163 162 }; 164 163
Note:
See TracChangeset
for help on using the changeset viewer.