Changeset 84 for GPL/trunk/alsa-kernel/pci/emu10k1/emufx.c
- Timestamp:
- Oct 23, 2006, 11:07:11 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/pci/emu10k1/emufx.c
r34 r84 3 3 * Creative Labs, Inc. 4 4 * Routines for effect processor FX8010 5 * 6 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk> 7 * Added EMU 1010 support. 5 8 * 6 9 * BUGS: … … 29 32 #include <linux/delay.h> 30 33 #include <linux/slab.h> 34 31 35 #include <sound/core.h> 36 #include <sound/tlv.h> 32 37 #include <sound/emu10k1.h> 33 34 38 35 39 #if 0 /* for testing purposes - digital out -> capture */ … … 262 266 }; 263 267 268 /* dB gain = (float) 20 * log10( float(db_table_value) / 0x8000000 ) */ 264 269 static const u32 db_table[101] = { 265 270 0x00000000, 0x01571f82, 0x01674b41, 0x01783a1b, 0x0189f540, … … 286 291 }; 287 292 293 /* EMU10k1/EMU10k2 DSP control db gain */ 294 static DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1); 295 288 296 static const u32 onoff_table[2] = { 289 297 0x00000000, 0x00000001 … … 310 318 */ 311 319 312 static int snd_emu10k1_gpr_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 313 { 314 struct snd_emu10k1_fx8010_ctl *ctl = (struct snd_emu10k1_fx8010_ctl *)kcontrol->private_value; 320 static int snd_emu10k1_gpr_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 321 { 322 struct snd_emu10k1_fx8010_ctl *ctl = 323 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; 315 324 316 325 if (ctl->min == 0 && ctl->max == 1) … … 324 333 } 325 334 326 static int snd_emu10k1_gpr_ctl_get(s nd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)335 static int snd_emu10k1_gpr_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 327 336 { 328 337 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 329 struct snd_emu10k1_fx8010_ctl *ctl = (struct snd_emu10k1_fx8010_ctl *)kcontrol->private_value; 338 struct snd_emu10k1_fx8010_ctl *ctl = 339 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; 330 340 unsigned long flags; 331 341 unsigned int i; … … 338 348 } 339 349 340 static int snd_emu10k1_gpr_ctl_put(s nd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)350 static int snd_emu10k1_gpr_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 341 351 { 342 352 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 343 struct snd_emu10k1_fx8010_ctl *ctl = (struct snd_emu10k1_fx8010_ctl *)kcontrol->private_value; 353 struct snd_emu10k1_fx8010_ctl *ctl = 354 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; 344 355 unsigned long flags; 345 356 unsigned int nval, val; … … 365 376 break; 366 377 case EMU10K1_GPR_TRANSLATION_BASS: 367 snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); 378 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { 379 change = -EIO; 380 goto __error; 381 } 368 382 for (j = 0; j < 5; j++) 369 383 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]); 370 384 break; 371 385 case EMU10K1_GPR_TRANSLATION_TREBLE: 372 snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); 386 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { 387 change = -EIO; 388 goto __error; 389 } 373 390 for (j = 0; j < 5; j++) 374 391 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]); … … 413 430 unsigned long flags; 414 431 415 snd_runtime_check(emu, return -EINVAL);416 snd_runtime_check(handler, return -EINVAL);417 432 irq = kmalloc(sizeof(*irq), GFP_ATOMIC); 418 433 if (irq == NULL) … … 443 458 unsigned long flags; 444 459 445 snd_runtime_check(irq, return -EINVAL);446 460 spin_lock_irqsave(&emu->fx8010.irq_lock, flags); 447 461 if ((tmp = emu->fx8010.irq_handlers) == irq) { … … 466 480 *************************************************************************/ 467 481 468 static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr, 469 u32 op, u32 r, u32 a, u32 x, u32 y) 482 static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode, 483 unsigned int *ptr, 484 u32 op, u32 r, u32 a, u32 x, u32 y) 470 485 { 471 486 u_int32_t *code; 472 487 snd_assert(*ptr < 512, return); 473 code = (u_int32_t *)icode->code + (*ptr) * 2;488 code = (u_int32_t __force *)icode->code + (*ptr) * 2; 474 489 set_bit(*ptr, icode->code_valid); 475 490 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); … … 481 496 snd_emu10k1_write_op(icode, ptr, op, r, a, x, y) 482 497 483 static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr, 484 u32 op, u32 r, u32 a, u32 x, u32 y) 498 static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode, 499 unsigned int *ptr, 500 u32 op, u32 r, u32 a, u32 x, u32 y) 485 501 { 486 502 u_int32_t *code; 487 503 snd_assert(*ptr < 1024, return); 488 code = (u_int32_t *)icode->code + (*ptr) * 2;504 code = (u_int32_t __force *)icode->code + (*ptr) * 2; 489 505 set_bit(*ptr, icode->code_valid); 490 506 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); … … 496 512 snd_emu10k1_audigy_write_op(icode, ptr, op, r, a, x, y) 497 513 498 void snd_emu10k1_efx_write(struct snd_emu10k1 *emu, unsigned int pc, unsigned int data)514 static void snd_emu10k1_efx_write(struct snd_emu10k1 *emu, unsigned int pc, unsigned int data) 499 515 { 500 516 pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; … … 508 524 } 509 525 510 static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 526 static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, 527 struct snd_emu10k1_fx8010_code *icode) 511 528 { 512 529 int gpr; … … 523 540 } 524 541 525 static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 542 static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu, 543 struct snd_emu10k1_fx8010_code *icode) 526 544 { 527 545 int gpr; … … 537 555 } 538 556 539 static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 557 static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, 558 struct snd_emu10k1_fx8010_code *icode) 540 559 { 541 560 int tram; … … 559 578 } 560 579 561 static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 580 static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu, 581 struct snd_emu10k1_fx8010_code *icode) 562 582 { 563 583 int tram; … … 581 601 } 582 602 583 static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 603 static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, 604 struct snd_emu10k1_fx8010_code *icode) 584 605 { 585 606 u32 pc, lo, hi; … … 597 618 } 598 619 599 static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 620 static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, 621 struct snd_emu10k1_fx8010_code *icode) 600 622 { 601 623 u32 pc; … … 612 634 } 613 635 614 static struct snd_emu10k1_fx8010_ctl *snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, snd_ctl_elem_id_t *id) 636 static struct snd_emu10k1_fx8010_ctl * 637 snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id) 615 638 { 616 639 struct snd_emu10k1_fx8010_ctl *ctl; 617 s nd_kcontrol_t*kcontrol;640 struct snd_kcontrol *kcontrol; 618 641 struct list_head *list; 619 642 … … 629 652 } 630 653 631 static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 654 static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, 655 struct snd_emu10k1_fx8010_code *icode) 632 656 { 633 657 unsigned int i; 634 snd_ctl_elem_id_t *_id, id; 635 emu10k1_fx8010_control_gpr_t *_gctl; 636 emu10k1_fx8010_control_gpr_t *gctl; 658 struct snd_ctl_elem_id __user *_id; 659 struct snd_ctl_elem_id id; 660 struct snd_emu10k1_fx8010_control_gpr __user *_gctl; 661 struct snd_emu10k1_fx8010_control_gpr *gctl; 637 662 int err; 638 663 … … 682 707 } 683 708 684 static void snd_emu10k1_ctl_private_free(s nd_kcontrol_t*kctl)709 static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl) 685 710 { 686 711 struct snd_emu10k1_fx8010_ctl *ctl; … … 692 717 } 693 718 694 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 719 static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, 720 struct snd_emu10k1_fx8010_code *icode) 695 721 { 696 722 unsigned int i, j; 697 emu10k1_fx8010_control_gpr_t*_gctl;698 emu10k1_fx8010_control_gpr_t*gctl;723 struct snd_emu10k1_fx8010_control_gpr __user *_gctl; 724 struct snd_emu10k1_fx8010_control_gpr *gctl; 699 725 struct snd_emu10k1_fx8010_ctl *ctl, *nctl; 700 s nd_kcontrol_new_tknew;701 s nd_kcontrol_t*kctl;702 s nd_ctl_elem_value_t*val;726 struct snd_kcontrol_new knew; 727 struct snd_kcontrol *kctl; 728 struct snd_ctl_elem_value *val; 703 729 int err = 0; 704 730 705 val = (snd_ctl_elem_value_t *)kmalloc(sizeof(*val), GFP_KERNEL);731 val = kmalloc(sizeof(*val), GFP_KERNEL); 706 732 gctl = kmalloc(sizeof(*gctl), GFP_KERNEL); 707 733 nctl = kmalloc(sizeof(*nctl), GFP_KERNEL); … … 717 743 goto __error; 718 744 } 719 snd_runtime_check(gctl->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER || 720 gctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM, err = -EINVAL; goto __error); 721 snd_runtime_check(gctl->id.name[0] != '\0', err = -EINVAL; goto __error); 745 if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && 746 gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { 747 err = -EINVAL; 748 goto __error; 749 } 750 if (! gctl->id.name[0]) { 751 err = -EINVAL; 752 goto __error; 753 } 722 754 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); 723 755 memset(&knew, 0, sizeof(knew)); … … 728 760 knew.subdevice = gctl->id.subdevice; 729 761 knew.info = snd_emu10k1_gpr_ctl_info; 762 if (gctl->tlv.p) { 763 knew.tlv.p = gctl->tlv.p; 764 knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 765 SNDRV_CTL_ELEM_ACCESS_TLV_READ; 766 } 730 767 knew.get = snd_emu10k1_gpr_ctl_get; 731 768 knew.put = snd_emu10k1_gpr_ctl_put; … … 742 779 nctl->translation = gctl->translation; 743 780 if (ctl == NULL) { 744 ctl = (struct snd_emu10k1_fx8010_ctl *)kmalloc(sizeof(*ctl), GFP_KERNEL);781 ctl = kmalloc(sizeof(*ctl), GFP_KERNEL); 745 782 if (ctl == NULL) { 746 783 err = -ENOMEM; … … 773 810 } 774 811 775 static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 812 static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, 813 struct snd_emu10k1_fx8010_code *icode) 776 814 { 777 815 unsigned int i; 778 snd_ctl_elem_id_t *_id, id; 816 struct snd_ctl_elem_id id; 817 struct snd_ctl_elem_id __user *_id; 779 818 struct snd_emu10k1_fx8010_ctl *ctl; 780 s nd_card_t*card = emu->card;819 struct snd_card *card = emu->card; 781 820 782 821 for (i = 0, _id = icode->gpr_del_controls; 783 822 i < icode->gpr_del_control_count; i++, _id++) { 784 snd_runtime_check(copy_from_user(&id, _id, sizeof(id)) == 0, return -EFAULT); 823 if (copy_from_user(&id, _id, sizeof(id))) 824 return -EFAULT; 785 825 down_write(&card->controls_rwsem); 786 826 ctl = snd_emu10k1_look_for_ctl(emu, &id); … … 792 832 } 793 833 794 static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 834 static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu, 835 struct snd_emu10k1_fx8010_code *icode) 795 836 { 796 837 unsigned int i = 0, j; 797 838 unsigned int total = 0; 798 emu10k1_fx8010_control_gpr_t*gctl;799 emu10k1_fx8010_control_gpr_t*_gctl;839 struct snd_emu10k1_fx8010_control_gpr *gctl; 840 struct snd_emu10k1_fx8010_control_gpr __user *_gctl; 800 841 struct snd_emu10k1_fx8010_ctl *ctl; 801 s nd_ctl_elem_id_t*id;842 struct snd_ctl_elem_id *id; 802 843 struct list_head *list; 803 844 … … 840 881 } 841 882 842 static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 883 static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, 884 struct snd_emu10k1_fx8010_code *icode) 843 885 { 844 886 int err = 0; … … 871 913 } 872 914 873 static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_code_t *icode) 915 static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, 916 struct snd_emu10k1_fx8010_code *icode) 874 917 { 875 918 int err; … … 889 932 } 890 933 891 static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, emu10k1_fx8010_pcm_t *ipcm) 934 static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, 935 struct snd_emu10k1_fx8010_pcm_rec *ipcm) 892 936 { 893 937 unsigned int i; … … 934 978 } 935 979 936 static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, emu10k1_fx8010_pcm_t *ipcm) 980 static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, 981 struct snd_emu10k1_fx8010_pcm_rec *ipcm) 937 982 { 938 983 unsigned int i; … … 968 1013 #define SND_EMU10K1_CAPTURE_CHANNELS 4 969 1014 970 static void __devinit snd_emu10k1_init_mono_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) 1015 static void __devinit 1016 snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1017 const char *name, int gpr, int defval) 971 1018 { 972 1019 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; … … 976 1023 ctl->min = 0; 977 1024 ctl->max = 100; 1025 ctl->tlv.p = snd_emu10k1_db_scale1; 978 1026 ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; 979 1027 } 980 1028 981 static void __devinit snd_emu10k1_init_stereo_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) 1029 static void __devinit 1030 snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1031 const char *name, int gpr, int defval) 982 1032 { 983 1033 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; … … 988 1038 ctl->min = 0; 989 1039 ctl->max = 100; 1040 ctl->tlv.p = snd_emu10k1_db_scale1; 990 1041 ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; 991 1042 } 992 1043 993 static void __devinit snd_emu10k1_init_mono_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) 1044 static void __devinit 1045 snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1046 const char *name, int gpr, int defval) 994 1047 { 995 1048 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; … … 1002 1055 } 1003 1056 1004 static void __devinit snd_emu10k1_init_stereo_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) 1057 static void __devinit 1058 snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, 1059 const char *name, int gpr, int defval) 1005 1060 { 1006 1061 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; … … 1014 1069 } 1015 1070 1071 static int snd_emu10k1_audigy_dsp_convert_32_to_2x16( 1072 struct snd_emu10k1_fx8010_code *icode, 1073 u32 *ptr, int tmp, int bit_shifter16, 1074 int reg_in, int reg_out) 1075 { 1076 A_OP(icode, ptr, iACC3, A_GPR(tmp + 1), reg_in, A_C_00000000, A_C_00000000); 1077 A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp + 1), A_GPR(bit_shifter16 - 1), A_C_00000000); 1078 A_OP(icode, ptr, iTSTNEG, A_GPR(tmp + 2), A_GPR(tmp), A_C_80000000, A_GPR(bit_shifter16 - 2)); 1079 A_OP(icode, ptr, iANDXOR, A_GPR(tmp + 2), A_GPR(tmp + 2), A_C_80000000, A_C_00000000); 1080 A_OP(icode, ptr, iANDXOR, A_GPR(tmp), A_GPR(tmp), A_GPR(bit_shifter16 - 3), A_C_00000000); 1081 A_OP(icode, ptr, iMACINT0, A_GPR(tmp), A_C_00000000, A_GPR(tmp), A_C_00010000); 1082 A_OP(icode, ptr, iANDXOR, reg_out, A_GPR(tmp), A_C_ffffffff, A_GPR(tmp + 2)); 1083 A_OP(icode, ptr, iACC3, reg_out + 1, A_GPR(tmp + 1), A_C_00000000, A_C_00000000); 1084 return 1; 1085 } 1016 1086 1017 1087 /* … … 1022 1092 { 1023 1093 int err, i, z, gpr, nctl; 1094 int bit_shifter16; 1024 1095 const int playback = 10; 1025 1096 const int capture = playback + (SND_EMU10K1_PLAYBACK_CHANNELS * 2); /* we reserve 10 voices */ … … 1027 1098 const int tmp = 0x88; 1028 1099 u32 ptr; 1029 emu10k1_fx8010_code_t*icode = NULL;1030 emu10k1_fx8010_control_gpr_t*controls = NULL, *ctl;1100 struct snd_emu10k1_fx8010_code *icode = NULL; 1101 struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; 1031 1102 u32 *gpr_map; 1032 1103 mm_segment_t seg; 1033 1104 1034 spin_lock_init(&emu->fx8010.irq_lock);1035 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl);1036 1037 if ((icode = (emu10k1_fx8010_code_t *)kzalloc(sizeof(*icode),GFP_KERNEL)) == NULL ||1038 ( icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL ||1039 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,sizeof(*controls), GFP_KERNEL)) == NULL) {1105 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || 1106 (icode->gpr_map = (u_int32_t __user *) 1107 kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), 1108 GFP_KERNEL)) == NULL || 1109 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1110 sizeof(*controls), GFP_KERNEL)) == NULL) { 1040 1111 err = -ENOMEM; 1041 1112 goto __err; 1042 1113 } 1043 gpr_map = (u32 *)icode->gpr_map;1114 gpr_map = (u32 __force *)icode->gpr_map; 1044 1115 1045 1116 icode->tram_data_map = icode->gpr_map + 512; … … 1059 1130 nctl = 0; 1060 1131 gpr = stereo_mix + 10; 1132 gpr_map[gpr++] = 0x00007fff; 1133 gpr_map[gpr++] = 0x00008000; 1134 gpr_map[gpr++] = 0x0000ffff; 1135 bit_shifter16 = gpr; 1061 1136 1062 1137 /* stop FX processor */ 1063 1138 snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); 1064 1139 1140 #if 1 1065 1141 /* PCM front Playback Volume (independent from stereo mix) */ 1066 1142 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT)); … … 1102 1178 gpr += 2; 1103 1179 1104 /* MusicPlayback */1180 /* Synth Playback */ 1105 1181 A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+0), A_GPR(stereo_mix+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT)); 1106 1182 A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+1), A_GPR(stereo_mix+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT)); 1107 snd_emu10k1_init_stereo_control(&controls[nctl++], " MusicPlayback Volume", gpr, 100);1183 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Playback Volume", gpr, 100); 1108 1184 gpr += 2; 1109 1185 … … 1114 1190 gpr += 2; 1115 1191 1116 /* MusicCapture */1192 /* Synth Capture */ 1117 1193 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT)); 1118 1194 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT)); 1119 snd_emu10k1_init_stereo_control(&controls[nctl++], " MusicCapture Volume", gpr, 0);1195 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0); 1120 1196 gpr += 2; 1121 1197 … … 1126 1202 A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) 1127 1203 1128 /* AC'97 Playback Volume - used only for mic */ 1204 /* emu1212 DSP 0 and DSP 1 Capture */ 1205 if (emu->card_capabilities->emu1010) { 1206 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_P16VIN(0x0)); 1207 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_P16VIN(0x1)); 1208 snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0); 1209 gpr += 2; 1210 } 1211 /* AC'97 Playback Volume - used only for mic (renamed later) */ 1129 1212 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AC97_L); 1130 1213 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AC97_R); … … 1158 1241 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_OPT_SPDIF_L); 1159 1242 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_OPT_SPDIF_R); 1160 snd_emu10k1_init_stereo_control(&controls[nctl++], "IEC958 Optical Playback Volume", gpr, 0);1243 snd_emu10k1_init_stereo_control(&controls[nctl++], SNDRV_CTL_NAME_IEC958("Optical ",PLAYBACK,VOLUME), gpr, 0); 1161 1244 gpr += 2; 1162 1245 /* Optical SPDIF Capture Volume */ 1163 1246 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_OPT_SPDIF_L); 1164 1247 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_OPT_SPDIF_R); 1165 snd_emu10k1_init_stereo_control(&controls[nctl++], "IEC958 Optical Capture Volume", gpr, 0);1248 snd_emu10k1_init_stereo_control(&controls[nctl++], SNDRV_CTL_NAME_IEC958("Optical ",CAPTURE,VOLUME), gpr, 0); 1166 1249 gpr += 2; 1167 1250 … … 1265 1348 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 4), A_GPR(playback + 4), A_C_00000000, A_C_00000000); /* center */ 1266 1349 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), A_GPR(playback + 5), A_C_00000000, A_C_00000000); /* LFE */ 1267 1268 1350 if (emu->card_capabilities->spk71) { 1269 1351 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 6), A_GPR(playback + 6), A_C_00000000, A_C_00000000); /* side left */ 1270 1352 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 7), A_GPR(playback + 7), A_C_00000000, A_C_00000000); /* side right */ 1271 1353 } 1354 1272 1355 1273 1356 ctl = &controls[nctl + 0]; … … 1350 1433 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+6+SND_EMU10K1_PLAYBACK_CHANNELS)); 1351 1434 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+7+SND_EMU10K1_PLAYBACK_CHANNELS)); 1352 snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0); 1353 //snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0); 1435 snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0); 1354 1436 gpr += 2; 1355 1437 … … 1359 1441 A_PUT_OUTPUT(A_EXTOUT_ACENTER, playback+4 + SND_EMU10K1_PLAYBACK_CHANNELS); 1360 1442 A_PUT_OUTPUT(A_EXTOUT_ALFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS); 1361 1362 1443 if (emu->card_capabilities->spk71) 1363 1444 A_PUT_STEREO_OUTPUT(A_EXTOUT_ASIDE_L, A_EXTOUT_ASIDE_R, playback+6 + SND_EMU10K1_PLAYBACK_CHANNELS); … … 1368 1449 /* digital outputs */ 1369 1450 /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */ 1451 if (emu->card_capabilities->emu1010) { 1452 /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */ 1453 snd_printk("EMU outputs on\n"); 1454 for (z = 0; z < 8; z++) { 1455 A_OP(icode, &ptr, iACC3, A_EMU32OUTL(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000); 1456 } 1457 } 1370 1458 1371 1459 /* IEC958 Optical Raw Playback Switch */ … … 1390 1478 } 1391 1479 } 1392 snd_emu10k1_init_stereo_onoff_control(controls + nctl++, "IEC958 Optical Raw Playback Switch", gpr, 0);1480 snd_emu10k1_init_stereo_onoff_control(controls + nctl++, SNDRV_CTL_NAME_IEC958("Optical Raw ",PLAYBACK,SWITCH), gpr, 0); 1393 1481 gpr += 2; 1394 1482 … … 1398 1486 1399 1487 /* ADC buffer */ 1488 #ifdef EMU10K1_CAPTURE_DIGITAL_OUT 1489 A_PUT_STEREO_OUTPUT(A_EXTOUT_ADC_CAP_L, A_EXTOUT_ADC_CAP_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); 1490 #else 1400 1491 A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_L, capture); 1401 1492 A_PUT_OUTPUT(A_EXTOUT_ADC_CAP_R, capture+1); 1402 1403 /* EFX capture - capture the 16 EXTINs */ 1404 for (z = 0; z < 16; z++) { 1405 A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z)); 1406 } 1407 1493 #endif 1494 1495 if (emu->card_capabilities->emu1010) { 1496 snd_printk("EMU inputs on\n"); 1497 /* Capture 8 channels of S32_LE sound */ 1498 1499 /* printk("emufx.c: gpr=0x%x, tmp=0x%x\n",gpr, tmp); */ 1500 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */ 1501 /* A_P16VIN(0) is delayed by one sample, 1502 * so all other A_P16VIN channels will need to also be delayed 1503 */ 1504 /* Left ADC in. 1 of 2 */ 1505 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) ); 1506 /* Right ADC in 1 of 2 */ 1507 gpr_map[gpr++] = 0x00000000; 1508 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) ); 1509 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000); 1510 gpr_map[gpr++] = 0x00000000; 1511 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(4) ); 1512 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x2), A_C_00000000, A_C_00000000); 1513 gpr_map[gpr++] = 0x00000000; 1514 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(6) ); 1515 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x3), A_C_00000000, A_C_00000000); 1516 /* For 96kHz mode */ 1517 /* Left ADC in. 2 of 2 */ 1518 gpr_map[gpr++] = 0x00000000; 1519 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0x8) ); 1520 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x4), A_C_00000000, A_C_00000000); 1521 /* Right ADC in 2 of 2 */ 1522 gpr_map[gpr++] = 0x00000000; 1523 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xa) ); 1524 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x5), A_C_00000000, A_C_00000000); 1525 gpr_map[gpr++] = 0x00000000; 1526 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xc) ); 1527 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x6), A_C_00000000, A_C_00000000); 1528 gpr_map[gpr++] = 0x00000000; 1529 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) ); 1530 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000); 1531 1532 #if 0 1533 for (z = 4; z < 8; z++) { 1534 A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000); 1535 } 1536 for (z = 0xc; z < 0x10; z++) { 1537 A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_C_00000000); 1538 } 1539 #endif 1540 } else { 1541 1542 /* EFX capture - capture the 16 EXTINs */ 1543 /* Capture 16 channels of S16_LE sound */ 1544 for (z = 0; z < 16; z++) { 1545 A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z)); 1546 } 1547 } 1548 1549 #endif /* JCD test */ 1408 1550 /* 1409 1551 * ok, set up done.. … … 1421 1563 seg = snd_enter_user(); 1422 1564 icode->gpr_add_control_count = nctl; 1423 icode->gpr_add_controls = ( emu10k1_fx8010_control_gpr_t__user *)controls;1565 icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; 1424 1566 err = snd_emu10k1_icode_poke(emu, icode); 1425 1567 snd_leave_user(seg); … … 1428 1570 kfree(controls); 1429 1571 if (icode != NULL) { 1430 kfree((void *)icode->gpr_map);1572 kfree((void __force *)icode->gpr_map); 1431 1573 kfree(icode); 1432 1574 } … … 1441 1583 /* when volume = max, then copy only to avoid volume modification */ 1442 1584 /* with iMAC0 (negative values) */ 1443 static void __devinit _volume( emu10k1_fx8010_code_t*icode, u32 *ptr, u32 dst, u32 src, u32 vol)1585 static void __devinit _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) 1444 1586 { 1445 1587 OP(icode, ptr, iMAC0, dst, C_00000000, src, vol); … … 1448 1590 OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000); 1449 1591 } 1450 static void __devinit _volume_add( emu10k1_fx8010_code_t*icode, u32 *ptr, u32 dst, u32 src, u32 vol)1592 static void __devinit _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) 1451 1593 { 1452 1594 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); … … 1456 1598 OP(icode, ptr, iMAC0, dst, dst, src, vol); 1457 1599 } 1458 static void __devinit _volume_out( emu10k1_fx8010_code_t*icode, u32 *ptr, u32 dst, u32 src, u32 vol)1600 static void __devinit _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) 1459 1601 { 1460 1602 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); … … 1491 1633 int err, i, z, gpr, tmp, playback, capture; 1492 1634 u32 ptr; 1493 emu10k1_fx8010_code_t*icode;1494 emu10k1_fx8010_pcm_t*ipcm = NULL;1495 emu10k1_fx8010_control_gpr_t*controls = NULL, *ctl;1635 struct snd_emu10k1_fx8010_code *icode; 1636 struct snd_emu10k1_fx8010_pcm_rec *ipcm = NULL; 1637 struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; 1496 1638 u32 *gpr_map; 1497 1639 mm_segment_t seg; 1498 1640 1499 spin_lock_init(&emu->fx8010.irq_lock); 1500 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); 1501 1502 if ((icode = (emu10k1_fx8010_code_t *)kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) 1641 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) 1503 1642 return -ENOMEM; 1504 if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL || 1505 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL || 1506 (ipcm = (emu10k1_fx8010_pcm_t *)kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { 1643 if ((icode->gpr_map = (u_int32_t __user *) 1644 kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), 1645 GFP_KERNEL)) == NULL || 1646 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1647 sizeof(struct snd_emu10k1_fx8010_control_gpr), 1648 GFP_KERNEL)) == NULL || 1649 (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { 1507 1650 err = -ENOMEM; 1508 1651 goto __err; 1509 1652 } 1510 gpr_map = (u32 *)icode->gpr_map;1653 gpr_map = (u32 __force *)icode->gpr_map; 1511 1654 1512 1655 icode->tram_data_map = icode->gpr_map + 256; … … 1565 1708 ipcm->etram[1] = 1; 1566 1709 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1710 gpr_map[gpr + 0] = 0xfffff000; 1711 gpr_map[gpr + 1] = 0xffff0000; 1712 gpr_map[gpr + 2] = 0x70000000; 1713 gpr_map[gpr + 3] = 0x00000007; 1714 gpr_map[gpr + 4] = 0x001f << 11; 1715 gpr_map[gpr + 5] = 0x001c << 11; 1716 gpr_map[gpr + 6] = (0x22 - 0x01) - 1; /* skip at 01 to 22 */ 1717 gpr_map[gpr + 7] = (0x22 - 0x06) - 1; /* skip at 06 to 22 */ 1718 gpr_map[gpr + 8] = 0x2000000 + (2<<11); 1719 gpr_map[gpr + 9] = 0x4000000 + (2<<11); 1720 gpr_map[gpr + 10] = 1<<11; 1721 gpr_map[gpr + 11] = (0x24 - 0x0a) - 1; /* skip at 0a to 24 */ 1722 gpr_map[gpr + 12] = 0; 1580 1723 1581 1724 /* if the trigger flag is not set, skip */ … … 1658 1801 gpr += 4; 1659 1802 1660 /* MusicPlayback Volume */1803 /* Synth Playback Volume */ 1661 1804 for (z = 0; z < 2; z++) 1662 1805 VOLUME_ADD(icode, &ptr, playback + z, 2 + z, gpr + z); 1663 snd_emu10k1_init_stereo_control(controls + i++, " MusicPlayback Volume", gpr, 100);1664 gpr += 2; 1665 1666 /* MusicCapture Volume + Switch */1806 snd_emu10k1_init_stereo_control(controls + i++, "Synth Playback Volume", gpr, 100); 1807 gpr += 2; 1808 1809 /* Synth Capture Volume + Switch */ 1667 1810 for (z = 0; z < 2; z++) { 1668 1811 SWITCH(icode, &ptr, tmp + 0, 2 + z, gpr + 2 + z); 1669 1812 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); 1670 1813 } 1671 snd_emu10k1_init_stereo_control(controls + i++, " MusicCapture Volume", gpr, 0);1672 snd_emu10k1_init_stereo_onoff_control(controls + i++, " MusicCapture Switch", gpr + 2, 0);1814 snd_emu10k1_init_stereo_control(controls + i++, "Synth Capture Volume", gpr, 0); 1815 snd_emu10k1_init_stereo_onoff_control(controls + i++, "Synth Capture Switch", gpr + 2, 0); 1673 1816 gpr += 4; 1674 1817 … … 1730 1873 for (z = 0; z < 2; z++) 1731 1874 VOLUME_ADDIN(icode, &ptr, playback + z, EXTIN_SPDIF_CD_L + z, gpr + z); 1732 snd_emu10k1_init_stereo_control(controls + i++, "IEC958 TTL Playback Volume", gpr, 0);1875 snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",PLAYBACK,VOLUME), gpr, 0); 1733 1876 gpr += 2; 1734 1877 … … 1738 1881 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); 1739 1882 } 1740 snd_emu10k1_init_stereo_control(controls + i++, "IEC958 TTL Capture Volume", gpr, 0);1741 snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 TTL Capture Switch", gpr + 2, 0);1883 snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",CAPTURE,VOLUME), gpr, 0); 1884 snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("TTL ",CAPTURE,SWITCH), gpr + 2, 0); 1742 1885 gpr += 4; 1743 1886 } … … 1764 1907 for (z = 0; z < 2; z++) 1765 1908 VOLUME_ADDIN(icode, &ptr, playback + z, EXTIN_TOSLINK_L + z, gpr + z); 1766 snd_emu10k1_init_stereo_control(controls + i++, "IEC958 LiveDrive Playback Volume", gpr, 0);1909 snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",PLAYBACK,VOLUME), gpr, 0); 1767 1910 gpr += 2; 1768 1911 … … 1772 1915 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); 1773 1916 } 1774 snd_emu10k1_init_stereo_control(controls + i++, "IEC958 LiveDrive Capture Volume", gpr, 0);1775 snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 LiveDrive Capture Switch", gpr + 2, 0);1917 snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",CAPTURE,VOLUME), gpr, 0); 1918 snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("LiveDrive ",CAPTURE,SWITCH), gpr + 2, 0); 1776 1919 gpr += 4; 1777 1920 } … … 1798 1941 for (z = 0; z < 2; z++) 1799 1942 VOLUME_ADDIN(icode, &ptr, playback + z, EXTIN_COAX_SPDIF_L + z, gpr + z); 1800 snd_emu10k1_init_stereo_control(controls + i++, "IEC958 Coaxial Playback Volume", gpr, 0);1943 snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",PLAYBACK,VOLUME), gpr, 0); 1801 1944 gpr += 2; 1802 1945 … … 1806 1949 VOLUME_ADD(icode, &ptr, capture + z, tmp + 0, gpr + z); 1807 1950 } 1808 snd_emu10k1_init_stereo_control(controls + i++, "IEC958 Coaxial Capture Volume", gpr, 0);1809 snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 Coaxial Capture Switch", gpr + 2, 0);1951 snd_emu10k1_init_stereo_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",CAPTURE,VOLUME), gpr, 0); 1952 snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("Coaxial ",CAPTURE,SWITCH), gpr + 2, 0); 1810 1953 gpr += 4; 1811 1954 } … … 1934 2077 } 1935 2078 1936 snd_emu10k1_init_stereo_onoff_control(controls + i++, "IEC958 Optical Raw Playback Switch", gpr, 0);2079 snd_emu10k1_init_stereo_onoff_control(controls + i++, SNDRV_CTL_NAME_IEC958("Optical Raw ",PLAYBACK,SWITCH), gpr, 0); 1937 2080 gpr += 2; 1938 2081 } … … 2035 2178 seg = snd_enter_user(); 2036 2179 icode->gpr_add_control_count = i; 2037 icode->gpr_add_controls = ( emu10k1_fx8010_control_gpr_t__user *)controls;2180 icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; 2038 2181 err = snd_emu10k1_icode_poke(emu, icode); 2039 2182 snd_leave_user(seg); … … 2044 2187 kfree(controls); 2045 2188 if (icode != NULL) { 2046 kfree((void *)icode->gpr_map);2189 kfree((void __force *)icode->gpr_map); 2047 2190 kfree(icode); 2048 2191 } … … 2052 2195 int __devinit snd_emu10k1_init_efx(struct snd_emu10k1 *emu) 2053 2196 { 2197 spin_lock_init(&emu->fx8010.irq_lock); 2198 INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); 2054 2199 if (emu->audigy) 2055 2200 return _snd_emu10k1_audigy_init_efx(emu); … … 2067 2212 } 2068 2213 2069 #if 0 / / FIXME: who use them?2214 #if 0 /* FIXME: who use them? */ 2070 2215 int snd_emu10k1_fx8010_tone_control_activate(struct snd_emu10k1 *emu, int output) 2071 2216 { 2072 snd_runtime_check(output >= 0 && output < 6, return -EINVAL); 2217 if (output < 0 || output >= 6) 2218 return -EINVAL; 2073 2219 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1); 2074 2220 return 0; … … 2077 2223 int snd_emu10k1_fx8010_tone_control_deactivate(struct snd_emu10k1 *emu, int output) 2078 2224 { 2079 snd_runtime_check(output >= 0 && output < 6, return -EINVAL); 2225 if (output < 0 || output >= 6) 2226 return -EINVAL; 2080 2227 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0); 2081 2228 return 0; … … 2097 2244 size = 0x2000 << size_reg; 2098 2245 } 2099 if ( emu->fx8010.etram_pages.bytes== size)2246 if ((emu->fx8010.etram_pages.bytes / 2) == size) 2100 2247 return 0; 2101 2248 spin_lock_irq(&emu->emu_lock); … … 2125 2272 } 2126 2273 2127 static int snd_emu10k1_fx8010_open(s nd_hwdep_t* hw, struct file *file)2274 static int snd_emu10k1_fx8010_open(struct snd_hwdep * hw, struct file *file) 2128 2275 { 2129 2276 return 0; … … 2138 2285 } 2139 2286 2140 static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, emu10k1_fx8010_info_t *info) 2287 static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, 2288 struct snd_emu10k1_fx8010_info *info) 2141 2289 { 2142 2290 char **fxbus, **extin, **extout; … … 2164 2312 } 2165 2313 2166 static int snd_emu10k1_fx8010_ioctl(s nd_hwdep_t* hw, struct file *file, unsigned int cmd, unsigned long arg)2314 static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) 2167 2315 { 2168 2316 struct snd_emu10k1 *emu = hw->private_data; 2169 emu10k1_fx8010_info_t*info;2170 emu10k1_fx8010_code_t*icode;2171 emu10k1_fx8010_pcm_t*ipcm;2317 struct snd_emu10k1_fx8010_info *info; 2318 struct snd_emu10k1_fx8010_code *icode; 2319 struct snd_emu10k1_fx8010_pcm_rec *ipcm; 2172 2320 unsigned int addr; 2321 void __user *argp = (void __user *)arg; 2173 2322 int res; 2174 2323 2175 2324 switch (cmd) { 2176 2325 case SNDRV_EMU10K1_IOCTL_INFO: 2177 info = (emu10k1_fx8010_info_t *)kmalloc(sizeof(*info), GFP_KERNEL);2326 info = kmalloc(sizeof(*info), GFP_KERNEL); 2178 2327 if (!info) 2179 2328 return -ENOMEM; … … 2182 2331 return res; 2183 2332 } 2184 if (copy_to_user( (void *)arg, info, sizeof(*info))) {2333 if (copy_to_user(argp, info, sizeof(*info))) { 2185 2334 kfree(info); 2186 2335 return -EFAULT; … … 2191 2340 if (!capable(CAP_SYS_ADMIN)) 2192 2341 return -EPERM; 2193 icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL);2342 icode = kmalloc(sizeof(*icode), GFP_KERNEL); 2194 2343 if (icode == NULL) 2195 2344 return -ENOMEM; 2196 if (copy_from_user(icode, (void *)arg, sizeof(*icode))) {2345 if (copy_from_user(icode, argp, sizeof(*icode))) { 2197 2346 kfree(icode); 2198 2347 return -EFAULT; … … 2202 2351 return res; 2203 2352 case SNDRV_EMU10K1_IOCTL_CODE_PEEK: 2204 icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL);2353 icode = kmalloc(sizeof(*icode), GFP_KERNEL); 2205 2354 if (icode == NULL) 2206 2355 return -ENOMEM; 2207 if (copy_from_user(icode, (void *)arg, sizeof(*icode))) {2356 if (copy_from_user(icode, argp, sizeof(*icode))) { 2208 2357 kfree(icode); 2209 2358 return -EFAULT; 2210 2359 } 2211 2360 res = snd_emu10k1_icode_peek(emu, icode); 2212 if (res == 0 && copy_to_user( (void *)arg, icode, sizeof(*icode))) {2361 if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { 2213 2362 kfree(icode); 2214 2363 return -EFAULT; … … 2217 2366 return res; 2218 2367 case SNDRV_EMU10K1_IOCTL_PCM_POKE: 2219 ipcm = (emu10k1_fx8010_pcm_t *)kmalloc(sizeof(*ipcm), GFP_KERNEL);2368 ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); 2220 2369 if (ipcm == NULL) 2221 2370 return -ENOMEM; 2222 if (copy_from_user(ipcm, (void *)arg, sizeof(*ipcm))) {2371 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { 2223 2372 kfree(ipcm); 2224 2373 return -EFAULT; … … 2228 2377 return res; 2229 2378 case SNDRV_EMU10K1_IOCTL_PCM_PEEK: 2230 ipcm = (emu10k1_fx8010_pcm_t *)kzalloc(sizeof(*ipcm), GFP_KERNEL);2379 ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); 2231 2380 if (ipcm == NULL) 2232 2381 return -ENOMEM; 2233 if (copy_from_user(ipcm, (void *)arg, sizeof(*ipcm))) {2382 if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { 2234 2383 kfree(ipcm); 2235 2384 return -EFAULT; 2236 2385 } 2237 2386 res = snd_emu10k1_ipcm_peek(emu, ipcm); 2238 if (res == 0 && copy_to_user( (void *)arg, ipcm, sizeof(*ipcm))) {2387 if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { 2239 2388 kfree(ipcm); 2240 2389 return -EFAULT; … … 2245 2394 if (!capable(CAP_SYS_ADMIN)) 2246 2395 return -EPERM; 2247 if (get_user(addr, (unsigned int *)arg))2396 if (get_user(addr, (unsigned int __user *)argp)) 2248 2397 return -EFAULT; 2249 2398 down(&emu->fx8010.lock); … … 2283 2432 if (!capable(CAP_SYS_ADMIN)) 2284 2433 return -EPERM; 2285 if (get_user(addr, (unsigned int *)arg))2434 if (get_user(addr, (unsigned int __user *)argp)) 2286 2435 return -EFAULT; 2287 2436 if (addr > 0x1ff) … … 2302 2451 else 2303 2452 addr = snd_emu10k1_ptr_read(emu, DBG, 0); 2304 if (put_user(addr, (unsigned int *)arg))2453 if (put_user(addr, (unsigned int __user *)argp)) 2305 2454 return -EFAULT; 2306 2455 return 0; … … 2309 2458 } 2310 2459 2311 static int snd_emu10k1_fx8010_release(s nd_hwdep_t* hw, struct file *file)2460 static int snd_emu10k1_fx8010_release(struct snd_hwdep * hw, struct file *file) 2312 2461 { 2313 2462 return 0; 2314 2463 } 2315 2464 2316 int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, s nd_hwdep_t** rhwdep)2317 { 2318 s nd_hwdep_t*hw;2465 int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep) 2466 { 2467 struct snd_hwdep *hw; 2319 2468 int err; 2320 2469 … … 2333 2482 return 0; 2334 2483 } 2484 2485 #ifdef CONFIG_PM 2486 int __devinit snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) 2487 { 2488 int len; 2489 2490 len = emu->audigy ? 0x200 : 0x100; 2491 emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL); 2492 if (! emu->saved_gpr) 2493 return -ENOMEM; 2494 len = emu->audigy ? 0x100 : 0xa0; 2495 emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL); 2496 emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL); 2497 if (! emu->tram_val_saved || ! emu->tram_addr_saved) 2498 return -ENOMEM; 2499 len = emu->audigy ? 2 * 1024 : 2 * 512; 2500 emu->saved_icode = vmalloc(len * 4); 2501 if (! emu->saved_icode) 2502 return -ENOMEM; 2503 return 0; 2504 } 2505 2506 void snd_emu10k1_efx_free_pm_buffer(struct snd_emu10k1 *emu) 2507 { 2508 kfree(emu->saved_gpr); 2509 kfree(emu->tram_val_saved); 2510 kfree(emu->tram_addr_saved); 2511 vfree(emu->saved_icode); 2512 } 2513 2514 /* 2515 * save/restore GPR, TRAM and codes 2516 */ 2517 void snd_emu10k1_efx_suspend(struct snd_emu10k1 *emu) 2518 { 2519 int i, len; 2520 2521 len = emu->audigy ? 0x200 : 0x100; 2522 for (i = 0; i < len; i++) 2523 emu->saved_gpr[i] = snd_emu10k1_ptr_read(emu, emu->gpr_base + i, 0); 2524 2525 len = emu->audigy ? 0x100 : 0xa0; 2526 for (i = 0; i < len; i++) { 2527 emu->tram_val_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + i, 0); 2528 emu->tram_addr_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + i, 0); 2529 if (emu->audigy) { 2530 emu->tram_addr_saved[i] >>= 12; 2531 emu->tram_addr_saved[i] |= 2532 snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + i, 0) << 20; 2533 } 2534 } 2535 2536 len = emu->audigy ? 2 * 1024 : 2 * 512; 2537 for (i = 0; i < len; i++) 2538 emu->saved_icode[i] = snd_emu10k1_efx_read(emu, i); 2539 } 2540 2541 void snd_emu10k1_efx_resume(struct snd_emu10k1 *emu) 2542 { 2543 int i, len; 2544 2545 /* set up TRAM */ 2546 if (emu->fx8010.etram_pages.bytes > 0) { 2547 unsigned size, size_reg = 0; 2548 size = emu->fx8010.etram_pages.bytes / 2; 2549 size = (size - 1) >> 13; 2550 while (size) { 2551 size >>= 1; 2552 size_reg++; 2553 } 2554 outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); 2555 snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); 2556 snd_emu10k1_ptr_write(emu, TCBS, 0, size_reg); 2557 outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); 2558 } 2559 2560 if (emu->audigy) 2561 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); 2562 else 2563 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); 2564 2565 len = emu->audigy ? 0x200 : 0x100; 2566 for (i = 0; i < len; i++) 2567 snd_emu10k1_ptr_write(emu, emu->gpr_base + i, 0, emu->saved_gpr[i]); 2568 2569 len = emu->audigy ? 0x100 : 0xa0; 2570 for (i = 0; i < len; i++) { 2571 snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + i, 0, 2572 emu->tram_val_saved[i]); 2573 if (! emu->audigy) 2574 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, 2575 emu->tram_addr_saved[i]); 2576 else { 2577 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, 2578 emu->tram_addr_saved[i] << 12); 2579 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, 2580 emu->tram_addr_saved[i] >> 20); 2581 } 2582 } 2583 2584 len = emu->audigy ? 2 * 1024 : 2 * 512; 2585 for (i = 0; i < len; i++) 2586 snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]); 2587 2588 /* start FX processor when the DSP code is updated */ 2589 if (emu->audigy) 2590 snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); 2591 else 2592 snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); 2593 } 2594 #endif
Note:
See TracChangeset
for help on using the changeset viewer.