Changeset 76
- Timestamp:
- Apr 9, 2006, 12:09:39 PM (19 years ago)
- Location:
- GPL/trunk
- Files:
-
- 1 added
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/core/control.c
r34 r76 316 316 struct snd_ctl_elem_id id; 317 317 unsigned int idx; 318 319 snd_runtime_check(card != NULL && kcontrol != NULL, return -EINVAL); 320 snd_assert(kcontrol->info != NULL, return -EINVAL); 318 int err = -EINVAL; 319 320 if (! kcontrol) 321 return err; 322 323 snd_assert(card != NULL, goto error); 324 snd_assert(kcontrol->info != NULL, goto error); 325 321 326 id = kcontrol->id; 322 327 down_write(&card->controls_rwsem); 323 #if 0// doesnt works, traps on some systems328 #if 1 // doesnt works, traps on some systems 324 329 if (snd_ctl_find_id(card, &id)) { 325 330 up_write(&card->controls_rwsem); … … 331 336 id.name, 332 337 id.index); 333 return -EBUSY; 338 err = -EBUSY; 339 goto error; 334 340 } 335 341 if (snd_ctl_find_hole(card, kcontrol->count) < 0) { 336 342 up_write(&card->controls_rwsem); 337 snd_ctl_free_one(kcontrol);338 return -ENOMEM;343 err = -ENOMEM; 344 goto error; 339 345 } 340 346 #endif … … 347 353 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); 348 354 return 0; 355 356 error: 357 snd_ctl_free_one(kcontrol); 358 return err; 349 359 } 350 360 … … 395 405 } 396 406 397 static struct snd_kcontrol *_ctl_find_id398 (struct snd_card * card, struct snd_ctl_elem_id *id); /* w/o lock */399 400 407 /** 401 408 * snd_ctl_remove_unlocked_id - remove the unlocked control of the given id and release it … … 441 448 * Returns zero if successful, or a negative error code on failure. 442 449 */ 443 int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id) 444 { 445 struct snd_kcontrol *kctl; 446 447 down_write(&card->controls_rwsem); 448 kctl = _ctl_find_id(card, src_id); 449 if (kctl == NULL) { 450 up_write(&card->controls_rwsem); 451 return -ENOENT; 452 } 453 kctl->id = *dst_id; 454 kctl->id.numid = card->last_numid + 1; 455 card->last_numid += kctl->count; 456 up_write(&card->controls_rwsem); 457 return 0; 458 } 459 460 static struct snd_kcontrol *_ctl_find_numid(struct snd_card * card, unsigned int numid) 450 int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id, 451 struct snd_ctl_elem_id *dst_id) 452 { 453 struct snd_kcontrol *kctl; 454 455 down_write(&card->controls_rwsem); 456 kctl = snd_ctl_find_id(card, src_id); 457 if (kctl == NULL) { 458 up_write(&card->controls_rwsem); 459 return -ENOENT; 460 } 461 kctl->id = *dst_id; 462 kctl->id.numid = card->last_numid + 1; 463 card->last_numid += kctl->count; 464 up_write(&card->controls_rwsem); 465 return 0; 466 } 467 468 /** 469 * snd_ctl_find_numid - find the control instance with the given number-id 470 * @card: the card instance 471 * @numid: the number-id to search 472 * 473 * Finds the control instance with the given number-id from the card. 474 * 475 * Returns the pointer of the instance if found, or NULL if not. 476 * 477 * The caller must down card->controls_rwsem before calling this function 478 * (if the race condition can happen). 479 */ 480 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) 461 481 { 462 482 struct list_head *list; 463 483 struct snd_kcontrol *kctl; 464 484 465 snd_ runtime_check(card != NULL && numid != 0, return NULL);485 snd_assert(card != NULL && numid != 0, return NULL); 466 486 list_for_each(list, &card->controls) { 467 487 kctl = snd_kcontrol(list); … … 472 492 } 473 493 474 static struct snd_kcontrol *_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id)475 {476 struct list_head *list;477 struct snd_kcontrol *kctl;478 479 snd_runtime_check(card != NULL && id != NULL, return NULL);480 if (id->numid != 0)481 return _ctl_find_numid(card, id->numid);482 list_for_each(list, &card->controls) {483 kctl = snd_kcontrol(list);484 if (kctl->id.iface != id->iface)485 continue;486 if (kctl->id.device != id->device)487 continue;488 if (kctl->id.subdevice != id->subdevice)489 continue;490 if (strncmp(kctl->id.name, id->name, sizeof(kctl->id.name)))491 continue;492 if (kctl->id.index > id->index)493 continue;494 if (kctl->id.index + kctl->count <= id->index)495 continue;496 return kctl;497 }498 return NULL;499 }500 501 494 /** 502 * snd_ctl_find_id - find the control instance with the given id 503 * @card: the card instance 504 * @id: the id to search 505 * 506 * Finds the control instance with the given id from the card. 507 * 508 * Returns the pointer of the instance if found, or NULL if not. 509 */ 510 struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id) 511 { 512 struct snd_kcontrol *kctl; 513 down_read(&card->controls_rwsem); 514 kctl = _ctl_find_id(card, id); 515 up_read(&card->controls_rwsem); 516 return kctl; 517 } 518 519 /** 520 * snd_ctl_find_numid - find the control instance with the given number-id 521 * @card: the card instance 522 * @numid: the number-id to search 523 * 524 * Finds the control instance with the given number-id from the card. 525 * 526 * Returns the pointer of the instance if found, or NULL if not. 527 */ 528 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid) 529 { 530 struct snd_kcontrol *kctl; 531 down_read(&card->controls_rwsem); 532 kctl = _ctl_find_numid(card, numid); 533 up_read(&card->controls_rwsem); 534 return kctl; 535 } 495 * snd_ctl_find_id - find the control instance with the given id 496 * @card: the card instance 497 * @id: the id to search 498 * 499 * Finds the control instance with the given id from the card. 500 * 501 * Returns the pointer of the instance if found, or NULL if not. 502 * 503 * The caller must down card->controls_rwsem before calling this function 504 * (if the race condition can happen). 505 */ 506 struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, 507 struct snd_ctl_elem_id *id) 508 { 509 struct list_head *list; 510 struct snd_kcontrol *kctl; 511 512 snd_assert(card != NULL && id != NULL, return NULL); 513 if (id->numid != 0) 514 return snd_ctl_find_numid(card, id->numid); 515 list_for_each(list, &card->controls) { 516 kctl = snd_kcontrol(list); 517 if (kctl->id.iface != id->iface) 518 continue; 519 if (kctl->id.device != id->device) 520 continue; 521 if (kctl->id.subdevice != id->subdevice) 522 continue; 523 if (strncmp(kctl->id.name, id->name, sizeof(kctl->id.name))) 524 continue; 525 if (kctl->id.index > id->index) 526 continue; 527 if (kctl->id.index + kctl->count <= id->index) 528 continue; 529 return kctl; 530 } 531 return NULL; 532 } 536 533 537 534 static int snd_ctl_card_info(struct snd_card * card, struct snd_ctl_file * ctl, … … 617 614 } 618 615 619 static int snd_ctl_elem_info(struct snd_ctl_file *ctl, struct snd_ctl_elem_info *_info) 616 static int snd_ctl_elem_info(struct snd_ctl_file *ctl, 617 struct snd_ctl_elem_info *info) 620 618 { 621 619 struct snd_card *card = ctl->card; 622 struct snd_ctl_elem_info info;623 620 struct snd_kcontrol *kctl; 624 621 struct snd_kcontrol_volatile *vd; … … 626 623 int result; 627 624 628 if (copy_from_user(&info, _info, sizeof(info)))629 return -EFAULT;630 625 down_read(&card->controls_rwsem); 631 kctl = _ctl_find_id(card, &info.id);626 kctl = snd_ctl_find_id(card, &info->id); 632 627 if (kctl == NULL) { 633 628 up_read(&card->controls_rwsem); … … 635 630 } 636 631 #ifdef CONFIG_SND_DEBUG 637 info .access = 0;632 info->access = 0; 638 633 #endif 639 result = kctl->info(kctl, &info);634 result = kctl->info(kctl, info); 640 635 if (result >= 0) { 641 snd_assert(info .access == 0, );642 index_offset = snd_ctl_get_ioff(kctl, &info .id);636 snd_assert(info->access == 0, ); 637 index_offset = snd_ctl_get_ioff(kctl, &info->id); 643 638 vd = &kctl->vd[index_offset]; 644 snd_ctl_build_ioff(&info .id, kctl, index_offset);645 info .access = vd->access;639 snd_ctl_build_ioff(&info->id, kctl, index_offset); 640 info->access = vd->access; 646 641 if (vd->owner) { 647 info .access |= SNDRV_CTL_ELEM_ACCESS_LOCK;642 info->access |= SNDRV_CTL_ELEM_ACCESS_LOCK; 648 643 if (vd->owner == ctl) 649 info .access |= SNDRV_CTL_ELEM_ACCESS_OWNER;650 info .owner = vd->owner_pid;644 info->access |= SNDRV_CTL_ELEM_ACCESS_OWNER; 645 info->owner = vd->owner_pid; 651 646 } else { 652 info .owner = -1;647 info->owner = -1; 653 648 } 654 649 } 655 650 up_read(&card->controls_rwsem); 656 if (result >= 0)657 if (copy_to_user(_info, &info, sizeof(info)))658 return -EFAULT;659 651 return result; 660 652 } 661 #if 0 662 int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *_control) 663 { 664 665 struct snd_ctl_elem_value *control; 666 struct snd_kcontrol *kctl; 667 struct snd_kcontrol_volatile *vd; 668 unsigned int index_offset; 669 int result, indirect; 670 671 control = kmalloc(sizeof(*control), GFP_KERNEL); 672 if (control == NULL) 673 return -ENOMEM; 674 if (copy_from_user(control, _control, sizeof(*control))) 675 return -EFAULT; 676 down_read(&card->controls_rwsem); 677 kctl = _ctl_find_id(card, &control->id); 678 if (kctl == NULL) { 679 result = -ENOENT; 680 } else { 681 index_offset = snd_ctl_get_ioff(kctl, &control->id); 682 vd = &kctl->vd[index_offset]; 683 indirect = vd->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT ? 1 : 0; 684 if (control->indirect != indirect) { 685 result = -EACCES; 686 } else { 687 if ((vd->access & SNDRV_CTL_ELEM_ACCESS_READ) && kctl->get != NULL) { 688 snd_ctl_build_ioff(&control->id, kctl, index_offset); 689 result = kctl->get(kctl, control); 690 } else { 691 result = -EPERM; 692 } 693 } 694 } 695 up_read(&card->controls_rwsem); 696 if (result >= 0) 697 if (copy_to_user(_control, control, sizeof(*control))) 698 return -EFAULT; 699 kfree(control); 700 return result; 701 } 702 703 int snd_ctl_elem_write(struct snd_ctl_file *file, struct snd_ctl_elem_value *_control) 704 { 705 struct snd_card *card = file->card; 706 struct snd_ctl_elem_value *control; 707 struct snd_kcontrol *kctl; 708 struct snd_kcontrol_volatile *vd; 709 unsigned int index_offset; 710 int result, indirect; 711 712 control = kmalloc(sizeof(*control), GFP_KERNEL); 713 if (control == NULL) 714 return -ENOMEM; 715 if (copy_from_user(control, _control, sizeof(*control))) 716 return -EFAULT; 717 down_read(&card->controls_rwsem); 718 kctl = _ctl_find_id(card, &control->id); 719 if (kctl == NULL) { 720 result = -ENOENT; 721 } else { 722 index_offset = snd_ctl_get_ioff(kctl, &control->id); 723 vd = &kctl->vd[index_offset]; 724 indirect = vd->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT ? 1 : 0; 725 if (control->indirect != indirect) { 726 result = -EACCES; 727 } else { 728 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || 729 kctl->put == NULL || 730 (vd->owner != NULL && vd->owner != file)) { 731 result = -EPERM; 732 } else { 733 snd_ctl_build_ioff(&control->id, kctl, index_offset); 734 result = kctl->put(kctl, control); 735 } 736 if (result > 0) { 737 up_read(&card->controls_rwsem); 738 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &control->id); 739 result = 0; 740 goto __unlocked; 741 } 742 } 743 } 744 up_read(&card->controls_rwsem); 745 __unlocked: 746 if (result >= 0) 747 if (copy_to_user(_control, control, sizeof(*control))) 748 return -EFAULT; 749 kfree(control); 750 return result; 751 } 752 #else 653 753 654 int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control) 754 655 { … … 785 686 struct snd_ctl_elem_value *control; 786 687 int result; 787 688 788 689 control = kmalloc(sizeof(*control), GFP_KERNEL); 789 690 if (control == NULL) 790 return -ENOMEM; 691 return -ENOMEM; 791 692 if (copy_from_user(control, _control, sizeof(*control))) { 792 693 kfree(control); … … 845 746 control = kmalloc(sizeof(*control), GFP_KERNEL); 846 747 if (control == NULL) 847 return -ENOMEM; 748 return -ENOMEM; 848 749 if (copy_from_user(control, _control, sizeof(*control))) { 849 750 kfree(control); … … 858 759 } 859 760 860 #endif 861 static int snd_ctl_elem_lock(struct snd_ctl_file *file, struct snd_ctl_elem_id *_id) 761 762 static int snd_ctl_elem_lock(struct snd_ctl_file *file, 763 struct snd_ctl_elem_id __user *_id) 862 764 { 863 765 struct snd_card *card = file->card; … … 870 772 return -EFAULT; 871 773 down_write(&card->controls_rwsem); 872 kctl = _ctl_find_id(card, &id);774 kctl = snd_ctl_find_id(card, &id); 873 775 if (kctl == NULL) { 874 776 result = -ENOENT; … … 887 789 } 888 790 889 static int snd_ctl_elem_unlock(struct snd_ctl_file *file, struct snd_ctl_elem_id *_id) 791 static int snd_ctl_elem_unlock(struct snd_ctl_file *file, 792 struct snd_ctl_elem_id __user *_id) 890 793 { 891 794 struct snd_card *card = file->card; … … 898 801 return -EFAULT; 899 802 down_write(&card->controls_rwsem); 900 kctl = _ctl_find_id(card, &id);803 kctl = snd_ctl_find_id(card, &id); 901 804 if (kctl == NULL) { 902 805 result = -ENOENT; … … 948 851 int change; 949 852 struct user_element *ue = kcontrol->private_data; 950 853 951 854 change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0; 952 855 if (change) … … 970 873 struct user_element *ue; 971 874 int idx, err; 972 875 973 876 if (card->user_ctl_count >= MAX_USER_CONTROLS) 974 877 return -ENOMEM; -
GPL/trunk/alsa-kernel/core/memalloc.c
r32 r76 149 149 res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags); 150 150 if (res != NULL) { 151 #ifdef NEED_RESERVE_PAGES152 mark_pages(virt_to_page(res), pg); /* should be dma_to_page() */153 #endif154 151 inc_snd_pages(pg); 155 152 } … … 168 165 pg = get_order(size); 169 166 dec_snd_pages(pg); 170 #ifdef NEED_RESERVE_PAGES171 unmark_pages(virt_to_page(ptr), pg); /* should be dma_to_page() */172 #endif173 167 dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); 174 168 } … … 402 396 } 403 397 404 static void mark_pages(struct page *page, int order)405 {406 struct page *last_page = page + (1 << order);407 while (page < last_page)408 SetPageReserved(page++);409 }410 411 static void unmark_pages(struct page *page, int order)412 {413 struct page *last_page = page + (1 << order);414 while (page < last_page)415 ClearPageReserved(page++);416 }417 398 418 399 /** … … 434 415 pg = get_order(size); 435 416 if ((res = (void *) __get_free_pages(dma_flags, pg)) != NULL) { 436 mark_pages(virt_to_page(res), pg);437 417 inc_snd_pages(pg); 438 418 } … … 456 436 pg = get_order(size); 457 437 dec_snd_pages(pg); 458 unmark_pages(virt_to_page(ptr), pg);459 438 free_pages((unsigned long) ptr, pg); 460 439 } … … 532 511 res = pci_alloc_consistent(pci, PAGE_SIZE * (1 << pg), dmaaddr); 533 512 if (res != NULL) { 534 #ifdef NEED_RESERVE_PAGES535 mark_pages(virt_to_page(res), pg); /* should be dma_to_page() */536 #endif537 513 inc_snd_pages(pg); 538 514 } … … 589 565 for (pg = 0; PAGE_SIZE * (1 << pg) < size; pg++); 590 566 dec_snd_pages(pg); 591 #ifdef NEED_RESERVE_PAGES592 unmark_pages(virt_to_page(ptr), pg); /* should be dma_to_page() */593 #endif594 567 pci_free_consistent(pci, PAGE_SIZE * (1 << pg), ptr, dmaaddr); 595 568 } … … 638 611 if (ptr) { 639 612 memset(ptr, 0, PAGE_SIZE); 640 mark_pages(ptr, 0);641 613 } 642 614 *addrp = addr; -
GPL/trunk/alsa-kernel/core/pcm_native.c
r35 r76 1106 1106 static int snd_pcm_pre_resume(snd_pcm_substream_t *substream, int state) 1107 1107 { 1108 snd_pcm_runtime_t *runtime = substream->runtime; 1108 snd_pcm_runtime_t *runtime; 1109 if (substream) runtime = substream->runtime; 1110 if (!runtime) return 0; 1109 1111 if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) 1110 1112 return -ENOSYS; … … 1115 1117 static int snd_pcm_do_resume(snd_pcm_substream_t *substream, int state) 1116 1118 { 1117 snd_pcm_runtime_t *runtime = substream->runtime; 1119 snd_pcm_runtime_t *runtime; 1120 if (substream) runtime = substream->runtime; 1121 if (!runtime) return 0; 1118 1122 if (runtime->trigger_master != substream) 1119 1123 return 0; … … 1123 1127 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) 1124 1128 return 0; 1125 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); 1129 if (substream->ops->trigger) 1130 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); 1131 else return 0; 1126 1132 } 1127 1133 … … 1135 1141 static void snd_pcm_post_resume(snd_pcm_substream_t *substream, int state) 1136 1142 { 1137 snd_pcm_runtime_t *runtime = substream->runtime; 1143 snd_pcm_runtime_t *runtime; 1144 if (substream) runtime = substream->runtime; 1145 if (!runtime) return; 1138 1146 snd_pcm_trigger_tstamp(substream); 1139 1147 if (substream->timer) … … 1153 1161 static int snd_pcm_resume(snd_pcm_substream_t *substream) 1154 1162 { 1155 snd_card_t *card = substream->pcm->card;1163 snd_card_t *card; 1156 1164 int res; 1157 1165 1158 snd_power_lock(card); 1159 if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile)) >= 0) 1160 res = snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); 1161 snd_power_unlock(card); 1166 if(substream && substream->pcm) 1167 { 1168 card = substream->pcm->card; 1169 snd_power_lock(card); 1170 if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile)) >= 0) 1171 res = snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); 1172 snd_power_unlock(card); 1173 } 1162 1174 return res; 1163 1175 } … … 2060 2072 err = snd_pcm_hw_constraints_init(substream); 2061 2073 if (err < 0) { 2062 snd_printd("snd_pcm_hw_constraints_init failed \n");2074 snd_printd("snd_pcm_hw_constraints_init failed: %i\n", err); 2063 2075 snd_pcm_release_file(pcm_file); 2064 2076 return err; … … 2067 2079 if ((err = substream->ops->open(substream)) < 0) { 2068 2080 snd_pcm_release_file(pcm_file); 2081 snd_printd("supbstream open failed: %i\n", err); 2069 2082 return err; 2070 2083 } … … 2073 2086 err = snd_pcm_hw_constraints_complete(substream); 2074 2087 if (err < 0) { 2075 snd_printd("snd_pcm_hw_constraints_complete failed \n");2088 snd_printd("snd_pcm_hw_constraints_complete failed: %i\n", err); 2076 2089 snd_pcm_release_file(pcm_file); 2077 2090 return err; … … 2532 2545 case SNDRV_PCM_IOCTL_DROP: 2533 2546 return snd_pcm_drop(substream); 2547 case SNDRV_PCM_IOCTL_PAUSE: 2548 { 2549 int res; 2550 snd_pcm_stream_lock_irq(substream); 2551 res = snd_pcm_pause(substream, (int)(unsigned long)arg); 2552 snd_pcm_stream_unlock_irq(substream); 2553 return res; 2554 } 2534 2555 } 2535 2556 snd_printd("unknown ioctl = 0x%x\n", cmd); … … 2611 2632 return result < 0 ? result : 0; 2612 2633 } 2613 case SNDRV_PCM_IOCTL_PAUSE:2614 {2615 int res;2616 snd_pcm_stream_lock_irq(substream);2617 res = snd_pcm_pause(substream, (long) arg);2618 snd_pcm_stream_unlock_irq(substream);2619 return res;2620 }2621 2634 } 2622 2635 return snd_pcm_common_ioctl1(substream, cmd, arg); -
GPL/trunk/alsa-kernel/include/sound/ac97_codec.h
r71 r76 306 306 #define AC97_ALC650_SOUCE_MASK 0x000f /* Source number */ 307 307 #define AC97_ALC650_CHANNEL_MASK 0x00f0 /* Channel number */ 308 #define AC97_ALC650_CHANNEL_SHIFT 4 308 #define AC97_ALC650_CHANNEL_SHIFT 4 309 309 #define AC97_ALC650_SPSR_MASK 0x0f00 /* S/PDIF Sample Rate bits */ 310 310 #define AC97_ALC650_SPSR_SHIFT 8 … … 434 434 }; 435 435 436 /* static resolution table */ 437 struct snd_ac97_res_table { 438 unsigned short reg; /* register */ 439 unsigned short bits; /* resolution bitmask */ 440 }; 441 436 442 struct snd_ac97_template { 437 443 void *private_data; … … 441 447 unsigned short addr; /* physical address of codec [0-3] */ 442 448 unsigned int scaps; /* driver capabilities */ 443 unsigned int limited_regs; /* allow limited registers only */ 444 DECLARE_BITMAP(reg_accessed, 0x80); /* bit flags */ 449 const struct snd_ac97_res_table *res_table; /* static resolution */ 445 450 }; 446 451 … … 464 469 unsigned short caps; /* capabilities (register 0) */ 465 470 unsigned short ext_id; /* extended feature identification (register 28) */ 466 unsigned short ext_mid; /* extended modem ID (register 3C) */ 471 unsigned short ext_mid; /* extended modem ID (register 3C) */ 472 const struct snd_ac97_res_table *res_table; /* static resolution */ 467 473 unsigned int scaps; /* driver capabilities */ 468 474 unsigned int flags; /* specific code */ … … 470 476 unsigned int spdif_status; 471 477 unsigned short regs[0x80]; /* register cache */ 472 unsigned int limited_regs; /* allow limited registers only */473 478 DECLARE_BITMAP(reg_accessed, 0x80); /* bit flags */ 474 479 union { /* vendor specific code */ -
GPL/trunk/alsa-kernel/include/sound/driver.h
r73 r76 655 655 ##retval;\ 656 656 } 657 658 657 #define snd_runtime_check snd_assert 659 658 … … 749 748 typedef unsigned gfp_t; 750 749 750 #ifndef cpu_relax 751 #define cpu_relax() 752 #endif 753 751 754 #endif /* __DRIVER_H */ -
GPL/trunk/alsa-kernel/pci/ac97/ac97_codec.c
r72 r76 144 144 { 0x49434511, 0xffffffff, "ICE1232", NULL, NULL }, // alias VIA VT1611A? 145 145 { 0x49434514, 0xffffffff, "ICE1232A", NULL, NULL }, 146 { 0x49434551, 0xffffffff, "VT1616", patch_vt1616, NULL }, 146 { 0x49434551, 0xffffffff, "VT1616", patch_vt1616, NULL }, 147 147 { 0x49434552, 0xffffffff, "VT1616i", patch_vt1616, NULL }, // VT1616 compatible (chipset integrated) 148 148 { 0x49544520, 0xffffffff, "IT2226E", NULL, NULL }, … … 151 151 { 0x4e534331, 0xffffffff, "LM4549", NULL, NULL }, 152 152 { 0x4e534350, 0xffffffff, "LM4550", NULL, NULL }, 153 { 0x4e534350, 0xffffffff, "LM4550", patch_lm4550, NULL }, // volume wrap fix 153 154 { 0x50534304, 0xffffffff, "UCB1400", NULL, NULL }, 154 155 { 0x53494c20, 0xffffffe0, "Si3036,8", mpatch_si3036, mpatch_si3036, AC97_MODEM_PATCH }, … … 192 193 static int snd_ac97_valid_reg(struct snd_ac97 *ac97, unsigned short reg) 193 194 { 194 if (ac97->limited_regs && ! test_bit(reg, ac97->reg_accessed))195 return 0;196 197 195 /* filter some registers for buggy codecs */ 198 196 switch (ac97->id) { … … 257 255 /** 258 256 * snd_ac97_read - read a value from the given register 259 * 257 * 260 258 * @ac97: the ac97 instance 261 259 * @reg: the register to read … … 411 409 { 412 410 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 413 411 414 412 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 415 413 uinfo->count = e->shift_l == e->shift_r ? 1 : 2; 416 414 uinfo->value.enumerated.items = e->mask; 417 415 418 416 if (uinfo->value.enumerated.item > e->mask - 1) 419 417 uinfo->value.enumerated.item = e->mask - 1; … … 427 425 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 428 426 unsigned short val, bitmask; 429 427 430 428 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) 431 429 ; … … 444 442 unsigned short val; 445 443 unsigned short mask, bitmask; 446 444 447 445 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) 448 446 ; … … 530 528 int err, page_save; 531 529 unsigned short val, val2, val_mask; 532 530 533 531 page_save = snd_ac97_page_save(ac97, reg, kcontrol); 534 532 val = (ucontrol->value.integer.value[0] & mask); … … 580 578 }; 581 579 582 static const struct snd_kcontrol_new snd_ac97_control_capture_src = 583 AC97_ENUM("Capture Source", std_enum[0]); 580 static const struct snd_kcontrol_new snd_ac97_control_capture_src = 581 AC97_ENUM("Capture Source", std_enum[0]); 584 582 585 583 static const struct snd_kcontrol_new snd_ac97_control_capture_vol = … … 648 646 return 0; 649 647 } 650 648 651 649 static int snd_ac97_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 652 650 { … … 660 658 return 0; 661 659 } 662 660 663 661 static int snd_ac97_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 664 662 { … … 683 681 return 0; 684 682 } 685 683 686 684 static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 687 685 { … … 735 733 v = new & (IEC958_AES0_CON_EMPHASIS_5015|IEC958_AES0_CON_NOT_COPYRIGHT) ? 0 : AC97_CXR_COPYRGT; 736 734 v |= new & IEC958_AES0_NONAUDIO ? AC97_CXR_SPDIF_AC3 : AC97_CXR_SPDIF_PCM; 737 change |= snd_ac97_update_bits_nolock(ac97, AC97_CXR_AUDIO_MISC, 735 change |= snd_ac97_update_bits_nolock(ac97, AC97_CXR_AUDIO_MISC, 738 736 AC97_CXR_SPDIF_MASK | AC97_CXR_COPYRGT, 739 737 v); … … 845 843 int rshift = (kcontrol->private_value >> 12) & 0x0f; 846 844 int mask = (kcontrol->private_value >> 16) & 0xff; 847 845 848 846 ucontrol->value.integer.value[0] = mask - ((ac97->spec.ad18xx.pcmreg[codec] >> lshift) & mask); 849 847 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) … … 860 858 int mask = (kcontrol->private_value >> 16) & 0xff; 861 859 unsigned short val, valmask; 862 860 863 861 val = (mask - (ucontrol->value.integer.value[0] & mask)) << lshift; 864 862 valmask = mask << lshift; … … 888 886 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 889 887 int codec = kcontrol->private_value & 3; 890 888 891 889 down(&ac97->page_mutex); 892 890 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); … … 901 899 int codec = kcontrol->private_value & 3; 902 900 unsigned short val1, val2; 903 901 904 902 val1 = 31 - (ucontrol->value.integer.value[0] & 31); 905 903 val2 = 31 - (ucontrol->value.integer.value[1] & 31); … … 1008 1006 } 1009 1007 1010 if (ac97->limited_regs && test_bit(reg, ac97->reg_accessed))1011 return 1; /* allow without check */1012 1013 1008 val = snd_ac97_read(ac97, reg); 1014 1009 if (!(val & mask)) { … … 1030 1025 int i; 1031 1026 1032 *lo_max = *hi_max = 0; 1027 /* first look up the static resolution table */ 1028 if (ac97->res_table) { 1029 const struct snd_ac97_res_table *tbl; 1030 for (tbl = ac97->res_table; tbl->reg; tbl++) { 1031 if (tbl->reg == reg) { 1032 *lo_max = tbl->bits & 0xff; 1033 *hi_max = (tbl->bits >> 8) & 0xff; 1034 return; 1035 } 1036 } 1037 } 1038 1039 *lo_max = *hi_max = 0; 1033 1040 for (i = 0 ; i < ARRAY_SIZE(cbit); i++) { 1034 1041 unsigned short val; … … 1243 1250 /* build master controls */ 1244 1251 /* AD claims to remove this control from AD1887, although spec v2.2 does not allow this */ 1245 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER)) { 1252 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER)) { 1253 #ifndef TARGET_OS2 1246 1254 if (ac97->flags & AC97_HAS_NO_MASTER_VOL) 1247 1255 err = snd_ac97_cmute_new(card, "Master Playback Switch", AC97_MASTER, ac97); 1248 else 1256 else 1257 #endif 1249 1258 err = snd_ac97_cmix_new(card, "Master Playback", AC97_MASTER, ac97); 1250 1259 if (err < 0) … … 1290 1299 return err; 1291 1300 } 1292 1301 1293 1302 /* build master mono controls */ 1294 1303 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_MONO)) { … … 1296 1305 return err; 1297 1306 } 1298 1307 1299 1308 /* build master tone controls */ 1300 1309 if (!(ac97->flags & AC97_HAS_NO_TONE)) { … … 1311 1320 } 1312 1321 } 1313 1322 1314 1323 /* build PC Speaker controls */ 1315 if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && 1324 if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && 1316 1325 ((ac97->flags & AC97_HAS_PC_BEEP) || 1317 1326 snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) { … … 1322 1331 snd_ac97_read(ac97, AC97_PC_BEEP) | 0x801e); 1323 1332 } 1324 1333 1325 1334 /* build Phone controls */ 1326 1335 if (!(ac97->flags & AC97_HAS_NO_PHONE)) { … … 1330 1339 } 1331 1340 } 1332 1341 1333 1342 /* build MIC controls */ 1334 1343 if (!(ac97->flags & AC97_HAS_NO_MIC)) { … … 1346 1355 return err; 1347 1356 } 1348 1357 1349 1358 /* build CD controls */ 1350 1359 if (!(ac97->flags & AC97_HAS_NO_CD)) { … … 1354 1363 } 1355 1364 } 1356 1365 1357 1366 /* build Video controls */ 1358 1367 if (!(ac97->flags & AC97_HAS_NO_VIDEO)) { … … 1397 1406 snd_ac97_write_cache(ac97, AC97_PCM, init_val); 1398 1407 } else { 1399 if (!(ac97->flags & AC97_HAS_NO_STD_PCM)) { 1408 if (!(ac97->flags & AC97_HAS_NO_STD_PCM)) { 1409 #ifndef TARGET_OS2 1400 1410 if (ac97->flags & AC97_HAS_NO_PCM_VOL) 1401 1411 err = snd_ac97_cmute_new(card, "PCM Playback Switch", AC97_PCM, ac97); 1402 else 1412 else 1413 #endif 1403 1414 err = snd_ac97_cmix_new(card, "PCM Playback", AC97_PCM, ac97); 1404 1415 if (err < 0) … … 1514 1525 ac97->spdif_status = SNDRV_PCM_DEFAULT_CON_SPDIF; 1515 1526 } 1516 1527 1517 1528 /* build chip specific controls */ 1518 1529 if (ac97->build_ops->build_specific) … … 1575 1586 unsigned short saved; 1576 1587 1577 if (ac97->bus->no_vra) {1588 if (ac97->bus->no_vra || !(ac97->ext_id & AC97_EI_VRA) ) { 1578 1589 *r_result = SNDRV_PCM_RATE_48000; 1579 1590 if ((ac97->flags & AC97_DOUBLE_RATE) && … … 1678 1689 (! modem && ! (pid->flags & AC97_MODEM_PATCH))) 1679 1690 pid->patch(ac97); 1680 } 1691 } 1681 1692 1682 1693 pid = look_for_codec_id(snd_ac97_codec_ids, id); … … 1722 1733 end_time = jiffies + timeout; 1723 1734 do { 1724 1735 1725 1736 /* use preliminary reads to settle the communication */ 1726 1737 snd_ac97_read(ac97, AC97_RESET); … … 1765 1776 * The ops table must include valid callbacks (at least read and 1766 1777 * write). The other callbacks, wait and reset, are not mandatory. 1767 * 1778 * 1768 1779 * The clock is set to 48000. If another clock is needed, set 1769 1780 * (*rbus)->clock manually. … … 1860 1871 * The template must include the codec number (num) and address (addr), 1861 1872 * and the private data (private_data). 1862 * 1873 * 1863 1874 * The ac97 instance is registered as a low-level device, so you don't 1864 1875 * have to release it manually. … … 1897 1908 ac97->addr = template->addr; 1898 1909 ac97->scaps = template->scaps; 1899 ac97->limited_regs = template->limited_regs; 1900 memcpy(ac97->reg_accessed, template->reg_accessed, sizeof(ac97->reg_accessed)); 1910 ac97->res_table = template->res_table; 1901 1911 bus->codec[ac97->num] = ac97; 1902 1912 init_MUTEX(&ac97->reg_mutex); … … 1955 1965 if (pid) 1956 1966 ac97->flags |= pid->flags; 1957 1967 1958 1968 /* test for AC'97 */ 1959 1969 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO) && !(ac97->scaps & AC97_SCAP_AUDIO)) { … … 2040 2050 snd_printk(KERN_WARNING "MC'97 %d converters and GPIO not ready (0x%x)\n", ac97->num, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS)); 2041 2051 } 2042 2052 2043 2053 __ready_ok: 2044 2054 if (ac97_is_audio(ac97)) … … 2139 2149 if (ac97->scaps && ac97_is_audio(ac97)) { 2140 2150 reg = snd_ac97_read(ac97, AC97_EXTENDED_STATUS); 2141 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) 2151 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) 2142 2152 reg &= ~AC97_EA_PRJ; 2143 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) 2153 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) 2144 2154 reg &= ~(AC97_EA_PRI | AC97_EA_PRK); 2145 2155 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, reg); … … 2316 2326 else 2317 2327 strcpy(dst, src); 2318 } 2328 } 2319 2329 2320 2330 /* remove the control with the given name and optional suffix */ … … 2443 2453 } 2444 2454 2445 static const struct snd_kcontrol_new snd_ac97_alc_jack_detect = 2455 static const struct snd_kcontrol_new snd_ac97_alc_jack_detect = 2446 2456 AC97_SINGLE("Jack Detect", AC97_ALC650_CLOCK, 5, 1, 0); 2447 2457 -
GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.c
r72 r76 390 390 /* This is known to work for the ViewSonic ViewPad 1000 391 391 * Randolph Bentson <bentson@holmsjoen.com> 392 * WM9703/9707/9708/9717 392 * WM9703/9707/9708/9717 393 393 */ 394 394 int err, i; 395 395 396 396 for (i = 0; i < ARRAY_SIZE(wm97xx_snd_ac97_controls); i++) { 397 397 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0) … … 474 474 static const char* wm9711_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"}; 475 475 static const char* wm9711_mic[] = {"Mic 1", "Differential", "Mic 2", "Stereo"}; 476 static const char* wm9711_rec_sel[] = 476 static const char* wm9711_rec_sel[] = 477 477 {"Mic 1", "NC", "NC", "Master Mix", "Line", "Headphone Mix", "Phone Mix", "Phone"}; 478 478 static const char* wm9711_ng_type[] = {"Constant Gain", "Mute"}; … … 572 572 { 573 573 int err, i; 574 574 575 575 for (i = 0; i < ARRAY_SIZE(wm9711_snd_ac97_controls); i++) { 576 576 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97))) < 0) … … 597 597 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_MIC | 598 598 AC97_HAS_NO_PC_BEEP | AC97_HAS_NO_VIDEO | AC97_HAS_NO_CD; 599 599 600 600 return 0; 601 601 } … … 603 603 static const char* wm9713_mic_mixer[] = {"Stereo", "Mic 1", "Mic 2", "Mute"}; 604 604 static const char* wm9713_rec_mux[] = {"Stereo", "Left", "Right", "Mute"}; 605 static const char* wm9713_rec_src[] = 606 {"Mic 1", "Mic 2", "Line", "Mono In", "Headphone Mix", "Master Mix", 605 static const char* wm9713_rec_src[] = 606 {"Mic 1", "Mic 2", "Line", "Mono In", "Headphone Mix", "Master Mix", 607 607 "Mono Mix", "Zh"}; 608 608 static const char* wm9713_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"}; 609 609 static const char* wm9713_alc_select[] = {"None", "Left", "Right", "Stereo"}; 610 610 static const char* wm9713_mono_pga[] = {"Vmid", "Zh", "Mono Mix", "Inv 1"}; 611 static const char* wm9713_spk_pga[] = 611 static const char* wm9713_spk_pga[] = 612 612 {"Vmid", "Zh", "Headphone Mix", "Master Mix", "Inv", "NC", "NC", "NC"}; 613 613 static const char* wm9713_hp_pga[] = {"Vmid", "Zh", "Headphone Mix", "NC"}; 614 614 static const char* wm9713_out3_pga[] = {"Vmid", "Zh", "Inv 1", "NC"}; 615 615 static const char* wm9713_out4_pga[] = {"Vmid", "Zh", "Inv 2", "NC"}; 616 static const char* wm9713_dac_inv[] = 617 {"Off", "Mono Mix", "Master Mix", "Headphone Mix L", "Headphone Mix R", 616 static const char* wm9713_dac_inv[] = 617 {"Off", "Mono Mix", "Master Mix", "Headphone Mix L", "Headphone Mix R", 618 618 "Headphone Mix Mono", "NC", "Vmid"}; 619 619 static const char* wm9713_base[] = {"Linear Control", "Adaptive Boost"}; … … 739 739 { 740 740 int err, i; 741 741 742 742 for (i = 0; i < ARRAY_SIZE(wm13_snd_ac97_controls_3d); i++) { 743 743 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97))) < 0) … … 750 750 { 751 751 int err, i; 752 752 753 753 for (i = 0; i < ARRAY_SIZE(wm13_snd_ac97_controls); i++) { 754 754 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97))) < 0) … … 783 783 .build_specific = patch_wolfson_wm9713_specific, 784 784 .build_3d = patch_wolfson_wm9713_3d, 785 #ifdef CONFIG_PM 785 #ifdef CONFIG_PM 786 786 .suspend = patch_wolfson_wm9713_suspend, 787 787 .resume = patch_wolfson_wm9713_resume … … 1184 1184 1185 1185 /* Gateway M675 notebook */ 1186 if (ac97->pci && 1186 if (ac97->pci && 1187 1187 ac97->subsystem_vendor == 0x107b && 1188 1188 ac97->subsystem_device == 0x0601) … … 1248 1248 1249 1249 ac97->build_ops = &patch_cirrus_ops; 1250 ac97->flags |= AC97_CS_SPDIF; 1250 ac97->flags |= AC97_CS_SPDIF; 1251 1251 ac97->rates[AC97_RATES_SPDIF] &= ~SNDRV_PCM_RATE_32000; 1252 1252 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ … … 1259 1259 /* force the detection of PC Beep */ 1260 1260 ac97->flags |= AC97_HAS_PC_BEEP; 1261 1261 1262 1262 return patch_cirrus_spdif(ac97); 1263 1263 } … … 1398 1398 static int cfg_bits[3] = { 1<<12, 1<<14, 1<<13 }; 1399 1399 unsigned short val; 1400 1400 1401 1401 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]); 1402 1402 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0004); // SDIE … … 1449 1449 {0, 1} 1450 1450 }; 1451 1451 1452 1452 // patch for Analog Devices 1453 1453 unsigned short codecs[3]; … … 1487 1487 /* ok, deselect all ID bits */ 1488 1488 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000); 1489 ac97->spec.ad18xx.codec_cfg[0] = 1490 ac97->spec.ad18xx.codec_cfg[1] = 1489 ac97->spec.ad18xx.codec_cfg[0] = 1490 ac97->spec.ad18xx.codec_cfg[1] = 1491 1491 ac97->spec.ad18xx.codec_cfg[2] = 0x0000; 1492 1492 } … … 1846 1846 { 1847 1847 unsigned short misc; 1848 1848 1849 1849 patch_ad1881(ac97); 1850 1850 ac97->build_ops = &patch_ad1888_build_ops; … … 1920 1920 { 1921 1921 unsigned short misc; 1922 1922 1923 1923 patch_ad1881(ac97); 1924 1924 ac97->build_ops = &patch_ad1985_build_ops; … … 1949 1949 { 1950 1950 int shared; 1951 1951 1952 1952 /* shared Line-In */ 1953 1953 shared = is_shared_linein(ac97); … … 2041 2041 2042 2042 /* enable AC97_ALC650_GPIO_SETUP, AC97_ALC650_CLOCK for R/W */ 2043 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS, 2043 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS, 2044 2044 snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x8000); 2045 2045 … … 2076 2076 { 2077 2077 int shared; 2078 2078 2079 2079 /* shared Line-In */ 2080 2080 shared = is_shared_linein(ac97); … … 2222 2222 { 2223 2223 int shared; 2224 2224 2225 2225 /* shared Line-In */ 2226 2226 shared = is_shared_linein(ac97); … … 2365 2365 2366 2366 return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL, 2367 0x01 << 1, 2367 0x01 << 1, 2368 2368 (ucontrol->value.enumerated.item[0] & 0x01) << 1); 2369 2369 } … … 2381 2381 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Valid Switch", AC97_CM9739_SPDIF_CTRL, 2, 1, 0), 2382 2382 /* BIT 3: SPI2F */ 2383 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Monitor", AC97_CM9739_SPDIF_CTRL, 3, 1, 0), 2383 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Monitor", AC97_CM9739_SPDIF_CTRL, 3, 1, 0), 2384 2384 /* BIT 4: SPI2SDI */ 2385 2385 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), AC97_CM9739_SPDIF_CTRL, 4, 1, 0), … … 2569 2569 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Valid Switch", AC97_CM9761_SPDIF_CTRL, 2, 1, 0), 2570 2570 /* BIT 3: SPI2F */ 2571 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Monitor", AC97_CM9761_SPDIF_CTRL, 3, 1, 0), 2571 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Monitor", AC97_CM9761_SPDIF_CTRL, 3, 1, 0), 2572 2572 /* BIT 4: SPI2SDI */ 2573 2573 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), AC97_CM9761_SPDIF_CTRL, 4, 1, 0), … … 2661 2661 return 0; 2662 2662 } 2663 2663 2664 2664 #define AC97_CM9780_SIDE 0x60 2665 2665 #define AC97_CM9780_JACK 0x62 … … 2824 2824 return 0; 2825 2825 } 2826 2827 /* 2828 * LM 4550 Codec 2829 * 2830 * We use a static resolution table since LM4550 codec cannot be 2831 * properly autoprobed to determine the resolution via 2832 * check_volume_resolution(). 2833 */ 2834 2835 static struct snd_ac97_res_table lm4550_restbl[] = { 2836 { AC97_MASTER, 0x1f1f }, 2837 { AC97_HEADPHONE, 0x1f1f }, 2838 { AC97_MASTER_MONO, 0x001f }, 2839 { AC97_PC_BEEP, 0x001f }, /* LSB is ignored */ 2840 { AC97_PHONE, 0x001f }, 2841 { AC97_MIC, 0x001f }, 2842 { AC97_LINE, 0x1f1f }, 2843 { AC97_CD, 0x1f1f }, 2844 { AC97_VIDEO, 0x1f1f }, 2845 { AC97_AUX, 0x1f1f }, 2846 { AC97_PCM, 0x1f1f }, 2847 { AC97_REC_GAIN, 0x0f0f }, 2848 {0} /* terminator */ 2849 }; 2850 2851 int patch_lm4550(struct snd_ac97 *ac97) 2852 { 2853 ac97->res_table = lm4550_restbl; 2854 return 0; 2855 } 2856 -
GPL/trunk/alsa-kernel/pci/ac97/ac97_patch.h
r72 r76 60 60 int patch_it2646(struct snd_ac97 * ac97); 61 61 int mpatch_si3036(struct snd_ac97 * ac97); 62 int patch_lm4550(struct snd_ac97 * ac97); -
GPL/trunk/alsa-kernel/pci/bt87x.c
r70 r76 794 794 /* AVerMedia Studio No. 103, 203, ...? */ 795 795 BT_DEVICE(878, 0x1461, 0x0003, 48000), 796 /* Leadtek Winfast tv 2000xp delux */ 797 BT_DEVICE(878, 0x107d, 0x6606, 32000), 796 798 {0} 797 799 }; … … 804 806 } blacklist[] __devinitdata = { 805 807 {0x0071, 0x0101}, /* Nebula Electronics DigiTV */ 808 {0x11bd, 0x001c}, /* Pinnacle PCTV Sat */ 806 809 {0x11bd, 0x0026}, /* Pinnacle PCTV SAT CI */ 807 810 {0x1461, 0x0761}, /* AVermedia AverTV DVB-T */ 808 811 {0x1461, 0x0771}, /* AVermedia DVB-T 771 */ 809 812 {0x1822, 0x0001}, /* Twinhan VisionPlus DVB-T */ 813 {0x18ac, 0xd500}, /* DVICO FusionHDTV 5 Lite */ 810 814 {0x18ac, 0xdb10}, /* DVICO FusionHDTV DVB-T Lite */ 811 815 {0x270f, 0xfc00}, /* Chaintech Digitop DST-1000 DVB-S */ 816 {0x7063, 0x2000}, /* pcHDTV HD-2000 TV */ 812 817 }; 813 818 … … 825 830 if (blacklist[i].subvendor == pci->subsystem_vendor && 826 831 blacklist[i].subdevice == pci->subsystem_device) { 827 snd_printdd(KERN_INFO "card %#04x :%#04x has no audio\n",828 pci-> subsystem_vendor, pci->subsystem_device);832 snd_printdd(KERN_INFO "card %#04x-%#04x:%#04x has no audio\n", 833 pci->device, pci->subsystem_vendor, pci->subsystem_device); 829 834 return -EBUSY; 830 835 } 831 836 832 snd_printk(KERN_INFO "unknown card %#04x :%#04x, using default rate 32000\n",833 pci-> subsystem_vendor, pci->subsystem_device);837 snd_printk(KERN_INFO "unknown card %#04x-%#04x:%#04x, using default rate 32000\n", 838 pci->device, pci->subsystem_vendor, pci->subsystem_device); 834 839 snd_printk(KERN_DEBUG "please mail id, board name, and, " 835 840 "if it works, the correct digital_rate option to " -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106.h
r32 r76 6 6 * FEATURES currently supported: 7 7 * See ca0106_main.c for features. 8 * 8 * 9 9 * Changelog: 10 10 * Support interrupts per period. … … 154 154 * bit 9 0 = Mute / 1 = Analog out. 155 155 * bit 10 0 = Line-in / 1 = Mic-in. 156 157 156 * bit 11 0 = ? / 1 = ? 157 * bit 12 0 = 48 Khz / 1 = 96 Khz Analog out on SB Live 24bit. 158 158 * bit 13 0 = ? / 1 = ? 159 159 * bit 14 0 = Mute / 1 = Analog out … … 173 173 /* CA0106 pointer-offset register set, accessed through the PTR and DATA registers */ 174 174 /********************************************************************************************************/ 175 175 176 176 /* Initally all registers from 0x00 to 0x3f have zero contents. */ 177 177 #define PLAYBACK_LIST_ADDR 0x00 /* Base DMA address of a list of pointers to each period/size */ 178 /* One list entry: 4 bytes for DMA address, 178 /* One list entry: 4 bytes for DMA address, 179 179 * 4 bytes for period_size << 16. 180 180 * One list entry is 8 bytes long. … … 218 218 * Playback mixer out enable [31:28] (one bit per channel) 219 219 */ 220 /* The Digital out jack is shared with the Center/LFE Analogue output. 220 /* The Digital out jack is shared with the Center/LFE Analogue output. 221 221 * The jack has 4 poles. I will call 1 - Tip, 2 - Next to 1, 3 - Next to 2, 4 - Next to 3 222 222 * For Analogue: 1 -> Center Speaker, 2 -> Sub Woofer, 3 -> Ground, 4 -> Ground … … 231 231 */ 232 232 /* A standard 2 pole mono mini-jack to RCA plug can be used for SPDIF Stereo PCM output from the Front channel. 233 * A standard 3 pole stereo mini-jack to 2 RCA plugs can be used for SPDIF AC3/DTS and Stereo PCM output utilising the Rear channel and just one of the RCA plugs. 233 * A standard 3 pole stereo mini-jack to 2 RCA plugs can be used for SPDIF AC3/DTS and Stereo PCM output utilising the Rear channel and just one of the RCA plugs. 234 234 */ 235 235 #define SPCS0 0x41 /* SPDIF output Channel Status 0 register. For Rear. default=0x02108004, non-audio=0x02108006 */ … … 331 331 #define CAPTURE_SOURCE_CHANNEL3 0x000f0000 /* 3 - Mic in, Line in, TAD in, Aux in. */ 332 332 #define CAPTURE_SOURCE_RECORD_MAP 0x0000ffff /* Default 0x00e4 */ 333 /* Record Map [7:0] (2 bits per channel) 0=mapped to channel 0, 1=mapped to channel 1, 2=mapped to channel2, 3=mapped to channel3 333 /* Record Map [7:0] (2 bits per channel) 0=mapped to channel 0, 1=mapped to channel 1, 2=mapped to channel2, 3=mapped to channel3 334 334 * Record source select for channel 0 [18:16] 335 335 * Record source select for channel 1 [22:20] … … 400 400 /* Similar to register 0x66, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */ 401 401 #define UNKNOWN6b 0x6b /* Unknown. Readonly. Default 00400000 00400000 00400000 00400000 */ 402 #define UART_A_DATA 0x6c /* Uart, used in setting sample rates, bits per sample etc. */ 403 #define UART_A_CMD 0x6d /* Uart, used in setting sample rates, bits per sample etc. */ 404 #define UART_B_DATA 0x6e /* Uart, Unknown. */ 405 #define UART_B_CMD 0x6f /* Uart, Unknown. */ 402 #define MIDI_UART_A_DATA 0x6c /* Midi Uart A Data */ 403 #define MIDI_UART_A_CMD 0x6d /* Midi Uart A Command/Status */ 404 #define MIDI_UART_B_DATA 0x6e /* Midi Uart B Data (currently unused) */ 405 #define MIDI_UART_B_CMD 0x6f /* Midi Uart B Command/Status (currently unused) */ 406 407 /* unique channel identifier for midi->channel */ 408 409 #define CA0106_MIDI_CHAN_A 0x1 410 #define CA0106_MIDI_CHAN_B 0x2 411 412 /* from mpu401 */ 413 414 #define CA0106_MIDI_INPUT_AVAIL 0x80 415 #define CA0106_MIDI_OUTPUT_READY 0x40 416 #define CA0106_MPU401_RESET 0xff 417 #define CA0106_MPU401_ENTER_UART 0x3f 418 #define CA0106_MPU401_ACK 0xfe 419 406 420 #define SAMPLE_RATE_TRACKER_STATUS 0x70 /* Readonly. Default 00108000 00108000 00500000 00500000 */ 407 421 /* Estimated sample rate [19:0] Relative to 48kHz. 0x8000 = 1.0 … … 418 432 * SRC input source select [4] 0=Audio from digital mixer, 1=Audio from analog source. 419 433 * Record rate [9:8] (0=48kHz, 1=Not available, 2=96kHz, 3=192Khz) 420 * Record mixer output enable [12:10] 434 * Record mixer output enable [12:10] 421 435 * I2S input rate master mode [15:14] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz) 422 436 * I2S output rate [17:16] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz) … … 431 445 * Record Source 0 input [29:28] (0=SPDIF in, 1=I2S in, 2=AC97 Mic, 3=AC97 PCM) 432 446 * Record Source 1 input [31:30] (0=SPDIF in, 1=I2S in, 2=AC97 Mic, 3=AC97 PCM) 433 */ 447 */ 434 448 /* Sample rate output control register Channel=1 435 449 * I2S Input 0 volume Right [7:0] … … 453 467 * I2S output enable [19:16] 454 468 * SPDIF output enable [27:24] 455 */ 469 */ 456 470 #define UNKNOWN73 0x73 /* Unknown. Readonly. Default 0x0 */ 457 471 #define CHIP_VERSION 0x74 /* P17 Chip version. Channel_id 0 only. Default 00000071 */ … … 478 492 #define SPI 0x7a /* SPI: Serial Interface Register */ 479 493 #define I2C_A 0x7b /* I2C Address. 32 bit */ 480 #define I2C_D0 0x7c/* I2C Data Port 0. 32 bit */481 #define I2C_D1 0x7d/* I2C Data Port 1. 32 bit */494 #define I2C_D0 0x7c /* I2C Data Port 0. 32 bit */ 495 #define I2C_D1 0x7d /* I2C Data Port 1. 32 bit */ 482 496 //I2C values 483 #define I2C_A_ADC_ADD_MASK 0x000000fe//The address is a 7 bit address484 #define I2C_A_ADC_RW_MASK 0x00000001//bit mask for R/W485 #define I2C_A_ADC_TRANS_MASK 0x00000010//Bit mask for I2c address DAC value486 #define I2C_A_ADC_ABORT_MASK 0x00000020//Bit mask for I2C transaction abort flag487 #define I2C_A_ADC_LAST_MASK 0x00000040//Bit mask for Last word transaction488 #define I2C_A_ADC_BYTE_MASK 0x00000080//Bit mask for Byte Mode489 490 #define I2C_A_ADC_ADD 0x00000034 //This is the Device address for ADC491 #define I2C_A_ADC_READ 0x00000001//To perform a read operation492 #define I2C_A_ADC_START 0x00000100//Start I2C transaction493 #define I2C_A_ADC_ABORT 0x00000200//I2C transaction abort494 #define I2C_A_ADC_LAST 0x00000400//I2C last transaction495 #define I2C_A_ADC_BYTE 0x00000800//I2C one byte mode496 497 #define I2C_D_ADC_REG_MASK 0xfe000000 //ADC address register498 #define I2C_D_ADC_DAT_MASK 0x01ff0000//ADC data register499 500 #define ADC_TIMEOUT 0x00000007//ADC Timeout Clock Disable501 #define ADC_IFC_CTRL 0x0000000b//ADC Interface Control502 #define ADC_MASTER 0x0000000c//ADC Master Mode Control503 #define ADC_POWER 0x0000000d//ADC PowerDown Control504 #define ADC_ATTEN_ADCL 0x0000000e//ADC Attenuation ADCL505 #define ADC_ATTEN_ADCR 0x0000000f//ADC Attenuation ADCR506 #define ADC_ALC_CTRL1 0x00000010//ADC ALC Control 1507 #define ADC_ALC_CTRL2 0x00000011//ADC ALC Control 2508 #define ADC_ALC_CTRL3 0x00000012//ADC ALC Control 3509 #define ADC_NOISE_CTRL 0x00000013//ADC Noise Gate Control510 #define ADC_LIMIT_CTRL 0x00000014//ADC Limiter Control511 #define ADC_MUX 0x00000015//ADC Mux offset497 #define I2C_A_ADC_ADD_MASK 0x000000fe //The address is a 7 bit address 498 #define I2C_A_ADC_RW_MASK 0x00000001 //bit mask for R/W 499 #define I2C_A_ADC_TRANS_MASK 0x00000010 //Bit mask for I2c address DAC value 500 #define I2C_A_ADC_ABORT_MASK 0x00000020 //Bit mask for I2C transaction abort flag 501 #define I2C_A_ADC_LAST_MASK 0x00000040 //Bit mask for Last word transaction 502 #define I2C_A_ADC_BYTE_MASK 0x00000080 //Bit mask for Byte Mode 503 504 #define I2C_A_ADC_ADD 0x00000034 //This is the Device address for ADC 505 #define I2C_A_ADC_READ 0x00000001 //To perform a read operation 506 #define I2C_A_ADC_START 0x00000100 //Start I2C transaction 507 #define I2C_A_ADC_ABORT 0x00000200 //I2C transaction abort 508 #define I2C_A_ADC_LAST 0x00000400 //I2C last transaction 509 #define I2C_A_ADC_BYTE 0x00000800 //I2C one byte mode 510 511 #define I2C_D_ADC_REG_MASK 0xfe000000 //ADC address register 512 #define I2C_D_ADC_DAT_MASK 0x01ff0000 //ADC data register 513 514 #define ADC_TIMEOUT 0x00000007 //ADC Timeout Clock Disable 515 #define ADC_IFC_CTRL 0x0000000b //ADC Interface Control 516 #define ADC_MASTER 0x0000000c //ADC Master Mode Control 517 #define ADC_POWER 0x0000000d //ADC PowerDown Control 518 #define ADC_ATTEN_ADCL 0x0000000e //ADC Attenuation ADCL 519 #define ADC_ATTEN_ADCR 0x0000000f //ADC Attenuation ADCR 520 #define ADC_ALC_CTRL1 0x00000010 //ADC ALC Control 1 521 #define ADC_ALC_CTRL2 0x00000011 //ADC ALC Control 2 522 #define ADC_ALC_CTRL3 0x00000012 //ADC ALC Control 3 523 #define ADC_NOISE_CTRL 0x00000013 //ADC Noise Gate Control 524 #define ADC_LIMIT_CTRL 0x00000014 //ADC Limiter Control 525 #define ADC_MUX 0x00000015 //ADC Mux offset 512 526 513 527 #if 0 514 528 /* FIXME: Not tested yet. */ 515 #define ADC_GAIN_MASK 0x000000ff//Mask for ADC Gain516 #define ADC_ZERODB 0x000000cf//Value to set ADC to 0dB517 #define ADC_MUTE_MASK 0x000000c0//Mask for ADC mute518 #define ADC_MUTE 0x000000c0//Value to mute ADC519 #define ADC_OSR 0x00000008//Mask for ADC oversample rate select520 #define ADC_TIMEOUT_DISABLE 0x00000008//Value and mask to disable Timeout clock521 #define ADC_HPF_DISABLE 0x00000100//Value and mask to disable High pass filter522 #define ADC_TRANWIN_MASK 0x00000070//Mask for Length of Transient Window529 #define ADC_GAIN_MASK 0x000000ff //Mask for ADC Gain 530 #define ADC_ZERODB 0x000000cf //Value to set ADC to 0dB 531 #define ADC_MUTE_MASK 0x000000c0 //Mask for ADC mute 532 #define ADC_MUTE 0x000000c0 //Value to mute ADC 533 #define ADC_OSR 0x00000008 //Mask for ADC oversample rate select 534 #define ADC_TIMEOUT_DISABLE 0x00000008 //Value and mask to disable Timeout clock 535 #define ADC_HPF_DISABLE 0x00000100 //Value and mask to disable High pass filter 536 #define ADC_TRANWIN_MASK 0x00000070 //Mask for Length of Transient Window 523 537 #endif 524 538 525 #define ADC_MUX_MASK 0x0000000f//Mask for ADC Mux526 #define ADC_MUX_MIC 0x00000002//Value to select Mic at ADC Mux527 #define ADC_MUX_LINEIN 0x00000004//Value to select LineIn at ADC Mux528 #define ADC_MUX_PHONE 0x00000001//Value to select TAD at ADC Mux (Not used)529 #define ADC_MUX_AUX 0x00000008//Value to select Aux at ADC Mux539 #define ADC_MUX_MASK 0x0000000f //Mask for ADC Mux 540 #define ADC_MUX_MIC 0x00000002 //Value to select Mic at ADC Mux 541 #define ADC_MUX_LINEIN 0x00000004 //Value to select LineIn at ADC Mux 542 #define ADC_MUX_PHONE 0x00000001 //Value to select TAD at ADC Mux (Not used) 543 #define ADC_MUX_AUX 0x00000008 //Value to select Aux at ADC Mux 530 544 531 545 #define SET_CHANNEL 0 /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */ … … 539 553 #define CONTROL_UNKNOWN_CHANNEL 2 540 554 541 typedef struct snd_ca0106_channel ca0106_channel_t; 542 typedef struct snd_ca0106 ca0106_t; 543 typedef struct snd_ca0106_pcm ca0106_pcm_t;555 #include "ca_midi.h" 556 557 struct snd_ca0106; 544 558 545 559 struct snd_ca0106_channel { 546 ca0106_t*emu;560 struct snd_ca0106 *emu; 547 561 int number; 548 562 int use; 549 void (*interrupt)( ca0106_t *emu, ca0106_channel_t*channel);550 ca0106_pcm_t*epcm;563 void (*interrupt)(struct snd_ca0106 *emu, struct snd_ca0106_channel *channel); 564 struct snd_ca0106_pcm *epcm; 551 565 }; 552 566 553 567 struct snd_ca0106_pcm { 554 ca0106_t*emu;555 s nd_pcm_substream_t*substream;568 struct snd_ca0106 *emu; 569 struct snd_pcm_substream *substream; 556 570 int channel_id; 557 571 unsigned short running; 558 572 }; 559 573 560 typedef struct { 561 u32 serial; 562 char * name; 563 int ac97; 564 int gpio_type; 565 int i2c_adc; 566 } ca0106_details_t; 574 struct snd_ca0106_details { 575 u32 serial; 576 char * name; 577 int ac97; 578 int gpio_type; 579 int i2c_adc; 580 int spi_dac; 581 }; 567 582 568 583 // definition of the chip-specific record 569 584 struct snd_ca0106 { 570 snd_card_t *card; 571 ca0106_details_t *details; 572 struct pci_dev *pci; 573 574 unsigned long port; 575 struct resource *res_port; 576 int irq; 577 578 unsigned int revision; /* chip revision */ 579 unsigned int serial; /* serial number */ 580 unsigned short model; /* subsystem id */ 581 582 spinlock_t emu_lock; 583 584 ac97_t *ac97; 585 snd_pcm_t *pcm; 586 587 ca0106_channel_t playback_channels[4]; 588 ca0106_channel_t capture_channels[4]; 589 u32 spdif_bits[4]; /* s/pdif out setup */ 590 int spdif_enable; 591 int capture_source; 592 int capture_mic_line_in; 593 594 struct snd_dma_buffer buffer; 585 struct snd_card *card; 586 struct snd_ca0106_details *details; 587 struct pci_dev *pci; 588 589 unsigned long port; 590 struct resource *res_port; 591 int irq; 592 593 unsigned int revision; /* chip revision */ 594 unsigned int serial; /* serial number */ 595 unsigned short model; /* subsystem id */ 596 597 spinlock_t emu_lock; 598 599 struct snd_ac97 *ac97; 600 struct snd_pcm *pcm; 601 602 struct snd_ca0106_channel playback_channels[4]; 603 struct snd_ca0106_channel capture_channels[4]; 604 u32 spdif_bits[4]; /* s/pdif out setup */ 605 int spdif_enable; 606 int capture_source; 607 int capture_mic_line_in; 608 609 struct snd_dma_buffer buffer; 610 611 struct snd_ca_midi midi; 612 struct snd_ca_midi midi2; 595 613 }; 596 614 597 int __devinit snd_ca0106_mixer(ca0106_t *emu); 598 int __devinit snd_ca0106_proc_init(ca0106_t * emu); 599 600 unsigned int snd_ca0106_ptr_read(ca0106_t * emu, 601 unsigned int reg, 602 unsigned int chn); 603 604 void snd_ca0106_ptr_write(ca0106_t *emu, 605 unsigned int reg, 606 unsigned int chn, 607 unsigned int data); 608 609 int snd_ca0106_i2c_write(ca0106_t *emu, u32 reg, u32 value); 615 int snd_ca0106_mixer(struct snd_ca0106 *emu); 616 int snd_ca0106_proc_init(struct snd_ca0106 * emu); 617 618 unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu, 619 unsigned int reg, 620 unsigned int chn); 621 622 void snd_ca0106_ptr_write(struct snd_ca0106 *emu, 623 unsigned int reg, 624 unsigned int chn, 625 unsigned int data); 626 627 int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value); 628 629 -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106_main.c
r32 r76 19 19 * unmute the MIC and turn up the MASTER Playback volume. 20 20 * So, to prevent feedback when capturing, minimise the "Capture feedback into Playback" volume. 21 * 21 * 22 22 * The only playback controls that currently do anything are: - 23 23 * Analog Front … … 27 27 * SPDIF Rear 28 28 * SPDIF Center/LFE 29 * 29 * 30 30 * For capture from Mic in or Line in. 31 31 * Digital/Analog ( switch must be in Analog mode for CAPTURE. ) 32 * 32 * 33 33 * CAPTURE feedback into PLAYBACK 34 * 34 * 35 35 * Changelog: 36 36 * Support interrupts per period. … … 105 105 * SPDIF Out control switches between Mic in and SPDIF out. 106 106 * No sound out or mic input working yet. 107 * 107 * 108 108 * GENERAL INFO: 109 109 * Model: SB0413 … … 138 138 #include <linux/pci.h> 139 139 #include <linux/slab.h> 140 //#include <linux/moduleparam.h> 140 #include <linux/moduleparam.h> 141 //#include <linux/dma-mapping.h> 141 142 #include <sound/core.h> 142 143 #include <sound/initval.h> … … 164 165 #include "ca0106.h" 165 166 166 static ca0106_details_t ca0106_chip_details[] = { 167 /* AudigyLS[SB0310] */ 168 { /*.serial = */0x10021102, 169 /*.name = */"AudigyLS [SB0310]", 170 /*.ac97 = */1,0,0 } , 171 /* Unknown AudigyLS that also says SB0310 on it */ 172 { /*.serial = */0x10051102, 173 /*.name = */"AudigyLS [SB0310b]", 174 /*.ac97 = */1,0,0 } , 175 /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */ 176 { /*.serial = */0x10061102, 177 /*.name = */"Live! 7.1 24bit [SB0410]",0, 178 /*.gpio_type = */1, 179 /*.i2c_adc = */1 } , 180 /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */ 181 { /*.serial = */0x10071102, 182 /*.name = */"Live! 7.1 24bit [SB0413]",0, 183 /*.gpio_type = */1, 184 /*.i2c_adc = */1 } , 185 /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ 186 { /*.serial = */0x10091462, 187 /*.name = */"MSI K8N Diamond MB [SB0438]",0, 188 /*.gpio_type = */1, 189 /*.i2c_adc = */1 } , 190 /* Shuttle XPC SD31P which has an onboard Creative Labs Sound Blaster Live! 24-bit EAX 191 * high-definition 7.1 audio processor". 192 * Added using info from andrewvegan in alsa bug #1298 193 */ 194 { .serial = 0x30381297, 195 .name = "Shuttle XPC SD31P [SD31P]", 196 .gpio_type = 1, 197 .i2c_adc = 1 } , 198 { /*.serial = */0, 199 /*.name = */"AudigyLS [Unknown]",0,0,0 } 167 static struct snd_ca0106_details ca0106_chip_details[] = { 168 /* AudigyLS[SB0310] */ 169 { .serial = 0x10021102, 170 .name = "AudigyLS [SB0310]", 171 .ac97 = 1 } , 172 /* Unknown AudigyLS that also says SB0310 on it */ 173 { .serial = 0x10051102, 174 .name = "AudigyLS [SB0310b]", 175 .ac97 = 1 } , 176 /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */ 177 { .serial = 0x10061102, 178 .name = "Live! 7.1 24bit [SB0410]", 179 .gpio_type = 1, 180 .i2c_adc = 1 } , 181 /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */ 182 { .serial = 0x10071102, 183 .name = "Live! 7.1 24bit [SB0413]", 184 .gpio_type = 1, 185 .i2c_adc = 1 } , 186 /* New Audigy SE. Has a different DAC. */ 187 /* SB0570: 188 * CTRL:CA0106-DAT 189 * ADC: WM8768GEDS 190 * DAC: WM8775EDS 191 */ 192 { .serial = 0x100a1102, 193 .name = "Audigy SE [SB0570]", 194 .gpio_type = 1, 195 .i2c_adc = 1, 196 .spi_dac = 1 } , 197 /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ 198 { .serial = 0x10091462, 199 .name = "MSI K8N Diamond MB [SB0438]", 200 .gpio_type = 1, 201 .i2c_adc = 1 } , 202 /* Shuttle XPC SD31P which has an onboard Creative Labs 203 * Sound Blaster Live! 24-bit EAX 204 * high-definition 7.1 audio processor". 205 * Added using info from andrewvegan in alsa bug #1298 206 */ 207 { .serial = 0x30381297, 208 .name = "Shuttle XPC SD31P [SD31P]", 209 .gpio_type = 1, 210 .i2c_adc = 1 } , 211 /* Shuttle XPC SD11G5 which has an onboard Creative Labs 212 * Sound Blaster Live! 24-bit EAX 213 * high-definition 7.1 audio processor". 214 * Fixes ALSA bug#1600 215 */ 216 { .serial = 0x30411297, 217 .name = "Shuttle XPC SD11G5 [SD11G5]", 218 .gpio_type = 1, 219 .i2c_adc = 1 } , 220 { .serial = 0, 221 .name = "AudigyLS [Unknown]" } 200 222 }; 201 223 202 224 /* hardware definition */ 203 static s nd_pcm_hardware_tsnd_ca0106_playback_hw = {204 /*.info = */(SNDRV_PCM_INFO_MMAP |225 static struct snd_pcm_hardware snd_ca0106_playback_hw = { 226 .info = (SNDRV_PCM_INFO_MMAP | 205 227 SNDRV_PCM_INFO_INTERLEAVED | 206 228 SNDRV_PCM_INFO_BLOCK_TRANSFER | 207 229 SNDRV_PCM_INFO_MMAP_VALID), 208 /*.formats = */SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 209 /*.rates = */SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, 210 /*.rate_min = */48000, 211 /*.rate_max = */192000, 212 /*.channels_min = */2, //1, 213 /*.channels_max = */2, //6, 214 /*.buffer_bytes_max = */((65536 - 64) * 8), 215 /*.period_bytes_min = */64, 216 /*.period_bytes_max = */(65536 - 64), 217 /*.periods_min = */2, 218 /*.periods_max = */8, 219 /*.fifo_size = */0, 230 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 231 .rates = (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | 232 SNDRV_PCM_RATE_192000), 233 .rate_min = 48000, 234 .rate_max = 192000, 235 .channels_min = 2, //1, 236 .channels_max = 2, //6, 237 .buffer_bytes_max = ((65536 - 64) * 8), 238 .period_bytes_min = 64, 239 .period_bytes_max = (65536 - 64), 240 .periods_min = 2, 241 .periods_max = 8, 242 .fifo_size = 0, 220 243 }; 221 244 222 static s nd_pcm_hardware_tsnd_ca0106_capture_hw = {223 /*.info = */ (SNDRV_PCM_INFO_MMAP |245 static struct snd_pcm_hardware snd_ca0106_capture_hw = { 246 .info = (SNDRV_PCM_INFO_MMAP | 224 247 SNDRV_PCM_INFO_INTERLEAVED | 225 248 SNDRV_PCM_INFO_BLOCK_TRANSFER | 226 249 SNDRV_PCM_INFO_MMAP_VALID), 227 /*.formats = */SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 228 /*.rates = */SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, 229 /*.rate_min = */44100, 230 /*.rate_max = */192000, 231 /*.channels_min = */2, 232 /*.channels_max = */2, 233 /*.buffer_bytes_max = */((65536 - 64) * 8), 234 /*.period_bytes_min = */64, 235 /*.period_bytes_max = */(65536 - 64), 236 /*.periods_min = */2, 237 /*.periods_max = */2, 238 /*.fifo_size = */0, 250 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 251 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 252 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000), 253 .rate_min = 44100, 254 .rate_max = 192000, 255 .channels_min = 2, 256 .channels_max = 2, 257 .buffer_bytes_max = ((65536 - 64) * 8), 258 .period_bytes_min = 64, 259 .period_bytes_max = (65536 - 64), 260 .periods_min = 2, 261 .periods_max = 2, 262 .fifo_size = 0, 239 263 }; 240 264 241 unsigned int snd_ca0106_ptr_read( ca0106_t * emu,242 unsigned int reg, 265 unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu, 266 unsigned int reg, 243 267 unsigned int chn) 244 268 { 245 269 unsigned long flags; 246 270 unsigned int regptr, val; 247 271 248 272 regptr = (reg << 16) | chn; 249 273 … … 255 279 } 256 280 257 void snd_ca0106_ptr_write( ca0106_t *emu,258 unsigned int reg, 259 unsigned int chn, 281 void snd_ca0106_ptr_write(struct snd_ca0106 *emu, 282 unsigned int reg, 283 unsigned int chn, 260 284 unsigned int data) 261 285 { … … 271 295 } 272 296 273 int snd_ca0106_i2c_write(ca0106_t *emu, 274 u32 reg, 275 u32 value) 276 { 277 u32 tmp; 278 int timeout=0; 279 int status; 280 int retry; 281 if ((reg > 0x7f) || (value > 0x1ff)) 282 { 283 snd_printk("i2c_write: invalid values.\n"); 284 return -EINVAL; 285 } 286 287 tmp = reg << 25 | value << 16; 288 /* Not sure what this I2C channel controls. */ 289 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ 290 291 /* This controls the I2C connected to the WM8775 ADC Codec */ 292 snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp); 293 294 for(retry=0;retry<10;retry++) 295 { 296 /* Send the data to i2c */ 297 tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); 298 tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); 299 tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); 300 snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); 301 302 /* Wait till the transaction ends */ 303 while(1) 304 { 305 status = snd_ca0106_ptr_read(emu, I2C_A, 0); 306 //snd_printk("I2C:status=0x%x\n", status); 307 timeout++; 308 if((status & I2C_A_ADC_START)==0) 309 break; 310 311 if(timeout>1000) 312 break; 313 } 314 //Read back and see if the transaction is successful 315 if((status & I2C_A_ADC_ABORT)==0) 316 break; 317 } 318 319 if(retry==10) 320 { 321 snd_printk("Writing to ADC failed!\n"); 322 return -EINVAL; 323 } 324 325 return 0; 326 } 327 328 329 static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) 297 int snd_ca0106_spi_write(struct snd_ca0106 * emu, 298 unsigned int data) 299 { 300 unsigned int reset, set; 301 unsigned int reg, tmp; 302 int n, result; 303 reg = SPI; 304 if (data > 0xffff) /* Only 16bit values allowed */ 305 return 1; 306 tmp = snd_ca0106_ptr_read(emu, reg, 0); 307 reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ 308 set = reset | 0x10000; /* Set xxx1xxxx */ 309 snd_ca0106_ptr_write(emu, reg, 0, reset | data); 310 tmp = snd_ca0106_ptr_read(emu, reg, 0); /* write post */ 311 snd_ca0106_ptr_write(emu, reg, 0, set | data); 312 result = 1; 313 /* Wait for status bit to return to 0 */ 314 for (n = 0; n < 100; n++) { 315 udelay(10); 316 tmp = snd_ca0106_ptr_read(emu, reg, 0); 317 if (!(tmp & 0x10000)) { 318 result = 0; 319 break; 320 } 321 } 322 if (result) /* Timed out */ 323 return 1; 324 snd_ca0106_ptr_write(emu, reg, 0, reset | data); 325 tmp = snd_ca0106_ptr_read(emu, reg, 0); /* Write post */ 326 return 0; 327 } 328 329 int snd_ca0106_i2c_write(struct snd_ca0106 *emu, 330 u32 reg, 331 u32 value) 332 { 333 u32 tmp; 334 int timeout = 0; 335 int status; 336 int retry; 337 if ((reg > 0x7f) || (value > 0x1ff)) { 338 snd_printk(KERN_ERR "i2c_write: invalid values.\n"); 339 return -EINVAL; 340 } 341 342 tmp = reg << 25 | value << 16; 343 /* Not sure what this I2C channel controls. */ 344 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ 345 346 /* This controls the I2C connected to the WM8775 ADC Codec */ 347 snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp); 348 349 for (retry = 0; retry < 10; retry++) { 350 /* Send the data to i2c */ 351 tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); 352 tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); 353 tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); 354 snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); 355 356 /* Wait till the transaction ends */ 357 while (1) { 358 status = snd_ca0106_ptr_read(emu, I2C_A, 0); 359 //snd_printk("I2C:status=0x%x\n", status); 360 timeout++; 361 if ((status & I2C_A_ADC_START) == 0) 362 break; 363 364 if (timeout > 1000) 365 break; 366 } 367 //Read back and see if the transaction is successful 368 if ((status & I2C_A_ADC_ABORT) == 0) 369 break; 370 } 371 372 if (retry == 10) { 373 snd_printk(KERN_ERR "Writing to ADC failed!\n"); 374 return -EINVAL; 375 } 376 377 return 0; 378 } 379 380 381 static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb) 330 382 { 331 383 unsigned long flags; 332 384 unsigned int enable; 333 385 334 386 spin_lock_irqsave(&emu->emu_lock, flags); 335 387 enable = inl(emu->port + INTE) | intrenb; … … 338 390 } 339 391 340 static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) 341 { 342 ca0106_pcm_t *epcm = runtime->private_data; 343 344 if (epcm) { 345 kfree(epcm); 346 } 392 static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb) 393 { 394 unsigned long flags; 395 unsigned int enable; 396 397 spin_lock_irqsave(&emu->emu_lock, flags); 398 enable = inl(emu->port + INTE) & ~intrenb; 399 outl(enable, emu->port + INTE); 400 spin_unlock_irqrestore(&emu->emu_lock, flags); 401 } 402 403 404 static void snd_ca0106_pcm_free_substream(struct snd_pcm_runtime *runtime) 405 { 406 kfree(runtime->private_data); 347 407 } 348 408 349 409 /* open_playback callback */ 350 static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id) 351 { 352 ca0106_t *chip = snd_pcm_substream_chip(substream); 353 ca0106_channel_t *channel = &(chip->playback_channels[channel_id]); 354 ca0106_pcm_t *epcm; 355 snd_pcm_runtime_t *runtime = substream->runtime; 410 static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, 411 int channel_id) 412 { 413 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); 414 struct snd_ca0106_channel *channel = &(chip->playback_channels[channel_id]); 415 struct snd_ca0106_pcm *epcm; 416 struct snd_pcm_runtime *runtime = substream->runtime; 356 417 int err; 357 418 358 epcm = k calloc(1,sizeof(*epcm), GFP_KERNEL);419 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 359 420 360 421 if (epcm == NULL) … … 363 424 epcm->substream = substream; 364 425 epcm->channel_id=channel_id; 365 426 366 427 runtime->private_data = epcm; 367 428 runtime->private_free = snd_ca0106_pcm_free_substream; 368 429 369 430 runtime->hw = snd_ca0106_playback_hw; 370 431 … … 372 433 channel->number = channel_id; 373 434 374 channel->use=1;435 channel->use = 1; 375 436 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); 376 437 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; 377 channel->epcm=epcm;438 channel->epcm = epcm; 378 439 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 379 440 return err; … … 384 445 385 446 /* close callback */ 386 static int snd_ca0106_pcm_close_playback(s nd_pcm_substream_t*substream)387 { 388 ca0106_t*chip = snd_pcm_substream_chip(substream);389 s nd_pcm_runtime_t*runtime = substream->runtime;390 ca0106_pcm_t*epcm = runtime->private_data;391 chip->playback_channels[epcm->channel_id].use=0;392 /* FIXME: maybe zero others */447 static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream) 448 { 449 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); 450 struct snd_pcm_runtime *runtime = substream->runtime; 451 struct snd_ca0106_pcm *epcm = runtime->private_data; 452 chip->playback_channels[epcm->channel_id].use = 0; 453 /* FIXME: maybe zero others */ 393 454 return 0; 394 455 } 395 456 396 static int snd_ca0106_pcm_open_playback_front(s nd_pcm_substream_t*substream)457 static int snd_ca0106_pcm_open_playback_front(struct snd_pcm_substream *substream) 397 458 { 398 459 return snd_ca0106_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); 399 460 } 400 461 401 static int snd_ca0106_pcm_open_playback_center_lfe(s nd_pcm_substream_t*substream)462 static int snd_ca0106_pcm_open_playback_center_lfe(struct snd_pcm_substream *substream) 402 463 { 403 464 return snd_ca0106_pcm_open_playback_channel(substream, PCM_CENTER_LFE_CHANNEL); 404 465 } 405 466 406 static int snd_ca0106_pcm_open_playback_unknown(s nd_pcm_substream_t*substream)467 static int snd_ca0106_pcm_open_playback_unknown(struct snd_pcm_substream *substream) 407 468 { 408 469 return snd_ca0106_pcm_open_playback_channel(substream, PCM_UNKNOWN_CHANNEL); 409 470 } 410 471 411 static int snd_ca0106_pcm_open_playback_rear(s nd_pcm_substream_t*substream)472 static int snd_ca0106_pcm_open_playback_rear(struct snd_pcm_substream *substream) 412 473 { 413 474 return snd_ca0106_pcm_open_playback_channel(substream, PCM_REAR_CHANNEL); … … 415 476 416 477 /* open_capture callback */ 417 static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) 418 { 419 ca0106_t *chip = snd_pcm_substream_chip(substream); 420 ca0106_channel_t *channel = &(chip->capture_channels[channel_id]); 421 ca0106_pcm_t *epcm; 422 snd_pcm_runtime_t *runtime = substream->runtime; 478 static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substream, 479 int channel_id) 480 { 481 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); 482 struct snd_ca0106_channel *channel = &(chip->capture_channels[channel_id]); 483 struct snd_ca0106_pcm *epcm; 484 struct snd_pcm_runtime *runtime = substream->runtime; 423 485 int err; 424 486 425 epcm = k calloc(1,sizeof(*epcm), GFP_KERNEL);487 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 426 488 if (epcm == NULL) { 427 snd_printk("open_capture_channel: failed epcm alloc\n");489 snd_printk(KERN_ERR "open_capture_channel: failed epcm alloc\n"); 428 490 return -ENOMEM; 429 491 } … … 431 493 epcm->substream = substream; 432 494 epcm->channel_id=channel_id; 433 495 434 496 runtime->private_data = epcm; 435 497 runtime->private_free = snd_ca0106_pcm_free_substream; 436 498 437 499 runtime->hw = snd_ca0106_capture_hw; 438 500 … … 440 502 channel->number = channel_id; 441 503 442 channel->use=1;504 channel->use = 1; 443 505 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); 444 506 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; 445 channel->epcm =epcm;507 channel->epcm = epcm; 446 508 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 447 509 return err; … … 453 515 454 516 /* close callback */ 455 static int snd_ca0106_pcm_close_capture(s nd_pcm_substream_t*substream)456 { 457 ca0106_t*chip = snd_pcm_substream_chip(substream);458 s nd_pcm_runtime_t*runtime = substream->runtime;459 ca0106_pcm_t*epcm = runtime->private_data;460 chip->capture_channels[epcm->channel_id].use=0;461 /* FIXME: maybe zero others */517 static int snd_ca0106_pcm_close_capture(struct snd_pcm_substream *substream) 518 { 519 struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); 520 struct snd_pcm_runtime *runtime = substream->runtime; 521 struct snd_ca0106_pcm *epcm = runtime->private_data; 522 chip->capture_channels[epcm->channel_id].use = 0; 523 /* FIXME: maybe zero others */ 462 524 return 0; 463 525 } 464 526 465 static int snd_ca0106_pcm_open_0_capture(s nd_pcm_substream_t*substream)527 static int snd_ca0106_pcm_open_0_capture(struct snd_pcm_substream *substream) 466 528 { 467 529 return snd_ca0106_pcm_open_capture_channel(substream, 0); 468 530 } 469 531 470 static int snd_ca0106_pcm_open_1_capture(s nd_pcm_substream_t*substream)532 static int snd_ca0106_pcm_open_1_capture(struct snd_pcm_substream *substream) 471 533 { 472 534 return snd_ca0106_pcm_open_capture_channel(substream, 1); 473 535 } 474 536 475 static int snd_ca0106_pcm_open_2_capture(s nd_pcm_substream_t*substream)537 static int snd_ca0106_pcm_open_2_capture(struct snd_pcm_substream *substream) 476 538 { 477 539 return snd_ca0106_pcm_open_capture_channel(substream, 2); 478 540 } 479 541 480 static int snd_ca0106_pcm_open_3_capture(s nd_pcm_substream_t*substream)542 static int snd_ca0106_pcm_open_3_capture(struct snd_pcm_substream *substream) 481 543 { 482 544 return snd_ca0106_pcm_open_capture_channel(substream, 3); … … 484 546 485 547 /* hw_params callback */ 486 static int snd_ca0106_pcm_hw_params_playback(s nd_pcm_substream_t*substream,487 s nd_pcm_hw_params_t *hw_params)548 static int snd_ca0106_pcm_hw_params_playback(struct snd_pcm_substream *substream, 549 struct snd_pcm_hw_params *hw_params) 488 550 { 489 551 return snd_pcm_lib_malloc_pages(substream, … … 492 554 493 555 /* hw_free callback */ 494 static int snd_ca0106_pcm_hw_free_playback(s nd_pcm_substream_t*substream)556 static int snd_ca0106_pcm_hw_free_playback(struct snd_pcm_substream *substream) 495 557 { 496 558 return snd_pcm_lib_free_pages(substream); … … 498 560 499 561 /* hw_params callback */ 500 static int snd_ca0106_pcm_hw_params_capture(s nd_pcm_substream_t*substream,501 s nd_pcm_hw_params_t *hw_params)562 static int snd_ca0106_pcm_hw_params_capture(struct snd_pcm_substream *substream, 563 struct snd_pcm_hw_params *hw_params) 502 564 { 503 565 return snd_pcm_lib_malloc_pages(substream, … … 506 568 507 569 /* hw_free callback */ 508 static int snd_ca0106_pcm_hw_free_capture(s nd_pcm_substream_t*substream)570 static int snd_ca0106_pcm_hw_free_capture(struct snd_pcm_substream *substream) 509 571 { 510 572 return snd_pcm_lib_free_pages(substream); … … 512 574 513 575 /* prepare playback callback */ 514 static int snd_ca0106_pcm_prepare_playback(s nd_pcm_substream_t*substream)515 { 516 ca0106_t*emu = snd_pcm_substream_chip(substream);517 s nd_pcm_runtime_t*runtime = substream->runtime;518 ca0106_pcm_t*epcm = runtime->private_data;576 static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream) 577 { 578 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 579 struct snd_pcm_runtime *runtime = substream->runtime; 580 struct snd_ca0106_pcm *epcm = runtime->private_data; 519 581 int channel = epcm->channel_id; 520 582 u32 *table_base = (u32 *)(emu->buffer.area+(8*16*channel)); … … 531 593 u32 reg71; 532 594 int i; 533 595 534 596 //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); 535 597 //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); … … 541 603 case 44100: 542 604 reg40_set = 0x10000 << (channel<<1); 543 reg71_set = 0x01010000; 605 reg71_set = 0x01010000; 544 606 break; 545 607 case 48000: 546 608 reg40_set = 0; 547 reg71_set = 0; 609 reg71_set = 0; 548 610 break; 549 611 case 96000: 550 612 reg40_set = 0x20000 << (channel<<1); 551 reg71_set = 0x02020000; 613 reg71_set = 0x02020000; 552 614 break; 553 615 case 192000: 554 616 reg40_set = 0x30000 << (channel<<1); 555 reg71_set = 0x03030000; 617 reg71_set = 0x03030000; 556 618 break; 557 619 default: 558 620 reg40_set = 0; 559 reg71_set = 0; 621 reg71_set = 0; 560 622 break; 561 623 } … … 585 647 /* FIXME: Check emu->buffer.size before actually writing to it. */ 586 648 for(i=0; i < runtime->periods; i++) { 587 table_base[i*2] =runtime->dma_addr+(i*period_size_bytes);588 table_base[ (i*2)+1]=period_size_bytes<<16;589 } 590 649 table_base[i*2] = runtime->dma_addr + (i * period_size_bytes); 650 table_base[i*2+1] = period_size_bytes << 16; 651 } 652 591 653 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer.addr+(8*16*channel)); 592 654 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); 593 655 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_PTR, channel, 0); 594 656 snd_ca0106_ptr_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); 595 596 597 657 snd_ca0106_ptr_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes 658 /* FIXME test what 0 bytes does. */ 659 snd_ca0106_ptr_write(emu, PLAYBACK_PERIOD_SIZE, channel, 0); // buffer size in bytes 598 660 snd_ca0106_ptr_write(emu, PLAYBACK_POINTER, channel, 0); 599 661 snd_ca0106_ptr_write(emu, 0x07, channel, 0x0); … … 613 675 614 676 /* prepare capture callback */ 615 static int snd_ca0106_pcm_prepare_capture(s nd_pcm_substream_t*substream)616 { 617 ca0106_t*emu = snd_pcm_substream_chip(substream);618 s nd_pcm_runtime_t*runtime = substream->runtime;619 ca0106_pcm_t*epcm = runtime->private_data;620 621 622 623 624 625 626 627 628 677 static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream) 678 { 679 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 680 struct snd_pcm_runtime *runtime = substream->runtime; 681 struct snd_ca0106_pcm *epcm = runtime->private_data; 682 int channel = epcm->channel_id; 683 u32 hcfg_mask = HCFG_CAPTURE_S32_LE; 684 u32 hcfg_set = 0x00000000; 685 u32 hcfg; 686 u32 over_sampling=0x2; 687 u32 reg71_mask = 0x0000c000 ; /* Global. Set ADC rate. */ 688 u32 reg71_set = 0; 689 u32 reg71; 690 629 691 //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); 630 692 //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); 631 632 633 634 635 636 693 //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); 694 /* reg71 controls ADC rate. */ 695 switch (runtime->rate) { 696 case 44100: 697 reg71_set = 0x00004000; 698 break; 637 699 case 48000: 638 reg71_set = 0; 639 640 641 642 643 644 645 reg71_set = 0x0000c000; 646 647 648 649 reg71_set = 0; 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 700 reg71_set = 0; 701 break; 702 case 96000: 703 reg71_set = 0x00008000; 704 over_sampling=0xa; 705 break; 706 case 192000: 707 reg71_set = 0x0000c000; 708 over_sampling=0xa; 709 break; 710 default: 711 reg71_set = 0; 712 break; 713 } 714 /* Format is a global setting */ 715 /* FIXME: Only let the first channel accessed set this. */ 716 switch (runtime->format) { 717 case SNDRV_PCM_FORMAT_S16_LE: 718 hcfg_set = 0; 719 break; 720 case SNDRV_PCM_FORMAT_S32_LE: 721 hcfg_set = HCFG_CAPTURE_S32_LE; 722 break; 723 default: 724 hcfg_set = 0; 725 break; 726 } 727 hcfg = inl(emu->port + HCFG) ; 728 hcfg = (hcfg & ~hcfg_mask) | hcfg_set; 729 outl(hcfg, emu->port + HCFG); 730 reg71 = snd_ca0106_ptr_read(emu, 0x71, 0); 731 reg71 = (reg71 & ~reg71_mask) | reg71_set; 732 snd_ca0106_ptr_write(emu, 0x71, 0, reg71); 671 733 if (emu->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ 672 673 734 snd_ca0106_i2c_write(emu, ADC_MASTER, over_sampling); /* Adjust the over sampler to better suit the capture rate. */ 735 } 674 736 675 737 … … 684 746 685 747 /* trigger_playback callback */ 686 static int snd_ca0106_pcm_trigger_playback(s nd_pcm_substream_t*substream,748 static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream, 687 749 int cmd) 688 750 { 689 ca0106_t*emu = snd_pcm_substream_chip(substream);690 s nd_pcm_runtime_t*runtime;691 ca0106_pcm_t*epcm;751 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 752 struct snd_pcm_runtime *runtime; 753 struct snd_ca0106_pcm *epcm; 692 754 int channel; 693 755 int result = 0; 694 756 struct list_head *pos; 695 s nd_pcm_substream_t*s;757 struct snd_pcm_substream *s; 696 758 u32 basic = 0; 697 759 u32 extended = 0; … … 737 799 738 800 /* trigger_capture callback */ 739 static int snd_ca0106_pcm_trigger_capture(s nd_pcm_substream_t*substream,801 static int snd_ca0106_pcm_trigger_capture(struct snd_pcm_substream *substream, 740 802 int cmd) 741 803 { 742 ca0106_t*emu = snd_pcm_substream_chip(substream);743 s nd_pcm_runtime_t*runtime = substream->runtime;744 ca0106_pcm_t*epcm = runtime->private_data;804 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 805 struct snd_pcm_runtime *runtime = substream->runtime; 806 struct snd_ca0106_pcm *epcm = runtime->private_data; 745 807 int channel = epcm->channel_id; 746 808 int result = 0; … … 766 828 /* pointer_playback callback */ 767 829 static snd_pcm_uframes_t 768 snd_ca0106_pcm_pointer_playback(s nd_pcm_substream_t*substream)769 { 770 ca0106_t*emu = snd_pcm_substream_chip(substream);771 s nd_pcm_runtime_t*runtime = substream->runtime;772 ca0106_pcm_t*epcm = runtime->private_data;830 snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream) 831 { 832 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 833 struct snd_pcm_runtime *runtime = substream->runtime; 834 struct snd_ca0106_pcm *epcm = runtime->private_data; 773 835 snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; 774 836 int channel = epcm->channel_id; … … 793 855 /* pointer_capture callback */ 794 856 static snd_pcm_uframes_t 795 snd_ca0106_pcm_pointer_capture(s nd_pcm_substream_t*substream)796 { 797 ca0106_t*emu = snd_pcm_substream_chip(substream);798 s nd_pcm_runtime_t*runtime = substream->runtime;799 ca0106_pcm_t*epcm = runtime->private_data;857 snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream) 858 { 859 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 860 struct snd_pcm_runtime *runtime = substream->runtime; 861 struct snd_ca0106_pcm *epcm = runtime->private_data; 800 862 snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; 801 863 int channel = channel=epcm->channel_id; … … 815 877 816 878 /* operators */ 817 static snd_pcm_ops_t snd_ca0106_playback_front_ops = { 818 /*.open = */snd_ca0106_pcm_open_playback_front, 819 /*.close = */snd_ca0106_pcm_close_playback, 820 /*.ioctl = */snd_pcm_lib_ioctl, 821 /*.hw_params = */snd_ca0106_pcm_hw_params_playback, 822 /*.hw_free = */snd_ca0106_pcm_hw_free_playback, 823 /*.prepare = */snd_ca0106_pcm_prepare_playback, 824 /*.trigger = */snd_ca0106_pcm_trigger_playback, 825 /*.pointer = */snd_ca0106_pcm_pointer_playback, 826 0,0,0,0 879 static struct snd_pcm_ops snd_ca0106_playback_front_ops = { 880 .open = snd_ca0106_pcm_open_playback_front, 881 .close = snd_ca0106_pcm_close_playback, 882 .ioctl = snd_pcm_lib_ioctl, 883 .hw_params = snd_ca0106_pcm_hw_params_playback, 884 .hw_free = snd_ca0106_pcm_hw_free_playback, 885 .prepare = snd_ca0106_pcm_prepare_playback, 886 .trigger = snd_ca0106_pcm_trigger_playback, 887 .pointer = snd_ca0106_pcm_pointer_playback, 827 888 }; 828 889 829 static snd_pcm_ops_t snd_ca0106_capture_0_ops = { 830 /*.open = */snd_ca0106_pcm_open_0_capture, 831 /*.close = */snd_ca0106_pcm_close_capture, 832 /*.ioctl = */snd_pcm_lib_ioctl, 833 /*.hw_params = */snd_ca0106_pcm_hw_params_capture, 834 /*.hw_free = */snd_ca0106_pcm_hw_free_capture, 835 /*.prepare = */snd_ca0106_pcm_prepare_capture, 836 /*.trigger = */snd_ca0106_pcm_trigger_capture, 837 /*.pointer = */snd_ca0106_pcm_pointer_capture, 838 0,0,0,0 890 static struct snd_pcm_ops snd_ca0106_capture_0_ops = { 891 .open = snd_ca0106_pcm_open_0_capture, 892 .close = snd_ca0106_pcm_close_capture, 893 .ioctl = snd_pcm_lib_ioctl, 894 .hw_params = snd_ca0106_pcm_hw_params_capture, 895 .hw_free = snd_ca0106_pcm_hw_free_capture, 896 .prepare = snd_ca0106_pcm_prepare_capture, 897 .trigger = snd_ca0106_pcm_trigger_capture, 898 .pointer = snd_ca0106_pcm_pointer_capture, 839 899 }; 840 900 841 static snd_pcm_ops_t snd_ca0106_capture_1_ops = { 842 /*.open = */snd_ca0106_pcm_open_1_capture, 843 /*.close = */snd_ca0106_pcm_close_capture, 844 /*.ioctl = */snd_pcm_lib_ioctl, 845 /*.hw_params = */snd_ca0106_pcm_hw_params_capture, 846 /*.hw_free = */snd_ca0106_pcm_hw_free_capture, 847 /*.prepare = */snd_ca0106_pcm_prepare_capture, 848 /*.trigger = */snd_ca0106_pcm_trigger_capture, 849 /*.pointer = */snd_ca0106_pcm_pointer_capture, 850 0,0,0,0 901 static struct snd_pcm_ops snd_ca0106_capture_1_ops = { 902 .open = snd_ca0106_pcm_open_1_capture, 903 .close = snd_ca0106_pcm_close_capture, 904 .ioctl = snd_pcm_lib_ioctl, 905 .hw_params = snd_ca0106_pcm_hw_params_capture, 906 .hw_free = snd_ca0106_pcm_hw_free_capture, 907 .prepare = snd_ca0106_pcm_prepare_capture, 908 .trigger = snd_ca0106_pcm_trigger_capture, 909 .pointer = snd_ca0106_pcm_pointer_capture, 851 910 }; 852 911 853 static snd_pcm_ops_t snd_ca0106_capture_2_ops = { 854 /*.open = */snd_ca0106_pcm_open_2_capture, 855 /*.close = */snd_ca0106_pcm_close_capture, 856 /*.ioctl = */snd_pcm_lib_ioctl, 857 /*.hw_params = */snd_ca0106_pcm_hw_params_capture, 858 /*.hw_free = */snd_ca0106_pcm_hw_free_capture, 859 /*.prepare = */snd_ca0106_pcm_prepare_capture, 860 /*.trigger = */snd_ca0106_pcm_trigger_capture, 861 /*.pointer = */snd_ca0106_pcm_pointer_capture, 862 0,0,0,0 912 static struct snd_pcm_ops snd_ca0106_capture_2_ops = { 913 .open = snd_ca0106_pcm_open_2_capture, 914 .close = snd_ca0106_pcm_close_capture, 915 .ioctl = snd_pcm_lib_ioctl, 916 .hw_params = snd_ca0106_pcm_hw_params_capture, 917 .hw_free = snd_ca0106_pcm_hw_free_capture, 918 .prepare = snd_ca0106_pcm_prepare_capture, 919 .trigger = snd_ca0106_pcm_trigger_capture, 920 .pointer = snd_ca0106_pcm_pointer_capture, 863 921 }; 864 922 865 static snd_pcm_ops_t snd_ca0106_capture_3_ops = { 866 /*.open = */snd_ca0106_pcm_open_3_capture, 867 /*.close = */snd_ca0106_pcm_close_capture, 868 /*.ioctl = */snd_pcm_lib_ioctl, 869 /*.hw_params = */snd_ca0106_pcm_hw_params_capture, 870 /*.hw_free = */snd_ca0106_pcm_hw_free_capture, 871 /*.prepare = */snd_ca0106_pcm_prepare_capture, 872 /*.trigger = */snd_ca0106_pcm_trigger_capture, 873 /*.pointer = */snd_ca0106_pcm_pointer_capture, 874 0,0,0,0 923 static struct snd_pcm_ops snd_ca0106_capture_3_ops = { 924 .open = snd_ca0106_pcm_open_3_capture, 925 .close = snd_ca0106_pcm_close_capture, 926 .ioctl = snd_pcm_lib_ioctl, 927 .hw_params = snd_ca0106_pcm_hw_params_capture, 928 .hw_free = snd_ca0106_pcm_hw_free_capture, 929 .prepare = snd_ca0106_pcm_prepare_capture, 930 .trigger = snd_ca0106_pcm_trigger_capture, 931 .pointer = snd_ca0106_pcm_pointer_capture, 875 932 }; 876 933 877 static snd_pcm_ops_t snd_ca0106_playback_center_lfe_ops = { 878 /*.open = */snd_ca0106_pcm_open_playback_center_lfe, 879 /*.close = */snd_ca0106_pcm_close_playback, 880 /*.ioctl = */snd_pcm_lib_ioctl, 881 /*.hw_params = */snd_ca0106_pcm_hw_params_playback, 882 /*.hw_free = */snd_ca0106_pcm_hw_free_playback, 883 /*.prepare = */snd_ca0106_pcm_prepare_playback, 884 /*.trigger = */snd_ca0106_pcm_trigger_playback, 885 /*.pointer = */snd_ca0106_pcm_pointer_playback, 886 0,0,0,0 934 static struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { 935 .open = snd_ca0106_pcm_open_playback_center_lfe, 936 .close = snd_ca0106_pcm_close_playback, 937 .ioctl = snd_pcm_lib_ioctl, 938 .hw_params = snd_ca0106_pcm_hw_params_playback, 939 .hw_free = snd_ca0106_pcm_hw_free_playback, 940 .prepare = snd_ca0106_pcm_prepare_playback, 941 .trigger = snd_ca0106_pcm_trigger_playback, 942 .pointer = snd_ca0106_pcm_pointer_playback, 887 943 }; 888 944 889 static snd_pcm_ops_t snd_ca0106_playback_unknown_ops = { 890 /*.open = */snd_ca0106_pcm_open_playback_unknown, 891 /*.close = */snd_ca0106_pcm_close_playback, 892 /*.ioctl = */snd_pcm_lib_ioctl, 893 /*.hw_params = */snd_ca0106_pcm_hw_params_playback, 894 /*.hw_free = */snd_ca0106_pcm_hw_free_playback, 895 /*.prepare = */snd_ca0106_pcm_prepare_playback, 896 /*.trigger = */snd_ca0106_pcm_trigger_playback, 897 /*.pointer = */snd_ca0106_pcm_pointer_playback, 898 0,0,0,0 945 static struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { 946 .open = snd_ca0106_pcm_open_playback_unknown, 947 .close = snd_ca0106_pcm_close_playback, 948 .ioctl = snd_pcm_lib_ioctl, 949 .hw_params = snd_ca0106_pcm_hw_params_playback, 950 .hw_free = snd_ca0106_pcm_hw_free_playback, 951 .prepare = snd_ca0106_pcm_prepare_playback, 952 .trigger = snd_ca0106_pcm_trigger_playback, 953 .pointer = snd_ca0106_pcm_pointer_playback, 899 954 }; 900 955 901 static snd_pcm_ops_t snd_ca0106_playback_rear_ops = { 902 /*.open = */snd_ca0106_pcm_open_playback_rear, 903 /*.close = */snd_ca0106_pcm_close_playback, 904 /*.ioctl = */snd_pcm_lib_ioctl, 905 /*.hw_params = */snd_ca0106_pcm_hw_params_playback, 906 /*.hw_free = */snd_ca0106_pcm_hw_free_playback, 907 /*.prepare = */snd_ca0106_pcm_prepare_playback, 908 /*.trigger = */snd_ca0106_pcm_trigger_playback, 909 /*.pointer = */snd_ca0106_pcm_pointer_playback, 910 0,0,0,0 956 static struct snd_pcm_ops snd_ca0106_playback_rear_ops = { 957 .open = snd_ca0106_pcm_open_playback_rear, 958 .close = snd_ca0106_pcm_close_playback, 959 .ioctl = snd_pcm_lib_ioctl, 960 .hw_params = snd_ca0106_pcm_hw_params_playback, 961 .hw_free = snd_ca0106_pcm_hw_free_playback, 962 .prepare = snd_ca0106_pcm_prepare_playback, 963 .trigger = snd_ca0106_pcm_trigger_playback, 964 .pointer = snd_ca0106_pcm_pointer_playback, 911 965 }; 912 966 913 967 914 static unsigned short snd_ca0106_ac97_read( ac97_t*ac97,968 static unsigned short snd_ca0106_ac97_read(struct snd_ac97 *ac97, 915 969 unsigned short reg) 916 970 { 917 ca0106_t*emu = ac97->private_data;971 struct snd_ca0106 *emu = ac97->private_data; 918 972 unsigned long flags; 919 973 unsigned short val; … … 926 980 } 927 981 928 static void snd_ca0106_ac97_write( ac97_t*ac97,982 static void snd_ca0106_ac97_write(struct snd_ac97 *ac97, 929 983 unsigned short reg, unsigned short val) 930 984 { 931 ca0106_t*emu = ac97->private_data;985 struct snd_ca0106 *emu = ac97->private_data; 932 986 unsigned long flags; 933 987 934 988 spin_lock_irqsave(&emu->emu_lock, flags); 935 989 outb(reg, emu->port + AC97ADDRESS); … … 938 992 } 939 993 940 static int snd_ca0106_ac97( ca0106_t*chip)941 { 942 ac97_bus_t*pbus;943 ac97_template_tac97;994 static int snd_ca0106_ac97(struct snd_ca0106 *chip) 995 { 996 struct snd_ac97_bus *pbus; 997 struct snd_ac97_template ac97; 944 998 int err; 945 static ac97_bus_ops_t ops = { 946 0, 947 /* .write = */snd_ca0106_ac97_write, 948 /* .read = */snd_ca0106_ac97_read, 949 0,0 999 static struct snd_ac97_bus_ops ops = { 1000 .write = snd_ca0106_ac97_write, 1001 .read = snd_ca0106_ac97_read, 950 1002 }; 951 1003 952 1004 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) 953 return err; 954 pbus->no_vra = 1; /* we don't need VRA */ 1005 return err; 1006 pbus->no_vra = 1; /* we don't need VRA */ 1007 955 1008 memset(&ac97, 0, sizeof(ac97)); 956 957 1009 ac97.private_data = chip; 1010 ac97.scaps = AC97_SCAP_NO_SPDIF; 958 1011 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); 959 1012 } 960 1013 961 static int snd_ca0106_free( ca0106_t*chip)1014 static int snd_ca0106_free(struct snd_ca0106 *chip) 962 1015 { 963 1016 if (chip->res_port != NULL) { /* avoid access to already used hardware */ … … 982 1035 983 1036 // release the i/o port 984 if (chip->res_port) { 985 release_resource(chip->res_port); 986 kfree_nocheck(chip->res_port); 987 } 1037 release_and_free_resource(chip->res_port); 1038 988 1039 // release the irq 989 1040 if (chip->irq >= 0) … … 994 1045 } 995 1046 996 static int snd_ca0106_dev_free(s nd_device_t*device)997 { 998 ca0106_t*chip = device->device_data;1047 static int snd_ca0106_dev_free(struct snd_device *device) 1048 { 1049 struct snd_ca0106 *chip = device->device_data; 999 1050 return snd_ca0106_free(chip); 1000 1051 } … … 1005 1056 unsigned int status; 1006 1057 1007 ca0106_t*chip = dev_id;1058 struct snd_ca0106 *chip = dev_id; 1008 1059 int i; 1009 1060 int mask; 1010 1061 unsigned int stat76; 1011 ca0106_channel_t *pchannel; 1012 1013 spin_lock(&chip->emu_lock); 1062 struct snd_ca0106_channel *pchannel; 1014 1063 1015 1064 status = inl(chip->port + IPR); 1016 1017 // call updater, unlock before it1018 spin_unlock(&chip->emu_lock);1019 1020 1065 if (! status) 1021 1066 return IRQ_NONE; … … 1027 1072 for(i = 0; i < 4; i++) { 1028 1073 pchannel = &(chip->playback_channels[i]); 1029 if (stat76 & mask) {1074 if (stat76 & mask) { 1030 1075 /* FIXME: Select the correct substream for period elapsed */ 1031 1076 if(pchannel->use) { 1032 1033 1077 snd_pcm_period_elapsed(pchannel->epcm->substream); 1078 //printk(KERN_INFO "interrupt [%d] used\n", i); 1034 1079 } 1035 1080 } … … 1041 1086 for(i = 0; i < 4; i++) { 1042 1087 pchannel = &(chip->capture_channels[i]); 1043 if (stat76 & mask) {1088 if (stat76 & mask) { 1044 1089 /* FIXME: Select the correct substream for period elapsed */ 1045 1090 if(pchannel->use) { 1046 1047 1091 snd_pcm_period_elapsed(pchannel->epcm->substream); 1092 //printk(KERN_INFO "interrupt [%d] used\n", i); 1048 1093 } 1049 1094 } … … 1054 1099 1055 1100 snd_ca0106_ptr_write(chip, EXTENDED_INT, 0, stat76); 1056 spin_lock(&chip->emu_lock); 1101 1102 if (chip->midi.dev_id && 1103 (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { 1104 if (chip->midi.interrupt) 1105 chip->midi.interrupt(&chip->midi, status); 1106 else 1107 chip->midi.interrupt_disable(&chip->midi, chip->midi.tx_enable | chip->midi.rx_enable); 1108 } 1109 1057 1110 // acknowledge the interrupt if necessary 1058 1111 outl(status, chip->port+IPR); 1059 1112 1060 spin_unlock(&chip->emu_lock);1061 1062 eoi_irq(irq);1063 1064 1113 return IRQ_HANDLED; 1065 1114 } 1066 1115 1067 static void snd_ca0106_pcm_free(snd_pcm_t *pcm) 1068 { 1069 ca0106_t *emu = pcm->private_data; 1070 emu->pcm = NULL; 1071 snd_pcm_lib_preallocate_free_for_all(pcm); 1072 } 1073 1074 static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) 1075 { 1076 snd_pcm_t *pcm; 1077 snd_pcm_substream_t *substream; 1116 static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm) 1117 { 1118 struct snd_pcm *pcm; 1119 struct snd_pcm_substream *substream; 1078 1120 int err; 1079 1121 1080 1122 if (rpcm) 1081 1123 *rpcm = NULL; 1082 1124 if ((err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm)) < 0) 1083 1125 return err; 1084 1126 1085 1127 pcm->private_data = emu; 1086 pcm->private_free = snd_ca0106_pcm_free;1087 1128 1088 1129 switch (device) { … … 1110 1151 emu->pcm = pcm; 1111 1152 1112 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 1113 substream; 1153 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 1154 substream; 1114 1155 substream = substream->next) { 1115 if ((err = snd_pcm_lib_preallocate_pages(substream, 1116 SNDRV_DMA_TYPE_DEV, 1117 snd_dma_pci_data(emu->pci), 1156 if ((err = snd_pcm_lib_preallocate_pages(substream, 1157 SNDRV_DMA_TYPE_DEV, 1158 snd_dma_pci_data(emu->pci), 1118 1159 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */ 1119 1160 return err; 1120 1161 } 1121 1162 1122 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 1123 substream; 1163 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 1164 substream; 1124 1165 substream = substream->next) { 1125 if ((err = snd_pcm_lib_preallocate_pages(substream, 1126 SNDRV_DMA_TYPE_DEV, 1127 snd_dma_pci_data(emu->pci), 1166 if ((err = snd_pcm_lib_preallocate_pages(substream, 1167 SNDRV_DMA_TYPE_DEV, 1168 snd_dma_pci_data(emu->pci), 1128 1169 64*1024, 64*1024)) < 0) 1129 1170 return err; 1130 1171 } 1131 1172 1132 1173 if (rpcm) 1133 1174 *rpcm = pcm; 1134 1175 1135 1176 return 0; 1136 1177 } 1137 1178 1138 static int __devinit snd_ca0106_create(snd_card_t *card, 1179 static unsigned int spi_dac_init[] = { 1180 0x00ff, 1181 0x02ff, 1182 0x0400, 1183 0x0520, 1184 0x0600, 1185 0x08ff, 1186 0x0aff, 1187 0x0cff, 1188 0x0eff, 1189 0x10ff, 1190 0x1200, 1191 0x1400, 1192 0x1480, 1193 0x1800, 1194 0x1aff, 1195 0x1cff, 1196 0x1e00, 1197 0x0530, 1198 0x0602, 1199 0x0622, 1200 0x1400, 1201 }; 1202 1203 static int __devinit snd_ca0106_create(struct snd_card *card, 1139 1204 struct pci_dev *pci, 1140 ca0106_t**rchip)1141 { 1142 ca0106_t*chip;1143 ca0106_details_t*c;1205 struct snd_ca0106 **rchip) 1206 { 1207 struct snd_ca0106 *chip; 1208 struct snd_ca0106_details *c; 1144 1209 int err; 1145 1210 int ch; 1146 static s nd_device_ops_tops = {1147 /*.dev_free = */snd_ca0106_dev_free, 0,0,01211 static struct snd_device_ops ops = { 1212 .dev_free = snd_ca0106_dev_free, 1148 1213 }; 1149 1214 1150 1215 *rchip = NULL; 1151 1216 1152 1217 if ((err = pci_enable_device(pci)) < 0) 1153 return err; 1154 pci_set_dma_mask(pci, 0xffffffffUL); 1155 pci_set_consistent_dma_mask(pci, 0xffffffffUL); 1156 1157 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1218 return err; 1219 pci_set_dma_mask(pci, 0xFFFFFFFF); 1220 1221 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1158 1222 if (chip == NULL) { 1159 1223 pci_disable_device(pci); 1160 1224 return -ENOMEM; 1161 1225 } 1162 1226 1163 1227 chip->card = card; 1164 1228 chip->pci = pci; … … 1166 1230 1167 1231 spin_lock_init(&chip->emu_lock); 1168 1232 1169 1233 chip->port = pci_resource_start(pci, 0); 1170 1234 if ((chip->res_port = request_region(chip->port, 0x20, 1171 "snd_ca0106")) == NULL) { 1235 "snd_ca0106")) == NULL) { 1172 1236 snd_ca0106_free(chip); 1173 1237 printk(KERN_ERR "cannot allocate the port\n"); … … 1183 1247 } 1184 1248 chip->irq = pci->irq; 1185 1186 /* This stores the periods table. */ 1249 1250 /* This stores the periods table. */ 1187 1251 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &chip->buffer) < 0) { 1188 1252 snd_ca0106_free(chip); … … 1199 1263 chip->revision, chip->serial); 1200 1264 #endif 1201 strcpy(card->driver, "CA0106"); 1202 strcpy(card->shortname, "CA0106"); 1203 1204 for (c=ca0106_chip_details; c->serial; c++) { 1205 if (c->serial == chip->serial) break; 1206 } 1207 chip->details = c; 1208 sprintf(card->longname, "%s at 0x%lx irq %i", 1209 c->name, chip->port, chip->irq); 1265 strcpy(card->driver, "CA0106"); 1266 strcpy(card->shortname, "CA0106"); 1267 1268 for (c = ca0106_chip_details; c->serial; c++) { 1269 if (c->serial == chip->serial) 1270 break; 1271 } 1272 chip->details = c; 1273 sprintf(card->longname, "%s at 0x%lx irq %i", 1274 c->name, chip->port, chip->irq); 1210 1275 1211 1276 outl(0, chip->port + INTE); … … 1266 1331 //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */ 1267 1332 /* Analog or Digital output */ 1268 1269 1333 snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); 1334 snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */ 1270 1335 chip->spdif_enable = 0; /* Set digital SPDIF output off */ 1271 1336 chip->capture_source = 3; /* Set CAPTURE_SOURCE */ … … 1295 1360 /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ 1296 1361 outl(0x0, chip->port+GPIO); 1297 1298 1362 //outl(0x00f0e000, chip->port+GPIO); /* Analog */ 1363 outl(0x005f5301, chip->port+GPIO); /* Analog */ 1299 1364 } else { 1300 1365 outl(0x0, chip->port+GPIO); … … 1310 1375 1311 1376 if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ 1312 snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ 1313 } 1377 snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ 1378 } 1379 if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ 1380 int size, n; 1381 1382 size = ARRAY_SIZE(spi_dac_init); 1383 for (n=0; n < size; n++) 1384 snd_ca0106_spi_write(chip, spi_dac_init[n]); 1385 } 1314 1386 1315 1387 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, … … 1322 1394 } 1323 1395 1396 1397 static void ca0106_midi_interrupt_enable(struct snd_ca_midi *midi, int intr) 1398 { 1399 snd_ca0106_intr_enable((struct snd_ca0106 *)(midi->dev_id), intr); 1400 } 1401 1402 static void ca0106_midi_interrupt_disable(struct snd_ca_midi *midi, int intr) 1403 { 1404 snd_ca0106_intr_disable((struct snd_ca0106 *)(midi->dev_id), intr); 1405 } 1406 1407 static unsigned char ca0106_midi_read(struct snd_ca_midi *midi, int idx) 1408 { 1409 return (unsigned char)snd_ca0106_ptr_read((struct snd_ca0106 *)(midi->dev_id), 1410 midi->port + idx, 0); 1411 } 1412 1413 static void ca0106_midi_write(struct snd_ca_midi *midi, int data, int idx) 1414 { 1415 snd_ca0106_ptr_write((struct snd_ca0106 *)(midi->dev_id), midi->port + idx, 0, data); 1416 } 1417 1418 static struct snd_card *ca0106_dev_id_card(void *dev_id) 1419 { 1420 return ((struct snd_ca0106 *)dev_id)->card; 1421 } 1422 1423 static int ca0106_dev_id_port(void *dev_id) 1424 { 1425 return ((struct snd_ca0106 *)dev_id)->port; 1426 } 1427 1428 static int __devinit snd_ca0106_midi(struct snd_ca0106 *chip, unsigned int channel) 1429 { 1430 struct snd_ca_midi *midi; 1431 char *name; 1432 int err; 1433 1434 if (channel == CA0106_MIDI_CHAN_B) { 1435 name = "CA0106 MPU-401 (UART) B"; 1436 midi = &chip->midi2; 1437 midi->tx_enable = INTE_MIDI_TX_B; 1438 midi->rx_enable = INTE_MIDI_RX_B; 1439 midi->ipr_tx = IPR_MIDI_TX_B; 1440 midi->ipr_rx = IPR_MIDI_RX_B; 1441 midi->port = MIDI_UART_B_DATA; 1442 } else { 1443 name = "CA0106 MPU-401 (UART)"; 1444 midi = &chip->midi; 1445 midi->tx_enable = INTE_MIDI_TX_A; 1446 midi->rx_enable = INTE_MIDI_TX_B; 1447 midi->ipr_tx = IPR_MIDI_TX_A; 1448 midi->ipr_rx = IPR_MIDI_RX_A; 1449 midi->port = MIDI_UART_A_DATA; 1450 } 1451 1452 midi->reset = CA0106_MPU401_RESET; 1453 midi->enter_uart = CA0106_MPU401_ENTER_UART; 1454 midi->ack = CA0106_MPU401_ACK; 1455 1456 midi->input_avail = CA0106_MIDI_INPUT_AVAIL; 1457 midi->output_ready = CA0106_MIDI_OUTPUT_READY; 1458 1459 midi->channel = channel; 1460 1461 midi->interrupt_enable = ca0106_midi_interrupt_enable; 1462 midi->interrupt_disable = ca0106_midi_interrupt_disable; 1463 1464 midi->read = ca0106_midi_read; 1465 midi->write = ca0106_midi_write; 1466 1467 midi->get_dev_id_card = ca0106_dev_id_card; 1468 midi->get_dev_id_port = ca0106_dev_id_port; 1469 1470 midi->dev_id = chip; 1471 1472 if ((err = ca_midi_init(chip, midi, 0, name)) < 0) 1473 return err; 1474 1475 return 0; 1476 } 1477 1478 1324 1479 static int __devinit snd_ca0106_probe(struct pci_dev *pci, 1325 1480 const struct pci_device_id *pci_id) 1326 1481 { 1327 1482 static int dev; 1328 s nd_card_t*card;1329 ca0106_t*chip;1483 struct snd_card *card; 1484 struct snd_ca0106 *chip; 1330 1485 int err; 1331 1486 … … 1361 1516 snd_card_free(card); 1362 1517 return err; 1363 1518 } 1364 1519 if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */ 1365 1366 1367 1368 1369 1520 if ((err = snd_ca0106_ac97(chip)) < 0) { 1521 snd_card_free(card); 1522 return err; 1523 } 1524 } 1370 1525 if ((err = snd_ca0106_mixer(chip)) < 0) { 1371 1526 snd_card_free(card); … … 1373 1528 } 1374 1529 1530 snd_printdd("ca0106: probe for MIDI channel A ..."); 1531 if ((err = snd_ca0106_midi(chip,CA0106_MIDI_CHAN_A)) < 0) { 1532 snd_card_free(card); 1533 snd_printdd(" failed, err=0x%x\n",err); 1534 return err; 1535 } 1536 snd_printdd(" done.\n"); 1537 1538 #ifdef CONFIG_PROC_FS 1375 1539 snd_ca0106_proc_init(chip); 1540 #endif 1376 1541 1377 1542 if ((err = snd_card_register(card)) < 0) { … … 1400 1565 // pci_driver definition 1401 1566 static struct pci_driver driver = { 1402 0,0,0, 1403 /*.name = */"CA0106", 1404 /*.id_table = */snd_ca0106_ids, 1405 /*.probe = */snd_ca0106_probe, 1406 /*.remove = */snd_ca0106_remove, 1407 0,0 1567 .name = "CA0106", 1568 .id_table = snd_ca0106_ids, 1569 .probe = snd_ca0106_probe, 1570 .remove = __devexit_p(snd_ca0106_remove), 1408 1571 }; 1409 1572 … … 1411 1574 static int __init alsa_card_ca0106_init(void) 1412 1575 { 1413 int err; 1414 1415 if ((err = pci_module_init(&driver)) > 0) 1416 return err; 1417 1418 return 0; 1576 return pci_register_driver(&driver); 1419 1577 } 1420 1578 -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106_mixer.c
r32 r76 1 #define __NO_VERSION__2 1 /* 3 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> … … 7 6 * FEATURES currently supported: 8 7 * See ca0106_main.c for features. 9 * 8 * 10 9 * Changelog: 11 10 * Support interrupts per period. … … 66 65 #include <linux/pci.h> 67 66 #include <linux/slab.h> 68 //#include <linux/moduleparam.h>67 #include <linux/moduleparam.h> 69 68 #include <sound/core.h> 70 69 #include <sound/initval.h> … … 75 74 #include "ca0106.h" 76 75 77 static int snd_ca0106_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 76 static int snd_ca0106_shared_spdif_info(struct snd_kcontrol *kcontrol, 77 struct snd_ctl_elem_info *uinfo) 78 78 { 79 79 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; … … 84 84 } 85 85 86 static int snd_ca0106_shared_spdif_get(s nd_kcontrol_t *kcontrol,87 s nd_ctl_elem_value_t *ucontrol)88 { 89 ca0106_t*emu = snd_kcontrol_chip(kcontrol);86 static int snd_ca0106_shared_spdif_get(struct snd_kcontrol *kcontrol, 87 struct snd_ctl_elem_value *ucontrol) 88 { 89 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 90 90 91 91 ucontrol->value.enumerated.item[0] = emu->spdif_enable; … … 93 93 } 94 94 95 static int snd_ca0106_shared_spdif_put(s nd_kcontrol_t *kcontrol,96 s nd_ctl_elem_value_t *ucontrol)97 { 98 ca0106_t*emu = snd_kcontrol_chip(kcontrol);95 static int snd_ca0106_shared_spdif_put(struct snd_kcontrol *kcontrol, 96 struct snd_ctl_elem_value *ucontrol) 97 { 98 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 99 99 unsigned int val; 100 100 int change = 0; … … 116 116 } else { 117 117 /* Analog */ 118 119 120 121 122 123 118 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf); 119 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000); 120 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, 121 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000); 122 mask = inl(emu->port + GPIO) | 0x101; 123 outl(mask, emu->port + GPIO); 124 124 } 125 125 } … … 127 127 } 128 128 129 static snd_kcontrol_new_t snd_ca0106_shared_spdif __devinitdata = 130 { 131 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER, 0,0, 132 /*.name = */ "SPDIF Out", 0,0,0, 133 /*.info = */ snd_ca0106_shared_spdif_info, 134 /*.get = */ snd_ca0106_shared_spdif_get, 135 /*.put = */ snd_ca0106_shared_spdif_put,0 136 }; 137 138 static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 139 { 140 static char *texts[6] = { "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" }; 129 static int snd_ca0106_capture_source_info(struct snd_kcontrol *kcontrol, 130 struct snd_ctl_elem_info *uinfo) 131 { 132 static char *texts[6] = { 133 "IEC958 out", "i2s mixer out", "IEC958 in", "i2s in", "AC97 in", "SRC out" 134 }; 141 135 142 136 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; … … 149 143 } 150 144 151 static int snd_ca0106_capture_source_get(s nd_kcontrol_t *kcontrol,152 s nd_ctl_elem_value_t *ucontrol)153 { 154 ca0106_t*emu = snd_kcontrol_chip(kcontrol);145 static int snd_ca0106_capture_source_get(struct snd_kcontrol *kcontrol, 146 struct snd_ctl_elem_value *ucontrol) 147 { 148 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 155 149 156 150 ucontrol->value.enumerated.item[0] = emu->capture_source; … … 158 152 } 159 153 160 static int snd_ca0106_capture_source_put(s nd_kcontrol_t *kcontrol,161 s nd_ctl_elem_value_t *ucontrol)162 { 163 ca0106_t*emu = snd_kcontrol_chip(kcontrol);154 static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol, 155 struct snd_ctl_elem_value *ucontrol) 156 { 157 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 164 158 unsigned int val; 165 159 int change = 0; … … 178 172 } 179 173 180 static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata = 181 { 182 /*.iface = */ SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 183 /*.name = */ "Capture Source",0,0,0, 184 /*.info = */ snd_ca0106_capture_source_info, 185 /*.get = */ snd_ca0106_capture_source_get, 186 /*.put = */ snd_ca0106_capture_source_put,0 174 static int snd_ca0106_capture_mic_line_in_info(struct snd_kcontrol *kcontrol, 175 struct snd_ctl_elem_info *uinfo) 176 { 177 static char *texts[2] = { "Line in", "Mic in" }; 178 179 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 180 uinfo->count = 1; 181 uinfo->value.enumerated.items = 2; 182 if (uinfo->value.enumerated.item > 1) 183 uinfo->value.enumerated.item = 1; 184 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 185 return 0; 186 } 187 188 static int snd_ca0106_capture_mic_line_in_get(struct snd_kcontrol *kcontrol, 189 struct snd_ctl_elem_value *ucontrol) 190 { 191 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 192 193 ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in; 194 return 0; 195 } 196 197 static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol, 198 struct snd_ctl_elem_value *ucontrol) 199 { 200 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 201 unsigned int val; 202 int change = 0; 203 u32 tmp; 204 205 val = ucontrol->value.enumerated.item[0] ; 206 change = (emu->capture_mic_line_in != val); 207 if (change) { 208 emu->capture_mic_line_in = val; 209 if (val) { 210 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */ 211 tmp = inl(emu->port+GPIO) & ~0x400; 212 tmp = tmp | 0x400; 213 outl(tmp, emu->port+GPIO); 214 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC); 215 } else { 216 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */ 217 tmp = inl(emu->port+GPIO) & ~0x400; 218 outl(tmp, emu->port+GPIO); 219 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN); 220 } 221 } 222 return change; 223 } 224 225 static struct snd_kcontrol_new snd_ca0106_capture_mic_line_in __devinitdata = 226 { 227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 228 .name = "Mic/Line in Capture", 229 .info = snd_ca0106_capture_mic_line_in_info, 230 .get = snd_ca0106_capture_mic_line_in_get, 231 .put = snd_ca0106_capture_mic_line_in_put 187 232 }; 188 233 189 static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 190 { 191 static char *texts[2] = { "Line in", "Mic in" }; 192 193 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 194 uinfo->count = 1; 195 uinfo->value.enumerated.items = 2; 196 if (uinfo->value.enumerated.item > 1) 197 uinfo->value.enumerated.item = 1; 198 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 199 return 0; 200 } 201 202 static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol, 203 snd_ctl_elem_value_t * ucontrol) 204 { 205 ca0106_t *emu = snd_kcontrol_chip(kcontrol); 206 207 ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in; 208 return 0; 209 } 210 211 static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol, 212 snd_ctl_elem_value_t * ucontrol) 213 { 214 ca0106_t *emu = snd_kcontrol_chip(kcontrol); 215 unsigned int val; 216 int change = 0; 217 u32 tmp; 218 219 val = ucontrol->value.enumerated.item[0] ; 220 change = (emu->capture_mic_line_in != val); 221 if (change) { 222 emu->capture_mic_line_in = val; 223 if (val) { 224 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */ 225 tmp = inl(emu->port+GPIO) & ~0x400; 226 tmp = tmp | 0x400; 227 outl(tmp, emu->port+GPIO); 228 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC); 229 } else { 230 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */ 231 tmp = inl(emu->port+GPIO) & ~0x400; 232 outl(tmp, emu->port+GPIO); 233 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN); 234 } 235 } 236 return change; 237 } 238 239 static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata = 240 { 241 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 242 "Mic/Line in Capture",0,0,0, 243 snd_ca0106_capture_mic_line_in_info, 244 snd_ca0106_capture_mic_line_in_get, 245 snd_ca0106_capture_mic_line_in_put,0 246 }; 247 248 static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 234 static int snd_ca0106_spdif_info(struct snd_kcontrol *kcontrol, 235 struct snd_ctl_elem_info *uinfo) 249 236 { 250 237 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; … … 253 240 } 254 241 255 static int snd_ca0106_spdif_get(s nd_kcontrol_t *kcontrol,256 s nd_ctl_elem_value_t *ucontrol)257 { 258 ca0106_t*emu = snd_kcontrol_chip(kcontrol);242 static int snd_ca0106_spdif_get(struct snd_kcontrol *kcontrol, 243 struct snd_ctl_elem_value *ucontrol) 244 { 245 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 259 246 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 260 247 … … 266 253 } 267 254 268 static int snd_ca0106_spdif_get_mask(s nd_kcontrol_t *kcontrol,269 s nd_ctl_elem_value_t *ucontrol)255 static int snd_ca0106_spdif_get_mask(struct snd_kcontrol *kcontrol, 256 struct snd_ctl_elem_value *ucontrol) 270 257 { 271 258 ucontrol->value.iec958.status[0] = 0xff; … … 276 263 } 277 264 278 static int snd_ca0106_spdif_put(s nd_kcontrol_t *kcontrol,279 s nd_ctl_elem_value_t *ucontrol)280 { 281 ca0106_t*emu = snd_kcontrol_chip(kcontrol);265 static int snd_ca0106_spdif_put(struct snd_kcontrol *kcontrol, 266 struct snd_ctl_elem_value *ucontrol) 267 { 268 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 282 269 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 283 270 int change; … … 296 283 } 297 284 298 static snd_kcontrol_new_t snd_ca0106_spdif_mask_control = 299 { 300 /* .iface = */ SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 301 /* .name = */ SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), 0, 302 /* .access = */ SNDRV_CTL_ELEM_ACCESS_READ, 303 /* .count = */ 4, 304 /* .info = */ snd_ca0106_spdif_info, 305 /* .get = */ snd_ca0106_spdif_get_mask,0,0 306 }; 307 308 static snd_kcontrol_new_t snd_ca0106_spdif_control = 309 { 310 /* .iface = */ SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 311 /* .name = */ SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),0,0, 312 /* .count = */ 4, 313 /* .info = */ snd_ca0106_spdif_info, 314 /* .get = */ snd_ca0106_spdif_get, 315 /* .put = */ snd_ca0106_spdif_put, 0 316 }; 317 318 static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 285 static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol, 286 struct snd_ctl_elem_info *uinfo) 319 287 { 320 288 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; … … 325 293 } 326 294 327 static int snd_ca0106_volume_get(s nd_kcontrol_t *kcontrol,328 snd_ctl_elem_value_t * ucontrol, int reg, int channel_id)329 { 330 ca0106_t*emu = snd_kcontrol_chip(kcontrol);295 static int snd_ca0106_volume_get(struct snd_kcontrol *kcontrol, 296 struct snd_ctl_elem_value *ucontrol) 297 { 298 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 331 299 unsigned int value; 300 int channel_id, reg; 301 302 channel_id = (kcontrol->private_value >> 8) & 0xff; 303 reg = kcontrol->private_value & 0xff; 332 304 333 305 value = snd_ca0106_ptr_read(emu, reg, channel_id); … … 337 309 } 338 310 339 static int snd_ca0106_volume_get_spdif_front(snd_kcontrol_t * kcontrol, 340 snd_ctl_elem_value_t * ucontrol) 341 { 342 int channel_id = CONTROL_FRONT_CHANNEL; 343 int reg = PLAYBACK_VOLUME1; 344 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 345 } 346 347 static int snd_ca0106_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol, 348 snd_ctl_elem_value_t * ucontrol) 349 { 350 int channel_id = CONTROL_CENTER_LFE_CHANNEL; 351 int reg = PLAYBACK_VOLUME1; 352 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 353 } 354 static int snd_ca0106_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol, 355 snd_ctl_elem_value_t * ucontrol) 356 { 357 int channel_id = CONTROL_UNKNOWN_CHANNEL; 358 int reg = PLAYBACK_VOLUME1; 359 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 360 } 361 static int snd_ca0106_volume_get_spdif_rear(snd_kcontrol_t * kcontrol, 362 snd_ctl_elem_value_t * ucontrol) 363 { 364 int channel_id = CONTROL_REAR_CHANNEL; 365 int reg = PLAYBACK_VOLUME1; 366 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 367 } 368 static int snd_ca0106_volume_get_analog_front(snd_kcontrol_t * kcontrol, 369 snd_ctl_elem_value_t * ucontrol) 370 { 371 int channel_id = CONTROL_FRONT_CHANNEL; 372 int reg = PLAYBACK_VOLUME2; 373 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 374 } 375 376 static int snd_ca0106_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol, 377 snd_ctl_elem_value_t * ucontrol) 378 { 379 int channel_id = CONTROL_CENTER_LFE_CHANNEL; 380 int reg = PLAYBACK_VOLUME2; 381 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 382 } 383 static int snd_ca0106_volume_get_analog_unknown(snd_kcontrol_t * kcontrol, 384 snd_ctl_elem_value_t * ucontrol) 385 { 386 int channel_id = CONTROL_UNKNOWN_CHANNEL; 387 int reg = PLAYBACK_VOLUME2; 388 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 389 } 390 static int snd_ca0106_volume_get_analog_rear(snd_kcontrol_t * kcontrol, 391 snd_ctl_elem_value_t * ucontrol) 392 { 393 int channel_id = CONTROL_REAR_CHANNEL; 394 int reg = PLAYBACK_VOLUME2; 395 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 396 } 397 398 static int snd_ca0106_volume_get_feedback(snd_kcontrol_t * kcontrol, 399 snd_ctl_elem_value_t * ucontrol) 400 { 401 int channel_id = 1; 402 int reg = CAPTURE_CONTROL; 403 return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); 404 } 405 406 static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol, 407 snd_ctl_elem_value_t * ucontrol, int reg, int channel_id) 408 { 409 ca0106_t *emu = snd_kcontrol_chip(kcontrol); 410 unsigned int value; 411 //value = snd_ca0106_ptr_read(emu, reg, channel_id); 412 //value = value & 0xffff; 413 value = ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16); 414 value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) ); 415 snd_ca0106_ptr_write(emu, reg, channel_id, value); 416 return 1; 417 } 418 static int snd_ca0106_volume_put_spdif_front(snd_kcontrol_t * kcontrol, 419 snd_ctl_elem_value_t * ucontrol) 420 { 421 int channel_id = CONTROL_FRONT_CHANNEL; 422 int reg = PLAYBACK_VOLUME1; 423 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 424 } 425 static int snd_ca0106_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol, 426 snd_ctl_elem_value_t * ucontrol) 427 { 428 int channel_id = CONTROL_CENTER_LFE_CHANNEL; 429 int reg = PLAYBACK_VOLUME1; 430 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 431 } 432 static int snd_ca0106_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol, 433 snd_ctl_elem_value_t * ucontrol) 434 { 435 int channel_id = CONTROL_UNKNOWN_CHANNEL; 436 int reg = PLAYBACK_VOLUME1; 437 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 438 } 439 static int snd_ca0106_volume_put_spdif_rear(snd_kcontrol_t * kcontrol, 440 snd_ctl_elem_value_t * ucontrol) 441 { 442 int channel_id = CONTROL_REAR_CHANNEL; 443 int reg = PLAYBACK_VOLUME1; 444 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 445 } 446 static int snd_ca0106_volume_put_analog_front(snd_kcontrol_t * kcontrol, 447 snd_ctl_elem_value_t * ucontrol) 448 { 449 int channel_id = CONTROL_FRONT_CHANNEL; 450 int reg = PLAYBACK_VOLUME2; 451 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 452 } 453 static int snd_ca0106_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol, 454 snd_ctl_elem_value_t * ucontrol) 455 { 456 int channel_id = CONTROL_CENTER_LFE_CHANNEL; 457 int reg = PLAYBACK_VOLUME2; 458 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 459 } 460 static int snd_ca0106_volume_put_analog_unknown(snd_kcontrol_t * kcontrol, 461 snd_ctl_elem_value_t * ucontrol) 462 { 463 int channel_id = CONTROL_UNKNOWN_CHANNEL; 464 int reg = PLAYBACK_VOLUME2; 465 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 466 } 467 static int snd_ca0106_volume_put_analog_rear(snd_kcontrol_t * kcontrol, 468 snd_ctl_elem_value_t * ucontrol) 469 { 470 int channel_id = CONTROL_REAR_CHANNEL; 471 int reg = PLAYBACK_VOLUME2; 472 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 473 } 474 475 static int snd_ca0106_volume_put_feedback(snd_kcontrol_t * kcontrol, 476 snd_ctl_elem_value_t * ucontrol) 477 { 478 int channel_id = 1; 479 int reg = CAPTURE_CONTROL; 480 return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); 481 } 482 483 static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front = 484 { 485 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 486 "Analog Front Playback Volume" 487 ,0,0,0, 488 snd_ca0106_volume_info, 489 snd_ca0106_volume_get_analog_front, 490 snd_ca0106_volume_put_analog_front,0 311 static int snd_ca0106_volume_put(struct snd_kcontrol *kcontrol, 312 struct snd_ctl_elem_value *ucontrol) 313 { 314 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 315 unsigned int oval, nval; 316 int channel_id, reg; 317 318 channel_id = (kcontrol->private_value >> 8) & 0xff; 319 reg = kcontrol->private_value & 0xff; 320 321 oval = snd_ca0106_ptr_read(emu, reg, channel_id); 322 nval = ((0xff - ucontrol->value.integer.value[0]) << 24) | 323 ((0xff - ucontrol->value.integer.value[1]) << 16); 324 nval |= ((0xff - ucontrol->value.integer.value[0]) << 8) | 325 ((0xff - ucontrol->value.integer.value[1]) ); 326 if (oval == nval) 327 return 0; 328 snd_ca0106_ptr_write(emu, reg, channel_id, nval); 329 return 1; 330 } 331 332 #define CA_VOLUME(xname,chid,reg) \ 333 { \ 334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 335 .info = snd_ca0106_volume_info, \ 336 .get = snd_ca0106_volume_get, \ 337 .put = snd_ca0106_volume_put, \ 338 .private_value = ((chid) << 8) | (reg) \ 339 } 340 341 342 static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = { 343 CA_VOLUME("Analog Front Playback Volume", 344 CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2), 345 CA_VOLUME("Analog Rear Playback Volume", 346 CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2), 347 CA_VOLUME("Analog Center/LFE Playback Volume", 348 CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2), 349 CA_VOLUME("Analog Side Playback Volume", 350 CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2), 351 352 CA_VOLUME("IEC958 Front Playback Volume", 353 CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1), 354 CA_VOLUME("IEC958 Rear Playback Volume", 355 CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1), 356 CA_VOLUME("IEC958 Center/LFE Playback Volume", 357 CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1), 358 CA_VOLUME("IEC958 Unknown Playback Volume", 359 CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1), 360 361 CA_VOLUME("CAPTURE feedback Playback Volume", 362 1, CAPTURE_CONTROL), 363 364 { 365 .access = SNDRV_CTL_ELEM_ACCESS_READ, 366 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 367 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), 368 .count = 4, 369 .info = snd_ca0106_spdif_info, 370 .get = snd_ca0106_spdif_get_mask 371 }, 372 { 373 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 374 .name = "IEC958 Playback Switch", 375 .info = snd_ca0106_shared_spdif_info, 376 .get = snd_ca0106_shared_spdif_get, 377 .put = snd_ca0106_shared_spdif_put 378 }, 379 { 380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 381 .name = "Capture Source", 382 .info = snd_ca0106_capture_source_info, 383 .get = snd_ca0106_capture_source_get, 384 .put = snd_ca0106_capture_source_put 385 }, 386 { 387 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 388 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 389 .count = 4, 390 .info = snd_ca0106_spdif_info, 391 .get = snd_ca0106_spdif_get, 392 .put = snd_ca0106_spdif_put 393 }, 491 394 }; 492 static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = 493 { 494 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 495 "Analog Center/LFE Playback Volume",0,0,0, 496 snd_ca0106_volume_info, 497 snd_ca0106_volume_get_analog_center_lfe, 498 snd_ca0106_volume_put_analog_center_lfe,0 499 }; 500 static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = 501 { 502 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 503 "Analog Side Playback Volume",0,0,0, 504 snd_ca0106_volume_info, 505 snd_ca0106_volume_get_analog_unknown, 506 snd_ca0106_volume_put_analog_unknown,0 507 }; 508 static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear = 509 { 510 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 511 "Analog Rear Playback Volume",0,0,0, 512 snd_ca0106_volume_info, 513 snd_ca0106_volume_get_analog_rear, 514 snd_ca0106_volume_put_analog_rear,0 515 }; 516 static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front = 517 { 518 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 519 "SPDIF Front Playback Volume",0,0,0, 520 snd_ca0106_volume_info, 521 snd_ca0106_volume_get_spdif_front, 522 snd_ca0106_volume_put_spdif_front,0 523 }; 524 static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe = 525 { 526 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 527 "SPDIF Center/LFE Playback Volume",0,0,0, 528 snd_ca0106_volume_info, 529 snd_ca0106_volume_get_spdif_center_lfe, 530 snd_ca0106_volume_put_spdif_center_lfe,0 531 }; 532 static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown = 533 { 534 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 535 "SPDIF Unknown Playback Volume",0,0,0, 536 snd_ca0106_volume_info, 537 snd_ca0106_volume_get_spdif_unknown, 538 snd_ca0106_volume_put_spdif_unknown,0 539 }; 540 static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear = 541 { 542 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 543 "SPDIF Rear Playback Volume",0,0,0, 544 snd_ca0106_volume_info, 545 snd_ca0106_volume_get_spdif_rear, 546 snd_ca0106_volume_put_spdif_rear,0 547 }; 548 549 static snd_kcontrol_new_t snd_ca0106_volume_control_feedback = 550 { 551 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 552 "CAPTURE feedback Playback",0,0,0, 553 snd_ca0106_volume_info, 554 snd_ca0106_volume_get_feedback, 555 snd_ca0106_volume_put_feedback,0 556 }; 557 558 559 static int remove_ctl(snd_card_t *card, const char *name) 560 { 561 snd_ctl_elem_id_t id; 395 396 static int __devinit remove_ctl(struct snd_card *card, const char *name) 397 { 398 struct snd_ctl_elem_id id; 562 399 memset(&id, 0, sizeof(id)); 563 400 strcpy(id.name, name); … … 566 403 } 567 404 568 static s nd_kcontrol_t *ctl_find(snd_card_t*card, const char *name)569 { 570 s nd_ctl_elem_id_tsid;405 static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card, const char *name) 406 { 407 struct snd_ctl_elem_id sid; 571 408 memset(&sid, 0, sizeof(sid)); 572 409 /* FIXME: strcpy is bad. */ … … 576 413 } 577 414 578 static int rename_ctl(snd_card_t*card, const char *src, const char *dst)579 { 580 s nd_kcontrol_t*kctl = ctl_find(card, src);415 static int __devinit rename_ctl(struct snd_card *card, const char *src, const char *dst) 416 { 417 struct snd_kcontrol *kctl = ctl_find(card, src); 581 418 if (kctl) { 582 419 strcpy(kctl->id.name, dst); … … 586 423 } 587 424 588 int __devinit snd_ca0106_mixer(ca0106_t *emu) 589 { 590 int err; 591 snd_kcontrol_t *kctl; 592 snd_card_t *card = emu->card; 425 int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) 426 { 427 int i, err; 428 struct snd_card *card = emu->card; 593 429 char **c; 594 430 static char *ca0106_remove_ctls[] = { … … 630 466 }; 631 467 #if 1 632 for (c =ca0106_remove_ctls; *c; c++)468 for (c = ca0106_remove_ctls; *c; c++) 633 469 remove_ctl(card, *c); 634 for (c =ca0106_rename_ctls; *c; c += 2)470 for (c = ca0106_rename_ctls; *c; c += 2) 635 471 rename_ctl(card, c[0], c[1]); 636 472 #endif 637 473 638 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_front, emu)) == NULL) 639 return -ENOMEM; 640 if ((err = snd_ctl_add(card, kctl))) 641 return err; 642 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_rear, emu)) == NULL) 643 return -ENOMEM; 644 if ((err = snd_ctl_add(card, kctl))) 645 return err; 646 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_center_lfe, emu)) == NULL) 647 return -ENOMEM; 648 if ((err = snd_ctl_add(card, kctl))) 649 return err; 650 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_unknown, emu)) == NULL) 651 return -ENOMEM; 652 if ((err = snd_ctl_add(card, kctl))) 653 return err; 654 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_front, emu)) == NULL) 655 return -ENOMEM; 656 if ((err = snd_ctl_add(card, kctl))) 657 return err; 658 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_rear, emu)) == NULL) 659 return -ENOMEM; 660 if ((err = snd_ctl_add(card, kctl))) 661 return err; 662 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_center_lfe, emu)) == NULL) 663 return -ENOMEM; 664 if ((err = snd_ctl_add(card, kctl))) 665 return err; 666 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_unknown, emu)) == NULL) 667 return -ENOMEM; 668 if ((err = snd_ctl_add(card, kctl))) 669 return err; 670 if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_feedback, emu)) == NULL) 671 return -ENOMEM; 672 if ((err = snd_ctl_add(card, kctl))) 673 return err; 674 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_mask_control, emu)) == NULL) 675 return -ENOMEM; 676 if ((err = snd_ctl_add(card, kctl))) 677 return err; 678 if ((kctl = snd_ctl_new1(&snd_ca0106_shared_spdif, emu)) == NULL) 679 return -ENOMEM; 680 if ((err = snd_ctl_add(card, kctl))) 681 return err; 682 if ((kctl = snd_ctl_new1(&snd_ca0106_capture_source, emu)) == NULL) 683 return -ENOMEM; 684 if ((err = snd_ctl_add(card, kctl))) 685 return err; 686 if (emu->details->i2c_adc == 1) { 687 if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL) 688 return -ENOMEM; 689 if ((err = snd_ctl_add(card, kctl))) 690 return err; 691 } 692 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) 693 return -ENOMEM; 694 if ((err = snd_ctl_add(card, kctl))) 695 return err; 474 for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) { 475 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu)); 476 if (err < 0) 477 return err; 478 } 479 if (emu->details->i2c_adc == 1) { 480 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)); 481 if (err < 0) 482 return err; 483 } 696 484 return 0; 697 485 } -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106_proc.c
r32 r76 1 #define __NO_VERSION__2 1 /* 3 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> 4 3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit 5 * Version: 0.0.1 74 * Version: 0.0.18 6 5 * 7 6 * FEATURES currently supported: … … 41 40 * 0.0.17 42 41 * Add iec958 file in proc file system to show status of SPDIF in. 43 * 42 * 0.0.18 43 * Implement support for Line-in capture on SB Live 24bit. 44 * 44 45 * This code was initally based on code from ALSA's emu10k1x.c which is: 45 46 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> … … 66 67 #include <linux/pci.h> 67 68 #include <linux/slab.h> 68 //#include <linux/moduleparam.h>69 #include <linux/moduleparam.h> 69 70 #include <sound/core.h> 70 71 #include <sound/initval.h> … … 76 77 #include "ca0106.h" 77 78 79 80 #ifdef CONFIG_PROC_FS 78 81 79 82 struct snd_ca0106_category_str { … … 97 100 98 101 99 void snd_ca0106_proc_dump_iec958( snd_info_buffer_t*buffer, u32 value)102 static void snd_ca0106_proc_dump_iec958( struct snd_info_buffer *buffer, u32 value) 100 103 { 101 104 int i; … … 271 274 } 272 275 273 static void snd_ca0106_proc_iec958(s nd_info_entry_t*entry,274 s nd_info_buffer_t *buffer)275 { 276 ca0106_t*emu = entry->private_data;276 static void snd_ca0106_proc_iec958(struct snd_info_entry *entry, 277 struct snd_info_buffer *buffer) 278 { 279 struct snd_ca0106 *emu = entry->private_data; 277 280 u32 value; 278 281 … … 293 296 } 294 297 295 static void snd_ca0106_proc_reg_write32(s nd_info_entry_t*entry,296 s nd_info_buffer_t *buffer)297 { 298 ca0106_t*emu = entry->private_data;298 static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry, 299 struct snd_info_buffer *buffer) 300 { 301 struct snd_ca0106 *emu = entry->private_data; 299 302 unsigned long flags; 300 303 char line[64]; … … 313 316 } 314 317 315 static void snd_ca0106_proc_reg_read32(s nd_info_entry_t*entry,316 s nd_info_buffer_t *buffer)317 { 318 ca0106_t*emu = entry->private_data;318 static void snd_ca0106_proc_reg_read32(struct snd_info_entry *entry, 319 struct snd_info_buffer *buffer) 320 { 321 struct snd_ca0106 *emu = entry->private_data; 319 322 unsigned long value; 320 323 unsigned long flags; … … 329 332 } 330 333 331 static void snd_ca0106_proc_reg_read16(s nd_info_entry_t*entry,332 s nd_info_buffer_t *buffer)333 { 334 ca0106_t*emu = entry->private_data;334 static void snd_ca0106_proc_reg_read16(struct snd_info_entry *entry, 335 struct snd_info_buffer *buffer) 336 { 337 struct snd_ca0106 *emu = entry->private_data; 335 338 unsigned int value; 336 339 unsigned long flags; … … 345 348 } 346 349 347 static void snd_ca0106_proc_reg_read8(s nd_info_entry_t*entry,348 s nd_info_buffer_t *buffer)349 { 350 ca0106_t*emu = entry->private_data;350 static void snd_ca0106_proc_reg_read8(struct snd_info_entry *entry, 351 struct snd_info_buffer *buffer) 352 { 353 struct snd_ca0106 *emu = entry->private_data; 351 354 unsigned int value; 352 355 unsigned long flags; … … 361 364 } 362 365 363 static void snd_ca0106_proc_reg_read1(s nd_info_entry_t*entry,364 s nd_info_buffer_t *buffer)365 { 366 ca0106_t*emu = entry->private_data;366 static void snd_ca0106_proc_reg_read1(struct snd_info_entry *entry, 367 struct snd_info_buffer *buffer) 368 { 369 struct snd_ca0106 *emu = entry->private_data; 367 370 unsigned long value; 368 371 int i,j; … … 379 382 } 380 383 381 static void snd_ca0106_proc_reg_read2(s nd_info_entry_t*entry,382 s nd_info_buffer_t *buffer)383 { 384 ca0106_t*emu = entry->private_data;384 static void snd_ca0106_proc_reg_read2(struct snd_info_entry *entry, 385 struct snd_info_buffer *buffer) 386 { 387 struct snd_ca0106 *emu = entry->private_data; 385 388 unsigned long value; 386 389 int i,j; … … 397 400 } 398 401 399 static void snd_ca0106_proc_reg_write(s nd_info_entry_t*entry,400 s nd_info_buffer_t *buffer)401 { 402 ca0106_t*emu = entry->private_data;402 static void snd_ca0106_proc_reg_write(struct snd_info_entry *entry, 403 struct snd_info_buffer *buffer) 404 { 405 struct snd_ca0106 *emu = entry->private_data; 403 406 char line[64]; 404 407 unsigned int reg, channel_id , val; … … 413 416 } 414 417 415 416 int __devinit snd_ca0106_proc_init(ca0106_t * emu) 417 { 418 snd_info_entry_t *entry; 418 static void snd_ca0106_proc_i2c_write(struct snd_info_entry *entry, 419 struct snd_info_buffer *buffer) 420 { 421 struct snd_ca0106 *emu = entry->private_data; 422 char line[64]; 423 unsigned int reg, val; 424 #if 0 425 while (!snd_info_get_line(buffer, line, sizeof(line))) { 426 if (sscanf(line, "%x %x", ®, &val) != 2) 427 continue; 428 if ((reg <= 0x7f) || (val <= 0x1ff)) { 429 snd_ca0106_i2c_write(emu, reg, val); 430 } 431 } 432 #endif 433 } 434 435 int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu) 436 { 437 struct snd_info_entry *entry; 419 438 420 439 if(! snd_card_proc_new(emu->card, "iec958", &entry)) … … 424 443 entry->c.text.write_size = 64; 425 444 entry->c.text.write = snd_ca0106_proc_reg_write32; 445 entry->mode |= S_IWUSR; 426 446 } 427 447 if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry)) … … 433 453 entry->c.text.write_size = 64; 434 454 entry->c.text.write = snd_ca0106_proc_reg_write; 455 entry->mode |= S_IWUSR; 456 // entry->private_data = emu; 457 } 458 if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) { 459 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_i2c_write); 460 entry->c.text.write_size = 64; 461 entry->c.text.write = snd_ca0106_proc_i2c_write; 462 entry->mode |= S_IWUSR; 435 463 // entry->private_data = emu; 436 464 } … … 440 468 } 441 469 470 #endif /* CONFIG_PROC_FS */ -
GPL/trunk/alsa-kernel/pci/ca0106/makefile.os2
r32 r76 14 14 #=================================================================== 15 15 FILE1 = ca0106_main.obj ca0106_proc.obj ca0106_mixer.obj 16 FILE2 = 16 FILE2 = ca_midi.obj 17 17 FILE3 = 18 18 FILE4 = -
GPL/trunk/alsa-kernel/pci/cs4281.c
r34 r76 1092 1092 change = 1; 1093 1093 } 1094 if (ucontrol->value.integer.value[0] != vol L) {1094 if (ucontrol->value.integer.value[0] != volR) { 1095 1095 volR = CS_VOL_MASK - (ucontrol->value.integer.value[1] & CS_VOL_MASK); 1096 1096 snd_cs4281_pokeBA0(chip, regR, volR); … … 1462 1462 { 1463 1463 unsigned int tmp; 1464 int timeout;1464 unsigned long end_time; 1465 1465 int retry_count = 2; 1466 1466 … … 1541 1541 * Wait for the DLL ready signal from the clock logic. 1542 1542 */ 1543 #ifdef TARGET_OS2 1544 // end_time = (jiffies + 1000) + 1; 1545 #else 1546 // end_time = (jiffies + HZ / 4) + 1; 1547 #endif 1548 timeout = HZ; 1543 end_time = jiffies + HZ; 1549 1544 do { 1550 1545 /* … … 1554 1549 if (snd_cs4281_peekBA0(chip, BA0_CLKCR1) & BA0_CLKCR1_DLLRDY) 1555 1550 goto __ok0; 1556 s nd_cs4281_delay_long();1557 } while (time out-- > 0);1551 schedule_timeout_uninterruptible(1); 1552 } while (time_after_eq(end_time, jiffies)); 1558 1553 1559 1554 snd_printk(KERN_ERR "DLLRDY not seen\n"); … … 1572 1567 * Wait for the codec ready signal from the AC97 codec. 1573 1568 */ 1574 #ifdef TARGET_OS2 1575 // end_time = (jiffies + 1000) + 1; 1576 #else 1577 // end_time = (jiffies + (3 * HZ) / 4) + 1; 1578 #endif 1579 timeout = HZ; 1569 end_time = jiffies + HZ; 1580 1570 do { 1581 1571 /* … … 1585 1575 if (snd_cs4281_peekBA0(chip, BA0_ACSTS) & BA0_ACSTS_CRDY) 1586 1576 goto __ok1; 1587 s nd_cs4281_delay_long();1588 } while (time out-- > 0);1577 schedule_timeout_uninterruptible(1); 1578 } while (time_after_eq(end_time, jiffies)); 1589 1579 1590 1580 snd_printk(KERN_ERR "never read codec ready from AC'97 (0x%x)\n", snd_cs4281_peekBA0(chip, BA0_ACSTS)); … … 1593 1583 __ok1: 1594 1584 if (chip->dual_codec) { 1595 timeout =HZ;1585 end_time = jiffies + HZ; 1596 1586 do { 1597 1587 if (snd_cs4281_peekBA0(chip, BA0_ACSTS2) & BA0_ACSTS_CRDY) 1598 1588 goto __codec2_ok; 1599 s nd_cs4281_delay_long();1600 } while (time out-- > 0);1589 schedule_timeout_uninterruptible(1); 1590 } while (time_after_eq(end_time, jiffies)); 1601 1591 snd_printk(KERN_INFO "secondary codec doesn't respond. disable it...\n"); 1602 1592 chip->dual_codec = 0; … … 1615 1605 * the codec is pumping ADC data across the AC-link. 1616 1606 */ 1617 1618 #ifdef TARGET_OS2 1619 // end_time = (jiffies + 5000); 1620 #else 1621 // end_time = (jiffies + (5 * HZ) / 4) + 1; 1622 #endif 1623 timeout = HZ; 1607 end_time = jiffies + HZ; 1624 1608 do { 1625 1609 /* … … 1629 1613 if ((snd_cs4281_peekBA0(chip, BA0_ACISV) & (BA0_ACISV_SLV(3) | BA0_ACISV_SLV(4))) == (BA0_ACISV_SLV(3) | BA0_ACISV_SLV(4))) 1630 1614 goto __ok2; 1631 s nd_cs4281_delay_long();1632 } while (time out-- > 0);1615 schedule_timeout_uninterruptible(1); 1616 } while (time_after_eq(end_time, jiffies)); 1633 1617 1634 1618 if (--retry_count > 0) -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.c
r34 r76 49 49 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 50 50 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 51 static int external_amp[SNDRV_CARDS] = {0 };52 static int thinkpad[SNDRV_CARDS] = { 1,0,0,0,0,0,0,0};53 static int mmap_valid[SNDRV_CARDS] = { 0};51 static int external_amp[SNDRV_CARDS] = {0,0,0,0,0,0,0,0}; 52 static int thinkpad[SNDRV_CARDS] = {0,0,0,0,0,0,0,0}; 53 static int mmap_valid[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; 54 54 55 55 //module_param_array(index, int, NULL, 0444); … … 167 167 .id_table = snd_cs46xx_ids, 168 168 .probe = snd_card_cs46xx_probe, 169 .remove = snd_card_cs46xx_remove,169 .remove = __devexit_p(snd_card_cs46xx_remove), 170 170 #ifdef CONFIG_PM 171 171 .suspend = snd_cs46xx_suspend, -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c
r34 r76 54 54 #include <linux/slab.h> 55 55 //#include <linux/gameport.h> 56 #include <linux/mutex.h> 57 56 58 57 59 #include <sound/core.h> … … 316 318 317 319 snd_assert(!(offset & 3) && !(len & 3), return -EINVAL); 318 dst = (char*)chip->region.idx[bank+1].remap_addr + offset;320 dst = chip->region.idx[bank+1].remap_addr + offset; 319 321 len /= sizeof(u32); 320 322 … … 322 324 while (len-- > 0) { 323 325 writel(*src++, dst); 324 (char*)dst += sizeof(u32);326 dst += sizeof(u32); 325 327 } 326 328 return 0; … … 910 912 snd_assert (sample_rate != 0, return -ENXIO); 911 913 912 down(&chip->spos_mutex);914 mutex_lock(&chip->spos_mutex); 913 915 914 916 if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) { 915 up(&chip->spos_mutex);917 mutex_unlock(&chip->spos_mutex); 916 918 return -ENXIO; 917 919 } 918 920 919 snd_assert (cpcm->pcm_channel != NULL );921 snd_assert (cpcm->pcm_channel != NULL, return -ENXIO); 920 922 if (!cpcm->pcm_channel) { 921 up(&chip->spos_mutex);923 mutex_unlock(&chip->spos_mutex); 922 924 return -ENXIO; 923 925 } … … 925 927 926 928 if (cs46xx_dsp_pcm_channel_set_period (chip,cpcm->pcm_channel,period_size)) { 927 up(&chip->spos_mutex);929 mutex_unlock(&chip->spos_mutex); 928 930 return -EINVAL; 929 931 } … … 952 954 substream->ops = &snd_cs46xx_playback_iec958_ops; 953 955 } else { 954 snd_assert(0 );956 snd_assert(0, return -ENXIO); 955 957 } 956 958 #else … … 966 968 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) { 967 969 #ifdef CONFIG_SND_CS46XX_NEW_DSP 968 up(&chip->spos_mutex);970 mutex_unlock(&chip->spos_mutex); 969 971 #endif 970 972 return err; … … 981 983 substream->ops = &snd_cs46xx_playback_indirect_iec958_ops; 982 984 } else { 983 snd_assert(0 );985 snd_assert(0, return -ENXIO); 984 986 } 985 987 #else … … 990 992 991 993 #ifdef CONFIG_SND_CS46XX_NEW_DSP 992 up(&chip->spos_mutex);994 mutex_unlock(&chip->spos_mutex); 993 995 #endif 994 996 … … 1305 1307 struct snd_pcm_runtime *runtime = substream->runtime; 1306 1308 1307 cpcm = (struct snd_cs46xx_pcm * )kzalloc(sizeof(*cpcm), GFP_KERNEL);1309 cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL); 1308 1310 if (cpcm == NULL) 1309 1311 return -ENOMEM; … … 1320 1322 cpcm->substream = substream; 1321 1323 #ifdef CONFIG_SND_CS46XX_NEW_DSP 1322 down(&chip->spos_mutex);1324 mutex_lock(&chip->spos_mutex); 1323 1325 cpcm->pcm_channel = NULL; 1324 1326 cpcm->pcm_channel_id = pcm_channel_id; … … 1329 1331 &hw_constraints_period_sizes); 1330 1332 1331 up(&chip->spos_mutex);1333 mutex_unlock(&chip->spos_mutex); 1332 1334 #else 1333 1335 chip->playback_pcm = cpcm; /* HACK */ … … 1368 1370 snd_printdd("open raw iec958 channel\n"); 1369 1371 1370 down(&chip->spos_mutex);1372 mutex_lock(&chip->spos_mutex); 1371 1373 cs46xx_iec958_pre_open (chip); 1372 up(&chip->spos_mutex);1374 mutex_unlock(&chip->spos_mutex); 1373 1375 1374 1376 return _cs46xx_playback_open_channel(substream,DSP_IEC958_CHANNEL); … … 1386 1388 err = snd_cs46xx_playback_close(substream); 1387 1389 1388 down(&chip->spos_mutex);1390 mutex_lock(&chip->spos_mutex); 1389 1391 cs46xx_iec958_post_close (chip); 1390 up(&chip->spos_mutex);1392 mutex_unlock(&chip->spos_mutex); 1391 1393 1392 1394 return err; … … 1429 1431 1430 1432 #ifdef CONFIG_SND_CS46XX_NEW_DSP 1431 down(&chip->spos_mutex);1433 mutex_lock(&chip->spos_mutex); 1432 1434 if (cpcm->pcm_channel) { 1433 1435 cs46xx_dsp_destroy_pcm_channel(chip,cpcm->pcm_channel); 1434 1436 cpcm->pcm_channel = NULL; 1435 1437 } 1436 up(&chip->spos_mutex);1438 mutex_unlock(&chip->spos_mutex); 1437 1439 #else 1438 1440 chip->playback_pcm = NULL; … … 1849 1851 switch (kcontrol->private_value) { 1850 1852 case CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT: 1851 down(&chip->spos_mutex);1853 mutex_lock(&chip->spos_mutex); 1852 1854 change = (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED); 1853 1855 if (ucontrol->value.integer.value[0] && !change) … … 1857 1859 1858 1860 res = (change != (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED)); 1859 up(&chip->spos_mutex);1861 mutex_unlock(&chip->spos_mutex); 1860 1862 break; 1861 1863 case CS46XX_MIXER_SPDIF_INPUT_ELEMENT: … … 1998 2000 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1999 2001 2000 down(&chip->spos_mutex);2002 mutex_lock(&chip->spos_mutex); 2001 2003 ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_default >> 24) & 0xff); 2002 2004 ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_default >> 16) & 0xff); 2003 2005 ucontrol->value.iec958.status[2] = 0; 2004 2006 ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_default) & 0xff); 2005 up(&chip->spos_mutex);2007 mutex_unlock(&chip->spos_mutex); 2006 2008 2007 2009 return 0; … … 2016 2018 int change; 2017 2019 2018 down(&chip->spos_mutex);2020 mutex_lock(&chip->spos_mutex); 2019 2021 val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) | 2020 2022 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[2]) << 16) | … … 2030 2032 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); 2031 2033 2032 up(&chip->spos_mutex);2034 mutex_unlock(&chip->spos_mutex); 2033 2035 2034 2036 return change; … … 2051 2053 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 2052 2054 2053 down(&chip->spos_mutex);2055 mutex_lock(&chip->spos_mutex); 2054 2056 ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_stream >> 24) & 0xff); 2055 2057 ucontrol->value.iec958.status[1] = _wrap_all_bits((ins->spdif_csuv_stream >> 16) & 0xff); 2056 2058 ucontrol->value.iec958.status[2] = 0; 2057 2059 ucontrol->value.iec958.status[3] = _wrap_all_bits((ins->spdif_csuv_stream) & 0xff); 2058 up(&chip->spos_mutex);2060 mutex_unlock(&chip->spos_mutex); 2059 2061 2060 2062 return 0; … … 2069 2071 int change; 2070 2072 2071 down(&chip->spos_mutex);2073 mutex_lock(&chip->spos_mutex); 2072 2074 val = ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[0]) << 24) | 2073 2075 ((unsigned int)_wrap_all_bits(ucontrol->value.iec958.status[1]) << 16) | … … 2083 2085 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); 2084 2086 2085 up(&chip->spos_mutex);2087 mutex_unlock(&chip->spos_mutex); 2086 2088 2087 2089 return change; … … 2343 2345 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); 2344 2346 } else { 2345 snd_assert(0 ); /* should never happen ... */2347 snd_assert(0, return); /* should never happen ... */ 2346 2348 } 2347 2349 … … 2748 2750 #endif /* CONFIG_GAMEPORT */ 2749 2751 2752 #ifdef CONFIG_PROC_FS 2750 2753 /* 2751 2754 * proc interface … … 2763 2766 size = region->size - pos; 2764 2767 if (size > 0) { 2765 if (copy_to_user_fromio(buf, (char*)region->remap_addr + pos, size))2768 if (copy_to_user_fromio(buf, region->remap_addr + pos, size)) 2766 2769 return -EFAULT; 2767 2770 } … … 2801 2804 return 0; 2802 2805 } 2806 #else /* !CONFIG_PROC_FS */ 2807 #define snd_cs46xx_proc_init(card, chip) 2808 #define snd_cs46xx_proc_done(chip) 2809 #endif 2803 2810 2804 2811 /* … … 3037 3044 if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY) 3038 3045 goto ok1; 3039 msleep(10); 3046 //msleep(10); 3047 set_current_state(TASK_UNINTERRUPTIBLE); 3048 schedule_timeout((HZ+99)/100); 3040 3049 } 3041 3050 … … 3086 3095 if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4)) 3087 3096 goto ok2; 3088 msleep(10); 3097 //msleep(10); 3098 set_current_state(TASK_UNINTERRUPTIBLE); 3099 schedule_timeout((HZ+99)/100); 3089 3100 } 3090 3101 … … 3661 3672 int amp_saved; 3662 3673 3663 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);3664 3674 snd_pcm_suspend_all(chip->pcm); 3665 3675 // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); … … 3678 3688 pci_disable_device(pci); 3679 3689 pci_save_state(pci); 3690 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 3680 3691 return 0; 3681 3692 } … … 3715 3726 chip->active_ctrl(chip, -1); /* disable CLKRUN */ 3716 3727 chip->amplifier = amp_saved; 3717 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 3728 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 3729 printk("CS46XX: resume\n"); 3718 3730 return 0; 3719 3731 } … … 3744 3756 return err; 3745 3757 3746 chip = (struct snd_cs46xx *)kzalloc(sizeof(*chip), GFP_KERNEL);3758 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 3747 3759 if (chip == NULL) { 3748 3760 pci_disable_device(pci); … … 3751 3763 spin_lock_init(&chip->reg_lock); 3752 3764 #ifdef CONFIG_SND_CS46XX_NEW_DSP 3753 init_MUTEX(&chip->spos_mutex);3765 mutex_init(&chip->spos_mutex); 3754 3766 #endif 3755 3767 chip->card = card; -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.h
r34 r76 64 64 65 65 /*if (bank == 0) printk("snd_cs46xx_poke: %04X - %08X\n",reg >> 2,val); */ 66 writel(val, (char*)chip->region.idx[bank+1].remap_addr + offset);66 writel(val, chip->region.idx[bank+1].remap_addr + offset); 67 67 } 68 68 … … 71 71 unsigned int bank = reg >> 16; 72 72 unsigned int offset = reg & 0xffff; 73 return readl( (char*)chip->region.idx[bank+1].remap_addr + offset);73 return readl(chip->region.idx[bank+1].remap_addr + offset); 74 74 } 75 75 76 76 static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val) 77 77 { 78 writel(val, (char*)chip->region.name.ba0.remap_addr + offset);78 writel(val, chip->region.name.ba0.remap_addr + offset); 79 79 } 80 80 81 81 static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset) 82 82 { 83 return readl( (char*)chip->region.name.ba0.remap_addr + offset);83 return readl(chip->region.name.ba0.remap_addr + offset); 84 84 } 85 85 … … 89 89 struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, 90 90 int symbol_type); 91 #ifdef CONFIG_PROC_FS 91 92 int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip); 92 93 int cs46xx_dsp_proc_done (struct snd_cs46xx *chip); 94 #else 95 #define cs46xx_dsp_proc_init(card, chip) 96 #define cs46xx_dsp_proc_done(chip) 97 #endif 93 98 int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip); 94 99 int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset, … … 107 112 struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, 108 113 u32 * scb_data, u32 dest); 114 #ifdef CONFIG_PROC_FS 109 115 void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb); 110 116 void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip, 111 117 struct dsp_scb_descriptor * scb); 118 #else 119 #define cs46xx_dsp_proc_free_scb_desc(scb) 120 #define cs46xx_dsp_proc_register_scb_desc(chip, scb) 121 #endif 112 122 struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip); 113 123 struct dsp_scb_descriptor * -
GPL/trunk/alsa-kernel/pci/cs46xx/dsp_spos.c
r34 r76 29 29 #include <linux/slab.h> 30 30 #include <linux/vmalloc.h> 31 #include <linux/mutex.h> 32 31 33 #include <sound/core.h> 32 34 #include <sound/control.h> … … 234 236 ins->symbol_table.highest_frag_index = 0; 235 237 236 237 238 return NULL;238 if (ins->symbol_table.symbols == NULL) { 239 cs46xx_dsp_spos_destroy(chip); 240 goto error; 239 241 } 240 242 … … 244 246 245 247 if (ins->code.data == NULL) { 246 247 return NULL;248 cs46xx_dsp_spos_destroy(chip); 249 goto error; 248 250 } 249 251 … … 255 257 256 258 if (ins->modules == NULL) { 257 258 return NULL;259 cs46xx_dsp_spos_destroy(chip); 260 goto error; 259 261 } 260 262 … … 277 279 /* byte 3 */ (unsigned int)_wrap_all_bits( (SNDRV_PCM_DEFAULT_CON_SPDIF >> 24) & 0xff) | 278 280 /* left and right validity bits */ (1 << 13) | (1 << 12); 279 280 return ins; 281 return ins; 282 error: 283 kfree(ins); 284 return NULL; 281 285 } 282 286 … … 288 292 snd_assert(ins != NULL, return); 289 293 290 down(&chip->spos_mutex);294 mutex_lock(&chip->spos_mutex); 291 295 for (i = 0; i < ins->nscb; ++i) { 292 296 if (ins->scbs[i].deleted) continue; … … 299 303 kfree(ins->modules); 300 304 kfree(ins); 301 up(&chip->spos_mutex);305 mutex_unlock(&chip->spos_mutex); 302 306 } 303 307 … … 440 444 441 445 446 #ifdef CONFIG_PROC_FS 442 447 static struct dsp_symbol_entry * 443 448 cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx * chip, u32 address, int symbol_type) … … 497 502 int i,j; 498 503 499 down(&chip->spos_mutex);504 mutex_lock(&chip->spos_mutex); 500 505 snd_iprintf(buffer, "MODULES:\n"); 501 506 for ( i = 0; i < ins->nmodules; ++i ) { … … 510 515 } 511 516 } 512 up(&chip->spos_mutex);517 mutex_unlock(&chip->spos_mutex); 513 518 } 514 519 … … 521 526 void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; 522 527 523 down(&chip->spos_mutex);528 mutex_lock(&chip->spos_mutex); 524 529 snd_iprintf(buffer, "TASK TREES:\n"); 525 530 for ( i = 0; i < ins->ntask; ++i) { … … 538 543 539 544 snd_iprintf(buffer,"\n"); 540 up(&chip->spos_mutex);545 mutex_unlock(&chip->spos_mutex); 541 546 } 542 547 … … 548 553 int i; 549 554 550 down(&chip->spos_mutex);555 mutex_lock(&chip->spos_mutex); 551 556 snd_iprintf(buffer, "SCB's:\n"); 552 557 for ( i = 0; i < ins->nscb; ++i) { … … 571 576 572 577 snd_iprintf(buffer,"\n"); 573 up(&chip->spos_mutex);578 mutex_unlock(&chip->spos_mutex); 574 579 } 575 580 … … 852 857 ins->proc_scb_info_entry = entry; 853 858 854 down(&chip->spos_mutex);859 mutex_lock(&chip->spos_mutex); 855 860 /* register/update SCB's entries on proc */ 856 861 for (i = 0; i < ins->nscb; ++i) { … … 859 864 cs46xx_dsp_proc_register_scb_desc (chip, (ins->scbs + i)); 860 865 } 861 up(&chip->spos_mutex);866 mutex_unlock(&chip->spos_mutex); 862 867 863 868 return 0; … … 899 904 } 900 905 901 down(&chip->spos_mutex);906 mutex_lock(&chip->spos_mutex); 902 907 for (i = 0; i < ins->nscb; ++i) { 903 908 if (ins->scbs[i].deleted) continue; 904 909 cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); 905 910 } 906 up(&chip->spos_mutex);911 mutex_unlock(&chip->spos_mutex); 907 912 908 913 if (ins->proc_dsp_dir) { … … 913 918 return 0; 914 919 } 920 #endif /* CONFIG_PROC_FS */ 915 921 916 922 static int debug_tree; … … 1360 1366 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV); 1361 1367 1362 snd_assert (chip->nr_ac97_codecs == 1 || chip->nr_ac97_codecs == 2 );1368 snd_assert (chip->nr_ac97_codecs == 1 || chip->nr_ac97_codecs == 2, return -ENXIO); 1363 1369 1364 1370 if (chip->nr_ac97_codecs == 1) { … … 1510 1516 /* 8 */ 0, 1511 1517 /* 9 */ FG_TASK_HEADER_ADDR, NULL_SCB_ADDR, 1512 /* A */ spdifo_task->address,1518 /* A */ /*spdifo_task->address*/0, 1513 1519 SPDIFO_SCB_INST + SPDIFOFIFOPointer, 1514 1520 { … … 1519 1525 /* E */ 0x0108,0x0001, /* SPDIFOStMoFormat:SPDIFOFIFOBaseAddr; */ 1520 1526 /* F */ DSP_SPOS_UUUU /* SPDIFOFree; */ 1521 1527 }; 1522 1528 1523 1529 /* 0xBB0 */ … … 1533 1539 /* 8 */ DSP_SPOS_UUUU, /* TempStatus */ 1534 1540 /* 9 */ SPDIFO_SCB_INST, NULL_SCB_ADDR, 1535 /* A */ spdifi_task->address,1541 /* A */ /*spdifi_task->address*/0, 1536 1542 SPDIFI_SCB_INST + SPDIFIFIFOPointer, 1537 1543 /* NOTE: The SPDIF input task write the sample in mono … … 1544 1550 /* E */ 0x01f0,0x0001, 1545 1551 /* F */ DSP_SPOS_UUUU /* SPDIN_STATUS monitor */ 1546 1552 }; 1547 1553 1548 1554 /* 0xBA0 */ … … 1558 1564 /* 8 */ DSP_SPOS_UUUU, 1559 1565 /* 9 */ SPDIFI_SCB_INST,NULL_SCB_ADDR, 1560 /* A */ s16_async_codec_input_task->address,1566 /* A */ /*s16_async_codec_input_task->address*/0, 1561 1567 HFG_TREE_SCB + AsyncCIOFIFOPointer, 1562 1568 … … 1596 1602 the output buffer of this task */ 1597 1603 /* F */ 0, /* DSP_SPOS_UUUU */ 1598 }; 1604 }; 1605 1606 spdifo_scb.entry_point = spdifo_task->address; 1607 spdifi_scb.entry_point = spdifi_task->address; 1608 async_codec_input_scb.io_entry_point = 1609 s16_async_codec_input_task->address; 1599 1610 1600 1611 spdifo_scb_desc = cs46xx_dsp_create_scb(chip,"SPDIFOSCB",(u32 *)&spdifo_scb,SPDIFO_SCB_INST); … … 1693 1704 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1694 1705 1695 down(&chip->spos_mutex);1706 mutex_lock(&chip->spos_mutex); 1696 1707 1697 1708 if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED) ) { … … 1737 1748 /* monitor state */ 1738 1749 ins->spdif_status_in = 1; 1739 up(&chip->spos_mutex);1750 mutex_unlock(&chip->spos_mutex); 1740 1751 1741 1752 return 0; … … 1749 1760 snd_assert (ins->spdif_in_src != NULL,return -EINVAL); 1750 1761 1751 down(&chip->spos_mutex);1762 mutex_lock(&chip->spos_mutex); 1752 1763 1753 1764 /* Remove the asynchronous receiver SCB */ … … 1759 1770 /* monitor state */ 1760 1771 ins->spdif_status_in = 0; 1761 up(&chip->spos_mutex);1772 mutex_unlock(&chip->spos_mutex); 1762 1773 1763 1774 /* restore amplifier */ … … 1775 1786 snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); 1776 1787 1777 down(&chip->spos_mutex);1788 mutex_lock(&chip->spos_mutex); 1778 1789 ins->pcm_input = cs46xx_add_record_source(chip,ins->ref_snoop_scb,PCMSERIALIN_PCM_SCB_ADDR, 1779 1790 "PCMSerialInput_Wave"); 1780 up(&chip->spos_mutex);1791 mutex_unlock(&chip->spos_mutex); 1781 1792 1782 1793 return 0; … … 1789 1800 snd_assert (ins->pcm_input != NULL,return -EINVAL); 1790 1801 1791 down(&chip->spos_mutex);1802 mutex_lock(&chip->spos_mutex); 1792 1803 cs46xx_dsp_remove_scb (chip,ins->pcm_input); 1793 1804 ins->pcm_input = NULL; 1794 up(&chip->spos_mutex);1805 mutex_unlock(&chip->spos_mutex); 1795 1806 1796 1807 return 0; … … 1804 1815 snd_assert (ins->codec_in_scb != NULL,return -EINVAL); 1805 1816 1806 down(&chip->spos_mutex);1817 mutex_lock(&chip->spos_mutex); 1807 1818 ins->adc_input = cs46xx_add_record_source(chip,ins->codec_in_scb,PCMSERIALIN_SCB_ADDR, 1808 1819 "PCMSerialInput_ADC"); 1809 up(&chip->spos_mutex);1820 mutex_unlock(&chip->spos_mutex); 1810 1821 1811 1822 return 0; … … 1818 1829 snd_assert (ins->adc_input != NULL,return -EINVAL); 1819 1830 1820 down(&chip->spos_mutex);1831 mutex_lock(&chip->spos_mutex); 1821 1832 cs46xx_dsp_remove_scb (chip,ins->adc_input); 1822 1833 ins->adc_input = NULL; 1823 up(&chip->spos_mutex);1834 mutex_unlock(&chip->spos_mutex); 1824 1835 1825 1836 return 0; … … 1868 1879 struct dsp_scb_descriptor * scb; 1869 1880 1870 down(&chip->spos_mutex);1881 mutex_lock(&chip->spos_mutex); 1871 1882 1872 1883 /* main output */ … … 1887 1898 ins->dac_volume_right = right; 1888 1899 1889 up(&chip->spos_mutex);1900 mutex_unlock(&chip->spos_mutex); 1890 1901 1891 1902 return 0; … … 1896 1907 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 1897 1908 1898 down(&chip->spos_mutex);1909 mutex_lock(&chip->spos_mutex); 1899 1910 1900 1911 if (ins->asynch_rx_scb != NULL) … … 1905 1916 ins->spdif_input_volume_right = right; 1906 1917 1907 up(&chip->spos_mutex);1918 mutex_unlock(&chip->spos_mutex); 1908 1919 1909 1920 return 0; -
GPL/trunk/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c
r34 r76 29 29 #include <linux/init.h> 30 30 #include <linux/slab.h> 31 #include <linux/mutex.h> 32 31 33 #include <sound/core.h> 32 34 #include <sound/control.h> … … 65 67 } 66 68 69 #ifdef CONFIG_PROC_FS 67 70 static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, 68 71 struct snd_info_buffer *buffer) … … 77 80 ins = chip->dsp_spos_instance; 78 81 79 down(&chip->spos_mutex);82 mutex_lock(&chip->spos_mutex); 80 83 snd_iprintf(buffer,"%04x %s:\n",scb->address,scb->scb_name); 81 84 … … 105 108 106 109 snd_iprintf(buffer,"index [%d] ref_count [%d]\n",scb->index,scb->ref_count); 107 up(&chip->spos_mutex); 108 } 110 mutex_unlock(&chip->spos_mutex); 111 } 112 #endif 109 113 110 114 static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) … … 221 225 222 226 227 #ifdef CONFIG_PROC_FS 223 228 void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb) 224 229 { … … 276 281 } 277 282 } 283 #endif /* CONFIG_PROC_FS */ 278 284 279 285 static struct dsp_scb_descriptor * … … 425 431 0, /* COstrmRsConfig */ 426 432 0, /* COstrmBufPtr */ 427 channel_disp,fifo_addr, /* leftChanBaseIOaddr:rightChanIOdisp */433 /*channel_disp*/0,/*fifo_addr*/0, /* leftChanBaseIOaddr:rightChanIOdisp */ 428 434 0x0000,0x0080, /* (!AC97!) COexpVolChangeRate:COscaleShiftCount */ 429 0,child_scb_addr /* COreserved - need child scb to work with rom code */ 430 }; 431 432 435 0,/*child_scb_addr*/0 /* COreserved - need child scb to work with rom code */ 436 }; 437 438 codec_out_scb.left_chan_base_IO_addr = channel_disp; 439 codec_out_scb.right_chan_IO_disp = fifo_addr; 440 codec_out_scb.last_sub_ptr = child_scb_addr; 441 433 442 scb = cs46xx_dsp_create_generic_scb(chip,codec_name,(u32 *)&codec_out_scb, 434 443 dest,"S16_CODECOUTPUTTASK",parent_scb, … … 468 477 469 478 RSCONFIG_SAMPLE_16STEREO + RSCONFIG_MODULO_64, /* strmRsConfig */ 470 sample_buffer_addr << 0x10, /* strmBufPtr; defined as a dword ptr, used as a byte ptr */471 channel_disp,fifo_addr, /* (!AC97!) leftChanBaseINaddr=AC97primary479 /*sample_buffer_addr << 0x10*/0, /* strmBufPtr; defined as a dword ptr, used as a byte ptr */ 480 /*channel_disp*/0,/*fifo_addr*/0, /* (!AC97!) leftChanBaseINaddr=AC97primary 472 481 link input slot 3 :rightChanINdisp=""slot 4 */ 473 482 0x0000,0x0000, /* (!AC97!) ????:scaleShiftCount; no shift needed … … 475 484 0x80008000 /* ??clw cwcgame.scb has 0 */ 476 485 }; 477 486 487 codec_input_scb.strm_buf_ptr = sample_buffer_addr << 0x10; 488 codec_input_scb.rightChanINdisp = channel_disp; 489 codec_input_scb.left_chan_base_IN_addr = fifo_addr; 490 478 491 scb = cs46xx_dsp_create_generic_scb(chip,codec_name,(u32 *)&codec_input_scb, 479 492 dest,"S16_CODECINPUTTASK",parent_scb, … … 546 559 NULL_SCB_ADDR,NULL_SCB_ADDR, 547 560 /* Pointer to this tasks parameter block & stream function pointer */ 548 0,NULL_SCB_ADDR, 561 0,NULL_SCB_ADDR, 562 #ifndef TARGET_OS2 549 563 /* rsConfig register for stream buffer (rsDMA reg. is loaded from basicReq.daw */ 550 564 /* for incoming streams, or basicReq.saw, for outgoing streams) */ … … 554 568 ((dest >> 4) << RSCONFIG_STREAM_NUM_SHIFT) + /* stream number = SCBaddr/16 */ 555 569 RSCONFIG_SAMPLE_16STEREO + 556 RSCONFIG_MODULO_32, /* dest buffer(PCMreaderBuf) is 32 dwords (256 bytes) */ 570 RSCONFIG_MODULO_32, /* dest buffer(PCMreaderBuf) is 32 dwords (256 bytes) */ 571 #else 572 0, 573 #endif 557 574 /* Stream sample pointer & MAC-unit mode for this stream */ 558 (sample_buffer_addr << 0x10),575 /*(sample_buffer_addr << 0x10)*/0, 559 576 /* Fractional increment per output sample in the input sample buffer */ 560 577 0, … … 565 582 0xffff,0xffff 566 583 } 567 }; 584 }; 585 586 pcm_reader_scb.strm_rs_config = RSCONFIG_DMA_ENABLE + 587 (19 << RSCONFIG_MAX_DMA_SIZE_SHIFT) + 588 ((dest >> 4) << RSCONFIG_STREAM_NUM_SHIFT) + 589 RSCONFIG_SAMPLE_16STEREO + 590 RSCONFIG_MODULO_32; 591 pcm_reader_scb.strm_buf_ptr = sample_buffer_addr << 0x10; 568 592 569 593 if (ins->null_algorithm == NULL) { … … 672 696 /* wont work with any other rate than 673 697 the native DSP rate */ 674 snd_assert (rate = 48000);698 snd_assert (rate == 48000, return NULL); 675 699 676 700 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, … … 1243 1267 case DSP_PCM_S71_CHANNEL: 1244 1268 /* TODO */ 1245 snd_assert(0 );1269 snd_assert(0, return NULL); 1246 1270 break; 1247 1271 case DSP_IEC958_CHANNEL: … … 1259 1283 break; 1260 1284 default: 1261 snd_assert (0 );1285 snd_assert (0, return NULL); 1262 1286 return NULL; 1263 1287 } … … 1316 1340 } 1317 1341 1318 s printf (scb_name,"SrcTask_SCB%d",src_index);1342 snprintf (scb_name,DSP_MAX_SCB_NAME,"SrcTask_SCB%d",src_index); 1319 1343 1320 1344 snd_printdd( "dsp_spos: creating SRC \"%s\"\n",scb_name); … … 1340 1364 1341 1365 1342 s printf (scb_name,"PCMReader_SCB%d",pcm_index);1366 snprintf (scb_name,DSP_MAX_SCB_NAME,"PCMReader_SCB%d",pcm_index); 1343 1367 1344 1368 snd_printdd( "dsp_spos: creating PCM \"%s\" (%d)\n",scb_name, -
GPL/trunk/alsa-kernel/pci/cs46xx/makefile.os2
r32 r76 3 3 4 4 CDEFINES = -D__KERNEL__ -DMODULE -dTARGET_OS2 -dALSA_BUILD -D__ISAPNP__ -DCONFIG_ISAPNP -D__i386_ 5 #- dCONFIG_SND_CS46XX_NEW_DSP5 #-DCONFIG_SND_CS46XX_NEW_DSP 6 6 7 7 32BIT=1 … … 14 14 # 15 15 #=================================================================== 16 FILE1 = cs46xx.obj cs46xx_lib.obj 17 ##dsp_spos.obj dsp_spos_scb_lib.obj 18 FILE2 = 16 FILE1 = cs46xx.obj cs46xx_lib.obj 17 #FILE2 = dsp_spos.obj dsp_spos_scb_lib.obj 19 18 FILE3 = 20 19 FILE4 = -
GPL/trunk/alsa-kernel/pci/es1968.c
r32 r76 1817 1817 offset &= 0xfffe; 1818 1818 offset += chip->measure_count * (CLOCK_MEASURE_BUFSIZE/2); 1819 1819 #if 0 /* vladest patch baseg on r.ihle suggestion */ 1820 1820 t = stop_time.tv_sec - start_time.tv_sec; 1821 1821 t *= 1000000; … … 1824 1824 else 1825 1825 t += stop_time.tv_usec - start_time.tv_usec; 1826 #else 1827 t = 50000; 1828 #endif 1826 1829 if (t == 0) { 1827 1830 snd_printk("?? calculation error..\n"); -
GPL/trunk/alsa-kernel/pci/hda/hda_codec.c
r69 r76 530 530 bus->caddr_tbl[codec_addr] = codec; 531 531 532 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID); 532 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID); 533 if (codec->vendor_id == -1) 534 /* read again, hopefully the access method was corrected 535 * in the last read... 536 */ 537 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, 538 AC_PAR_VENDOR_ID); 533 539 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_SUBSYSTEM_ID); 534 540 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_REV_ID); … … 723 729 * read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit. 724 730 */ 725 static int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int index) 731 int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, 732 int direction, int index) 726 733 { 727 734 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); … … 734 741 * update the AMP value, mask = bit mask to set, val = the value 735 742 */ 736 static int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int idx, int mask, int val) 743 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, 744 int direction, int idx, int mask, int val) 737 745 { 738 746 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); … … 863 871 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 864 872 0x80, *valp ? 0 : 0x80); 865 873 866 874 return change; 867 875 } … … 1890 1898 if (mout->hp_nid) 1891 1899 /* headphone out will just decode front left/right (stereo) */ 1892 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 1900 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 1901 /* extra outputs copied from front */ 1902 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 1903 if (mout->extra_out_nid[i]) 1904 snd_hda_codec_setup_stream(codec, 1905 mout->extra_out_nid[i], 1906 stream_tag, 0, format); 1907 1893 1908 /* surrounds */ 1894 1909 for (i = 1; i < mout->num_dacs; i++) { … … 1914 1929 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0); 1915 1930 if (mout->hp_nid) 1916 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0); 1931 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0); 1932 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 1933 if (mout->extra_out_nid[i]) 1934 snd_hda_codec_setup_stream(codec, 1935 mout->extra_out_nid[i], 1936 0, 0, 0); 1917 1937 down(&codec->spdif_mutex); 1918 1938 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) { … … 1936 1956 } 1937 1957 1938 /* parse all pin widgets and store the useful pin nids to cfg */ 1958 /* 1959 * Parse all pin widgets and store the useful pin nids to cfg 1960 * 1961 * The number of line-outs or any primary output is stored in line_outs, 1962 * and the corresponding output pins are assigned to line_out_pins[], 1963 * in the order of front, rear, CLFE, side, ... 1964 * 1965 * If more extra outputs (speaker and headphone) are found, the pins are 1966 * assisnged to hp_pin and speaker_pins[], respectively. If no line-out jack 1967 * is detected, one of speaker of HP pins is assigned as the primary 1968 * output, i.e. to line_out_pins[0]. So, line_outs is always positive 1969 * if any analog output exists. 1970 * 1971 * The analog input pins are assigned to input_pins array. 1972 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 1973 * respectively. 1974 */ 1939 1975 int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 1940 1976 hda_nid_t *ignore_nids) 1941 1977 { 1942 1978 hda_nid_t nid, nid_start; 1943 1944 short seq, sequences[4], assoc_line_out;1979 int i, j, nodes; 1980 short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)]; 1945 1981 1946 1982 memset(cfg, 0, sizeof(*cfg)); … … 1983 2019 cfg->line_outs++; 1984 2020 break; 1985 case AC_JACK_SPEAKER: 1986 cfg->speaker_pin = nid; 1987 break; 2021 case AC_JACK_SPEAKER: 2022 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 2023 continue; 2024 cfg->speaker_pins[cfg->speaker_outs] = nid; 2025 cfg->speaker_outs++; 2026 break; 1988 2027 case AC_JACK_HP_OUT: 1989 2028 cfg->hp_pin = nid; … … 2048 2087 break; 2049 2088 } 2089 /* 2090 * debug prints of the parsed results 2091 */ 2092 snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", 2093 cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1], 2094 cfg->line_out_pins[2], cfg->line_out_pins[3], 2095 cfg->line_out_pins[4]); 2096 snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", 2097 cfg->speaker_outs, cfg->speaker_pins[0], 2098 cfg->speaker_pins[1], cfg->speaker_pins[2], 2099 cfg->speaker_pins[3], cfg->speaker_pins[4]); 2100 snd_printd(" hp=0x%x, dig_out=0x%x, din_in=0x%x\n", 2101 cfg->hp_pin, cfg->dig_out_pin, cfg->dig_in_pin); 2102 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x," 2103 " cd=0x%x, aux=0x%x\n", 2104 cfg->input_pins[AUTO_PIN_MIC], 2105 cfg->input_pins[AUTO_PIN_FRONT_MIC], 2106 cfg->input_pins[AUTO_PIN_LINE], 2107 cfg->input_pins[AUTO_PIN_FRONT_LINE], 2108 cfg->input_pins[AUTO_PIN_CD], 2109 cfg->input_pins[AUTO_PIN_AUX]); 2110 2111 /* 2112 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin 2113 * as a primary output 2114 */ 2115 if (! cfg->line_outs) { 2116 if (cfg->speaker_outs) { 2117 cfg->line_outs = cfg->speaker_outs; 2118 memcpy(cfg->line_out_pins, cfg->speaker_pins, 2119 sizeof(cfg->speaker_pins)); 2120 cfg->speaker_outs = 0; 2121 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); 2122 } else if (cfg->hp_pin) { 2123 cfg->line_outs = 1; 2124 cfg->line_out_pins[0] = cfg->hp_pin; 2125 cfg->hp_pin = 0; 2126 } 2127 } 2050 2128 2051 2129 return 0; -
GPL/trunk/alsa-kernel/pci/hda/hda_generic.c
r69 r76 48 48 /* patch-specific record */ 49 49 struct hda_gspec { 50 struct hda_gnode *dac_node;/* DAC node */51 struct hda_gnode *out_pin_node;/* Output pin (Line-Out) node */52 struct hda_gnode *pcm_vol_node;/* Node for PCM volume */53 unsigned int pcm_vol_index;/* connection of PCM volume */50 struct hda_gnode *dac_node[2]; /* DAC node */ 51 struct hda_gnode *out_pin_node[2]; /* Output pin (Line-Out) node */ 52 struct hda_gnode *pcm_vol_node[2]; /* Node for PCM volume */ 53 unsigned int pcm_vol_index[2]; /* connection of PCM volume */ 54 54 55 55 struct hda_gnode *adc_node; /* ADC node */ … … 70 70 * retrieve the default device type from the default config value 71 71 */ 72 #define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 73 #define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 74 72 #define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> \ 73 AC_DEFCFG_DEVICE_SHIFT) 74 #define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> \ 75 AC_DEFCFG_LOCATION_SHIFT) 76 #define defcfg_port_conn(node) (((node)->def_cfg & AC_DEFCFG_PORT_CONN) >> \ 77 AC_DEFCFG_PORT_CONN_SHIFT) 75 78 /* 76 79 * destructor … … 262 265 */ 263 266 static int parse_output_path(struct hda_codec *codec, struct hda_gspec *spec, 264 struct hda_gnode *node)267 struct hda_gnode *node, int dac_idx) 265 268 { 266 269 int i, err; … … 276 279 return 0; 277 280 } 278 279 if (spec->dac_node) {280 281 return node == spec->dac_node;282 283 spec->dac_node= node;284 285 spec->pcm_vol_node= node;286 spec->pcm_vol_index= 0;281 snd_printdd("AUD_OUT found %x\n", node->nid); 282 if (spec->dac_node[dac_idx]) { 283 /* already DAC node is assigned, just unmute & connect */ 284 return node == spec->dac_node[dac_idx]; 285 } 286 spec->dac_node[dac_idx] = node; 287 if (node->wid_caps & AC_WCAP_OUT_AMP) { 288 spec->pcm_vol_node[dac_idx] = node; 289 spec->pcm_vol_index[dac_idx] = 0; 287 290 } 288 291 return 1; /* found */ … … 292 295 child = hda_get_node(spec, node->conn_list[i]); 293 296 if (! child) 294 295 err = parse_output_path(codec, spec, child);297 continue; 298 err = parse_output_path(codec, spec, child, dac_idx); 296 299 if (err < 0) 297 300 return err; … … 303 306 select_input_connection(codec, node, i); 304 307 unmute_input(codec, node, i); 305 306 if (! spec->pcm_vol_node) {307 308 spec->pcm_vol_node= node;309 spec->pcm_vol_index= i;310 311 spec->pcm_vol_node= node;312 spec->pcm_vol_index= 0;313 308 unmute_output(codec, node); 309 if (! spec->pcm_vol_node[dac_idx]) { 310 if (node->wid_caps & AC_WCAP_IN_AMP) { 311 spec->pcm_vol_node[dac_idx] = node; 312 spec->pcm_vol_index[dac_idx] = i; 313 } else if (node->wid_caps & AC_WCAP_OUT_AMP) { 314 spec->pcm_vol_node[dac_idx] = node; 315 spec->pcm_vol_index[dac_idx] = 0; 316 } 314 317 } 315 318 return 1; … … 339 342 /* output capable? */ 340 343 if (! (node->pin_caps & AC_PINCAP_OUT)) 341 continue; 344 continue; 345 if (defcfg_port_conn(node) == AC_JACK_PORT_NONE) 346 continue; /* unconnected */ 342 347 if (jack_type >= 0) { 343 348 if (jack_type != defcfg_type(node)) … … 350 355 continue; 351 356 } 352 353 err = parse_output_path(codec, spec, node);357 clear_check_flags(spec); 358 err = parse_output_path(codec, spec, node, 0); 354 359 if (err < 0) 355 return NULL; 356 else if (err > 0) { 360 return NULL; 361 if (! err && spec->out_pin_node[0]) { 362 err = parse_output_path(codec, spec, node, 1); 363 if (err < 0) 364 return NULL; 365 } 366 if (err > 0) { 357 367 /* unmute the PIN output */ 358 368 unmute_output(codec, node); … … 381 391 /* first, look for the line-out pin */ 382 392 node = parse_output_jack(codec, spec, AC_JACK_LINE_OUT); 383 if (node) /* found, remember the PIN node */ 384 spec->out_pin_node = node; 393 if (node) /* found, remember the PIN node */ 394 spec->out_pin_node[0] = node; 395 else { 396 /* if no line-out is found, try speaker out */ 397 node = parse_output_jack(codec, spec, AC_JACK_SPEAKER); 398 if (node) 399 spec->out_pin_node[0] = node; 400 } 385 401 /* look for the HP-out pin */ 386 402 node = parse_output_jack(codec, spec, AC_JACK_HP_OUT); 387 if (node) { 388 if (! spec->out_pin_node) 389 spec->out_pin_node = node; 390 } 391 392 if (! spec->out_pin_node) { 403 if (node) { 404 if (! spec->out_pin_node[0]) 405 spec->out_pin_node[0] = node; 406 else 407 spec->out_pin_node[1] = node; 408 } 409 410 if (! spec->out_pin_node[0]) { 393 411 /* no line-out or HP pins found, 394 412 * then choose for the first output pin 395 396 spec->out_pin_node= parse_output_jack(codec, spec, -1);397 if (! spec->out_pin_node)398 413 */ 414 spec->out_pin_node[0] = parse_output_jack(codec, spec, -1); 415 if (! spec->out_pin_node[0]) 416 snd_printd("hda_generic: no proper output path found\n"); 399 417 } 400 418 … … 506 524 return 0; 507 525 508 if (node->wid_caps & AC_WCAP_DIGITAL) 526 if (defcfg_port_conn(node) == AC_JACK_PORT_NONE) 527 return 0; /* unconnected */ 528 529 if (node->wid_caps & AC_WCAP_DIGITAL) 509 530 return 0; /* skip SPDIF */ 510 531 … … 549 570 // awk added - fixed no recording due to muted widget 550 571 unmute_input(codec, adc_node, 0); 551 572 552 573 /* 553 574 * check each connection of the ADC … … 732 753 { 733 754 struct hda_gspec *spec = codec->spec; 734 int err; 735 736 err = create_mixer(codec, spec->pcm_vol_node, spec->pcm_vol_index, 737 "PCM", "Playback"); 738 if (err < 0) 739 return err; 755 static const char *types[2] = { "Master", "Headphone" }; 756 int i, err; 757 758 for (i = 0; i < 2 && spec->pcm_vol_node[i]; i++) { 759 err = create_mixer(codec, spec->pcm_vol_node[i], 760 spec->pcm_vol_index[i], 761 types[i], "Playback"); 762 if (err < 0) 763 return err; 764 } 740 765 return 0; 741 766 } … … 834 859 const char *type; 835 860 836 if (! spec->out_pin_node)861 if (! spec->out_pin_node[0]) 837 862 return 0; 838 863 … … 848 873 if (check_existing_control(codec, type, "Playback")) 849 874 continue; 850 clear_check_flags(spec); 851 err = parse_loopback_path(codec, spec, spec->out_pin_node, 875 clear_check_flags(spec); 876 err = parse_loopback_path(codec, spec, 877 spec->out_pin_node[0], 852 878 node, type); 853 879 if (err < 0) … … 884 910 }; 885 911 912 static int generic_pcm2_prepare(struct hda_pcm_stream *hinfo, 913 struct hda_codec *codec, 914 unsigned int stream_tag, 915 unsigned int format, 916 struct snd_pcm_substream *substream) 917 { 918 struct hda_gspec *spec = codec->spec; 919 920 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); 921 snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 922 stream_tag, 0, format); 923 return 0; 924 } 925 926 static int generic_pcm2_cleanup(struct hda_pcm_stream *hinfo, 927 struct hda_codec *codec, 928 struct snd_pcm_substream *substream) 929 { 930 struct hda_gspec *spec = codec->spec; 931 932 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); 933 snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 0, 0, 0); 934 return 0; 935 } 936 886 937 static int build_generic_pcms(struct hda_codec *codec) 887 938 { … … 889 940 struct hda_pcm *info = &spec->pcm_rec; 890 941 891 if (! spec->dac_node&& ! spec->adc_node) {942 if (! spec->dac_node[0] && ! spec->adc_node) { 892 943 snd_printd("hda_generic: no PCM found\n"); 893 944 return 0; … … 897 948 codec->pcm_info = info; 898 949 899 info->name = "HDA Generic"; 900 if (spec->dac_node) { 901 info->stream[0] = generic_pcm_playback; 902 info->stream[0].nid = spec->dac_node->nid; 950 info->name = "HDA Generic"; 951 if (spec->dac_node[0]) { 952 info->stream[0] = generic_pcm_playback; 953 info->stream[0].nid = spec->dac_node[0]->nid; 954 if (spec->dac_node[1]) { 955 info->stream[0].ops.prepare = generic_pcm2_prepare; 956 info->stream[0].ops.cleanup = generic_pcm2_cleanup; 957 } 903 958 } 904 959 if (spec->adc_node) { -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.c
r69 r76 31 31 * 32 32 * 2004.12.01 Major rewrite by tiwai, merged the work of pshou 33 * 33 * 34 34 */ 35 35 … … 104 104 #define ICH6_REG_INTSTS 0x24 105 105 #define ICH6_REG_WALCLK 0x30 106 #define ICH6_REG_SYNC 0x34 106 #define ICH6_REG_SYNC 0x34 107 107 #define ICH6_REG_CORBLBASE 0x40 108 108 #define ICH6_REG_CORBUBASE 0x44 … … 250 250 unsigned int frags; /* number for period in the play buffer */ 251 251 unsigned int fifo_size; /* FIFO size */ 252 unsigned int last_pos; /* last updated period position */253 252 254 253 void __iomem *sd_addr; /* stream descriptor pointer */ … … 260 259 unsigned int format_val; /* format value to be set in the controller and the codec */ 261 260 unsigned char stream_tag; /* assigned stream */ 262 unsigned char index; /* stream index */ 261 unsigned char index; /* stream index */ 262 /* for sanity check of position buffer */ 263 unsigned int period_intr; 263 264 264 265 unsigned int opened: 1; 265 266 unsigned int running: 1; 266 unsigned int period_updating: 1;267 267 }; 268 268 … … 446 446 447 447 /* send a command */ 448 static int azx_ send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,448 static int azx_corb_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, 449 449 unsigned int verb, unsigned int para) 450 450 { … … 485 485 return; 486 486 chip->rirb.wp = wp; 487 487 488 488 while (chip->rirb.rp != wp) { 489 489 chip->rirb.rp++; … … 503 503 504 504 /* receive a response */ 505 static unsigned int azx_ get_response(struct hda_codec *codec)505 static unsigned int azx_rirb_get_response(struct hda_codec *codec) 506 506 { 507 507 struct azx *chip = codec->bus->private_data; … … 509 509 510 510 while (chip->rirb.cmds) { 511 if (! --timeout) { 512 if (printk_ratelimit()) 513 snd_printk(KERN_ERR 514 "azx_get_response timeout\n"); 515 chip->rirb.rp = azx_readb(chip, RIRBWP); 516 chip->rirb.cmds = 0; 517 return -1; 518 } 519 msleep(1); 511 if (! --timeout) { 512 snd_printk(KERN_ERR 513 "hda_intel: azx_get_response timeout, " 514 "switching to single_cmd mode...\n"); 515 chip->rirb.rp = azx_readb(chip, RIRBWP); 516 chip->rirb.cmds = 0; 517 /* switch to single_cmd mode */ 518 chip->single_cmd = 1; 519 azx_free_cmd_io(chip); 520 return -1; 521 } 522 msleep(1); 520 523 } 521 524 return chip->rirb.res; /* the last value */ … … 578 581 } 579 582 583 /* 584 * The below are the main callbacks from hda_codec. 585 * 586 * They are just the skeleton to call sub-callbacks according to the 587 * current setting of chip->single_cmd. 588 */ 589 590 /* send a command */ 591 static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, 592 int direct, unsigned int verb, 593 unsigned int para) 594 { 595 struct azx *chip = codec->bus->private_data; 596 if (chip->single_cmd) 597 return azx_single_send_cmd(codec, nid, direct, verb, para); 598 else 599 return azx_corb_send_cmd(codec, nid, direct, verb, para); 600 } 601 602 /* get a response */ 603 static unsigned int azx_get_response(struct hda_codec *codec) 604 { 605 struct azx *chip = codec->bus->private_data; 606 if (chip->single_cmd) 607 return azx_single_get_response(codec); 608 else 609 return azx_rirb_get_response(codec); 610 } 611 612 580 613 /* reset codec link */ 581 614 static int azx_reset(struct azx *chip) … … 626 659 /* 627 660 * Lowlevel interface 628 */ 661 */ 629 662 630 663 /* enable interrupts */ … … 733 766 case AZX_DRIVER_ATI: 734 767 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 735 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 768 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 736 769 ®); 737 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 770 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 738 771 (reg & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP); 739 772 break; … … 765 798 return IRQ_NONE; 766 799 } 767 800 768 801 for (i = 0; i < chip->num_streams; i++) { 769 802 azx_dev = &chip->azx_dev[i]; 770 803 if (status & azx_dev->sd_int_sta_mask) { 771 804 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 772 773 azx_dev->period_updating = 1;805 if (azx_dev->substream && azx_dev->running) { 806 azx_dev->period_intr++; 774 807 spin_unlock(&chip->reg_lock); 775 808 snd_pcm_period_elapsed(azx_dev->substream); 776 809 spin_lock(&chip->reg_lock); 777 azx_dev->period_updating = 0;778 810 } 779 811 } … … 794 826 #endif 795 827 spin_unlock(&chip->reg_lock); 796 828 797 829 return IRQ_HANDLED; 798 830 } … … 899 931 bus_temp.private_data = chip; 900 932 bus_temp.modelname = model; 901 bus_temp.pci = chip->pci; 902 if (chip->single_cmd) { 903 bus_temp.ops.command = azx_single_send_cmd; 904 bus_temp.ops.get_response = azx_single_get_response; 905 } else { 906 bus_temp.ops.command = azx_send_cmd; 907 bus_temp.ops.get_response = azx_get_response; 908 } 933 bus_temp.pci = chip->pci; 934 bus_temp.ops.command = azx_send_cmd; 935 bus_temp.ops.get_response = azx_get_response; 909 936 910 937 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0) … … 1091 1118 else 1092 1119 azx_dev->fifo_size = 0; 1093 azx_dev->last_pos = 0;1094 1120 1095 1121 return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag, … … 1139 1165 unsigned int pos; 1140 1166 1141 if (chip->position_fix == POS_FIX_POSBUF) { 1167 if (chip->position_fix == POS_FIX_POSBUF || 1168 chip->position_fix == POS_FIX_AUTO) { 1142 1169 /* use the position buffer */ 1143 pos = *azx_dev->posbuf; 1144 } else { 1170 pos = *azx_dev->posbuf; 1171 if (chip->position_fix == POS_FIX_AUTO && 1172 azx_dev->period_intr == 1 && ! pos) { 1173 printk(KERN_WARNING 1174 "hda-intel: Invalid position buffer, " 1175 "using LPIB read method instead.\n"); 1176 chip->position_fix = POS_FIX_NONE; 1177 goto read_lpib; 1178 } 1179 } else { 1180 read_lpib: 1145 1181 /* read LPIB */ 1146 1182 pos = azx_sd_readl(azx_dev, SD_LPIB); … … 1307 1343 for (i = 0; i < chip->pcm_devs; i++) 1308 1344 snd_pcm_suspend_all(chip->pcm[i]); 1309 snd_hda_suspend(chip->bus, state); 1310 if (! chip->single_cmd) 1311 azx_free_cmd_io(chip); 1345 snd_hda_suspend(chip->bus, state); 1346 azx_free_cmd_io(chip); 1312 1347 pci_disable_device(pci); 1313 1348 pci_save_state(pci); … … 1346 1381 azx_int_clear(chip); 1347 1382 1348 /* disable CORB/RIRB */ 1349 if (! chip->single_cmd) 1350 azx_free_cmd_io(chip); 1383 /* disable CORB/RIRB */ 1384 azx_free_cmd_io(chip); 1351 1385 1352 1386 /* disable position buffer */ … … 1396 1430 1397 1431 *rchip = NULL; 1398 1432 1399 1433 if ((err = pci_enable_device(pci)) < 0) 1400 1434 return err; 1401 1435 1402 1436 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1403 1437 1404 1438 if (NULL == chip) { 1405 1439 snd_printk(KERN_ERR SFX "cannot allocate chip\n"); … … 1415 1449 chip->driver_type = driver_type; 1416 1450 1417 chip->position_fix = position_fix ? position_fix : POS_FIX_POSBUF;1451 chip->position_fix = position_fix; 1418 1452 chip->single_cmd = single_cmd; 1419 1453 -
GPL/trunk/alsa-kernel/pci/hda/hda_local.h
r69 r76 67 67 int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 68 68 int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 69 /* lowlevel accessor with caching; use carefully */ 70 int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, 71 int direction, int index); 72 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, 73 int direction, int idx, int mask, int val); 69 74 70 75 /* mono switch binding multiple inputs */ … … 130 135 int num_dacs; /* # of DACs, must be more than 1 */ 131 136 hda_nid_t *dac_nids; /* DAC list */ 132 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 137 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 138 hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */ 133 139 hda_nid_t dig_out_nid; /* digital out audio widget */ 134 140 int max_channels; /* currently supported analog channels */ … … 216 222 struct auto_pin_cfg { 217 223 int line_outs; 218 hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ 219 hda_nid_t speaker_pin; 224 hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ 225 int speaker_outs; 226 hda_nid_t speaker_pins[5]; 220 227 hda_nid_t hp_pin; 221 228 hda_nid_t input_pins[AUTO_PIN_LAST]; -
GPL/trunk/alsa-kernel/pci/hda/patch_analog.c
r69 r76 132 132 if (err < 0) 133 133 return err; 134 } 134 } 135 135 if (spec->dig_in_nid) { 136 136 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); … … 309 309 int i; 310 310 311 ad198x_init(codec);311 codec->patch_ops.init(codec); 312 312 for (i = 0; i < spec->num_mixers; i++) 313 313 snd_hda_resume_ctls(codec, spec->mixers[i]); … … 332 332 333 333 /* 334 * EAPD control 335 * the private value = nid | (invert << 8) 336 */ 337 static int ad198x_eapd_info(struct snd_kcontrol *kcontrol, 338 struct snd_ctl_elem_info *uinfo) 339 { 340 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 341 uinfo->count = 1; 342 uinfo->value.integer.min = 0; 343 uinfo->value.integer.max = 1; 344 return 0; 345 } 346 347 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol, 348 struct snd_ctl_elem_value *ucontrol) 349 { 350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 351 struct ad198x_spec *spec = codec->spec; 352 int invert = (kcontrol->private_value >> 8) & 1; 353 if (invert) 354 ucontrol->value.integer.value[0] = ! spec->cur_eapd; 355 else 356 ucontrol->value.integer.value[0] = spec->cur_eapd; 357 return 0; 358 } 359 360 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol, 361 struct snd_ctl_elem_value *ucontrol) 362 { 363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 364 struct ad198x_spec *spec = codec->spec; 365 int invert = (kcontrol->private_value >> 8) & 1; 366 hda_nid_t nid = kcontrol->private_value & 0xff; 367 unsigned int eapd; 368 eapd = ucontrol->value.integer.value[0]; 369 if (invert) 370 eapd = !eapd; 371 if (eapd == spec->cur_eapd && ! codec->in_resume) 372 return 0; 373 spec->cur_eapd = eapd; 374 snd_hda_codec_write(codec, nid, 375 0, AC_VERB_SET_EAPD_BTLENABLE, 376 eapd ? 0x02 : 0x00); 377 return 1; 378 } 379 380 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, 381 struct snd_ctl_elem_info *uinfo); 382 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, 383 struct snd_ctl_elem_value *ucontrol); 384 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, 385 struct snd_ctl_elem_value *ucontrol); 386 387 /* 334 388 * AD1986A specific 335 389 */ … … 345 399 }; 346 400 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC }; 401 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 }; 347 402 348 403 static struct hda_input_mux ad1986a_capture_source = { … … 476 531 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), 477 532 {0} /* end */ 533 }; 534 535 /* additional mixers for 3stack mode */ 536 static struct snd_kcontrol_new ad1986a_3st_mixers[] = { 537 { 538 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 539 .name = "Channel Mode", 540 .info = ad198x_ch_mode_info, 541 .get = ad198x_ch_mode_get, 542 .put = ad198x_ch_mode_put, 543 }, 544 {0} /* end */ 545 }; 546 547 /* laptop model - 2ch only */ 548 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC }; 549 550 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = { 551 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), 552 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), 553 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT), 554 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 555 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), 556 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */ 557 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), 558 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), 559 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), 560 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), 561 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), 562 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), 563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 564 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 565 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), 566 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), 567 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), 568 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ 569 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 570 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), 571 { 572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 573 .name = "Capture Source", 574 .info = ad198x_mux_enum_info, 575 .get = ad198x_mux_enum_get, 576 .put = ad198x_mux_enum_put, 577 }, 578 {0} /* end */ 579 }; 580 581 /* laptop-eapd model - 2ch only */ 582 583 /* master controls both pins 0x1a and 0x1b */ 584 static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol, 585 struct snd_ctl_elem_value *ucontrol) 586 { 587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 588 long *valp = ucontrol->value.integer.value; 589 int change; 590 591 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, 592 0x7f, valp[0] & 0x7f); 593 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, 594 0x7f, valp[1] & 0x7f); 595 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 596 0x7f, valp[0] & 0x7f); 597 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 598 0x7f, valp[1] & 0x7f); 599 return change; 600 } 601 602 static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol, 603 struct snd_ctl_elem_value *ucontrol) 604 { 605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 606 long *valp = ucontrol->value.integer.value; 607 int change; 608 609 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, 610 0x80, valp[0] ? 0 : 0x80); 611 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, 612 0x80, valp[1] ? 0 : 0x80); 613 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 614 0x80, valp[0] ? 0 : 0x80); 615 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 616 0x80, valp[1] ? 0 : 0x80); 617 return change; 618 } 619 620 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = { 621 .num_items = 3, 622 .items = { 623 { "Mic", 0x0 }, 624 { "Internal Mic", 0x4 }, 625 { "Mix", 0x5 }, 626 }, 627 }; 628 629 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { 630 { 631 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 632 .name = "Master Playback Volume", 633 .info = snd_hda_mixer_amp_volume_info, 634 .get = snd_hda_mixer_amp_volume_get, 635 .put = ad1986a_laptop_master_vol_put, 636 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), 637 }, 638 { 639 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 640 .name = "Master Playback Switch", 641 .info = snd_hda_mixer_amp_switch_info, 642 .get = snd_hda_mixer_amp_switch_get, 643 .put = ad1986a_laptop_master_sw_put, 644 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), 645 }, 646 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), 647 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), 648 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT), 649 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), 650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 651 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 652 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 653 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), 654 { 655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 656 .name = "Capture Source", 657 .info = ad198x_mux_enum_info, 658 .get = ad198x_mux_enum_get, 659 .put = ad198x_mux_enum_put, 660 }, 661 { 662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 663 .name = "External Amplifier", 664 .info = ad198x_eapd_info, 665 .get = ad198x_eapd_get, 666 .put = ad198x_eapd_put, 667 .private_value = 0x1b | (1 << 8), /* port-D, inversed */ 668 }, 669 {0} /* end */ 478 670 }; 479 671 … … 536 728 }; 537 729 730 /* additional verbs for 3-stack model */ 731 static struct hda_verb ad1986a_3st_init_verbs[] = { 732 /* Mic and line-in selectors */ 733 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, 734 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 735 {0} /* end */ 736 }; 737 738 static struct hda_verb ad1986a_ch2_init[] = { 739 /* Surround out -> Line In */ 740 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 741 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 742 /* CLFE -> Mic in */ 743 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 744 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 745 {0} /* end */ 746 }; 747 748 static struct hda_verb ad1986a_ch4_init[] = { 749 /* Surround out -> Surround */ 750 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 751 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 752 /* CLFE -> Mic in */ 753 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 754 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 755 {0} /* end */ 756 }; 757 758 static struct hda_verb ad1986a_ch6_init[] = { 759 /* Surround out -> Surround out */ 760 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 761 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 762 /* CLFE -> CLFE */ 763 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 764 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 765 {0} /* end */ 766 }; 767 768 static struct hda_channel_mode ad1986a_modes[3] = { 769 { 2, ad1986a_ch2_init }, 770 { 4, ad1986a_ch4_init }, 771 { 6, ad1986a_ch6_init }, 772 }; 773 774 /* eapd initialization */ 775 static struct hda_verb ad1986a_eapd_init_verbs[] = { 776 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, 777 {0} 778 }; 779 780 /* models */ 781 enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD }; 782 783 static struct hda_board_config ad1986a_cfg_tbl[] = { 784 { .modelname = "6stack", .config = AD1986A_6STACK }, 785 { .modelname = "3stack", .config = AD1986A_3STACK }, 786 { .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84, 787 .config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */ 788 { .modelname = "laptop", .config = AD1986A_LAPTOP }, 789 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e, 790 .config = AD1986A_LAPTOP }, /* FSC V2060 */ 791 { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017, 792 .config = AD1986A_LAPTOP }, /* Samsung M50 */ 793 { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f, 794 .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */ 795 { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD }, 796 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024, 797 .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */ 798 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213, 799 .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */ 800 {0} 801 }; 538 802 539 803 static int patch_ad1986a(struct hda_codec *codec) 540 804 { 541 struct ad198x_spec *spec; 805 struct ad198x_spec *spec; 806 int board_config; 542 807 543 808 spec = kzalloc(sizeof(*spec), GFP_KERNEL); … … 553 818 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; 554 819 spec->num_adc_nids = 1; 555 556 spec->capsrc_nids = ad1986a_adc_nids;820 spec->adc_nids = ad1986a_adc_nids; 821 spec->capsrc_nids = ad1986a_capsrc_nids; 557 822 spec->input_mux = &ad1986a_capture_source; 558 823 spec->num_mixers = 1; … … 562 827 563 828 codec->patch_ops = ad198x_patch_ops; 829 /* override some parameters */ 830 board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl); 831 switch (board_config) { 832 case AD1986A_3STACK: 833 spec->num_mixers = 2; 834 spec->mixers[1] = ad1986a_3st_mixers; 835 spec->num_init_verbs = 2; 836 spec->init_verbs[1] = ad1986a_3st_init_verbs; 837 spec->channel_mode = ad1986a_modes; 838 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); 839 break; 840 case AD1986A_LAPTOP: 841 spec->mixers[0] = ad1986a_laptop_mixers; 842 spec->multiout.max_channels = 2; 843 spec->multiout.num_dacs = 1; 844 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 845 break; 846 case AD1986A_LAPTOP_EAPD: 847 spec->mixers[0] = ad1986a_laptop_eapd_mixers; 848 spec->num_init_verbs = 2; 849 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 850 spec->multiout.max_channels = 2; 851 spec->multiout.num_dacs = 1; 852 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 853 spec->multiout.dig_out_nid = 0; 854 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 855 break; 856 } 564 857 565 858 return 0; … … 576 869 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; 577 870 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; 871 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 }; 578 872 579 873 static struct hda_input_mux ad1983_capture_source = { … … 717 1011 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; 718 1012 spec->num_adc_nids = 1; 719 720 spec->capsrc_nids = ad1983_adc_nids;1013 spec->adc_nids = ad1983_adc_nids; 1014 spec->capsrc_nids = ad1983_capsrc_nids; 721 1015 spec->input_mux = &ad1983_capture_source; 722 1016 spec->num_mixers = 1; … … 742 1036 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; 743 1037 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; 1038 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 }; 744 1039 745 1040 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ … … 847 1142 }; 848 1143 1144 /* 1145 * Patch for HP nx6320 1146 * 1147 * nx6320 uses EAPD in the reserve way - EAPD-on means the internal 1148 * speaker output enabled _and_ mute-LED off. 1149 */ 1150 1151 #define AD1981_HP_EVENT 0x37 1152 #define AD1981_MIC_EVENT 0x38 1153 1154 static struct hda_verb ad1981_hp_init_verbs[] = { 1155 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */ 1156 /* pin sensing on HP and Mic jacks */ 1157 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, 1158 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, 1159 {0} 1160 }; 1161 1162 /* turn on/off EAPD (+ mute HP) as a master switch */ 1163 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1164 struct snd_ctl_elem_value *ucontrol) 1165 { 1166 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1167 struct ad198x_spec *spec = codec->spec; 1168 1169 if (! ad198x_eapd_put(kcontrol, ucontrol)) 1170 return 0; 1171 1172 /* toggle HP mute appropriately */ 1173 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, 1174 0x80, spec->cur_eapd ? 0 : 0x80); 1175 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, 1176 0x80, spec->cur_eapd ? 0 : 0x80); 1177 return 1; 1178 } 1179 1180 /* bind volumes of both NID 0x05 and 0x06 */ 1181 static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol, 1182 struct snd_ctl_elem_value *ucontrol) 1183 { 1184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1185 long *valp = ucontrol->value.integer.value; 1186 int change; 1187 1188 change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, 1189 0x7f, valp[0] & 0x7f); 1190 change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, 1191 0x7f, valp[1] & 0x7f); 1192 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, 1193 0x7f, valp[0] & 0x7f); 1194 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, 1195 0x7f, valp[1] & 0x7f); 1196 return change; 1197 } 1198 1199 /* mute internal speaker if HP is plugged */ 1200 static void ad1981_hp_automute(struct hda_codec *codec) 1201 { 1202 unsigned int present; 1203 1204 present = snd_hda_codec_read(codec, 0x06, 0, 1205 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1206 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, 1207 0x80, present ? 0x80 : 0); 1208 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, 1209 0x80, present ? 0x80 : 0); 1210 } 1211 1212 /* toggle input of built-in and mic jack appropriately */ 1213 static void ad1981_hp_automic(struct hda_codec *codec) 1214 { 1215 static struct hda_verb mic_jack_on[] = { 1216 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1217 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1218 {0} 1219 }; 1220 static struct hda_verb mic_jack_off[] = { 1221 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1222 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1223 {0} 1224 }; 1225 unsigned int present; 1226 1227 present = snd_hda_codec_read(codec, 0x08, 0, 1228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1229 if (present) 1230 snd_hda_sequence_write(codec, mic_jack_on); 1231 else 1232 snd_hda_sequence_write(codec, mic_jack_off); 1233 } 1234 1235 /* unsolicited event for HP jack sensing */ 1236 static void ad1981_hp_unsol_event(struct hda_codec *codec, 1237 unsigned int res) 1238 { 1239 res >>= 26; 1240 switch (res) { 1241 case AD1981_HP_EVENT: 1242 ad1981_hp_automute(codec); 1243 break; 1244 case AD1981_MIC_EVENT: 1245 ad1981_hp_automic(codec); 1246 break; 1247 } 1248 } 1249 1250 static struct hda_input_mux ad1981_hp_capture_source = { 1251 .num_items = 3, 1252 .items = { 1253 { "Mic", 0x0 }, 1254 { "Docking-Station", 0x1 }, 1255 { "Mix", 0x2 }, 1256 }, 1257 }; 1258 1259 static struct snd_kcontrol_new ad1981_hp_mixers[] = { 1260 { 1261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1262 .name = "Master Playback Volume", 1263 .info = snd_hda_mixer_amp_volume_info, 1264 .get = snd_hda_mixer_amp_volume_get, 1265 .put = ad1981_hp_master_vol_put, 1266 .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), 1267 }, 1268 { 1269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1270 .name = "Master Playback Switch", 1271 .info = ad198x_eapd_info, 1272 .get = ad198x_eapd_get, 1273 .put = ad1981_hp_master_sw_put, 1274 .private_value = 0x05, 1275 }, 1276 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), 1277 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), 1278 #if 0 1279 /* FIXME: analog mic/line loopback doesn't work with my tests... 1280 * (although recording is OK) 1281 */ 1282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), 1283 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), 1284 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1285 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), 1286 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), 1287 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), 1288 /* FIXME: does this laptop have analog CD connection? */ 1289 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1290 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1291 #endif 1292 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), 1293 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT), 1294 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), 1295 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), 1296 { 1297 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1298 .name = "Capture Source", 1299 .info = ad198x_mux_enum_info, 1300 .get = ad198x_mux_enum_get, 1301 .put = ad198x_mux_enum_put, 1302 }, 1303 {0} /* end */ 1304 }; 1305 1306 /* initialize jack-sensing, too */ 1307 static int ad1981_hp_init(struct hda_codec *codec) 1308 { 1309 ad198x_init(codec); 1310 ad1981_hp_automute(codec); 1311 ad1981_hp_automic(codec); 1312 return 0; 1313 } 1314 1315 /* models */ 1316 enum { AD1981_BASIC, AD1981_HP }; 1317 1318 static struct hda_board_config ad1981_cfg_tbl[] = { 1319 { .modelname = "hp", .config = AD1981_HP }, 1320 { .pci_subvendor = 0x103c, .pci_subdevice = 0x30aa, 1321 .config = AD1981_HP }, /* HP nx6320 */ 1322 { .pci_subvendor = 0x103c, .pci_subdevice = 0x309f, 1323 .config = AD1981_HP }, /* HP nx9420 AngelFire */ 1324 { .modelname = "basic", .config = AD1981_BASIC }, 1325 {0} 1326 }; 1327 849 1328 static int patch_ad1981(struct hda_codec *codec) 850 1329 { 851 struct ad198x_spec *spec; 1330 struct ad198x_spec *spec; 1331 int board_config; 852 1332 853 1333 spec = kzalloc(sizeof(*spec), GFP_KERNEL); … … 864 1344 spec->num_adc_nids = 1; 865 1345 spec->adc_nids = ad1981_adc_nids; 866 spec->capsrc_nids = ad1981_adc_nids;1346 spec->capsrc_nids = ad1981_capsrc_nids; 867 1347 spec->input_mux = &ad1981_capture_source; 868 1348 spec->num_mixers = 1; … … 873 1353 874 1354 codec->patch_ops = ad198x_patch_ops; 1355 1356 /* override some parameters */ 1357 board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl); 1358 switch (board_config) { 1359 case AD1981_HP: 1360 spec->mixers[0] = ad1981_hp_mixers; 1361 spec->num_init_verbs = 2; 1362 spec->init_verbs[1] = ad1981_hp_init_verbs; 1363 spec->multiout.dig_out_nid = 0; 1364 spec->input_mux = &ad1981_hp_capture_source; 1365 1366 codec->patch_ops.init = ad1981_hp_init; 1367 codec->patch_ops.unsol_event = ad1981_hp_unsol_event; 1368 break; 1369 } 875 1370 876 1371 return 0; … … 1061 1556 } 1062 1557 1063 /*1064 * EAPD control1065 */1066 static int ad1988_eapd_info(struct snd_kcontrol *kcontrol,1067 struct snd_ctl_elem_info *uinfo)1068 {1069 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;1070 uinfo->count = 1;1071 uinfo->value.integer.min = 0;1072 uinfo->value.integer.max = 1;1073 return 0;1074 }1075 1076 static int ad1988_eapd_get(struct snd_kcontrol *kcontrol,1077 struct snd_ctl_elem_value *ucontrol)1078 {1079 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1080 struct ad198x_spec *spec = codec->spec;1081 ucontrol->value.enumerated.item[0] = ! spec->cur_eapd;1082 return 0;1083 }1084 1085 static int ad1988_eapd_put(struct snd_kcontrol *kcontrol,1086 struct snd_ctl_elem_value *ucontrol)1087 {1088 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1089 struct ad198x_spec *spec = codec->spec;1090 unsigned int eapd;1091 eapd = ! ucontrol->value.enumerated.item[0];1092 if (eapd == spec->cur_eapd && ! codec->in_resume)1093 return 0;1094 spec->cur_eapd = eapd;1095 snd_hda_codec_write(codec, 0x12 /* port-D */,1096 0, AC_VERB_SET_EAPD_BTLENABLE,1097 eapd ? 0x02 : 0x00);1098 return 0;1099 }1100 1101 1558 /* 6-stack mode */ 1102 1559 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { … … 1220 1677 { 1221 1678 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1222 .name = "External Amplifier", 1223 .info = ad1988_eapd_info, 1224 .get = ad1988_eapd_get, 1225 .put = ad1988_eapd_put, 1679 .name = "External Amplifier", 1680 .info = ad198x_eapd_info, 1681 .get = ad198x_eapd_get, 1682 .put = ad198x_eapd_put, 1683 .private_value = 0x12 | (1 << 8), /* port-D, inversed */ 1226 1684 }, 1227 1685 … … 1595 2053 else 1596 2054 snd_hda_sequence_write(codec, ad1988_laptop_hp_off); 1597 } 2055 } 1598 2056 1599 2057 … … 1796 2254 idx = ad1988_pin_idx(pin); 1797 2255 nid = ad1988_idx_to_dac(codec, idx); 1798 if (! spec->multiout.dac_nids[0]) { 1799 /* use this as the primary output */ 1800 spec->multiout.dac_nids[0] = nid; 1801 if (! spec->multiout.num_dacs) 1802 spec->multiout.num_dacs = 1; 1803 } else 1804 /* specify the DAC as the extra output */ 1805 spec->multiout.hp_nid = nid; 2256 /* specify the DAC as the extra output */ 2257 if (! spec->multiout.hp_nid) 2258 spec->multiout.hp_nid = nid; 2259 else 2260 spec->multiout.extra_out_nid[0] = nid; 1806 2261 /* control HP volume/switch on the output mixer amp */ 1807 2262 sprintf(name, "%s Playback Volume", pfx); … … 1922 2377 hda_nid_t pin; 1923 2378 1924 pin = spec->autocfg.speaker_pin;2379 pin = spec->autocfg.speaker_pins[0]; 1925 2380 if (pin) /* connect to front */ 1926 2381 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); … … 1970 2425 return err; 1971 2426 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) 1972 return err; 1973 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 1974 ! spec->autocfg.hp_pin) 2427 return err; 2428 if (! spec->autocfg.line_outs) 1975 2429 return 0; /* can't find valid BIOS pin config */ 1976 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 1977 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, 1978 "Speaker")) < 0 || 1979 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, 2430 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 2431 (err = ad1988_auto_create_extra_out(codec, 2432 spec->autocfg.speaker_pins[0], 2433 "Speaker")) < 0 || 2434 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pin, 1980 2435 "Headphone")) < 0 || 1981 2436 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) -
GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c
r74 r76 7 7 * PeiSen Hou <pshou@realtek.com.tw> 8 8 * Takashi Iwai <tiwai@suse.de> 9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 9 10 * 10 11 * This driver is free software; you can redistribute it and/or modify … … 50 51 ALC880_UNIWILL_DIG, 51 52 ALC880_CLEVO, 52 ALC880_TCL_S700, 53 ALC880_TCL_S700, 54 ALC880_LG, 55 ALC880_LG_LW, 53 56 #ifdef CONFIG_SND_DEBUG 54 57 ALC880_TEST, … … 64 67 ALC260_HP_3013, 65 68 ALC260_FUJITSU_S702X, 69 ALC260_ACER, 70 #ifdef CONFIG_SND_DEBUG 71 ALC260_TEST, 72 #endif 66 73 ALC260_AUTO, 67 74 ALC260_MODEL_LAST /* last tag */ … … 71 78 enum { 72 79 ALC262_BASIC, 80 ALC262_FUJITSU, 73 81 ALC262_AUTO, 74 82 ALC262_MODEL_LAST /* last tag */ … … 109 117 struct hda_pcm_stream *stream_analog_capture; 110 118 111 char *stream_name_digital; /* digital PCM stream */ 119 char *stream_name_digital; /* digital PCM stream */ 112 120 struct hda_pcm_stream *stream_digital_playback; 113 121 struct hda_pcm_stream *stream_digital_capture; … … 133 141 134 142 /* PCM information */ 135 struct hda_pcm pcm_rec[ 2]; /* used in alc_build_pcms() */143 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ 136 144 137 145 /* dynamic controls, init_verbs and input_mux */ … … 141 149 struct hda_input_mux private_imux; 142 150 hda_nid_t private_dac_nids[5]; 151 152 /* hooks */ 153 void (*init_hook)(struct hda_codec *codec); 154 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 155 156 /* for pin sensing */ 157 unsigned int sense_updated: 1; 158 unsigned int jack_present: 1; 143 159 }; 144 160 … … 158 174 unsigned int num_channel_mode; 159 175 const struct hda_channel_mode *channel_mode; 160 const struct hda_input_mux *input_mux; 176 const struct hda_input_mux *input_mux; 177 void (*unsol_event)(struct hda_codec *, unsigned int); 178 void (*init_hook)(struct hda_codec *); 161 179 }; 162 180 … … 219 237 } 220 238 221 222 /* 223 * Control of pin widget settings via the mixer. Only boolean settings are 224 * supported, so VrefEn can't be controlled using these functions as they 225 * stand. 226 */ 227 static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 239 /* 240 * Control the mode of pin widget settings via the mixer. "pc" is used 241 * instead of "%" to avoid consequences of accidently treating the % as 242 * being part of a format specifier. Maximum allowed length of a value is 243 * 63 characters plus NULL terminator. 244 * 245 * Note: some retasking pin complexes seem to ignore requests for input 246 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these 247 * are requested. Therefore order this list so that this behaviour will not 248 * cause problems when mixer clients move through the enum sequentially. 249 * NIDs 0x0f and 0x10 have been observed to have this behaviour. 250 */ 251 static char *alc_pin_mode_names[] = { 252 "Mic 50pc bias", "Mic 80pc bias", 253 "Line in", "Line out", "Headphone out", 254 }; 255 static unsigned char alc_pin_mode_values[] = { 256 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, 257 }; 258 /* The control can present all 5 options, or it can limit the options based 259 * in the pin being assumed to be exclusively an input or an output pin. 260 */ 261 #define ALC_PIN_DIR_IN 0x00 262 #define ALC_PIN_DIR_OUT 0x01 263 #define ALC_PIN_DIR_INOUT 0x02 264 265 /* Info about the pin modes supported by the three different pin directions. 266 * For each direction the minimum and maximum values are given. 267 */ 268 static signed char alc_pin_mode_dir_info[3][2] = { 269 { 0, 2 }, /* ALC_PIN_DIR_IN */ 270 { 3, 4 }, /* ALC_PIN_DIR_OUT */ 271 { 0, 4 }, /* ALC_PIN_DIR_INOUT */ 272 }; 273 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) 274 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) 275 #define alc_pin_mode_n_items(_dir) \ 276 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) 277 278 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 279 { 280 unsigned int item_num = uinfo->value.enumerated.item; 281 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 282 283 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 284 uinfo->count = 1; 285 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); 286 287 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) 288 item_num = alc_pin_mode_min(dir); 289 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); 290 return 0; 291 } 292 293 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 294 { 295 unsigned int i; 296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 297 hda_nid_t nid = kcontrol->private_value & 0xffff; 298 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 299 long *valp = ucontrol->value.integer.value; 300 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); 301 302 /* Find enumerated value for current pinctl setting */ 303 i = alc_pin_mode_min(dir); 304 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir)) 305 i++; 306 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir); 307 return 0; 308 } 309 310 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 311 { 312 signed int change; 313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 314 hda_nid_t nid = kcontrol->private_value & 0xffff; 315 unsigned char dir = (kcontrol->private_value >> 16) & 0xff; 316 long val = *ucontrol->value.integer.value; 317 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); 318 319 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir)) 320 val = alc_pin_mode_min(dir); 321 322 change = pinctl != alc_pin_mode_values[val]; 323 if (change) { 324 /* Set pin mode to that requested */ 325 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, 326 alc_pin_mode_values[val]); 327 328 /* Also enable the retasking pin's input/output as required 329 * for the requested pin mode. Enum values of 2 or less are 330 * input modes. 331 * 332 * Dynamically switching the input/output buffers probably 333 * reduces noise slightly, particularly on input. However, 334 * havingboth input and output buffers enabled 335 * simultaneously doesn't seem to be problematic. 336 */ 337 if (val <= 2) { 338 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 339 AMP_OUT_MUTE); 340 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 341 AMP_IN_UNMUTE(0)); 342 } else { 343 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 344 AMP_IN_MUTE(0)); 345 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, 346 AMP_OUT_UNMUTE); 347 } 348 } 349 return change; 350 } 351 352 #define ALC_PIN_MODE(xname, nid, dir) \ 353 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 354 .info = alc_pin_mode_info, \ 355 .get = alc_pin_mode_get, \ 356 .put = alc_pin_mode_put, \ 357 .private_value = nid | (dir<<16) } 358 359 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged 360 * together using a mask with more than one bit set. This control is 361 * currently used only by the ALC260 test model. At this stage they are not 362 * needed for any "production" models. 363 */ 364 #ifdef CONFIG_SND_DEBUG 365 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 228 366 { 229 367 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; … … 233 371 return 0; 234 372 } 235 236 static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 373 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 237 374 { 238 375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 239 376 hda_nid_t nid = kcontrol->private_value & 0xffff; 240 longmask = (kcontrol->private_value >> 16) & 0xff;377 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 241 378 long *valp = ucontrol->value.integer.value; 242 243 *valp = 0; 244 if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask) 245 *valp = 1; 379 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); 380 381 *valp = (val & mask) != 0; 246 382 return 0; 247 383 } 248 249 static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 250 { 384 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 385 { 386 signed int change; 251 387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 252 388 hda_nid_t nid = kcontrol->private_value & 0xffff; 253 long mask = (kcontrol->private_value >> 16) & 0xff; 389 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 390 long val = *ucontrol->value.integer.value; 391 unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); 392 393 /* Set/unset the masked GPIO bit(s) as needed */ 394 change = (val==0?0:mask) != (gpio_data & mask); 395 if (val==0) 396 gpio_data &= ~mask; 397 else 398 gpio_data |= mask; 399 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data); 400 401 return change; 402 } 403 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ 404 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 405 .info = alc_gpio_data_info, \ 406 .get = alc_gpio_data_get, \ 407 .put = alc_gpio_data_put, \ 408 .private_value = nid | (mask<<16) } 409 #endif /* CONFIG_SND_DEBUG */ 410 411 /* A switch control to allow the enabling of the digital IO pins on the 412 * ALC260. This is incredibly simplistic; the intention of this control is 413 * to provide something in the test model allowing digital outputs to be 414 * identified if present. If models are found which can utilise these 415 * outputs a more complete mixer control can be devised for those models if 416 * necessary. 417 */ 418 #ifdef CONFIG_SND_DEBUG 419 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 420 { 421 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 422 uinfo->count = 1; 423 uinfo->value.integer.min = 0; 424 uinfo->value.integer.max = 1; 425 return 0; 426 } 427 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 428 { 429 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 430 hda_nid_t nid = kcontrol->private_value & 0xffff; 431 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 254 432 long *valp = ucontrol->value.integer.value; 255 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); 256 int change = ((pinctl & mask)!=0) != *valp; 257 258 if (change) 259 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, 260 *valp?(pinctl|mask):(pinctl&~mask)); 433 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); 434 435 *valp = (val & mask) != 0; 436 return 0; 437 } 438 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 439 { 440 signed int change; 441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 442 hda_nid_t nid = kcontrol->private_value & 0xffff; 443 unsigned char mask = (kcontrol->private_value >> 16) & 0xff; 444 long val = *ucontrol->value.integer.value; 445 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); 446 447 /* Set/unset the masked control bit(s) as needed */ 448 change = (val==0?0:mask) != (ctrl_data & mask); 449 if (val==0) 450 ctrl_data &= ~mask; 451 else 452 ctrl_data |= mask; 453 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data); 454 261 455 return change; 262 456 } 263 264 #define ALC_PINCTL_SWITCH(xname, nid, mask) \ 457 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ 265 458 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 266 .info = alc_ pinctl_switch_info, \267 .get = alc_ pinctl_switch_get, \268 .put = alc_ pinctl_switch_put, \269 .private_value = (nid)| (mask<<16) }270 459 .info = alc_spdif_ctrl_info, \ 460 .get = alc_spdif_ctrl_get, \ 461 .put = alc_spdif_ctrl_put, \ 462 .private_value = nid | (mask<<16) } 463 #endif /* CONFIG_SND_DEBUG */ 271 464 272 465 /* … … 281 474 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) 282 475 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; 283 476 284 477 spec->channel_mode = preset->channel_mode; 285 478 spec->num_channel_mode = preset->num_channel_mode; … … 291 484 spec->multiout.dig_out_nid = preset->dig_out_nid; 292 485 spec->multiout.hp_nid = preset->hp_nid; 293 486 294 487 spec->input_mux = preset->input_mux; 295 488 296 489 spec->num_adc_nids = preset->num_adc_nids; 297 490 spec->adc_nids = preset->adc_nids; 298 spec->dig_in_nid = preset->dig_in_nid; 491 spec->dig_in_nid = preset->dig_in_nid; 492 spec->unsol_event = preset->unsol_event; 493 spec->init_hook = preset->init_hook; 299 494 } 300 495 … … 494 689 /* front, rear, clfe, rear_surr */ 495 690 0x02, 0x03, 0x04, 0x05 496 }; 691 }; 497 692 498 693 static struct hda_input_mux alc880_6stack_capture_source = { … … 554 749 * The system also has a pair of internal speakers, and a headphone jack. 555 750 * These are both connected to Line2 on the codec, hence to DAC 02. 556 * 751 * 557 752 * There is a variable resistor to control the speaker or headphone 558 753 * volume. This is a hardware-only device without a software API. … … 964 1159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 965 1160 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 966 1161 967 1162 {0} 968 1163 }; … … 1026 1221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1027 1222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1028 1223 1029 1224 {0} 1030 1225 }; … … 1099 1294 1100 1295 /* 1296 * LG m1 express dual 1297 * 1298 * Pin assignment: 1299 * Rear Line-In/Out (blue): 0x14 1300 * Build-in Mic-In: 0x15 1301 * Speaker-out: 0x17 1302 * HP-Out (green): 0x1b 1303 * Mic-In/Out (red): 0x19 1304 * SPDIF-Out: 0x1e 1305 */ 1306 1307 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ 1308 static hda_nid_t alc880_lg_dac_nids[3] = { 1309 0x05, 0x02, 0x03 1310 }; 1311 1312 /* seems analog CD is not working */ 1313 static struct hda_input_mux alc880_lg_capture_source = { 1314 .num_items = 3, 1315 .items = { 1316 { "Mic", 0x1 }, 1317 { "Line", 0x5 }, 1318 { "Internal Mic", 0x6 }, 1319 }, 1320 }; 1321 1322 /* 2,4,6 channel modes */ 1323 static struct hda_verb alc880_lg_ch2_init[] = { 1324 /* set line-in and mic-in to input */ 1325 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1326 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 1327 {0} 1328 }; 1329 1330 static struct hda_verb alc880_lg_ch4_init[] = { 1331 /* set line-in to out and mic-in to input */ 1332 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 1333 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 1334 {0} 1335 }; 1336 1337 static struct hda_verb alc880_lg_ch6_init[] = { 1338 /* set line-in and mic-in to output */ 1339 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 1340 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 1341 {0} 1342 }; 1343 1344 static struct hda_channel_mode alc880_lg_ch_modes[3] = { 1345 { 2, alc880_lg_ch2_init }, 1346 { 4, alc880_lg_ch4_init }, 1347 { 6, alc880_lg_ch6_init }, 1348 }; 1349 1350 static struct snd_kcontrol_new alc880_lg_mixer[] = { 1351 /* FIXME: it's not really "master" but front channels */ 1352 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1353 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), 1354 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1355 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), 1356 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), 1357 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), 1358 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), 1359 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), 1360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1362 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), 1363 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), 1364 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), 1365 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), 1366 { 1367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1368 .name = "Channel Mode", 1369 .info = alc_ch_mode_info, 1370 .get = alc_ch_mode_get, 1371 .put = alc_ch_mode_put, 1372 }, 1373 {0} /* end */ 1374 }; 1375 1376 static struct hda_verb alc880_lg_init_verbs[] = { 1377 /* set capture source to mic-in */ 1378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1381 /* mute all amp mixer inputs */ 1382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, 1383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, 1384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, 1385 /* line-in to input */ 1386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1388 /* built-in mic */ 1389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1391 /* speaker-out */ 1392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1394 /* mic-in to input */ 1395 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 1396 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1398 /* HP-out */ 1399 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, 1400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1401 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1402 /* jack sense */ 1403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 1404 {0} 1405 }; 1406 1407 /* toggle speaker-output according to the hp-jack state */ 1408 static void alc880_lg_automute(struct hda_codec *codec) 1409 { 1410 unsigned int present; 1411 1412 present = snd_hda_codec_read(codec, 0x1b, 0, 1413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1414 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, 1415 0x80, present ? 0x80 : 0); 1416 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, 1417 0x80, present ? 0x80 : 0); 1418 } 1419 1420 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 1421 { 1422 /* Looks like the unsol event is incompatible with the standard 1423 * definition. 4bit tag is placed at 28 bit! 1424 */ 1425 if ((res >> 28) == 0x01) 1426 alc880_lg_automute(codec); 1427 } 1428 1429 /* 1430 * LG LW20 1431 * 1432 * Pin assignment: 1433 * Speaker-out: 0x14 1434 * Mic-In: 0x18 1435 * Built-in Mic-In: 0x19 (?) 1436 * HP-Out: 0x1b 1437 * SPDIF-Out: 0x1e 1438 */ 1439 1440 /* seems analog CD is not working */ 1441 static struct hda_input_mux alc880_lg_lw_capture_source = { 1442 .num_items = 2, 1443 .items = { 1444 { "Mic", 0x0 }, 1445 { "Internal Mic", 0x1 }, 1446 }, 1447 }; 1448 1449 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { 1450 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1451 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), 1452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1454 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 1455 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 1456 {0} /* end */ 1457 }; 1458 1459 static struct hda_verb alc880_lg_lw_init_verbs[] = { 1460 /* set capture source to mic-in */ 1461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, 1465 /* speaker-out */ 1466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1468 /* HP-out */ 1469 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 1470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1471 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1472 /* mic-in to input */ 1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1475 /* built-in mic */ 1476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1477 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1478 /* jack sense */ 1479 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, 1480 {0} 1481 }; 1482 1483 /* toggle speaker-output according to the hp-jack state */ 1484 static void alc880_lg_lw_automute(struct hda_codec *codec) 1485 { 1486 unsigned int present; 1487 1488 present = snd_hda_codec_read(codec, 0x1b, 0, 1489 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1490 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 1491 0x80, present ? 0x80 : 0); 1492 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 1493 0x80, present ? 0x80 : 0); 1494 } 1495 1496 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 1497 { 1498 /* Looks like the unsol event is incompatible with the standard 1499 * definition. 4bit tag is placed at 28 bit! 1500 */ 1501 if ((res >> 28) == 0x01) 1502 alc880_lg_lw_automute(codec); 1503 } 1504 1505 /* 1506 * Common callbacks 1101 1507 */ 1102 1508 … … 1107 1513 1108 1514 for (i = 0; i < spec->num_init_verbs; i++) 1109 snd_hda_sequence_write(codec, spec->init_verbs[i]); 1515 snd_hda_sequence_write(codec, spec->init_verbs[i]); 1516 if (spec->init_hook) 1517 spec->init_hook(codec); 1110 1518 return 0; 1519 } 1520 1521 static void alc_unsol_event(struct hda_codec *codec, unsigned int res) 1522 { 1523 struct alc_spec *spec = codec->spec; 1524 1525 if (spec->unsol_event) 1526 spec->unsol_event(codec, res); 1111 1527 } 1112 1528 … … 1249 1665 .channels_max = 2, 1250 1666 /* NID is set in alc_build_pcms */ 1667 }; 1668 1669 /* Used by alc_build_pcms to flag that a PCM has no playback stream */ 1670 static struct hda_pcm_stream alc_pcm_null_playback = { 1671 .substreams = 0, 1672 .channels_min = 0, 1673 .channels_max = 0, 1251 1674 }; 1252 1675 … … 1278 1701 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 1279 1702 } 1703 } 1704 } 1705 1706 /* If the use of more than one ADC is requested for the current 1707 * model, configure a second analog capture-only PCM. 1708 */ 1709 if (spec->num_adc_nids > 1) { 1710 codec->num_pcms++; 1711 info++; 1712 info->name = spec->stream_name_analog; 1713 /* No playback stream for second PCM */ 1714 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; 1715 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; 1716 if (spec->stream_analog_capture) { 1717 snd_assert(spec->adc_nids, return -EINVAL); 1718 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 1719 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; 1280 1720 } 1281 1721 } … … 1322 1762 .build_pcms = alc_build_pcms, 1323 1763 .init = alc_init, 1324 .free = alc_free, 1764 .free = alc_free, 1765 .unsol_event = alc_unsol_event, 1325 1766 #ifdef CONFIG_PM 1326 1767 .resume = alc_resume, … … 1341 1782 1342 1783 static struct hda_input_mux alc880_test_capture_source = { 1343 .num_items = 5,1784 .num_items = 7, 1344 1785 .items = { 1345 1786 { "In-1", 0x0 }, … … 1347 1788 { "In-3", 0x2 }, 1348 1789 { "In-4", 0x3 }, 1349 { "CD", 0x4 }, 1790 { "CD", 0x4 }, 1791 { "Front", 0x5 }, 1792 { "Surround", 0x6 }, 1350 1793 }, 1351 1794 }; … … 1620 2063 /* Back 3 jack, front 2 jack (Internal add Aux-In) */ 1621 2064 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, 1622 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, 2065 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, 1623 2066 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, 1624 2067 … … 1653 2096 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, 1654 2097 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, 1655 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, 2098 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, 2099 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560, .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */ 1656 2100 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */ 1657 2101 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, … … 1669 2113 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, 1670 2114 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ 2115 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */ 1671 2116 1672 2117 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, … … 1679 2124 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, 1680 2125 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, 1681 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ 2126 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ 2127 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */ 1682 2128 1683 2129 { .modelname = "asus", .config = ALC880_ASUS }, … … 1692 2138 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, 1693 2139 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, 1694 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, 2140 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, 2141 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */ 1695 2142 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, 1696 2143 1697 2144 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, 1698 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, 2145 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, 1699 2146 1700 2147 { .modelname = "F1734", .config = ALC880_F1734 }, 1701 2148 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, 1702 2149 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, 2150 2151 { .modelname = "lg", .config = ALC880_LG }, 2152 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG }, 2153 { .modelname = "lg-lw", .config = ALC880_LG_LW }, 2154 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW }, 1703 2155 1704 2156 #ifdef CONFIG_SND_DEBUG … … 1878 2330 .channel_mode = alc880_threestack_modes, 1879 2331 .input_mux = &alc880_capture_source, 1880 }, 2332 }, 2333 [ALC880_LG] = { 2334 .mixers = { alc880_lg_mixer }, 2335 .init_verbs = { alc880_volume_init_verbs, 2336 alc880_lg_init_verbs }, 2337 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), 2338 .dac_nids = alc880_lg_dac_nids, 2339 .dig_out_nid = ALC880_DIGOUT_NID, 2340 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), 2341 .channel_mode = alc880_lg_ch_modes, 2342 .input_mux = &alc880_lg_capture_source, 2343 .unsol_event = alc880_lg_unsol_event, 2344 .init_hook = alc880_lg_automute, 2345 }, 2346 [ALC880_LG_LW] = { 2347 .mixers = { alc880_lg_lw_mixer }, 2348 .init_verbs = { alc880_volume_init_verbs, 2349 alc880_lg_lw_init_verbs }, 2350 .num_dacs = 1, 2351 .dac_nids = alc880_dac_nids, 2352 .dig_out_nid = ALC880_DIGOUT_NID, 2353 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 2354 .channel_mode = alc880_2_jack_modes, 2355 .input_mux = &alc880_lg_lw_capture_source, 2356 .unsol_event = alc880_lg_lw_unsol_event, 2357 .init_hook = alc880_lg_lw_automute, 2358 }, 1881 2359 #ifdef CONFIG_SND_DEBUG 1882 2360 [ALC880_TEST] = { … … 2043 2521 if (alc880_is_fixed_pin(pin)) { 2044 2522 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 2045 if (! spec->multiout.dac_nids[0]) { 2046 /* use this as the primary output */ 2047 spec->multiout.dac_nids[0] = nid; 2048 if (! spec->multiout.num_dacs) 2049 spec->multiout.num_dacs = 1; 2050 } else 2051 /* specify the DAC as the extra output */ 2052 spec->multiout.hp_nid = nid; 2523 /* specify the DAC as the extra output */ 2524 if (! spec->multiout.hp_nid) 2525 spec->multiout.hp_nid = nid; 2526 else 2527 spec->multiout.extra_out_nid[0] = nid; 2053 2528 /* control HP volume/switch on the output mixer amp */ 2054 2529 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); … … 2063 2538 } else if (alc880_is_multi_pin(pin)) { 2064 2539 /* set manual connection */ 2065 if (! spec->multiout.dac_nids[0]) {2066 /* use this as the primary output */2067 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));2068 if (! spec->multiout.num_dacs)2069 spec->multiout.num_dacs = 1;2070 }2071 2540 /* we have only a switch on HP-out PIN */ 2072 2541 sprintf(name, "%s Playback Switch", pfx); … … 2152 2621 hda_nid_t pin; 2153 2622 2154 pin = spec->autocfg.speaker_pin;2623 pin = spec->autocfg.speaker_pins[0]; 2155 2624 if (pin) /* connect to front */ 2156 2625 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); … … 2187 2656 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 2188 2657 alc880_ignore)) < 0) 2189 return err; 2190 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 2191 ! spec->autocfg.hp_pin) 2192 return 0; /* can't find valid BIOS pin config */ 2658 return err; 2659 if (! spec->autocfg.line_outs) 2660 return 0; /* can't find valid BIOS pin config */ 2193 2661 2194 2662 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 2195 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 2196 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, 2197 "Speaker")) < 0 || 2198 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, 2663 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 2664 (err = alc880_auto_create_extra_out(spec, 2665 spec->autocfg.speaker_pins[0], 2666 "Speaker")) < 0 || 2667 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin, 2199 2668 "Headphone")) < 0 || 2200 2669 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) … … 2218 2687 } 2219 2688 2220 /* init callback for auto-configuration model -- overriding the default init */ 2221 static int alc880_auto_init(struct hda_codec *codec) 2222 { 2223 alc_init(codec); 2224 alc880_auto_init_multi_out(codec); 2225 alc880_auto_init_extra_out(codec); 2226 alc880_auto_init_analog_input(codec); 2227 return 0; 2689 /* additional initialization for auto-configuration model */ 2690 static void alc880_auto_init(struct hda_codec *codec) 2691 { 2692 alc880_auto_init_multi_out(codec); 2693 alc880_auto_init_extra_out(codec); 2694 alc880_auto_init_analog_input(codec); 2228 2695 } 2229 2696 … … 2291 2758 2292 2759 codec->patch_ops = alc_patch_ops; 2293 2294 codec->patch_ops.init= alc880_auto_init;2760 if (board_config == ALC880_AUTO) 2761 spec->init_hook = alc880_auto_init; 2295 2762 2296 2763 return 0; … … 2320 2787 /* ADC1, 0 */ 2321 2788 0x05, 0x04 2789 }; 2790 2791 /* NIDs used when simultaneous access to both ADCs makes sense. Note that 2792 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. 2793 */ 2794 static hda_nid_t alc260_dual_adc_nids[2] = { 2795 /* ADC0, ADC1 */ 2796 0x04, 0x05 2322 2797 }; 2323 2798 … … 2335 2810 }; 2336 2811 2337 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack 2338 * and the internal CD lines.2812 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, 2813 * headphone jack and the internal CD lines. 2339 2814 */ 2340 2815 static struct hda_input_mux alc260_fujitsu_capture_source = { 2341 .num_items = 2,2816 .num_items = 3, 2342 2817 .items = { 2343 2818 { "Mic/Line", 0x0 }, 2819 { "CD", 0x4 }, 2820 { "Headphone", 0x2 }, 2821 }, 2822 }; 2823 2824 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to 2825 * the Fujitsu S702x, but jacks are marked differently. We won't allow 2826 * retasking the Headphone jack, so it won't be available here. 2827 */ 2828 static struct hda_input_mux alc260_acer_capture_source = { 2829 .num_items = 3, 2830 .items = { 2831 { "Mic", 0x0 }, 2832 { "Line", 0x2 }, 2344 2833 { "CD", 0x4 }, 2345 2834 }, … … 2363 2852 * HP_3013: hp_3013 + input + capture 2364 2853 * fujitsu: fujitsu + capture 2854 * acer: acer + capture 2365 2855 */ 2366 2856 … … 2373 2863 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 2374 2864 {0} /* end */ 2375 }; 2865 }; 2376 2866 2377 2867 static struct snd_kcontrol_new alc260_input_mixer[] = { … … 2408 2898 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 2409 2899 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), 2410 ALC_PIN CTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),2900 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 2411 2901 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 2412 2902 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 2413 2903 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), 2414 2904 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), 2905 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), 2415 2906 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 2416 2907 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 2417 2908 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2418 2909 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), 2910 {0} /* end */ 2911 }; 2912 2913 static struct snd_kcontrol_new alc260_acer_mixer[] = { 2914 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 2915 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), 2916 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 2917 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 2918 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 2919 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 2920 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), 2921 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 2922 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 2923 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 2924 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 2925 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 2419 2926 {0} /* end */ 2420 2927 }; … … 2476 2983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2477 2984 /* select line-out */ 2478 {0x 15, AC_VERB_SET_CONNECT_SEL, 0x00},2985 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 2479 2986 /* LINE-OUT pin */ 2480 2987 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, … … 2629 3136 /* Headphone/Line-out jack connects to Line1 pin; make it an output */ 2630 3137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2631 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ 2632 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2633 /* Ensure all other unused pins are disabled and muted. 2634 * Note: trying to set widget 0x15 to anything blocks all audio 2635 * output for some reason, so just leave that at the default. 3138 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ 3139 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3140 /* Ensure all other unused pins are disabled and muted. */ 3141 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 3142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3143 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 3144 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3145 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 3146 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 3148 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3149 3150 /* Disable digital (SPDIF) pins */ 3151 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3152 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3153 3154 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus 3155 * when acting as an output. 2636 3156 */ 2637 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2638 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3157 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 3158 3159 /* Start with output sum widgets muted and their output gains at min */ 3160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3162 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3165 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3167 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3168 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3169 3170 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ 3171 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3172 /* Unmute Line1 pin widget output buffer since it starts as an output. 3173 * If the pin mode is changed by the user the pin mode control will 3174 * take care of enabling the pin's input/output buffers as needed. 3175 * Therefore there's no need to enable the input buffer at this 3176 * stage. 3177 */ 3178 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3179 /* Unmute input buffer of pin widget used for Line-in (no equiv 3180 * mixer ctrl) 3181 */ 3182 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3183 3184 /* Mute capture amp left and right */ 3185 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3186 /* Set ADC connection select to match default mixer setting - line 3187 * in (on mic1 pin) 3188 */ 3189 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 3190 3191 /* Do the same for the second ADC: mute capture input amp and 3192 * set ADC connection to line in (on mic1 pin) 3193 */ 3194 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3195 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 3196 3197 /* Mute all inputs to mixer widget (even unconnected ones) */ 3198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 3199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 3200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 3201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 3202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 3203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 3204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 3205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 3206 3207 {0} 3208 }; 3209 3210 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and 3211 * similar laptops (adapted from Fujitsu init verbs). 3212 */ 3213 static struct hda_verb alc260_acer_init_verbs[] = { 3214 /* On TravelMate laptops, GPIO 0 enables the internal speaker and 3215 * the headphone jack. Turn this on and rely on the standard mute 3216 * methods whenever the user wants to turn these outputs off. 3217 */ 3218 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 3219 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 3220 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 3221 /* Internal speaker/Headphone jack is connected to Line-out pin */ 3222 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 3223 /* Internal microphone/Mic jack is connected to Mic1 pin */ 3224 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, 3225 /* Line In jack is connected to Line1 pin */ 3226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3227 /* Ensure all other unused pins are disabled and muted. */ 3228 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 3229 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2639 3230 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2640 3231 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2641 3232 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2642 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2643 /* Disable digital (SPDIF) pins */ 2644 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 2645 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 2646 2647 /* Start with mixer outputs muted */ 2648 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2650 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2651 2652 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ 2653 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2654 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */ 2655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2656 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */ 2657 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2658 2659 /* Mute capture amp left and right */ 2660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2661 /* Set ADC connection select to line in (on mic1 pin) */ 2662 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 2663 2664 /* Mute all inputs to mixer widget (even unconnected ones) */ 2665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 2666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 2667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 2668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 2669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 2670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 2671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 2672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 3233 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 3235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3236 /* Disable digital (SPDIF) pins */ 3237 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3238 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3239 3240 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum 3241 * bus when acting as outputs. 3242 */ 3243 {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, 3244 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 3245 3246 /* Start with output sum widgets muted and their output gains at min */ 3247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3248 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3253 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3254 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3255 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3256 3257 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ 3258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3259 /* Unmute Mic1 and Line1 pin widget input buffers since they start as 3260 * inputs. If the pin mode is changed by the user the pin mode control 3261 * will take care of enabling the pin's input/output buffers as needed. 3262 * Therefore there's no need to enable the input buffer at this 3263 * stage. 3264 */ 3265 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3266 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3267 3268 /* Mute capture amp left and right */ 3269 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3270 /* Set ADC connection select to match default mixer setting - mic 3271 * (on mic1 pin) 3272 */ 3273 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 3274 3275 /* Do similar with the second ADC: mute capture input amp and 3276 * set ADC connection to line (on line1 pin) 3277 */ 3278 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3279 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, 3280 3281 /* Mute all inputs to mixer widget (even unconnected ones) */ 3282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 3283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 3284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 3285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 3286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 3287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 3288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 3289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 2673 3290 2674 3291 {0} 2675 3292 }; 3293 3294 /* Test configuration for debugging, modelled after the ALC880 test 3295 * configuration. 3296 */ 3297 #ifdef CONFIG_SND_DEBUG 3298 static hda_nid_t alc260_test_dac_nids[1] = { 3299 0x02, 3300 }; 3301 static hda_nid_t alc260_test_adc_nids[2] = { 3302 0x04, 0x05, 3303 }; 3304 /* This is a bit messy since the two input muxes in the ALC260 have slight 3305 * variations in their signal assignments. The ideal way to deal with this 3306 * is to extend alc_spec.input_mux to allow a different input MUX for each 3307 * ADC. For the purposes of the test model it's sufficient to just list 3308 * both options for affected signal indices. The separate input mux 3309 * functionality only needs to be considered if a model comes along which 3310 * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to 3311 * record. 3312 */ 3313 static struct hda_input_mux alc260_test_capture_source = { 3314 .num_items = 8, 3315 .items = { 3316 { "MIC1 pin", 0x0 }, 3317 { "MIC2 pin", 0x1 }, 3318 { "LINE1 pin", 0x2 }, 3319 { "LINE2 pin", 0x3 }, 3320 { "CD pin", 0x4 }, 3321 { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 }, 3322 { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 }, 3323 { "HP-OUT pin (cap2 only)", 0x7 }, 3324 }, 3325 }; 3326 static struct snd_kcontrol_new alc260_test_mixer[] = { 3327 /* Output driver widgets */ 3328 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3329 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 3330 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), 3331 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), 3332 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), 3333 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), 3334 3335 /* Modes for retasking pin widgets */ 3336 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), 3337 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), 3338 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), 3339 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), 3340 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), 3341 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), 3342 3343 /* Loopback mixer controls */ 3344 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), 3345 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), 3346 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), 3347 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), 3348 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), 3349 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), 3350 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), 3351 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), 3352 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 3353 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 3354 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 3355 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 3356 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), 3357 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), 3358 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), 3359 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), 3360 3361 /* Controls for GPIO pins, assuming they are configured as outputs */ 3362 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), 3363 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), 3364 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), 3365 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), 3366 3367 /* Switches to allow the digital IO pins to be enabled. The datasheet 3368 * is ambigious as to which NID is which; testing on laptops which 3369 * make this output available should provide clarification. 3370 */ 3371 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), 3372 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), 3373 3374 {0} /* end */ 3375 }; 3376 static struct hda_verb alc260_test_init_verbs[] = { 3377 /* Enable all GPIOs as outputs with an initial value of 0 */ 3378 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, 3379 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 3380 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, 3381 3382 /* Enable retasking pins as output, initially without power amp */ 3383 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3384 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3385 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3387 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3388 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3389 3390 /* Disable digital (SPDIF) pins initially, but users can enable 3391 * them via a mixer switch. In the case of SPDIF-out, this initverb 3392 * payload also sets the generation to 0, output to be in "consumer" 3393 * PCM format, copyright asserted, no pre-emphasis and no validity 3394 * control. 3395 */ 3396 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3397 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 3398 3399 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the 3400 * OUT1 sum bus when acting as an output. 3401 */ 3402 {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, 3403 {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, 3404 {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, 3405 {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, 3406 3407 /* Start with output sum widgets muted and their output gains at min */ 3408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3415 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3416 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3417 3418 /* Unmute retasking pin widget output buffers since the default 3419 * state appears to be output. As the pin mode is changed by the 3420 * user the pin mode control will take care of enabling the pin's 3421 * input/output buffers as needed. 3422 */ 3423 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3424 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3427 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3428 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3429 /* Also unmute the mono-out pin widget */ 3430 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3431 3432 /* Mute capture amp left and right */ 3433 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3434 /* Set ADC connection select to match default mixer setting (mic1 3435 * pin) 3436 */ 3437 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 3438 3439 /* Do the same for the second ADC: mute capture input amp and 3440 * set ADC connection to mic1 pin 3441 */ 3442 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3443 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 3444 3445 /* Mute all inputs to mixer widget (even unconnected ones) */ 3446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 3447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 3448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 3449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 3450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 3451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 3452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 3453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 3454 3455 {0} 3456 }; 3457 #endif 2676 3458 2677 3459 static struct hda_pcm_stream alc260_pcm_analog_playback = { … … 2716 3498 } else 2717 3499 return 0; /* N/A */ 2718 2719 sprintf(name, "%s Playback Volume", pfx);3500 3501 sprintf(name, /*sizeof(name), */"%s Playback Volume", pfx); 2720 3502 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 2721 3503 return err; 2722 sprintf(name, "%s Playback Switch", pfx);3504 sprintf(name, /*sizeof(name), */"%s Playback Switch", pfx); 2723 3505 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 2724 3506 return err; … … 2744 3526 } 2745 3527 2746 nid = cfg->speaker_pin;3528 nid = cfg->speaker_pins[0]; 2747 3529 if (nid) { 2748 3530 err = alc260_add_playback_controls(spec, nid, "Speaker"); … … 2757 3539 return err; 2758 3540 } 2759 return 0; 3541 return 0; 2760 3542 } 2761 3543 … … 2804 3586 snd_hda_codec_write(codec, idx + 0x0b, 0, 2805 3587 AC_VERB_SET_CONNECT_SEL, sel_idx); 2806 3588 2807 3589 } 2808 3590 } … … 2813 3595 hda_nid_t nid; 2814 3596 2815 nid = spec->autocfg.line_out_pins[0]; 3597 nid = spec->autocfg.line_out_pins[0]; 2816 3598 if (nid) 2817 3599 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 2818 2819 nid = spec->autocfg.speaker_pin;3600 3601 nid = spec->autocfg.speaker_pins[0]; 2820 3602 if (nid) 2821 3603 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); … … 2824 3606 if (nid) 2825 3607 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 2826 } 3608 } 2827 3609 2828 3610 #define ALC260_PIN_CD_NID 0x16 … … 2855 3637 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 2856 3638 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2857 3639 2858 3640 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 2859 3641 * mixer widget … … 2883 3665 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2884 3666 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2885 3667 2886 3668 {0} 2887 3669 }; … … 2932 3714 } 2933 3715 2934 /* init callback for auto-configuration model -- overriding the default init */ 2935 static int alc260_auto_init(struct hda_codec *codec) 2936 { 2937 alc_init(codec); 2938 alc260_auto_init_multi_out(codec); 2939 alc260_auto_init_analog_input(codec); 2940 return 0; 3716 /* additional initialization for auto-configuration model */ 3717 static void alc260_auto_init(struct hda_codec *codec) 3718 { 3719 alc260_auto_init_multi_out(codec); 3720 alc260_auto_init_analog_input(codec); 2941 3721 } 2942 3722 … … 2947 3727 { .modelname = "basic", .config = ALC260_BASIC }, 2948 3728 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb, 2949 .config = ALC260_BASIC }, /* Sony VAIO */ 3729 .config = ALC260_BASIC }, /* Sony VAIO */ 3730 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729, 3731 .config = ALC260_BASIC }, /* CTL Travel Master U553W */ 2950 3732 { .modelname = "hp", .config = ALC260_HP }, 2951 3733 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, … … 2958 3740 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, 2959 3741 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, 3742 { .modelname = "acer", .config = ALC260_ACER }, 3743 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER }, 3744 #ifdef CONFIG_SND_DEBUG 3745 { .modelname = "test", .config = ALC260_TEST }, 3746 #endif 2960 3747 { .modelname = "auto", .config = ALC260_AUTO }, 2961 3748 {0} 2962 3749 }; 2963 3750 … … 3009 3796 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 3010 3797 .dac_nids = alc260_dac_nids, 3011 .num_adc_nids = ARRAY_SIZE(alc260_ adc_nids),3012 .adc_nids = alc260_ adc_nids,3798 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 3799 .adc_nids = alc260_dual_adc_nids, 3013 3800 .num_channel_mode = ARRAY_SIZE(alc260_modes), 3014 3801 .channel_mode = alc260_modes, 3015 3802 .input_mux = &alc260_fujitsu_capture_source, 3016 3803 }, 3804 [ALC260_ACER] = { 3805 .mixers = { alc260_acer_mixer, 3806 alc260_capture_mixer }, 3807 .init_verbs = { alc260_acer_init_verbs }, 3808 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 3809 .dac_nids = alc260_dac_nids, 3810 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), 3811 .adc_nids = alc260_dual_adc_nids, 3812 .num_channel_mode = ARRAY_SIZE(alc260_modes), 3813 .channel_mode = alc260_modes, 3814 .input_mux = &alc260_acer_capture_source, 3815 }, 3816 #ifdef CONFIG_SND_DEBUG 3817 [ALC260_TEST] = { 3818 .mixers = { alc260_test_mixer, 3819 alc260_capture_mixer }, 3820 .init_verbs = { alc260_test_init_verbs }, 3821 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), 3822 .dac_nids = alc260_test_dac_nids, 3823 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), 3824 .adc_nids = alc260_test_adc_nids, 3825 .num_channel_mode = ARRAY_SIZE(alc260_modes), 3826 .channel_mode = alc260_modes, 3827 .input_mux = &alc260_test_capture_source, 3828 }, 3829 #endif 3017 3830 }; 3018 3831 … … 3058 3871 3059 3872 codec->patch_ops = alc_patch_ops; 3060 3061 codec->patch_ops.init= alc260_auto_init;3873 if (board_config == ALC260_AUTO) 3874 spec->init_hook = alc260_auto_init; 3062 3875 3063 3876 return 0; … … 3417 4230 */ 3418 4231 static struct hda_board_config alc882_cfg_tbl[] = { 3419 { .modelname = "3stack-dig", .config = ALC8 61_3ST_DIG },3420 { .modelname = "6stack-dig", .config = ALC8 61_6ST_DIG },4232 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG }, 4233 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG }, 3421 4234 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ 3422 4235 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ 3423 4236 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ 3424 { .modelname = "auto", .config = ALC8 61_AUTO },4237 { .modelname = "auto", .config = ALC882_AUTO }, 3425 4238 {0} 3426 4239 }; … … 3465 4278 /* set as output */ 3466 4279 struct alc_spec *spec = codec->spec; 3467 int idx; 3468 4280 int idx; 4281 3469 4282 if (spec->multiout.dac_nids[dac_idx] == 0x25) 3470 4283 idx = 4; … … 3484 4297 3485 4298 for (i = 0; i <= HDA_SIDE; i++) { 3486 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 4299 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3487 4300 if (nid) 3488 4301 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); … … 3534 4347 } 3535 4348 3536 /* init callback for auto-configuration model -- overriding the default init */ 3537 static int alc882_auto_init(struct hda_codec *codec) 3538 { 3539 alc_init(codec); 3540 alc882_auto_init_multi_out(codec); 3541 alc882_auto_init_hp_out(codec); 3542 alc882_auto_init_analog_input(codec); 3543 return 0; 4349 /* additional initialization for auto-configuration model */ 4350 static void alc882_auto_init(struct hda_codec *codec) 4351 { 4352 alc882_auto_init_multi_out(codec); 4353 alc882_auto_init_hp_out(codec); 4354 alc882_auto_init_analog_input(codec); 3544 4355 } 3545 4356 … … 3607 4418 3608 4419 codec->patch_ops = alc_patch_ops; 3609 3610 codec->patch_ops.init= alc882_auto_init;4420 if (board_config == ALC882_AUTO) 4421 spec->init_hook = alc882_auto_init; 3611 4422 3612 4423 return 0; … … 3644 4455 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 3645 4456 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 3646 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),3647 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),3648 {3649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,3650 .name = "Capture Source",3651 .count = 1,3652 .info = alc882_mux_enum_info,3653 .get = alc882_mux_enum_get,3654 .put = alc882_mux_enum_put,3655 },3656 4457 {0} /* end */ 3657 }; 3658 4458 }; 4459 3659 4460 #define alc262_capture_mixer alc882_capture_mixer 3660 4461 #define alc262_capture_alt_mixer alc882_capture_alt_mixer … … 3714 4515 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3715 4516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3716 4517 3717 4518 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 3718 4519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 3719 4520 3720 4521 /* FIXME: use matrix-type input source selection */ 3721 4522 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ … … 3734 4535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3735 4536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 4537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3737 4538 3738 4539 {0} 4540 }; 4541 4542 /* 4543 * fujitsu model 4544 * 0x14 = headphone/spdif-out, 0x15 = internal speaker 4545 */ 4546 4547 #define ALC_HP_EVENT 0x37 4548 4549 static struct hda_verb alc262_fujitsu_unsol_verbs[] = { 4550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 4551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 4552 {0} 4553 }; 4554 4555 static struct hda_input_mux alc262_fujitsu_capture_source = { 4556 .num_items = 2, 4557 .items = { 4558 { "Mic", 0x0 }, 4559 { "CD", 0x4 }, 4560 }, 4561 }; 4562 4563 /* mute/unmute internal speaker according to the hp jack and mute state */ 4564 static void alc262_fujitsu_automute(struct hda_codec *codec, int force) 4565 { 4566 struct alc_spec *spec = codec->spec; 4567 unsigned int mute; 4568 4569 if (force || ! spec->sense_updated) { 4570 unsigned int present; 4571 /* need to execute and sync at first */ 4572 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 4573 present = snd_hda_codec_read(codec, 0x14, 0, 4574 AC_VERB_GET_PIN_SENSE, 0); 4575 spec->jack_present = (present & 0x80000000) != 0; 4576 spec->sense_updated = 1; 4577 } 4578 if (spec->jack_present) { 4579 /* mute internal speaker */ 4580 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 4581 0x80, 0x80); 4582 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 4583 0x80, 0x80); 4584 } else { 4585 /* unmute internal speaker if necessary */ 4586 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); 4587 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 4588 0x80, mute & 0x80); 4589 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0); 4590 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 4591 0x80, mute & 0x80); 4592 } 4593 } 4594 4595 /* unsolicited event for HP jack sensing */ 4596 static void alc262_fujitsu_unsol_event(struct hda_codec *codec, 4597 unsigned int res) 4598 { 4599 if ((res >> 26) != ALC_HP_EVENT) 4600 return; 4601 alc262_fujitsu_automute(codec, 1); 4602 } 4603 4604 /* bind volumes of both NID 0x0c and 0x0d */ 4605 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, 4606 struct snd_ctl_elem_value *ucontrol) 4607 { 4608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4609 long *valp = ucontrol->value.integer.value; 4610 int change; 4611 4612 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, 4613 0x7f, valp[0] & 0x7f); 4614 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, 4615 0x7f, valp[1] & 0x7f); 4616 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, 4617 0x7f, valp[0] & 0x7f); 4618 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, 4619 0x7f, valp[1] & 0x7f); 4620 return change; 4621 } 4622 4623 /* bind hp and internal speaker mute (with plug check) */ 4624 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 4625 struct snd_ctl_elem_value *ucontrol) 4626 { 4627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4628 long *valp = ucontrol->value.integer.value; 4629 int change; 4630 4631 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 4632 0x80, valp[0] ? 0 : 0x80); 4633 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 4634 0x80, valp[1] ? 0 : 0x80); 4635 if (change || codec->in_resume) 4636 alc262_fujitsu_automute(codec, codec->in_resume); 4637 return change; 4638 } 4639 4640 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { 4641 { 4642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4643 .name = "Master Playback Volume", 4644 .info = snd_hda_mixer_amp_volume_info, 4645 .get = snd_hda_mixer_amp_volume_get, 4646 .put = alc262_fujitsu_master_vol_put, 4647 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), 4648 }, 4649 { 4650 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4651 .name = "Master Playback Switch", 4652 .info = snd_hda_mixer_amp_switch_info, 4653 .get = snd_hda_mixer_amp_switch_get, 4654 .put = alc262_fujitsu_master_sw_put, 4655 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 4656 }, 4657 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 4658 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 4659 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 4660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 4661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 4662 {0} /* end */ 3739 4663 }; 3740 4664 … … 3759 4683 } 3760 4684 3761 nid = cfg->speaker_pin;4685 nid = cfg->speaker_pins[0]; 3762 4686 if (nid) { 3763 4687 if (nid == 0x16) { 3764 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",3765 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)3766 return err;3767 4688 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 3768 4689 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) … … 3789 4710 return err; 3790 4711 } else { 3791 if (! cfg->line_out_pins[0])3792 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",3793 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)3794 return err;3795 4712 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 3796 4713 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) … … 3798 4715 } 3799 4716 } 3800 return 0; 4717 return 0; 3801 4718 } 3802 4719 … … 3837 4754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3838 4755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3839 4756 3840 4757 /* set up input amps for analog loopback */ 3841 4758 /* Amp Indices: DAC = 0, mixer = 1 */ … … 3885 4802 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3886 4803 alc262_ignore)) < 0) 3887 return err; 3888 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 3889 ! spec->autocfg.hp_pin) 4804 return err; 4805 if (! spec->autocfg.line_outs) 3890 4806 return 0; /* can't find valid BIOS pin config */ 3891 4807 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || … … 3915 4831 3916 4832 /* init callback for auto-configuration model -- overriding the default init */ 3917 static int alc262_auto_init(struct hda_codec *codec) 3918 { 3919 alc_init(codec); 3920 alc262_auto_init_multi_out(codec); 3921 alc262_auto_init_hp_out(codec); 3922 alc262_auto_init_analog_input(codec); 3923 return 0; 4833 static void alc262_auto_init(struct hda_codec *codec) 4834 { 4835 alc262_auto_init_multi_out(codec); 4836 alc262_auto_init_hp_out(codec); 4837 alc262_auto_init_analog_input(codec); 3924 4838 } 3925 4839 … … 3929 4843 static struct hda_board_config alc262_cfg_tbl[] = { 3930 4844 { .modelname = "basic", .config = ALC262_BASIC }, 4845 { .modelname = "fujitsu", .config = ALC262_FUJITSU }, 4846 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU }, 3931 4847 { .modelname = "auto", .config = ALC262_AUTO }, 3932 4848 {0} 3933 4849 }; 3934 4850 … … 3943 4859 .channel_mode = alc262_modes, 3944 4860 .input_mux = &alc262_capture_source, 4861 }, 4862 [ALC262_FUJITSU] = { 4863 .mixers = { alc262_fujitsu_mixer }, 4864 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, 4865 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 4866 .dac_nids = alc262_dac_nids, 4867 .hp_nid = 0x03, 4868 .dig_out_nid = ALC262_DIGOUT_NID, 4869 .num_channel_mode = ARRAY_SIZE(alc262_modes), 4870 .channel_mode = alc262_modes, 4871 .input_mux = &alc262_fujitsu_capture_source, 4872 .unsol_event = alc262_fujitsu_unsol_event, 3945 4873 }, 3946 4874 }; … … 3992 4920 spec->stream_analog_playback = &alc262_pcm_analog_playback; 3993 4921 spec->stream_analog_capture = &alc262_pcm_analog_capture; 3994 4922 3995 4923 spec->stream_name_digital = "ALC262 Digital"; 3996 4924 spec->stream_digital_playback = &alc262_pcm_digital_playback; … … 4016 4944 4017 4945 codec->patch_ops = alc_patch_ops; 4018 4019 codec->patch_ops.init= alc262_auto_init;4020 4946 if (board_config == ALC262_AUTO) 4947 spec->init_hook = alc262_auto_init; 4948 4021 4949 return 0; 4022 4950 } … … 4087 5015 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 4088 5016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 4089 5017 4090 5018 /* Capture mixer control */ 4091 5019 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), … … 4121 5049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 4122 5050 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 4123 5051 4124 5052 /* Capture mixer control */ 4125 5053 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), … … 4142 5070 }, 4143 5071 {0} /* end */ 4144 }; 4145 5072 }; 5073 4146 5074 /* 4147 5075 * generic initialization of ADC, input mixers and output mixers … … 4178 5106 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 4179 5107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4180 5108 4181 5109 /* Unmute DAC0~3 & spdif out*/ 4182 5110 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, … … 4185 5113 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4186 5114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4187 5115 4188 5116 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 4189 5117 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, … … 4191 5119 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4192 5120 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4193 5121 4194 5122 /* Unmute Stereo Mixer 15 */ 4195 5123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, … … 4246 5174 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4247 5175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4248 5176 4249 5177 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 4250 5178 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, … … 4252 5180 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4253 5181 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4254 5182 4255 5183 /* Unmute Stereo Mixer 15 */ 4256 5184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, … … 4280 5208 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 4281 5209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4282 5210 4283 5211 /* Unmute DAC0~3 & spdif out*/ 4284 5212 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, … … 4287 5215 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 4288 5216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4289 5217 4290 5218 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 4291 5219 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, … … 4293 5221 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4294 5222 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4295 5223 4296 5224 /* Unmute Stereo Mixer 15 */ 4297 5225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, … … 4311 5239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4312 5240 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 5241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 5242 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 4315 5243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4316 5244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 5245 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 5246 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 4319 5247 4320 5248 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 … … 4446 5374 case 0x0d: 4447 5375 idx1 = 0; 4448 idx = 1; // Mic In 5376 idx = 1; // Mic In 4449 5377 break; 4450 case 0x10: 5378 case 0x10: 4451 5379 idx1 = 3; 4452 idx = 1; // Mic In 5380 idx = 1; // Mic In 4453 5381 break; 4454 5382 case 0x11: … … 4467 5395 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4468 5396 imux->items[imux->num_items].index = idx1; 4469 imux->num_items++; 5397 imux->num_items++; 4470 5398 } 4471 5399 return 0; … … 4548 5476 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4549 5477 alc861_ignore)) < 0) 4550 return err; 4551 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 4552 ! spec->autocfg.hp_pin) 4553 return 0; /* can't find valid BIOS pin config */ 5478 return err; 5479 if (! spec->autocfg.line_outs) 5480 return 0; /* can't find valid BIOS pin config */ 4554 5481 4555 5482 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || … … 4579 5506 } 4580 5507 4581 /* init callback for auto-configuration model -- overriding the default init */ 4582 static int alc861_auto_init(struct hda_codec *codec) 4583 { 4584 alc_init(codec); 4585 alc861_auto_init_multi_out(codec); 4586 alc861_auto_init_hp_out(codec); 4587 alc861_auto_init_analog_input(codec); 4588 4589 return 0; 5508 /* additional initialization for auto-configuration model */ 5509 static void alc861_auto_init(struct hda_codec *codec) 5510 { 5511 alc861_auto_init_multi_out(codec); 5512 alc861_auto_init_hp_out(codec); 5513 alc861_auto_init_analog_input(codec); 5514 4590 5515 } 4591 5516 … … 4639 5564 .input_mux = &alc861_capture_source, 4640 5565 }, 4641 }; 5566 }; 4642 5567 4643 5568 … … 4652 5577 return -ENOMEM; 4653 5578 4654 codec->spec = spec; 5579 codec->spec = spec; 4655 5580 4656 5581 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); … … 4684 5609 4685 5610 codec->patch_ops = alc_patch_ops; 4686 4687 codec->patch_ops.init= alc861_auto_init;4688 5611 if (board_config == ALC861_AUTO) 5612 spec->init_hook = alc861_auto_init; 5613 4689 5614 return 0; 4690 5615 } -
GPL/trunk/alsa-kernel/pci/hda/patch_si3054.c
r69 r76 297 297 struct hda_codec_preset snd_hda_preset_si3054[] = { 298 298 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 }, 299 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 }, 299 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 }, 300 { .id = 0x11c13026, .name = "Si3054", .patch = patch_si3054 }, 300 301 {0} 301 302 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c
r69 r76 50 50 unsigned int surr_switch: 1; 51 51 unsigned int line_switch: 1; 52 unsigned int mic_switch: 1; 52 unsigned int mic_switch: 1; 53 unsigned int alt_switch: 1; 54 unsigned int hp_detect: 1; 53 55 54 56 /* playback */ 55 56 hda_nid_t dac_nids[4];57 struct hda_multi_out multiout; 58 hda_nid_t dac_nids[5]; 57 59 58 60 /* capture */ … … 73 75 74 76 /* capture source */ 75 76 unsigned int cur_mux[2];77 struct hda_input_mux *input_mux; 78 unsigned int cur_mux[3]; 77 79 78 80 /* i/o switches */ … … 108 110 }; 109 111 112 static hda_nid_t stac927x_adc_nids[3] = { 113 0x07, 0x08, 0x09 114 }; 115 116 static hda_nid_t stac927x_mux_nids[3] = { 117 0x15, 0x16, 0x17 118 }; 119 110 120 static hda_nid_t stac9200_pin_nids[8] = { 111 121 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, … … 115 125 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 116 126 0x0f, 0x10, 0x11, 0x15, 0x1b, 127 }; 128 129 static hda_nid_t stac927x_pin_nids[14] = { 130 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 131 0x0f, 0x10, 0x11, 0x12, 0x13, 132 0x14, 0x21, 0x22, 0x23, 117 133 }; 118 134 … … 151 167 152 168 static struct hda_verb stac922x_core_init[] = { 153 /* set master volume and direct control */ 169 /* set master volume and direct control */ 154 170 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 155 171 {0} 172 }; 173 174 static struct hda_verb stac927x_core_init[] = { 175 /* set master volume and direct control */ 176 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 177 {0} 156 178 }; 157 179 … … 189 211 }; 190 212 213 static snd_kcontrol_new_t stac927x_mixer[] = { 214 { 215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 216 .name = "Input Source", 217 .count = 1, 218 .info = stac92xx_mux_enum_info, 219 .get = stac92xx_mux_enum_get, 220 .put = stac92xx_mux_enum_put, 221 }, 222 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT), 223 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT), 224 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT), 225 {0} /* end */ 226 }; 227 191 228 static int stac92xx_build_controls(struct hda_codec *codec) 192 229 { … … 215 252 return err; 216 253 } 217 return 0; 254 return 0; 218 255 } 219 256 … … 242 279 243 280 static unsigned int d945gtp3_pin_configs[10] = { 244 0x0221401f, 0x01a19022, 0x01813021, 0x01114010,245 246 281 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, 282 0x40000100, 0x40000100, 0x40000100, 0x40000100, 283 0x02a19120, 0x40000100, 247 284 }; 248 285 249 286 static unsigned int d945gtp5_pin_configs[10] = { 250 0x0221401f, 0x01111012, 0x01813024, 0x01114010,251 0x01a19021, 0x01116011, 0x01452130, 0x40000100,252 287 0x0221401f, 0x01011012, 0x01813024, 0x01014010, 288 0x01a19021, 0x01016011, 0x01452130, 0x40000100, 289 0x02a19320, 0x40000100, 253 290 }; 254 291 … … 267 304 .pci_subdevice = 0x0101, 268 305 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ 269 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 306 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 307 .pci_subdevice = 0x0202, 308 .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack, 9221 A1 */ 309 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 310 .pci_subdevice = 0x0b0b, 311 .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack, 9221 A1 */ 312 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 270 313 .pci_subdevice = 0x0404, 271 314 .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */ … … 275 318 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 276 319 .pci_subdevice = 0x0013, 277 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ 320 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ 321 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 322 .pci_subdevice = 0x0417, 323 .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */ 278 324 {0} /* terminator */ 325 }; 326 327 static unsigned int ref927x_pin_configs[14] = { 328 0x01813122, 0x01a19021, 0x01014010, 0x01016011, 329 0x01012012, 0x01011014, 0x40000100, 0x40000100, 330 0x40000100, 0x40000100, 0x40000100, 0x01441030, 331 0x01c41030, 0x40000100, 332 }; 333 334 static unsigned int *stac927x_brd_tbl[] = { 335 ref927x_pin_configs, 336 }; 337 338 static struct hda_board_config stac927x_cfg_tbl[] = { 339 { .modelname = "ref", 340 .pci_subvendor = PCI_VENDOR_ID_INTEL, 341 .pci_subdevice = 0x2668, /* DFI LanParty */ 342 .config = STAC_REF }, /* SigmaTel reference board */ 343 {0} /* terminator */ 279 344 }; 280 345 … … 300 365 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, 301 366 AC_VERB_GET_CONFIG_DEFAULT, 302 0x00); 367 0x00); 303 368 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); 304 369 } … … 410 475 }; 411 476 477 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { 478 .substreams = 1, 479 .channels_min = 2, 480 .channels_max = 2, 481 .nid = 0x06, /* NID to query formats and rates */ 482 .ops = { 483 .open = stac92xx_playback_pcm_open, 484 .prepare = stac92xx_playback_pcm_prepare, 485 .cleanup = stac92xx_playback_pcm_cleanup 486 }, 487 }; 488 412 489 static struct hda_pcm_stream stac92xx_pcm_analog_capture = { 413 490 .substreams = 2, 414 491 .channels_min = 2, 415 416 .nid = 0x06, /* NID to query formats and rates */492 .channels_max = 2, 493 /* NID is set in stac92xx_build_pcms */ 417 494 .ops = { 418 495 .prepare = stac92xx_capture_pcm_prepare, … … 432 509 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; 433 510 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; 434 511 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 512 513 if (spec->alt_switch) { 514 codec->num_pcms++; 515 info++; 516 info->name = "STAC92xx Analog Alt"; 517 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; 518 } 435 519 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 436 520 codec->num_pcms++; … … 450 534 } 451 535 536 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) 537 { 538 unsigned int pincap = snd_hda_param_read(codec, nid, 539 AC_PAR_PIN_CAP); 540 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; 541 if (pincap & AC_PINCAP_VREF_100) 542 return AC_PINCTL_VREF_100; 543 if (pincap & AC_PINCAP_VREF_80) 544 return AC_PINCTL_VREF_80; 545 if (pincap & AC_PINCAP_VREF_50) 546 return AC_PINCTL_VREF_50; 547 if (pincap & AC_PINCAP_VREF_GRD) 548 return AC_PINCTL_VREF_GRD; 549 return 0; 550 } 551 452 552 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) 453 553 … … 486 586 487 587 if (val) 488 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); 489 else 490 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN); 588 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); 589 else { 590 unsigned int pinctl = AC_PINCTL_IN_EN; 591 if (io_idx) /* set VREF for mic */ 592 pinctl |= stac92xx_get_vref(codec, nid); 593 stac92xx_auto_set_pinctl(codec, nid, pinctl); 594 } 491 595 492 596 return 1; … … 590 694 } 591 695 696 /* 697 * XXX The line_out pin widget connection list may not be set to the 698 * desired DAC nid. This is the case on 927x where ports A and B can 699 * be routed to several DACs. 700 * 701 * This requires an analysis of the line-out/hp pin configuration 702 * to provide a best fit for pin/DAC configurations that are routable. 703 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports 704 * A and B is not supported. 705 */ 592 706 /* fill in the dac_nids table from the parsed pin configuration */ 593 707 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) … … 604 718 } 605 719 606 720 spec->multiout.num_dacs = cfg->line_outs; 607 721 608 722 return 0; … … 672 786 return 0; 673 787 674 675 if (wid_caps & AC_WCAP_UNSOL_CAP) 788 wid_caps = get_wcaps(codec, pin); 789 if (wid_caps & AC_WCAP_UNSOL_CAP) { 676 790 /* Enable unsolicited responses on the HP widget */ 677 791 snd_hda_codec_write(codec, pin, 0, 678 792 AC_VERB_SET_UNSOLICITED_ENABLE, 679 STAC_UNSOL_ENABLE); 793 STAC_UNSOL_ENABLE); 794 spec->hp_detect = 1; 795 } 680 796 681 797 nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff; … … 711 827 int index = -1; 712 828 if (cfg->input_pins[i]) { 713 /* Enable active pin widget as an input */714 stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN);715 716 829 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 717 830 … … 755 868 } 756 869 757 static int stac92 2x_parse_auto_config(struct hda_codec *codec)870 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) 758 871 { 759 872 struct sigmatel_spec *spec = codec->spec; … … 761 874 762 875 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) 763 return err; 876 return err; 877 if (! spec->autocfg.line_outs) 878 return 0; /* can't find valid pin config */ 764 879 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) 765 880 return err; 766 881 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) 767 882 return err; 768 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)769 return 0; /* can't find valid pin config */770 883 771 884 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || … … 778 891 spec->surr_switch = 1; 779 892 780 if (spec->autocfg.dig_out_pin) { 781 spec->multiout.dig_out_nid = 0x08; 782 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); 783 } 784 if (spec->autocfg.dig_in_pin) { 785 spec->dig_in_nid = 0x09; 786 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); 787 } 893 if (spec->autocfg.dig_out_pin) 894 spec->multiout.dig_out_nid = dig_out; 895 if (spec->autocfg.dig_in_pin) 896 spec->dig_in_nid = dig_in; 788 897 789 898 if (spec->kctl_alloc) … … 795 904 } 796 905 906 /* add playback controls for HP output */ 907 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, 908 struct auto_pin_cfg *cfg) 909 { 910 struct sigmatel_spec *spec = codec->spec; 911 hda_nid_t pin = cfg->hp_pin; 912 unsigned int wid_caps; 913 914 if (! pin) 915 return 0; 916 917 wid_caps = get_wcaps(codec, pin); 918 if (wid_caps & AC_WCAP_UNSOL_CAP) { 919 /* Enable unsolicited responses on the HP widget */ 920 snd_hda_codec_write(codec, pin, 0, 921 AC_VERB_SET_UNSOLICITED_ENABLE, 922 STAC_UNSOL_ENABLE); 923 spec->hp_detect = 1; 924 } 925 926 return 0; 927 } 928 797 929 static int stac9200_parse_auto_config(struct hda_codec *codec) 798 930 { … … 806 938 return err; 807 939 808 if (spec->autocfg.dig_out_pin) { 809 spec->multiout.dig_out_nid = 0x05; 810 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); 811 } 812 if (spec->autocfg.dig_in_pin) { 813 spec->dig_in_nid = 0x04; 814 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); 815 } 940 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) 941 return err; 942 943 if (spec->autocfg.dig_out_pin) 944 spec->multiout.dig_out_nid = 0x05; 945 if (spec->autocfg.dig_in_pin) 946 spec->dig_in_nid = 0x04; 816 947 817 948 if (spec->kctl_alloc) … … 825 956 static int stac92xx_init(struct hda_codec *codec) 826 957 { 827 struct sigmatel_spec *spec = codec->spec; 828 829 snd_hda_sequence_write(codec, spec->init); 830 831 stac92xx_auto_init_multi_out(codec); 832 stac92xx_auto_init_hp_out(codec); 833 834 return 0; 958 struct sigmatel_spec *spec = codec->spec; 959 struct auto_pin_cfg *cfg = &spec->autocfg; 960 int i; 961 962 snd_hda_sequence_write(codec, spec->init); 963 964 /* set up pins */ 965 if (spec->hp_detect) { 966 /* fake event to set up pins */ 967 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 968 } else { 969 stac92xx_auto_init_multi_out(codec); 970 stac92xx_auto_init_hp_out(codec); 971 } 972 for (i = 0; i < AUTO_PIN_LAST; i++) { 973 hda_nid_t nid = cfg->input_pins[i]; 974 if (nid) { 975 unsigned int pinctl = AC_PINCTL_IN_EN; 976 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) 977 pinctl |= stac92xx_get_vref(codec, nid); 978 stac92xx_auto_set_pinctl(codec, nid, pinctl); 979 } 980 } 981 if (cfg->dig_out_pin) 982 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 983 AC_PINCTL_OUT_EN); 984 if (cfg->dig_in_pin) 985 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, 986 AC_PINCTL_IN_EN); 987 988 return 0; 835 989 } 836 990 … … 897 1051 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); 898 1052 } 899 } 1053 } 900 1054 901 1055 #ifdef CONFIG_PM … … 998 1152 spec->multiout.dac_nids = spec->dac_nids; 999 1153 1000 err = stac922x_parse_auto_config(codec); 1001 if (err < 0) { 1154 err = stac92xx_parse_auto_config(codec, 0x08, 0x09); 1155 if (err < 0) { 1156 stac92xx_free(codec); 1157 return err; 1158 } 1159 1160 codec->patch_ops = stac92xx_patch_ops; 1161 1162 return 0; 1163 } 1164 1165 static int patch_stac927x(struct hda_codec *codec) 1166 { 1167 struct sigmatel_spec *spec; 1168 int err; 1169 1170 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1171 if (spec == NULL) 1172 return -ENOMEM; 1173 1174 codec->spec = spec; 1175 spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl); 1176 if (spec->board_config < 0) 1177 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n"); 1178 else { 1179 spec->num_pins = 14; 1180 spec->pin_nids = stac927x_pin_nids; 1181 spec->pin_configs = stac927x_brd_tbl[spec->board_config]; 1182 stac92xx_set_config_regs(codec); 1183 } 1184 1185 spec->adc_nids = stac927x_adc_nids; 1186 spec->mux_nids = stac927x_mux_nids; 1187 spec->num_muxes = 3; 1188 1189 spec->init = stac927x_core_init; 1190 spec->mixer = stac927x_mixer; 1191 1192 spec->multiout.dac_nids = spec->dac_nids; 1193 1194 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); 1195 if (err < 0) { 1002 1196 stac92xx_free(codec); 1003 1197 return err; … … 1010 1204 1011 1205 /* 1206 * STAC 7661(?) hack 1207 */ 1208 1209 /* static config for Sony VAIO FE550G */ 1210 static hda_nid_t vaio_dacs[] = { 0x2 }; 1211 #define VAIO_HP_DAC 0x5 1212 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; 1213 static hda_nid_t vaio_mux_nids[] = { 0x15 }; 1214 1215 static struct hda_input_mux vaio_mux = { 1216 .num_items = 2, 1217 .items = { 1218 /* { "HP", 0x0 }, 1219 { "Unknown", 0x1 }, */ 1220 { "Mic", 0x2 }, 1221 { "PCM", 0x3 }, 1222 } 1223 }; 1224 1225 static struct hda_verb vaio_init[] = { 1226 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ 1227 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ 1228 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ 1229 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ 1230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ 1231 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ 1232 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ 1233 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ 1234 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ 1235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ 1236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ 1237 {0} 1238 }; 1239 1240 /* bind volumes of both NID 0x02 and 0x05 */ 1241 static int vaio_master_vol_put(struct snd_kcontrol *kcontrol, 1242 struct snd_ctl_elem_value *ucontrol) 1243 { 1244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1245 long *valp = ucontrol->value.integer.value; 1246 int change; 1247 1248 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, 1249 0x7f, valp[0] & 0x7f); 1250 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, 1251 0x7f, valp[1] & 0x7f); 1252 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, 1253 0x7f, valp[0] & 0x7f); 1254 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, 1255 0x7f, valp[1] & 0x7f); 1256 return change; 1257 } 1258 1259 /* bind volumes of both NID 0x02 and 0x05 */ 1260 static int vaio_master_sw_put(struct snd_kcontrol *kcontrol, 1261 struct snd_ctl_elem_value *ucontrol) 1262 { 1263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1264 long *valp = ucontrol->value.integer.value; 1265 int change; 1266 1267 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, 1268 0x80, valp[0] & 0x80); 1269 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, 1270 0x80, valp[1] & 0x80); 1271 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, 1272 0x80, valp[0] & 0x80); 1273 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, 1274 0x80, valp[1] & 0x80); 1275 return change; 1276 } 1277 1278 static struct snd_kcontrol_new vaio_mixer[] = { 1279 { 1280 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1281 .name = "Master Playback Volume", 1282 .info = snd_hda_mixer_amp_volume_info, 1283 .get = snd_hda_mixer_amp_volume_get, 1284 .put = vaio_master_vol_put, 1285 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 1286 }, 1287 { 1288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1289 .name = "Master Playback Switch", 1290 .info = snd_hda_mixer_amp_switch_info, 1291 .get = snd_hda_mixer_amp_switch_get, 1292 .put = vaio_master_sw_put, 1293 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), 1294 }, 1295 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ 1296 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 1297 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 1298 { 1299 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1300 .name = "Capture Source", 1301 .count = 1, 1302 .info = stac92xx_mux_enum_info, 1303 .get = stac92xx_mux_enum_get, 1304 .put = stac92xx_mux_enum_put, 1305 }, 1306 {0} 1307 }; 1308 1309 static struct hda_codec_ops stac7661_patch_ops = { 1310 .build_controls = stac92xx_build_controls, 1311 .build_pcms = stac92xx_build_pcms, 1312 .init = stac92xx_init, 1313 .free = stac92xx_free, 1314 #ifdef CONFIG_PM 1315 .resume = stac92xx_resume, 1316 #endif 1317 }; 1318 1319 enum { STAC7661_VAIO }; 1320 1321 static struct hda_board_config stac7661_cfg_tbl[] = { 1322 { .modelname = "vaio", .config = STAC7661_VAIO }, 1323 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6, 1324 .config = STAC7661_VAIO }, 1325 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef, 1326 .config = STAC7661_VAIO }, 1327 {0} 1328 }; 1329 1330 static int patch_stac7661(struct hda_codec *codec) 1331 { 1332 struct sigmatel_spec *spec; 1333 int board_config; 1334 1335 board_config = snd_hda_check_board_config(codec, stac7661_cfg_tbl); 1336 if (board_config < 0) 1337 /* unknown config, let generic-parser do its job... */ 1338 return snd_hda_parse_generic_codec(codec); 1339 1340 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1341 if (spec == NULL) 1342 return -ENOMEM; 1343 1344 codec->spec = spec; 1345 switch (board_config) { 1346 case STAC7661_VAIO: 1347 spec->mixer = vaio_mixer; 1348 spec->init = vaio_init; 1349 spec->multiout.max_channels = 2; 1350 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); 1351 spec->multiout.dac_nids = vaio_dacs; 1352 spec->multiout.hp_nid = VAIO_HP_DAC; 1353 spec->num_adcs = ARRAY_SIZE(vaio_adcs); 1354 spec->adc_nids = vaio_adcs; 1355 spec->input_mux = &vaio_mux; 1356 spec->mux_nids = vaio_mux_nids; 1357 break; 1358 } 1359 1360 codec->patch_ops = stac7661_patch_ops; 1361 return 0; 1362 } 1363 1364 1365 /* 1012 1366 * patch entries 1013 1367 */ … … 1019 1373 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, 1020 1374 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, 1021 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, 1375 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, 1376 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, 1377 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, 1378 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, 1379 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, 1380 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, 1381 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, 1382 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, 1383 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, 1384 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, 1385 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, 1386 { .id = 0x83847661, .name = "STAC7661", .patch = patch_stac7661 }, 1022 1387 {0} /* terminator */ 1023 1388 }; -
GPL/trunk/alsa-kernel/pci/intel8x0.c
r70 r76 494 494 { 0x10de, 0x00da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ 495 495 { 0x10de, 0x00ea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8S */ 496 { 0x10de, 0x026b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* MCP51 */ 496 497 { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */ 497 498 { 0x1022, 0x7445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */ … … 834 835 unsigned int status; 835 836 unsigned int i; 837 #ifdef TARGET_OS2 838 int fOurIrq = FALSE; 839 #endif 836 840 837 841 status = igetdword(chip, chip->int_sta_reg); … … 854 858 #endif 855 859 } 856 return IRQ_RETVAL(status); 857 } 860 return IRQ_NONE/*RETVAL(status)*/; 861 } 862 #ifdef TARGET_OS2 863 fOurIrq = TRUE; 864 #endif 858 865 859 866 for (i = 0; i < chip->bdbars_count; i++) { … … 865 872 /* ack them */ 866 873 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask); 874 #ifdef TARGET_OS2 875 if (fOurIrq) { 876 //eoi_irq(irq); 877 } 878 #endif //TARGET_OS2 867 879 868 880 return IRQ_HANDLED; … … 1161 1173 runtime->hw.period_bytes_max = 64*1024; 1162 1174 } 1175 #if 1 /* vladest */ 1163 1176 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 1164 1177 return err; 1178 #endif 1165 1179 runtime->private_data = ichdev; 1166 1180 return 0; … … 1175 1189 err = snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMOUT]); 1176 1190 if (err < 0) 1191 { 1192 printk("snd_intel8x0_pcm_open open error: %i\n", err); 1177 1193 return err; 1194 } 1178 1195 if (chip->multi6) { 1179 1196 runtime->hw.channels_max = 6; … … 1988 2005 .name = "Fujitsu-Siemens D1522", /* AD1981 */ 1989 2006 .type = AC97_TUNE_HP_ONLY 1990 }, 2007 }, 2008 { 2009 .subvendor = 0x8086, 2010 .subdevice = 0x0104, 2011 .name = "Intel D845GEBV2", /* AD1981B */ 2012 .type = AC97_TUNE_HP_ONLY 2013 }, 1991 2014 { 1992 2015 .subvendor = 0x8086, … … 2310 2333 */ 2311 2334 end_time = jiffies + HZ; 2312 i = 0;2313 2335 do { 2314 status = igetdword(chip, ICHREG(GLOB_STA)) & chip->codec_isr_bits;; 2336 status = igetdword(chip, ICHREG(GLOB_STA)) & 2337 chip->codec_isr_bits; 2315 2338 if (status) 2316 2339 break; 2317 2340 mdelay(1); 2318 2341 //do_delay(chip); 2319 i++; 2320 } while (i<100);/*(time_after_eq(end_time, jiffies));*/ 2342 } while (time_after_eq(end_time, jiffies)); 2321 2343 2322 2344 if (! status) { … … 2410 2432 static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing) 2411 2433 { 2412 unsigned int i ;2434 unsigned int i, timeout; 2413 2435 int err; 2414 2436 … … 2428 2450 for (i = 0; i < chip->bdbars_count; i++) 2429 2451 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); 2452 for (i = 0; i < chip->bdbars_count; i++) { 2453 timeout = 100000; 2454 while (--timeout != 0) { 2455 if ((igetbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset) & ICH_RESETREGS) == 0) 2456 break; 2457 } 2458 if (timeout == 0) 2459 printk(KERN_ERR "intel8x0: reset of registers failed?\n"); 2460 } 2430 2461 /* initialize Buffer Descriptor Lists */ 2431 2462 for (i = 0; i < chip->bdbars_count; i++) … … 2606 2637 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); 2607 2638 spin_unlock_irq(&chip->reg_lock); 2608 2639 #if 0 2609 2640 t = stop_time.tv_sec - start_time.tv_sec; 2610 2641 t *= 1000000; 2611 2642 t += stop_time.tv_usec - start_time.tv_usec; 2643 #else 2644 t = 50000; /* patch, suggested by r.ihle */ 2645 #endif 2612 2646 printk(KERN_INFO "%s: measured %lu usecs\n", __FUNCTION__, t); 2613 2647 if (t == 0) { -
GPL/trunk/alsa-kernel/pci/maestro3.c
r70 r76 830 830 831 831 struct pci_dev *pci; 832 struct m3_quirk *quirk;833 struct m3_hv_quirk *hv_quirk;832 const struct m3_quirk *quirk; 833 const struct m3_hv_quirk *hv_quirk; 834 834 835 835 int dacs_active; … … 918 918 919 919 MODULE_DEVICE_TABLE(pci, snd_m3_ids); 920 #if 0 921 struct m3_quirk { 922 const char *name; /* device name */ 923 u16 vendor, device; /* subsystem ids */ 924 int amp_gpio; /* gpio pin # for external amp, -1 = default */ 925 int irda_workaround; /* non-zero if avoid to touch 0x10 on GPIO_DIRECTION 926 (e.g. for IrDA on Dell Inspirons) */ 927 }; 928 #endif 929 static struct m3_quirk m3_quirk_list[] = { 920 921 static const struct m3_quirk m3_quirk_list[] = { 930 922 /* panasonic CF-28 "toughbook" */ 931 923 { 932 /*.name = */"Panasonic CF-28", 933 /*.vendor = */0x10f7, 934 /*.device = */0x833e, 935 /*.amp_gpio = */0x0d, 936 0 924 .name = "Panasonic CF-28", 925 .vendor = 0x10f7, 926 .device = 0x833e, 927 .amp_gpio = 0x0d, 937 928 }, 938 929 /* panasonic CF-72 "toughbook" */ 939 930 { 940 /*.name = */"Panasonic CF-72", 941 /*.vendor = */0x10f7, 942 /*.device = */0x833d, 943 /*.amp_gpio = */0x0d, 944 0 931 .name = "Panasonic CF-72", 932 .vendor = 0x10f7, 933 .device = 0x833d, 934 .amp_gpio = 0x0d, 945 935 }, 946 936 /* Dell Inspiron 4000 */ 947 937 { 948 /*.name = */"Dell Inspiron 4000",949 /*.vendor = */0x1028,950 /*.device = */0x00b0,951 /*.amp_gpio = */-1,952 /*.irda_workaround = */1,938 .name = "Dell Inspiron 4000", 939 .vendor = 0x1028, 940 .device = 0x00b0, 941 .amp_gpio = -1, 942 .irda_workaround = 1, 953 943 }, 954 944 /* Dell Inspiron 8000 */ 955 945 { 956 /*.name = */"Dell Inspiron 8000",957 /*.vendor = */0x1028,958 /*.device = */0x00a4,959 /*.amp_gpio = */-1,960 /*.irda_workaround = */1,946 .name = "Dell Inspiron 8000", 947 .vendor = 0x1028, 948 .device = 0x00a4, 949 .amp_gpio = -1, 950 .irda_workaround = 1, 961 951 }, 962 #if 1963 952 /* Dell Inspiron 8100 */ 964 953 { 965 /*.name = */"Dell Inspiron 8100",966 /*.vendor = */0x1028,967 /*.device = */0x00e6,968 /*.amp_gpio = */-1,969 /*.irda_workaround = */1,954 .name = "Dell Inspiron 8100", 955 .vendor = 0x1028, 956 .device = 0x00e6, 957 .amp_gpio = -1, 958 .irda_workaround = 1, 970 959 }, 971 #endif972 960 /* NEC LM800J/7 */ 973 961 { 974 /*.name = */"NEC LM800J/7", 975 /*.vendor = */0x1033, 976 /*.device = */0x80f1, 977 /*.amp_gpio = */0x03, 978 0 962 .name = "NEC LM800J/7", 963 .vendor = 0x1033, 964 .device = 0x80f1, 965 .amp_gpio = 0x03, 979 966 }, 980 967 /* LEGEND ZhaoYang 3100CF */ 981 968 { 982 "LEGEND ZhaoYang 3100CF", 983 0x1509, 984 0x1740, 985 0x03, 986 0 969 .name = "LEGEND ZhaoYang 3100CF", 970 .vendor = 0x1509, 971 .device = 0x1740, 972 .amp_gpio = 0x03, 987 973 }, 988 974 /* END */ 989 { 0}975 { NULL } 990 976 }; 991 977 992 978 /* These values came from the Windows driver. */ 993 static struct m3_hv_quirk m3_hv_quirk_list[] = {979 static const struct m3_hv_quirk m3_hv_quirk_list[] = { 994 980 /* Allegro chips */ 995 981 { 0x125D, 0x1988, 0x0E11, 0x002E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, … … 1398 1384 } 1399 1385 1400 1401 static struct play_vals { 1386 static const struct play_vals { 1402 1387 u16 addr, val; 1403 1388 } pv[] = { … … 1465 1450 * Native record driver 1466 1451 */ 1467 static struct rec_vals {1452 static const struct rec_vals { 1468 1453 u16 addr, val; 1469 1454 } rv[] = { … … 1635 1620 return; 1636 1621 1637 hwptr = snd_m3_get_pointer(chip, s, subs) % s->dma_size; 1638 diff = (s->dma_size + hwptr - s->hwptr) % s->dma_size; 1622 hwptr = snd_m3_get_pointer(chip, s, subs); 1623 /* try to avoid expensive modulo divisions */ 1624 if (hwptr >= s->dma_size) 1625 hwptr %= s->dma_size; 1626 1627 diff = s->dma_size + hwptr - s->hwptr; 1628 if (diff >= s->dma_size) 1629 diff %= s->dma_size; 1630 1639 1631 s->hwptr = hwptr; 1640 1632 s->count += diff; 1633 1641 1634 if (s->count >= (signed)s->period_size) { 1642 s->count %= s->period_size; 1635 if (s->count < 2 * (signed)s->period_size) 1636 s->count -= (signed)s->period_size; 1637 else 1638 s->count %= s->period_size; 1639 1643 1640 spin_unlock(&chip->reg_lock); 1644 1641 snd_pcm_period_elapsed(subs); … … 1715 1712 u8 status; 1716 1713 int i; 1717 #ifdef TARGET_OS2 1718 int fOurIrq = FALSE; 1719 #endif 1720 #ifdef DEBUG 1721 dprintf(("int")); 1722 #endif 1714 1723 1715 status = inb(chip->iobase + HOST_INT_STATUS); 1724 #ifdef DEBUG1725 dprintf(("%x",status));1726 #endif1727 1716 1728 1717 if (status == 0xff) 1729 1718 return IRQ_NONE; 1730 1719 1731 #ifdef TARGET_OS21732 fOurIrq = TRUE;1733 #endif1734 1720 if (status & HV_INT_PENDING) 1735 1721 tasklet_hi_schedule(&chip->hwvol_tq); … … 1764 1750 /* ack ints */ 1765 1751 outb(status, chip->iobase + HOST_INT_STATUS); 1766 #ifdef TARGET_OS21767 if (fOurIrq) {1768 eoi_irq(irq);1769 }1770 #endif //TARGET_OS21771 1772 1752 return IRQ_HANDLED; 1773 1753 } … … 1996 1976 if (! (snd_m3_inb(chip, 0x30) & 1)) 1997 1977 return 0; 1978 cpu_relax(); 1998 1979 } while (i-- > 0); 1999 1980 … … 2007 1988 m3_t *chip = ac97->private_data; 2008 1989 unsigned long flags; 2009 unsigned short data ;1990 unsigned short data = 0xffff; 2010 1991 2011 1992 if (snd_m3_ac97_wait(chip)) 2012 return 0xffff;1993 goto fail; 2013 1994 spin_lock_irqsave(&chip->ac97_lock, flags); 2014 1995 snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND); 2015 1996 if (snd_m3_ac97_wait(chip)) 2016 return 0xffff;1997 goto fail_unlock; 2017 1998 data = snd_m3_inw(chip, CODEC_DATA); 1999 fail_unlock: 2018 2000 spin_unlock_irqrestore(&chip->ac97_lock, flags); 2001 fail: 2019 2002 return data; 2020 2003 } … … 2178 2161 */ 2179 2162 2180 static u16 assp_kernel_image[] __devinitdata = {2163 static const u16 assp_kernel_image[] __devinitdata = { 2181 2164 0x7980, 0x0030, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x00FB, 0x7980, 0x00DD, 0x7980, 0x03B4, 2182 2165 0x7980, 0x0332, 0x7980, 0x0287, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x03B4, … … 2265 2248 * that is to be loaded at 0x400 on the DSP. 2266 2249 */ 2267 static u16 assp_minisrc_image[] __devinitdata = {2250 static const u16 assp_minisrc_image[] __devinitdata = { 2268 2251 2269 2252 0xBF80, 0x101E, 0x906E, 0x006E, 0x8B88, 0x6980, 0xEF88, 0x906F, 0x0D6F, 0x6900, 0xEB08, 0x0412, … … 2308 2291 2309 2292 #define MINISRC_LPF_LEN 10 2310 static u16 minisrc_lpf[MINISRC_LPF_LEN] __devinitdata = {2293 static const u16 minisrc_lpf[MINISRC_LPF_LEN] __devinitdata = { 2311 2294 0X0743, 0X1104, 0X0A4C, 0XF88D, 0X242C, 2312 2295 0X1023, 0X1AA9, 0X0B60, 0XEFDD, 0X186F … … 2415 2398 2416 2399 /* 2417 * align instance address to 256 bytes so that it 's2400 * align instance address to 256 bytes so that its 2418 2401 * shifted list address is aligned. 2419 2402 * list address = (mem address >> 1) >> 7; … … 2698 2681 m3_t *chip; 2699 2682 int i, err; 2700 struct m3_quirk *quirk; 2701 struct m3_hv_quirk *hv_quirk; 2702 #ifdef TARGET_OS2 2703 static snd_device_ops_t ops = { 2704 snd_m3_dev_free,0,0,0 2683 const struct m3_quirk *quirk; 2684 const struct m3_hv_quirk *hv_quirk; 2685 static struct snd_device_ops ops = { 2686 .dev_free = snd_m3_dev_free, 2705 2687 }; 2706 #else2707 static snd_device_ops_t ops = {2708 dev_free: snd_m3_dev_free,2709 };2710 #endif2711 2688 2712 2689 *chip_ret = NULL; … … 2854 2831 2855 2832 pci_read_config_dword(pci, PCI_CLASS_REVISION, &pci->_class); 2856 2857 #ifdef DEBUG2858 dprintf(("m3_probe. %x",pci->_class));2859 #endif2860 2833 2861 2834 #if 0 // os/2 doesnt pickup classes … … 2912 2885 return err; 2913 2886 } 2914 #ifdef DEBUG2915 dprintf(("m3_probe: card registered"));2916 #endif2917 2887 2918 2888 #if 0 /* TODO: not supported yet */ 2919 /* TODO enable midi irq and i/o*/2889 /* TODO enable MIDI IRQ and I/O */ 2920 2890 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401, 2921 2891 chip->iobase + MPU401_DATA_PORT, 1, 2922 2892 chip->irq, 0, &chip->rmidi); 2923 2893 if (err < 0) 2924 printk(KERN_WARNING "maestro3: no midisupport.\n");2894 printk(KERN_WARNING "maestro3: no MIDI support.\n"); 2925 2895 #endif 2926 2896 -
GPL/trunk/alsa-kernel/pci/nm256/nm256.c
r32 r76 1 /* 1 /* 2 2 * Driver for NeoMagic 256AV and 256ZX chipsets. 3 3 * Copyright (c) 2000 by Takashi Iwai <tiwai@suse.de> … … 24 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 25 */ 26 26 27 27 #include <sound/driver.h> 28 #include <asm/io.h> 29 #include <linux/delay.h> 30 #include <linux/interrupt.h> 31 #include <linux/init.h> 32 #include <linux/pci.h> 33 #include <linux/slab.h> 34 #include <linux/moduleparam.h> 35 #include <linux/mutex.h> 36 37 #include <sound/core.h> 28 38 #include <sound/info.h> 29 39 #include <sound/control.h> 30 40 #include <sound/pcm.h> 31 41 #include <sound/ac97_codec.h> 32 #define SNDRV_GET_ID33 42 #include <sound/initval.h> 34 43 … … 39 48 MODULE_DESCRIPTION("NeoMagic NM256AV/ZX"); 40 49 MODULE_LICENSE("GPL"); 41 MODULE_CLASSES("{sound}"); 42 MODULE_DEVICES("{{NeoMagic,NM256AV}," 43 "{NeoMagic,NM256ZX}}"); 50 MODULE_SUPPORTED_DEVICE("{{NeoMagic,NM256AV}," 51 "{NeoMagic,NM256ZX}}"); 44 52 45 53 /* … … 47 55 */ 48 56 49 static int index [SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX*/50 static char *id [SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */51 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;52 static int playback_bufsize[SNDRV_CARDS] = {REPEAT_SNDRV(16)};53 static int capture_bufsize[SNDRV_CARDS] = {REPEAT_SNDRV(16)};54 static int force_ac97[SNDRV_CARDS] = {REPEAT_SNDRV(0)}; /* disabled as default*/55 static int buffer_top[SNDRV_CARDS] = {REPEAT_SNDRV(0)}; /* not specified */56 static int use_cache[SNDRV_CARDS] = {REPEAT_SNDRV(0)};/* disabled */57 static int vaio_hack[SNDRV_CARDS] = {REPEAT_SNDRV(0)}; /* disabled */58 static int reset_workaround [SNDRV_CARDS];59 60 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");57 static int index = SNDRV_DEFAULT_IDX1; /* Index */ 58 static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 59 static int playback_bufsize = 16; 60 static int capture_bufsize = 16; 61 static int force_ac97; /* disabled as default */ 62 static int buffer_top; /* not specified */ 63 static int use_cache; /* disabled */ 64 static int vaio_hack; /* disabled */ 65 static int reset_workaround; 66 static int reset_workaround_2; 67 68 //module_param(index, int, 0444); 61 69 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 62 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC); 63 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s"); 70 //module_param(id, charp, 0444); 64 71 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); 65 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); 66 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 67 MODULE_PARM_DESC(enable, "Enable this soundcard."); 68 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 69 MODULE_PARM(playback_bufsize, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 72 //module_param(playback_bufsize, int, 0444); 70 73 MODULE_PARM_DESC(playback_bufsize, "DAC frame size in kB for " CARD_NAME " soundcard."); 71 MODULE_PARM_SYNTAX(playback_bufsize, SNDRV_ENABLED); 72 MODULE_PARM(capture_bufsize, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 74 //module_param(capture_bufsize, int, 0444); 73 75 MODULE_PARM_DESC(capture_bufsize, "ADC frame size in kB for " CARD_NAME " soundcard."); 74 MODULE_PARM_SYNTAX(capture_bufsize, SNDRV_ENABLED); 75 MODULE_PARM(force_ac97, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 76 //module_param(force_ac97, bool, 0444); 76 77 MODULE_PARM_DESC(force_ac97, "Force to use AC97 codec for " CARD_NAME " soundcard."); 77 MODULE_PARM_SYNTAX(force_ac97, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); 78 MODULE_PARM(buffer_top, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 78 //module_param(buffer_top, int, 0444); 79 79 MODULE_PARM_DESC(buffer_top, "Set the top address of audio buffer for " CARD_NAME " soundcard."); 80 MODULE_PARM_SYNTAX(buffer_top, SNDRV_ENABLED); 81 MODULE_PARM(use_cache, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 80 //module_param(use_cache, bool, 0444); 82 81 MODULE_PARM_DESC(use_cache, "Enable the cache for coefficient table access."); 83 MODULE_PARM_SYNTAX(use_cache, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); 84 MODULE_PARM(vaio_hack, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 82 //module_param(vaio_hack, bool, 0444); 85 83 MODULE_PARM_DESC(vaio_hack, "Enable workaround for Sony VAIO notebooks."); 86 MODULE_PARM_SYNTAX(vaio_hack, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); 87 //module_param_array(reset_workaround, bool, boot_devs, 0444); 84 //module_param(reset_workaround, bool, 0444); 88 85 MODULE_PARM_DESC(reset_workaround, "Enable AC97 RESET workaround for some laptops."); 86 //module_param(reset_workaround_2, bool, 0444); 87 MODULE_PARM_DESC(reset_workaround_2, "Enable extended AC97 RESET workaround for some other laptops."); 88 89 /* just for backward compatibility */ 90 static int enable; 91 //module_param(enable, bool, 0444); 92 93 94 /* nm256 */ 95 #ifndef PCI_VENDOR_ID_NEOMAGIC 96 #define PCI_VENDOR_ID_NEOMEGIC 0x10c8 97 #endif 98 #ifndef PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 99 #define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 100 #endif 101 #ifndef PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 102 #define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 103 #endif 104 #ifndef PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 105 #define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 106 #endif 107 89 108 /* 90 109 * hw definitions … … 180 199 #define NM_PBUFFER_CURRP (NM_PLAYBACK_REG_OFFSET + 0x8) 181 200 182 /* 183 * type definitions 184 */ 185 186 typedef struct snd_nm256 nm256_t; 187 typedef struct snd_nm256_stream nm256_stream_t; 188 189 struct snd_nm256_stream { 190 191 nm256_t *chip; 192 snd_pcm_substream_t *substream; 193 int running; 194 int suspended; 195 196 u32 buf; /* offset from chip->buffer */ 197 int bufsize; /* buffer size in bytes */ 198 unsigned long bufptr; /* mapped pointer */ 199 unsigned long bufptr_addr; /* physical address of the mapped pointer */ 200 201 int dma_size; /* buffer size of the substream in bytes */ 202 int period_size; /* period size in bytes */ 203 int periods; /* # of periods */ 204 int shift; /* bit shifts */ 205 int cur_period; /* current period # */ 201 struct nm256_stream { 202 203 struct nm256 *chip; 204 struct snd_pcm_substream *substream; 205 int running; 206 int suspended; 207 208 u32 buf; /* offset from chip->buffer */ 209 int bufsize; /* buffer size in bytes */ 210 void __iomem *bufptr; /* mapped pointer */ 211 unsigned long bufptr_addr; /* physical address of the mapped pointer */ 212 213 int dma_size; /* buffer size of the substream in bytes */ 214 int period_size; /* period size in bytes */ 215 int periods; /* # of periods */ 216 int shift; /* bit shifts */ 217 int cur_period; /* current period # */ 206 218 207 219 }; 208 220 209 struct snd_nm256 { 210 211 snd_card_t *card; 212 213 unsigned long cport; /* control port */ 214 struct resource *res_cport; /* its resource */ 215 unsigned long cport_addr; /* physical address */ 216 217 unsigned long buffer; /* buffer */ 218 struct resource *res_buffer; /* its resource */ 219 unsigned long buffer_addr; /* buffer phyiscal address */ 220 221 u32 buffer_start; /* start offset from pci resource 0 */ 222 u32 buffer_end; /* end offset */ 223 u32 buffer_size; /* total buffer size */ 224 225 u32 all_coeff_buf; /* coefficient buffer */ 226 u32 coeff_buf[2]; /* coefficient buffer for each stream */ 227 228 unsigned int coeffs_current: 1; /* coeff. table is loaded? */ 229 unsigned int use_cache: 1; /* use one big coef. table */ 230 unsigned int reset_workaround: 1; /* Workaround for some laptops to avoid freeze */ 231 232 int mixer_base; /* register offset of ac97 mixer */ 233 int mixer_status_offset; /* offset of mixer status reg. */ 234 int mixer_status_mask; /* bit mask to test the mixer status */ 235 236 int irq; 237 int irq_acks; 238 irqreturn_t (*interrupt)(int, void *, struct pt_regs *); 239 int badintrcount; /* counter to check bogus interrupts */ 240 struct semaphore irq_mutex; 241 242 nm256_stream_t streams[2]; 243 244 ac97_t *ac97; 245 246 snd_pcm_t *pcm; 247 248 struct pci_dev *pci; 249 250 spinlock_t reg_lock; 221 struct nm256 { 222 223 struct snd_card *card; 224 225 void __iomem *cport; /* control port */ 226 struct resource *res_cport; /* its resource */ 227 unsigned long cport_addr; /* physical address */ 228 229 void __iomem *buffer; /* buffer */ 230 struct resource *res_buffer; /* its resource */ 231 unsigned long buffer_addr; /* buffer phyiscal address */ 232 233 u32 buffer_start; /* start offset from pci resource 0 */ 234 u32 buffer_end; /* end offset */ 235 u32 buffer_size; /* total buffer size */ 236 237 u32 all_coeff_buf; /* coefficient buffer */ 238 u32 coeff_buf[2]; /* coefficient buffer for each stream */ 239 240 unsigned int coeffs_current: 1; /* coeff. table is loaded? */ 241 unsigned int use_cache: 1; /* use one big coef. table */ 242 unsigned int reset_workaround: 1; /* Workaround for some laptops to avoid freeze */ 243 unsigned int reset_workaround_2: 1; /* Extended workaround for some other laptops to avoid freeze */ 244 unsigned int in_resume: 1; 245 246 int mixer_base; /* register offset of ac97 mixer */ 247 int mixer_status_offset; /* offset of mixer status reg. */ 248 int mixer_status_mask; /* bit mask to test the mixer status */ 249 250 int irq; 251 int irq_acks; 252 irqreturn_t (*interrupt)(int, void *, struct pt_regs *); 253 int badintrcount; /* counter to check bogus interrupts */ 254 struct mutex irq_mutex; 255 256 struct nm256_stream streams[2]; 257 258 struct snd_ac97 *ac97; 259 unsigned short *ac97_regs; /* register caches, only for valid regs */ 260 261 struct snd_pcm *pcm; 262 263 struct pci_dev *pci; 264 265 spinlock_t reg_lock; 251 266 252 267 }; … … 262 277 * PCI ids 263 278 */ 264 265 #ifndef PCI_VENDOR_ID_NEOMAGIC 266 #define PCI_VENDOR_ID_NEOMEGIC 0x10c8 279 static struct pci_device_id snd_nm256_ids[] = { 280 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 281 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 282 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 283 {0,}, 284 }; 285 286 MODULE_DEVICE_TABLE(pci, snd_nm256_ids); 287 288 289 /* 290 * lowlvel stuffs 291 */ 292 293 static inline u8 294 snd_nm256_readb(struct nm256 *chip, int offset) 295 { 296 return readb(chip->cport + offset); 297 } 298 299 static inline u16 300 snd_nm256_readw(struct nm256 *chip, int offset) 301 { 302 return readw(chip->cport + offset); 303 } 304 305 static inline u32 306 snd_nm256_readl(struct nm256 *chip, int offset) 307 { 308 return readl(chip->cport + offset); 309 } 310 311 static inline void 312 snd_nm256_writeb(struct nm256 *chip, int offset, u8 val) 313 { 314 writeb(val, chip->cport + offset); 315 } 316 317 static inline void 318 snd_nm256_writew(struct nm256 *chip, int offset, u16 val) 319 { 320 writew(val, chip->cport + offset); 321 } 322 323 static inline void 324 snd_nm256_writel(struct nm256 *chip, int offset, u32 val) 325 { 326 writel(val, chip->cport + offset); 327 } 328 329 static inline void 330 snd_nm256_write_buffer(struct nm256 *chip, void *src, int offset, int size) 331 { 332 offset -= chip->buffer_start; 333 #ifdef CONFIG_SND_DEBUG 334 if (offset < 0 || offset >= chip->buffer_size) { 335 snd_printk(KERN_ERR "write_buffer invalid offset = %d size = %d\n", 336 offset, size); 337 return; 338 } 267 339 #endif 268 #ifndef PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 269 #define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 270 #endif 271 #ifndef PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 272 #define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 273 #endif 274 275 276 static struct pci_device_id snd_nm256_ids[] = { 277 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 278 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 279 {0,}, 280 }; 281 282 MODULE_DEVICE_TABLE(pci, snd_nm256_ids); 283 284 285 /* 286 * lowlvel stuffs 287 */ 288 289 inline static u8 290 snd_nm256_readb(nm256_t *chip, int offset) 291 { 292 return readb(chip->cport + offset); 293 } 294 295 inline static u16 296 snd_nm256_readw(nm256_t *chip, int offset) 297 { 298 return readw(chip->cport + offset); 299 } 300 301 inline static u32 302 snd_nm256_readl(nm256_t *chip, int offset) 303 { 304 return readl(chip->cport + offset); 305 } 306 307 inline static void 308 snd_nm256_writeb(nm256_t *chip, int offset, u8 val) 309 { 310 writeb(val, chip->cport + offset); 311 } 312 313 inline static void 314 snd_nm256_writew(nm256_t *chip, int offset, u16 val) 315 { 316 writew(val, chip->cport + offset); 317 } 318 319 inline static void 320 snd_nm256_writel(nm256_t *chip, int offset, u32 val) 321 { 322 writel(val, chip->cport + offset); 323 } 324 325 inline static void 326 snd_nm256_write_buffer(nm256_t *chip, void *src, int offset, int size) 327 { 328 offset -= chip->buffer_start; 329 #ifdef SNDRV_CONFIG_DEBUG 330 if (offset < 0 || offset >= chip->buffer_size) { 331 printk("nm256: write_buffer invalid offset = %d size = %d\n", offset, size); 332 return; 333 } 334 #endif 335 memcpy_toio(chip->buffer + offset, src, size); 340 memcpy_toio(chip->buffer + offset, src, size); 336 341 } 337 342 … … 343 348 snd_nm256_get_start_offset(int which) 344 349 { 345 346 347 348 350 u16 offset = 0; 351 while (which-- > 0) 352 offset += coefficient_sizes[which]; 353 return offset; 349 354 } 350 355 351 356 static void 352 snd_nm256_load_one_coefficient( nm256_t*chip, int stream, u32 port, int which)353 { 354 355 356 357 358 359 360 361 362 363 357 snd_nm256_load_one_coefficient(struct nm256 *chip, int stream, u32 port, int which) 358 { 359 u32 coeff_buf = chip->coeff_buf[stream]; 360 u16 offset = snd_nm256_get_start_offset(which); 361 u16 size = coefficient_sizes[which]; 362 363 snd_nm256_write_buffer(chip, coefficients + offset, coeff_buf, size); 364 snd_nm256_writel(chip, port, coeff_buf); 365 /* ??? Record seems to behave differently than playback. */ 366 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 367 size--; 368 snd_nm256_writel(chip, port + 4, coeff_buf + size); 364 369 } 365 370 366 371 static void 367 snd_nm256_load_coefficient(nm256_t *chip, int stream, int number) 368 { 369 /* The enable register for the specified engine. */ 370 u32 poffset = (stream == SNDRV_PCM_STREAM_CAPTURE ? NM_RECORD_ENABLE_REG : NM_PLAYBACK_ENABLE_REG); 371 u32 addr = NM_COEFF_START_OFFSET; 372 373 addr += (stream == SNDRV_PCM_STREAM_CAPTURE ? NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET); 374 375 if (snd_nm256_readb(chip, poffset) & 1) { 376 snd_printd("NM256: Engine was enabled while loading coefficients!\n"); 377 return; 378 } 379 380 /* The recording engine uses coefficient values 8-15. */ 381 number &= 7; 382 if (stream == SNDRV_PCM_STREAM_CAPTURE) 383 number += 8; 384 385 if (! chip->use_cache) { 386 snd_nm256_load_one_coefficient(chip, stream, addr, number); 387 return; 388 } 389 if (! chip->coeffs_current) { 390 snd_nm256_write_buffer(chip, coefficients, chip->all_coeff_buf, 391 NM_TOTAL_COEFF_COUNT * 4); 392 chip->coeffs_current = 1; 393 } else { 394 u32 base = chip->all_coeff_buf; 395 u32 offset = snd_nm256_get_start_offset(number); 396 u32 end_offset = offset + coefficient_sizes[number]; 397 snd_nm256_writel(chip, addr, base + offset); 398 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 399 end_offset--; 400 snd_nm256_writel(chip, addr + 4, base + end_offset); 401 } 372 snd_nm256_load_coefficient(struct nm256 *chip, int stream, int number) 373 { 374 /* The enable register for the specified engine. */ 375 u32 poffset = (stream == SNDRV_PCM_STREAM_CAPTURE ? 376 NM_RECORD_ENABLE_REG : NM_PLAYBACK_ENABLE_REG); 377 u32 addr = NM_COEFF_START_OFFSET; 378 379 addr += (stream == SNDRV_PCM_STREAM_CAPTURE ? 380 NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET); 381 382 if (snd_nm256_readb(chip, poffset) & 1) { 383 snd_printd("NM256: Engine was enabled while loading coefficients!\n"); 384 return; 385 } 386 387 /* The recording engine uses coefficient values 8-15. */ 388 number &= 7; 389 if (stream == SNDRV_PCM_STREAM_CAPTURE) 390 number += 8; 391 392 if (! chip->use_cache) { 393 snd_nm256_load_one_coefficient(chip, stream, addr, number); 394 return; 395 } 396 if (! chip->coeffs_current) { 397 snd_nm256_write_buffer(chip, coefficients, chip->all_coeff_buf, 398 NM_TOTAL_COEFF_COUNT * 4); 399 chip->coeffs_current = 1; 400 } else { 401 u32 base = chip->all_coeff_buf; 402 u32 offset = snd_nm256_get_start_offset(number); 403 u32 end_offset = offset + coefficient_sizes[number]; 404 snd_nm256_writel(chip, addr, base + offset); 405 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 406 end_offset--; 407 snd_nm256_writel(chip, addr + 4, base + end_offset); 408 } 402 409 } 403 410 … … 405 412 /* The actual rates supported by the card. */ 406 413 static unsigned int samplerates[8] = { 407 414 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 408 415 }; 409 #define NUM_SAMPLERATES (sizeof(samplerates) / sizeof(samplerates[0])) 410 static snd_pcm_hw_constraint_list_t constraints_rates = { 411 NUM_SAMPLERATES, 412 samplerates, 413 0, 416 static struct snd_pcm_hw_constraint_list constraints_rates = { 417 .count = ARRAY_SIZE(samplerates), 418 .list = samplerates, 419 .mask = 0, 414 420 }; 415 421 … … 420 426 snd_nm256_fixed_rate(unsigned int rate) 421 427 { 422 423 for (i = 0; i < NUM_SAMPLERATES; i++) {424 425 426 427 428 428 unsigned int i; 429 for (i = 0; i < ARRAY_SIZE(samplerates); i++) { 430 if (rate == samplerates[i]) 431 return i; 432 } 433 snd_BUG(); 434 return 0; 429 435 } 430 436 … … 433 439 */ 434 440 static void 435 snd_nm256_set_format(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *substream) 436 { 437 snd_pcm_runtime_t *runtime = substream->runtime; 438 int rate_index = snd_nm256_fixed_rate(runtime->rate); 439 unsigned char ratebits = (rate_index << 4) & NM_RATE_MASK; 440 441 s->shift = 0; 442 if (snd_pcm_format_width(runtime->format) == 16) { 443 ratebits |= NM_RATE_BITS_16; 444 s->shift++; 445 } 446 if (runtime->channels > 1) { 447 ratebits |= NM_RATE_STEREO; 448 s->shift++; 449 } 450 451 runtime->rate = samplerates[rate_index]; 452 453 switch (substream->stream) { 454 case SNDRV_PCM_STREAM_PLAYBACK: 455 snd_nm256_load_coefficient(chip, 0, rate_index); /* 0 = playback */ 456 snd_nm256_writeb(chip, 457 NM_PLAYBACK_REG_OFFSET + NM_RATE_REG_OFFSET, 458 ratebits); 459 break; 460 case SNDRV_PCM_STREAM_CAPTURE: 461 snd_nm256_load_coefficient(chip, 1, rate_index); /* 1 = record */ 462 snd_nm256_writeb(chip, 463 NM_RECORD_REG_OFFSET + NM_RATE_REG_OFFSET, 464 ratebits); 465 break; 466 } 441 snd_nm256_set_format(struct nm256 *chip, struct nm256_stream *s, 442 struct snd_pcm_substream *substream) 443 { 444 struct snd_pcm_runtime *runtime = substream->runtime; 445 int rate_index = snd_nm256_fixed_rate(runtime->rate); 446 unsigned char ratebits = (rate_index << 4) & NM_RATE_MASK; 447 448 s->shift = 0; 449 if (snd_pcm_format_width(runtime->format) == 16) { 450 ratebits |= NM_RATE_BITS_16; 451 s->shift++; 452 } 453 if (runtime->channels > 1) { 454 ratebits |= NM_RATE_STEREO; 455 s->shift++; 456 } 457 458 runtime->rate = samplerates[rate_index]; 459 460 switch (substream->stream) { 461 case SNDRV_PCM_STREAM_PLAYBACK: 462 snd_nm256_load_coefficient(chip, 0, rate_index); /* 0 = playback */ 463 snd_nm256_writeb(chip, 464 NM_PLAYBACK_REG_OFFSET + NM_RATE_REG_OFFSET, 465 ratebits); 466 break; 467 case SNDRV_PCM_STREAM_CAPTURE: 468 snd_nm256_load_coefficient(chip, 1, rate_index); /* 1 = record */ 469 snd_nm256_writeb(chip, 470 NM_RECORD_REG_OFFSET + NM_RATE_REG_OFFSET, 471 ratebits); 472 break; 473 } 467 474 } 468 475 469 476 /* acquire interrupt */ 470 static int snd_nm256_acquire_irq( nm256_t*chip)471 { 472 down(&chip->irq_mutex);473 474 475 chip->card->driver, (void*)chip)) {476 snd_printk("unable to grab IRQ %d\n", chip->pci->irq);477 up(&chip->irq_mutex);478 479 480 481 482 483 up(&chip->irq_mutex);484 477 static int snd_nm256_acquire_irq(struct nm256 *chip) 478 { 479 mutex_lock(&chip->irq_mutex); 480 if (chip->irq < 0) { 481 if (request_irq(chip->pci->irq, chip->interrupt, SA_INTERRUPT|SA_SHIRQ, 482 chip->card->driver, chip)) { 483 snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq); 484 mutex_unlock(&chip->irq_mutex); 485 return -EBUSY; 486 } 487 chip->irq = chip->pci->irq; 488 } 489 chip->irq_acks++; 490 mutex_unlock(&chip->irq_mutex); 491 return 0; 485 492 } 486 493 487 494 /* release interrupt */ 488 static void snd_nm256_release_irq( nm256_t*chip)489 { 490 down(&chip->irq_mutex);491 492 493 494 free_irq(chip->irq, (void*)chip);495 496 497 up(&chip->irq_mutex);495 static void snd_nm256_release_irq(struct nm256 *chip) 496 { 497 mutex_lock(&chip->irq_mutex); 498 if (chip->irq_acks > 0) 499 chip->irq_acks--; 500 if (chip->irq_acks == 0 && chip->irq >= 0) { 501 free_irq(chip->irq, chip); 502 chip->irq = -1; 503 } 504 mutex_unlock(&chip->irq_mutex); 498 505 } 499 506 … … 503 510 504 511 /* update the watermark (current period) */ 505 static void snd_nm256_pcm_mark( nm256_t *chip, nm256_stream_t*s, int reg)506 { 507 508 509 512 static void snd_nm256_pcm_mark(struct nm256 *chip, struct nm256_stream *s, int reg) 513 { 514 s->cur_period++; 515 s->cur_period %= s->periods; 516 snd_nm256_writel(chip, reg, s->buf + s->cur_period * s->period_size); 510 517 } 511 518 … … 514 521 515 522 static void 516 snd_nm256_playback_start(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *substream) 517 { 518 /* program buffer pointers */ 519 snd_nm256_writel(chip, NM_PBUFFER_START, s->buf); 520 snd_nm256_writel(chip, NM_PBUFFER_END, s->buf + s->dma_size - (1 << s->shift)); 521 snd_nm256_writel(chip, NM_PBUFFER_CURRP, s->buf); 522 snd_nm256_playback_mark(chip, s); 523 524 /* Enable playback engine and interrupts. */ 525 snd_nm256_writeb(chip, NM_PLAYBACK_ENABLE_REG, 526 NM_PLAYBACK_ENABLE_FLAG | NM_PLAYBACK_FREERUN); 527 /* Enable both channels. */ 528 snd_nm256_writew(chip, NM_AUDIO_MUTE_REG, 0x0); 523 snd_nm256_playback_start(struct nm256 *chip, struct nm256_stream *s, 524 struct snd_pcm_substream *substream) 525 { 526 /* program buffer pointers */ 527 snd_nm256_writel(chip, NM_PBUFFER_START, s->buf); 528 snd_nm256_writel(chip, NM_PBUFFER_END, s->buf + s->dma_size - (1 << s->shift)); 529 snd_nm256_writel(chip, NM_PBUFFER_CURRP, s->buf); 530 snd_nm256_playback_mark(chip, s); 531 532 /* Enable playback engine and interrupts. */ 533 snd_nm256_writeb(chip, NM_PLAYBACK_ENABLE_REG, 534 NM_PLAYBACK_ENABLE_FLAG | NM_PLAYBACK_FREERUN); 535 /* Enable both channels. */ 536 snd_nm256_writew(chip, NM_AUDIO_MUTE_REG, 0x0); 529 537 } 530 538 531 539 static void 532 snd_nm256_capture_start(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *substream) 533 { 534 /* program buffer pointers */ 535 snd_nm256_writel(chip, NM_RBUFFER_START, s->buf); 536 snd_nm256_writel(chip, NM_RBUFFER_END, s->buf + s->dma_size); 537 snd_nm256_writel(chip, NM_RBUFFER_CURRP, s->buf); 538 snd_nm256_capture_mark(chip, s); 539 540 /* Enable playback engine and interrupts. */ 541 snd_nm256_writeb(chip, NM_RECORD_ENABLE_REG, 542 NM_RECORD_ENABLE_FLAG | NM_RECORD_FREERUN); 540 snd_nm256_capture_start(struct nm256 *chip, struct nm256_stream *s, 541 struct snd_pcm_substream *substream) 542 { 543 /* program buffer pointers */ 544 snd_nm256_writel(chip, NM_RBUFFER_START, s->buf); 545 snd_nm256_writel(chip, NM_RBUFFER_END, s->buf + s->dma_size); 546 snd_nm256_writel(chip, NM_RBUFFER_CURRP, s->buf); 547 snd_nm256_capture_mark(chip, s); 548 549 /* Enable playback engine and interrupts. */ 550 snd_nm256_writeb(chip, NM_RECORD_ENABLE_REG, 551 NM_RECORD_ENABLE_FLAG | NM_RECORD_FREERUN); 543 552 } 544 553 545 554 /* Stop the play engine. */ 546 555 static void 547 snd_nm256_playback_stop( nm256_t*chip)548 { 549 550 551 552 553 556 snd_nm256_playback_stop(struct nm256 *chip) 557 { 558 /* Shut off sound from both channels. */ 559 snd_nm256_writew(chip, NM_AUDIO_MUTE_REG, 560 NM_AUDIO_MUTE_LEFT | NM_AUDIO_MUTE_RIGHT); 561 /* Disable play engine. */ 562 snd_nm256_writeb(chip, NM_PLAYBACK_ENABLE_REG, 0); 554 563 } 555 564 556 565 static void 557 snd_nm256_capture_stop( nm256_t*chip)558 { 559 560 566 snd_nm256_capture_stop(struct nm256 *chip) 567 { 568 /* Disable recording engine. */ 569 snd_nm256_writeb(chip, NM_RECORD_ENABLE_REG, 0); 561 570 } 562 571 563 572 static int 564 snd_nm256_playback_trigger(s nd_pcm_substream_t*substream, int cmd)565 { 566 nm256_t*chip = snd_pcm_substream_chip(substream);567 nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data;568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 573 snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd) 574 { 575 struct nm256 *chip = snd_pcm_substream_chip(substream); 576 struct nm256_stream *s = substream->runtime->private_data; 577 int err = 0; 578 579 snd_assert(s != NULL, return -ENXIO); 580 581 spin_lock(&chip->reg_lock); 582 switch (cmd) { 583 case SNDRV_PCM_TRIGGER_RESUME: 584 s->suspended = 0; 585 /* fallthru */ 586 case SNDRV_PCM_TRIGGER_START: 587 if (! s->running) { 588 snd_nm256_playback_start(chip, s, substream); 589 s->running = 1; 590 } 591 break; 592 case SNDRV_PCM_TRIGGER_SUSPEND: 593 s->suspended = 1; 594 /* fallthru */ 595 case SNDRV_PCM_TRIGGER_STOP: 596 if (s->running) { 597 snd_nm256_playback_stop(chip); 598 s->running = 0; 599 } 600 break; 601 default: 602 err = -EINVAL; 603 break; 604 } 605 spin_unlock(&chip->reg_lock); 606 return err; 598 607 } 599 608 600 609 static int 601 snd_nm256_capture_trigger(s nd_pcm_substream_t*substream, int cmd)602 { 603 nm256_t*chip = snd_pcm_substream_chip(substream);604 nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data;605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 610 snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd) 611 { 612 struct nm256 *chip = snd_pcm_substream_chip(substream); 613 struct nm256_stream *s = substream->runtime->private_data; 614 int err = 0; 615 616 snd_assert(s != NULL, return -ENXIO); 617 618 spin_lock(&chip->reg_lock); 619 switch (cmd) { 620 case SNDRV_PCM_TRIGGER_START: 621 case SNDRV_PCM_TRIGGER_RESUME: 622 if (! s->running) { 623 snd_nm256_capture_start(chip, s, substream); 624 s->running = 1; 625 } 626 break; 627 case SNDRV_PCM_TRIGGER_STOP: 628 case SNDRV_PCM_TRIGGER_SUSPEND: 629 if (s->running) { 630 snd_nm256_capture_stop(chip); 631 s->running = 0; 632 } 633 break; 634 default: 635 err = -EINVAL; 636 break; 637 } 638 spin_unlock(&chip->reg_lock); 639 return err; 631 640 } 632 641 … … 635 644 * prepare playback/capture channel 636 645 */ 637 static int snd_nm256_pcm_prepare(s nd_pcm_substream_t*substream)638 { 639 nm256_t*chip = snd_pcm_substream_chip(substream);640 snd_pcm_runtime_t*runtime = substream->runtime;641 nm256_stream_t *s = (nm256_stream_t*)runtime->private_data;642 643 644 645 646 647 648 649 650 651 652 653 654 646 static int snd_nm256_pcm_prepare(struct snd_pcm_substream *substream) 647 { 648 struct nm256 *chip = snd_pcm_substream_chip(substream); 649 struct snd_pcm_runtime *runtime = substream->runtime; 650 struct nm256_stream *s = runtime->private_data; 651 652 snd_assert(s, return -ENXIO); 653 s->dma_size = frames_to_bytes(runtime, substream->runtime->buffer_size); 654 s->period_size = frames_to_bytes(runtime, substream->runtime->period_size); 655 s->periods = substream->runtime->periods; 656 s->cur_period = 0; 657 658 spin_lock_irq(&chip->reg_lock); 659 s->running = 0; 660 snd_nm256_set_format(chip, s, substream); 661 spin_unlock_irq(&chip->reg_lock); 662 663 return 0; 655 664 } 656 665 … … 660 669 */ 661 670 static snd_pcm_uframes_t 662 snd_nm256_playback_pointer(s nd_pcm_substream_t *substream)663 { 664 nm256_t*chip = snd_pcm_substream_chip(substream);665 nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data;666 667 668 669 670 671 671 snd_nm256_playback_pointer(struct snd_pcm_substream *substream) 672 { 673 struct nm256 *chip = snd_pcm_substream_chip(substream); 674 struct nm256_stream *s = substream->runtime->private_data; 675 unsigned long curp; 676 677 snd_assert(s, return 0); 678 curp = snd_nm256_readl(chip, NM_PBUFFER_CURRP) - (unsigned long)s->buf; 679 curp %= s->dma_size; 680 return bytes_to_frames(substream->runtime, curp); 672 681 } 673 682 674 683 static snd_pcm_uframes_t 675 snd_nm256_capture_pointer(snd_pcm_substream_t * substream) 676 { 677 nm256_t *chip = snd_pcm_substream_chip(substream); 678 nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data; 679 unsigned long curp; 680 681 snd_assert(s != NULL, return 0); 682 curp = snd_nm256_readl(chip, NM_RBUFFER_CURRP) - (unsigned long)s->buf; 683 curp %= s->dma_size; 684 return bytes_to_frames(substream->runtime, curp); 685 } 686 684 snd_nm256_capture_pointer(struct snd_pcm_substream *substream) 685 { 686 struct nm256 *chip = snd_pcm_substream_chip(substream); 687 struct nm256_stream *s = substream->runtime->private_data; 688 unsigned long curp; 689 690 snd_assert(s != NULL, return 0); 691 curp = snd_nm256_readl(chip, NM_RBUFFER_CURRP) - (unsigned long)s->buf; 692 curp %= s->dma_size; 693 return bytes_to_frames(substream->runtime, curp); 694 } 695 696 /* Remapped I/O space can be accessible as pointer on i386 */ 697 /* This might be changed in the future */ 687 698 #ifndef __i386__ 688 /* FIXME: I/O space is not accessible via pointers on all architectures */689 690 699 /* 691 700 * silence / copy for playback 692 701 */ 693 702 static int 694 snd_nm256_playback_silence(s nd_pcm_substream_t*substream,695 696 697 698 { 699 snd_pcm_runtime_t*runtime = substream->runtime;700 nm256_stream_t *s = (nm256_stream_t*)runtime->private_data;701 702 703 704 703 snd_nm256_playback_silence(struct snd_pcm_substream *substream, 704 int channel, /* not used (interleaved data) */ 705 snd_pcm_uframes_t pos, 706 snd_pcm_uframes_t count) 707 { 708 struct snd_pcm_runtime *runtime = substream->runtime; 709 struct nm256_stream *s = runtime->private_data; 710 count = frames_to_bytes(runtime, count); 711 pos = frames_to_bytes(runtime, pos); 712 memset_io(s->bufptr + pos, 0, count); 713 return 0; 705 714 } 706 715 707 716 static int 708 snd_nm256_playback_copy(s nd_pcm_substream_t*substream,709 710 711 void*src,712 713 { 714 snd_pcm_runtime_t*runtime = substream->runtime;715 nm256_stream_t *s = (nm256_stream_t*)runtime->private_data;716 717 718 if (copy_from_user_toio((volatile void *)(s->bufptr + pos), src, count))719 720 717 snd_nm256_playback_copy(struct snd_pcm_substream *substream, 718 int channel, /* not used (interleaved data) */ 719 snd_pcm_uframes_t pos, 720 void __user *src, 721 snd_pcm_uframes_t count) 722 { 723 struct snd_pcm_runtime *runtime = substream->runtime; 724 struct nm256_stream *s = runtime->private_data; 725 count = frames_to_bytes(runtime, count); 726 pos = frames_to_bytes(runtime, pos); 727 if (copy_from_user_toio(s->bufptr + pos, src, count)) 728 return -EFAULT; 729 return 0; 721 730 } 722 731 … … 725 734 */ 726 735 static int 727 snd_nm256_capture_copy(s nd_pcm_substream_t*substream,728 729 730 void*dst,731 732 { 733 snd_pcm_runtime_t*runtime = substream->runtime;734 nm256_stream_t *s = (nm256_stream_t*)runtime->private_data;735 736 737 if (copy_to_user_fromio(dst, (volatile void *)(s->bufptr + pos), count))738 739 736 snd_nm256_capture_copy(struct snd_pcm_substream *substream, 737 int channel, /* not used (interleaved data) */ 738 snd_pcm_uframes_t pos, 739 void __user *dst, 740 snd_pcm_uframes_t count) 741 { 742 struct snd_pcm_runtime *runtime = substream->runtime; 743 struct nm256_stream *s = runtime->private_data; 744 count = frames_to_bytes(runtime, count); 745 pos = frames_to_bytes(runtime, pos); 746 if (copy_to_user_fromio(dst, s->bufptr + pos, count)) 747 return -EFAULT; 748 return 0; 740 749 } 741 750 … … 749 758 /* spinlock held! */ 750 759 static void 751 snd_nm256_playback_update( nm256_t*chip)752 { 753 nm256_stream_t*s;754 755 756 757 758 759 760 761 760 snd_nm256_playback_update(struct nm256 *chip) 761 { 762 struct nm256_stream *s; 763 764 s = &chip->streams[SNDRV_PCM_STREAM_PLAYBACK]; 765 if (s->running && s->substream) { 766 spin_unlock(&chip->reg_lock); 767 snd_pcm_period_elapsed(s->substream); 768 spin_lock(&chip->reg_lock); 769 snd_nm256_playback_mark(chip, s); 770 } 762 771 } 763 772 764 773 /* spinlock held! */ 765 774 static void 766 snd_nm256_capture_update( nm256_t*chip)767 { 768 nm256_stream_t*s;769 770 771 772 773 774 775 776 775 snd_nm256_capture_update(struct nm256 *chip) 776 { 777 struct nm256_stream *s; 778 779 s = &chip->streams[SNDRV_PCM_STREAM_CAPTURE]; 780 if (s->running && s->substream) { 781 spin_unlock(&chip->reg_lock); 782 snd_pcm_period_elapsed(s->substream); 783 spin_lock(&chip->reg_lock); 784 snd_nm256_capture_mark(chip, s); 785 } 777 786 } 778 787 … … 780 789 * hardware info 781 790 */ 782 783 static snd_pcm_hardware_t snd_nm256_playback = 784 { 785 /* info: */ 786 #ifdef __i386__ 787 SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID| 791 static struct snd_pcm_hardware snd_nm256_playback = 792 { 793 .info = SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | 794 SNDRV_PCM_INFO_INTERLEAVED | 795 /*SNDRV_PCM_INFO_PAUSE |*/ 796 SNDRV_PCM_INFO_RESUME, 797 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 798 .rates = SNDRV_PCM_RATE_KNOT/*24k*/ | SNDRV_PCM_RATE_8000_48000, 799 .rate_min = 8000, 800 .rate_max = 48000, 801 .channels_min = 1, 802 .channels_max = 2, 803 .periods_min = 2, 804 .periods_max = 1024, 805 .buffer_bytes_max = 128 * 1024, 806 .period_bytes_min = 256, 807 .period_bytes_max = 128 * 1024, 808 }; 809 810 static struct snd_pcm_hardware snd_nm256_capture = 811 { 812 .info = SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | 813 SNDRV_PCM_INFO_INTERLEAVED | 814 /*SNDRV_PCM_INFO_PAUSE |*/ 815 SNDRV_PCM_INFO_RESUME, 816 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 817 .rates = SNDRV_PCM_RATE_KNOT/*24k*/ | SNDRV_PCM_RATE_8000_48000, 818 .rate_min = 8000, 819 .rate_max = 48000, 820 .channels_min = 1, 821 .channels_max = 2, 822 .periods_min = 2, 823 .periods_max = 1024, 824 .buffer_bytes_max = 128 * 1024, 825 .period_bytes_min = 256, 826 .period_bytes_max = 128 * 1024, 827 }; 828 829 830 /* set dma transfer size */ 831 static int snd_nm256_pcm_hw_params(struct snd_pcm_substream *substream, 832 struct snd_pcm_hw_params *hw_params) 833 { 834 /* area and addr are already set and unchanged */ 835 substream->runtime->dma_bytes = params_buffer_bytes(hw_params); 836 return 0; 837 } 838 839 /* 840 * open 841 */ 842 static void snd_nm256_setup_stream(struct nm256 *chip, struct nm256_stream *s, 843 struct snd_pcm_substream *substream, 844 struct snd_pcm_hardware *hw_ptr) 845 { 846 struct snd_pcm_runtime *runtime = substream->runtime; 847 848 s->running = 0; 849 runtime->hw = *hw_ptr; 850 runtime->hw.buffer_bytes_max = s->bufsize; 851 runtime->hw.period_bytes_max = s->bufsize / 2; 852 runtime->dma_area = (void __force *) s->bufptr; 853 runtime->dma_addr = s->bufptr_addr; 854 runtime->dma_bytes = s->bufsize; 855 runtime->private_data = s; 856 s->substream = substream; 857 858 snd_pcm_set_sync(substream); 859 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 860 &constraints_rates); 861 } 862 863 static int 864 snd_nm256_playback_open(struct snd_pcm_substream *substream) 865 { 866 struct nm256 *chip = snd_pcm_substream_chip(substream); 867 868 if (snd_nm256_acquire_irq(chip) < 0) 869 return -EBUSY; 870 snd_nm256_setup_stream(chip, &chip->streams[SNDRV_PCM_STREAM_PLAYBACK], 871 substream, &snd_nm256_playback); 872 return 0; 873 } 874 875 static int 876 snd_nm256_capture_open(struct snd_pcm_substream *substream) 877 { 878 struct nm256 *chip = snd_pcm_substream_chip(substream); 879 880 if (snd_nm256_acquire_irq(chip) < 0) 881 return -EBUSY; 882 snd_nm256_setup_stream(chip, &chip->streams[SNDRV_PCM_STREAM_CAPTURE], 883 substream, &snd_nm256_capture); 884 return 0; 885 } 886 887 /* 888 * close - we don't have to do special.. 889 */ 890 static int 891 snd_nm256_playback_close(struct snd_pcm_substream *substream) 892 { 893 struct nm256 *chip = snd_pcm_substream_chip(substream); 894 895 snd_nm256_release_irq(chip); 896 return 0; 897 } 898 899 900 static int 901 snd_nm256_capture_close(struct snd_pcm_substream *substream) 902 { 903 struct nm256 *chip = snd_pcm_substream_chip(substream); 904 905 snd_nm256_release_irq(chip); 906 return 0; 907 } 908 909 /* 910 * create a pcm instance 911 */ 912 static struct snd_pcm_ops snd_nm256_playback_ops = { 913 .open = snd_nm256_playback_open, 914 .close = snd_nm256_playback_close, 915 .ioctl = snd_pcm_lib_ioctl, 916 .hw_params = snd_nm256_pcm_hw_params, 917 .prepare = snd_nm256_pcm_prepare, 918 .trigger = snd_nm256_playback_trigger, 919 .pointer = snd_nm256_playback_pointer, 920 #ifndef __i386__ 921 .copy = snd_nm256_playback_copy, 922 .silence = snd_nm256_playback_silence, 788 923 #endif 789 SNDRV_PCM_INFO_INTERLEAVED | 790 /*SNDRV_PCM_INFO_PAUSE |*/ 791 SNDRV_PCM_INFO_RESUME, 792 /* formats: */ SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 793 /* rates: */ SNDRV_PCM_RATE_KNOT/*24k*/ | SNDRV_PCM_RATE_8000_48000, 794 /* rate_min: */ 8000, 795 /* rate_max: */ 48000, 796 /* channels_min: */ 1, 797 /* channels_max: */ 2, 798 /* buffer_bytes_max: */ 128 * 1024, 799 /* period_bytes_min: */ 256, 800 /* period_bytes_max: */ 128 * 1024, 801 /* .periods_min = */ 2, 802 /* .periods_max = */ 1024, 803 0 924 .mmap = snd_pcm_lib_mmap_iomem, 804 925 }; 805 926 806 static snd_pcm_hardware_t snd_nm256_capture = 807 { 808 /* info: */ 809 #ifdef __i386__ 810 SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID| 927 static struct snd_pcm_ops snd_nm256_capture_ops = { 928 .open = snd_nm256_capture_open, 929 .close = snd_nm256_capture_close, 930 .ioctl = snd_pcm_lib_ioctl, 931 .hw_params = snd_nm256_pcm_hw_params, 932 .prepare = snd_nm256_pcm_prepare, 933 .trigger = snd_nm256_capture_trigger, 934 .pointer = snd_nm256_capture_pointer, 935 #ifndef __i386__ 936 .copy = snd_nm256_capture_copy, 811 937 #endif 812 SNDRV_PCM_INFO_INTERLEAVED | 813 /*SNDRV_PCM_INFO_PAUSE |*/ 814 SNDRV_PCM_INFO_RESUME, 815 /* formats: */ SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 816 /* rates: */ SNDRV_PCM_RATE_KNOT/*24k*/ | SNDRV_PCM_RATE_8000_48000, 817 /* rate_min: */ 8000, 818 /* rate_max: */ 48000, 819 /* channels_min: */ 1, 820 /* channels_max: */ 2, 821 /* buffer_bytes_max: */ 128 * 1024, 822 /* period_bytes_min: */ 256, 823 /* period_bytes_max: */ 128 * 1024, 824 /* .periods_min = */ 2, 825 /* .periods_max = */ 1024, 826 0 938 .mmap = snd_pcm_lib_mmap_iomem, 827 939 }; 828 940 829 830 /* set dma transfer size */831 static int snd_nm256_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *hw_params)832 {833 /* area and addr are already set and unchanged */834 substream->runtime->dma_bytes = params_buffer_bytes(hw_params);835 return 0;836 }837 838 /*839 * open840 */841 static void snd_nm256_setup_stream(nm256_t *chip, nm256_stream_t *s,842 snd_pcm_substream_t *substream,843 snd_pcm_hardware_t *hw_ptr)844 {845 snd_pcm_runtime_t *runtime = substream->runtime;846 847 s->running = 0;848 runtime->hw = *hw_ptr;849 runtime->hw.buffer_bytes_max = s->bufsize;850 runtime->hw.period_bytes_max = s->bufsize / 2;851 runtime->dma_area = (void *)s->bufptr;852 runtime->dma_addr = s->bufptr_addr;853 runtime->dma_bytes = s->bufsize;854 runtime->private_data = s;855 s->substream = substream;856 857 snd_pcm_set_sync(substream);858 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,859 &constraints_rates);860 }861 862 static int863 snd_nm256_playback_open(snd_pcm_substream_t *substream)864 {865 nm256_t *chip = snd_pcm_substream_chip(substream);866 867 if (snd_nm256_acquire_irq(chip) < 0)868 return -EBUSY;869 snd_nm256_setup_stream(chip, &chip->streams[SNDRV_PCM_STREAM_PLAYBACK],870 substream, &snd_nm256_playback);871 return 0;872 }873 874 static int875 snd_nm256_capture_open(snd_pcm_substream_t *substream)876 {877 nm256_t *chip = snd_pcm_substream_chip(substream);878 879 if (snd_nm256_acquire_irq(chip) < 0)880 return -EBUSY;881 snd_nm256_setup_stream(chip, &chip->streams[SNDRV_PCM_STREAM_CAPTURE],882 substream, &snd_nm256_capture);883 return 0;884 }885 886 /*887 * close - we don't have to do special..888 */889 static int890 snd_nm256_playback_close(snd_pcm_substream_t *substream)891 {892 nm256_t *chip = snd_pcm_substream_chip(substream);893 894 snd_nm256_release_irq(chip);895 return 0;896 }897 898 899 static int900 snd_nm256_capture_close(snd_pcm_substream_t *substream)901 {902 nm256_t *chip = snd_pcm_substream_chip(substream);903 904 snd_nm256_release_irq(chip);905 return 0;906 }907 908 /*909 * create a pcm instance910 */911 912 static snd_pcm_ops_t snd_nm256_playback_ops = {913 /* .open = */ snd_nm256_playback_open,914 /* .close = */ snd_nm256_playback_close,915 /* .ioctl = */ snd_pcm_lib_ioctl,916 /* .hw_params = */ snd_nm256_pcm_hw_params,917 NULL,918 /* .prepare = */ snd_nm256_pcm_prepare,919 /* .trigger = */ snd_nm256_playback_trigger,920 /* .pointer = */ snd_nm256_playback_pointer,921 #ifndef __i386__922 /* .copy = */ snd_nm256_playback_copy,923 /* .silence = */ snd_nm256_playback_silence,924 NULL,NULL925 #else926 NULL,NULL,NULL,NULL927 #endif928 };929 930 static snd_pcm_ops_t snd_nm256_capture_ops = {931 /* .open = */ snd_nm256_capture_open,932 /* .close = */ snd_nm256_capture_close,933 /* .ioctl = */ snd_pcm_lib_ioctl,934 /* .hw_params = */ snd_nm256_pcm_hw_params,935 NULL,936 /* .prepare = */ snd_nm256_pcm_prepare,937 /* .trigger = */ snd_nm256_capture_trigger,938 /* .pointer = */ snd_nm256_capture_pointer,939 #ifndef __i386__940 /* .copy = */ snd_nm256_capture_copy,941 NULL,NULL,NULL942 #else943 NULL,NULL,NULL,NULL944 #endif945 };946 947 941 static int __devinit 948 snd_nm256_pcm( nm256_t*chip, int device)949 { 950 snd_pcm_t*pcm;951 952 953 954 nm256_stream_t*s = &chip->streams[i];955 s->bufptr = chip->buffer + s->buf - chip->buffer_start;956 s->bufptr_addr = chip->buffer_addr + s->buf - chip->buffer_start;957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 } 973 974 975 /* 976 * Initialize the hardware. 942 snd_nm256_pcm(struct nm256 *chip, int device) 943 { 944 struct snd_pcm *pcm; 945 int i, err; 946 947 for (i = 0; i < 2; i++) { 948 struct nm256_stream *s = &chip->streams[i]; 949 s->bufptr = chip->buffer + (s->buf - chip->buffer_start); 950 s->bufptr_addr = chip->buffer_addr + (s->buf - chip->buffer_start); 951 } 952 953 err = snd_pcm_new(chip->card, chip->card->driver, device, 954 1, 1, &pcm); 955 if (err < 0) 956 return err; 957 958 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_nm256_playback_ops); 959 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_nm256_capture_ops); 960 961 pcm->private_data = chip; 962 pcm->info_flags = 0; 963 chip->pcm = pcm; 964 965 return 0; 966 } 967 968 969 /* 970 * Initialize the hardware. 977 971 */ 978 972 static void 979 snd_nm256_init_chip(nm256_t *chip) 980 { 981 /* Reset everything. */ 982 snd_nm256_writeb(chip, 0x0, 0x11); 983 snd_nm256_writew(chip, 0x214, 0); 984 /* stop sounds.. */ 985 //snd_nm256_playback_stop(chip); 986 //snd_nm256_capture_stop(chip); 987 } 973 snd_nm256_init_chip(struct nm256 *chip) 974 { 975 /* Reset everything. */ 976 snd_nm256_writeb(chip, 0x0, 0x11); 977 snd_nm256_writew(chip, 0x214, 0); 978 /* stop sounds.. */ 979 //snd_nm256_playback_stop(chip); 980 //snd_nm256_capture_stop(chip); 981 } 982 988 983 989 984 static irqreturn_t 990 snd_nm256_intr_check( nm256_t*chip)991 { 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 } 1014 1015 /* 1016 * Handle a potential interrupt for the device referred to by DEV_ID. 985 snd_nm256_intr_check(struct nm256 *chip) 986 { 987 if (chip->badintrcount++ > 1000) { 988 /* 989 * I'm not sure if the best thing is to stop the card from 990 * playing or just release the interrupt (after all, we're in 991 * a bad situation, so doing fancy stuff may not be such a good 992 * idea). 993 * 994 * I worry about the card engine continuing to play noise 995 * over and over, however--that could become a very 996 * obnoxious problem. And we know that when this usually 997 * happens things are fairly safe, it just means the user's 998 * inserted a PCMCIA card and someone's spamming us with IRQ 9s. 999 */ 1000 if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running) 1001 snd_nm256_playback_stop(chip); 1002 if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running) 1003 snd_nm256_capture_stop(chip); 1004 chip->badintrcount = 0; 1005 return IRQ_HANDLED; 1006 } 1007 return IRQ_NONE; 1008 } 1009 1010 /* 1011 * Handle a potential interrupt for the device referred to by DEV_ID. 1017 1012 * 1018 1013 * I don't like the cut-n-paste job here either between the two routines, … … 1025 1020 snd_nm256_interrupt(int irq, void *dev_id, struct pt_regs *dummy) 1026 1021 { 1027 nm256_t *chip = dev_id; 1028 u16 status; 1029 u8 cbyte; 1030 #ifdef TARGET_OS2 1031 int fOurIrq = FALSE; 1032 #endif 1033 1034 status = snd_nm256_readw(chip, NM_INT_REG); 1035 1036 /* Not ours. */ 1037 if (status == 0) { 1038 snd_nm256_intr_check(chip); 1039 return IRQ_NONE; 1040 } 1041 #ifdef TARGET_OS2 1042 fOurIrq = TRUE; 1043 #endif 1044 1045 chip->badintrcount = 0; 1046 1047 /* Rather boring; check for individual interrupts and process them. */ 1048 1049 spin_lock(&chip->reg_lock); 1050 if (status & NM_PLAYBACK_INT) { 1051 status &= ~NM_PLAYBACK_INT; 1052 NM_ACK_INT(chip, NM_PLAYBACK_INT); 1053 snd_nm256_playback_update(chip); 1054 } 1055 1056 if (status & NM_RECORD_INT) { 1057 status &= ~NM_RECORD_INT; 1058 NM_ACK_INT(chip, NM_RECORD_INT); 1059 snd_nm256_capture_update(chip); 1060 } 1061 1062 if (status & NM_MISC_INT_1) { 1063 status &= ~NM_MISC_INT_1; 1064 NM_ACK_INT(chip, NM_MISC_INT_1); 1065 snd_printd("NM256: Got misc interrupt #1\n"); 1066 snd_nm256_writew(chip, NM_INT_REG, 0x8000); 1067 cbyte = snd_nm256_readb(chip, 0x400); 1068 snd_nm256_writeb(chip, 0x400, cbyte | 2); 1069 } 1070 1071 if (status & NM_MISC_INT_2) { 1072 status &= ~NM_MISC_INT_2; 1073 NM_ACK_INT(chip, NM_MISC_INT_2); 1074 snd_printd("NM256: Got misc interrupt #2\n"); 1075 cbyte = snd_nm256_readb(chip, 0x400); 1076 snd_nm256_writeb(chip, 0x400, cbyte & ~2); 1077 } 1078 1079 /* Unknown interrupt. */ 1080 if (status) { 1081 snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", 1082 status); 1083 /* Pray. */ 1084 NM_ACK_INT(chip, status); 1085 } 1086 1087 spin_unlock(&chip->reg_lock); 1088 #ifdef TARGET_OS2 1089 if (fOurIrq) { 1090 eoi_irq(irq); 1091 } 1092 #endif //TARGET_OS2 1093 return IRQ_HANDLED; 1022 struct nm256 *chip = dev_id; 1023 u16 status; 1024 u8 cbyte; 1025 1026 status = snd_nm256_readw(chip, NM_INT_REG); 1027 1028 /* Not ours. */ 1029 if (status == 0) 1030 return snd_nm256_intr_check(chip); 1031 1032 chip->badintrcount = 0; 1033 1034 /* Rather boring; check for individual interrupts and process them. */ 1035 1036 spin_lock(&chip->reg_lock); 1037 if (status & NM_PLAYBACK_INT) { 1038 status &= ~NM_PLAYBACK_INT; 1039 NM_ACK_INT(chip, NM_PLAYBACK_INT); 1040 snd_nm256_playback_update(chip); 1041 } 1042 1043 if (status & NM_RECORD_INT) { 1044 status &= ~NM_RECORD_INT; 1045 NM_ACK_INT(chip, NM_RECORD_INT); 1046 snd_nm256_capture_update(chip); 1047 } 1048 1049 if (status & NM_MISC_INT_1) { 1050 status &= ~NM_MISC_INT_1; 1051 NM_ACK_INT(chip, NM_MISC_INT_1); 1052 snd_printd("NM256: Got misc interrupt #1\n"); 1053 snd_nm256_writew(chip, NM_INT_REG, 0x8000); 1054 cbyte = snd_nm256_readb(chip, 0x400); 1055 snd_nm256_writeb(chip, 0x400, cbyte | 2); 1056 } 1057 1058 if (status & NM_MISC_INT_2) { 1059 status &= ~NM_MISC_INT_2; 1060 NM_ACK_INT(chip, NM_MISC_INT_2); 1061 snd_printd("NM256: Got misc interrupt #2\n"); 1062 cbyte = snd_nm256_readb(chip, 0x400); 1063 snd_nm256_writeb(chip, 0x400, cbyte & ~2); 1064 } 1065 1066 /* Unknown interrupt. */ 1067 if (status) { 1068 snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", 1069 status); 1070 /* Pray. */ 1071 NM_ACK_INT(chip, status); 1072 } 1073 1074 spin_unlock(&chip->reg_lock); 1075 return IRQ_HANDLED; 1094 1076 } 1095 1077 … … 1103 1085 snd_nm256_interrupt_zx(int irq, void *dev_id, struct pt_regs *dummy) 1104 1086 { 1105 nm256_t *chip = dev_id; 1106 u32 status; 1107 u8 cbyte; 1108 #ifdef TARGET_OS2 1109 int fOurIrq = FALSE; 1110 #endif 1111 1112 status = snd_nm256_readl(chip, NM_INT_REG); 1113 1114 /* Not ours. */ 1115 if (status == 0) 1116 { 1117 snd_nm256_intr_check(chip); 1118 return IRQ_NONE; 1119 } 1120 #ifdef TARGET_OS2 1121 fOurIrq = TRUE; 1122 #endif 1123 1124 chip->badintrcount = 0; 1125 1126 /* Rather boring; check for individual interrupts and process them. */ 1127 1128 spin_lock(&chip->reg_lock); 1129 if (status & NM2_PLAYBACK_INT) { 1130 status &= ~NM2_PLAYBACK_INT; 1131 NM2_ACK_INT(chip, NM2_PLAYBACK_INT); 1132 snd_nm256_playback_update(chip); 1133 } 1134 1135 if (status & NM2_RECORD_INT) { 1136 status &= ~NM2_RECORD_INT; 1137 NM2_ACK_INT(chip, NM2_RECORD_INT); 1138 snd_nm256_capture_update(chip); 1139 } 1140 1141 if (status & NM2_MISC_INT_1) { 1142 status &= ~NM2_MISC_INT_1; 1143 NM2_ACK_INT(chip, NM2_MISC_INT_1); 1144 snd_printd("NM256: Got misc interrupt #1\n"); 1145 cbyte = snd_nm256_readb(chip, 0x400); 1146 snd_nm256_writeb(chip, 0x400, cbyte | 2); 1147 } 1148 1149 if (status & NM2_MISC_INT_2) { 1150 status &= ~NM2_MISC_INT_2; 1151 NM2_ACK_INT(chip, NM2_MISC_INT_2); 1152 snd_printd("NM256: Got misc interrupt #2\n"); 1153 cbyte = snd_nm256_readb(chip, 0x400); 1154 snd_nm256_writeb(chip, 0x400, cbyte & ~2); 1155 } 1156 1157 /* Unknown interrupt. */ 1158 if (status) { 1159 snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", 1160 status); 1161 /* Pray. */ 1162 NM2_ACK_INT(chip, status); 1163 } 1164 1165 spin_unlock(&chip->reg_lock); 1166 #ifdef TARGET_OS2 1167 if (fOurIrq) { 1168 eoi_irq(irq); 1169 } 1170 #endif //TARGET_OS2 1171 return IRQ_HANDLED; 1087 struct nm256 *chip = dev_id; 1088 u32 status; 1089 u8 cbyte; 1090 1091 status = snd_nm256_readl(chip, NM_INT_REG); 1092 1093 /* Not ours. */ 1094 if (status == 0) 1095 return snd_nm256_intr_check(chip); 1096 1097 chip->badintrcount = 0; 1098 1099 /* Rather boring; check for individual interrupts and process them. */ 1100 1101 spin_lock(&chip->reg_lock); 1102 if (status & NM2_PLAYBACK_INT) { 1103 status &= ~NM2_PLAYBACK_INT; 1104 NM2_ACK_INT(chip, NM2_PLAYBACK_INT); 1105 snd_nm256_playback_update(chip); 1106 } 1107 1108 if (status & NM2_RECORD_INT) { 1109 status &= ~NM2_RECORD_INT; 1110 NM2_ACK_INT(chip, NM2_RECORD_INT); 1111 snd_nm256_capture_update(chip); 1112 } 1113 1114 if (status & NM2_MISC_INT_1) { 1115 status &= ~NM2_MISC_INT_1; 1116 NM2_ACK_INT(chip, NM2_MISC_INT_1); 1117 snd_printd("NM256: Got misc interrupt #1\n"); 1118 cbyte = snd_nm256_readb(chip, 0x400); 1119 snd_nm256_writeb(chip, 0x400, cbyte | 2); 1120 } 1121 1122 if (status & NM2_MISC_INT_2) { 1123 status &= ~NM2_MISC_INT_2; 1124 NM2_ACK_INT(chip, NM2_MISC_INT_2); 1125 snd_printd("NM256: Got misc interrupt #2\n"); 1126 cbyte = snd_nm256_readb(chip, 0x400); 1127 snd_nm256_writeb(chip, 0x400, cbyte & ~2); 1128 } 1129 1130 /* Unknown interrupt. */ 1131 if (status) { 1132 snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", 1133 status); 1134 /* Pray. */ 1135 NM2_ACK_INT(chip, status); 1136 } 1137 1138 spin_unlock(&chip->reg_lock); 1139 return IRQ_HANDLED; 1172 1140 } 1173 1141 … … 1181 1149 */ 1182 1150 static int 1183 snd_nm256_ac97_ready(nm256_t *chip) 1184 { 1185 int timeout = 10; 1186 u32 testaddr; 1187 u16 testb; 1188 1189 testaddr = chip->mixer_status_offset; 1190 testb = chip->mixer_status_mask; 1191 1192 /* 1193 * Loop around waiting for the mixer to become ready. 1194 */ 1195 while (timeout-- > 0) { 1196 if ((snd_nm256_readw(chip, testaddr) & testb) == 0) 1197 return 1; 1198 udelay(100); 1199 } 1200 return 0; 1201 } 1202 1203 /* 1151 snd_nm256_ac97_ready(struct nm256 *chip) 1152 { 1153 int timeout = 10; 1154 u32 testaddr; 1155 u16 testb; 1156 1157 testaddr = chip->mixer_status_offset; 1158 testb = chip->mixer_status_mask; 1159 1160 /* 1161 * Loop around waiting for the mixer to become ready. 1162 */ 1163 while (timeout-- > 0) { 1164 if ((snd_nm256_readw(chip, testaddr) & testb) == 0) 1165 return 1; 1166 udelay(100); 1167 } 1168 return 0; 1169 } 1170 1171 /* 1172 * Initial register values to be written to the AC97 mixer. 1173 * While most of these are identical to the reset values, we do this 1174 * so that we have most of the register contents cached--this avoids 1175 * reading from the mixer directly (which seems to be problematic, 1176 * probably due to ignorance). 1177 */ 1178 1179 struct initialValues { 1180 unsigned short reg; 1181 unsigned short value; 1182 }; 1183 1184 static struct initialValues nm256_ac97_init_val[] = 1185 { 1186 { AC97_MASTER, 0x8000 }, 1187 { AC97_HEADPHONE, 0x8000 }, 1188 { AC97_MASTER_MONO, 0x8000 }, 1189 { AC97_PC_BEEP, 0x8000 }, 1190 { AC97_PHONE, 0x8008 }, 1191 { AC97_MIC, 0x8000 }, 1192 { AC97_LINE, 0x8808 }, 1193 { AC97_CD, 0x8808 }, 1194 { AC97_VIDEO, 0x8808 }, 1195 { AC97_AUX, 0x8808 }, 1196 { AC97_PCM, 0x8808 }, 1197 { AC97_REC_SEL, 0x0000 }, 1198 { AC97_REC_GAIN, 0x0B0B }, 1199 { AC97_GENERAL_PURPOSE, 0x0000 }, 1200 { AC97_3D_CONTROL, 0x8000 }, 1201 { AC97_VENDOR_ID1, 0x8384 }, 1202 { AC97_VENDOR_ID2, 0x7609 }, 1203 }; 1204 1205 static int nm256_ac97_idx(unsigned short reg) 1206 { 1207 int i; 1208 for (i = 0; i < ARRAY_SIZE(nm256_ac97_init_val); i++) 1209 if (nm256_ac97_init_val[i].reg == reg) 1210 return i; 1211 return -1; 1212 } 1213 1214 /* 1215 * some nm256 easily crash when reading from mixer registers 1216 * thus we're treating it as a write-only mixer and cache the 1217 * written values 1204 1218 */ 1205 1219 static unsigned short 1206 snd_nm256_ac97_read(ac97_t *ac97, unsigned short reg) 1207 { 1208 nm256_t *chip = ac97->private_data; 1209 int res; 1210 1211 if (reg >= 128) 1212 return 0; 1213 1214 if (! snd_nm256_ac97_ready(chip)) 1215 return 0; 1216 res = snd_nm256_readw(chip, chip->mixer_base + reg); 1217 /* Magic delay. Bleah yucky. */ 1218 msleep(1); 1219 return res; 1220 } 1221 1222 /* 1220 snd_nm256_ac97_read(struct snd_ac97 *ac97, unsigned short reg) 1221 { 1222 struct nm256 *chip = ac97->private_data; 1223 int idx = nm256_ac97_idx(reg); 1224 1225 if (idx < 0) 1226 return 0; 1227 return chip->ac97_regs[idx]; 1228 } 1229 1230 /* 1223 1231 */ 1224 1232 static void 1225 snd_nm256_ac97_write(ac97_t *ac97, 1226 unsigned short reg, unsigned short val) 1227 { 1228 nm256_t *chip = ac97->private_data; 1229 int tries = 2; 1230 u32 base; 1231 1232 base = chip->mixer_base; 1233 1234 snd_nm256_ac97_ready(chip); 1235 1236 /* Wait for the write to take, too. */ 1237 while (tries-- > 0) { 1238 snd_nm256_writew(chip, base + reg, val); 1239 msleep(1); /* a little delay here seems better.. */ 1240 if (snd_nm256_ac97_ready(chip)) 1241 return; 1242 } 1243 snd_printd("nm256: ac97 codec not ready..\n"); 1244 } 1233 snd_nm256_ac97_write(struct snd_ac97 *ac97, 1234 unsigned short reg, unsigned short val) 1235 { 1236 struct nm256 *chip = ac97->private_data; 1237 int tries = 2; 1238 int idx = nm256_ac97_idx(reg); 1239 u32 base; 1240 1241 if (idx < 0) 1242 return; 1243 1244 base = chip->mixer_base; 1245 1246 snd_nm256_ac97_ready(chip); 1247 1248 /* Wait for the write to take, too. */ 1249 while (tries-- > 0) { 1250 snd_nm256_writew(chip, base + reg, val); 1251 msleep(1); /* a little delay here seems better.. */ 1252 if (snd_nm256_ac97_ready(chip)) { 1253 /* successful write: set cache */ 1254 chip->ac97_regs[idx] = val; 1255 return; 1256 } 1257 } 1258 snd_printd("nm256: ac97 codec not ready..\n"); 1259 } 1260 1261 /* static resolution table */ 1262 static struct snd_ac97_res_table nm256_res_table[] = { 1263 { AC97_MASTER, 0x1f1f }, 1264 { AC97_HEADPHONE, 0x1f1f }, 1265 { AC97_MASTER_MONO, 0x001f }, 1266 { AC97_PC_BEEP, 0x001f }, 1267 { AC97_PHONE, 0x001f }, 1268 { AC97_MIC, 0x001f }, 1269 { AC97_LINE, 0x1f1f }, 1270 { AC97_CD, 0x1f1f }, 1271 { AC97_VIDEO, 0x1f1f }, 1272 { AC97_AUX, 0x1f1f }, 1273 { AC97_PCM, 0x1f1f }, 1274 { AC97_REC_GAIN, 0x0f0f }, 1275 {0} /* terminator */ 1276 }; 1245 1277 1246 1278 /* initialize the ac97 into a known state */ 1247 1279 static void 1248 snd_nm256_ac97_reset(ac97_t *ac97) 1249 { 1250 nm256_t *chip = ac97->private_data; 1251 /* Reset the mixer. 'Tis magic! */ 1252 snd_nm256_writeb(chip, 0x6c0, 1); 1253 if (! chip->reset_workaround) { 1254 /* Dell latitude LS will lock up by this */ 1255 snd_nm256_writeb(chip, 0x6cc, 0x87); 1256 } 1257 snd_nm256_writeb(chip, 0x6cc, 0x80); 1258 snd_nm256_writeb(chip, 0x6cc, 0x0); 1280 snd_nm256_ac97_reset(struct snd_ac97 *ac97) 1281 { 1282 struct nm256 *chip = ac97->private_data; 1283 1284 /* Reset the mixer. 'Tis magic! */ 1285 snd_nm256_writeb(chip, 0x6c0, 1); 1286 if (! chip->reset_workaround) { 1287 /* Dell latitude LS will lock up by this */ 1288 snd_nm256_writeb(chip, 0x6cc, 0x87); 1289 } 1290 if (! chip->reset_workaround_2) { 1291 /* Dell latitude CSx will lock up by this */ 1292 snd_nm256_writeb(chip, 0x6cc, 0x80); 1293 snd_nm256_writeb(chip, 0x6cc, 0x0); 1294 } 1295 if (! chip->in_resume) { 1296 int i; 1297 for (i = 0; i < ARRAY_SIZE(nm256_ac97_init_val); i++) { 1298 /* preload the cache, so as to avoid even a single 1299 * read of the mixer regs 1300 */ 1301 snd_nm256_ac97_write(ac97, nm256_ac97_init_val[i].reg, 1302 nm256_ac97_init_val[i].value); 1303 } 1304 } 1259 1305 } 1260 1306 1261 1307 /* create an ac97 mixer interface */ 1262 1308 static int __devinit 1263 snd_nm256_mixer(nm256_t *chip) 1264 { 1265 ac97_bus_t *pbus; 1266 ac97_template_t ac97; 1267 int i, err; 1268 static ac97_bus_ops_t ops = { 1269 snd_nm256_ac97_reset, 1270 snd_nm256_ac97_write, 1271 snd_nm256_ac97_read,0,0 1272 }; 1273 /* looks like nm256 hangs up when unexpected registers are touched... */ 1274 static int mixer_regs[] = { 1275 AC97_MASTER, AC97_HEADPHONE, AC97_MASTER_MONO, 1276 AC97_PC_BEEP, AC97_PHONE, AC97_MIC, AC97_LINE, AC97_CD, 1277 AC97_VIDEO, AC97_AUX, AC97_PCM, AC97_REC_SEL, 1278 AC97_REC_GAIN, AC97_GENERAL_PURPOSE, AC97_3D_CONTROL, 1279 /*AC97_EXTENDED_ID,*/ 1280 AC97_VENDOR_ID1, AC97_VENDOR_ID2, 1281 -1 1282 }; 1283 1284 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) 1285 return err; 1286 1287 memset(&ac97, 0, sizeof(ac97)); 1288 ac97.scaps = AC97_SCAP_AUDIO; /* we support audio! */ 1289 ac97.limited_regs = 1; 1290 for (i = 0; mixer_regs[i] >= 0; i++) 1291 set_bit(mixer_regs[i], ac97.reg_accessed); 1292 ac97.private_data = chip; 1293 pbus->no_vra = 1; 1294 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97); 1295 if (err < 0) 1296 return err; 1297 if (! (chip->ac97->id & (0xf0000000))) { 1298 /* looks like an invalid id */ 1299 sprintf(chip->card->mixername, "%s AC97", chip->card->driver); 1300 } 1301 return 0; 1302 } 1303 1304 /* 1309 snd_nm256_mixer(struct nm256 *chip) 1310 { 1311 struct snd_ac97_bus *pbus; 1312 struct snd_ac97_template ac97; 1313 int err; 1314 static struct snd_ac97_bus_ops ops = { 1315 .reset = snd_nm256_ac97_reset, 1316 .write = snd_nm256_ac97_write, 1317 .read = snd_nm256_ac97_read, 1318 }; 1319 1320 chip->ac97_regs = kcalloc(sizeof(short), 1321 ARRAY_SIZE(nm256_ac97_init_val), GFP_KERNEL); 1322 if (! chip->ac97_regs) 1323 return -ENOMEM; 1324 1325 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) 1326 return err; 1327 1328 memset(&ac97, 0, sizeof(ac97)); 1329 ac97.scaps = AC97_SCAP_AUDIO; /* we support audio! */ 1330 ac97.private_data = chip; 1331 ac97.res_table = nm256_res_table; 1332 pbus->no_vra = 1; 1333 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97); 1334 if (err < 0) 1335 return err; 1336 if (! (chip->ac97->id & (0xf0000000))) { 1337 /* looks like an invalid id */ 1338 sprintf(chip->card->mixername, "%s AC97", chip->card->driver); 1339 } 1340 return 0; 1341 } 1342 1343 /* 1305 1344 * See if the signature left by the NM256 BIOS is intact; if so, we use 1306 1345 * the associated address as the end of our audio buffer in the video … … 1309 1348 1310 1349 static int __devinit 1311 snd_nm256_peek_for_sig(nm256_t *chip) 1312 { 1313 /* The signature is located 1K below the end of video RAM. */ 1314 unsigned long temp; 1315 /* Default buffer end is 5120 bytes below the top of RAM. */ 1316 unsigned long pointer_found = chip->buffer_end - 0x1400; 1317 u32 sig; 1318 1319 temp = (unsigned long) ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16); 1320 if (temp == 0) { 1321 snd_printk("Unable to scan for card signature in video RAM\n"); 1322 return -EBUSY; 1323 } 1324 1325 sig = readl(temp); 1326 if ((sig & NM_SIG_MASK) == NM_SIGNATURE) { 1327 u32 pointer = readl(temp + 4); 1328 1329 /* 1330 * If it's obviously invalid, don't use it 1331 */ 1332 if (pointer == 0xffffffff || 1333 pointer < chip->buffer_size || 1334 pointer > chip->buffer_end) { 1335 snd_printk("invalid signature found: 0x%x\n", pointer); 1336 iounmap((void *)temp); 1337 return -ENODEV; 1338 } else { 1339 pointer_found = pointer; 1340 printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n", pointer); 1341 } 1342 } 1343 1344 iounmap((void *)temp); 1345 chip->buffer_end = pointer_found; 1346 1347 return 0; 1350 snd_nm256_peek_for_sig(struct nm256 *chip) 1351 { 1352 /* The signature is located 1K below the end of video RAM. */ 1353 void __iomem *temp; 1354 /* Default buffer end is 5120 bytes below the top of RAM. */ 1355 unsigned long pointer_found = chip->buffer_end - 0x1400; 1356 u32 sig; 1357 1358 temp = ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16); 1359 if (temp == NULL) { 1360 snd_printk(KERN_ERR "Unable to scan for card signature in video RAM\n"); 1361 return -EBUSY; 1362 } 1363 1364 sig = readl(temp); 1365 if ((sig & NM_SIG_MASK) == NM_SIGNATURE) { 1366 u32 pointer = readl(temp + 4); 1367 1368 /* 1369 * If it's obviously invalid, don't use it 1370 */ 1371 if (pointer == 0xffffffff || 1372 pointer < chip->buffer_size || 1373 pointer > chip->buffer_end) { 1374 snd_printk(KERN_ERR "invalid signature found: 0x%x\n", pointer); 1375 iounmap(temp); 1376 return -ENODEV; 1377 } else { 1378 pointer_found = pointer; 1379 printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n", 1380 pointer); 1381 } 1382 } 1383 1384 iounmap(temp); 1385 chip->buffer_end = pointer_found; 1386 1387 return 0; 1348 1388 } 1349 1389 … … 1353 1393 * event. 1354 1394 */ 1355 static int nm256_suspend(snd_card_t *card, pm_message_t state) 1356 { 1357 nm256_t *chip = card->pm_private_data; 1358 snd_pcm_suspend_all(chip->pcm); 1359 snd_ac97_suspend(chip->ac97); 1360 chip->coeffs_current = 0; 1361 return 0; 1362 } 1363 1364 static int nm256_resume(snd_card_t *card, u32 state) 1365 { 1366 nm256_t *chip = card->pm_private_data; 1367 int i; 1368 /* Perform a full reset on the hardware */ 1369 pci_enable_device(chip->pci); 1370 snd_nm256_init_chip(chip); 1371 1372 /* restore ac97 */ 1373 snd_ac97_resume(chip->ac97); 1374 for (i = 0; i < 2; i++) { 1375 nm256_stream_t *s = &chip->streams[i]; 1376 if (s->substream && s->suspended) { 1377 spin_lock_irq(&chip->reg_lock); 1378 snd_nm256_set_format(chip, s, s->substream); 1379 spin_unlock_irq(&chip->reg_lock); 1380 } 1381 } 1382 1383 return 0; 1395 static int nm256_suspend(struct pci_dev *pci, pm_message_t state) 1396 { 1397 struct snd_card *card = pci_get_drvdata(pci); 1398 struct nm256 *chip = card->private_data; 1399 1400 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1401 snd_pcm_suspend_all(chip->pcm); 1402 snd_ac97_suspend(chip->ac97); 1403 chip->coeffs_current = 0; 1404 pci_disable_device(pci); 1405 pci_save_state(pci); 1406 return 0; 1407 } 1408 1409 static int nm256_resume(struct pci_dev *pci) 1410 { 1411 struct snd_card *card = pci_get_drvdata(pci); 1412 struct nm256 *chip = card->private_data; 1413 int i; 1414 1415 /* Perform a full reset on the hardware */ 1416 chip->in_resume = 1; 1417 pci_restore_state(pci); 1418 pci_enable_device(pci); 1419 snd_nm256_init_chip(chip); 1420 1421 /* restore ac97 */ 1422 snd_ac97_resume(chip->ac97); 1423 1424 for (i = 0; i < 2; i++) { 1425 struct nm256_stream *s = &chip->streams[i]; 1426 if (s->substream && s->suspended) { 1427 spin_lock_irq(&chip->reg_lock); 1428 snd_nm256_set_format(chip, s, s->substream); 1429 spin_unlock_irq(&chip->reg_lock); 1430 } 1431 } 1432 1433 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 1434 chip->in_resume = 0; 1435 return 0; 1384 1436 } 1385 1437 #endif /* CONFIG_PM */ 1386 1438 1387 static int snd_nm256_free(nm256_t *chip) 1388 { 1389 if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running) 1390 snd_nm256_playback_stop(chip); 1391 if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running) 1392 snd_nm256_capture_stop(chip); 1393 1394 if (chip->irq >= 0) 1395 synchronize_irq(chip->irq); 1396 1397 if (chip->cport) 1398 iounmap((void *) chip->cport); 1399 if (chip->buffer) 1400 iounmap((void *) chip->buffer); 1401 if (chip->res_cport) { 1402 release_resource(chip->res_cport); 1403 kfree_nocheck(chip->res_cport); 1404 } 1405 if (chip->res_buffer) { 1406 release_resource(chip->res_buffer); 1407 kfree_nocheck(chip->res_buffer); 1408 } 1409 if (chip->irq >= 0) 1410 free_irq(chip->irq, (void*)chip); 1411 1412 kfree(chip); 1413 return 0; 1414 } 1415 1416 static int snd_nm256_dev_free(snd_device_t *device) 1417 { 1418 nm256_t *chip = device->device_data; 1419 return snd_nm256_free(chip); 1439 static int snd_nm256_free(struct nm256 *chip) 1440 { 1441 if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running) 1442 snd_nm256_playback_stop(chip); 1443 if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running) 1444 snd_nm256_capture_stop(chip); 1445 1446 if (chip->irq >= 0) 1447 synchronize_irq(chip->irq); 1448 1449 if (chip->cport) 1450 iounmap(chip->cport); 1451 if (chip->buffer) 1452 iounmap(chip->buffer); 1453 release_and_free_resource(chip->res_cport); 1454 release_and_free_resource(chip->res_buffer); 1455 if (chip->irq >= 0) 1456 free_irq(chip->irq, chip); 1457 1458 pci_disable_device(chip->pci); 1459 kfree(chip->ac97_regs); 1460 kfree(chip); 1461 return 0; 1462 } 1463 1464 static int snd_nm256_dev_free(struct snd_device *device) 1465 { 1466 struct nm256 *chip = device->device_data; 1467 return snd_nm256_free(chip); 1420 1468 } 1421 1469 1422 1470 static int __devinit 1423 snd_nm256_create(snd_card_t *card, struct pci_dev *pci, 1424 int play_bufsize, int capt_bufsize, 1425 int force_load, 1426 u32 buffertop, 1427 int usecache, 1428 nm256_t **chip_ret) 1429 { 1430 nm256_t *chip; 1431 int err, pval; 1432 #ifdef TARGET_OS2 1433 static snd_device_ops_t ops = { 1434 snd_nm256_dev_free,0,0,0 1435 }; 1436 #else 1437 static snd_device_ops_t ops = { 1438 dev_free: snd_nm256_dev_free, 1439 }; 1440 #endif 1441 u32 addr; 1442 1443 *chip_ret = NULL; 1444 1445 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 1446 if (chip == NULL) 1447 return -ENOMEM; 1448 1449 chip->card = card; 1450 chip->pci = pci; 1451 chip->use_cache = usecache; 1452 spin_lock_init(&chip->reg_lock); 1453 chip->irq = -1; 1454 init_MUTEX(&chip->irq_mutex); 1455 1456 chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize = play_bufsize; 1457 chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize = capt_bufsize; 1458 1459 /* 1460 * The NM256 has two memory ports. The first port is nothing 1461 * more than a chunk of video RAM, which is used as the I/O ring 1462 * buffer. The second port has the actual juicy stuff (like the 1463 * mixer and the playback engine control registers). 1464 */ 1465 1466 chip->buffer_addr = pci_resource_start(pci, 0); 1467 chip->cport_addr = pci_resource_start(pci, 1); 1468 1469 /* Init the memory port info. */ 1470 /* remap control port (#2) */ 1471 chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE, 1472 card->driver); 1473 if (chip->res_cport == NULL) { 1474 snd_printk("memory region 0x%lx (size 0x%x) busy\n", 1475 chip->cport_addr, NM_PORT2_SIZE); 1476 err = -EBUSY; 1477 goto __error; 1478 } 1479 chip->cport = (unsigned long) ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE); 1480 if (chip->cport == 0) { 1481 snd_printk("unable to map control port %lx\n", chip->cport_addr); 1482 err = -ENOMEM; 1483 goto __error; 1484 } 1485 1486 if (!strcmp(card->driver, "NM256AV")) { 1487 /* Ok, try to see if this is a non-AC97 version of the hardware. */ 1488 pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE); 1489 if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { 1490 if (! force_load) { 1491 printk(KERN_ERR "nm256: no ac97 is found!\n"); 1492 printk(KERN_ERR " force the driver to load by passing in the module parameter\n"); 1493 printk(KERN_ERR " force_ac97=1\n"); 1494 printk(KERN_ERR " or try sb16 or cs423x drivers instead.\n"); 1495 err = -ENXIO; 1496 goto __error; 1497 } 1498 } 1499 chip->buffer_end = 2560 * 1024; 1500 chip->interrupt = snd_nm256_interrupt; 1501 chip->mixer_status_offset = NM_MIXER_STATUS_OFFSET; 1502 chip->mixer_status_mask = NM_MIXER_READY_MASK; 1503 } else { 1504 /* Not sure if there is any relevant detect for the ZX or not. */ 1505 if (snd_nm256_readb(chip, 0xa0b) != 0) 1506 chip->buffer_end = 6144 * 1024; 1507 else 1508 chip->buffer_end = 4096 * 1024; 1509 1510 chip->interrupt = snd_nm256_interrupt_zx; 1511 chip->mixer_status_offset = NM2_MIXER_STATUS_OFFSET; 1512 chip->mixer_status_mask = NM2_MIXER_READY_MASK; 1513 } 1514 1515 chip->buffer_size = chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize + chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize; 1516 if (chip->use_cache) 1517 chip->buffer_size += NM_TOTAL_COEFF_COUNT * 4; 1518 else 1519 chip->buffer_size += NM_MAX_PLAYBACK_COEF_SIZE + NM_MAX_RECORD_COEF_SIZE; 1520 1521 if (buffertop >= chip->buffer_size && buffertop < chip->buffer_end) 1522 chip->buffer_end = buffertop; 1523 else { 1524 /* get buffer end pointer from signature */ 1525 if ((err = snd_nm256_peek_for_sig(chip)) < 0) 1526 goto __error; 1527 } 1528 1529 chip->buffer_start = chip->buffer_end - chip->buffer_size; 1530 chip->buffer_addr += chip->buffer_start; 1531 1532 printk(KERN_INFO "nm256: Mapping port 1 from 0x%x - 0x%x\n", 1533 chip->buffer_start, chip->buffer_end); 1534 1535 chip->res_buffer = request_mem_region(chip->buffer_addr, 1536 chip->buffer_size, 1537 card->driver); 1538 if (chip->res_buffer == NULL) { 1539 snd_printk("nm256: buffer 0x%lx (size 0x%x) busy\n", 1540 chip->buffer_addr, chip->buffer_size); 1541 err = -EBUSY; 1542 goto __error; 1543 } 1544 chip->buffer = (unsigned long) ioremap_nocache(chip->buffer_addr, chip->buffer_size); 1545 if (chip->buffer == 0) { 1546 err = -ENOMEM; 1547 snd_printk("unable to map ring buffer at %lx\n", chip->buffer_addr); 1548 goto __error; 1549 } 1550 1551 /* set offsets */ 1552 addr = chip->buffer_start; 1553 chip->streams[SNDRV_PCM_STREAM_PLAYBACK].buf = addr; 1554 addr += chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize; 1555 chip->streams[SNDRV_PCM_STREAM_CAPTURE].buf = addr; 1556 addr += chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize; 1557 if (chip->use_cache) { 1558 chip->all_coeff_buf = addr; 1559 } else { 1560 chip->coeff_buf[SNDRV_PCM_STREAM_PLAYBACK] = addr; 1561 addr += NM_MAX_PLAYBACK_COEF_SIZE; 1562 chip->coeff_buf[SNDRV_PCM_STREAM_CAPTURE] = addr; 1563 } 1564 1565 /* Fixed setting. */ 1566 chip->mixer_base = NM_MIXER_OFFSET; 1567 1568 chip->coeffs_current = 0; 1569 1570 snd_nm256_init_chip(chip); 1571 1572 // pci_set_master(pci); /* needed? */ 1573 1574 snd_card_set_pm_callback(card, nm256_suspend, nm256_resume, chip); 1575 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) 1576 goto __error; 1577 1578 *chip_ret = chip; 1579 return 0; 1471 snd_nm256_create(struct snd_card *card, struct pci_dev *pci, 1472 struct nm256 **chip_ret) 1473 { 1474 struct nm256 *chip; 1475 int err, pval; 1476 static struct snd_device_ops ops = { 1477 .dev_free = snd_nm256_dev_free, 1478 }; 1479 u32 addr; 1480 1481 *chip_ret = NULL; 1482 1483 if ((err = pci_enable_device(pci)) < 0) 1484 return err; 1485 1486 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1487 if (chip == NULL) { 1488 pci_disable_device(pci); 1489 return -ENOMEM; 1490 } 1491 1492 chip->card = card; 1493 chip->pci = pci; 1494 chip->use_cache = use_cache; 1495 spin_lock_init(&chip->reg_lock); 1496 chip->irq = -1; 1497 mutex_init(&chip->irq_mutex); 1498 1499 /* store buffer sizes in bytes */ 1500 chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize = playback_bufsize * 1024; 1501 chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize = capture_bufsize * 1024; 1502 1503 /* 1504 * The NM256 has two memory ports. The first port is nothing 1505 * more than a chunk of video RAM, which is used as the I/O ring 1506 * buffer. The second port has the actual juicy stuff (like the 1507 * mixer and the playback engine control registers). 1508 */ 1509 1510 chip->buffer_addr = pci_resource_start(pci, 0); 1511 chip->cport_addr = pci_resource_start(pci, 1); 1512 1513 /* Init the memory port info. */ 1514 /* remap control port (#2) */ 1515 chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE, 1516 card->driver); 1517 if (chip->res_cport == NULL) { 1518 snd_printk(KERN_ERR "memory region 0x%lx (size 0x%x) busy\n", 1519 chip->cport_addr, NM_PORT2_SIZE); 1520 err = -EBUSY; 1521 goto __error; 1522 } 1523 chip->cport = ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE); 1524 if (chip->cport == NULL) { 1525 snd_printk(KERN_ERR "unable to map control port %lx\n", chip->cport_addr); 1526 err = -ENOMEM; 1527 goto __error; 1528 } 1529 1530 if (!strcmp(card->driver, "NM256AV")) { 1531 /* Ok, try to see if this is a non-AC97 version of the hardware. */ 1532 pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE); 1533 if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { 1534 if (! force_ac97) { 1535 printk(KERN_ERR "nm256: no ac97 is found!\n"); 1536 printk(KERN_ERR " force the driver to load by " 1537 "passing in the module parameter\n"); 1538 printk(KERN_ERR " force_ac97=1\n"); 1539 printk(KERN_ERR " or try sb16 or cs423x drivers instead.\n"); 1540 err = -ENXIO; 1541 goto __error; 1542 } 1543 } 1544 chip->buffer_end = 2560 * 1024; 1545 chip->interrupt = snd_nm256_interrupt; 1546 chip->mixer_status_offset = NM_MIXER_STATUS_OFFSET; 1547 chip->mixer_status_mask = NM_MIXER_READY_MASK; 1548 } else { 1549 /* Not sure if there is any relevant detect for the ZX or not. */ 1550 if (snd_nm256_readb(chip, 0xa0b) != 0) 1551 chip->buffer_end = 6144 * 1024; 1552 else 1553 chip->buffer_end = 4096 * 1024; 1554 1555 chip->interrupt = snd_nm256_interrupt_zx; 1556 chip->mixer_status_offset = NM2_MIXER_STATUS_OFFSET; 1557 chip->mixer_status_mask = NM2_MIXER_READY_MASK; 1558 } 1559 1560 chip->buffer_size = chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize + 1561 chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize; 1562 if (chip->use_cache) 1563 chip->buffer_size += NM_TOTAL_COEFF_COUNT * 4; 1564 else 1565 chip->buffer_size += NM_MAX_PLAYBACK_COEF_SIZE + NM_MAX_RECORD_COEF_SIZE; 1566 1567 if (buffer_top >= chip->buffer_size && buffer_top < chip->buffer_end) 1568 chip->buffer_end = buffer_top; 1569 else { 1570 /* get buffer end pointer from signature */ 1571 if ((err = snd_nm256_peek_for_sig(chip)) < 0) 1572 goto __error; 1573 } 1574 1575 chip->buffer_start = chip->buffer_end - chip->buffer_size; 1576 chip->buffer_addr += chip->buffer_start; 1577 1578 printk(KERN_INFO "nm256: Mapping port 1 from 0x%x - 0x%x\n", 1579 chip->buffer_start, chip->buffer_end); 1580 1581 chip->res_buffer = request_mem_region(chip->buffer_addr, 1582 chip->buffer_size, 1583 card->driver); 1584 if (chip->res_buffer == NULL) { 1585 snd_printk(KERN_ERR "nm256: buffer 0x%lx (size 0x%x) busy\n", 1586 chip->buffer_addr, chip->buffer_size); 1587 err = -EBUSY; 1588 goto __error; 1589 } 1590 chip->buffer = ioremap_nocache(chip->buffer_addr, chip->buffer_size); 1591 if (chip->buffer == NULL) { 1592 err = -ENOMEM; 1593 snd_printk(KERN_ERR "unable to map ring buffer at %lx\n", chip->buffer_addr); 1594 goto __error; 1595 } 1596 1597 /* set offsets */ 1598 addr = chip->buffer_start; 1599 chip->streams[SNDRV_PCM_STREAM_PLAYBACK].buf = addr; 1600 addr += chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize; 1601 chip->streams[SNDRV_PCM_STREAM_CAPTURE].buf = addr; 1602 addr += chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize; 1603 if (chip->use_cache) { 1604 chip->all_coeff_buf = addr; 1605 } else { 1606 chip->coeff_buf[SNDRV_PCM_STREAM_PLAYBACK] = addr; 1607 addr += NM_MAX_PLAYBACK_COEF_SIZE; 1608 chip->coeff_buf[SNDRV_PCM_STREAM_CAPTURE] = addr; 1609 } 1610 1611 /* Fixed setting. */ 1612 chip->mixer_base = NM_MIXER_OFFSET; 1613 1614 chip->coeffs_current = 0; 1615 1616 snd_nm256_init_chip(chip); 1617 1618 // pci_set_master(pci); /* needed? */ 1619 1620 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) 1621 goto __error; 1622 1623 snd_card_set_dev(card, &pci->dev); 1624 1625 *chip_ret = chip; 1626 return 0; 1580 1627 1581 1628 __error: 1582 snd_nm256_free(chip); 1583 return err; 1584 } 1629 snd_nm256_free(chip); 1630 return err; 1631 } 1632 1585 1633 1586 1634 struct nm256_quirk { … … 1590 1638 }; 1591 1639 1592 enum { NM_BLACKLISTED, NM_RESET_WORKAROUND };1640 enum { NM_BLACKLISTED, NM_RESET_WORKAROUND, NM_RESET_WORKAROUND_2 }; 1593 1641 1594 1642 static struct nm256_quirk nm256_quirks[] __devinitdata = { 1595 1643 /* HP omnibook 4150 has cs4232 codec internally */ 1596 { 0x103c, 0x0007,NM_BLACKLISTED },1644 { .vendor = 0x103c, .device = 0x0007, .type = NM_BLACKLISTED }, 1597 1645 /* Sony PCG-F305 */ 1598 { 0x104d, 0x8041,NM_RESET_WORKAROUND },1646 { .vendor = 0x104d, .device = 0x8041, .type = NM_RESET_WORKAROUND }, 1599 1647 /* Dell Latitude LS */ 1600 { 0x1028, 0x0080, NM_RESET_WORKAROUND }, 1601 {0 } /* terminator */ 1648 { .vendor = 0x1028, .device = 0x0080, .type = NM_RESET_WORKAROUND }, 1649 /* Dell Latitude CSx */ 1650 { .vendor = 0x1028, .device = 0x0091, .type = NM_RESET_WORKAROUND_2 }, 1651 {0} /* terminator */ 1602 1652 }; 1603 1653 1604 1654 1605 1655 static int __devinit snd_nm256_probe(struct pci_dev *pci, 1606 const struct pci_device_id *pci_id) 1607 { 1608 static int dev; 1609 snd_card_t *card; 1610 nm256_t *chip; 1611 int err; 1612 unsigned int xbuffer_top; 1613 struct nm256_quirk *q; 1614 u16 subsystem_vendor, subsystem_device; 1615 1616 if ((err = pci_enable_device(pci)) < 0) 1617 return err; 1618 1619 if (dev >= SNDRV_CARDS) 1620 return -ENODEV; 1621 if (!enable[dev]) { 1622 dev++; 1623 return -ENOENT; 1624 } 1625 1626 pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 1627 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); 1628 1629 for (q = nm256_quirks; q->vendor; q++) { 1630 if (q->vendor == subsystem_vendor && q->device == subsystem_device) { 1631 switch (q->type) { 1632 case NM_BLACKLISTED: 1633 printk(KERN_INFO "nm256: The device is blacklisted. Loading stopped\n"); 1634 return -ENODEV; 1635 case NM_RESET_WORKAROUND: 1636 reset_workaround[dev] = 1; 1637 break; 1638 } 1639 } 1640 } 1641 1642 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 1643 if (card == NULL) 1644 return -ENOMEM; 1645 1646 switch (pci->device) { 1647 case PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO: 1648 strcpy(card->driver, "NM256AV"); 1649 break; 1650 case PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO: 1651 strcpy(card->driver, "NM256ZX"); 1652 break; 1653 default: 1654 snd_printk("invalid device id 0x%x\n", pci->device); 1655 snd_card_free(card); 1656 return -EINVAL; 1657 } 1658 1659 if (vaio_hack[dev]) 1660 xbuffer_top = 0x25a800; /* this avoids conflicts with XFree86 server */ 1661 else 1662 xbuffer_top = buffer_top[dev]; 1663 1664 if (playback_bufsize[dev] < 4) 1665 playback_bufsize[dev] = 4; 1666 if (playback_bufsize[dev] > 128) 1667 playback_bufsize[dev] = 128; 1668 if (capture_bufsize[dev] < 4) 1669 capture_bufsize[dev] = 4; 1670 if (capture_bufsize[dev] > 128) 1671 capture_bufsize[dev] = 128; 1672 if ((err = snd_nm256_create(card, pci, 1673 playback_bufsize[dev] * 1024, /* in bytes */ 1674 capture_bufsize[dev] * 1024, /* in bytes */ 1675 force_ac97[dev], 1676 xbuffer_top, 1677 use_cache[dev], 1678 &chip)) < 0) { 1679 snd_card_free(card); 1680 return err; 1681 } 1682 1683 if (reset_workaround[dev]) { 1684 snd_printdd(KERN_INFO "nm256: reset_workaround activated\n"); 1685 chip->reset_workaround = 1; 1686 } 1687 if ((err = snd_nm256_pcm(chip, 0)) < 0 || 1688 (err = snd_nm256_mixer(chip)) < 0) { 1689 snd_card_free(card); 1690 return err; 1691 } 1692 1693 sprintf(card->shortname, "NeoMagic %s", card->driver); 1694 sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %d", 1695 card->shortname, 1696 chip->buffer_addr, chip->cport_addr, chip->irq); 1697 1698 if ((err = snd_card_register(card)) < 0) { 1699 snd_card_free(card); 1700 return err; 1701 } 1702 1703 pci_set_drvdata(pci, card); 1704 dev++; 1705 return 0; 1656 const struct pci_device_id *pci_id) 1657 { 1658 struct snd_card *card; 1659 struct nm256 *chip; 1660 int err; 1661 struct nm256_quirk *q; 1662 u16 subsystem_vendor, subsystem_device; 1663 1664 pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 1665 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); 1666 1667 for (q = nm256_quirks; q->vendor; q++) { 1668 if (q->vendor == subsystem_vendor && q->device == subsystem_device) { 1669 switch (q->type) { 1670 case NM_BLACKLISTED: 1671 printk(KERN_INFO "nm256: The device is blacklisted. " 1672 "Loading stopped\n"); 1673 return -ENODEV; 1674 case NM_RESET_WORKAROUND_2: 1675 reset_workaround_2 = 1; 1676 /* Fall-through */ 1677 case NM_RESET_WORKAROUND: 1678 reset_workaround = 1; 1679 break; 1680 } 1681 } 1682 } 1683 1684 card = snd_card_new(index, id, THIS_MODULE, 0); 1685 if (card == NULL) 1686 return -ENOMEM; 1687 1688 switch (pci->device) { 1689 case PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO: 1690 strcpy(card->driver, "NM256AV"); 1691 break; 1692 case PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO: 1693 strcpy(card->driver, "NM256ZX"); 1694 break; 1695 case PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO: 1696 strcpy(card->driver, "NM256XL+"); 1697 break; 1698 default: 1699 snd_printk(KERN_ERR "invalid device id 0x%x\n", pci->device); 1700 snd_card_free(card); 1701 return -EINVAL; 1702 } 1703 1704 if (vaio_hack) 1705 buffer_top = 0x25a800; /* this avoids conflicts with XFree86 server */ 1706 1707 if (playback_bufsize < 4) 1708 playback_bufsize = 4; 1709 if (playback_bufsize > 128) 1710 playback_bufsize = 128; 1711 if (capture_bufsize < 4) 1712 capture_bufsize = 4; 1713 if (capture_bufsize > 128) 1714 capture_bufsize = 128; 1715 if ((err = snd_nm256_create(card, pci, &chip)) < 0) { 1716 snd_card_free(card); 1717 return err; 1718 } 1719 card->private_data = chip; 1720 1721 if (reset_workaround) { 1722 snd_printdd(KERN_INFO "nm256: reset_workaround activated\n"); 1723 chip->reset_workaround = 1; 1724 } 1725 1726 if (reset_workaround_2) { 1727 snd_printdd(KERN_INFO "nm256: reset_workaround_2 activated\n"); 1728 chip->reset_workaround_2 = 1; 1729 } 1730 1731 if ((err = snd_nm256_pcm(chip, 0)) < 0 || 1732 (err = snd_nm256_mixer(chip)) < 0) { 1733 snd_card_free(card); 1734 return err; 1735 } 1736 1737 sprintf(card->shortname, "NeoMagic %s", card->driver); 1738 sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %d", 1739 card->shortname, 1740 chip->buffer_addr, chip->cport_addr, chip->irq); 1741 1742 if ((err = snd_card_register(card)) < 0) { 1743 snd_card_free(card); 1744 return err; 1745 } 1746 1747 pci_set_drvdata(pci, card); 1748 return 0; 1706 1749 } 1707 1750 1708 1751 static void __devexit snd_nm256_remove(struct pci_dev *pci) 1709 1752 { 1710 snd_card_free(pci_get_drvdata(pci)); 1711 pci_set_drvdata(pci, NULL); 1712 } 1753 snd_card_free(pci_get_drvdata(pci)); 1754 pci_set_drvdata(pci, NULL); 1755 } 1756 1713 1757 1714 1758 static struct pci_driver driver = { 1715 0,0,0,"NeoMagic 256", 1716 snd_nm256_ids, 1717 snd_nm256_probe, 1718 snd_nm256_remove, 1719 SND_PCI_PM_CALLBACKS 1759 .name = "NeoMagic 256", 1760 .id_table = snd_nm256_ids, 1761 .probe = snd_nm256_probe, 1762 .remove = snd_nm256_remove, 1763 #ifdef CONFIG_PM 1764 .suspend = nm256_suspend, 1765 .resume = nm256_resume, 1766 #endif 1720 1767 }; 1721 1768 1769 1722 1770 static int __init alsa_card_nm256_init(void) 1723 1771 { 1724 int err; 1725 if ((err = pci_module_init(&driver)) < 0) { 1726 #ifdef MODULE 1727 // printk(KERN_ERR "NeoMagic 256 audio soundchip not found or device busy\n"); 1728 #endif 1729 return err; 1730 } 1731 return 0; 1772 return pci_register_driver(&driver); 1732 1773 } 1733 1774 1734 1775 static void __exit alsa_card_nm256_exit(void) 1735 1776 { 1736 1777 pci_unregister_driver(&driver); 1737 1778 } 1738 1779 1739 1780 module_init(alsa_card_nm256_init) 1740 1781 module_exit(alsa_card_nm256_exit) 1741 1742 #ifndef MODULE1743 1744 /* format is: snd-nm256=enable,index,id,1745 playback_bufsize,capture_bufsize,1746 force_ac97,buffer_top,use_cache */1747 1748 static int __init alsa_card_nm256_setup(char *str)1749 {1750 static unsigned __initdata nr_dev = 0;1751 1752 if (nr_dev >= SNDRV_CARDS)1753 return 0;1754 (void)(get_option(&str,&enable[nr_dev]) == 2 &&1755 get_option(&str,&index[nr_dev]) == 2 &&1756 get_id(&str,&id[nr_dev]) == 2 &&1757 get_option(&str,&playback_bufsize[nr_dev]) == 2 &&1758 get_option(&str,&capture_bufsize[nr_dev]) == 2 &&1759 get_option(&str,&force_ac97[nr_dev]) == 2 &&1760 get_option(&str,&buffer_top[nr_dev]) == 2 &&1761 get_option(&str,&use_cache[nr_dev]) == 2);1762 nr_dev++;1763 return 1;1764 }1765 1766 __setup("snd-nm256=", alsa_card_nm256_setup);1767 1768 #endif /* ifndef MODULE */ -
GPL/trunk/alsa-kernel/pci/via82xx.c
r70 r76 2363 2363 { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */ 2364 2364 { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */ 2365 { .subvendor = 0x1462, .subdevice = 0x7142, .action = VIA_DXS_ENABLE }, /* MSI K8MM-V */ 2365 { .subvendor = 0x1462, .subdevice = 0x7142, .action = VIA_DXS_ENABLE }, /* MSI K8MM-V */ 2366 { .subvendor = 0x1462, .subdevice = 0xb012, .action = VIA_DXS_SRC }, /* P4M800/VIA8237R */ 2366 2367 { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */ 2367 2368 { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */ … … 2376 2377 { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */ 2377 2378 { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ 2378 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ 2379 { .subvendor = 0x16f3, .subdevice = 0x6405, .action = VIA_DXS_SRC }, /* Jetway K8M8MS */ 2380 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ 2379 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ 2380 { .subvendor = 0x1695, .subdevice = 0x300c, .action = VIA_DXS_SRC }, /* EPoX EP-8KRAI */ 2381 { .subvendor = 0x1695, .subdevice = 0x300e, .action = VIA_DXS_SRC }, /* EPoX 9HEAI */ 2382 { .subvendor = 0x16f3, .subdevice = 0x6405, .action = VIA_DXS_SRC }, /* Jetway K8M8MS */ 2383 { .subvendor = 0x1734, .subdevice = 0x1078, .action = VIA_DXS_SRC }, /* FSC Amilo L7300 */ 2384 { .subvendor = 0x1734, .subdevice = 0x1093, .action = VIA_DXS_SRC }, /* FSC */ 2385 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ { .subvendor = 0x1849, .subdevice = 0x9739, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */ 2381 2386 { .subvendor = 0x1849, .subdevice = 0x9761, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */ 2382 2387 { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */ -
GPL/trunk/drv32/pciids.h
r32 r76 78 78 #define PCIID_INTEL_ICH6 ((PCI_DEVICE_ID_INTEL_ICH6<<16) | PCI_VENDOR_ID_INTEL) 79 79 #define PCIID_INTEL_ICH7 ((PCI_DEVICE_ID_INTEL_ICH7<<16) | PCI_VENDOR_ID_INTEL) 80 #define PCIID_SI_7012 0x7012 80 #define PCIID_SI_7012 0x70121039 81 81 82 #define PCIID_NVIDIA_MCP_AUDIO 0x10de01b1 83 #define PCIID_NVIDIA_MCP2_AUDIO 0x10de006a 84 #define PCIID_NVIDIA_MCP3_AUDIO 0x10de00da 85 #define PCIID_NVIDIA_CK8S_AUDIO 0x10de00ea 86 #define PCIID_NVIDIA_CK8_AUDIO 0x10de008a 87 82 #define PCIID_NVIDIA_MCP_AUDIO 0x01b110de 83 #define PCIID_NVIDIA_MCP2_AUDIO 0x006a10de 84 #define PCIID_NVIDIA_MCP3_AUDIO 0x00da10de 85 #define PCIID_NVIDIA_CK8S_AUDIO 0x00ea10de 86 #define PCIID_NVIDIA_CK8_AUDIO 0x008a10de 88 87 89 88 #define PCIID_CIRRUS_4281 ((PCI_DEVICE_ID_CIRRUS_4281<<16) | PCI_VENDOR_ID_CIRRUS) -
GPL/trunk/include/version.mak
r63 r76 11 11 BLDLVL_REVISION = 1.1 12 12 BLDLVL_FILEVER = 4 13 BLDLVL_DATETIME = 04.01.2006 00:19:0613 BLDLVL_DATETIME = 31.03.2006 01:05:34 14 14 BLDLVL_MACHINE = VLAD -
GPL/trunk/lib32/fminstrload.c
r34 r76 125 125 //****************************************************************************** 126 126 127 #ifdef DEBUG 127 #if 0 128 //def DEBUG 128 129 /* 129 130 * Show instrument FM operators -
GPL/trunk/lib32/ioctl.c
r32 r76 1063 1063 if (fileid == opened_handles[i].FileId) 1064 1064 { 1065 opened_handles[i].reuse = 0; 1065 1066 if (OSS32_WaveClose((OSSSTREAMID)opened_handles[i].handle) == 0) 1066 1067 opened_handles[i].handle = 0; … … 1069 1070 else 1070 1071 { 1072 opened_handles[i].reuse = 0; 1071 1073 if (OSS32_WaveClose((OSSSTREAMID)opened_handles[i].handle) == 0) 1072 1074 opened_handles[i].handle = 0; -
GPL/trunk/lib32/irq.c
r63 r76 45 45 46 46 static IRQ_SLOT arSlots[MAX_IRQ_SLOTS] = { 0 }; 47 static ULONG eoiIrq[255] = {0}; 47 48 48 49 … … 51 52 static IRQ_SLOT *FindSlot(unsigned irq) 52 53 { 53 IRQ_SLOT *pSlot;54 55 for( pSlot = arSlots; pSlot != &arSlots[MAX_IRQ_SLOTS]; pSlot++ )56 {57 if( pSlot->irqNo == irq ) return pSlot;58 }59 60 return NULL;54 IRQ_SLOT *pSlot; 55 56 for( pSlot = arSlots; pSlot != &arSlots[MAX_IRQ_SLOTS]; pSlot++ ) 57 { 58 if( pSlot->irqNo == irq ) return pSlot; 59 } 60 61 return NULL; 61 62 } 62 63 … … 71 72 IRQ_SLOT *pSlot = FindSlot(irq); 72 73 unsigned u, uSlotNo = (unsigned)-1; 73 if( !pSlot )74 {75 // find empty slot76 for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ )77 {78 if( arSlots[uSlotNo].flHandlers == 0 )79 {80 81 }82 }83 84 } 85 86 if( pSlot )87 {88 if(RMRequestIRQ(/*hResMgr,*/ irq, (x0 & SA_SHIRQ) != 0) == FALSE) {89 90 // return 0;91 }92 93 for( u = 0; u < MAX_SHAREDIRQS; u++ )94 {95 if( pSlot->irqHandlers[u].handler == NULL )96 {97 pSlot->irqNo = irq;98 99 100 101 102 103 104 74 if( !pSlot ) 75 { 76 // find empty slot 77 for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ ) 78 { 79 if( arSlots[uSlotNo].flHandlers == 0 ) 80 { 81 pSlot = &arSlots[uSlotNo]; break; 82 } 83 } 84 85 } 86 87 if( pSlot ) 88 { 89 if(RMRequestIRQ(/*hResMgr,*/ irq, (x0 & SA_SHIRQ) != 0) == FALSE) { 90 dprintf(("RMRequestIRQ failed for irq %d", irq)); 91 // return 0; 92 } 93 94 for( u = 0; u < MAX_SHAREDIRQS; u++ ) 95 { 96 if( pSlot->irqHandlers[u].handler == NULL ) 97 { 98 pSlot->irqNo = irq; 99 pSlot->irqHandlers[u].handler = handler; 100 pSlot->irqHandlers[u].x0 = x0; 101 pSlot->irqHandlers[u].x1 = (char *)x1; 102 pSlot->irqHandlers[u].x2 = x2; 103 104 if( pSlot->flHandlers != 0 || 105 ALSA_SetIrq(irq, uSlotNo, (x0 & SA_SHIRQ) != 0) ) 105 106 { 106 107 107 pSlot->flHandlers |= 1 << u; 108 return 0; 108 109 } 109 110 110 111 } 112 } 113 } 114 115 dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));111 break; 112 } 113 } 114 } 115 116 dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq)); 116 117 return 1; 117 118 } … … 122 123 void free_irq(unsigned int irq, void *userdata) 123 124 { 124 unsigned u;125 IRQ_SLOT *pSlot;126 127 if( (pSlot = FindSlot(irq)) != NULL )128 {129 for( u = 0; u < MAX_SHAREDIRQS; u++ )130 {131 if( pSlot->irqHandlers[u].x2 == userdata )132 {133 134 135 136 137 138 // pSlot->fEOI = 0;139 }140 141 142 143 144 145 146 147 148 }149 }150 }125 unsigned u; 126 IRQ_SLOT *pSlot; 127 128 if( (pSlot = FindSlot(irq)) != NULL ) 129 { 130 for( u = 0; u < MAX_SHAREDIRQS; u++ ) 131 { 132 if( pSlot->irqHandlers[u].x2 == userdata ) 133 { 134 pSlot->flHandlers &= ~(1 << u); 135 if( pSlot->flHandlers == 0 ) 136 { 137 ALSA_FreeIrq(pSlot->irqNo); 138 pSlot->irqNo = 0; 139 // pSlot->fEOI = 0; 140 } 141 142 pSlot->irqHandlers[u].handler = NULL; 143 pSlot->irqHandlers[u].x0 = 0; 144 pSlot->irqHandlers[u].x1 = NULL; 145 pSlot->irqHandlers[u].x2 = NULL; 146 147 return; 148 149 } 150 } 151 } 151 152 } 152 153 … … 156 157 void eoi_irq(unsigned int irq) 157 158 { 158 (void)irq; 159 /* 160 IRQ_SLOT *pSlot = FindSlot(irq); 161 162 if( pSlot ) pSlot->fEOI = 1; 163 */ 159 /*(void)irq; */ 160 /* 161 IRQ_SLOT *pSlot = FindSlot(irq); 162 163 if( pSlot ) pSlot->fEOI = 1; 164 */ 165 eoiIrq[irq]++; 164 166 } 165 167 … … 169 171 BOOL process_interrupt(ULONG ulSlotNo, ULONG *pulIrq) 170 172 { 171 unsigned u;172 int rc;173 IRQ_SLOT *pSlot;174 175 #ifdef DEBUG 176 // dprintf(("int proc"));177 #endif 178 179 if(fSuspended) 173 unsigned u; 174 int rc; 175 IRQ_SLOT *pSlot; 176 177 #ifdef DEBUG 178 dprintf(("enter int proc %d %d",ulSlotNo, *pulIrq)); 179 #endif 180 181 if(fSuspended) 180 182 {//If our device is suspended, then we can't receive interrupts, so it must 181 //be for some other device182 //Don't pass it to the linux handler as the device doesn't respond as expected183 //be for some other device 184 //Don't pass it to the linux handler as the device doesn't respond as expected 183 185 //when suspended 184 186 #ifdef DEBUG 185 dprintf((" IRQ %d suspended",irq));187 dprintf(("Slot %d IRQ %d suspended",ulSlotNo, *pulIrq)); 186 188 #endif 187 189 return FALSE; 188 190 } 189 191 190 if( ulSlotNo < MAX_IRQ_SLOTS ) 191 { 192 pSlot = &arSlots[ulSlotNo]; 193 194 for( u = 0; u < MAX_SHAREDIRQS; u++ ) 195 { 196 if( pSlot->irqHandlers[u].handler ) 197 { 198 fInInterrupt = TRUE; 199 rc = pSlot->irqHandlers[u].handler(pSlot->irqNo, 200 pSlot->irqHandlers[u].x2, 0); 201 fInInterrupt = FALSE; 202 203 if( rc /*== 1 || pSlot->fEOI*/ ) { 204 205 *pulIrq = pSlot->irqNo; 206 // pSlot->fEOI = 0; 207 208 //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver 209 OSS32_ProcessIRQ(); 210 return TRUE; 211 } 212 } 213 } 214 } 192 if( ulSlotNo < MAX_IRQ_SLOTS ) 193 { 194 pSlot = &arSlots[ulSlotNo]; 195 196 for( u = 0; u < MAX_SHAREDIRQS; u++ ) 197 { 198 if(pSlot && pSlot->irqHandlers[u].handler ) 199 { 200 fInInterrupt = TRUE; 201 rc = pSlot->irqHandlers[u].handler(pSlot->irqNo, 202 pSlot->irqHandlers[u].x2, 0); 203 if (rc == 1) eoi_irq(pSlot->irqNo); 204 rc = (eoiIrq[pSlot->irqNo] > 0); 205 fInInterrupt = FALSE; 206 207 if( rc /*== 1 || pSlot->fEOI*/ ) { 208 209 *pulIrq = pSlot->irqNo; 210 // pSlot->fEOI = 0; 211 212 //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver 213 OSS32_ProcessIRQ(); 214 #ifdef DEBUG 215 dprintf(("exit(1) int proc %d %d",ulSlotNo, *pulIrq)); 216 #endif 217 eoiIrq[pSlot->irqNo] = 0; 218 return TRUE; 219 } 220 } 221 } 222 } 223 #ifdef DEBUG 224 dprintf(("exit(0) int proc %d %d",ulSlotNo, *pulIrq)); 225 #endif 215 226 216 227 return FALSE; … … 236 247 //****************************************************************************** 237 248 238 239 -
GPL/trunk/lib32/memory.cpp
r32 r76 195 195 if (rc == 0) { 196 196 *pAddr = (LINEAR)addr; 197 if (flags & VMDHA_USEHIGHMEM) 198 dprintf(("allocated %X in HIGH memory"), size); 199 else dprintf(("allocated %X in LOW memory"), size); 197 200 } 198 201 if ((rc == 87) && -
GPL/trunk/lib32/ossidc.cpp
r34 r76 268 268 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_ca0106_exit); 269 269 } 270 if((ForceCard == CARD_NONE || ForceCard == CARD_AZX) && 271 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_azx_init) == 0) 272 { 273 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_azx_exit); 274 } 270 275 if((ForceCard == CARD_NONE || ForceCard == CARD_BT87X) && 271 276 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_bt87x_init) == 0) … … 273 278 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_bt87x_exit); 274 279 } 275 if((ForceCard == CARD_NONE || ForceCard == CARD_AZX) && 276 nrCardsDetected < (OSS32_MAX_AUDIOCARDS-1) && call_module_init(alsa_card_azx_init) == 0) 277 { 278 fnCardExitCall[nrCardsDetected] = name_module_exit(alsa_card_azx_exit); 279 } 280 280 281 #endif 281 282 fStrategyInit = FALSE; -
GPL/trunk/lib32/pci.c
r75 r76 465 465 466 466 // create adapter 467 RMDone((driver->id_table[i]. vendor << 16) | driver->id_table[i].device);467 RMDone((driver->id_table[i].device << 16) | driver->id_table[i].vendor); 468 468 nrCardsDetected++; 469 469 return 1; -
GPL/trunk/lib32/sound.c
r34 r76 775 775 return OSSERR_INVALID_PARAMETER; 776 776 } 777 777 tryagain: 778 778 //set operation to non-blocking 779 779 pHandle->file.f_flags = O_NONBLOCK; … … 950 950 //initialize parameter block & set sample rate, nr of channels and sample format, nr of periods, 951 951 //period size and buffer size 952 tryagain:952 //tryagain: 953 953 _snd_pcm_hw_params_any(¶ms); 954 954 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, -
GPL/trunk/lib32/stack.cpp
r32 r76 77 77 //allocate our private stack 78 78 rc = DevVMAlloc(VMDHA_USEHIGHMEM|VMDHA_FIXED|VMDHL_CONTIGUOUS, TOTAL_STACKSIZE, (LINEAR)-1, (LINEAR)&StackBase); 79 79 80 if(rc) { 80 DebugInt3(); 81 return 0; 81 if (rc == 87) 82 { 83 rc = DevVMAlloc(VMDHA_FIXED|VMDHL_CONTIGUOUS, TOTAL_STACKSIZE, (LINEAR)-1, (LINEAR)&StackBase); 84 } 85 if (rc) 86 { 87 DebugInt3(); 88 return 0; 89 } 82 90 } 83 91 Ring0Stack[0].addr = StackBase; -
GPL/trunk/lib32/timer.c
r32 r76 94 94 void do_gettimeofday(struct timeval *tv) 95 95 { 96 #if 0 96 97 tv->tv_sec = 0; //os2gettimesec(); 97 98 tv->tv_usec = os2gettimemsec() * 1000; 99 #else /* r.ihle patch */ 100 unsigned u = os2gettimemsec(); 101 tv->tv_sec = u / 1000; 102 tv->tv_usec = (u % 1000) * 1000; 103 #endif 98 104 } 99 105 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.