Changeset 366
- Timestamp:
- Aug 30, 2008, 9:18:38 PM (17 years ago)
- 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 26 26 #include <sound/info.h> 27 27 #include <linux/proc_fs.h> 28 #include <linux/pci.h> 29 #include <linux/dma-mapping.h> 28 30 #include <sound/memalloc.h> 29 31 #ifdef CONFIG_SBUS … … 66 68 #define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1 67 69 68 #ifdef CONFIG_PCI 70 /* 71 * Hacks 72 */ 73 69 74 #if defined(__i386__) || defined(__ppc__) || defined(__x86_64__) 70 71 75 /* 72 76 * A hack to allocate large buffers via dma_alloc_coherent() … … 121 125 #define dma_free_coherent(dev,size,ptr,addr) pci_free_consistent((struct pci_dev *)(dev),size,ptr,addr) 122 126 123 #endif /* CONFIG_PCI */ 127 /* 128 * 129 * Generic memory allocators 130 * 131 */ 132 133 static long snd_allocated_pages; /* holding the number of allocated pages */ 134 135 static inline void inc_snd_pages(int order) 136 { 137 snd_allocated_pages += 1 << order; 138 } 139 140 static 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 */ 154 void *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 */ 181 void *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 */ 204 void 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 */ 124 221 125 222 /* allocate the coherent DMA pages */ … … 156 253 dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); 157 254 } 255 256 #ifdef CONFIG_SBUS 257 258 static 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 274 static 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 290 static 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 */ 158 309 159 310 #if ! defined(__arm__) … … 247 398 } 248 399 400 249 401 /** 250 402 * snd_dma_free_pages - release the allocated buffer … … 353 505 354 506 355 /*356 *357 * Generic memory allocators358 *359 */360 361 507 /* Pure 2^n version of get_order */ 362 508 static inline int get_order(unsigned int size) … … 373 519 } 374 520 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 687 522 688 523 /* -
GPL/branches/alsa-resync1/alsa-kernel/core/seq/seq_clientmgr.c
r300 r366 567 567 568 568 /* 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 /*599 569 * deliver an event to the specified destination. 600 570 * if filter is non-zero, client filter bitmap is tested. -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/adriver.h
r348 r366 37 37 #endif 38 38 39 #if def ALSA_BUILD39 #if defined(ALSA_BUILD) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) 40 40 #if defined(CONFIG_MODVERSIONS) && !defined(__GENKSYMS__) && !defined(__DEPEND__) 41 41 #define MODVERSIONS … … 47 47 #undef _set_ver 48 48 #endif 49 #endif /* ALSA_BUILD */49 #endif /* ALSA_BUILD && KERNEL < 2.6.0 */ 50 50 51 51 #include <linux/module.h> -
GPL/branches/alsa-resync1/alsa-kernel/pci/ac97/ac97_pcm.c
r302 r366 213 213 snd_ac97_update_bits_nolock(ac97, reg, mask, bits); 214 214 /* 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 */233 215 #ifndef TARGET_OS2 234 216 spin_lock(&ac97->reg_lock); -
GPL/branches/alsa-resync1/alsa-kernel/pci/cmipci.c
r300 r366 2627 2627 */ 2628 2628 2629 static void snd_cmipci_proc_read(struct snd_info_entry *entry, 2629 #ifdef CONFIG_PROC_FS 2630 static void snd_cmipci_proc_read(struct snd_info_entry *entry, 2630 2631 struct snd_info_buffer *buffer) 2631 2632 { … … 2649 2650 { 2650 2651 struct snd_info_entry *entry; 2652 2651 2653 if (! snd_card_proc_new(cm->card, "cmipci", &entry)) 2652 2654 snd_info_set_text_ops(entry, cm, 1024, snd_cmipci_proc_read); 2653 2655 } 2656 #else /* !CONFIG_PROC_FS */ 2657 static inline void snd_cmipci_proc_init(struct cmipci *cm) {} 2658 #endif 2659 2654 2660 2655 2661 static struct pci_device_id snd_cmipci_ids[] = { -
GPL/branches/alsa-resync1/alsa-kernel/pci/intel8x0.c
r348 r366 42 42 #define SNDRV_GET_ID 43 43 #include <sound/initval.h> 44 /* for 440MX workaround */ 45 #include <asm/pgtable.h> 46 #include <asm/cacheflush.h> 44 47 45 48 #define I810_DEBUG … … 82 85 #else 83 86 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 87 static int ac97_quirk[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = AC97_TUNE_DEFAULT}; 84 88 #endif 85 89 #ifdef SUPPORT_JOYSTICK … … 865 869 /* ack */ 866 870 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); 878 879 } 879 880 #ifdef TARGET_OS2
Note:
See TracChangeset
for help on using the changeset viewer.