Changeset 84
- Timestamp:
- Oct 23, 2006, 11:07:11 PM (19 years ago)
- Location:
- GPL/trunk
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/core/control.c
r77 r84 27 27 /* max number of user-defined controls */ 28 28 #define MAX_USER_CONTROLS 32 29 30 static inline struct snd_ctl_elem_id *snd_ctl_build_ioff(struct snd_ctl_elem_id *dst_id,31 struct snd_kcontrol *src_kctl,32 unsigned int offset)33 {34 *dst_id = src_kctl->id;35 dst_id->index += offset;36 dst_id->numid += offset;37 return dst_id;38 }39 29 40 30 extern int control_id_changed; … … 223 213 * Returns the pointer of the newly generated instance, or NULL on failure. 224 214 */ 225 struct snd_kcontrol *snd_ctl_new1(struct snd_kcontrol_new const * ncontrol, void *private_data) 215 struct snd_kcontrol *snd_ctl_new1(struct snd_kcontrol_new const * ncontrol, 216 void *private_data) 226 217 { 227 218 struct snd_kcontrol kctl; … … 244 235 kctl.get = ncontrol->get; 245 236 kctl.put = ncontrol->put; 246 kctl.tlv = ncontrol->tlv; 237 kctl.tlv.p = 238 ncontrol->tlv.p; 247 239 kctl.private_value = ncontrol->private_value; 248 240 kctl.private_data = private_data; … … 1037 1029 #endif 1038 1030 1039 static int snd_ctl_tlv_read(struct snd_card *card, 1040 struct snd_ctl_tlv __user *_tlv) 1041 { 1042 struct snd_ctl_tlv tlv; 1043 struct snd_kcontrol *kctl; 1044 unsigned int len; 1045 int err = 0; 1046 1047 if (copy_from_user(&tlv, _tlv, sizeof(tlv))) 1048 return -EFAULT; 1049 if (tlv.length < sizeof(unsigned int) * 3) 1050 return -EINVAL; 1051 down_read(&card->controls_rwsem); 1052 kctl = snd_ctl_find_numid(card, tlv.numid); 1053 if (kctl == NULL) { 1054 err = -ENOENT; 1055 goto __kctl_end; 1056 } 1057 if (kctl->tlv == NULL) { 1058 err = -ENXIO; 1059 goto __kctl_end; 1060 } 1061 len = kctl->tlv[1] + 2 * sizeof(unsigned int); 1062 if (tlv.length < len) { 1063 err = -ENOMEM; 1064 goto __kctl_end; 1065 } 1066 if (copy_to_user(_tlv->tlv, kctl->tlv, len)) 1067 err = -EFAULT; 1068 __kctl_end: 1069 up_read(&card->controls_rwsem); 1070 return err; 1071 } 1031 static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, 1032 struct snd_ctl_tlv __user *_tlv, 1033 int op_flag) 1034 { 1035 struct snd_card *card = file->card; 1036 struct snd_ctl_tlv tlv; 1037 struct snd_kcontrol *kctl; 1038 struct snd_kcontrol_volatile *vd; 1039 unsigned int len; 1040 int err = 0; 1041 1042 if (copy_from_user(&tlv, _tlv, sizeof(tlv))) 1043 return -EFAULT; 1044 if (tlv.length < sizeof(unsigned int) * 3) 1045 return -EINVAL; 1046 down_read(&card->controls_rwsem); 1047 kctl = snd_ctl_find_numid(card, tlv.numid); 1048 if (kctl == NULL) { 1049 err = -ENOENT; 1050 goto __kctl_end; 1051 } 1052 if (kctl->tlv.p == NULL) { 1053 err = -ENXIO; 1054 goto __kctl_end; 1055 } 1056 vd = &kctl->vd[tlv.numid - kctl->id.numid]; 1057 if ((op_flag == 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) == 0) || 1058 (op_flag > 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) == 0) || 1059 (op_flag < 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) { 1060 err = -ENXIO; 1061 goto __kctl_end; 1062 } 1063 if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { 1064 if (file && vd->owner != NULL && vd->owner != file) { 1065 err = -EPERM; 1066 goto __kctl_end; 1067 } 1068 err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv); 1069 if (err > 0) { 1070 up_read(&card->controls_rwsem); 1071 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &kctl->id); 1072 return 0; 1073 } 1074 } else { 1075 if (op_flag) { 1076 err = -ENXIO; 1077 goto __kctl_end; 1078 } 1079 len = kctl->tlv.p[1] + 2 * sizeof(unsigned int); 1080 if (tlv.length < len) { 1081 err = -ENOMEM; 1082 goto __kctl_end; 1083 } 1084 if (copy_to_user(_tlv->tlv, kctl->tlv.p, len)) 1085 err = -EFAULT; 1086 } 1087 __kctl_end: 1088 up_read(&card->controls_rwsem); 1089 return err; 1090 } 1091 1072 1092 1073 1093 static int snd_ctl_ioctl(struct inode *inode, struct file *file, … … 1093 1113 case SNDRV_CTL_IOCTL_ELEM_INFO: 1094 1114 return snd_ctl_elem_info(ctl, (struct snd_ctl_elem_info *) arg); 1095 #if 11096 1115 case SNDRV_CTL_IOCTL_ELEM_READ: 1097 1116 return snd_ctl_elem_read_user(ctl->card, argp); 1098 1117 case SNDRV_CTL_IOCTL_ELEM_WRITE: 1099 1118 return snd_ctl_elem_write_user(ctl, argp); 1100 #else1101 case SNDRV_CTL_IOCTL_ELEM_READ:1102 return snd_ctl_elem_read(ctl->card, (struct snd_ctl_elem_value *) arg);1103 case SNDRV_CTL_IOCTL_ELEM_WRITE:1104 return snd_ctl_elem_write(ctl, (struct snd_ctl_elem_value *) arg);1105 #endif1106 1119 case SNDRV_CTL_IOCTL_ELEM_LOCK: 1107 1120 return snd_ctl_elem_lock(ctl, (struct snd_ctl_elem_id *) arg); … … 1117 1130 return snd_ctl_subscribe_events(ctl, (int *) arg); 1118 1131 case SNDRV_CTL_IOCTL_TLV_READ: 1119 return snd_ctl_tlv_read(card, argp); 1132 return snd_ctl_tlv_ioctl(ctl, argp, 0); 1133 case SNDRV_CTL_IOCTL_TLV_WRITE: 1134 return snd_ctl_tlv_ioctl(ctl, argp, 1); 1135 case SNDRV_CTL_IOCTL_TLV_COMMAND: 1136 return snd_ctl_tlv_ioctl(ctl, argp, -1); 1120 1137 case SNDRV_CTL_IOCTL_POWER: 1121 1138 if (get_user(err, (int *)arg)) -
GPL/trunk/alsa-kernel/core/misc.c
r34 r84 21 21 22 22 #include <sound/driver.h> 23 23 #include <sound/firmware.h> 24 24 int snd_task_name(struct task_struct *task, char *name, size_t size) 25 25 { … … 669 669 } 670 670 671 int mod_firmware_load(const char *fn, char **fp) 672 { 673 return 0; 674 } 675 676 static int snd_try_load_firmware(const char *path, const char *name, 677 struct firmware *firmware) 678 { 679 char filename[30 + FIRMWARE_NAME_MAX]; 680 681 sprintf(filename, "%s/%s", path, name); 682 firmware->size = mod_firmware_load(filename, (char **)&firmware->data); 683 if (firmware->size) 684 printk(KERN_INFO "Loaded '%s'.", filename); 685 return firmware->size; 686 } 687 688 int request_firmware(const struct firmware **fw, const char *name) 689 { 690 struct firmware *firmware; 691 692 *fw = NULL; 693 firmware = kmalloc(sizeof *firmware, GFP_KERNEL); 694 if (!firmware) 695 return -ENOMEM; 696 if (!snd_try_load_firmware("/lib/firmware", name, firmware) && 697 !snd_try_load_firmware("/lib/hotplug/firmware", name, firmware) && 698 !snd_try_load_firmware("/usr/lib/hotplug/firmware", name, firmware)) { 699 kfree(firmware); 700 return -EIO; 701 } 702 *fw = firmware; 703 return 0; 704 } 705 706 void release_firmware(const struct firmware *fw) 707 { 708 if (fw) { 709 vfree(fw->data); 710 kfree(fw); 711 } 712 } 713 -
GPL/trunk/alsa-kernel/include/sound/asound.h
r77 r84 754 754 #define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) /* control value may be changed without a notification */ 755 755 #define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<2) /* when was control changed */ 756 #define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) /* TLV read is possible */ 757 #define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) /* TLV write is possible */ 758 #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) 759 #define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6) /* TLV command is possible */ 756 760 #define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) /* control does actually nothing, but may be updated */ 757 761 #define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) /* write lock */ 758 762 #define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */ 763 #define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */ 759 764 #define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */ 760 765 #define SNDRV_CTL_ELEM_ACCESS_DINDIRECT (1<<30) /* indirect access for matrix dimensions in the info structure */ … … 864 869 SNDRV_CTL_IOCTL_ELEM_REMOVE = _IOWR('U', 0x19, struct snd_ctl_elem_id), 865 870 SNDRV_CTL_IOCTL_TLV_READ = _IOWR('U', 0x1a, struct snd_ctl_tlv), 871 SNDRV_CTL_IOCTL_TLV_WRITE = _IOWR('U', 0x1b, struct snd_ctl_tlv), 872 SNDRV_CTL_IOCTL_TLV_COMMAND = _IOWR('U', 0x1c, struct snd_ctl_tlv), 866 873 SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE = _IOWR('U', 0x20, int), 867 874 SNDRV_CTL_IOCTL_HWDEP_INFO = _IOR('U', 0x21, struct snd_hwdep_info), … … 893 900 #define SNDRV_CTL_EVENT_MASK_INFO (1<<1) /* element info was changed */ 894 901 #define SNDRV_CTL_EVENT_MASK_ADD (1<<2) /* element was added */ 902 #define SNDRV_CTL_EVENT_MASK_TLV (1<<3) /* element TLV tree was changed */ 895 903 #define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) /* element was removed */ 896 904 -
GPL/trunk/alsa-kernel/include/sound/control.h
r77 r84 28 28 typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); 29 29 typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); 30 typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol, 31 int op_flag, /* 0=read,1=write,-1=command */ 32 unsigned int size, 33 unsigned int __user *tlv); 30 34 31 35 struct snd_kcontrol_new { … … 40 44 snd_kcontrol_get_t *get; 41 45 snd_kcontrol_put_t *put; 42 unsigned int *tlv; 46 union { 47 snd_kcontrol_tlv_rw_t *c; 48 unsigned int *p; 49 } tlv; 43 50 unsigned long private_value; 44 51 }; … … 57 64 snd_kcontrol_get_t *get; 58 65 snd_kcontrol_put_t *put; 59 unsigned int *tlv; 66 union { 67 snd_kcontrol_tlv_rw_t *c; 68 unsigned int *p; 69 } tlv; 60 70 unsigned long private_value; 61 71 #ifdef TARGET_OS2 … … 140 150 } 141 151 152 static inline struct snd_ctl_elem_id *snd_ctl_build_ioff(struct snd_ctl_elem_id *dst_id, 153 struct snd_kcontrol *src_kctl, 154 unsigned int offset) 155 { 156 *dst_id = src_kctl->id; 157 dst_id->index += offset; 158 dst_id->numid += offset; 159 return dst_id; 160 } 161 142 162 #endif /* __CONTROL_H */ -
GPL/trunk/alsa-kernel/include/sound/emu10k1.h
r34 r84 188 188 /* NOTE: The rest of the bits in this register */ 189 189 /* _are_ relevant under Linux. */ 190 #define HCFG_CODECFORMAT_MASK 0x00070000 /* CODEC format */ 190 #define HCFG_PUSH_BUTTON_ENABLE 0x00100000 /* Enables Volume Inc/Dec and Mute functions */ 191 #define HCFG_BAUD_RATE 0x00080000 /* 0 = 48kHz, 1 = 44.1kHz */ 192 #define HCFG_EXPANDED_MEM 0x00040000 /* 1 = any 16M of 4G addr, 0 = 32M of 2G addr */ 193 #define HCFG_CODECFORMAT_MASK 0x00030000 /* CODEC format */ 194 195 /* Specific to Alice2, CA0102 */ 196 #define HCFG_CODECFORMAT_AC97_1 0x00000000 /* AC97 CODEC format -- Ver 1.03 */ 197 #define HCFG_CODECFORMAT_AC97_2 0x00010000 /* AC97 CODEC format -- Ver 2.1 */ 198 #define HCFG_AUTOMUTE_ASYNC 0x00008000 /* When set, the async sample rate convertors */ 199 /* will automatically mute their output when */ 200 /* they are not rate-locked to the external */ 201 /* async audio source */ 202 #define HCFG_AUTOMUTE_SPDIF 0x00004000 /* When set, the async sample rate convertors */ 203 /* will automatically mute their output when */ 204 /* the SPDIF V-bit indicates invalid audio */ 205 #define HCFG_EMU32_SLAVE 0x00002000 /* 0 = Master, 1 = Slave. Slave for EMU1010 */ 206 #define HCFG_SLOW_RAMP 0x00001000 /* Increases Send Smoothing time constant */ 207 /* 0x00000800 not used on Alice2 */ 208 #define HCFG_PHASE_TRACK_MASK 0x00000700 /* When set, forces corresponding input to */ 209 /* phase track the previous input. */ 210 /* I2S0 can phase track the last S/PDIF input */ 211 #define HCFG_I2S_ASRC_ENABLE 0x00000070 /* When set, enables asynchronous sample rate */ 212 /* conversion for the corresponding */ 213 /* I2S format input */ 214 /* Rest of HCFG 0x0000000f same as below. LOCKSOUNDCACHE etc. */ 215 216 217 218 /* Older chips */ 191 219 #define HCFG_CODECFORMAT_AC97 0x00000000 /* AC97 CODEC format -- Primary Output */ 192 220 #define HCFG_CODECFORMAT_I2S 0x00010000 /* I2S CODEC format -- Secondary (Rear) Output */ … … 245 273 #define A_IOCFG_DISABLE_ANALOG 0x0040 /* = 'enable' for Audigy2 (chiprev=4) */ 246 274 #define A_IOCFG_ENABLE_DIGITAL 0x0004 275 #define A_IOCFG_ENABLE_DIGITAL_AUDIGY4 0x0080 247 276 #define A_IOCFG_UNKNOWN_20 0x0020 248 277 #define A_IOCFG_DISABLE_AC97_FRONT 0x0080 /* turn off ac97 front -> front (10k2.1) */ … … 885 914 #define A_HIWORD_OPA_MASK 0x000007ff 886 915 916 /************************************************************************************************/ 917 /* EMU1010m HANA FPGA registers */ 918 /************************************************************************************************/ 919 #define EMU_HANA_DESTHI 0x00 /* 0000xxx 3 bits Link Destination */ 920 #define EMU_HANA_DESTLO 0x01 /* 00xxxxx 5 bits */ 921 #define EMU_HANA_SRCHI 0x02 /* 0000xxx 3 bits Link Source */ 922 #define EMU_HANA_SRCLO 0x03 /* 00xxxxx 5 bits */ 923 #define EMU_HANA_DOCK_PWR 0x04 /* 000000x 1 bits Audio Dock power */ 924 #define EMU_HANA_DOCK_PWR_ON 0x01 /* Audio Dock power on */ 925 #define EMU_HANA_WCLOCK 0x05 /* 0000xxx 3 bits Word Clock source select */ 926 /* Must be written after power on to reset DLL */ 927 /* One is unable to detect the Audio dock without this */ 928 #define EMU_HANA_WCLOCK_SRC_MASK 0x07 929 #define EMU_HANA_WCLOCK_INT_48K 0x00 930 #define EMU_HANA_WCLOCK_INT_44_1K 0x01 931 #define EMU_HANA_WCLOCK_HANA_SPDIF_IN 0x02 932 #define EMU_HANA_WCLOCK_HANA_ADAT_IN 0x03 933 #define EMU_HANA_WCLOCK_SYNC_BNCN 0x04 934 #define EMU_HANA_WCLOCK_2ND_HANA 0x05 935 #define EMU_HANA_WCLOCK_SRC_RESERVED 0x06 936 #define EMU_HANA_WCLOCK_OFF 0x07 /* For testing, forces fallback to DEFCLOCK */ 937 #define EMU_HANA_WCLOCK_MULT_MASK 0x18 938 #define EMU_HANA_WCLOCK_1X 0x00 939 #define EMU_HANA_WCLOCK_2X 0x08 940 #define EMU_HANA_WCLOCK_4X 0x10 941 #define EMU_HANA_WCLOCK_MULT_RESERVED 0x18 942 943 #define EMU_HANA_DEFCLOCK 0x06 /* 000000x 1 bits Default Word Clock */ 944 #define EMU_HANA_DEFCLOCK_48K 0x00 945 #define EMU_HANA_DEFCLOCK_44_1K 0x01 946 947 #define EMU_HANA_UNMUTE 0x07 /* 000000x 1 bits Mute all audio outputs */ 948 #define EMU_MUTE 0x00 949 #define EMU_UNMUTE 0x01 950 951 #define EMU_HANA_FPGA_CONFIG 0x08 /* 00000xx 2 bits Config control of FPGAs */ 952 #define EMU_HANA_FPGA_CONFIG_AUDIODOCK 0x01 /* Set in order to program FPGA on Audio Dock */ 953 #define EMU_HANA_FPGA_CONFIG_HANA 0x02 /* Set in order to program FPGA on Hana */ 954 955 #define EMU_HANA_IRQ_ENABLE 0x09 /* 000xxxx 4 bits IRQ Enable */ 956 #define EMU_HANA_IRQ_WCLK_CHANGED 0x01 957 #define EMU_HANA_IRQ_ADAT 0x02 958 #define EMU_HANA_IRQ_DOCK 0x04 959 #define EMU_HANA_IRQ_DOCK_LOST 0x08 960 961 #define EMU_HANA_SPDIF_MODE 0x0a /* 00xxxxx 5 bits SPDIF MODE */ 962 #define EMU_HANA_SPDIF_MODE_TX_COMSUMER 0x00 963 #define EMU_HANA_SPDIF_MODE_TX_PRO 0x01 964 #define EMU_HANA_SPDIF_MODE_TX_NOCOPY 0x02 965 #define EMU_HANA_SPDIF_MODE_RX_COMSUMER 0x00 966 #define EMU_HANA_SPDIF_MODE_RX_PRO 0x04 967 #define EMU_HANA_SPDIF_MODE_RX_NOCOPY 0x08 968 #define EMU_HANA_SPDIF_MODE_RX_INVALID 0x10 969 970 #define EMU_HANA_OPTICAL_TYPE 0x0b /* 00000xx 2 bits ADAT or SPDIF in/out */ 971 #define EMU_HANA_OPTICAL_IN_SPDIF 0x00 972 #define EMU_HANA_OPTICAL_IN_ADAT 0x01 973 #define EMU_HANA_OPTICAL_OUT_SPDIF 0x00 974 #define EMU_HANA_OPTICAL_OUT_ADAT 0x02 975 976 #define EMU_HANA_MIDI_IN 0x0c /* 000000x 1 bit Control MIDI */ 977 #define EMU_HANA_MIDI_IN_FROM_HAMOA 0x00 /* HAMOA MIDI in to Alice 2 MIDI B */ 978 #define EMU_HANA_MIDI_IN_FROM_DOCK 0x01 /* Audio Dock MIDI in to Alice 2 MIDI B */ 979 980 #define EMU_HANA_DOCK_LEDS_1 0x0d /* 000xxxx 4 bit Audio Dock LEDs */ 981 #define EMU_HANA_DOCK_LEDS_1_MIDI1 0x01 /* MIDI 1 LED on */ 982 #define EMU_HANA_DOCK_LEDS_1_MIDI2 0x02 /* MIDI 2 LED on */ 983 #define EMU_HANA_DOCK_LEDS_1_SMPTE_IN 0x04 /* SMPTE IN LED on */ 984 #define EMU_HANA_DOCK_LEDS_1_SMPTE_OUT 0x08 /* SMPTE OUT LED on */ 985 986 #define EMU_HANA_DOCK_LEDS_2 0x0e /* 0xxxxxx 6 bit Audio Dock LEDs */ 987 #define EMU_HANA_DOCK_LEDS_2_44K 0x01 /* 44.1 kHz LED on */ 988 #define EMU_HANA_DOCK_LEDS_2_48K 0x02 /* 48 kHz LED on */ 989 #define EMU_HANA_DOCK_LEDS_2_96K 0x04 /* 96 kHz LED on */ 990 #define EMU_HANA_DOCK_LEDS_2_192K 0x08 /* 192 kHz LED on */ 991 #define EMU_HANA_DOCK_LEDS_2_LOCK 0x10 /* LOCK LED on */ 992 #define EMU_HANA_DOCK_LEDS_2_EXT 0x20 /* EXT LED on */ 993 994 #define EMU_HANA_DOCK_LEDS_3 0x0f /* 0xxxxxx 6 bit Audio Dock LEDs */ 995 #define EMU_HANA_DOCK_LEDS_3_CLIP_A 0x01 /* Mic A Clip LED on */ 996 #define EMU_HANA_DOCK_LEDS_3_CLIP_B 0x02 /* Mic B Clip LED on */ 997 #define EMU_HANA_DOCK_LEDS_3_SIGNAL_A 0x04 /* Signal A Clip LED on */ 998 #define EMU_HANA_DOCK_LEDS_3_SIGNAL_B 0x08 /* Signal B Clip LED on */ 999 #define EMU_HANA_DOCK_LEDS_3_MANUAL_CLIP 0x10 /* Manual Clip detection */ 1000 #define EMU_HANA_DOCK_LEDS_3_MANUAL_SIGNAL 0x20 /* Manual Signal detection */ 1001 1002 #define EMU_HANA_ADC_PADS 0x10 /* 0000xxx 3 bit Audio Dock ADC 14dB pads */ 1003 #define EMU_HANA_DOCK_ADC_PAD1 0x01 /* 14dB Attenuation on Audio Dock ADC 1 */ 1004 #define EMU_HANA_DOCK_ADC_PAD2 0x02 /* 14dB Attenuation on Audio Dock ADC 2 */ 1005 #define EMU_HANA_DOCK_ADC_PAD3 0x04 /* 14dB Attenuation on Audio Dock ADC 3 */ 1006 #define EMU_HANA_0202_ADC_PAD1 0x08 /* 14dB Attenuation on 0202 ADC 1 */ 1007 1008 #define EMU_HANA_DOCK_MISC 0x11 /* 0xxxxxx 6 bit Audio Dock misc bits */ 1009 #define EMU_HANA_DOCK_DAC1_MUTE 0x01 /* DAC 1 Mute */ 1010 #define EMU_HANA_DOCK_DAC2_MUTE 0x02 /* DAC 2 Mute */ 1011 #define EMU_HANA_DOCK_DAC3_MUTE 0x04 /* DAC 3 Mute */ 1012 #define EMU_HANA_DOCK_DAC4_MUTE 0x08 /* DAC 4 Mute */ 1013 #define EMU_HANA_DOCK_PHONES_192_DAC1 0x00 /* DAC 1 Headphones source at 192kHz */ 1014 #define EMU_HANA_DOCK_PHONES_192_DAC2 0x10 /* DAC 2 Headphones source at 192kHz */ 1015 #define EMU_HANA_DOCK_PHONES_192_DAC3 0x20 /* DAC 3 Headphones source at 192kHz */ 1016 #define EMU_HANA_DOCK_PHONES_192_DAC4 0x30 /* DAC 4 Headphones source at 192kHz */ 1017 1018 #define EMU_HANA_MIDI_OUT 0x12 /* 00xxxxx 5 bit Source for each MIDI out port */ 1019 #define EMU_HANA_MIDI_OUT_0202 0x01 /* 0202 MIDI from Alice 2. 0 = A, 1 = B */ 1020 #define EMU_HANA_MIDI_OUT_DOCK1 0x02 /* Audio Dock MIDI1 front, from Alice 2. 0 = A, 1 = B */ 1021 #define EMU_HANA_MIDI_OUT_DOCK2 0x04 /* Audio Dock MIDI2 rear, from Alice 2. 0 = A, 1 = B */ 1022 #define EMU_HANA_MIDI_OUT_SYNC2 0x08 /* Sync card. Not the actual MIDI out jack. 0 = A, 1 = B */ 1023 #define EMU_HANA_MIDI_OUT_LOOP 0x10 /* 0 = bits (3:0) normal. 1 = MIDI loopback enabled. */ 1024 1025 #define EMU_HANA_DAC_PADS 0x13 /* 00xxxxx 5 bit DAC 14dB attenuation pads */ 1026 #define EMU_HANA_DOCK_DAC_PAD1 0x01 /* 14dB Attenuation on AudioDock DAC 1. Left and Right */ 1027 #define EMU_HANA_DOCK_DAC_PAD2 0x02 /* 14dB Attenuation on AudioDock DAC 2. Left and Right */ 1028 #define EMU_HANA_DOCK_DAC_PAD3 0x04 /* 14dB Attenuation on AudioDock DAC 3. Left and Right */ 1029 #define EMU_HANA_DOCK_DAC_PAD4 0x08 /* 14dB Attenuation on AudioDock DAC 4. Left and Right */ 1030 #define EMU_HANA_0202_DAC_PAD1 0x10 /* 14dB Attenuation on 0202 DAC 1. Left and Right */ 1031 1032 /* 0x14 - 0x1f Unused R/W registers */ 1033 #define EMU_HANA_IRQ_STATUS 0x20 /* 000xxxx 4 bits IRQ Status */ 1034 #if 0 /* Already defined for reg 0x09 IRQ_ENABLE */ 1035 #define EMU_HANA_IRQ_WCLK_CHANGED 0x01 1036 #define EMU_HANA_IRQ_ADAT 0x02 1037 #define EMU_HANA_IRQ_DOCK 0x04 1038 #define EMU_HANA_IRQ_DOCK_LOST 0x08 1039 #endif 1040 1041 #define EMU_HANA_OPTION_CARDS 0x21 /* 000xxxx 4 bits Presence of option cards */ 1042 #define EMU_HANA_OPTION_HAMOA 0x01 /* HAMOA card present */ 1043 #define EMU_HANA_OPTION_SYNC 0x02 /* Sync card present */ 1044 #define EMU_HANA_OPTION_DOCK_ONLINE 0x04 /* Audio Dock online and FPGA configured */ 1045 #define EMU_HANA_OPTION_DOCK_OFFLINE 0x08 /* Audio Dock online and FPGA not configured */ 1046 1047 #define EMU_HANA_ID 0x22 /* 1010101 7 bits ID byte & 0x7f = 0x55 */ 1048 1049 #define EMU_HANA_MAJOR_REV 0x23 /* 0000xxx 3 bit Hana FPGA Major rev */ 1050 #define EMU_HANA_MINOR_REV 0x24 /* 0000xxx 3 bit Hana FPGA Minor rev */ 1051 1052 #define EMU_DOCK_MAJOR_REV 0x25 /* 0000xxx 3 bit Audio Dock FPGA Major rev */ 1053 #define EMU_DOCK_MINOR_REV 0x26 /* 0000xxx 3 bit Audio Dock FPGA Minor rev */ 1054 1055 #define EMU_DOCK_BOARD_ID 0x27 /* 00000xx 2 bits Audio Dock ID pins */ 1056 #define EMU_DOCK_BOARD_ID0 0x00 /* ID bit 0 */ 1057 #define EMU_DOCK_BOARD_ID1 0x03 /* ID bit 1 */ 1058 1059 #define EMU_HANA_WC_SPDIF_HI 0x28 /* 0xxxxxx 6 bit SPDIF IN Word clock, upper 6 bits */ 1060 #define EMU_HANA_WC_SPDIF_LO 0x29 /* 0xxxxxx 6 bit SPDIF IN Word clock, lower 6 bits */ 1061 1062 #define EMU_HANA_WC_ADAT_HI 0x2a /* 0xxxxxx 6 bit ADAT IN Word clock, upper 6 bits */ 1063 #define EMU_HANA_WC_ADAT_LO 0x2b /* 0xxxxxx 6 bit ADAT IN Word clock, lower 6 bits */ 1064 1065 #define EMU_HANA_WC_BNC_LO 0x2c /* 0xxxxxx 6 bit BNC IN Word clock, lower 6 bits */ 1066 #define EMU_HANA_WC_BNC_HI 0x2d /* 0xxxxxx 6 bit BNC IN Word clock, upper 6 bits */ 1067 1068 #define EMU_HANA2_WC_SPDIF_HI 0x2e /* 0xxxxxx 6 bit HANA2 SPDIF IN Word clock, upper 6 bits */ 1069 #define EMU_HANA2_WC_SPDIF_LO 0x2f /* 0xxxxxx 6 bit HANA2 SPDIF IN Word clock, lower 6 bits */ 1070 /* 0x30 - 0x3f Unused Read only registers */ 1071 1072 /************************************************************************************************/ 1073 /* EMU1010m HANA Destinations */ 1074 /************************************************************************************************/ 1075 #define EMU_DST_ALICE2_EMU32_0 0x000f /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1076 #define EMU_DST_ALICE2_EMU32_1 0x0000 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1077 #define EMU_DST_ALICE2_EMU32_2 0x0001 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1078 #define EMU_DST_ALICE2_EMU32_3 0x0002 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1079 #define EMU_DST_ALICE2_EMU32_4 0x0003 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1080 #define EMU_DST_ALICE2_EMU32_5 0x0004 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1081 #define EMU_DST_ALICE2_EMU32_6 0x0005 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1082 #define EMU_DST_ALICE2_EMU32_7 0x0006 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1083 #define EMU_DST_ALICE2_EMU32_8 0x0007 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1084 #define EMU_DST_ALICE2_EMU32_9 0x0008 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1085 #define EMU_DST_ALICE2_EMU32_A 0x0009 /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1086 #define EMU_DST_ALICE2_EMU32_B 0x000a /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1087 #define EMU_DST_ALICE2_EMU32_C 0x000b /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1088 #define EMU_DST_ALICE2_EMU32_D 0x000c /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1089 #define EMU_DST_ALICE2_EMU32_E 0x000d /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1090 #define EMU_DST_ALICE2_EMU32_F 0x000e /* 16 EMU32 channels to Alice2 +0 to +0xf */ 1091 #define EMU_DST_DOCK_DAC1_LEFT1 0x0100 /* Audio Dock DAC1 Left, 1st or 48kHz only */ 1092 #define EMU_DST_DOCK_DAC1_LEFT2 0x0101 /* Audio Dock DAC1 Left, 2nd or 96kHz */ 1093 #define EMU_DST_DOCK_DAC1_LEFT3 0x0102 /* Audio Dock DAC1 Left, 3rd or 192kHz */ 1094 #define EMU_DST_DOCK_DAC1_LEFT4 0x0103 /* Audio Dock DAC1 Left, 4th or 192kHz */ 1095 #define EMU_DST_DOCK_DAC1_RIGHT1 0x0104 /* Audio Dock DAC1 Right, 1st or 48kHz only */ 1096 #define EMU_DST_DOCK_DAC1_RIGHT2 0x0105 /* Audio Dock DAC1 Right, 2nd or 96kHz */ 1097 #define EMU_DST_DOCK_DAC1_RIGHT3 0x0106 /* Audio Dock DAC1 Right, 3rd or 192kHz */ 1098 #define EMU_DST_DOCK_DAC1_RIGHT4 0x0107 /* Audio Dock DAC1 Right, 4th or 192kHz */ 1099 #define EMU_DST_DOCK_DAC2_LEFT1 0x0108 /* Audio Dock DAC2 Left, 1st or 48kHz only */ 1100 #define EMU_DST_DOCK_DAC2_LEFT2 0x0109 /* Audio Dock DAC2 Left, 2nd or 96kHz */ 1101 #define EMU_DST_DOCK_DAC2_LEFT3 0x010a /* Audio Dock DAC2 Left, 3rd or 192kHz */ 1102 #define EMU_DST_DOCK_DAC2_LEFT4 0x010b /* Audio Dock DAC2 Left, 4th or 192kHz */ 1103 #define EMU_DST_DOCK_DAC2_RIGHT1 0x010c /* Audio Dock DAC2 Right, 1st or 48kHz only */ 1104 #define EMU_DST_DOCK_DAC2_RIGHT2 0x010d /* Audio Dock DAC2 Right, 2nd or 96kHz */ 1105 #define EMU_DST_DOCK_DAC2_RIGHT3 0x010e /* Audio Dock DAC2 Right, 3rd or 192kHz */ 1106 #define EMU_DST_DOCK_DAC2_RIGHT4 0x010f /* Audio Dock DAC2 Right, 4th or 192kHz */ 1107 #define EMU_DST_DOCK_DAC3_LEFT1 0x0110 /* Audio Dock DAC1 Left, 1st or 48kHz only */ 1108 #define EMU_DST_DOCK_DAC3_LEFT2 0x0111 /* Audio Dock DAC1 Left, 2nd or 96kHz */ 1109 #define EMU_DST_DOCK_DAC3_LEFT3 0x0112 /* Audio Dock DAC1 Left, 3rd or 192kHz */ 1110 #define EMU_DST_DOCK_DAC3_LEFT4 0x0113 /* Audio Dock DAC1 Left, 4th or 192kHz */ 1111 #define EMU_DST_DOCK_PHONES_LEFT1 0x0112 /* Audio Dock PHONES Left, 1st or 48kHz only */ 1112 #define EMU_DST_DOCK_PHONES_LEFT2 0x0113 /* Audio Dock PHONES Left, 2nd or 96kHz */ 1113 #define EMU_DST_DOCK_DAC3_RIGHT1 0x0114 /* Audio Dock DAC1 Right, 1st or 48kHz only */ 1114 #define EMU_DST_DOCK_DAC3_RIGHT2 0x0115 /* Audio Dock DAC1 Right, 2nd or 96kHz */ 1115 #define EMU_DST_DOCK_DAC3_RIGHT3 0x0116 /* Audio Dock DAC1 Right, 3rd or 192kHz */ 1116 #define EMU_DST_DOCK_DAC3_RIGHT4 0x0117 /* Audio Dock DAC1 Right, 4th or 192kHz */ 1117 #define EMU_DST_DOCK_PHONES_RIGHT1 0x0116 /* Audio Dock PHONES Right, 1st or 48kHz only */ 1118 #define EMU_DST_DOCK_PHONES_RIGHT2 0x0117 /* Audio Dock PHONES Right, 2nd or 96kHz */ 1119 #define EMU_DST_DOCK_DAC4_LEFT1 0x0118 /* Audio Dock DAC2 Left, 1st or 48kHz only */ 1120 #define EMU_DST_DOCK_DAC4_LEFT2 0x0119 /* Audio Dock DAC2 Left, 2nd or 96kHz */ 1121 #define EMU_DST_DOCK_DAC4_LEFT3 0x011a /* Audio Dock DAC2 Left, 3rd or 192kHz */ 1122 #define EMU_DST_DOCK_DAC4_LEFT4 0x011b /* Audio Dock DAC2 Left, 4th or 192kHz */ 1123 #define EMU_DST_DOCK_SPDIF_LEFT1 0x011a /* Audio Dock SPDIF Left, 1st or 48kHz only */ 1124 #define EMU_DST_DOCK_SPDIF_LEFT2 0x011b /* Audio Dock SPDIF Left, 2nd or 96kHz */ 1125 #define EMU_DST_DOCK_DAC4_RIGHT1 0x011c /* Audio Dock DAC2 Right, 1st or 48kHz only */ 1126 #define EMU_DST_DOCK_DAC4_RIGHT2 0x011d /* Audio Dock DAC2 Right, 2nd or 96kHz */ 1127 #define EMU_DST_DOCK_DAC4_RIGHT3 0x011e /* Audio Dock DAC2 Right, 3rd or 192kHz */ 1128 #define EMU_DST_DOCK_DAC4_RIGHT4 0x011f /* Audio Dock DAC2 Right, 4th or 192kHz */ 1129 #define EMU_DST_DOCK_SPDIF_RIGHT1 0x011e /* Audio Dock SPDIF Right, 1st or 48kHz only */ 1130 #define EMU_DST_DOCK_SPDIF_RIGHT2 0x011f /* Audio Dock SPDIF Right, 2nd or 96kHz */ 1131 #define EMU_DST_HANA_SPDIF_LEFT1 0x0200 /* Hana SPDIF Left, 1st or 48kHz only */ 1132 #define EMU_DST_HANA_SPDIF_LEFT2 0x0202 /* Hana SPDIF Left, 2nd or 96kHz */ 1133 #define EMU_DST_HANA_SPDIF_RIGHT1 0x0201 /* Hana SPDIF Right, 1st or 48kHz only */ 1134 #define EMU_DST_HANA_SPDIF_RIGHT2 0x0203 /* Hana SPDIF Right, 2nd or 96kHz */ 1135 #define EMU_DST_HAMOA_DAC_LEFT1 0x0300 /* Hamoa DAC Left, 1st or 48kHz only */ 1136 #define EMU_DST_HAMOA_DAC_LEFT2 0x0302 /* Hamoa DAC Left, 2nd or 96kHz */ 1137 #define EMU_DST_HAMOA_DAC_LEFT3 0x0304 /* Hamoa DAC Left, 3rd or 192kHz */ 1138 #define EMU_DST_HAMOA_DAC_LEFT4 0x0306 /* Hamoa DAC Left, 4th or 192kHz */ 1139 #define EMU_DST_HAMOA_DAC_RIGHT1 0x0301 /* Hamoa DAC Right, 1st or 48kHz only */ 1140 #define EMU_DST_HAMOA_DAC_RIGHT2 0x0303 /* Hamoa DAC Right, 2nd or 96kHz */ 1141 #define EMU_DST_HAMOA_DAC_RIGHT3 0x0305 /* Hamoa DAC Right, 3rd or 192kHz */ 1142 #define EMU_DST_HAMOA_DAC_RIGHT4 0x0307 /* Hamoa DAC Right, 4th or 192kHz */ 1143 #define EMU_DST_HANA_ADAT 0x0400 /* Hana ADAT 8 channel out +0 to +7 */ 1144 #define EMU_DST_ALICE_I2S0_LEFT 0x0500 /* Alice2 I2S0 Left */ 1145 #define EMU_DST_ALICE_I2S0_RIGHT 0x0501 /* Alice2 I2S0 Right */ 1146 #define EMU_DST_ALICE_I2S1_LEFT 0x0600 /* Alice2 I2S1 Left */ 1147 #define EMU_DST_ALICE_I2S1_RIGHT 0x0601 /* Alice2 I2S1 Right */ 1148 #define EMU_DST_ALICE_I2S2_LEFT 0x0700 /* Alice2 I2S2 Left */ 1149 #define EMU_DST_ALICE_I2S2_RIGHT 0x0701 /* Alice2 I2S2 Right */ 1150 1151 /************************************************************************************************/ 1152 /* EMU1010m HANA Sources */ 1153 /************************************************************************************************/ 1154 #define EMU_SRC_SILENCE 0x0000 /* Silence */ 1155 #define EMU_SRC_DOCK_MIC_A1 0x0100 /* Audio Dock Mic A, 1st or 48kHz only */ 1156 #define EMU_SRC_DOCK_MIC_A2 0x0101 /* Audio Dock Mic A, 2nd or 96kHz */ 1157 #define EMU_SRC_DOCK_MIC_A3 0x0102 /* Audio Dock Mic A, 3rd or 192kHz */ 1158 #define EMU_SRC_DOCK_MIC_A4 0x0103 /* Audio Dock Mic A, 4th or 192kHz */ 1159 #define EMU_SRC_DOCK_MIC_B1 0x0104 /* Audio Dock Mic B, 1st or 48kHz only */ 1160 #define EMU_SRC_DOCK_MIC_B2 0x0105 /* Audio Dock Mic B, 2nd or 96kHz */ 1161 #define EMU_SRC_DOCK_MIC_B3 0x0106 /* Audio Dock Mic B, 3rd or 192kHz */ 1162 #define EMU_SRC_DOCK_MIC_B4 0x0107 /* Audio Dock Mic B, 4th or 192kHz */ 1163 #define EMU_SRC_DOCK_ADC1_LEFT1 0x0108 /* Audio Dock ADC1 Left, 1st or 48kHz only */ 1164 #define EMU_SRC_DOCK_ADC1_LEFT2 0x0109 /* Audio Dock ADC1 Left, 2nd or 96kHz */ 1165 #define EMU_SRC_DOCK_ADC1_LEFT3 0x010a /* Audio Dock ADC1 Left, 3rd or 192kHz */ 1166 #define EMU_SRC_DOCK_ADC1_LEFT4 0x010b /* Audio Dock ADC1 Left, 4th or 192kHz */ 1167 #define EMU_SRC_DOCK_ADC1_RIGHT1 0x010c /* Audio Dock ADC1 Right, 1st or 48kHz only */ 1168 #define EMU_SRC_DOCK_ADC1_RIGHT2 0x010d /* Audio Dock ADC1 Right, 2nd or 96kHz */ 1169 #define EMU_SRC_DOCK_ADC1_RIGHT3 0x010e /* Audio Dock ADC1 Right, 3rd or 192kHz */ 1170 #define EMU_SRC_DOCK_ADC1_RIGHT4 0x010f /* Audio Dock ADC1 Right, 4th or 192kHz */ 1171 #define EMU_SRC_DOCK_ADC2_LEFT1 0x0110 /* Audio Dock ADC2 Left, 1st or 48kHz only */ 1172 #define EMU_SRC_DOCK_ADC2_LEFT2 0x0111 /* Audio Dock ADC2 Left, 2nd or 96kHz */ 1173 #define EMU_SRC_DOCK_ADC2_LEFT3 0x0112 /* Audio Dock ADC2 Left, 3rd or 192kHz */ 1174 #define EMU_SRC_DOCK_ADC2_LEFT4 0x0113 /* Audio Dock ADC2 Left, 4th or 192kHz */ 1175 #define EMU_SRC_DOCK_ADC2_RIGHT1 0x0114 /* Audio Dock ADC2 Right, 1st or 48kHz only */ 1176 #define EMU_SRC_DOCK_ADC2_RIGHT2 0x0115 /* Audio Dock ADC2 Right, 2nd or 96kHz */ 1177 #define EMU_SRC_DOCK_ADC2_RIGHT3 0x0116 /* Audio Dock ADC2 Right, 3rd or 192kHz */ 1178 #define EMU_SRC_DOCK_ADC2_RIGHT4 0x0117 /* Audio Dock ADC2 Right, 4th or 192kHz */ 1179 #define EMU_SRC_DOCK_ADC3_LEFT1 0x0118 /* Audio Dock ADC3 Left, 1st or 48kHz only */ 1180 #define EMU_SRC_DOCK_ADC3_LEFT2 0x0119 /* Audio Dock ADC3 Left, 2nd or 96kHz */ 1181 #define EMU_SRC_DOCK_ADC3_LEFT3 0x011a /* Audio Dock ADC3 Left, 3rd or 192kHz */ 1182 #define EMU_SRC_DOCK_ADC3_LEFT4 0x011b /* Audio Dock ADC3 Left, 4th or 192kHz */ 1183 #define EMU_SRC_DOCK_ADC3_RIGHT1 0x011c /* Audio Dock ADC3 Right, 1st or 48kHz only */ 1184 #define EMU_SRC_DOCK_ADC3_RIGHT2 0x011d /* Audio Dock ADC3 Right, 2nd or 96kHz */ 1185 #define EMU_SRC_DOCK_ADC3_RIGHT3 0x011e /* Audio Dock ADC3 Right, 3rd or 192kHz */ 1186 #define EMU_SRC_DOCK_ADC3_RIGHT4 0x011f /* Audio Dock ADC3 Right, 4th or 192kHz */ 1187 #define EMU_SRC_HAMOA_ADC_LEFT1 0x0200 /* Hamoa ADC Left, 1st or 48kHz only */ 1188 #define EMU_SRC_HAMOA_ADC_LEFT2 0x0202 /* Hamoa ADC Left, 2nd or 96kHz */ 1189 #define EMU_SRC_HAMOA_ADC_LEFT3 0x0204 /* Hamoa ADC Left, 3rd or 192kHz */ 1190 #define EMU_SRC_HAMOA_ADC_LEFT4 0x0206 /* Hamoa ADC Left, 4th or 192kHz */ 1191 #define EMU_SRC_HAMOA_ADC_RIGHT1 0x0201 /* Hamoa ADC Right, 1st or 48kHz only */ 1192 #define EMU_SRC_HAMOA_ADC_RIGHT2 0x0203 /* Hamoa ADC Right, 2nd or 96kHz */ 1193 #define EMU_SRC_HAMOA_ADC_RIGHT3 0x0205 /* Hamoa ADC Right, 3rd or 192kHz */ 1194 #define EMU_SRC_HAMOA_ADC_RIGHT4 0x0207 /* Hamoa ADC Right, 4th or 192kHz */ 1195 #define EMU_SRC_ALICE_EMU32A 0x0300 /* Alice2 EMU32a 16 outputs. +0 to +0xf */ 1196 #define EMU_SRC_ALICE_EMU32B 0x0310 /* Alice2 EMU32b 16 outputs. +0 to +0xf */ 1197 #define EMU_SRC_HANA_ADAT 0x0400 /* Hana ADAT 8 channel in +0 to +7 */ 1198 #define EMU_SRC_HANA_SPDIF_LEFT1 0x0500 /* Hana SPDIF Left, 1st or 48kHz only */ 1199 #define EMU_SRC_HANA_SPDIF_LEFT2 0x0502 /* Hana SPDIF Left, 2nd or 96kHz */ 1200 #define EMU_SRC_HANA_SPDIF_RIGHT1 0x0501 /* Hana SPDIF Right, 1st or 48kHz only */ 1201 #define EMU_SRC_HANA_SPDIF_RIGHT2 0x0503 /* Hana SPDIF Right, 2nd or 96kHz */ 1202 /* 0x600 and 0x700 no used */ 887 1203 888 1204 /* ------------------- STRUCTURES -------------------- */ … … 1061 1377 unsigned char spdif_bug; /* Has Spdif phasing bug */ 1062 1378 unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */ 1063 unsigned char ecard; /* APS EEPROM */ 1379 unsigned char ecard; /* APS EEPROM */ 1380 unsigned char emu1010; /* EMU 1010m card */ 1381 unsigned char spi_dac; /* SPI interface for DAC */ 1382 unsigned char i2c_adc; /* I2C interface for ADC */ 1383 unsigned char adc_1361t; /* Use Philips 1361T ADC */ 1064 1384 const char *driver; 1065 1385 const char *name; 1066 1386 const char *id; /* for backward compatibility - can be NULL if not needed */ 1067 1387 }; 1388 1389 struct snd_emu1010 { 1390 unsigned int output_source[64]; 1391 unsigned int input_source[64]; 1392 unsigned int adc_pads; /* bit mask */ 1393 unsigned int dac_pads; /* bit mask */ 1394 unsigned int internal_clock; /* 44100 or 48000 */ 1395 }; 1396 1068 1397 1069 1398 struct snd_emu10k1 { … … 1120 1449 spinlock_t emu_lock; 1121 1450 spinlock_t voice_lock; 1122 struct semaphore ptb_lock;1451 //struct semaphore ptb_lock; 1123 1452 1124 1453 struct snd_emu10k1_voice voices[NUM_G]; … … 1126 1455 struct snd_emu10k1_voice p16v_capture_voice; 1127 1456 int p16v_device_offset; 1128 u32 p16v_capture_source; 1457 u32 p16v_capture_source; 1458 struct snd_emu1010 emu1010; 1129 1459 u32 p16v_capture_channel; 1130 1460 struct snd_emu10k1_pcm_mixer pcm_mixer[32]; … … 1190 1520 int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep); 1191 1521 1192 irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id , struct pt_regs *regs);1522 irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id); 1193 1523 1194 1524 void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int voice); … … 1203 1533 unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn); 1204 1534 void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); 1535 int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data); 1536 int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value); 1537 int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value); 1538 int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src); 1205 1539 unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); 1206 1540 void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); … … 1519 1853 unsigned int min; /* minimum range */ 1520 1854 unsigned int max; /* maximum range */ 1855 union { 1856 snd_kcontrol_tlv_rw_t *c; 1857 unsigned int *p; 1858 } tlv; 1521 1859 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */ 1522 1860 }; -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106_mixer.c
r77 r84 75 75 #include "ca0106.h" 76 76 77 static DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale, -5150, 75, 1); 77 static DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1); 78 static DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1); 78 79 79 80 static int snd_ca0106_shared_spdif_info(struct snd_kcontrol *kcontrol, … … 336 337 { \ 337 338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 338 .info = snd_ca0106_volume_info, \ 339 .get = snd_ca0106_volume_get, \ 340 .put = snd_ca0106_volume_put, \ 341 .tlv = snd_ca0106_db_scale, \ 339 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 340 SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 341 .info = snd_ca0106_volume_info, \ 342 .get = snd_ca0106_volume_get, \ 343 .put = snd_ca0106_volume_put, \ 344 .tlv = { .p = snd_ca0106_db_scale1 }, \ 342 345 .private_value = ((chid) << 8) | (reg) \ 343 346 } 344 345 347 346 348 static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = { -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1.c
r34 r84 2 2 * The driver for the EMU10K1 (SB Live!) based soundcards 3 3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 4 * 5 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> 6 * Added support for Audigy 2 Value. 4 7 * 5 8 * … … 17 20 * along with this program; if not, write to the Free Software 18 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 19 23 * 20 24 */ … … 121 125 static int dev; 122 126 #endif 123 snd_card_t*card;127 struct snd_card *card; 124 128 struct snd_emu10k1 *emu; 125 129 #ifdef ENABLE_SYNTH 126 snd_seq_device_t*wave = NULL;130 struct snd_seq_device *wave = NULL; 127 131 #endif 128 132 int err; … … 145 149 (long)max_buffer_size[dev] * 1024 * 1024, 146 150 enable_ir[dev], subsystem[dev], 147 &emu)) < 0) { 148 snd_card_free(card); 149 return err; 150 } 151 if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) { 152 snd_card_free(card); 153 return err; 154 } 155 if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) { 156 snd_card_free(card); 157 return err; 158 } 159 if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) { 160 snd_card_free(card); 161 return err; 162 } 151 &emu)) < 0) 152 goto error; 153 card->private_data = emu; 154 if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) 155 goto error; 156 if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) 157 goto error; 158 if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) 159 goto error; 163 160 /* This stores the periods table. */ 164 161 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 165 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &emu->p16v_buffer) < 0) { 166 snd_p16v_free(emu); 167 return -ENOMEM; 168 } 162 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 163 1024, &emu->p16v_buffer)) < 0) 164 goto error; 169 165 } 170 if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) { 171 snd_card_free(card); 172 return err; 166 167 if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) 168 goto error; 169 170 if ((err = snd_emu10k1_timer(emu, 0)) < 0) 171 goto error; 172 173 if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) 174 goto error; 175 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 176 if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) 177 goto error; 173 178 } 174 175 if ((err = snd_emu10k1_timer(emu, 0)) < 0) { 176 snd_card_free(card); 177 return err; 179 if (emu->audigy) { 180 if ((err = snd_emu10k1_audigy_midi(emu)) < 0) 181 goto error; 182 } else { 183 if ((err = snd_emu10k1_midi(emu)) < 0) 184 goto error; 178 185 } 179 180 if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) { 181 snd_card_free(card); 182 return err; 183 } 184 185 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 186 if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) { 187 snd_card_free(card); 188 return err; 189 } 190 } 191 #ifdef TARGET_OS2 192 if (emu->audigy) { 193 if ((err = snd_emu10k1_audigy_midi(emu)) < 0) { 194 snd_card_free(card); 195 return err; 196 } 197 } else { 198 if ((err = snd_emu10k1_midi(emu)) < 0) { 199 snd_card_free(card); 200 return err; 201 } 202 } 203 #endif 204 if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) { 205 snd_card_free(card); 206 return err; 207 } 186 if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) 187 goto error; 208 188 #ifdef ENABLE_SYNTH 209 189 if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, … … 224 204 strcpy(card->driver, emu->card_capabilities->driver); 225 205 strcpy(card->shortname, emu->card_capabilities->name); 226 sprintf(card->longname, "%s (rev.%d) at 0x%lx, irq %i", card->shortname, emu->revision, emu->port, emu->irq); 227 228 // DebugInt3(); 229 230 if ((err = snd_card_register(card)) < 0) { 231 snd_card_free(card); 232 return err; 233 } 206 sprintf(card->longname, 207 "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i", 208 card->shortname, emu->revision, emu->serial, emu->port, emu->irq); 209 210 if ((err = snd_card_register(card)) < 0) 211 goto error; 212 234 213 pci_set_drvdata(pci, card); 235 214 dev++; 236 return 0; 215 return 0; 216 217 error: 218 snd_card_free(card); 219 return err; 237 220 } 238 221 … … 243 226 } 244 227 245 #ifdef TARGET_OS2 228 #ifdef CONFIG_PM 229 static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state) 230 { 231 struct snd_card *card = pci_get_drvdata(pci); 232 struct snd_emu10k1 *emu = card->private_data; 233 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 234 235 snd_pcm_suspend_all(emu->pcm); 236 snd_pcm_suspend_all(emu->pcm_mic); 237 snd_pcm_suspend_all(emu->pcm_efx); 238 snd_pcm_suspend_all(emu->pcm_multi); 239 snd_pcm_suspend_all(emu->pcm_p16v); 240 241 snd_ac97_suspend(emu->ac97); 242 243 snd_emu10k1_efx_suspend(emu); 244 snd_emu10k1_suspend_regs(emu); 245 if (emu->card_capabilities->ca0151_chip) 246 snd_p16v_suspend(emu); 247 248 snd_emu10k1_done(emu); 249 250 pci_disable_device(pci); 251 pci_save_state(pci); 252 pci_set_power_state(pci, PCI_D3hot); 253 return 0; 254 } 255 256 static int snd_emu10k1_resume(struct pci_dev *pci) 257 { 258 struct snd_card *card = pci_get_drvdata(pci); 259 struct snd_emu10k1 *emu = card->private_data; 260 261 pci_set_power_state(pci, PCI_D0); 262 pci_restore_state(pci); 263 if (pci_enable_device(pci) < 0) { 264 printk(KERN_ERR "emu10k1: pci_enable_device failed, " 265 "disabling device\n"); 266 snd_card_disconnect(card); 267 return -EIO; 268 } 269 270 pci_set_master(pci); 271 272 snd_emu10k1_resume_init(emu); 273 snd_emu10k1_efx_resume(emu); 274 snd_ac97_resume(emu->ac97); 275 snd_emu10k1_resume_regs(emu); 276 277 if (emu->card_capabilities->ca0151_chip) 278 snd_p16v_resume(emu); 279 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 280 return 0; 281 } 282 #endif 283 246 284 static struct pci_driver driver = { 247 0, 0, 0, 248 /* name: */ "EMU10K1/Audigy", 249 /* id_table:*/ snd_emu10k1_ids, 250 /* probe: */ snd_card_emu10k1_probe, 251 /* remove: */ snd_card_emu10k1_remove, 252 0, 0 285 .name = "EMU10K1_Audigy", 286 .id_table = snd_emu10k1_ids, 287 .probe = snd_card_emu10k1_probe, 288 .remove = snd_card_emu10k1_remove, 289 #ifdef CONFIG_PM 290 .suspend = snd_emu10k1_suspend, 291 .resume = snd_emu10k1_resume, 292 #endif 253 293 }; 254 #else255 static struct pci_driver driver = {256 name: "EMU10K1/Audigy",257 id_table: snd_emu10k1_ids,258 probe: snd_card_emu10k1_probe,259 remove: __devexit_p(snd_card_emu10k1_remove),260 };261 #endif262 294 263 295 static int __init alsa_card_emu10k1_init(void) 264 296 { 265 int err; 266 267 if ((err = pci_module_init(&driver)) < 0) { 268 #ifdef MODULE 269 // printk(KERN_ERR "EMU10K1/Audigy soundcard not found or device busy\n"); 270 #endif 271 return err; 272 } 273 return 0; 297 return pci_register_driver(&driver); 274 298 } 275 299 276 300 static void __exit alsa_card_emu10k1_exit(void) 277 301 { 278 302 pci_unregister_driver(&driver); 279 303 } 280 304 281 305 module_init(alsa_card_emu10k1_init) 282 306 module_exit(alsa_card_emu10k1_exit) 283 284 #ifndef MODULE285 286 /* format is: snd-emu10k1=enable,index,id,287 seq_ports,max_synth_voices */288 289 static int __init alsa_card_emu10k1_setup(char *str)290 {291 static unsigned __initdata nr_dev = 0;292 293 if (nr_dev >= SNDRV_CARDS)294 return 0;295 (void)(get_option(&str,&enable[nr_dev]) == 2 &&296 get_option(&str,&index[nr_dev]) == 2 &&297 get_id(&str,&id[nr_dev]) == 2 &&298 get_option(&str,&seq_ports[nr_dev]) == 2 &&299 get_option(&str,&max_synth_voices[nr_dev]) == 2);300 nr_dev++;301 return 1;302 }303 304 __setup("snd-emu10k1=", alsa_card_emu10k1_setup);305 306 #endif /* ifndef MODULE */ -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_callback.c
r34 r84 19 19 */ 20 20 21 #define __NO_VERSION__22 21 #include "emu10k1_synth_local.h" 23 22 #include <sound/asoundef.h> … … 29 28 30 29 /* Keeps track of what we are finding */ 31 typedefstruct best_voice {30 struct best_voice { 32 31 unsigned int time; 33 32 int voice; 34 } best_voice_t;33 }; 35 34 36 35 /* 37 36 * prototypes 38 37 */ 39 static void lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, best_voice_t*best, int active_only);38 static void lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, struct best_voice *best, int active_only); 40 39 static struct snd_emux_voice *get_voice(struct snd_emux *emu, struct snd_emux_port *port); 41 40 static int start_voice(struct snd_emux_voice *vp); … … 89 88 { 90 89 struct snd_emux *emu; 91 92 best_voice_tbest[V_END];90 struct snd_emux_voice *vp; 91 struct best_voice best[V_END]; 93 92 unsigned long flags; 94 93 int i; … … 211 210 /* spinlock held! */ 212 211 static void 213 lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, best_voice_t *best, int active_only) 214 { 215 struct snd_emux_voice *vp; 216 best_voice_t *bp; 212 lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, 213 struct best_voice *best, int active_only) 214 { 215 struct snd_emux_voice *vp; 216 struct best_voice *bp; 217 217 int i; 218 218 … … 279 279 { 280 280 struct snd_emu10k1 *hw; 281 282 best_voice_tbest[V_END];281 struct snd_emux_voice *vp; 282 struct best_voice best[V_END]; 283 283 int i; 284 284 … … 313 313 unsigned int temp; 314 314 int ch; 315 316 snd_midi_channel_t*chan;315 unsigned int addr, mapped_offset; 316 struct snd_midi_channel *chan; 317 317 struct snd_emu10k1 *hw; 318 318 struct snd_emu10k1_memblk *emem; -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_main.c
r34 r84 3 3 * Creative Labs, Inc. 4 4 * Routines for control of EMU10K1 chips 5 * 6 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk> 7 * Added support for Audigy 2 Value. 8 * Added EMU 1010 support. 9 * General bug fixes and enhancements. 10 * 5 11 * 6 12 * BUGS: … … 26 32 */ 27 33 28 #define __NO_VERSION__29 34 #include <sound/driver.h> 30 35 #include <linux/delay.h> … … 34 39 #include <sound/core.h> 35 40 #include <sound/emu10k1.h> 41 #include <sound/firmware.h> 36 42 #include "p16v.h" 37 38 #if 0 39 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Creative Labs, Inc."); 40 MODULE_DESCRIPTION("Routines for control of EMU10K1 chips"); 41 MODULE_LICENSE("GPL"); 42 #endif 43 #include "tina2.h" 43 44 44 45 /************************************************************************* … … 91 92 } 92 93 93 static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) 94 static unsigned int spi_dac_init[] = { 95 0x00ff, 96 0x02ff, 97 0x0400, 98 0x0520, 99 0x0600, 100 0x08ff, 101 0x0aff, 102 0x0cff, 103 0x0eff, 104 0x10ff, 105 0x1200, 106 0x1400, 107 0x1480, 108 0x1800, 109 0x1aff, 110 0x1cff, 111 0x1e00, 112 0x0530, 113 0x0602, 114 0x0622, 115 0x1400, 116 }; 117 118 static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) 94 119 { 95 int ch, idx, err;96 120 unsigned int silent_page; 97 98 emu->fx8010.itram_size = (16 * 1024)/2; 99 emu->fx8010.etram_pages.area = NULL; 100 emu->fx8010.etram_pages.bytes = 0; 121 int ch; 122 101 123 /* disable audio and lock cache */ 102 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); 124 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, 125 emu->port + HCFG); 103 126 104 127 /* reset recording buffers */ … … 121 144 snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT); 122 145 /* enable rear left + rear right AC97 slots */ 123 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | AC97SLOT_REAR_LEFT); 146 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | 147 AC97SLOT_REAR_LEFT); 124 148 } 125 149 126 150 /* init envelope engine */ 127 for (ch = 0; ch < NUM_G; ch++) { 128 emu->voices[ch].emu = emu; 129 emu->voices[ch].number = ch; 151 for (ch = 0; ch < NUM_G; ch++) 130 152 snd_emu10k1_voice_init(emu, ch); 131 } 132 133 /* 134 * Init to 0x02109204 : 135 * Clock accuracy = 0 (1000ppm) 136 * Sample Rate = 2 (48kHz) 137 * Audio Channel = 1 (Left of 2) 138 * Source Number = 0 (Unspecified) 139 * Generation Status = 1 (Original for Cat Code 12) 140 * Cat Code = 12 (Digital Signal Mixer) 141 * Mode = 0 (Mode 0) 142 * Emphasis = 0 (None) 143 * CP = 1 (Copyright unasserted) 144 * AN = 0 (Audio data) 145 * P = 0 (Consumer) 146 */ 147 snd_emu10k1_ptr_write(emu, SPCS0, 0, 148 emu->spdif_bits[0] = 149 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 150 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 151 SPCS_GENERATIONSTATUS | 0x00001200 | 152 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 153 snd_emu10k1_ptr_write(emu, SPCS1, 0, 154 emu->spdif_bits[1] = 155 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 156 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 157 SPCS_GENERATIONSTATUS | 0x00001200 | 158 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 159 snd_emu10k1_ptr_write(emu, SPCS2, 0, 160 emu->spdif_bits[2] = 161 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 162 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 163 SPCS_GENERATIONSTATUS | 0x00001200 | 164 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 165 166 if (emu->audigy && emu->revision == 4) { /* audigy2 */ 153 154 snd_emu10k1_ptr_write(emu, SPCS0, 0, emu->spdif_bits[0]); 155 snd_emu10k1_ptr_write(emu, SPCS1, 0, emu->spdif_bits[1]); 156 snd_emu10k1_ptr_write(emu, SPCS2, 0, emu->spdif_bits[2]); 157 158 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ 167 159 /* Hacks for Alice3 to work independent of haP16V driver */ 168 160 u32 tmp; … … 176 168 /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */ 177 169 snd_emu10k1_ptr20_write(emu, SRCSel, 0, 0x14); 178 179 170 /* Setup SRCMulti Input Audio Enable */ 180 171 /* Use 0xFFFFFFFF to enable P16V sounds. */ … … 186 177 snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, 0x78e4); 187 178 } 188 189 179 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ 190 180 /* Hacks for Alice3 to work independent of haP16V driver */ 191 181 u32 tmp; 192 182 193 snd_printk(KERN_ ERR "Audigy2 value:Special config.\n");183 snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); 194 184 //Setup SRCMulti_I2S SamplingRate 195 185 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); … … 215 205 outl(tmp, emu->port + A_IOCFG); 216 206 } 217 218 /* 219 * Clear page with silence & setup all pointers to this page 220 */ 221 memset(emu->silent_page.area, 0, PAGE_SIZE); 222 silent_page = emu->silent_page.addr << 1; 223 for (idx = 0; idx < MAXPAGES; idx++) 224 ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); 207 if (emu->card_capabilities->spi_dac) { /* Audigy 2 ZS Notebook with DAC Wolfson WM8768/WM8568 */ 208 int size, n; 209 size = ARRAY_SIZE(spi_dac_init); 210 for (n=0; n < size; n++) 211 snd_emu10k1_spi_write(emu, spi_dac_init[n]); 212 213 snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); 214 /* Enable GPIOs 215 * GPIO0: Unknown 216 * GPIO1: Speakers-enabled. 217 * GPIO2: Unknown 218 * GPIO3: Unknown 219 * GPIO4: IEC958 Output on. 220 * GPIO5: Unknown 221 * GPIO6: Unknown 222 * GPIO7: Unknown 223 */ 224 outl(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */ 225 226 } 227 225 228 snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); 226 229 snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ … … 233 236 } 234 237 235 /* 236 * Hokay, setup HCFG 237 * Mute Disable Audio = 0 238 * Lock Tank Memory = 1 239 * Lock Sound Memory = 0 240 * Auto Mute = 1 241 */ 242 if (emu->audigy) { 238 if (emu->card_capabilities->emu1010) { 239 outl(HCFG_AUTOMUTE_ASYNC | 240 HCFG_EMU32_SLAVE | 241 HCFG_AUDIOENABLE, emu->port + HCFG); 242 243 /* 244 * Hokay, setup HCFG 245 * Mute Disable Audio = 0 246 * Lock Tank Memory = 1 247 * Lock Sound Memory = 0 248 * Auto Mute = 1 249 */ 250 } else if (emu->audigy) { 243 251 if (emu->revision == 4) /* audigy2 */ 244 252 outl(HCFG_AUDIOENABLE | … … 259 267 260 268 if (enable_ir) { /* enable IR for SB Live */ 261 if (emu->audigy) { 269 if (emu->card_capabilities->emu1010) { 270 ; /* Disable all access to A_IOCFG for the emu1010 */ 271 } else if (emu->audigy) { 262 272 unsigned int reg = inl(emu->port + A_IOCFG); 263 273 outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG); … … 276 286 } 277 287 278 if (emu->audigy) { /* enable analog output */ 288 if (emu->card_capabilities->emu1010) { 289 ; /* Disable all access to A_IOCFG for the emu1010 */ 290 } else if (emu->audigy) { /* enable analog output */ 279 291 unsigned int reg = inl(emu->port + A_IOCFG); 280 292 outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); 281 293 } 282 294 283 /* 284 * Initialize the effect engine 285 */ 286 if ((err = snd_emu10k1_init_efx(emu)) < 0) 287 return err; 288 295 return 0; 296 } 297 298 static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu) 299 { 289 300 /* 290 301 * Enable the audio bit … … 293 304 294 305 /* Enable analog/digital outs on audigy */ 295 if (emu->audigy) { 306 if (emu->card_capabilities->emu1010) { 307 ; /* Disable all access to A_IOCFG for the emu1010 */ 308 } else if (emu->audigy) { 296 309 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); 310 297 311 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ 298 312 /* Unmute Analog now. Set GPO6 to 1 for Apollo. … … 328 342 329 343 snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); 330 331 emu->reserved_page = (struct snd_emu10k1_memblk *)snd_emu10k1_synth_alloc(emu, 4096);332 if (emu->reserved_page)333 emu->reserved_page->map_locked = 1;334 335 return 0;336 344 } 337 345 338 staticint snd_emu10k1_done(struct snd_emu10k1 * emu)346 int snd_emu10k1_done(struct snd_emu10k1 * emu) 339 347 { 340 348 int ch; … … 375 383 snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); 376 384 377 /* remove reserved page */378 if (emu->reserved_page != NULL) {379 snd_emu10k1_synth_free(emu, (snd_util_memblk_t *)emu->reserved_page);380 emu->reserved_page = NULL;381 }382 383 385 /* disable audio and lock cache */ 384 386 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); 385 387 snd_emu10k1_ptr_write(emu, PTB, 0, 0); 386 387 snd_emu10k1_free_efx(emu);388 388 389 389 return 0; … … 533 533 } 534 534 535 static int __devinitsnd_emu10k1_ecard_init(struct snd_emu10k1 * emu)535 static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) 536 536 { 537 537 unsigned int hc_value; … … 573 573 } 574 574 575 static int __devinitsnd_emu10k1_cardbus_init(struct snd_emu10k1 * emu)575 static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) 576 576 { 577 577 unsigned long special_port; … … 594 594 value = inl(special_port); 595 595 596 snd_emu10k1_ptr20_write(emu, TINA2_VOLUME, 0, 0xfefefefe); /* Defaults to 0x30303030 */ 596 597 return 0; 597 598 } 599 600 static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename) 601 { 602 int err; 603 int n, i; 604 int reg; 605 int value; 606 const struct firmware *fw_entry; 607 608 if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) { 609 snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err); 610 return err; 611 } 612 613 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); 614 if (fw_entry->size != 0x133a4) { 615 snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename); 616 return -EINVAL; 617 } 618 619 /* The FPGA is a Xilinx Spartan IIE XC2S50E */ 620 /* GPIO7 -> FPGA PGMN 621 * GPIO6 -> FPGA CCLK 622 * GPIO5 -> FPGA DIN 623 * FPGA CONFIG OFF -> FPGA PGMN 624 */ 625 outl(0x00, emu->port + A_IOCFG); /* Set PGMN low for 1uS. */ 626 udelay(1); 627 outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */ 628 udelay(100); /* Allow FPGA memory to clean */ 629 for(n = 0; n < fw_entry->size; n++) { 630 value=fw_entry->data[n]; 631 for(i = 0; i < 8; i++) { 632 reg = 0x80; 633 if (value & 0x1) 634 reg = reg | 0x20; 635 value = value >> 1; 636 outl(reg, emu->port + A_IOCFG); 637 outl(reg | 0x40, emu->port + A_IOCFG); 638 } 639 } 640 /* After programming, set GPIO bit 4 high again. */ 641 outl(0x10, emu->port + A_IOCFG); 642 643 644 release_firmware(fw_entry); 645 return 0; 646 } 647 648 static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) 649 { 650 unsigned int i; 651 int tmp,tmp2; 652 int reg; 653 int err; 654 const char *hana_filename = "emu/hana.fw"; 655 const char *dock_filename = "emu/audio_dock.fw"; 656 657 snd_printk(KERN_INFO "emu1010: Special config.\n"); 658 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 659 * Lock Sound Memory Cache, Lock Tank Memory Cache, 660 * Mute all codecs. 661 */ 662 663 outl(0x0005a00c, emu->port + HCFG); 664 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 665 * Lock Tank Memory Cache, 666 * Mute all codecs. 667 */ 668 outl(0x0005a004, emu->port + HCFG); 669 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 670 * Mute all codecs. 671 */ 672 outl(0x0005a000, emu->port + HCFG); 673 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 674 * Mute all codecs. 675 */ 676 outl(0x0005a000, emu->port + HCFG); 677 678 /* Disable 48Volt power to Audio Dock */ 679 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); 680 681 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 682 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); 683 snd_printdd("reg1=0x%x\n",reg); 684 if (reg == 0x55) { 685 /* FPGA netlist already present so clear it */ 686 /* Return to programming mode */ 687 688 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02 ); 689 } 690 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); 691 snd_printdd("reg2=0x%x\n",reg); 692 if (reg == 0x55) { 693 /* FPGA failed to return to programming mode */ 694 return -ENODEV; 695 } 696 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 697 if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) { 698 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename); 699 return err; 700 } 701 702 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 703 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); 704 if (reg != 0x55) { 705 /* FPGA failed to be programmed */ 706 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); 707 return -ENODEV; 708 } 709 710 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); 711 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp ); 712 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 ); 713 snd_printk("Hana ver:%d.%d\n",tmp ,tmp2); 714 /* Enable 48Volt power to Audio Dock */ 715 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON ); 716 717 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); 718 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 719 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); 720 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 721 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); 722 /* ADAT input. */ 723 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x01 ); 724 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); 725 /* Set no attenuation on Audio Dock pads. */ 726 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); 727 emu->emu1010.adc_pads = 0x00; 728 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); 729 /* Unmute Audio dock DACs, Headphone source DAC-4. */ 730 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); 731 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); 732 snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp ); 733 /* DAC PADs. */ 734 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f ); 735 emu->emu1010.dac_pads = 0x0f; 736 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); 737 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); 738 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 739 /* SPDIF Format. Set Consumer mode, 24bit, copy enable */ 740 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); 741 /* MIDI routing */ 742 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); 743 /* Unknown. */ 744 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); 745 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */ 746 /* IRQ Enable: All off */ 747 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 ); 748 749 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); 750 snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg); 751 /* Default WCLK set to 48kHz. */ 752 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 ); 753 /* Word Clock source, Internal 48kHz x1 */ 754 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); 755 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); 756 /* Audio Dock LEDs. */ 757 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); 758 759 #if 0 760 /* For 96kHz */ 761 snd_emu1010_fpga_link_dst_src_write(emu, 762 EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1); 763 snd_emu1010_fpga_link_dst_src_write(emu, 764 EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1); 765 snd_emu1010_fpga_link_dst_src_write(emu, 766 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT2); 767 snd_emu1010_fpga_link_dst_src_write(emu, 768 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT2); 769 #endif 770 #if 0 771 /* For 192kHz */ 772 snd_emu1010_fpga_link_dst_src_write(emu, 773 EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1); 774 snd_emu1010_fpga_link_dst_src_write(emu, 775 EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1); 776 snd_emu1010_fpga_link_dst_src_write(emu, 777 EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2); 778 snd_emu1010_fpga_link_dst_src_write(emu, 779 EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_RIGHT2); 780 snd_emu1010_fpga_link_dst_src_write(emu, 781 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT3); 782 snd_emu1010_fpga_link_dst_src_write(emu, 783 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT3); 784 snd_emu1010_fpga_link_dst_src_write(emu, 785 EMU_DST_ALICE2_EMU32_6, EMU_SRC_HAMOA_ADC_LEFT4); 786 snd_emu1010_fpga_link_dst_src_write(emu, 787 EMU_DST_ALICE2_EMU32_7, EMU_SRC_HAMOA_ADC_RIGHT4); 788 #endif 789 #if 1 790 /* For 48kHz */ 791 snd_emu1010_fpga_link_dst_src_write(emu, 792 EMU_DST_ALICE2_EMU32_0, EMU_SRC_DOCK_MIC_A1); 793 snd_emu1010_fpga_link_dst_src_write(emu, 794 EMU_DST_ALICE2_EMU32_1, EMU_SRC_DOCK_MIC_B1); 795 snd_emu1010_fpga_link_dst_src_write(emu, 796 EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2); 797 snd_emu1010_fpga_link_dst_src_write(emu, 798 EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_LEFT2); 799 snd_emu1010_fpga_link_dst_src_write(emu, 800 EMU_DST_ALICE2_EMU32_4, EMU_SRC_DOCK_ADC1_LEFT1); 801 snd_emu1010_fpga_link_dst_src_write(emu, 802 EMU_DST_ALICE2_EMU32_5, EMU_SRC_DOCK_ADC1_RIGHT1); 803 snd_emu1010_fpga_link_dst_src_write(emu, 804 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1); 805 snd_emu1010_fpga_link_dst_src_write(emu, 806 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1); 807 #endif 808 #if 0 809 /* Original */ 810 snd_emu1010_fpga_link_dst_src_write(emu, 811 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HANA_ADAT); 812 snd_emu1010_fpga_link_dst_src_write(emu, 813 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HANA_ADAT + 1); 814 snd_emu1010_fpga_link_dst_src_write(emu, 815 EMU_DST_ALICE2_EMU32_6, EMU_SRC_HANA_ADAT + 2); 816 snd_emu1010_fpga_link_dst_src_write(emu, 817 EMU_DST_ALICE2_EMU32_7, EMU_SRC_HANA_ADAT + 3); 818 snd_emu1010_fpga_link_dst_src_write(emu, 819 EMU_DST_ALICE2_EMU32_8, EMU_SRC_HANA_ADAT + 4); 820 snd_emu1010_fpga_link_dst_src_write(emu, 821 EMU_DST_ALICE2_EMU32_9, EMU_SRC_HANA_ADAT + 5); 822 snd_emu1010_fpga_link_dst_src_write(emu, 823 EMU_DST_ALICE2_EMU32_A, EMU_SRC_HANA_ADAT + 6); 824 snd_emu1010_fpga_link_dst_src_write(emu, 825 EMU_DST_ALICE2_EMU32_B, EMU_SRC_HANA_ADAT + 7); 826 snd_emu1010_fpga_link_dst_src_write(emu, 827 EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_MIC_A1); 828 snd_emu1010_fpga_link_dst_src_write(emu, 829 EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_MIC_B1); 830 snd_emu1010_fpga_link_dst_src_write(emu, 831 EMU_DST_ALICE2_EMU32_E, EMU_SRC_HAMOA_ADC_LEFT2); 832 snd_emu1010_fpga_link_dst_src_write(emu, 833 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2); 834 #endif 835 for (i=0;i < 0x20;i++) { 836 /* AudioDock Elink <- Silence */ 837 snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE); 838 } 839 for (i=0;i < 4;i++) { 840 /* Hana SPDIF Out <- Silence */ 841 snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE); 842 } 843 for (i=0;i < 7;i++) { 844 /* Hamoa DAC <- Silence */ 845 snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE); 846 } 847 for (i=0;i < 7;i++) { 848 /* Hana ADAT Out <- Silence */ 849 snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE); 850 } 851 snd_emu1010_fpga_link_dst_src_write(emu, 852 EMU_DST_ALICE_I2S0_LEFT, EMU_SRC_DOCK_ADC1_LEFT1); 853 snd_emu1010_fpga_link_dst_src_write(emu, 854 EMU_DST_ALICE_I2S0_RIGHT, EMU_SRC_DOCK_ADC1_RIGHT1); 855 snd_emu1010_fpga_link_dst_src_write(emu, 856 EMU_DST_ALICE_I2S1_LEFT, EMU_SRC_DOCK_ADC2_LEFT1); 857 snd_emu1010_fpga_link_dst_src_write(emu, 858 EMU_DST_ALICE_I2S1_RIGHT, EMU_SRC_DOCK_ADC2_RIGHT1); 859 snd_emu1010_fpga_link_dst_src_write(emu, 860 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1); 861 snd_emu1010_fpga_link_dst_src_write(emu, 862 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1); 863 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all 864 865 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); 866 867 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, 868 * Lock Sound Memory Cache, Lock Tank Memory Cache, 869 * Mute all codecs. 870 */ 871 outl(0x0000a000, emu->port + HCFG); 872 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, 873 * Lock Sound Memory Cache, Lock Tank Memory Cache, 874 * Un-Mute all codecs. 875 */ 876 outl(0x0000a001, emu->port + HCFG); 877 878 /* Initial boot complete. Now patches */ 879 880 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); 881 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ 882 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ 883 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ 884 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ 885 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 886 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ 887 888 /* Delay to allow Audio Dock to settle */ 889 msleep(100); 890 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ 891 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); /* OPTIONS: Which cards are attached to the EMU */ 892 /* FIXME: The loading of this should be able to happen any time, 893 * as the user can plug/unplug it at any time 894 */ 895 if (reg & (EMU_HANA_OPTION_DOCK_ONLINE | EMU_HANA_OPTION_DOCK_OFFLINE) ) { 896 /* Audio Dock attached */ 897 /* Return to Audio Dock programming mode */ 898 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 899 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); 900 if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) { 901 return err; 902 } 903 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 904 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ® ); 905 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); 906 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 907 snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); 908 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); 909 if (reg != 0x55) { 910 /* FPGA failed to be programmed */ 911 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); 912 return 0; 913 return -ENODEV; 914 } 915 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); 916 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); 917 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); 918 snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); 919 } 920 #if 0 921 snd_emu1010_fpga_link_dst_src_write(emu, 922 EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */ 923 snd_emu1010_fpga_link_dst_src_write(emu, 924 EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32B + 3); /* ALICE2 bus 0xa3 */ 925 snd_emu1010_fpga_link_dst_src_write(emu, 926 EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 2); /* ALICE2 bus 0xb2 */ 927 snd_emu1010_fpga_link_dst_src_write(emu, 928 EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); /* ALICE2 bus 0xb3 */ 929 #endif 930 /* Default outputs */ 931 snd_emu1010_fpga_link_dst_src_write(emu, 932 EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ 933 emu->emu1010.output_source[0] = 21; 934 snd_emu1010_fpga_link_dst_src_write(emu, 935 EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); 936 emu->emu1010.output_source[1] = 22; 937 snd_emu1010_fpga_link_dst_src_write(emu, 938 EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2); 939 emu->emu1010.output_source[2] = 23; 940 snd_emu1010_fpga_link_dst_src_write(emu, 941 EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); 942 emu->emu1010.output_source[3] = 24; 943 snd_emu1010_fpga_link_dst_src_write(emu, 944 EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4); 945 emu->emu1010.output_source[4] = 25; 946 snd_emu1010_fpga_link_dst_src_write(emu, 947 EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5); 948 emu->emu1010.output_source[5] = 26; 949 snd_emu1010_fpga_link_dst_src_write(emu, 950 EMU_DST_DOCK_DAC4_LEFT1, EMU_SRC_ALICE_EMU32A + 6); 951 emu->emu1010.output_source[6] = 27; 952 snd_emu1010_fpga_link_dst_src_write(emu, 953 EMU_DST_DOCK_DAC4_RIGHT1, EMU_SRC_ALICE_EMU32A + 7); 954 emu->emu1010.output_source[7] = 28; 955 snd_emu1010_fpga_link_dst_src_write(emu, 956 EMU_DST_DOCK_PHONES_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ 957 emu->emu1010.output_source[8] = 21; 958 snd_emu1010_fpga_link_dst_src_write(emu, 959 EMU_DST_DOCK_PHONES_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); 960 emu->emu1010.output_source[9] = 22; 961 snd_emu1010_fpga_link_dst_src_write(emu, 962 EMU_DST_DOCK_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ 963 emu->emu1010.output_source[10] = 21; 964 snd_emu1010_fpga_link_dst_src_write(emu, 965 EMU_DST_DOCK_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); 966 emu->emu1010.output_source[11] = 22; 967 snd_emu1010_fpga_link_dst_src_write(emu, 968 EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ 969 emu->emu1010.output_source[12] = 21; 970 snd_emu1010_fpga_link_dst_src_write(emu, 971 EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); 972 emu->emu1010.output_source[13] = 22; 973 snd_emu1010_fpga_link_dst_src_write(emu, 974 EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ 975 emu->emu1010.output_source[14] = 21; 976 snd_emu1010_fpga_link_dst_src_write(emu, 977 EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); 978 emu->emu1010.output_source[15] = 22; 979 snd_emu1010_fpga_link_dst_src_write(emu, 980 EMU_DST_HANA_ADAT, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ 981 emu->emu1010.output_source[16] = 21; 982 snd_emu1010_fpga_link_dst_src_write(emu, 983 EMU_DST_HANA_ADAT + 1, EMU_SRC_ALICE_EMU32A + 1); 984 emu->emu1010.output_source[17] = 22; 985 snd_emu1010_fpga_link_dst_src_write(emu, 986 EMU_DST_HANA_ADAT + 2, EMU_SRC_ALICE_EMU32A + 2); 987 emu->emu1010.output_source[18] = 23; 988 snd_emu1010_fpga_link_dst_src_write(emu, 989 EMU_DST_HANA_ADAT + 3, EMU_SRC_ALICE_EMU32A + 3); 990 emu->emu1010.output_source[19] = 24; 991 snd_emu1010_fpga_link_dst_src_write(emu, 992 EMU_DST_HANA_ADAT + 4, EMU_SRC_ALICE_EMU32A + 4); 993 emu->emu1010.output_source[20] = 25; 994 snd_emu1010_fpga_link_dst_src_write(emu, 995 EMU_DST_HANA_ADAT + 5, EMU_SRC_ALICE_EMU32A + 5); 996 emu->emu1010.output_source[21] = 26; 997 snd_emu1010_fpga_link_dst_src_write(emu, 998 EMU_DST_HANA_ADAT + 6, EMU_SRC_ALICE_EMU32A + 6); 999 emu->emu1010.output_source[22] = 27; 1000 snd_emu1010_fpga_link_dst_src_write(emu, 1001 EMU_DST_HANA_ADAT + 7, EMU_SRC_ALICE_EMU32A + 7); 1002 emu->emu1010.output_source[23] = 28; 1003 1004 /* TEMP: Select SPDIF in/out */ 1005 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ 1006 1007 /* TEMP: Select 48kHz SPDIF out */ 1008 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ 1009 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */ 1010 /* Word Clock source, Internal 48kHz x1 */ 1011 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); 1012 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); 1013 emu->emu1010.internal_clock = 1; /* 48000 */ 1014 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */ 1015 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */ 1016 //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */ 1017 //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */ 1018 //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */ 1019 1020 return 0; 1021 } 1022 598 1023 599 1024 /* 600 1025 * Create the EMU10K1 instance 601 1026 */ 1027 1028 #ifdef CONFIG_PM 1029 static int alloc_pm_buffer(struct snd_emu10k1 *emu); 1030 static void free_pm_buffer(struct snd_emu10k1 *emu); 1031 #endif 602 1032 603 1033 static int snd_emu10k1_free(struct snd_emu10k1 *emu) … … 606 1036 snd_emu10k1_fx8010_tram_setup(emu, 0); 607 1037 snd_emu10k1_done(emu); 608 } 1038 /* remove reserved page */ 1039 if (emu->reserved_page) { 1040 snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page); 1041 emu->reserved_page = NULL; 1042 } 1043 snd_emu10k1_free_efx(emu); 1044 } 1045 if (emu->card_capabilities->emu1010) { 1046 /* Disable 48Volt power to Audio Dock */ 1047 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); 1048 } 1049 609 1050 if (emu->memhdr) 610 1051 snd_util_memhdr_free(emu->memhdr); … … 613 1054 if (emu->ptb_pages.area) 614 1055 snd_dma_free_pages(&emu->ptb_pages); 615 if (emu->page_ptr_table) 616 vfree(emu->page_ptr_table); 617 if (emu->page_addr_table) 618 vfree(emu->page_addr_table); 1056 vfree(emu->page_ptr_table); 1057 vfree(emu->page_addr_table); 1058 #ifdef CONFIG_PM 1059 free_pm_buffer(emu); 1060 #endif 619 1061 if (emu->irq >= 0) 620 1062 free_irq(emu->irq, (void *)emu); 621 1063 if (emu->port) 622 1064 pci_release_regions(emu->pci); 623 if (emu-> audigy && emu->revision == 4) /* P16V */1065 if (emu->card_capabilities->ca0151_chip) /* P16V */ 624 1066 snd_p16v_free(emu); 1067 pci_disable_device(emu->pci); 625 1068 kfree(emu); 626 1069 return 0; 627 1070 } 628 1071 629 static int snd_emu10k1_dev_free(s nd_device_t*device)1072 static int snd_emu10k1_dev_free(struct snd_device *device) 630 1073 { 631 1074 struct snd_emu10k1 *emu = device->device_data; … … 633 1076 } 634 1077 635 /* vendor, device, subsystem, emu10k1_chip, emu10k2_chip, ca0102_chip, ca0108_chip, ca0151_chip, spk71, spdif_bug, ac97_chip, ecard, driver, name */636 1078 static struct snd_emu_chip_details emu_chip_details[] = { 637 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ 638 /* Tested by James@superbug.co.uk 3rd July 2005 */ 639 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, 640 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", 641 .id = "Audigy2", 642 .emu10k2_chip = 1, 643 .ca0108_chip = 1, 644 .spk71 = 1, 645 .ac97_chip = 1} , 646 /* Audigy 2 ZS Notebook Cardbus card.*/ 647 /* Tested by James@superbug.co.uk 30th October 2005 */ 648 /* Not working yet, but progressing. */ 649 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, 650 .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", 651 .id = "Audigy2", 652 .emu10k2_chip = 1, 653 .ca0108_chip = 1, 654 .ca_cardbus_chip = 1, 655 .spk71 = 1} , 656 {.vendor = 0x1102, .device = 0x0008, 657 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 658 .id = "Audigy2", 659 .emu10k2_chip = 1, 660 .ca0108_chip = 1, 661 .ac97_chip = 1} , 662 /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */ 663 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, 664 .driver = "Audigy2", .name = "E-mu 1212m [4001]", 665 .id = "EMU1212m", 666 .emu10k2_chip = 1, 667 .ca0102_chip = 1, 668 .ecard = 1} , 669 /* Tested by James@superbug.co.uk 3rd July 2005 */ 670 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 671 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 672 .id = "Audigy2", 673 .emu10k2_chip = 1, 674 .ca0102_chip = 1, 675 .ca0151_chip = 1, 676 .spk71 = 1, 677 .spdif_bug = 1, 678 .ac97_chip = 1} , 679 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 680 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 681 .id = "Audigy2", 682 .emu10k2_chip = 1, 683 .ca0102_chip = 1, 684 .ca0151_chip = 1, 685 .spk71 = 1, 686 .spdif_bug = 1, 687 .ac97_chip = 1} , 688 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 689 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 690 .id = "Audigy2", 691 .emu10k2_chip = 1, 692 .ca0102_chip = 1, 693 .ca0151_chip = 1, 694 .spk71 = 1, 695 .spdif_bug = 1, 696 .ac97_chip = 1} , 697 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, 698 .driver = "Audigy2", .name = "Audigy 2 [SB0240]", 699 .id = "Audigy2", 700 .emu10k2_chip = 1, 701 .ca0102_chip = 1, 702 .ca0151_chip = 1, 703 .spk71 = 1, 704 .spdif_bug = 1, 705 .ac97_chip = 1} , 706 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 707 .driver = "Audigy2", .name = "Audigy 2 EX [1005]", 708 .id = "Audigy2", 709 .emu10k2_chip = 1, 710 .ca0102_chip = 1, 711 .ca0151_chip = 1, 712 .spdif_bug = 1} , 713 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 714 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 715 .id = "Audigy2", 716 .emu10k2_chip = 1, 717 .ca0102_chip = 1, 718 .ca0151_chip = 1, 719 .spk71 = 1, 720 .spdif_bug = 1, 721 .ac97_chip = 1} , 722 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, 723 .driver = "Audigy2", .name = "Audigy 2 [Unknown]", 724 .id = "Audigy2", 725 .emu10k2_chip = 1, 726 .ca0102_chip = 1, 727 .ca0151_chip = 1, 728 .spdif_bug = 1, 729 .ac97_chip = 1} , 730 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, 731 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 732 .id = "Audigy", 733 .emu10k2_chip = 1, 734 .ca0102_chip = 1, 735 .ac97_chip = 1} , 736 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, 737 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", 738 .id = "Audigy", 739 .emu10k2_chip = 1, 740 .ca0102_chip = 1, 741 .spdif_bug = 1, 742 .ac97_chip = 1} , 743 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, 744 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 745 .id = "Audigy", 746 .emu10k2_chip = 1, 747 .ca0102_chip = 1, 748 .ac97_chip = 1} , 749 {.vendor = 0x1102, .device = 0x0004, 750 .driver = "Audigy", .name = "Audigy 1 [Unknown]", 751 .id = "Audigy", 752 .emu10k2_chip = 1, 753 .ca0102_chip = 1, 754 .ac97_chip = 1} , 755 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, 756 .driver = "EMU10K1", .name = "SBLive! [SB0105]", 757 .id = "Live", 758 .emu10k1_chip = 1, 759 .ac97_chip = 1, 760 .sblive51 = 1} , 761 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, 762 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", 763 .id = "Live", 764 .emu10k1_chip = 1, 765 .ac97_chip = 1, 766 .sblive51 = 1} , 767 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, 768 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", 769 .id = "Live", 770 .emu10k1_chip = 1, 771 .ac97_chip = 1, 772 .sblive51 = 1}, 773 /* Tested by Thomas Zehetbauer 27th Aug 2005 */ 774 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, 775 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", 776 .id = "Live", 777 .emu10k1_chip = 1, 778 .ac97_chip = 1, 779 .sblive51 = 1} , 780 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 781 .driver = "EMU10K1", .name = "SB Live 5.1", 782 .id = "Live", 783 .emu10k1_chip = 1, 784 .ac97_chip = 1, 785 .sblive51 = 1} , 786 /* Tested by alsa bugtrack user "hus" 12th Sept 2005 */ 787 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 788 .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", 789 .id = "Live", 790 .emu10k1_chip = 1, 791 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum 792 * share the same IDs! 793 */ 794 .sblive51 = 1} , 795 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 796 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 797 .id = "Live", 798 .emu10k1_chip = 1, 799 .ac97_chip = 1, 800 .sblive51 = 1} , 801 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, 802 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", 803 .id = "Live", 804 .emu10k1_chip = 1, 805 .ac97_chip = 1} , 806 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, 807 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", 808 .id = "Live", 809 .emu10k1_chip = 1, 810 .ac97_chip = 1, 811 .sblive51 = 1} , 812 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, 813 .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", 814 .id = "Live", 815 .emu10k1_chip = 1, 816 .ac97_chip = 1, 817 .sblive51 = 1} , 818 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, 819 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", 820 .id = "Live", 821 .emu10k1_chip = 1, 822 .ac97_chip = 1, 823 .sblive51 = 1} , 824 /* Tested by James@superbug.co.uk 3rd July 2005 */ 825 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, 826 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", 827 .id = "Live", 828 .emu10k1_chip = 1, 829 .ac97_chip = 1, 830 .sblive51 = 1} , 831 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, 832 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", 833 .id = "Live", 834 .emu10k1_chip = 1, 835 .ac97_chip = 1, 836 .sblive51 = 1} , 837 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, 838 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", 839 .id = "Live", 840 .emu10k1_chip = 1, 841 .ac97_chip = 1, 842 .sblive51 = 1} , 843 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, 844 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", 845 .id = "Live", 846 .emu10k1_chip = 1, 847 .ac97_chip = 1, 848 .sblive51 = 1} , 849 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 850 .driver = "EMU10K1", .name = "E-mu APS [4001]", 851 .id = "APS", 852 .emu10k1_chip = 1, 853 .ecard = 1} , 854 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, 855 .driver = "EMU10K1", .name = "SBLive! [CT4620]", 856 .id = "Live", 857 .emu10k1_chip = 1, 858 .ac97_chip = 1, 859 .sblive51 = 1} , 860 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, 861 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", 862 .id = "Live", 863 .emu10k1_chip = 1, 864 .ac97_chip = 1, 865 .sblive51 = 1} , 866 {.vendor = 0x1102, .device = 0x0002, 867 .driver = "EMU10K1", .name = "SB Live [Unknown]", 868 .id = "Live", 869 .emu10k1_chip = 1, 870 .ac97_chip = 1, 871 .sblive51 = 1} , 872 {0 } /* terminator */ 1079 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ 1080 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1081 /* DSP: CA0108-IAT 1082 * DAC: CS4382-KQ 1083 * ADC: Philips 1361T 1084 * AC97: STAC9750 1085 * CA0151: None 1086 */ 1087 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, 1088 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", 1089 .id = "Audigy2", 1090 .emu10k2_chip = 1, 1091 .ca0108_chip = 1, 1092 .spk71 = 1, 1093 .ac97_chip = 1} , 1094 /* Audigy4 (Not PRO) SB0610 */ 1095 /* Tested by James@superbug.co.uk 4th April 2006 */ 1096 /* A_IOCFG bits 1097 * Output 1098 * 0: ? 1099 * 1: ? 1100 * 2: ? 1101 * 3: 0 - Digital Out, 1 - Line in 1102 * 4: ? 1103 * 5: ? 1104 * 6: ? 1105 * 7: ? 1106 * Input 1107 * 8: ? 1108 * 9: ? 1109 * A: Green jack sense (Front) 1110 * B: ? 1111 * C: Black jack sense (Rear/Side Right) 1112 * D: Yellow jack sense (Center/LFE/Side Left) 1113 * E: ? 1114 * F: ? 1115 * 1116 * Digital Out/Line in switch using A_IOCFG bit 3 (0x08) 1117 * 0 - Digital Out 1118 * 1 - Line in 1119 */ 1120 /* Mic input not tested. 1121 * Analog CD input not tested 1122 * Digital Out not tested. 1123 * Line in working. 1124 * Audio output 5.1 working. Side outputs not working. 1125 */ 1126 /* DSP: CA10300-IAT LF 1127 * DAC: Cirrus Logic CS4382-KQZ 1128 * ADC: Philips 1361T 1129 * AC97: Sigmatel STAC9750 1130 * CA0151: None 1131 */ 1132 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102, 1133 .driver = "Audigy2", .name = "Audigy 4 [SB0610]", 1134 .id = "Audigy2", 1135 .emu10k2_chip = 1, 1136 .ca0108_chip = 1, 1137 .spk71 = 1, 1138 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1139 .ac97_chip = 1} , 1140 /* Audigy 2 ZS Notebook Cardbus card.*/ 1141 /* Tested by James@superbug.co.uk 22th December 2005 */ 1142 /* Audio output 7.1/Headphones working. 1143 * Digital output working. (AC3 not checked, only PCM) 1144 * Audio inputs not tested. 1145 */ 1146 /* DSP: Tina2 1147 * DAC: Wolfson WM8768/WM8568 1148 * ADC: Wolfson WM8775 1149 * AC97: None 1150 * CA0151: None 1151 */ 1152 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, 1153 .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", 1154 .id = "Audigy2", 1155 .emu10k2_chip = 1, 1156 .ca0108_chip = 1, 1157 .ca_cardbus_chip = 1, 1158 .spi_dac = 1, 1159 .spk71 = 1} , 1160 {.vendor = 0x1102, .device = 0x0008, 1161 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1162 .id = "Audigy2", 1163 .emu10k2_chip = 1, 1164 .ca0108_chip = 1, 1165 .ac97_chip = 1} , 1166 /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */ 1167 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, 1168 .driver = "Audigy2", .name = "E-mu 1010 [4001]", 1169 .id = "EMU1010", 1170 .emu10k2_chip = 1, 1171 .ca0102_chip = 1, 1172 .spk71 = 1, 1173 .emu1010 = 1} , 1174 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1175 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 1176 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 1177 .id = "Audigy2", 1178 .emu10k2_chip = 1, 1179 .ca0102_chip = 1, 1180 .ca0151_chip = 1, 1181 .spk71 = 1, 1182 .spdif_bug = 1, 1183 .ac97_chip = 1} , 1184 /* Tested by shane-alsa@cm.nu 5th Nov 2005 */ 1185 /* The 0x20061102 does have SB0350 written on it 1186 * Just like 0x20021102 1187 */ 1188 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, 1189 .driver = "Audigy2", .name = "Audigy 2 [SB0350b]", 1190 .id = "Audigy2", 1191 .emu10k2_chip = 1, 1192 .ca0102_chip = 1, 1193 .ca0151_chip = 1, 1194 .spk71 = 1, 1195 .spdif_bug = 1, 1196 .ac97_chip = 1} , 1197 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1198 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 1199 .id = "Audigy2", 1200 .emu10k2_chip = 1, 1201 .ca0102_chip = 1, 1202 .ca0151_chip = 1, 1203 .spk71 = 1, 1204 .spdif_bug = 1, 1205 .ac97_chip = 1} , 1206 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 1207 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 1208 .id = "Audigy2", 1209 .emu10k2_chip = 1, 1210 .ca0102_chip = 1, 1211 .ca0151_chip = 1, 1212 .spk71 = 1, 1213 .spdif_bug = 1, 1214 .ac97_chip = 1} , 1215 /* Audigy 2 */ 1216 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1217 /* DSP: CA0102-IAT 1218 * DAC: CS4382-KQ 1219 * ADC: Philips 1361T 1220 * AC97: STAC9721 1221 * CA0151: Yes 1222 */ 1223 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, 1224 .driver = "Audigy2", .name = "Audigy 2 [SB0240]", 1225 .id = "Audigy2", 1226 .emu10k2_chip = 1, 1227 .ca0102_chip = 1, 1228 .ca0151_chip = 1, 1229 .spk71 = 1, 1230 .spdif_bug = 1, 1231 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1232 .ac97_chip = 1} , 1233 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 1234 .driver = "Audigy2", .name = "Audigy 2 EX [1005]", 1235 .id = "Audigy2", 1236 .emu10k2_chip = 1, 1237 .ca0102_chip = 1, 1238 .ca0151_chip = 1, 1239 .spk71 = 1, 1240 .spdif_bug = 1} , 1241 /* Dell OEM/Creative Labs Audigy 2 ZS */ 1242 /* See ALSA bug#1365 */ 1243 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, 1244 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]", 1245 .id = "Audigy2", 1246 .emu10k2_chip = 1, 1247 .ca0102_chip = 1, 1248 .ca0151_chip = 1, 1249 .spk71 = 1, 1250 .spdif_bug = 1, 1251 .ac97_chip = 1} , 1252 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 1253 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 1254 .id = "Audigy2", 1255 .emu10k2_chip = 1, 1256 .ca0102_chip = 1, 1257 .ca0151_chip = 1, 1258 .spk71 = 1, 1259 .spdif_bug = 1, 1260 .ac97_chip = 1} , 1261 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, 1262 .driver = "Audigy2", .name = "Audigy 2 [Unknown]", 1263 .id = "Audigy2", 1264 .emu10k2_chip = 1, 1265 .ca0102_chip = 1, 1266 .ca0151_chip = 1, 1267 .spdif_bug = 1, 1268 .ac97_chip = 1} , 1269 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, 1270 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1271 .id = "Audigy", 1272 .emu10k2_chip = 1, 1273 .ca0102_chip = 1, 1274 .ac97_chip = 1} , 1275 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, 1276 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", 1277 .id = "Audigy", 1278 .emu10k2_chip = 1, 1279 .ca0102_chip = 1, 1280 .spdif_bug = 1, 1281 .ac97_chip = 1} , 1282 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, 1283 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1284 .id = "Audigy", 1285 .emu10k2_chip = 1, 1286 .ca0102_chip = 1, 1287 .ac97_chip = 1} , 1288 {.vendor = 0x1102, .device = 0x0004, 1289 .driver = "Audigy", .name = "Audigy 1 [Unknown]", 1290 .id = "Audigy", 1291 .emu10k2_chip = 1, 1292 .ca0102_chip = 1, 1293 .ac97_chip = 1} , 1294 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, 1295 .driver = "EMU10K1", .name = "SBLive! [SB0105]", 1296 .id = "Live", 1297 .emu10k1_chip = 1, 1298 .ac97_chip = 1, 1299 .sblive51 = 1} , 1300 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, 1301 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", 1302 .id = "Live", 1303 .emu10k1_chip = 1, 1304 .ac97_chip = 1, 1305 .sblive51 = 1} , 1306 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, 1307 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", 1308 .id = "Live", 1309 .emu10k1_chip = 1, 1310 .ac97_chip = 1, 1311 .sblive51 = 1}, 1312 /* Tested by ALSA bug#1680 26th December 2005 */ 1313 /* note: It really has SB0220 written on the card. */ 1314 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, 1315 .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", 1316 .id = "Live", 1317 .emu10k1_chip = 1, 1318 .ac97_chip = 1, 1319 .sblive51 = 1} , 1320 /* Tested by Thomas Zehetbauer 27th Aug 2005 */ 1321 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, 1322 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", 1323 .id = "Live", 1324 .emu10k1_chip = 1, 1325 .ac97_chip = 1, 1326 .sblive51 = 1} , 1327 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102, 1328 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", 1329 .id = "Live", 1330 .emu10k1_chip = 1, 1331 .ac97_chip = 1, 1332 .sblive51 = 1} , 1333 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 1334 .driver = "EMU10K1", .name = "SB Live 5.1", 1335 .id = "Live", 1336 .emu10k1_chip = 1, 1337 .ac97_chip = 1, 1338 .sblive51 = 1} , 1339 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ 1340 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 1341 .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", 1342 .id = "Live", 1343 .emu10k1_chip = 1, 1344 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum 1345 * share the same IDs! 1346 */ 1347 .sblive51 = 1} , 1348 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 1349 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 1350 .id = "Live", 1351 .emu10k1_chip = 1, 1352 .ac97_chip = 1, 1353 .sblive51 = 1} , 1354 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, 1355 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", 1356 .id = "Live", 1357 .emu10k1_chip = 1, 1358 .ac97_chip = 1} , 1359 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, 1360 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", 1361 .id = "Live", 1362 .emu10k1_chip = 1, 1363 .ac97_chip = 1, 1364 .sblive51 = 1} , 1365 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, 1366 .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", 1367 .id = "Live", 1368 .emu10k1_chip = 1, 1369 .ac97_chip = 1, 1370 .sblive51 = 1} , 1371 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, 1372 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", 1373 .id = "Live", 1374 .emu10k1_chip = 1, 1375 .ac97_chip = 1, 1376 .sblive51 = 1} , 1377 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1378 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, 1379 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", 1380 .id = "Live", 1381 .emu10k1_chip = 1, 1382 .ac97_chip = 1, 1383 .sblive51 = 1} , 1384 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, 1385 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", 1386 .id = "Live", 1387 .emu10k1_chip = 1, 1388 .ac97_chip = 1, 1389 .sblive51 = 1} , 1390 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, 1391 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", 1392 .id = "Live", 1393 .emu10k1_chip = 1, 1394 .ac97_chip = 1, 1395 .sblive51 = 1} , 1396 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, 1397 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", 1398 .id = "Live", 1399 .emu10k1_chip = 1, 1400 .ac97_chip = 1, 1401 .sblive51 = 1} , 1402 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 1403 .driver = "EMU10K1", .name = "E-mu APS [4001]", 1404 .id = "APS", 1405 .emu10k1_chip = 1, 1406 .ecard = 1} , 1407 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, 1408 .driver = "EMU10K1", .name = "SBLive! [CT4620]", 1409 .id = "Live", 1410 .emu10k1_chip = 1, 1411 .ac97_chip = 1, 1412 .sblive51 = 1} , 1413 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, 1414 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", 1415 .id = "Live", 1416 .emu10k1_chip = 1, 1417 .ac97_chip = 1, 1418 .sblive51 = 1} , 1419 {.vendor = 0x1102, .device = 0x0002, 1420 .driver = "EMU10K1", .name = "SB Live [Unknown]", 1421 .id = "Live", 1422 .emu10k1_chip = 1, 1423 .ac97_chip = 1, 1424 .sblive51 = 1} , 1425 {0 } /* terminator */ 873 1426 }; 874 1427 875 int __devinit snd_emu10k1_create(s nd_card_t *card,1428 int __devinit snd_emu10k1_create(struct snd_card *card, 876 1429 struct pci_dev * pci, 877 1430 unsigned short extin_mask, … … 883 1436 { 884 1437 struct snd_emu10k1 *emu; 885 int err;1438 int idx, err; 886 1439 int is_audigy; 887 1440 unsigned char revision; 1441 unsigned int silent_page; 888 1442 const struct snd_emu_chip_details *c; 889 #ifdef TARGET_OS2 890 static snd_device_ops_t ops = { 891 snd_emu10k1_dev_free,0,0,0 1443 static struct snd_device_ops ops = { 1444 .dev_free = snd_emu10k1_dev_free, 892 1445 }; 893 #else 894 static snd_device_ops_t ops = { 895 dev_free: snd_emu10k1_dev_free, 896 }; 897 #endif 1446 898 1447 *remu = NULL; 899 1448 … … 902 1451 return err; 903 1452 904 emu = (struct snd_emu10k1 *)kzalloc(sizeof(*emu), GFP_KERNEL); 905 if (emu == NULL) 1453 emu = kzalloc(sizeof(*emu), GFP_KERNEL); 1454 if (emu == NULL) { 1455 pci_disable_device(pci); 906 1456 return -ENOMEM; 907 1457 } 908 1458 emu->card = card; 909 1459 spin_lock_init(&emu->reg_lock); … … 912 1462 spin_lock_init(&emu->synth_lock); 913 1463 spin_lock_init(&emu->memblk_lock); 914 init_MUTEX(&emu->ptb_lock);915 1464 init_MUTEX(&emu->fx8010.lock); 916 1465 INIT_LIST_HEAD(&emu->mapped_link_head); … … 925 1474 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 926 1475 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 927 emu->card_type = EMU10K1_CARD_CREATIVE;928 1476 snd_printk("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); 929 1477 … … 937 1485 if (c->subsystem && (c->subsystem != emu->serial) ) 938 1486 continue; 939 if (c->revision && c->revision != emu->revision)940 continue;1487 if (c->revision && c->revision != emu->revision) 1488 continue; 941 1489 } 942 1490 break; … … 958 1506 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n", 959 1507 c->name, pci->vendor, pci->device, emu->serial); 1508 1509 if (!*card->id && c->id) { 1510 int i, n = 0; 1511 strlcpy(card->id, c->id, sizeof(card->id)); 1512 for (;;) { 1513 for (i = 0; i < snd_ecards_limit; i++) { 1514 if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id)) 1515 break; 1516 } 1517 if (i >= snd_ecards_limit) 1518 break; 1519 n++; 1520 if (n >= SNDRV_CARDS) 1521 break; 1522 sprintf(card->id, "%s_%d", c->id, n); 1523 } 1524 } 1525 960 1526 is_audigy = emu->audigy = c->emu10k2_chip; 1527 961 1528 /* set the DMA transfer mask */ 962 1529 emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK; … … 969 1536 if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { 970 1537 kfree(emu); 1538 pci_disable_device(pci); 971 1539 return err; 972 1540 } … … 982 1550 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 983 1551 32 * 1024, &emu->ptb_pages) < 0) { 984 snd_emu10k1_free(emu);985 return -ENOMEM;1552 err = -ENOMEM; 1553 goto error; 986 1554 } 987 1555 … … 989 1557 emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long)); 990 1558 if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { 991 snd_emu10k1_free(emu);992 return -ENOMEM;1559 err = -ENOMEM; 1560 goto error; 993 1561 } 994 1562 995 1563 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 996 1564 EMUPAGESIZE, &emu->silent_page) < 0) { 997 snd_emu10k1_free(emu);998 return -ENOMEM;1565 err = -ENOMEM; 1566 goto error; 999 1567 } 1000 1568 emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); 1001 1569 if (emu->memhdr == NULL) { 1002 snd_emu10k1_free(emu); 1003 return -ENOMEM; 1004 } 1005 emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - sizeof(snd_util_memblk_t); 1570 err = -ENOMEM; 1571 goto error; 1572 } 1573 emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - 1574 sizeof(struct snd_util_memblk); 1006 1575 1007 1576 pci_set_master(pci); … … 1014 1583 emu->fx8010.extin_mask = extin_mask; 1015 1584 emu->fx8010.extout_mask = extout_mask; 1585 emu->enable_ir = enable_ir; 1016 1586 1017 1587 if (emu->card_capabilities->ecard) { 1018 if ((err = snd_emu10k1_ecard_init(emu)) < 0) { 1019 snd_emu10k1_free(emu); 1020 return err; 1021 } 1588 if ((err = snd_emu10k1_ecard_init(emu)) < 0) 1589 goto error; 1022 1590 } else if (emu->card_capabilities->ca_cardbus_chip) { 1023 if ((err = snd_emu10k1_cardbus_init(emu)) < 0) { 1591 if ((err = snd_emu10k1_cardbus_init(emu)) < 0) 1592 goto error; 1593 } else if (emu->card_capabilities->emu1010) { 1594 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { 1024 1595 snd_emu10k1_free(emu); 1025 1596 return err; … … 1031 1602 } 1032 1603 1033 if ((err = snd_emu10k1_init(emu, enable_ir)) < 0) { 1034 snd_emu10k1_free(emu); 1035 return err; 1036 } 1037 1038 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) { 1039 snd_emu10k1_free(emu); 1040 return err; 1041 } 1042 1604 /* initialize TRAM setup */ 1605 emu->fx8010.itram_size = (16 * 1024)/2; 1606 emu->fx8010.etram_pages.area = NULL; 1607 emu->fx8010.etram_pages.bytes = 0; 1608 1609 /* 1610 * Init to 0x02109204 : 1611 * Clock accuracy = 0 (1000ppm) 1612 * Sample Rate = 2 (48kHz) 1613 * Audio Channel = 1 (Left of 2) 1614 * Source Number = 0 (Unspecified) 1615 * Generation Status = 1 (Original for Cat Code 12) 1616 * Cat Code = 12 (Digital Signal Mixer) 1617 * Mode = 0 (Mode 0) 1618 * Emphasis = 0 (None) 1619 * CP = 1 (Copyright unasserted) 1620 * AN = 0 (Audio data) 1621 * P = 0 (Consumer) 1622 */ 1623 emu->spdif_bits[0] = emu->spdif_bits[1] = 1624 emu->spdif_bits[2] = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 1625 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 1626 SPCS_GENERATIONSTATUS | 0x00001200 | 1627 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; 1628 1629 emu->reserved_page = (struct snd_emu10k1_memblk *) 1630 snd_emu10k1_synth_alloc(emu, 4096); 1631 if (emu->reserved_page) 1632 emu->reserved_page->map_locked = 1; 1633 1634 /* Clear silent pages and set up pointers */ 1635 memset(emu->silent_page.area, 0, PAGE_SIZE); 1636 silent_page = emu->silent_page.addr << 1; 1637 for (idx = 0; idx < MAXPAGES; idx++) 1638 ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); 1639 1640 /* set up voice indices */ 1641 for (idx = 0; idx < NUM_G; idx++) { 1642 emu->voices[idx].emu = emu; 1643 emu->voices[idx].number = idx; 1644 } 1645 1646 if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) 1647 goto error; 1648 #ifdef CONFIG_PM 1649 if ((err = alloc_pm_buffer(emu)) < 0) 1650 goto error; 1651 #endif 1652 1653 /* Initialize the effect engine */ 1654 if ((err = snd_emu10k1_init_efx(emu)) < 0) 1655 goto error; 1656 snd_emu10k1_audio_enable(emu); 1657 1658 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) 1659 goto error; 1660 1661 #ifdef CONFIG_PROC_FS 1043 1662 snd_emu10k1_proc_init(emu); 1044 1663 #endif 1664 1665 snd_card_set_dev(card, &pci->dev); 1045 1666 *remu = emu; 1046 1667 return 0; 1668 1669 error: 1670 snd_emu10k1_free(emu); 1671 return err; 1047 1672 } 1048 1673 1049 /* memory.c */ 1050 EXPORT_SYMBOL(snd_emu10k1_synth_alloc); 1051 EXPORT_SYMBOL(snd_emu10k1_synth_free); 1052 EXPORT_SYMBOL(snd_emu10k1_synth_bzero); 1053 EXPORT_SYMBOL(snd_emu10k1_synth_copy_from_user); 1054 EXPORT_SYMBOL(snd_emu10k1_memblk_map); 1055 /* voice.c */ 1056 EXPORT_SYMBOL(snd_emu10k1_voice_alloc); 1057 EXPORT_SYMBOL(snd_emu10k1_voice_free); 1058 /* io.c */ 1059 EXPORT_SYMBOL(snd_emu10k1_ptr_read); 1060 EXPORT_SYMBOL(snd_emu10k1_ptr_write); 1674 #ifdef CONFIG_PM 1675 static unsigned char saved_regs[] = { 1676 CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, 1677 FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, 1678 ATKHLDM, DCYSUSM, LFOVAL2, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2, 1679 TEMPENV, ADCCR, FXWC, MICBA, ADCBA, FXBA, 1680 MICBS, ADCBS, FXBS, CDCS, GPSCS, SPCS0, SPCS1, SPCS2, 1681 SPBYPASS, AC97SLOT, CDSRCS, GPSRCS, ZVSRCS, MICIDX, ADCIDX, FXIDX, 1682 0xff /* end */ 1683 }; 1684 static unsigned char saved_regs_audigy[] = { 1685 A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE, 1686 A_FXRT2, A_SENDAMOUNTS, A_FXRT1, 1687 0xff /* end */ 1688 }; 1689 1690 static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu) 1691 { 1692 int size; 1693 1694 size = ARRAY_SIZE(saved_regs); 1695 if (emu->audigy) 1696 size += ARRAY_SIZE(saved_regs_audigy); 1697 emu->saved_ptr = vmalloc(4 * NUM_G * size); 1698 if (! emu->saved_ptr) 1699 return -ENOMEM; 1700 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) 1701 return -ENOMEM; 1702 if (emu->card_capabilities->ca0151_chip && 1703 snd_p16v_alloc_pm_buffer(emu) < 0) 1704 return -ENOMEM; 1705 1706 return 0; 1707 } 1708 1709 static void free_pm_buffer(struct snd_emu10k1 *emu) 1710 { 1711 vfree(emu->saved_ptr); 1712 snd_emu10k1_efx_free_pm_buffer(emu); 1713 if (emu->card_capabilities->ca0151_chip) 1714 snd_p16v_free_pm_buffer(emu); 1715 } 1716 1717 void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu) 1718 { 1719 int i; 1720 unsigned char *reg; 1721 unsigned int *val; 1722 1723 val = emu->saved_ptr; 1724 for (reg = saved_regs; *reg != 0xff; reg++) 1725 for (i = 0; i < NUM_G; i++, val++) 1726 *val = snd_emu10k1_ptr_read(emu, *reg, i); 1727 if (emu->audigy) { 1728 for (reg = saved_regs_audigy; *reg != 0xff; reg++) 1729 for (i = 0; i < NUM_G; i++, val++) 1730 *val = snd_emu10k1_ptr_read(emu, *reg, i); 1731 } 1732 if (emu->audigy) 1733 emu->saved_a_iocfg = inl(emu->port + A_IOCFG); 1734 emu->saved_hcfg = inl(emu->port + HCFG); 1735 } 1736 1737 void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) 1738 { 1739 if (emu->card_capabilities->ecard) 1740 snd_emu10k1_ecard_init(emu); 1741 else if (emu->card_capabilities->ca_cardbus_chip) 1742 snd_emu10k1_cardbus_init(emu); 1743 else if (emu->card_capabilities->emu1010) 1744 snd_emu10k1_emu1010_init(emu); 1745 else 1746 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 1747 snd_emu10k1_init(emu, emu->enable_ir, 1); 1748 } 1749 1750 void snd_emu10k1_resume_regs(struct snd_emu10k1 *emu) 1751 { 1752 int i; 1753 unsigned char *reg; 1754 unsigned int *val; 1755 1756 snd_emu10k1_audio_enable(emu); 1757 1758 /* resore for spdif */ 1759 if (emu->audigy) 1760 outl(emu->saved_a_iocfg, emu->port + A_IOCFG); 1761 outl(emu->saved_hcfg, emu->port + HCFG); 1762 1763 val = emu->saved_ptr; 1764 for (reg = saved_regs; *reg != 0xff; reg++) 1765 for (i = 0; i < NUM_G; i++, val++) 1766 snd_emu10k1_ptr_write(emu, *reg, i, *val); 1767 if (emu->audigy) { 1768 for (reg = saved_regs_audigy; *reg != 0xff; reg++) 1769 for (i = 0; i < NUM_G; i++, val++) 1770 snd_emu10k1_ptr_write(emu, *reg, i, *val); 1771 } 1772 } 1773 #endif -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_patch.c
r34 r84 23 23 */ 24 24 25 #define __NO_VERSION__26 25 #include "emu10k1_synth_local.h" 27 26 … … 38 37 int 39 38 snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, 40 snd_util_memhdr_t *hdr, const void *data, long count) 39 struct snd_util_memhdr *hdr, 40 const void __user *data, long count) 41 41 { 42 42 int offset; … … 211 211 int 212 212 snd_emu10k1_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, 213 snd_util_memhdr_t*hdr)213 struct snd_util_memhdr *hdr) 214 214 { 215 215 struct snd_emu10k1 *emu; -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_synth.c
r34 r84 29 29 * create a new hardware dependent device for Emu10k1 30 30 */ 31 int snd_emu10k1_synth_new_device(snd_seq_device_t*dev)31 static int snd_emu10k1_synth_new_device(struct snd_seq_device *dev) 32 32 { 33 33 struct snd_emux *emu; … … 63 63 if (snd_emux_register(emu, dev->card, arg->index, "Emu10k1") < 0) { 64 64 snd_emux_free(emu); 65 emu->hw = NULL;66 65 return -ENOMEM; 67 66 } … … 77 76 } 78 77 79 int snd_emu10k1_synth_delete_device(snd_seq_device_t*dev)78 static int snd_emu10k1_synth_delete_device(struct snd_seq_device *dev) 80 79 { 81 80 struct snd_emux *emu; … … 105 104 static int __init alsa_emu10k1_synth_init(void) 106 105 { 107 108 static snd_seq_dev_ops_t ops = { 106 static struct snd_seq_dev_ops ops = { 109 107 snd_emu10k1_synth_new_device, 110 108 snd_emu10k1_synth_delete_device, 111 109 }; 112 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, sizeof(struct snd_emu10k1_synth_arg)); 110 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, 111 sizeof(struct snd_emu10k1_synth_arg)); 113 112 } 114 113 -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c
r34 r84 67 67 68 68 #define PTR 0x00 /* Indexed register set pointer register */ 69 70 69 /* NOTE: The CHANNELNUM and ADDRESS words can */ 70 /* be modified independently of each other. */ 71 71 72 72 #define DATA 0x04 /* Indexed register set data register */ 73 73 74 74 #define IPR 0x08 /* Global interrupt pending register */ 75 76 75 /* Clear pending interrupts by writing a 1 to */ 76 /* the relevant bits and zero to the other bits */ 77 77 #define IPR_MIDITRANSBUFEMPTY 0x00000001 /* MIDI UART transmit buffer empty */ 78 78 #define IPR_MIDIRECVBUFEMPTY 0x00000002 /* MIDI UART receive buffer empty */ … … 93 93 94 94 #define HCFG_LOCKSOUNDCACHE 0x00000008 /* 1 = Cancel bustmaster accesses to soundcache */ 95 95 /* NOTE: This should generally never be used. */ 96 96 #define HCFG_AUDIOENABLE 0x00000001 /* 0 = CODECs transmit zero-valued samples */ 97 98 97 /* Should be set to 1 when the EMU10K1 is */ 98 /* completely initialized. */ 99 99 #define GPIO 0x18 /* Defaults: 00001080-Analog, 00001000-SPDIF. */ 100 100 … … 108 108 /********************************************************************************************************/ 109 109 #define PLAYBACK_LIST_ADDR 0x00 /* Base DMA address of a list of pointers to each period/size */ 110 /* One list entry: 4 bytes for DMA address, 111 112 113 114 110 /* One list entry: 4 bytes for DMA address, 111 * 4 bytes for period_size << 16. 112 * One list entry is 8 bytes long. 113 * One list entry for each period in the buffer. 114 */ 115 115 #define PLAYBACK_LIST_SIZE 0x01 /* Size of list in bytes << 16. E.g. 8 periods -> 0x00380000 */ 116 116 #define PLAYBACK_LIST_PTR 0x02 /* Pointer to the current period being played */ … … 187 187 * - channel 2 is the center/lfe chanel 188 188 * Volume is controlled by the AC97 for the front and rear channels by 189 * the PCM Playback Volume, Sigmatel Surround Playback Volume and 189 * the PCM Playback Volume, Sigmatel Surround Playback Volume and 190 190 * Surround Playback Volume. The Sigmatel 4-Speaker Stereo switch affects 191 191 * the front/rear channel mixing in the REAR OUT jack. When using the … … 197 197 198 198 struct emu10k1x_voice { 199 200 201 202 203 199 struct emu10k1x *emu; 200 int number; 201 int use; 202 203 struct emu10k1x_pcm *epcm; 204 204 }; 205 205 206 206 struct emu10k1x_pcm { 207 208 209 210 207 struct emu10k1x *emu; 208 struct snd_pcm_substream *substream; 209 struct emu10k1x_voice *voice; 210 unsigned short running; 211 211 }; 212 212 213 213 struct emu10k1x_midi { 214 215 216 217 218 219 220 221 222 223 224 225 214 struct emu10k1x *emu; 215 struct snd_rawmidi *rmidi; 216 struct snd_rawmidi_substream *substream_input; 217 struct snd_rawmidi_substream *substream_output; 218 unsigned int midi_mode; 219 spinlock_t input_lock; 220 spinlock_t output_lock; 221 spinlock_t open_lock; 222 int tx_enable, rx_enable; 223 int port; 224 int ipr_tx, ipr_rx; 225 void (*interrupt)(struct emu10k1x *emu, unsigned int status); 226 226 }; 227 227 228 228 // definition of the chip-specific record 229 229 struct emu10k1x { 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 230 struct snd_card *card; 231 struct pci_dev *pci; 232 233 unsigned long port; 234 struct resource *res_port; 235 int irq; 236 237 unsigned int revision; /* chip revision */ 238 unsigned int serial; /* serial number */ 239 unsigned short model; /* subsystem id */ 240 241 spinlock_t emu_lock; 242 spinlock_t voice_lock; 243 244 struct snd_ac97 *ac97; 245 struct snd_pcm *pcm; 246 247 struct emu10k1x_voice voices[3]; 248 struct emu10k1x_voice capture_voice; 249 u32 spdif_bits[3]; // SPDIF out setup 250 251 struct snd_dma_buffer dma_buffer; 252 253 struct emu10k1x_midi midi; 254 254 }; 255 255 256 256 /* hardware definition */ 257 257 static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { 258 .info = (SNDRV_PCM_INFO_MMAP | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 258 .info = (SNDRV_PCM_INFO_MMAP | 259 SNDRV_PCM_INFO_INTERLEAVED | 260 SNDRV_PCM_INFO_BLOCK_TRANSFER | 261 SNDRV_PCM_INFO_MMAP_VALID), 262 .formats = SNDRV_PCM_FMTBIT_S16_LE, 263 .rates = SNDRV_PCM_RATE_48000, 264 .rate_min = 48000, 265 .rate_max = 48000, 266 .channels_min = 2, 267 .channels_max = 2, 268 .buffer_bytes_max = (32*1024), 269 .period_bytes_min = 64, 270 .period_bytes_max = (16*1024), 271 .periods_min = 2, 272 .periods_max = 8, 273 .fifo_size = 0, 274 274 }; 275 275 276 276 static struct snd_pcm_hardware snd_emu10k1x_capture_hw = { 277 .info = (SNDRV_PCM_INFO_MMAP | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 277 .info = (SNDRV_PCM_INFO_MMAP | 278 SNDRV_PCM_INFO_INTERLEAVED | 279 SNDRV_PCM_INFO_BLOCK_TRANSFER | 280 SNDRV_PCM_INFO_MMAP_VALID), 281 .formats = SNDRV_PCM_FMTBIT_S16_LE, 282 .rates = SNDRV_PCM_RATE_48000, 283 .rate_min = 48000, 284 .rate_max = 48000, 285 .channels_min = 2, 286 .channels_max = 2, 287 .buffer_bytes_max = (32*1024), 288 .period_bytes_min = 64, 289 .period_bytes_max = (16*1024), 290 .periods_min = 2, 291 .periods_max = 2, 292 .fifo_size = 0, 293 293 }; 294 294 295 static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, 296 unsigned int reg, 297 298 { 299 300 301 302 303 304 305 306 307 308 309 } 310 311 static void snd_emu10k1x_ptr_write(struct emu10k1x *emu, 312 unsigned int reg, 313 unsigned int chn, 314 315 { 316 317 318 319 320 321 322 323 324 295 static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, 296 unsigned int reg, 297 unsigned int chn) 298 { 299 unsigned long flags; 300 unsigned int regptr, val; 301 302 regptr = (reg << 16) | chn; 303 304 spin_lock_irqsave(&emu->emu_lock, flags); 305 outl(regptr, emu->port + PTR); 306 val = inl(emu->port + DATA); 307 spin_unlock_irqrestore(&emu->emu_lock, flags); 308 return val; 309 } 310 311 static void snd_emu10k1x_ptr_write(struct emu10k1x *emu, 312 unsigned int reg, 313 unsigned int chn, 314 unsigned int data) 315 { 316 unsigned int regptr; 317 unsigned long flags; 318 319 regptr = (reg << 16) | chn; 320 321 spin_lock_irqsave(&emu->emu_lock, flags); 322 outl(regptr, emu->port + PTR); 323 outl(data, emu->port + DATA); 324 spin_unlock_irqrestore(&emu->emu_lock, flags); 325 325 } 326 326 327 327 static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) 328 328 { 329 330 331 332 333 334 335 329 unsigned long flags; 330 unsigned int enable; 331 332 spin_lock_irqsave(&emu->emu_lock, flags); 333 enable = inl(emu->port + INTE) | intrenb; 334 outl(enable, emu->port + INTE); 335 spin_unlock_irqrestore(&emu->emu_lock, flags); 336 336 } 337 337 338 338 static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) 339 339 { 340 341 342 343 344 345 346 340 unsigned long flags; 341 unsigned int enable; 342 343 spin_lock_irqsave(&emu->emu_lock, flags); 344 enable = inl(emu->port + INTE) & ~intrenb; 345 outl(enable, emu->port + INTE); 346 spin_unlock_irqrestore(&emu->emu_lock, flags); 347 347 } 348 348 349 349 static void snd_emu10k1x_gpio_write(struct emu10k1x *emu, unsigned int value) 350 350 { 351 352 353 354 355 351 unsigned long flags; 352 353 spin_lock_irqsave(&emu->emu_lock, flags); 354 outl(value, emu->port + GPIO); 355 spin_unlock_irqrestore(&emu->emu_lock, flags); 356 356 } 357 357 358 358 static void snd_emu10k1x_pcm_free_substream(struct snd_pcm_runtime *runtime) 359 359 { 360 360 kfree(runtime->private_data); 361 361 } 362 362 363 363 static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voice *voice) 364 364 { 365 366 367 368 369 370 365 struct emu10k1x_pcm *epcm; 366 367 if ((epcm = voice->epcm) == NULL) 368 return; 369 if (epcm->substream == NULL) 370 return; 371 371 #if 0 372 373 374 375 372 snd_printk(KERN_INFO "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 373 epcm->substream->ops->pointer(epcm->substream), 374 snd_pcm_lib_period_bytes(epcm->substream), 375 snd_pcm_lib_buffer_bytes(epcm->substream)); 376 376 #endif 377 377 snd_pcm_period_elapsed(epcm->substream); 378 378 } 379 379 … … 381 381 static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream) 382 382 { 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 383 struct emu10k1x *chip = snd_pcm_substream_chip(substream); 384 struct emu10k1x_pcm *epcm; 385 struct snd_pcm_runtime *runtime = substream->runtime; 386 int err; 387 388 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { 389 return err; 390 } 391 if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) 392 return err; 393 394 epcm = (struct emu10k1x_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 395 if (epcm == NULL) 396 return -ENOMEM; 397 epcm->emu = chip; 398 epcm->substream = substream; 399 400 runtime->private_data = epcm; 401 runtime->private_free = snd_emu10k1x_pcm_free_substream; 402 403 runtime->hw = snd_emu10k1x_playback_hw; 404 405 return 0; 406 406 } 407 407 … … 409 409 static int snd_emu10k1x_playback_close(struct snd_pcm_substream *substream) 410 410 { 411 411 return 0; 412 412 } 413 413 414 414 /* hw_params callback */ 415 415 static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, 416 417 { 418 419 420 421 422 423 424 425 426 427 428 416 struct snd_pcm_hw_params *hw_params) 417 { 418 struct snd_pcm_runtime *runtime = substream->runtime; 419 struct emu10k1x_pcm *epcm = runtime->private_data; 420 421 if (! epcm->voice) { 422 epcm->voice = &epcm->emu->voices[substream->pcm->device]; 423 epcm->voice->use = 1; 424 epcm->voice->epcm = epcm; 425 } 426 427 return snd_pcm_lib_malloc_pages(substream, 428 params_buffer_bytes(hw_params)); 429 429 } 430 430 … … 432 432 static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) 433 433 { 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 434 struct snd_pcm_runtime *runtime = substream->runtime; 435 struct emu10k1x_pcm *epcm; 436 437 if (runtime->private_data == NULL) 438 return 0; 439 440 epcm = runtime->private_data; 441 442 if (epcm->voice) { 443 epcm->voice->use = 0; 444 epcm->voice->epcm = NULL; 445 epcm->voice = NULL; 446 } 447 448 return snd_pcm_lib_free_pages(substream); 449 449 } 450 450 … … 452 452 static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream) 453 453 { 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 454 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 455 struct snd_pcm_runtime *runtime = substream->runtime; 456 struct emu10k1x_pcm *epcm = runtime->private_data; 457 int voice = epcm->voice->number; 458 u32 *table_base = (u32 *)(emu->dma_buffer.area+1024*voice); 459 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); 460 int i; 461 462 for(i=0; i < runtime->periods; i++) { 463 *table_base++=runtime->dma_addr+(i*period_size_bytes); 464 *table_base++=period_size_bytes<<16; 465 } 466 467 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_ADDR, voice, emu->dma_buffer.addr+1024*voice); 468 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_SIZE, voice, (runtime->periods - 1) << 19); 469 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_PTR, voice, 0); 470 snd_emu10k1x_ptr_write(emu, PLAYBACK_POINTER, voice, 0); 471 snd_emu10k1x_ptr_write(emu, PLAYBACK_UNKNOWN1, voice, 0); 472 snd_emu10k1x_ptr_write(emu, PLAYBACK_UNKNOWN2, voice, 0); 473 snd_emu10k1x_ptr_write(emu, PLAYBACK_DMA_ADDR, voice, runtime->dma_addr); 474 475 snd_emu10k1x_ptr_write(emu, PLAYBACK_PERIOD_SIZE, voice, frames_to_bytes(runtime, runtime->period_size)<<16); 476 477 return 0; 478 478 } 479 479 480 480 /* trigger callback */ 481 481 static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream, 482 483 { 484 485 486 487 488 489 490 // snd_printk(KERN_INFO "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", (int)emu, cmd, (int)substream->ops->pointer(substream));491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 482 int cmd) 483 { 484 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 485 struct snd_pcm_runtime *runtime = substream->runtime; 486 struct emu10k1x_pcm *epcm = runtime->private_data; 487 int channel = epcm->voice->number; 488 int result = 0; 489 490 // snd_printk(KERN_INFO "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", (int)emu, cmd, (int)substream->ops->pointer(substream)); 491 492 switch (cmd) { 493 case SNDRV_PCM_TRIGGER_START: 494 if(runtime->periods == 2) 495 snd_emu10k1x_intr_enable(emu, (INTE_CH_0_LOOP | INTE_CH_0_HALF_LOOP) << channel); 496 else 497 snd_emu10k1x_intr_enable(emu, INTE_CH_0_LOOP << channel); 498 epcm->running = 1; 499 snd_emu10k1x_ptr_write(emu, TRIGGER_CHANNEL, 0, snd_emu10k1x_ptr_read(emu, TRIGGER_CHANNEL, 0)|(TRIGGER_CHANNEL_0<<channel)); 500 break; 501 case SNDRV_PCM_TRIGGER_STOP: 502 epcm->running = 0; 503 snd_emu10k1x_intr_disable(emu, (INTE_CH_0_LOOP | INTE_CH_0_HALF_LOOP) << channel); 504 snd_emu10k1x_ptr_write(emu, TRIGGER_CHANNEL, 0, snd_emu10k1x_ptr_read(emu, TRIGGER_CHANNEL, 0) & ~(TRIGGER_CHANNEL_0<<channel)); 505 break; 506 default: 507 result = -EINVAL; 508 break; 509 } 510 return result; 511 511 } 512 512 … … 515 515 snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream) 516 516 { 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 if (ptr3 != ptr4) 534 535 536 537 538 539 540 541 542 517 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 518 struct snd_pcm_runtime *runtime = substream->runtime; 519 struct emu10k1x_pcm *epcm = runtime->private_data; 520 int channel = epcm->voice->number; 521 snd_pcm_uframes_t ptr = 0, ptr1 = 0, ptr2= 0,ptr3 = 0,ptr4 = 0; 522 523 if (!epcm->running) 524 return 0; 525 526 ptr3 = snd_emu10k1x_ptr_read(emu, PLAYBACK_LIST_PTR, channel); 527 ptr1 = snd_emu10k1x_ptr_read(emu, PLAYBACK_POINTER, channel); 528 ptr4 = snd_emu10k1x_ptr_read(emu, PLAYBACK_LIST_PTR, channel); 529 530 if(ptr4 == 0 && ptr1 == frames_to_bytes(runtime, runtime->buffer_size)) 531 return 0; 532 533 if (ptr3 != ptr4) 534 ptr1 = snd_emu10k1x_ptr_read(emu, PLAYBACK_POINTER, channel); 535 ptr2 = bytes_to_frames(runtime, ptr1); 536 ptr2 += (ptr4 >> 3) * runtime->period_size; 537 ptr = ptr2; 538 539 if (ptr >= runtime->buffer_size) 540 ptr -= runtime->buffer_size; 541 542 return ptr; 543 543 } 544 544 545 545 /* operators */ 546 546 static struct snd_pcm_ops snd_emu10k1x_playback_ops = { 547 548 549 550 551 552 553 554 547 .open = snd_emu10k1x_playback_open, 548 .close = snd_emu10k1x_playback_close, 549 .ioctl = snd_pcm_lib_ioctl, 550 .hw_params = snd_emu10k1x_pcm_hw_params, 551 .hw_free = snd_emu10k1x_pcm_hw_free, 552 .prepare = snd_emu10k1x_pcm_prepare, 553 .trigger = snd_emu10k1x_pcm_trigger, 554 .pointer = snd_emu10k1x_pcm_pointer, 555 555 }; 556 556 … … 558 558 static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream) 559 559 { 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 560 struct emu10k1x *chip = snd_pcm_substream_chip(substream); 561 struct emu10k1x_pcm *epcm; 562 struct snd_pcm_runtime *runtime = substream->runtime; 563 int err; 564 565 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 566 return err; 567 if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) 568 return err; 569 570 epcm = (struct emu10k1x_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 571 if (epcm == NULL) 572 return -ENOMEM; 573 574 epcm->emu = chip; 575 epcm->substream = substream; 576 577 runtime->private_data = epcm; 578 runtime->private_free = snd_emu10k1x_pcm_free_substream; 579 580 runtime->hw = snd_emu10k1x_capture_hw; 581 582 return 0; 583 583 } 584 584 … … 586 586 static int snd_emu10k1x_pcm_close_capture(struct snd_pcm_substream *substream) 587 587 { 588 588 return 0; 589 589 } 590 590 591 591 /* hw_params callback */ 592 592 static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substream, 593 594 { 595 596 597 598 599 600 601 602 603 604 605 606 607 593 struct snd_pcm_hw_params *hw_params) 594 { 595 struct snd_pcm_runtime *runtime = substream->runtime; 596 struct emu10k1x_pcm *epcm = runtime->private_data; 597 598 if (! epcm->voice) { 599 if (epcm->emu->capture_voice.use) 600 return -EBUSY; 601 epcm->voice = &epcm->emu->capture_voice; 602 epcm->voice->epcm = epcm; 603 epcm->voice->use = 1; 604 } 605 606 return snd_pcm_lib_malloc_pages(substream, 607 params_buffer_bytes(hw_params)); 608 608 } 609 609 … … 611 611 static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) 612 612 { 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 613 struct snd_pcm_runtime *runtime = substream->runtime; 614 615 struct emu10k1x_pcm *epcm; 616 617 if (runtime->private_data == NULL) 618 return 0; 619 epcm = runtime->private_data; 620 621 if (epcm->voice) { 622 epcm->voice->use = 0; 623 epcm->voice->epcm = NULL; 624 epcm->voice = NULL; 625 } 626 627 return snd_pcm_lib_free_pages(substream); 628 628 } 629 629 … … 631 631 static int snd_emu10k1x_pcm_prepare_capture(struct snd_pcm_substream *substream) 632 632 { 633 634 635 636 637 638 639 640 641 633 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 634 struct snd_pcm_runtime *runtime = substream->runtime; 635 636 snd_emu10k1x_ptr_write(emu, CAPTURE_DMA_ADDR, 0, runtime->dma_addr); 637 snd_emu10k1x_ptr_write(emu, CAPTURE_BUFFER_SIZE, 0, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes 638 snd_emu10k1x_ptr_write(emu, CAPTURE_POINTER, 0, 0); 639 snd_emu10k1x_ptr_write(emu, CAPTURE_UNKNOWN, 0, 0); 640 641 return 0; 642 642 } 643 643 644 644 /* trigger_capture callback */ 645 645 static int snd_emu10k1x_pcm_trigger_capture(struct snd_pcm_substream *substream, 646 647 { 648 649 650 651 652 653 654 655 snd_emu10k1x_intr_enable(emu, INTE_CAP_0_LOOP | 656 657 658 659 660 661 662 snd_emu10k1x_intr_disable(emu, INTE_CAP_0_LOOP | 663 664 665 666 667 668 669 670 646 int cmd) 647 { 648 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 649 struct snd_pcm_runtime *runtime = substream->runtime; 650 struct emu10k1x_pcm *epcm = runtime->private_data; 651 int result = 0; 652 653 switch (cmd) { 654 case SNDRV_PCM_TRIGGER_START: 655 snd_emu10k1x_intr_enable(emu, INTE_CAP_0_LOOP | 656 INTE_CAP_0_HALF_LOOP); 657 snd_emu10k1x_ptr_write(emu, TRIGGER_CHANNEL, 0, snd_emu10k1x_ptr_read(emu, TRIGGER_CHANNEL, 0)|TRIGGER_CAPTURE); 658 epcm->running = 1; 659 break; 660 case SNDRV_PCM_TRIGGER_STOP: 661 epcm->running = 0; 662 snd_emu10k1x_intr_disable(emu, INTE_CAP_0_LOOP | 663 INTE_CAP_0_HALF_LOOP); 664 snd_emu10k1x_ptr_write(emu, TRIGGER_CHANNEL, 0, snd_emu10k1x_ptr_read(emu, TRIGGER_CHANNEL, 0) & ~(TRIGGER_CAPTURE)); 665 break; 666 default: 667 result = -EINVAL; 668 break; 669 } 670 return result; 671 671 } 672 672 … … 675 675 snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream) 676 676 { 677 678 679 680 681 682 683 684 685 686 687 688 689 677 struct emu10k1x *emu = snd_pcm_substream_chip(substream); 678 struct snd_pcm_runtime *runtime = substream->runtime; 679 struct emu10k1x_pcm *epcm = runtime->private_data; 680 snd_pcm_uframes_t ptr; 681 682 if (!epcm->running) 683 return 0; 684 685 ptr = bytes_to_frames(runtime, snd_emu10k1x_ptr_read(emu, CAPTURE_POINTER, 0)); 686 if (ptr >= runtime->buffer_size) 687 ptr -= runtime->buffer_size; 688 689 return ptr; 690 690 } 691 691 692 692 static struct snd_pcm_ops snd_emu10k1x_capture_ops = { 693 694 695 696 697 698 699 700 693 .open = snd_emu10k1x_pcm_open_capture, 694 .close = snd_emu10k1x_pcm_close_capture, 695 .ioctl = snd_pcm_lib_ioctl, 696 .hw_params = snd_emu10k1x_pcm_hw_params_capture, 697 .hw_free = snd_emu10k1x_pcm_hw_free_capture, 698 .prepare = snd_emu10k1x_pcm_prepare_capture, 699 .trigger = snd_emu10k1x_pcm_trigger_capture, 700 .pointer = snd_emu10k1x_pcm_pointer_capture, 701 701 }; 702 702 703 703 static unsigned short snd_emu10k1x_ac97_read(struct snd_ac97 *ac97, 704 705 { 706 707 708 709 710 711 712 713 714 704 unsigned short reg) 705 { 706 struct emu10k1x *emu = ac97->private_data; 707 unsigned long flags; 708 unsigned short val; 709 710 spin_lock_irqsave(&emu->emu_lock, flags); 711 outb(reg, emu->port + AC97ADDRESS); 712 val = inw(emu->port + AC97DATA); 713 spin_unlock_irqrestore(&emu->emu_lock, flags); 714 return val; 715 715 } 716 716 717 717 static void snd_emu10k1x_ac97_write(struct snd_ac97 *ac97, 718 719 { 720 721 722 723 724 725 726 718 unsigned short reg, unsigned short val) 719 { 720 struct emu10k1x *emu = ac97->private_data; 721 unsigned long flags; 722 723 spin_lock_irqsave(&emu->emu_lock, flags); 724 outb(reg, emu->port + AC97ADDRESS); 725 outw(val, emu->port + AC97DATA); 726 spin_unlock_irqrestore(&emu->emu_lock, flags); 727 727 } 728 728 729 729 static int snd_emu10k1x_ac97(struct emu10k1x *chip) 730 730 { 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 731 struct snd_ac97_bus *pbus; 732 struct snd_ac97_template ac97; 733 int err; 734 static struct snd_ac97_bus_ops ops = { 735 .write = snd_emu10k1x_ac97_write, 736 .read = snd_emu10k1x_ac97_read, 737 }; 738 739 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) 740 return err; 741 pbus->no_vra = 1; /* we don't need VRA */ 742 743 memset(&ac97, 0, sizeof(ac97)); 744 ac97.private_data = chip; 745 ac97.scaps = AC97_SCAP_NO_SPDIF; 746 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); 747 747 } 748 748 749 749 static int snd_emu10k1x_free(struct emu10k1x *chip) 750 750 { 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 751 snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0); 752 // disable interrupts 753 outl(0, chip->port + INTE); 754 // disable audio 755 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); 756 757 // release the i/o port 758 release_and_free_resource(chip->res_port); 759 760 // release the irq 761 if (chip->irq >= 0) 762 free_irq(chip->irq, (void *)chip); 763 764 // release the DMA 765 if (chip->dma_buffer.area) { 766 snd_dma_free_pages(&chip->dma_buffer); 767 } 768 769 pci_disable_device(chip->pci); 770 771 // release the data 772 kfree(chip); 773 return 0; 774 774 } 775 775 776 776 static int snd_emu10k1x_dev_free(struct snd_device *device) 777 777 { 778 struct emu10k1x *chip = device->device_data; 779 return snd_emu10k1x_free(chip); 780 } 781 782 static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, 783 struct pt_regs *regs) 784 { 785 unsigned int status; 786 787 struct emu10k1x *chip = dev_id; 788 struct emu10k1x_voice *pvoice = chip->voices; 789 int i; 790 int mask; 791 792 status = inl(chip->port + IPR); 793 794 if (! status) 795 return IRQ_NONE; 796 797 // capture interrupt 798 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { 799 struct emu10k1x_voice *pvoice = &chip->capture_voice; 800 if (pvoice->use) 801 snd_emu10k1x_pcm_interrupt(chip, pvoice); 802 else 803 snd_emu10k1x_intr_disable(chip, 804 INTE_CAP_0_LOOP | 805 INTE_CAP_0_HALF_LOOP); 806 } 807 808 mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; 809 for (i = 0; i < 3; i++) { 810 if (status & mask) { 811 if (pvoice->use) 812 snd_emu10k1x_pcm_interrupt(chip, pvoice); 813 else 814 snd_emu10k1x_intr_disable(chip, mask); 815 } 816 pvoice++; 817 mask <<= 1; 818 } 819 820 if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { 821 if (chip->midi.interrupt) 822 chip->midi.interrupt(chip, status); 823 else 824 snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); 825 } 826 827 // acknowledge the interrupt if necessary 828 outl(status, chip->port + IPR); 829 830 // snd_printk(KERN_INFO "interrupt %08x\n", status); 831 return IRQ_HANDLED; 778 struct emu10k1x *chip = device->device_data; 779 return snd_emu10k1x_free(chip); 780 } 781 782 static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id) 783 { 784 unsigned int status; 785 786 struct emu10k1x *chip = dev_id; 787 struct emu10k1x_voice *pvoice = chip->voices; 788 int i; 789 int mask; 790 791 status = inl(chip->port + IPR); 792 793 if (! status) 794 return IRQ_NONE; 795 796 // capture interrupt 797 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { 798 struct emu10k1x_voice *pvoice = &chip->capture_voice; 799 if (pvoice->use) 800 snd_emu10k1x_pcm_interrupt(chip, pvoice); 801 else 802 snd_emu10k1x_intr_disable(chip, 803 INTE_CAP_0_LOOP | 804 INTE_CAP_0_HALF_LOOP); 805 } 806 807 mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; 808 for (i = 0; i < 3; i++) { 809 if (status & mask) { 810 if (pvoice->use) 811 snd_emu10k1x_pcm_interrupt(chip, pvoice); 812 else 813 snd_emu10k1x_intr_disable(chip, mask); 814 } 815 pvoice++; 816 mask <<= 1; 817 } 818 819 if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { 820 if (chip->midi.interrupt) 821 chip->midi.interrupt(chip, status); 822 else 823 snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); 824 } 825 826 // acknowledge the interrupt if necessary 827 outl(status, chip->port + IPR); 828 829 // snd_printk(KERN_INFO "interrupt %08x\n", status); 830 return IRQ_HANDLED; 832 831 } 833 832 834 833 static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) 835 834 { 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 snd_dma_pci_data(emu->pci), 878 879 880 881 882 883 835 struct snd_pcm *pcm; 836 int err; 837 int capture = 0; 838 839 if (rpcm) 840 *rpcm = NULL; 841 if (device == 0) 842 capture = 1; 843 844 if ((err = snd_pcm_new(emu->card, "emu10k1x", device, 1, capture, &pcm)) < 0) 845 return err; 846 847 pcm->private_data = emu; 848 849 switch(device) { 850 case 0: 851 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1x_playback_ops); 852 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1x_capture_ops); 853 break; 854 case 1: 855 case 2: 856 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1x_playback_ops); 857 break; 858 } 859 860 pcm->info_flags = 0; 861 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 862 switch(device) { 863 case 0: 864 strcpy(pcm->name, "EMU10K1X Front"); 865 break; 866 case 1: 867 strcpy(pcm->name, "EMU10K1X Rear"); 868 break; 869 case 2: 870 strcpy(pcm->name, "EMU10K1X Center/LFE"); 871 break; 872 } 873 emu->pcm = pcm; 874 875 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 876 snd_dma_pci_data(emu->pci), 877 32*1024, 32*1024); 878 879 if (rpcm) 880 *rpcm = pcm; 881 882 return 0; 884 883 } 885 884 886 885 static int __devinit snd_emu10k1x_create(struct snd_card *card, 887 888 889 { 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 "EMU10K1X")) == NULL) { 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 outl(0, chip->port + INTE); 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 chip->spdif_bits[0] = 970 971 972 973 974 975 chip->spdif_bits[1] = 976 977 978 979 980 981 chip->spdif_bits[2] = 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 } 1001 1002 static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, 1003 1004 { 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 } 1029 1030 static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, 1031 1032 { 1033 1034 1035 886 struct pci_dev *pci, 887 struct emu10k1x **rchip) 888 { 889 struct emu10k1x *chip; 890 int err; 891 int ch; 892 static struct snd_device_ops ops = { 893 .dev_free = snd_emu10k1x_dev_free, 894 }; 895 896 *rchip = NULL; 897 898 if ((err = pci_enable_device(pci)) < 0) 899 return err; 900 pci_set_dma_mask(pci, 0x0fffffff); 901 902 chip = (struct emu10k1x *)kzalloc(sizeof(*chip), GFP_KERNEL); 903 if (chip == NULL) { 904 pci_disable_device(pci); 905 return -ENOMEM; 906 } 907 908 chip->card = card; 909 chip->pci = pci; 910 chip->irq = -1; 911 912 spin_lock_init(&chip->emu_lock); 913 spin_lock_init(&chip->voice_lock); 914 915 chip->port = pci_resource_start(pci, 0); 916 if ((chip->res_port = request_region(chip->port, 8, 917 "EMU10K1X")) == NULL) { 918 snd_printk(KERN_ERR "emu10k1x: cannot allocate the port 0x%lx\n", chip->port); 919 snd_emu10k1x_free(chip); 920 return -EBUSY; 921 } 922 923 if (request_irq(pci->irq, snd_emu10k1x_interrupt, 924 SA_INTERRUPT|SA_SHIRQ, "EMU10K1X", 925 (void *)chip)) { 926 snd_printk(KERN_ERR "emu10k1x: cannot grab irq %d\n", pci->irq); 927 snd_emu10k1x_free(chip); 928 return -EBUSY; 929 } 930 chip->irq = pci->irq; 931 932 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 933 4 * 1024, &chip->dma_buffer) < 0) { 934 snd_emu10k1x_free(chip); 935 return -ENOMEM; 936 } 937 938 pci_set_master(pci); 939 /* read revision & serial */ 940 pci_read_config_byte(pci, PCI_REVISION_ID, (char *)&chip->revision); 941 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 942 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 943 snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, 944 chip->revision, chip->serial); 945 946 outl(0, chip->port + INTE); 947 948 for(ch = 0; ch < 3; ch++) { 949 chip->voices[ch].emu = chip; 950 chip->voices[ch].number = ch; 951 } 952 953 /* 954 * Init to 0x02109204 : 955 * Clock accuracy = 0 (1000ppm) 956 * Sample Rate = 2 (48kHz) 957 * Audio Channel = 1 (Left of 2) 958 * Source Number = 0 (Unspecified) 959 * Generation Status = 1 (Original for Cat Code 12) 960 * Cat Code = 12 (Digital Signal Mixer) 961 * Mode = 0 (Mode 0) 962 * Emphasis = 0 (None) 963 * CP = 1 (Copyright unasserted) 964 * AN = 0 (Audio data) 965 * P = 0 (Consumer) 966 */ 967 snd_emu10k1x_ptr_write(chip, SPCS0, 0, 968 chip->spdif_bits[0] = 969 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 970 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 971 SPCS_GENERATIONSTATUS | 0x00001200 | 972 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 973 snd_emu10k1x_ptr_write(chip, SPCS1, 0, 974 chip->spdif_bits[1] = 975 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 976 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 977 SPCS_GENERATIONSTATUS | 0x00001200 | 978 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 979 snd_emu10k1x_ptr_write(chip, SPCS2, 0, 980 chip->spdif_bits[2] = 981 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 982 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 983 SPCS_GENERATIONSTATUS | 0x00001200 | 984 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 985 986 snd_emu10k1x_ptr_write(chip, SPDIF_SELECT, 0, 0x700); // disable SPDIF 987 snd_emu10k1x_ptr_write(chip, ROUTING, 0, 0x1003F); // routing 988 snd_emu10k1x_gpio_write(chip, 0x1080); // analog mode 989 990 outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); 991 992 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, 993 chip, &ops)) < 0) { 994 snd_emu10k1x_free(chip); 995 return err; 996 } 997 *rchip = chip; 998 return 0; 999 } 1000 1001 static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, 1002 struct snd_info_buffer *buffer) 1003 { 1004 struct emu10k1x *emu = entry->private_data; 1005 unsigned long value,value1,value2; 1006 unsigned long flags; 1007 int i; 1008 1009 snd_iprintf(buffer, "Registers:\n\n"); 1010 for(i = 0; i < 0x20; i+=4) { 1011 spin_lock_irqsave(&emu->emu_lock, flags); 1012 value = inl(emu->port + i); 1013 spin_unlock_irqrestore(&emu->emu_lock, flags); 1014 snd_iprintf(buffer, "Register %02X: %08lX\n", i, value); 1015 } 1016 snd_iprintf(buffer, "\nRegisters\n\n"); 1017 for(i = 0; i <= 0x48; i++) { 1018 value = snd_emu10k1x_ptr_read(emu, i, 0); 1019 if(i < 0x10 || (i >= 0x20 && i < 0x40)) { 1020 value1 = snd_emu10k1x_ptr_read(emu, i, 1); 1021 value2 = snd_emu10k1x_ptr_read(emu, i, 2); 1022 snd_iprintf(buffer, "%02X: %08lX %08lX %08lX\n", i, value, value1, value2); 1023 } else { 1024 snd_iprintf(buffer, "%02X: %08lX\n", i, value); 1025 } 1026 } 1027 } 1028 1029 static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, 1030 struct snd_info_buffer *buffer) 1031 { 1032 struct emu10k1x *emu = entry->private_data; 1033 char line[64]; 1034 unsigned int reg, channel_id , val; 1036 1035 #if 0 1037 1038 1039 1040 1041 if ((reg < 0x49) && (reg >=0) && (val <= 0xffffffff) 1042 1043 1044 1036 while (!snd_info_get_line(buffer, line, sizeof(line))) { 1037 if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) 1038 continue; 1039 1040 if ((reg < 0x49) && (reg >=0) && (val <= 0xffffffff) 1041 && (channel_id >=0) && (channel_id <= 2) ) 1042 snd_emu10k1x_ptr_write(emu, reg, channel_id, val); 1043 } 1045 1044 #endif 1046 1045 } … … 1048 1047 static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) 1049 1048 { 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1049 struct snd_info_entry *entry; 1050 1051 if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { 1052 snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); 1053 entry->c.text.write_size = 64; 1054 entry->c.text.write = snd_emu10k1x_proc_reg_write; 1055 entry->mode |= S_IWUSR; 1056 entry->private_data = emu; 1057 } 1058 1059 return 0; 1061 1060 } 1062 1061 1063 1062 static int snd_emu10k1x_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1064 1063 { 1065 1066 1067 1068 1069 1064 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1065 uinfo->count = 1; 1066 uinfo->value.integer.min = 0; 1067 uinfo->value.integer.max = 1; 1068 return 0; 1070 1069 } 1071 1070 1072 1071 static int snd_emu10k1x_shared_spdif_get(struct snd_kcontrol *kcontrol, 1073 1074 { 1075 1076 1077 1078 1079 1072 struct snd_ctl_elem_value *ucontrol) 1073 { 1074 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1075 1076 ucontrol->value.integer.value[0] = (snd_emu10k1x_ptr_read(emu, SPDIF_SELECT, 0) == 0x700) ? 0 : 1; 1077 1078 return 0; 1080 1079 } 1081 1080 1082 1081 static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, 1083 1084 { 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1082 struct snd_ctl_elem_value *ucontrol) 1083 { 1084 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1085 unsigned int val; 1086 int change = 0; 1087 1088 val = ucontrol->value.integer.value[0] ; 1089 1090 if (val) { 1091 // enable spdif output 1092 snd_emu10k1x_ptr_write(emu, SPDIF_SELECT, 0, 0x000); 1093 snd_emu10k1x_ptr_write(emu, ROUTING, 0, 0x700); 1094 snd_emu10k1x_gpio_write(emu, 0x1000); 1095 } else { 1096 // disable spdif output 1097 snd_emu10k1x_ptr_write(emu, SPDIF_SELECT, 0, 0x700); 1098 snd_emu10k1x_ptr_write(emu, ROUTING, 0, 0x1003F); 1099 snd_emu10k1x_gpio_write(emu, 0x1080); 1100 } 1101 return change; 1103 1102 } 1104 1103 1105 1104 static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata = 1106 1105 { 1107 1108 1109 1110 1111 1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1107 .name = "Analog/Digital Output Jack", 1108 .info = snd_emu10k1x_shared_spdif_info, 1109 .get = snd_emu10k1x_shared_spdif_get, 1110 .put = snd_emu10k1x_shared_spdif_put 1112 1111 }; 1113 1112 1114 1113 static int snd_emu10k1x_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1115 1114 { 1116 1117 1118 1115 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 1116 uinfo->count = 1; 1117 return 0; 1119 1118 } 1120 1119 1121 1120 static int snd_emu10k1x_spdif_get(struct snd_kcontrol *kcontrol, 1122 1123 { 1124 1125 1126 1127 1128 1129 1130 1131 1121 struct snd_ctl_elem_value *ucontrol) 1122 { 1123 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1124 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1125 1126 ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff; 1127 ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff; 1128 ucontrol->value.iec958.status[2] = (emu->spdif_bits[idx] >> 16) & 0xff; 1129 ucontrol->value.iec958.status[3] = (emu->spdif_bits[idx] >> 24) & 0xff; 1130 return 0; 1132 1131 } 1133 1132 1134 1133 static int snd_emu10k1x_spdif_get_mask(struct snd_kcontrol *kcontrol, 1135 1136 { 1137 1138 1139 1140 1141 1134 struct snd_ctl_elem_value *ucontrol) 1135 { 1136 ucontrol->value.iec958.status[0] = 0xff; 1137 ucontrol->value.iec958.status[1] = 0xff; 1138 ucontrol->value.iec958.status[2] = 0xff; 1139 ucontrol->value.iec958.status[3] = 0xff; 1140 return 0; 1142 1141 } 1143 1142 1144 1143 static int snd_emu10k1x_spdif_put(struct snd_kcontrol *kcontrol, 1145 1146 { 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1144 struct snd_ctl_elem_value *ucontrol) 1145 { 1146 struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); 1147 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1148 int change; 1149 unsigned int val; 1150 1151 val = (ucontrol->value.iec958.status[0] << 0) | 1152 (ucontrol->value.iec958.status[1] << 8) | 1153 (ucontrol->value.iec958.status[2] << 16) | 1154 (ucontrol->value.iec958.status[3] << 24); 1155 change = val != emu->spdif_bits[idx]; 1156 if (change) { 1157 snd_emu10k1x_ptr_write(emu, SPCS0 + idx, 0, val); 1158 emu->spdif_bits[idx] = val; 1159 } 1160 return change; 1162 1161 } 1163 1162 1164 1163 static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control = 1165 1164 { 1166 1167 1168 1169 1170 1171 1165 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1166 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1167 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), 1168 .count = 3, 1169 .info = snd_emu10k1x_spdif_info, 1170 .get = snd_emu10k1x_spdif_get_mask 1172 1171 }; 1173 1172 1174 1173 static struct snd_kcontrol_new snd_emu10k1x_spdif_control = 1175 1174 { 1176 1177 1178 1179 1180 1181 1175 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1176 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1177 .count = 3, 1178 .info = snd_emu10k1x_spdif_info, 1179 .get = snd_emu10k1x_spdif_get, 1180 .put = snd_emu10k1x_spdif_put 1182 1181 }; 1183 1182 1184 1183 static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu) 1185 1184 { 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1185 int err; 1186 struct snd_kcontrol *kctl; 1187 struct snd_card *card = emu->card; 1188 1189 if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL) 1190 return -ENOMEM; 1191 if ((err = snd_ctl_add(card, kctl))) 1192 return err; 1193 if ((kctl = snd_ctl_new1(&snd_emu10k1x_shared_spdif, emu)) == NULL) 1194 return -ENOMEM; 1195 if ((err = snd_ctl_add(card, kctl))) 1196 return err; 1197 if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_control, emu)) == NULL) 1198 return -ENOMEM; 1199 if ((err = snd_ctl_add(card, kctl))) 1200 return err; 1201 1202 return 0; 1204 1203 } 1205 1204 … … 1209 1208 static inline unsigned char mpu401_read(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int idx) 1210 1209 { 1211 1210 return (unsigned char)snd_emu10k1x_ptr_read(emu, mpu->port + idx, 0); 1212 1211 } 1213 1212 1214 1213 static inline void mpu401_write(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int data, int idx) 1215 1214 { 1216 1215 snd_emu10k1x_ptr_write(emu, mpu->port + idx, 0, data); 1217 1216 } 1218 1217 … … 1231 1230 static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu) 1232 1231 { 1233 1234 1235 1232 int timeout = 100000; 1233 for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) 1234 mpu401_read_data(emu, mpu); 1236 1235 #ifdef CONFIG_SND_DEBUG 1237 1238 1236 if (timeout <= 0) 1237 snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); 1239 1238 #endif 1240 1239 } … … 1242 1241 /* 1243 1242 1244 1243 */ 1245 1244 1246 1245 static void do_emu10k1x_midi_interrupt(struct emu10k1x *emu, 1247 1248 { 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1246 struct emu10k1x_midi *midi, unsigned int status) 1247 { 1248 unsigned char byte; 1249 1250 if (midi->rmidi == NULL) { 1251 snd_emu10k1x_intr_disable(emu, midi->tx_enable | midi->rx_enable); 1252 return; 1253 } 1254 1255 spin_lock(&midi->input_lock); 1256 if ((status & midi->ipr_rx) && mpu401_input_avail(emu, midi)) { 1257 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1258 mpu401_clear_rx(emu, midi); 1259 } else { 1260 byte = mpu401_read_data(emu, midi); 1261 if (midi->substream_input) 1262 snd_rawmidi_receive(midi->substream_input, &byte, 1); 1263 } 1264 } 1265 spin_unlock(&midi->input_lock); 1266 1267 spin_lock(&midi->output_lock); 1268 if ((status & midi->ipr_tx) && mpu401_output_ready(emu, midi)) { 1269 if (midi->substream_output && 1270 snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) { 1271 mpu401_write_data(emu, midi, byte); 1272 } else { 1273 snd_emu10k1x_intr_disable(emu, midi->tx_enable); 1274 } 1275 } 1276 spin_unlock(&midi->output_lock); 1278 1277 } 1279 1278 1280 1279 static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int status) 1281 1280 { 1282 do_emu10k1x_midi_interrupt(emu, &emu->midi, status); 1283 } 1284 1285 static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, 1286 struct emu10k1x_midi *midi, unsigned char cmd, int ack) 1287 { 1288 unsigned long flags; 1289 int timeout, ok; 1290 1291 spin_lock_irqsave(&midi->input_lock, flags); 1292 mpu401_write_data(emu, midi, 0x00); 1293 /* mpu401_clear_rx(emu, midi); */ 1294 1295 mpu401_write_cmd(emu, midi, cmd); 1296 if (ack) { 1297 ok = 0; 1298 timeout = 10000; 1299 while (!ok && timeout-- > 0) { 1300 if (mpu401_input_avail(emu, midi)) { 1301 if (mpu401_read_data(emu, midi) == MPU401_ACK) 1302 ok = 1; 1303 } 1304 } 1305 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) 1306 ok = 1; 1307 } else { 1308 ok = 1; 1309 } 1310 spin_unlock_irqrestore(&midi->input_lock, flags); 1311 if (!ok) 1312 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 1313 cmd, emu->port, 1314 mpu401_read_stat(emu, midi), 1315 mpu401_read_data(emu, midi)); 1281 do_emu10k1x_midi_interrupt(emu, &emu->midi, status); 1282 } 1283 1284 static int snd_emu10k1x_midi_cmd(struct emu10k1x * emu, 1285 struct emu10k1x_midi *midi, unsigned char cmd, int ack) 1286 { 1287 unsigned long flags; 1288 int timeout, ok; 1289 1290 spin_lock_irqsave(&midi->input_lock, flags); 1291 mpu401_write_data(emu, midi, 0x00); 1292 /* mpu401_clear_rx(emu, midi); */ 1293 1294 mpu401_write_cmd(emu, midi, cmd); 1295 if (ack) { 1296 ok = 0; 1297 timeout = 10000; 1298 while (!ok && timeout-- > 0) { 1299 if (mpu401_input_avail(emu, midi)) { 1300 if (mpu401_read_data(emu, midi) == MPU401_ACK) 1301 ok = 1; 1302 } 1303 } 1304 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) 1305 ok = 1; 1306 } else { 1307 ok = 1; 1308 } 1309 spin_unlock_irqrestore(&midi->input_lock, flags); 1310 if (!ok) { 1311 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 1312 cmd, emu->port, 1313 mpu401_read_stat(emu, midi), 1314 mpu401_read_data(emu, midi)); 1315 return 1; 1316 } 1317 return 0; 1316 1318 } 1317 1319 1318 1320 static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) 1319 1321 { 1320 struct emu10k1x *emu; 1321 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1322 unsigned long flags; 1323 1324 emu = midi->emu; 1325 snd_assert(emu, return -ENXIO); 1326 spin_lock_irqsave(&midi->open_lock, flags); 1327 midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT; 1328 midi->substream_input = substream; 1329 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { 1330 spin_unlock_irqrestore(&midi->open_lock, flags); 1331 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1); 1332 snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 1333 } else { 1334 spin_unlock_irqrestore(&midi->open_lock, flags); 1335 } 1336 return 0; 1322 struct emu10k1x *emu; 1323 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1324 unsigned long flags; 1325 1326 emu = midi->emu; 1327 snd_assert(emu, return -ENXIO); 1328 spin_lock_irqsave(&midi->open_lock, flags); 1329 midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT; 1330 midi->substream_input = substream; 1331 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { 1332 spin_unlock_irqrestore(&midi->open_lock, flags); 1333 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1)) 1334 goto error_out; 1335 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) 1336 goto error_out; 1337 } else { 1338 spin_unlock_irqrestore(&midi->open_lock, flags); 1339 } 1340 return 0; 1341 1342 error_out: 1343 return -EIO; 1337 1344 } 1338 1345 1339 1346 static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) 1340 1347 { 1341 struct emu10k1x *emu; 1342 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1343 unsigned long flags; 1344 1345 emu = midi->emu; 1346 snd_assert(emu, return -ENXIO); 1347 spin_lock_irqsave(&midi->open_lock, flags); 1348 midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT; 1349 midi->substream_output = substream; 1350 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1351 spin_unlock_irqrestore(&midi->open_lock, flags); 1352 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1); 1353 snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 1354 } else { 1355 spin_unlock_irqrestore(&midi->open_lock, flags); 1356 } 1357 return 0; 1348 struct emu10k1x *emu; 1349 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1350 unsigned long flags; 1351 1352 emu = midi->emu; 1353 snd_assert(emu, return -ENXIO); 1354 spin_lock_irqsave(&midi->open_lock, flags); 1355 midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT; 1356 midi->substream_output = substream; 1357 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1358 spin_unlock_irqrestore(&midi->open_lock, flags); 1359 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1)) 1360 goto error_out; 1361 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) 1362 goto error_out; 1363 } else { 1364 spin_unlock_irqrestore(&midi->open_lock, flags); 1365 } 1366 return 0; 1367 1368 error_out: 1369 return -EIO; 1358 1370 } 1359 1371 1360 1372 static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) 1361 1373 { 1362 struct emu10k1x *emu; 1363 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1364 unsigned long flags; 1365 1366 emu = midi->emu; 1367 snd_assert(emu, return -ENXIO); 1368 spin_lock_irqsave(&midi->open_lock, flags); 1369 snd_emu10k1x_intr_disable(emu, midi->rx_enable); 1370 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT; 1371 midi->substream_input = NULL; 1372 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { 1373 spin_unlock_irqrestore(&midi->open_lock, flags); 1374 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); 1375 } else { 1376 spin_unlock_irqrestore(&midi->open_lock, flags); 1377 } 1378 return 0; 1374 struct emu10k1x *emu; 1375 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1376 unsigned long flags; 1377 int err = 0; 1378 1379 emu = midi->emu; 1380 snd_assert(emu, return -ENXIO); 1381 spin_lock_irqsave(&midi->open_lock, flags); 1382 snd_emu10k1x_intr_disable(emu, midi->rx_enable); 1383 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT; 1384 midi->substream_input = NULL; 1385 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { 1386 spin_unlock_irqrestore(&midi->open_lock, flags); 1387 err = snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); 1388 } else { 1389 spin_unlock_irqrestore(&midi->open_lock, flags); 1390 } 1391 return err; 1379 1392 } 1380 1393 1381 1394 static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) 1382 1395 { 1383 struct emu10k1x *emu; 1384 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1385 unsigned long flags; 1386 1387 emu = midi->emu; 1388 snd_assert(emu, return -ENXIO); 1389 spin_lock_irqsave(&midi->open_lock, flags); 1390 snd_emu10k1x_intr_disable(emu, midi->tx_enable); 1391 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT; 1392 midi->substream_output = NULL; 1393 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1394 spin_unlock_irqrestore(&midi->open_lock, flags); 1395 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); 1396 } else { 1397 spin_unlock_irqrestore(&midi->open_lock, flags); 1398 } 1399 return 0; 1396 struct emu10k1x *emu; 1397 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1398 unsigned long flags; 1399 int err = 0; 1400 1401 emu = midi->emu; 1402 snd_assert(emu, return -ENXIO); 1403 spin_lock_irqsave(&midi->open_lock, flags); 1404 snd_emu10k1x_intr_disable(emu, midi->tx_enable); 1405 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT; 1406 midi->substream_output = NULL; 1407 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1408 spin_unlock_irqrestore(&midi->open_lock, flags); 1409 err = snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); 1410 } else { 1411 spin_unlock_irqrestore(&midi->open_lock, flags); 1412 } 1413 return err; 1400 1414 } 1401 1415 1402 1416 static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 1403 1417 { 1404 1405 1406 1407 1408 1409 1410 1411 1412 1418 struct emu10k1x *emu; 1419 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1420 emu = midi->emu; 1421 snd_assert(emu, return); 1422 1423 if (up) 1424 snd_emu10k1x_intr_enable(emu, midi->rx_enable); 1425 else 1426 snd_emu10k1x_intr_disable(emu, midi->rx_enable); 1413 1427 } 1414 1428 1415 1429 static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) 1416 1430 { 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1431 struct emu10k1x *emu; 1432 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1433 unsigned long flags; 1434 1435 emu = midi->emu; 1436 snd_assert(emu, return); 1437 1438 if (up) { 1439 int max = 4; 1440 unsigned char byte; 1441 1442 /* try to send some amount of bytes here before interrupts */ 1443 spin_lock_irqsave(&midi->output_lock, flags); 1444 while (max > 0) { 1445 if (mpu401_output_ready(emu, midi)) { 1446 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT) || 1447 snd_rawmidi_transmit(substream, &byte, 1) != 1) { 1448 /* no more data */ 1449 spin_unlock_irqrestore(&midi->output_lock, flags); 1450 return; 1451 } 1452 mpu401_write_data(emu, midi, byte); 1453 max--; 1454 } else { 1455 break; 1456 } 1457 } 1458 spin_unlock_irqrestore(&midi->output_lock, flags); 1459 snd_emu10k1x_intr_enable(emu, midi->tx_enable); 1460 } else { 1461 snd_emu10k1x_intr_disable(emu, midi->tx_enable); 1462 } 1449 1463 } 1450 1464 1451 1465 /* 1452 1466 1453 1467 */ 1454 1468 1455 1469 static struct snd_rawmidi_ops snd_emu10k1x_midi_output = 1456 1470 { 1457 1458 1459 1471 .open = snd_emu10k1x_midi_output_open, 1472 .close = snd_emu10k1x_midi_output_close, 1473 .trigger = snd_emu10k1x_midi_output_trigger, 1460 1474 }; 1461 1475 1462 1476 static struct snd_rawmidi_ops snd_emu10k1x_midi_input = 1463 1477 { 1464 1465 1466 1478 .open = snd_emu10k1x_midi_input_open, 1479 .close = snd_emu10k1x_midi_input_close, 1480 .trigger = snd_emu10k1x_midi_input_trigger, 1467 1481 }; 1468 1482 1469 1483 static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi) 1470 1484 { 1471 1472 1473 1485 struct emu10k1x_midi *midi = rmidi->private_data; 1486 midi->interrupt = NULL; 1487 midi->rmidi = NULL; 1474 1488 } 1475 1489 1476 1490 static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, 1477 1478 { 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1491 struct emu10k1x_midi *midi, int device, char *name) 1492 { 1493 struct snd_rawmidi *rmidi; 1494 int err; 1495 1496 if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) 1497 return err; 1498 midi->emu = emu; 1499 spin_lock_init(&midi->open_lock); 1500 spin_lock_init(&midi->input_lock); 1501 spin_lock_init(&midi->output_lock); 1502 strcpy(rmidi->name, name); 1503 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_emu10k1x_midi_output); 1504 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_emu10k1x_midi_input); 1505 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | 1506 SNDRV_RAWMIDI_INFO_INPUT | 1507 SNDRV_RAWMIDI_INFO_DUPLEX; 1508 rmidi->private_data = midi; 1509 rmidi->private_free = snd_emu10k1x_midi_free; 1510 midi->rmidi = rmidi; 1511 return 0; 1498 1512 } 1499 1513 1500 1514 static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu) 1501 1515 { 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1516 struct emu10k1x_midi *midi = &emu->midi; 1517 int err; 1518 1519 if ((err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)")) < 0) 1520 return err; 1521 1522 midi->tx_enable = INTE_MIDITXENABLE; 1523 midi->rx_enable = INTE_MIDIRXENABLE; 1524 midi->port = MUDATA; 1525 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; 1526 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; 1527 midi->interrupt = snd_emu10k1x_midi_interrupt; 1528 return 0; 1515 1529 } 1516 1530 1517 1531 static int __devinit snd_emu10k1x_probe(struct pci_dev *pci, 1518 1519 { 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1532 const struct pci_device_id *pci_id) 1533 { 1534 static int dev; 1535 struct snd_card *card; 1536 struct emu10k1x *chip; 1537 int err; 1538 1539 if (dev >= SNDRV_CARDS) 1540 return -ENODEV; 1541 if (!enable[dev]) { 1542 dev++; 1543 return -ENOENT; 1544 } 1545 1546 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 1547 if (card == NULL) 1548 return -ENOMEM; 1549 1550 if ((err = snd_emu10k1x_create(card, pci, &chip)) < 0) { 1551 snd_card_free(card); 1552 return err; 1553 } 1554 1555 if ((err = snd_emu10k1x_pcm(chip, 0, NULL)) < 0) { 1556 snd_card_free(card); 1557 return err; 1558 } 1559 if ((err = snd_emu10k1x_pcm(chip, 1, NULL)) < 0) { 1560 snd_card_free(card); 1561 return err; 1562 } 1563 if ((err = snd_emu10k1x_pcm(chip, 2, NULL)) < 0) { 1564 snd_card_free(card); 1565 return err; 1566 } 1567 1568 if ((err = snd_emu10k1x_ac97(chip)) < 0) { 1569 snd_card_free(card); 1570 return err; 1571 } 1572 1573 if ((err = snd_emu10k1x_mixer(chip)) < 0) { 1574 snd_card_free(card); 1575 return err; 1576 } 1577 1578 if ((err = snd_emu10k1x_midi(chip)) < 0) { 1579 snd_card_free(card); 1580 return err; 1581 } 1582 1583 snd_emu10k1x_proc_init(chip); 1584 1585 strcpy(card->driver, "EMU10K1X"); 1586 strcpy(card->shortname, "Dell Sound Blaster Live!"); 1587 sprintf(card->longname, "%s at 0x%lx irq %i", 1588 card->shortname, chip->port, chip->irq); 1589 1590 if ((err = snd_card_register(card)) < 0) { 1591 snd_card_free(card); 1592 return err; 1593 } 1594 1595 pci_set_drvdata(pci, card); 1596 dev++; 1597 return 0; 1584 1598 } 1585 1599 1586 1600 static void __devexit snd_emu10k1x_remove(struct pci_dev *pci) 1587 1601 { 1588 1589 1602 snd_card_free(pci_get_drvdata(pci)); 1603 pci_set_drvdata(pci, NULL); 1590 1604 } 1591 1605 1592 1606 // PCI IDs 1593 1607 static struct pci_device_id snd_emu10k1x_ids[] = { 1594 1595 1608 { 0x1102, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Dell OEM version (EMU10K1) */ 1609 { 0, } 1596 1610 }; 1597 1611 MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids); … … 1599 1613 // pci_driver definition 1600 1614 static struct pci_driver driver = { 1601 1602 1603 1604 1615 .name = "EMU10K1X", 1616 .id_table = snd_emu10k1x_ids, 1617 .probe = snd_emu10k1x_probe, 1618 .remove = snd_emu10k1x_remove, 1605 1619 }; 1606 1620 … … 1608 1622 static int __init alsa_card_emu10k1x_init(void) 1609 1623 { 1610 1611 1612 1613 1614 1615 1624 int err; 1625 1626 if ((err = pci_register_driver(&driver)) > 0) 1627 return err; 1628 1629 return 0; 1616 1630 } 1617 1631 … … 1619 1633 static void __exit alsa_card_emu10k1x_exit(void) 1620 1634 { 1621 1635 pci_unregister_driver(&driver); 1622 1636 } 1623 1637 -
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 -
GPL/trunk/alsa-kernel/pci/emu10k1/emumixer.c
r34 r84 5 5 * Routines for control of EMU10K1 chips / mixer routines 6 6 * Multichannel PCM support Copyright (c) Lee Revell <rlrevell@joe-job.com> 7 * 8 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk> 9 * Added EMU 1010 support. 7 10 * 8 11 * BUGS: … … 36 39 #define AC97_ID_STAC9758 0x83847658 37 40 38 static int snd_emu10k1_spdif_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)41 static int snd_emu10k1_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 39 42 { 40 43 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; … … 43 46 } 44 47 45 static int snd_emu10k1_spdif_get(s nd_kcontrol_t *kcontrol,46 s nd_ctl_elem_value_t *ucontrol)48 static int snd_emu10k1_spdif_get(struct snd_kcontrol *kcontrol, 49 struct snd_ctl_elem_value *ucontrol) 47 50 { 48 51 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 59 62 } 60 63 61 static int snd_emu10k1_spdif_get_mask(s nd_kcontrol_t *kcontrol,62 s nd_ctl_elem_value_t *ucontrol)64 static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol, 65 struct snd_ctl_elem_value *ucontrol) 63 66 { 64 67 ucontrol->value.iec958.status[0] = 0xff; … … 69 72 } 70 73 71 static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 74 static char *emu1010_src_texts[] = { 75 "Silence", 76 "Dock Mic A", 77 "Dock Mic B", 78 "Dock ADC1 Left", 79 "Dock ADC1 Right", 80 "Dock ADC2 Left", 81 "Dock ADC2 Right", 82 "Dock ADC3 Left", 83 "Dock ADC3 Right", 84 "0202 ADC Left", 85 "0202 ADC Right", 86 "0202 SPDIF Left", 87 "0202 SPDIF Right", 88 "ADAT 0", 89 "ADAT 1", 90 "ADAT 2", 91 "ADAT 3", 92 "ADAT 4", 93 "ADAT 5", 94 "ADAT 6", 95 "ADAT 7", 96 "DSP 0", 97 "DSP 1", 98 "DSP 2", 99 "DSP 3", 100 "DSP 4", 101 "DSP 5", 102 "DSP 6", 103 "DSP 7", 104 "DSP 8", 105 "DSP 9", 106 "DSP 10", 107 "DSP 11", 108 "DSP 12", 109 "DSP 13", 110 "DSP 14", 111 "DSP 15", 112 "DSP 16", 113 "DSP 17", 114 "DSP 18", 115 "DSP 19", 116 "DSP 20", 117 "DSP 21", 118 "DSP 22", 119 "DSP 23", 120 "DSP 24", 121 "DSP 25", 122 "DSP 26", 123 "DSP 27", 124 "DSP 28", 125 "DSP 29", 126 "DSP 30", 127 "DSP 31", 128 }; 129 130 static unsigned int emu1010_src_regs[] = { 131 EMU_SRC_SILENCE,/* 0 */ 132 EMU_SRC_DOCK_MIC_A1, /* 1 */ 133 EMU_SRC_DOCK_MIC_B1, /* 2 */ 134 EMU_SRC_DOCK_ADC1_LEFT1, /* 3 */ 135 EMU_SRC_DOCK_ADC1_RIGHT1, /* 4 */ 136 EMU_SRC_DOCK_ADC2_LEFT1, /* 5 */ 137 EMU_SRC_DOCK_ADC2_RIGHT1, /* 6 */ 138 EMU_SRC_DOCK_ADC3_LEFT1, /* 7 */ 139 EMU_SRC_DOCK_ADC3_RIGHT1, /* 8 */ 140 EMU_SRC_HAMOA_ADC_LEFT1, /* 9 */ 141 EMU_SRC_HAMOA_ADC_RIGHT1, /* 10 */ 142 EMU_SRC_HANA_SPDIF_LEFT1, /* 11 */ 143 EMU_SRC_HANA_SPDIF_RIGHT1, /* 12 */ 144 EMU_SRC_HANA_ADAT, /* 13 */ 145 EMU_SRC_HANA_ADAT+1, /* 14 */ 146 EMU_SRC_HANA_ADAT+2, /* 15 */ 147 EMU_SRC_HANA_ADAT+3, /* 16 */ 148 EMU_SRC_HANA_ADAT+4, /* 17 */ 149 EMU_SRC_HANA_ADAT+5, /* 18 */ 150 EMU_SRC_HANA_ADAT+6, /* 19 */ 151 EMU_SRC_HANA_ADAT+7, /* 20 */ 152 EMU_SRC_ALICE_EMU32A, /* 21 */ 153 EMU_SRC_ALICE_EMU32A+1, /* 22 */ 154 EMU_SRC_ALICE_EMU32A+2, /* 23 */ 155 EMU_SRC_ALICE_EMU32A+3, /* 24 */ 156 EMU_SRC_ALICE_EMU32A+4, /* 25 */ 157 EMU_SRC_ALICE_EMU32A+5, /* 26 */ 158 EMU_SRC_ALICE_EMU32A+6, /* 27 */ 159 EMU_SRC_ALICE_EMU32A+7, /* 28 */ 160 EMU_SRC_ALICE_EMU32A+8, /* 29 */ 161 EMU_SRC_ALICE_EMU32A+9, /* 30 */ 162 EMU_SRC_ALICE_EMU32A+0xa, /* 31 */ 163 EMU_SRC_ALICE_EMU32A+0xb, /* 32 */ 164 EMU_SRC_ALICE_EMU32A+0xc, /* 33 */ 165 EMU_SRC_ALICE_EMU32A+0xd, /* 34 */ 166 EMU_SRC_ALICE_EMU32A+0xe, /* 35 */ 167 EMU_SRC_ALICE_EMU32A+0xf, /* 36 */ 168 EMU_SRC_ALICE_EMU32B, /* 37 */ 169 EMU_SRC_ALICE_EMU32B+1, /* 38 */ 170 EMU_SRC_ALICE_EMU32B+2, /* 39 */ 171 EMU_SRC_ALICE_EMU32B+3, /* 40 */ 172 EMU_SRC_ALICE_EMU32B+4, /* 41 */ 173 EMU_SRC_ALICE_EMU32B+5, /* 42 */ 174 EMU_SRC_ALICE_EMU32B+6, /* 43 */ 175 EMU_SRC_ALICE_EMU32B+7, /* 44 */ 176 EMU_SRC_ALICE_EMU32B+8, /* 45 */ 177 EMU_SRC_ALICE_EMU32B+9, /* 46 */ 178 EMU_SRC_ALICE_EMU32B+0xa, /* 47 */ 179 EMU_SRC_ALICE_EMU32B+0xb, /* 48 */ 180 EMU_SRC_ALICE_EMU32B+0xc, /* 49 */ 181 EMU_SRC_ALICE_EMU32B+0xd, /* 50 */ 182 EMU_SRC_ALICE_EMU32B+0xe, /* 51 */ 183 EMU_SRC_ALICE_EMU32B+0xf, /* 52 */ 184 }; 185 186 static unsigned int emu1010_output_dst[] = { 187 EMU_DST_DOCK_DAC1_LEFT1, /* 0 */ 188 EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */ 189 EMU_DST_DOCK_DAC2_LEFT1, /* 2 */ 190 EMU_DST_DOCK_DAC2_RIGHT1, /* 3 */ 191 EMU_DST_DOCK_DAC3_LEFT1, /* 4 */ 192 EMU_DST_DOCK_DAC3_RIGHT1, /* 5 */ 193 EMU_DST_DOCK_DAC4_LEFT1, /* 6 */ 194 EMU_DST_DOCK_DAC4_RIGHT1, /* 7 */ 195 EMU_DST_DOCK_PHONES_LEFT1, /* 8 */ 196 EMU_DST_DOCK_PHONES_RIGHT1, /* 9 */ 197 EMU_DST_DOCK_SPDIF_LEFT1, /* 10 */ 198 EMU_DST_DOCK_SPDIF_RIGHT1, /* 11 */ 199 EMU_DST_HANA_SPDIF_LEFT1, /* 12 */ 200 EMU_DST_HANA_SPDIF_RIGHT1, /* 13 */ 201 EMU_DST_HAMOA_DAC_LEFT1, /* 14 */ 202 EMU_DST_HAMOA_DAC_RIGHT1, /* 15 */ 203 EMU_DST_HANA_ADAT, /* 16 */ 204 EMU_DST_HANA_ADAT+1, /* 17 */ 205 EMU_DST_HANA_ADAT+2, /* 18 */ 206 EMU_DST_HANA_ADAT+3, /* 19 */ 207 EMU_DST_HANA_ADAT+4, /* 20 */ 208 EMU_DST_HANA_ADAT+5, /* 21 */ 209 EMU_DST_HANA_ADAT+6, /* 22 */ 210 EMU_DST_HANA_ADAT+7, /* 23 */ 211 }; 212 213 static unsigned int emu1010_input_dst[] = { 214 EMU_DST_ALICE2_EMU32_0, 215 EMU_DST_ALICE2_EMU32_1, 216 EMU_DST_ALICE2_EMU32_2, 217 EMU_DST_ALICE2_EMU32_3, 218 EMU_DST_ALICE2_EMU32_4, 219 EMU_DST_ALICE2_EMU32_5, 220 EMU_DST_ALICE2_EMU32_6, 221 EMU_DST_ALICE2_EMU32_7, 222 EMU_DST_ALICE2_EMU32_8, 223 EMU_DST_ALICE2_EMU32_9, 224 EMU_DST_ALICE2_EMU32_A, 225 EMU_DST_ALICE2_EMU32_B, 226 EMU_DST_ALICE2_EMU32_C, 227 EMU_DST_ALICE2_EMU32_D, 228 EMU_DST_ALICE2_EMU32_E, 229 EMU_DST_ALICE2_EMU32_F, 230 EMU_DST_ALICE_I2S0_LEFT, 231 EMU_DST_ALICE_I2S0_RIGHT, 232 EMU_DST_ALICE_I2S1_LEFT, 233 EMU_DST_ALICE_I2S1_RIGHT, 234 EMU_DST_ALICE_I2S2_LEFT, 235 EMU_DST_ALICE_I2S2_RIGHT, 236 }; 237 238 static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 239 { 240 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 241 uinfo->count = 1; 242 uinfo->value.enumerated.items = 53; 243 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 244 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 245 strcpy(uinfo->value.enumerated.name, emu1010_src_texts[uinfo->value.enumerated.item]); 246 return 0; 247 } 248 249 static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol, 250 struct snd_ctl_elem_value *ucontrol) 251 { 252 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 253 int channel; 254 255 channel = (kcontrol->private_value) & 0xff; 256 ucontrol->value.enumerated.item[0] = emu->emu1010.output_source[channel]; 257 return 0; 258 } 259 260 static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol, 261 struct snd_ctl_elem_value *ucontrol) 262 { 263 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 264 int change = 0; 265 unsigned int val; 266 int channel; 267 268 channel = (kcontrol->private_value) & 0xff; 269 if (emu->emu1010.output_source[channel] != ucontrol->value.enumerated.item[0]) { 270 val = emu->emu1010.output_source[channel] = ucontrol->value.enumerated.item[0]; 271 change = 1; 272 snd_emu1010_fpga_link_dst_src_write(emu, 273 emu1010_output_dst[channel], emu1010_src_regs[val]); 274 } 275 return change; 276 } 277 278 static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol, 279 struct snd_ctl_elem_value *ucontrol) 280 { 281 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 282 int channel; 283 284 channel = (kcontrol->private_value) & 0xff; 285 ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel]; 286 return 0; 287 } 288 289 static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol, 290 struct snd_ctl_elem_value *ucontrol) 291 { 292 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 293 int change = 0; 294 unsigned int val; 295 int channel; 296 297 channel = (kcontrol->private_value) & 0xff; 298 if (emu->emu1010.input_source[channel] != ucontrol->value.enumerated.item[0]) { 299 val = emu->emu1010.input_source[channel] = ucontrol->value.enumerated.item[0]; 300 change = 1; 301 snd_emu1010_fpga_link_dst_src_write(emu, 302 emu1010_input_dst[channel], emu1010_src_regs[val]); 303 } 304 return change; 305 } 306 307 #define EMU1010_SOURCE_OUTPUT(xname,chid) \ 308 { \ 309 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 310 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 311 .info = snd_emu1010_input_output_source_info, \ 312 .get = snd_emu1010_output_source_get, \ 313 .put = snd_emu1010_output_source_put, \ 314 .private_value = chid \ 315 } 316 317 static struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] __devinitdata = { 318 EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Switch", 0), 319 EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Switch", 1), 320 EMU1010_SOURCE_OUTPUT("Dock DAC2 Left Playback Switch", 2), 321 EMU1010_SOURCE_OUTPUT("Dock DAC2 Right Playback Switch", 3), 322 EMU1010_SOURCE_OUTPUT("Dock DAC3 Left Playback Switch", 4), 323 EMU1010_SOURCE_OUTPUT("Dock DAC3 Right Playback Switch", 5), 324 EMU1010_SOURCE_OUTPUT("Dock DAC4 Left Playback Switch", 6), 325 EMU1010_SOURCE_OUTPUT("Dock DAC4 Right Playback Switch", 7), 326 EMU1010_SOURCE_OUTPUT("Dock Phones Left Playback Switch", 8), 327 EMU1010_SOURCE_OUTPUT("Dock Phones Right Playback Switch", 9), 328 EMU1010_SOURCE_OUTPUT("Dock SPDIF Left Playback Switch", 0xa), 329 EMU1010_SOURCE_OUTPUT("Dock SPDIF Right Playback Switch", 0xb), 330 EMU1010_SOURCE_OUTPUT("1010 SPDIF Left Playback Switch", 0xc), 331 EMU1010_SOURCE_OUTPUT("1010 SPDIF Right Playback Switch", 0xd), 332 EMU1010_SOURCE_OUTPUT("0202 DAC Left Playback Switch", 0xe), 333 EMU1010_SOURCE_OUTPUT("0202 DAC Right Playback Switch", 0xf), 334 EMU1010_SOURCE_OUTPUT("1010 ADAT 0 Playback Switch", 0x10), 335 EMU1010_SOURCE_OUTPUT("1010 ADAT 1 Playback Switch", 0x11), 336 EMU1010_SOURCE_OUTPUT("1010 ADAT 2 Playback Switch", 0x12), 337 EMU1010_SOURCE_OUTPUT("1010 ADAT 3 Playback Switch", 0x13), 338 EMU1010_SOURCE_OUTPUT("1010 ADAT 4 Playback Switch", 0x14), 339 EMU1010_SOURCE_OUTPUT("1010 ADAT 5 Playback Switch", 0x15), 340 EMU1010_SOURCE_OUTPUT("1010 ADAT 6 Playback Switch", 0x16), 341 EMU1010_SOURCE_OUTPUT("1010 ADAT 7 Playback Switch", 0x17), 342 }; 343 344 #define EMU1010_SOURCE_INPUT(xname,chid) \ 345 { \ 346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 347 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 348 .info = snd_emu1010_input_output_source_info, \ 349 .get = snd_emu1010_input_source_get, \ 350 .put = snd_emu1010_input_source_put, \ 351 .private_value = chid \ 352 } 353 354 static struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] __devinitdata = { 355 EMU1010_SOURCE_INPUT("DSP 0 Capture Switch", 0), 356 EMU1010_SOURCE_INPUT("DSP 1 Capture Switch", 1), 357 EMU1010_SOURCE_INPUT("DSP 2 Capture Switch", 2), 358 EMU1010_SOURCE_INPUT("DSP 3 Capture Switch", 3), 359 EMU1010_SOURCE_INPUT("DSP 4 Capture Switch", 4), 360 EMU1010_SOURCE_INPUT("DSP 5 Capture Switch", 5), 361 EMU1010_SOURCE_INPUT("DSP 6 Capture Switch", 6), 362 EMU1010_SOURCE_INPUT("DSP 7 Capture Switch", 7), 363 EMU1010_SOURCE_INPUT("DSP 8 Capture Switch", 8), 364 EMU1010_SOURCE_INPUT("DSP 9 Capture Switch", 9), 365 EMU1010_SOURCE_INPUT("DSP A Capture Switch", 0xa), 366 EMU1010_SOURCE_INPUT("DSP B Capture Switch", 0xb), 367 EMU1010_SOURCE_INPUT("DSP C Capture Switch", 0xc), 368 EMU1010_SOURCE_INPUT("DSP D Capture Switch", 0xd), 369 EMU1010_SOURCE_INPUT("DSP E Capture Switch", 0xe), 370 EMU1010_SOURCE_INPUT("DSP F Capture Switch", 0xf), 371 EMU1010_SOURCE_INPUT("DSP 10 Capture Switch", 0x10), 372 EMU1010_SOURCE_INPUT("DSP 11 Capture Switch", 0x11), 373 EMU1010_SOURCE_INPUT("DSP 12 Capture Switch", 0x12), 374 EMU1010_SOURCE_INPUT("DSP 13 Capture Switch", 0x13), 375 EMU1010_SOURCE_INPUT("DSP 14 Capture Switch", 0x14), 376 EMU1010_SOURCE_INPUT("DSP 15 Capture Switch", 0x15), 377 }; 378 379 380 381 382 static int snd_emu1010_adc_pads_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 383 { 384 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 385 uinfo->count = 1; 386 uinfo->value.integer.min = 0; 387 uinfo->value.integer.max = 1; 388 return 0; 389 } 390 391 static int snd_emu1010_adc_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 392 { 393 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 394 unsigned int mask = kcontrol->private_value & 0xff; 395 ucontrol->value.integer.value[0] = (emu->emu1010.adc_pads & mask) ? 1 : 0; 396 return 0; 397 } 398 399 static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 400 { 401 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 402 unsigned int mask = kcontrol->private_value & 0xff; 403 unsigned int val, cache; 404 val = ucontrol->value.integer.value[0]; 405 cache = emu->emu1010.adc_pads; 406 if (val == 1) 407 cache = cache | mask; 408 else 409 cache = cache & ~mask; 410 if (cache != emu->emu1010.adc_pads) { 411 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, cache ); 412 emu->emu1010.adc_pads = cache; 413 } 414 415 return 0; 416 } 417 418 419 420 #define EMU1010_ADC_PADS(xname,chid) \ 421 { \ 422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 423 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 424 .info = snd_emu1010_adc_pads_info, \ 425 .get = snd_emu1010_adc_pads_get, \ 426 .put = snd_emu1010_adc_pads_put, \ 427 .private_value = chid \ 428 } 429 430 static struct snd_kcontrol_new snd_emu1010_adc_pads[] __devinitdata = { 431 EMU1010_ADC_PADS("ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1), 432 EMU1010_ADC_PADS("ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2), 433 EMU1010_ADC_PADS("ADC3 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD3), 434 EMU1010_ADC_PADS("ADC1 14dB PAD 0202 Capture Switch", EMU_HANA_0202_ADC_PAD1), 435 }; 436 437 static int snd_emu1010_dac_pads_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 438 { 439 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 440 uinfo->count = 1; 441 uinfo->value.integer.min = 0; 442 uinfo->value.integer.max = 1; 443 return 0; 444 } 445 446 static int snd_emu1010_dac_pads_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 447 { 448 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 449 unsigned int mask = kcontrol->private_value & 0xff; 450 ucontrol->value.integer.value[0] = (emu->emu1010.dac_pads & mask) ? 1 : 0; 451 return 0; 452 } 453 454 static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 455 { 456 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 457 unsigned int mask = kcontrol->private_value & 0xff; 458 unsigned int val, cache; 459 val = ucontrol->value.integer.value[0]; 460 cache = emu->emu1010.dac_pads; 461 if (val == 1) 462 cache = cache | mask; 463 else 464 cache = cache & ~mask; 465 if (cache != emu->emu1010.dac_pads) { 466 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, cache ); 467 emu->emu1010.dac_pads = cache; 468 } 469 470 return 0; 471 } 472 473 474 475 #define EMU1010_DAC_PADS(xname,chid) \ 476 { \ 477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 478 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 479 .info = snd_emu1010_dac_pads_info, \ 480 .get = snd_emu1010_dac_pads_get, \ 481 .put = snd_emu1010_dac_pads_put, \ 482 .private_value = chid \ 483 } 484 485 static struct snd_kcontrol_new snd_emu1010_dac_pads[] __devinitdata = { 486 EMU1010_DAC_PADS("DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1), 487 EMU1010_DAC_PADS("DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2), 488 EMU1010_DAC_PADS("DAC3 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD3), 489 EMU1010_DAC_PADS("DAC4 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD4), 490 EMU1010_DAC_PADS("DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1), 491 }; 492 493 494 static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol, 495 struct snd_ctl_elem_info *uinfo) 496 { 497 static char *texts[2] = { 498 "44100", "48000" 499 }; 500 501 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 502 uinfo->count = 1; 503 uinfo->value.enumerated.items = 2; 504 if (uinfo->value.enumerated.item > 1) 505 uinfo->value.enumerated.item = 1; 506 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 507 return 0; 508 } 509 510 static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol, 511 struct snd_ctl_elem_value *ucontrol) 512 { 513 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 514 515 ucontrol->value.enumerated.item[0] = emu->emu1010.internal_clock; 516 return 0; 517 } 518 519 static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol, 520 struct snd_ctl_elem_value *ucontrol) 521 { 522 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 523 unsigned int val; 524 int change = 0; 525 526 val = ucontrol->value.enumerated.item[0] ; 527 change = (emu->emu1010.internal_clock != val); 528 if (change) { 529 emu->emu1010.internal_clock = val; 530 switch (val) { 531 case 0: 532 /* 44100 */ 533 /* Mute all */ 534 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE ); 535 /* Default fallback clock 48kHz */ 536 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_44_1K ); 537 /* Word Clock source, Internal 44.1kHz x1 */ 538 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, 539 EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X ); 540 /* Set LEDs on Audio Dock */ 541 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 542 EMU_HANA_DOCK_LEDS_2_44K | EMU_HANA_DOCK_LEDS_2_LOCK ); 543 /* Allow DLL to settle */ 544 msleep(10); 545 /* Unmute all */ 546 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); 547 break; 548 case 1: 549 /* 48000 */ 550 /* Mute all */ 551 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE ); 552 /* Default fallback clock 48kHz */ 553 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_48K ); 554 /* Word Clock source, Internal 48kHz x1 */ 555 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, 556 EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X ); 557 /* Set LEDs on Audio Dock */ 558 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 559 EMU_HANA_DOCK_LEDS_2_48K | EMU_HANA_DOCK_LEDS_2_LOCK ); 560 /* Allow DLL to settle */ 561 msleep(10); 562 /* Unmute all */ 563 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); 564 break; 565 } 566 } 567 return change; 568 } 569 570 static struct snd_kcontrol_new snd_emu1010_internal_clock = 571 { 572 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 574 .name = "Clock Internal Rate", 575 .count = 1, 576 .info = snd_emu1010_internal_clock_info, 577 .get = snd_emu1010_internal_clock_get, 578 .put = snd_emu1010_internal_clock_put 579 }; 580 581 582 #if 0 583 static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 72 584 { 73 585 static char *texts[] = {"44100", "48000", "96000"}; … … 82 594 } 83 595 84 static int snd_audigy_spdif_output_rate_get(s nd_kcontrol_t *kcontrol,85 s nd_ctl_elem_value_t *ucontrol)596 static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol, 597 struct snd_ctl_elem_value *ucontrol) 86 598 { 87 599 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 109 621 } 110 622 111 static int snd_audigy_spdif_output_rate_put(s nd_kcontrol_t *kcontrol,112 s nd_ctl_elem_value_t *ucontrol)623 static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol, 624 struct snd_ctl_elem_value *ucontrol) 113 625 { 114 626 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 143 655 } 144 656 145 static snd_kcontrol_new_t snd_audigy_spdif_output_rate = 146 { 147 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 148 "Audigy SPDIF Output Sample Rate", 0, 149 SNDRV_CTL_ELEM_ACCESS_READWRITE, 150 1, 151 snd_audigy_spdif_output_rate_info, 152 snd_audigy_spdif_output_rate_get, 153 snd_audigy_spdif_output_rate_put, 0 154 }; 155 156 static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, 157 snd_ctl_elem_value_t * ucontrol) 657 static struct snd_kcontrol_new snd_audigy_spdif_output_rate = 658 { 659 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 661 .name = "Audigy SPDIF Output Sample Rate", 662 .count = 1, 663 .info = snd_audigy_spdif_output_rate_info, 664 .get = snd_audigy_spdif_output_rate_get, 665 .put = snd_audigy_spdif_output_rate_put 666 }; 667 #endif 668 669 static int snd_emu10k1_spdif_put(struct snd_kcontrol *kcontrol, 670 struct snd_ctl_elem_value *ucontrol) 158 671 { 159 672 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 177 690 } 178 691 179 static snd_kcontrol_new_t snd_emu10k1_spdif_mask_control = 180 { 181 SNDRV_CTL_ELEM_IFACE_PCM,0,0, 182 SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), 183 0,SNDRV_CTL_ELEM_ACCESS_READ,4, 184 snd_emu10k1_spdif_info, 185 snd_emu10k1_spdif_get_mask,0,0 186 }; 187 188 static snd_kcontrol_new_t snd_emu10k1_spdif_control = 189 { 190 SNDRV_CTL_ELEM_IFACE_PCM,0,0, 191 SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),0,0,4, 192 snd_emu10k1_spdif_info, 193 snd_emu10k1_spdif_get, 194 snd_emu10k1_spdif_put,0 195 }; 692 static struct snd_kcontrol_new snd_emu10k1_spdif_mask_control = 693 { 694 .access = SNDRV_CTL_ELEM_ACCESS_READ, 695 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 696 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), 697 .count = 4, 698 .info = snd_emu10k1_spdif_info, 699 .get = snd_emu10k1_spdif_get_mask 700 }; 701 702 static struct snd_kcontrol_new snd_emu10k1_spdif_control = 703 { 704 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 705 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 706 .count = 4, 707 .info = snd_emu10k1_spdif_info, 708 .get = snd_emu10k1_spdif_get, 709 .put = snd_emu10k1_spdif_put 710 }; 711 196 712 197 713 static void update_emu10k1_fxrt(struct snd_emu10k1 *emu, int voice, unsigned char *route) … … 225 741 /* PCM stream controls */ 226 742 227 static int snd_emu10k1_send_routing_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)743 static int snd_emu10k1_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 228 744 { 229 745 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 235 751 } 236 752 237 static int snd_emu10k1_send_routing_get(snd_kcontrol_t * kcontrol, 238 snd_ctl_elem_value_t * ucontrol) 239 { 240 unsigned long flags; 241 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 242 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 753 static int snd_emu10k1_send_routing_get(struct snd_kcontrol *kcontrol, 754 struct snd_ctl_elem_value *ucontrol) 755 { 756 unsigned long flags; 757 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 758 struct snd_emu10k1_pcm_mixer *mix = 759 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 243 760 int voice, idx; 244 761 int num_efx = emu->audigy ? 8 : 4; … … 254 771 } 255 772 256 static int snd_emu10k1_send_routing_put(snd_kcontrol_t * kcontrol, 257 snd_ctl_elem_value_t * ucontrol) 258 { 259 unsigned long flags; 260 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 261 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 773 static int snd_emu10k1_send_routing_put(struct snd_kcontrol *kcontrol, 774 struct snd_ctl_elem_value *ucontrol) 775 { 776 unsigned long flags; 777 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 778 struct snd_emu10k1_pcm_mixer *mix = 779 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 262 780 int change = 0, voice, idx, val; 263 781 int num_efx = emu->audigy ? 8 : 4; … … 288 806 } 289 807 290 static snd_kcontrol_new_t snd_emu10k1_send_routing_control = 291 { 292 SNDRV_CTL_ELEM_IFACE_PCM,0,0, 293 "EMU10K1 PCM Send Routing",0, 294 SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,32, 295 snd_emu10k1_send_routing_info, 296 snd_emu10k1_send_routing_get, 297 snd_emu10k1_send_routing_put,0 298 }; 299 300 static int snd_emu10k1_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 808 static struct snd_kcontrol_new snd_emu10k1_send_routing_control = 809 { 810 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 811 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 812 .name = "EMU10K1 PCM Send Routing", 813 .count = 32, 814 .info = snd_emu10k1_send_routing_info, 815 .get = snd_emu10k1_send_routing_get, 816 .put = snd_emu10k1_send_routing_put 817 }; 818 819 static int snd_emu10k1_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 301 820 { 302 821 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 308 827 } 309 828 310 static int snd_emu10k1_send_volume_get(snd_kcontrol_t * kcontrol, 311 snd_ctl_elem_value_t * ucontrol) 312 { 313 unsigned long flags; 314 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 315 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 829 static int snd_emu10k1_send_volume_get(struct snd_kcontrol *kcontrol, 830 struct snd_ctl_elem_value *ucontrol) 831 { 832 unsigned long flags; 833 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 834 struct snd_emu10k1_pcm_mixer *mix = 835 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 316 836 int idx; 317 837 int num_efx = emu->audigy ? 8 : 4; … … 324 844 } 325 845 326 static int snd_emu10k1_send_volume_put(snd_kcontrol_t * kcontrol, 327 snd_ctl_elem_value_t * ucontrol) 328 { 329 unsigned long flags; 330 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 331 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 846 static int snd_emu10k1_send_volume_put(struct snd_kcontrol *kcontrol, 847 struct snd_ctl_elem_value *ucontrol) 848 { 849 unsigned long flags; 850 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 851 struct snd_emu10k1_pcm_mixer *mix = 852 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 332 853 int change = 0, idx, val; 333 854 int num_efx = emu->audigy ? 8 : 4; … … 356 877 } 357 878 358 static snd_kcontrol_new_t snd_emu10k1_send_volume_control = 359 { 360 SNDRV_CTL_ELEM_IFACE_PCM,0,0, 361 "EMU10K1 PCM Send Volume",0, 362 SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,32, 363 snd_emu10k1_send_volume_info, 364 snd_emu10k1_send_volume_get, 365 snd_emu10k1_send_volume_put,0 366 }; 367 368 static int snd_emu10k1_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 879 static struct snd_kcontrol_new snd_emu10k1_send_volume_control = 880 { 881 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 882 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 883 .name = "EMU10K1 PCM Send Volume", 884 .count = 32, 885 .info = snd_emu10k1_send_volume_info, 886 .get = snd_emu10k1_send_volume_get, 887 .put = snd_emu10k1_send_volume_put 888 }; 889 890 static int snd_emu10k1_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 369 891 { 370 892 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; … … 375 897 } 376 898 377 static int snd_emu10k1_attn_get(snd_kcontrol_t * kcontrol, 378 snd_ctl_elem_value_t * ucontrol) 379 { 380 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 381 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 899 static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol, 900 struct snd_ctl_elem_value *ucontrol) 901 { 902 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 903 struct snd_emu10k1_pcm_mixer *mix = 904 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 382 905 unsigned long flags; 383 906 int idx; … … 390 913 } 391 914 392 static int snd_emu10k1_attn_put(snd_kcontrol_t * kcontrol, 393 snd_ctl_elem_value_t * ucontrol) 394 { 395 unsigned long flags; 396 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 397 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 915 static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol, 916 struct snd_ctl_elem_value *ucontrol) 917 { 918 unsigned long flags; 919 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 920 struct snd_emu10k1_pcm_mixer *mix = 921 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 398 922 int change = 0, idx, val; 399 923 … … 418 942 } 419 943 420 static snd_kcontrol_new_t snd_emu10k1_attn_control = 421 { 422 SNDRV_CTL_ELEM_IFACE_PCM,0,0, 423 "EMU10K1 PCM Volume",0, 424 SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,32, 425 snd_emu10k1_attn_info, 426 snd_emu10k1_attn_get, 427 snd_emu10k1_attn_put,0 944 static struct snd_kcontrol_new snd_emu10k1_attn_control = 945 { 946 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 947 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 948 .name = "EMU10K1 PCM Volume", 949 .count = 32, 950 .info = snd_emu10k1_attn_info, 951 .get = snd_emu10k1_attn_get, 952 .put = snd_emu10k1_attn_put 428 953 }; 429 954 430 955 /* Mutichannel PCM stream controls */ 431 956 432 static int snd_emu10k1_efx_send_routing_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)957 static int snd_emu10k1_efx_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 433 958 { 434 959 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 440 965 } 441 966 442 static int snd_emu10k1_efx_send_routing_get(snd_kcontrol_t * kcontrol, 443 snd_ctl_elem_value_t * ucontrol) 444 { 445 unsigned long flags; 446 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 447 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 967 static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol *kcontrol, 968 struct snd_ctl_elem_value *ucontrol) 969 { 970 unsigned long flags; 971 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 972 struct snd_emu10k1_pcm_mixer *mix = 973 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 448 974 int idx; 449 975 int num_efx = emu->audigy ? 8 : 4; … … 458 984 } 459 985 460 static int snd_emu10k1_efx_send_routing_put(s nd_kcontrol_t *kcontrol,461 s nd_ctl_elem_value_t *ucontrol)986 static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol *kcontrol, 987 struct snd_ctl_elem_value *ucontrol) 462 988 { 463 989 unsigned long flags; … … 477 1003 } 478 1004 } 1005 479 1006 if (change && mix->epcm) { 480 1007 if (mix->epcm->voices[ch]) { … … 487 1014 } 488 1015 489 static s nd_kcontrol_new_tsnd_emu10k1_efx_send_routing_control =490 { 491 SNDRV_CTL_ELEM_IFACE_PCM,0,0,492 "Multichannel PCM Send Routing",0,493 SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,494 16,495 snd_emu10k1_efx_send_routing_info,496 snd_emu10k1_efx_send_routing_get,497 snd_emu10k1_efx_send_routing_put,0498 }; 499 500 static int snd_emu10k1_efx_send_volume_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)1016 static struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control = 1017 { 1018 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 1019 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1020 .name = "Multichannel PCM Send Routing", 1021 .count = 16, 1022 .info = snd_emu10k1_efx_send_routing_info, 1023 .get = snd_emu10k1_efx_send_routing_get, 1024 .put = snd_emu10k1_efx_send_routing_put 1025 }; 1026 1027 static int snd_emu10k1_efx_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 501 1028 { 502 1029 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 508 1035 } 509 1036 510 static int snd_emu10k1_efx_send_volume_get(snd_kcontrol_t * kcontrol, 511 snd_ctl_elem_value_t * ucontrol) 512 { 513 unsigned long flags; 514 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 515 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1037 static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol *kcontrol, 1038 struct snd_ctl_elem_value *ucontrol) 1039 { 1040 unsigned long flags; 1041 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1042 struct snd_emu10k1_pcm_mixer *mix = 1043 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 516 1044 int idx; 517 1045 int num_efx = emu->audigy ? 8 : 4; … … 524 1052 } 525 1053 526 static int snd_emu10k1_efx_send_volume_put(s nd_kcontrol_t *kcontrol,527 s nd_ctl_elem_value_t *ucontrol)1054 static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol *kcontrol, 1055 struct snd_ctl_elem_value *ucontrol) 528 1056 { 529 1057 unsigned long flags; … … 553 1081 554 1082 555 static s nd_kcontrol_new_tsnd_emu10k1_efx_send_volume_control =556 { 557 SNDRV_CTL_ELEM_IFACE_PCM,0,0,558 "Multichannel PCM Send Volume",0,559 SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,560 16,561 snd_emu10k1_efx_send_volume_info,562 snd_emu10k1_efx_send_volume_get,563 snd_emu10k1_efx_send_volume_put,0564 }; 565 566 static int snd_emu10k1_efx_attn_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)1083 static struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control = 1084 { 1085 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 1086 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1087 .name = "Multichannel PCM Send Volume", 1088 .count = 16, 1089 .info = snd_emu10k1_efx_send_volume_info, 1090 .get = snd_emu10k1_efx_send_volume_get, 1091 .put = snd_emu10k1_efx_send_volume_put 1092 }; 1093 1094 static int snd_emu10k1_efx_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 567 1095 { 568 1096 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; … … 573 1101 } 574 1102 575 static int snd_emu10k1_efx_attn_get(snd_kcontrol_t * kcontrol, 576 snd_ctl_elem_value_t * ucontrol) 577 { 578 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 579 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1103 static int snd_emu10k1_efx_attn_get(struct snd_kcontrol *kcontrol, 1104 struct snd_ctl_elem_value *ucontrol) 1105 { 1106 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1107 struct snd_emu10k1_pcm_mixer *mix = 1108 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 580 1109 unsigned long flags; 581 1110 … … 586 1115 } 587 1116 588 static int snd_emu10k1_efx_attn_put(s nd_kcontrol_t *kcontrol,589 s nd_ctl_elem_value_t *ucontrol)1117 static int snd_emu10k1_efx_attn_put(struct snd_kcontrol *kcontrol, 1118 struct snd_ctl_elem_value *ucontrol) 590 1119 { 591 1120 unsigned long flags; … … 610 1139 } 611 1140 612 static s nd_kcontrol_new_tsnd_emu10k1_efx_attn_control =613 { 614 SNDRV_CTL_ELEM_IFACE_PCM,0,0,615 "Multichannel PCM Volume",0,616 SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE,617 16,618 snd_emu10k1_efx_attn_info,619 snd_emu10k1_efx_attn_get,620 snd_emu10k1_efx_attn_put,0621 }; 622 623 static int snd_emu10k1_shared_spdif_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)1141 static struct snd_kcontrol_new snd_emu10k1_efx_attn_control = 1142 { 1143 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 1144 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1145 .name = "Multichannel PCM Volume", 1146 .count = 16, 1147 .info = snd_emu10k1_efx_attn_info, 1148 .get = snd_emu10k1_efx_attn_get, 1149 .put = snd_emu10k1_efx_attn_put 1150 }; 1151 1152 static int snd_emu10k1_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 624 1153 { 625 1154 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; … … 630 1159 } 631 1160 632 static int snd_emu10k1_shared_spdif_get(s nd_kcontrol_t *kcontrol,633 s nd_ctl_elem_value_t *ucontrol)1161 static int snd_emu10k1_shared_spdif_get(struct snd_kcontrol *kcontrol, 1162 struct snd_ctl_elem_value *ucontrol) 634 1163 { 635 1164 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 642 1171 } 643 1172 644 static int snd_emu10k1_shared_spdif_put(s nd_kcontrol_t *kcontrol,645 s nd_ctl_elem_value_t *ucontrol)1173 static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol *kcontrol, 1174 struct snd_ctl_elem_value *ucontrol) 646 1175 { 647 1176 unsigned long flags; … … 673 1202 } 674 1203 675 static s nd_kcontrol_new_tsnd_emu10k1_shared_spdif __devinitdata =676 { 677 SNDRV_CTL_ELEM_IFACE_MIXER,0,0,678 "SB Live Analog/Digital Output Jack",0,0,0,679 snd_emu10k1_shared_spdif_info,680 snd_emu10k1_shared_spdif_get,681 snd_emu10k1_shared_spdif_put,0682 }; 683 684 static s nd_kcontrol_new_tsnd_audigy_shared_spdif __devinitdata =685 { 686 SNDRV_CTL_ELEM_IFACE_MIXER,0,0,687 "Audigy Analog/Digital Output Jack",0,0,0,688 snd_emu10k1_shared_spdif_info,689 snd_emu10k1_shared_spdif_get,690 snd_emu10k1_shared_spdif_put,01204 static struct snd_kcontrol_new snd_emu10k1_shared_spdif __devinitdata = 1205 { 1206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1207 .name = "SB Live Analog/Digital Output Jack", 1208 .info = snd_emu10k1_shared_spdif_info, 1209 .get = snd_emu10k1_shared_spdif_get, 1210 .put = snd_emu10k1_shared_spdif_put 1211 }; 1212 1213 static struct snd_kcontrol_new snd_audigy_shared_spdif __devinitdata = 1214 { 1215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1216 .name = "Audigy Analog/Digital Output Jack", 1217 .info = snd_emu10k1_shared_spdif_info, 1218 .get = snd_emu10k1_shared_spdif_get, 1219 .put = snd_emu10k1_shared_spdif_put 691 1220 }; 692 1221 693 1222 /* 694 1223 */ 695 static void snd_emu10k1_mixer_free_ac97( ac97_t*ac97)1224 static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97) 696 1225 { 697 1226 struct snd_emu10k1 *emu = ac97->private_data; … … 701 1230 /* 702 1231 */ 703 static int remove_ctl(s nd_card_t*card, const char *name)704 { 705 s nd_ctl_elem_id_tid;1232 static int remove_ctl(struct snd_card *card, const char *name) 1233 { 1234 struct snd_ctl_elem_id id; 706 1235 memset(&id, 0, sizeof(id)); 707 1236 strcpy(id.name, name); … … 710 1239 } 711 1240 712 static s nd_kcontrol_t *ctl_find(snd_card_t*card, const char *name)713 { 714 s nd_ctl_elem_id_tsid;1241 static struct snd_kcontrol *ctl_find(struct snd_card *card, const char *name) 1242 { 1243 struct snd_ctl_elem_id sid; 715 1244 memset(&sid, 0, sizeof(sid)); 716 1245 strcpy(sid.name, name); … … 719 1248 } 720 1249 721 static int rename_ctl(s nd_card_t*card, const char *src, const char *dst)722 { 723 s nd_kcontrol_t*kctl = ctl_find(card, src);1250 static int rename_ctl(struct snd_card *card, const char *src, const char *dst) 1251 { 1252 struct snd_kcontrol *kctl = ctl_find(card, src); 724 1253 if (kctl) { 725 1254 strcpy(kctl->id.name, dst); … … 733 1262 { 734 1263 int err, pcm; 735 s nd_kcontrol_t*kctl;736 s nd_card_t*card = emu->card;1264 struct snd_kcontrol *kctl; 1265 struct snd_card *card = emu->card; 737 1266 char **c; 738 1267 static char *emu10k1_remove_ctls[] = { … … 742 1271 "PCM Out Path & Mute", 743 1272 "Mono Output Select", 1273 "Front Playback Switch", 1274 "Front Playback Volume", 744 1275 "Surround Playback Switch", 745 1276 "Surround Playback Volume", … … 758 1289 static char *audigy_remove_ctls[] = { 759 1290 /* Master/PCM controls on ac97 of Audigy has no effect */ 1291 /* On the Audigy2 the AC97 playback is piped into 1292 * the Philips ADC for 24bit capture */ 760 1293 "PCM Playback Switch", 761 1294 "PCM Playback Volume", … … 786 1319 }; 787 1320 1321 static char *audigy_remove_ctls_1361t_adc[] = { 1322 /* On the Audigy2 the AC97 playback is piped into 1323 * the Philips ADC for 24bit capture */ 1324 "PCM Playback Switch", 1325 "PCM Playback Volume", 1326 "Master Mono Playback Switch", 1327 "Master Mono Playback Volume", 1328 "Capture Source", 1329 "Capture Switch", 1330 "Capture Volume", 1331 "Mic Capture Volume", 1332 "Headphone Playback Switch", 1333 "Headphone Playback Volume", 1334 "3D Control - Center", 1335 "3D Control - Depth", 1336 "3D Control - Switch", 1337 "Line2 Playback Volume", 1338 "Line2 Capture Volume", 1339 NULL 1340 }; 1341 static char *audigy_rename_ctls_1361t_adc[] = { 1342 "Master Playback Switch", "Master Capture Switch", 1343 "Master Playback Volume", "Master Capture Volume", 1344 "Wave Master Playback Volume", "Master Playback Volume", 1345 "PC Speaker Playback Switch", "PC Speaker Capture Switch", 1346 "PC Speaker Playback Volume", "PC Speaker Capture Volume", 1347 "Phone Playback Switch", "Phone Capture Switch", 1348 "Phone Playback Volume", "Phone Capture Volume", 1349 "Mic Playback Switch", "Mic Capture Switch", 1350 "Mic Playback Volume", "Mic Capture Volume", 1351 "Line Playback Switch", "Line Capture Switch", 1352 "Line Playback Volume", "Line Capture Volume", 1353 "CD Playback Switch", "CD Capture Switch", 1354 "CD Playback Volume", "CD Capture Volume", 1355 "Aux Playback Switch", "Aux Capture Switch", 1356 "Aux Playback Volume", "Aux Capture Volume", 1357 "Video Playback Switch", "Video Capture Switch", 1358 "Video Playback Volume", "Video Capture Volume", 1359 1360 NULL 1361 }; 1362 788 1363 if (emu->card_capabilities->ac97_chip) { 789 ac97_bus_t*pbus;790 ac97_template_tac97;791 static ac97_bus_ops_tops = {792 0,snd_emu10k1_ac97_write,793 snd_emu10k1_ac97_read,0,01364 struct snd_ac97_bus *pbus; 1365 struct snd_ac97_template ac97; 1366 static struct snd_ac97_bus_ops ops = { 1367 .write = snd_emu10k1_ac97_write, 1368 .read = snd_emu10k1_ac97_read, 794 1369 }; 795 1370 796 1371 if ((err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus)) < 0) 797 return err; 798 1372 return err; 799 1373 pbus->no_vra = 1; /* we don't need VRA */ 1374 800 1375 memset(&ac97, 0, sizeof(ac97)); 801 1376 ac97.private_data = emu; … … 812 1387 if (emu->audigy) { 813 1388 /* set master volume to 0 dB */ 814 snd_ac97_write (emu->ac97, AC97_MASTER, 0x0000);1389 snd_ac97_write_cache(emu->ac97, AC97_MASTER, 0x0000); 815 1390 /* set capture source to mic */ 816 snd_ac97_write(emu->ac97, AC97_REC_SEL, 0x0000); 817 c = audigy_remove_ctls; 1391 snd_ac97_write_cache(emu->ac97, AC97_REC_SEL, 0x0000); 1392 if (emu->card_capabilities->adc_1361t) 1393 c = audigy_remove_ctls_1361t_adc; 1394 else 1395 c = audigy_remove_ctls; 818 1396 } else { 1397 /* 1398 * Credits for cards based on STAC9758: 1399 * James Courtier-Dutton <James@superbug.demon.co.uk> 1400 * Voluspa <voluspa@comhem.se> 1401 */ 819 1402 if (emu->ac97->id == AC97_ID_STAC9758) { 820 1403 emu->rear_ac97 = 1; … … 822 1405 } 823 1406 /* remove unused AC97 controls */ 824 snd_ac97_write (emu->ac97, AC97_SURROUND_MASTER, 0x0202);825 snd_ac97_write (emu->ac97, AC97_CENTER_LFE_MASTER, 0x0202);1407 snd_ac97_write_cache(emu->ac97, AC97_SURROUND_MASTER, 0x0202); 1408 snd_ac97_write_cache(emu->ac97, AC97_CENTER_LFE_MASTER, 0x0202); 826 1409 c = emu10k1_remove_ctls; 827 1410 } … … 839 1422 840 1423 if (emu->audigy) 841 c = audigy_rename_ctls; 1424 if (emu->card_capabilities->adc_1361t) 1425 c = audigy_rename_ctls_1361t_adc; 1426 else 1427 c = audigy_rename_ctls; 842 1428 else 843 1429 c = emu10k1_rename_ctls; … … 845 1431 rename_ctl(card, c[0], c[1]); 846 1432 1433 if (emu->card_capabilities->subsystem == 0x20071102) { /* Audigy 4 Pro */ 1434 rename_ctl(card, "Line2 Capture Volume", "Line1/Mic Capture Volume"); 1435 rename_ctl(card, "Analog Mix Capture Volume", "Line2 Capture Volume"); 1436 rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume"); 1437 rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume"); 1438 remove_ctl(card, "Headphone Playback Switch"); 1439 remove_ctl(card, "Headphone Playback Volume"); 1440 remove_ctl(card, "3D Control - Center"); 1441 remove_ctl(card, "3D Control - Depth"); 1442 remove_ctl(card, "3D Control - Switch"); 1443 } 847 1444 if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL) 848 1445 return -ENOMEM; … … 937 1534 } 938 1535 939 if (emu->audigy) { 1536 if ( emu->card_capabilities->emu1010) { 1537 ; /* Disable the snd_audigy_spdif_shared_spdif */ 1538 } else if (emu->audigy) { 940 1539 if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL) 941 1540 return -ENOMEM; … … 959 1558 return err; 960 1559 } 961 return 0; 962 } 1560 if ( emu->card_capabilities->emu1010) { 1561 int i; 1562 1563 for (i = 0; i < ARRAY_SIZE(snd_emu1010_output_enum_ctls); i++) { 1564 err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_output_enum_ctls[i], emu)); 1565 if (err < 0) 1566 return err; 1567 } 1568 for (i = 0; i < ARRAY_SIZE(snd_emu1010_input_enum_ctls); i++) { 1569 err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_input_enum_ctls[i], emu)); 1570 if (err < 0) 1571 return err; 1572 } 1573 for (i = 0; i < ARRAY_SIZE(snd_emu1010_adc_pads); i++) { 1574 err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_adc_pads[i], emu)); 1575 if (err < 0) 1576 return err; 1577 } 1578 for (i = 0; i < ARRAY_SIZE(snd_emu1010_dac_pads); i++) { 1579 err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_dac_pads[i], emu)); 1580 if (err < 0) 1581 return err; 1582 } 1583 err = snd_ctl_add(card, snd_ctl_new1(&snd_emu1010_internal_clock, emu)); 1584 if (err < 0) 1585 return err; 1586 } 1587 1588 return 0; 1589 } -
GPL/trunk/alsa-kernel/pci/emu10k1/emumpu401.c
r34 r84 31 31 static inline unsigned char mpu401_read(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mpu, int idx) 32 32 { 33 34 35 36 33 if (emu->audigy) 34 return (unsigned char)snd_emu10k1_ptr_read(emu, mpu->port + idx, 0); 35 else 36 return inb(emu->port + mpu->port + idx); 37 37 } 38 38 39 39 static inline void mpu401_write(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mpu, int data, int idx) 40 40 { 41 42 43 44 41 if (emu->audigy) 42 snd_emu10k1_ptr_write(emu, mpu->port + idx, 0, data); 43 else 44 outb(data, emu->port + mpu->port + idx); 45 45 } 46 46 … … 59 59 static void mpu401_clear_rx(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mpu) 60 60 { 61 62 63 61 int timeout = 100000; 62 for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) 63 mpu401_read_data(emu, mpu); 64 64 #ifdef CONFIG_SND_DEBUG 65 66 65 if (timeout <= 0) 66 snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); 67 67 #endif 68 68 } … … 70 70 /* 71 71 72 72 */ 73 73 74 74 static void do_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, unsigned int status) 75 75 { 76 unsigned char byte; 77 78 if (midi->rmidi == NULL) { 79 snd_emu10k1_intr_disable(emu, midi->tx_enable | midi->rx_enable); 80 return; 81 } 82 83 spin_lock(&midi->input_lock); 84 if ((status & midi->ipr_rx) && mpu401_input_avail(emu, midi)) { 85 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 86 mpu401_clear_rx(emu, midi); 87 } else { 88 byte = mpu401_read_data(emu, midi); 89 spin_unlock(&midi->input_lock); 90 if (midi->substream_input) 91 snd_rawmidi_receive(midi->substream_input, &byte, 1); 92 spin_lock(&midi->input_lock); 93 } 94 } 95 spin_unlock(&midi->input_lock); 96 97 spin_lock(&midi->output_lock); 98 if ((status & midi->ipr_tx) && mpu401_output_ready(emu, midi)) { 99 if (midi->substream_output && 100 snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) { 101 mpu401_write_data(emu, midi, byte); 102 } else { 103 snd_emu10k1_intr_disable(emu, midi->tx_enable); 104 } 105 } 106 spin_unlock(&midi->output_lock); 76 unsigned char byte; 77 78 if (midi->rmidi == NULL) { 79 snd_emu10k1_intr_disable(emu, midi->tx_enable | midi->rx_enable); 80 return; 81 } 82 83 spin_lock(&midi->input_lock); 84 if ((status & midi->ipr_rx) && mpu401_input_avail(emu, midi)) { 85 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 86 mpu401_clear_rx(emu, midi); 87 } else { 88 byte = mpu401_read_data(emu, midi); 89 if (midi->substream_input) 90 snd_rawmidi_receive(midi->substream_input, &byte, 1); 91 } 92 } 93 spin_unlock(&midi->input_lock); 94 95 spin_lock(&midi->output_lock); 96 if ((status & midi->ipr_tx) && mpu401_output_ready(emu, midi)) { 97 if (midi->substream_output && 98 snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) { 99 mpu401_write_data(emu, midi, byte); 100 } else { 101 snd_emu10k1_intr_disable(emu, midi->tx_enable); 102 } 103 } 104 spin_unlock(&midi->output_lock); 107 105 } 108 106 109 107 static void snd_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, unsigned int status) 110 108 { 111 109 do_emu10k1_midi_interrupt(emu, &emu->midi, status); 112 110 } 113 111 114 112 static void snd_emu10k1_midi_interrupt2(struct snd_emu10k1 *emu, unsigned int status) 115 113 { 116 do_emu10k1_midi_interrupt(emu, &emu->midi2, status); 117 } 118 119 static void snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned char cmd, int ack) 120 { 121 unsigned long flags; 122 int timeout, ok; 123 124 spin_lock_irqsave(&midi->input_lock, flags); 125 mpu401_write_data(emu, midi, 0x00); 126 /* mpu401_clear_rx(emu, midi); */ 127 128 mpu401_write_cmd(emu, midi, cmd); 129 if (ack) { 130 ok = 0; 131 timeout = 10000; 132 while (!ok && timeout-- > 0) { 133 if (mpu401_input_avail(emu, midi)) { 134 if (mpu401_read_data(emu, midi) == MPU401_ACK) 135 ok = 1; 136 } 137 } 138 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) 139 ok = 1; 140 } else { 141 ok = 1; 142 } 143 spin_unlock_irqrestore(&midi->input_lock, flags); 144 if (!ok) 145 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 146 cmd, emu->port, 147 mpu401_read_stat(emu, midi), 148 mpu401_read_data(emu, midi)); 149 } 150 151 static int snd_emu10k1_midi_input_open(snd_rawmidi_substream_t * substream) 152 { 153 struct snd_emu10k1 *emu; 154 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 155 unsigned long flags; 156 157 emu = midi->emu; 158 snd_assert(emu, return -ENXIO); 159 spin_lock_irqsave(&midi->open_lock, flags); 160 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; 161 midi->substream_input = substream; 162 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 163 spin_unlock_irqrestore(&midi->open_lock, flags); 164 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1); 165 snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 166 } else { 167 spin_unlock_irqrestore(&midi->open_lock, flags); 168 } 169 return 0; 170 } 171 172 static int snd_emu10k1_midi_output_open(snd_rawmidi_substream_t * substream) 173 { 174 struct snd_emu10k1 *emu; 175 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 176 unsigned long flags; 177 178 emu = midi->emu; 179 snd_assert(emu, return -ENXIO); 180 spin_lock_irqsave(&midi->open_lock, flags); 181 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; 182 midi->substream_output = substream; 183 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 184 spin_unlock_irqrestore(&midi->open_lock, flags); 185 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1); 186 snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 187 } else { 188 spin_unlock_irqrestore(&midi->open_lock, flags); 189 } 190 return 0; 191 } 192 193 static int snd_emu10k1_midi_input_close(snd_rawmidi_substream_t * substream) 194 { 195 struct snd_emu10k1 *emu; 196 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 197 unsigned long flags; 198 199 emu = midi->emu; 200 snd_assert(emu, return -ENXIO); 201 spin_lock_irqsave(&midi->open_lock, flags); 202 snd_emu10k1_intr_disable(emu, midi->rx_enable); 203 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; 204 midi->substream_input = NULL; 205 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 206 spin_unlock_irqrestore(&midi->open_lock, flags); 207 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 208 } else { 209 spin_unlock_irqrestore(&midi->open_lock, flags); 210 } 211 return 0; 212 } 213 214 static int snd_emu10k1_midi_output_close(snd_rawmidi_substream_t * substream) 215 { 216 struct snd_emu10k1 *emu; 217 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 218 unsigned long flags; 219 220 emu = midi->emu; 221 snd_assert(emu, return -ENXIO); 222 spin_lock_irqsave(&midi->open_lock, flags); 223 snd_emu10k1_intr_disable(emu, midi->tx_enable); 224 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; 225 midi->substream_output = NULL; 226 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 227 spin_unlock_irqrestore(&midi->open_lock, flags); 228 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 229 } else { 230 spin_unlock_irqrestore(&midi->open_lock, flags); 231 } 232 return 0; 233 } 234 235 static void snd_emu10k1_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) 236 { 237 struct snd_emu10k1 *emu; 238 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 239 emu = midi->emu; 240 snd_assert(emu, return); 241 242 if (up) 243 snd_emu10k1_intr_enable(emu, midi->rx_enable); 244 else 245 snd_emu10k1_intr_disable(emu, midi->rx_enable); 246 } 247 248 static void snd_emu10k1_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) 249 { 250 struct snd_emu10k1 *emu; 251 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 252 unsigned long flags; 253 254 emu = midi->emu; 255 snd_assert(emu, return); 256 257 if (up) { 258 int max = 4; 259 unsigned char byte; 260 261 /* try to send some amount of bytes here before interrupts */ 262 spin_lock_irqsave(&midi->output_lock, flags); 263 while (max > 0) { 264 if (mpu401_output_ready(emu, midi)) { 265 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT) || 266 snd_rawmidi_transmit(substream, &byte, 1) != 1) { 267 /* no more data */ 268 spin_unlock_irqrestore(&midi->output_lock, flags); 269 return; 270 } 271 mpu401_write_data(emu, midi, byte); 272 max--; 273 } else { 274 break; 275 } 276 } 277 spin_unlock_irqrestore(&midi->output_lock, flags); 278 snd_emu10k1_intr_enable(emu, midi->tx_enable); 279 } else { 280 snd_emu10k1_intr_disable(emu, midi->tx_enable); 281 } 114 do_emu10k1_midi_interrupt(emu, &emu->midi2, status); 115 } 116 117 static int snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned char cmd, int ack) 118 { 119 unsigned long flags; 120 int timeout, ok; 121 122 spin_lock_irqsave(&midi->input_lock, flags); 123 mpu401_write_data(emu, midi, 0x00); 124 /* mpu401_clear_rx(emu, midi); */ 125 126 mpu401_write_cmd(emu, midi, cmd); 127 if (ack) { 128 ok = 0; 129 timeout = 10000; 130 while (!ok && timeout-- > 0) { 131 if (mpu401_input_avail(emu, midi)) { 132 if (mpu401_read_data(emu, midi) == MPU401_ACK) 133 ok = 1; 134 } 135 } 136 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) 137 ok = 1; 138 } else { 139 ok = 1; 140 } 141 spin_unlock_irqrestore(&midi->input_lock, flags); 142 if (!ok) { 143 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 144 cmd, emu->port, 145 mpu401_read_stat(emu, midi), 146 mpu401_read_data(emu, midi)); 147 return 1; 148 } 149 return 0; 150 } 151 152 static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream) 153 { 154 struct snd_emu10k1 *emu; 155 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 156 unsigned long flags; 157 158 emu = midi->emu; 159 snd_assert(emu, return -ENXIO); 160 spin_lock_irqsave(&midi->open_lock, flags); 161 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; 162 midi->substream_input = substream; 163 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 164 spin_unlock_irqrestore(&midi->open_lock, flags); 165 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) 166 goto error_out; 167 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) 168 goto error_out; 169 } else { 170 spin_unlock_irqrestore(&midi->open_lock, flags); 171 } 172 return 0; 173 174 error_out: 175 return -EIO; 176 } 177 178 static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream) 179 { 180 struct snd_emu10k1 *emu; 181 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 182 unsigned long flags; 183 184 emu = midi->emu; 185 snd_assert(emu, return -ENXIO); 186 spin_lock_irqsave(&midi->open_lock, flags); 187 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; 188 midi->substream_output = substream; 189 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 190 spin_unlock_irqrestore(&midi->open_lock, flags); 191 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) 192 goto error_out; 193 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) 194 goto error_out; 195 } else { 196 spin_unlock_irqrestore(&midi->open_lock, flags); 197 } 198 return 0; 199 200 error_out: 201 return -EIO; 202 } 203 204 static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream) 205 { 206 struct snd_emu10k1 *emu; 207 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 208 unsigned long flags; 209 int err = 0; 210 211 emu = midi->emu; 212 snd_assert(emu, return -ENXIO); 213 spin_lock_irqsave(&midi->open_lock, flags); 214 snd_emu10k1_intr_disable(emu, midi->rx_enable); 215 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; 216 midi->substream_input = NULL; 217 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 218 spin_unlock_irqrestore(&midi->open_lock, flags); 219 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 220 } else { 221 spin_unlock_irqrestore(&midi->open_lock, flags); 222 } 223 return err; 224 } 225 226 static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream) 227 { 228 struct snd_emu10k1 *emu; 229 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 230 unsigned long flags; 231 int err = 0; 232 233 emu = midi->emu; 234 snd_assert(emu, return -ENXIO); 235 spin_lock_irqsave(&midi->open_lock, flags); 236 snd_emu10k1_intr_disable(emu, midi->tx_enable); 237 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; 238 midi->substream_output = NULL; 239 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 240 spin_unlock_irqrestore(&midi->open_lock, flags); 241 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 242 } else { 243 spin_unlock_irqrestore(&midi->open_lock, flags); 244 } 245 return err; 246 } 247 248 static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 249 { 250 struct snd_emu10k1 *emu; 251 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 252 emu = midi->emu; 253 snd_assert(emu, return); 254 255 if (up) 256 snd_emu10k1_intr_enable(emu, midi->rx_enable); 257 else 258 snd_emu10k1_intr_disable(emu, midi->rx_enable); 259 } 260 261 static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) 262 { 263 struct snd_emu10k1 *emu; 264 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 265 unsigned long flags; 266 267 emu = midi->emu; 268 snd_assert(emu, return); 269 270 if (up) { 271 int max = 4; 272 unsigned char byte; 273 274 /* try to send some amount of bytes here before interrupts */ 275 spin_lock_irqsave(&midi->output_lock, flags); 276 while (max > 0) { 277 if (mpu401_output_ready(emu, midi)) { 278 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT) || 279 snd_rawmidi_transmit(substream, &byte, 1) != 1) { 280 /* no more data */ 281 spin_unlock_irqrestore(&midi->output_lock, flags); 282 return; 283 } 284 mpu401_write_data(emu, midi, byte); 285 max--; 286 } else { 287 break; 288 } 289 } 290 spin_unlock_irqrestore(&midi->output_lock, flags); 291 snd_emu10k1_intr_enable(emu, midi->tx_enable); 292 } else { 293 snd_emu10k1_intr_disable(emu, midi->tx_enable); 294 } 282 295 } 283 296 284 297 /* 285 298 286 */ 287 288 #ifdef TARGET_OS2 289 static snd_rawmidi_ops_t snd_emu10k1_midi_output = 290 { 291 snd_emu10k1_midi_output_open, 292 snd_emu10k1_midi_output_close, 293 snd_emu10k1_midi_output_trigger,0 299 */ 300 301 static struct snd_rawmidi_ops snd_emu10k1_midi_output = 302 { 303 .open = snd_emu10k1_midi_output_open, 304 .close = snd_emu10k1_midi_output_close, 305 .trigger = snd_emu10k1_midi_output_trigger, 294 306 }; 295 307 296 static s nd_rawmidi_ops_tsnd_emu10k1_midi_input =297 { 298 snd_emu10k1_midi_input_open,299 snd_emu10k1_midi_input_close,300 snd_emu10k1_midi_input_trigger,0 308 static struct snd_rawmidi_ops snd_emu10k1_midi_input = 309 { 310 .open = snd_emu10k1_midi_input_open, 311 .close = snd_emu10k1_midi_input_close, 312 .trigger = snd_emu10k1_midi_input_trigger, 301 313 }; 302 #else 303 static snd_rawmidi_ops_t snd_emu10k1_midi_output = 304 { 305 open: snd_emu10k1_midi_output_open, 306 close: snd_emu10k1_midi_output_close, 307 trigger: snd_emu10k1_midi_output_trigger, 308 }; 309 310 static snd_rawmidi_ops_t snd_emu10k1_midi_input = 311 { 312 open: snd_emu10k1_midi_input_open, 313 close: snd_emu10k1_midi_input_close, 314 trigger: snd_emu10k1_midi_input_trigger, 315 }; 316 #endif 317 318 static void snd_emu10k1_midi_free(snd_rawmidi_t *rmidi) 319 { 320 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)rmidi->private_data; 321 midi->interrupt = NULL; 322 midi->rmidi = NULL; 314 315 static void snd_emu10k1_midi_free(struct snd_rawmidi *rmidi) 316 { 317 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)rmidi->private_data; 318 midi->interrupt = NULL; 319 midi->rmidi = NULL; 323 320 } 324 321 325 322 static int __devinit emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, char *name) 326 323 { 327 snd_rawmidi_t*rmidi;328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 324 struct snd_rawmidi *rmidi; 325 int err; 326 327 if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) 328 return err; 329 midi->emu = emu; 330 spin_lock_init(&midi->open_lock); 331 spin_lock_init(&midi->input_lock); 332 spin_lock_init(&midi->output_lock); 333 strcpy(rmidi->name, name); 334 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_emu10k1_midi_output); 335 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_emu10k1_midi_input); 336 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | 337 SNDRV_RAWMIDI_INFO_INPUT | 338 SNDRV_RAWMIDI_INFO_DUPLEX; 339 rmidi->private_data = midi; 340 rmidi->private_free = snd_emu10k1_midi_free; 341 midi->rmidi = rmidi; 342 return 0; 346 343 } 347 344 348 345 int __devinit snd_emu10k1_midi(struct snd_emu10k1 *emu) 349 346 { 350 351 352 353 354 355 356 357 358 359 360 361 362 347 struct snd_emu10k1_midi *midi = &emu->midi; 348 int err; 349 350 if ((err = emu10k1_midi_init(emu, midi, 0, "EMU10K1 MPU-401 (UART)")) < 0) 351 return err; 352 353 midi->tx_enable = INTE_MIDITXENABLE; 354 midi->rx_enable = INTE_MIDIRXENABLE; 355 midi->port = MUDATA; 356 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; 357 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; 358 midi->interrupt = snd_emu10k1_midi_interrupt; 359 return 0; 363 360 } 364 361 365 362 int __devinit snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu) 366 363 { 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 } 364 struct snd_emu10k1_midi *midi; 365 int err; 366 367 midi = &emu->midi; 368 if ((err = emu10k1_midi_init(emu, midi, 0, "Audigy MPU-401 (UART)")) < 0) 369 return err; 370 371 midi->tx_enable = INTE_MIDITXENABLE; 372 midi->rx_enable = INTE_MIDIRXENABLE; 373 midi->port = A_MUDATA1; 374 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; 375 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; 376 midi->interrupt = snd_emu10k1_midi_interrupt; 377 378 midi = &emu->midi2; 379 if ((err = emu10k1_midi_init(emu, midi, 1, "Audigy MPU-401 #2")) < 0) 380 return err; 381 382 midi->tx_enable = INTE_A_MIDITXENABLE2; 383 midi->rx_enable = INTE_A_MIDIRXENABLE2; 384 midi->port = A_MUDATA2; 385 midi->ipr_tx = IPR_A_MIDITRANSBUFEMPTY2; 386 midi->ipr_rx = IPR_A_MIDIRECVBUFEMPTY2; 387 midi->interrupt = snd_emu10k1_midi_interrupt2; 388 return 0; 389 } -
GPL/trunk/alsa-kernel/pci/emu10k1/emupcm.c
r34 r84 3 3 * Creative Labs, Inc. 4 4 * Routines for control of EMU10K1 chips / PCM routines 5 * Multichannel PCM support Copyright (c) Lee Revell <rlrevell@joe-job.com> 5 6 * 6 7 * BUGS: … … 26 27 */ 27 28 28 #define __NO_VERSION__29 29 #include <sound/driver.h> 30 #include <linux/pci.h> 31 #include <linux/delay.h> 30 32 #include <linux/slab.h> 31 33 #include <linux/time.h> 34 #include <linux/init.h> 32 35 #include <sound/core.h> 33 36 #include <sound/emu10k1.h> 34 37 35 static inline snd_ctl_elem_id_t *snd_ctl_build_ioff(snd_ctl_elem_id_t *dst_id, 36 snd_kcontrol_t *src_kctl, 37 unsigned int offset) 38 { 39 *dst_id = src_kctl->id; 40 dst_id->index += offset; 41 dst_id->numid += offset; 42 return dst_id; 43 } 44 45 static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *voice) 46 { 47 struct snd_emu10k1_pcm *epcm; 48 49 if ((epcm = voice->epcm) == NULL) 50 return; 51 if (epcm->substream == NULL) 52 return; 38 static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu, 39 struct snd_emu10k1_voice *voice) 40 { 41 struct snd_emu10k1_pcm *epcm; 42 43 if ((epcm = voice->epcm) == NULL) 44 return; 45 if (epcm->substream == NULL) 46 return; 53 47 #if 0 54 55 56 57 48 printk("IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 49 epcm->substream->runtime->hw->pointer(emu, epcm->substream), 50 snd_pcm_lib_period_bytes(epcm->substream), 51 snd_pcm_lib_buffer_bytes(epcm->substream)); 58 52 #endif 59 snd_pcm_period_elapsed(epcm->substream); 60 } 61 62 static void snd_emu10k1_pcm_ac97adc_interrupt(struct snd_emu10k1 *emu, unsigned int status) 53 snd_pcm_period_elapsed(epcm->substream); 54 } 55 56 static void snd_emu10k1_pcm_ac97adc_interrupt(struct snd_emu10k1 *emu, 57 unsigned int status) 63 58 { 64 59 #if 0 65 66 67 68 60 if (status & IPR_ADCBUFHALFFULL) { 61 if (emu->pcm_capture_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) 62 return; 63 } 69 64 #endif 70 snd_pcm_period_elapsed(emu->pcm_capture_substream); 71 } 72 73 static void snd_emu10k1_pcm_ac97mic_interrupt(struct snd_emu10k1 *emu, unsigned int status) 65 snd_pcm_period_elapsed(emu->pcm_capture_substream); 66 } 67 68 static void snd_emu10k1_pcm_ac97mic_interrupt(struct snd_emu10k1 *emu, 69 unsigned int status) 74 70 { 75 71 #if 0 76 77 78 79 72 if (status & IPR_MICBUFHALFFULL) { 73 if (emu->pcm_capture_mic_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) 74 return; 75 } 80 76 #endif 81 snd_pcm_period_elapsed(emu->pcm_capture_mic_substream); 82 } 83 84 static void snd_emu10k1_pcm_efx_interrupt(struct snd_emu10k1 *emu, unsigned int status) 77 snd_pcm_period_elapsed(emu->pcm_capture_mic_substream); 78 } 79 80 static void snd_emu10k1_pcm_efx_interrupt(struct snd_emu10k1 *emu, 81 unsigned int status) 85 82 { 86 83 #if 0 87 88 89 90 84 if (status & IPR_EFXBUFHALFFULL) { 85 if (emu->pcm_capture_efx_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) 86 return; 87 } 91 88 #endif 92 93 } 94 95 static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(s nd_pcm_substream_t *substream)96 { 97 98 snd_pcm_runtime_t*runtime = substream->runtime;99 100 101 102 103 104 105 106 107 108 109 89 snd_pcm_period_elapsed(emu->pcm_capture_efx_substream); 90 } 91 92 static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(struct snd_pcm_substream *substream) 93 { 94 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 95 struct snd_pcm_runtime *runtime = substream->runtime; 96 struct snd_emu10k1_pcm *epcm = runtime->private_data; 97 unsigned int ptr; 98 99 if (!epcm->running) 100 return 0; 101 ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff; 102 ptr += runtime->buffer_size; 103 ptr -= epcm->ccca_start_addr; 104 ptr %= runtime->buffer_size; 105 106 return ptr; 110 107 } 111 108 112 109 static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voices) 113 110 { 114 int err, i; 115 116 if (epcm->voices[1] != NULL && voices < 2) { 117 snd_emu10k1_voice_free(epcm->emu, epcm->voices[1]); 118 epcm->voices[1] = NULL; 119 } 120 for (i = 0; i < voices; i++) { 121 if (epcm->voices[i] == NULL) 122 break; 123 } 124 if (i == voices) 125 return 0; /* already allocated */ 126 for (i = 0; i < ARRAY_SIZE(epcm->voices); i++) { 127 if (epcm->voices[i]) { 128 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 129 epcm->voices[i] = NULL; 130 } 131 } 132 err = snd_emu10k1_voice_alloc(epcm->emu, 133 epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX, 134 voices, 135 &epcm->voices[0]); 136 if (err < 0) 137 return err; 138 epcm->voices[0]->epcm = epcm; 139 if (voices > 1) { 140 for (i = 1; i < voices; i++) { 141 epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i]; 142 epcm->voices[i]->epcm = epcm; 143 } 144 } 145 if (epcm->extra == NULL) { 146 err = snd_emu10k1_voice_alloc(epcm->emu, 147 epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX, 148 1, 149 &epcm->extra); 150 if (err < 0) { 151 // printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); 152 for (i = 0; i < voices; i++) { 153 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 154 epcm->voices[i] = NULL; 155 } 156 return err; 157 } 158 epcm->extra->epcm = epcm; 159 epcm->extra->interrupt = snd_emu10k1_pcm_interrupt; 160 } 161 return 0; 111 int err, i; 112 113 if (epcm->voices[1] != NULL && voices < 2) { 114 snd_emu10k1_voice_free(epcm->emu, epcm->voices[1]); 115 epcm->voices[1] = NULL; 116 } 117 for (i = 0; i < voices; i++) { 118 if (epcm->voices[i] == NULL) 119 break; 120 } 121 if (i == voices) 122 return 0; /* already allocated */ 123 124 for (i = 0; i < ARRAY_SIZE(epcm->voices); i++) { 125 if (epcm->voices[i]) { 126 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 127 epcm->voices[i] = NULL; 128 } 129 } 130 err = snd_emu10k1_voice_alloc(epcm->emu, 131 epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX, 132 voices, 133 &epcm->voices[0]); 134 135 if (err < 0) 136 return err; 137 epcm->voices[0]->epcm = epcm; 138 if (voices > 1) { 139 for (i = 1; i < voices; i++) { 140 epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i]; 141 epcm->voices[i]->epcm = epcm; 142 } 143 } 144 if (epcm->extra == NULL) { 145 err = snd_emu10k1_voice_alloc(epcm->emu, 146 epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX, 147 1, 148 &epcm->extra); 149 if (err < 0) { 150 /* printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame); */ 151 for (i = 0; i < voices; i++) { 152 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 153 epcm->voices[i] = NULL; 154 } 155 return err; 156 } 157 epcm->extra->epcm = epcm; 158 epcm->extra->interrupt = snd_emu10k1_pcm_interrupt; 159 } 160 return 0; 162 161 } 163 162 164 163 static unsigned int capture_period_sizes[31] = { 165 166 167 168 169 170 171 172 164 384, 448, 512, 640, 165 384*2, 448*2, 512*2, 640*2, 166 384*4, 448*4, 512*4, 640*4, 167 384*8, 448*8, 512*8, 640*8, 168 384*16, 448*16, 512*16, 640*16, 169 384*32, 448*32, 512*32, 640*32, 170 384*64, 448*64, 512*64, 640*64, 171 384*128,448*128,512*128 173 172 }; 174 173 175 static s nd_pcm_hw_constraint_list_t hw_constraints_capture_period_sizes = {176 177 178 174 static struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes = { 175 .count = 31, 176 .list = capture_period_sizes, 177 .mask = 0 179 178 }; 180 179 181 180 static unsigned int capture_rates[8] = { 182 181 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 183 182 }; 184 183 185 static s nd_pcm_hw_constraint_list_t hw_constraints_capture_rates = {186 187 188 184 static struct snd_pcm_hw_constraint_list hw_constraints_capture_rates = { 185 .count = 8, 186 .list = capture_rates, 187 .mask = 0 189 188 }; 190 189 191 190 static unsigned int snd_emu10k1_capture_rate_reg(unsigned int rate) 192 191 { 193 194 195 196 197 198 199 200 201 202 203 204 205 192 switch (rate) { 193 case 8000: return ADCCR_SAMPLERATE_8; 194 case 11025: return ADCCR_SAMPLERATE_11; 195 case 16000: return ADCCR_SAMPLERATE_16; 196 case 22050: return ADCCR_SAMPLERATE_22; 197 case 24000: return ADCCR_SAMPLERATE_24; 198 case 32000: return ADCCR_SAMPLERATE_32; 199 case 44100: return ADCCR_SAMPLERATE_44; 200 case 48000: return ADCCR_SAMPLERATE_48; 201 default: 202 snd_BUG(); 203 return ADCCR_SAMPLERATE_8; 204 } 206 205 } 207 206 208 207 static unsigned int snd_emu10k1_audigy_capture_rate_reg(unsigned int rate) 209 208 { 210 211 212 213 214 215 216 217 218 219 220 221 222 223 209 switch (rate) { 210 case 8000: return A_ADCCR_SAMPLERATE_8; 211 case 11025: return A_ADCCR_SAMPLERATE_11; 212 case 12000: return A_ADCCR_SAMPLERATE_12; /* really supported? */ 213 case 16000: return ADCCR_SAMPLERATE_16; 214 case 22050: return ADCCR_SAMPLERATE_22; 215 case 24000: return ADCCR_SAMPLERATE_24; 216 case 32000: return ADCCR_SAMPLERATE_32; 217 case 44100: return ADCCR_SAMPLERATE_44; 218 case 48000: return ADCCR_SAMPLERATE_48; 219 default: 220 snd_BUG(); 221 return A_ADCCR_SAMPLERATE_8; 222 } 224 223 } 225 224 226 225 static unsigned int emu10k1_calc_pitch_target(unsigned int rate) 227 226 { 228 229 230 231 232 227 unsigned int pitch_target; 228 229 pitch_target = (rate << 8) / 375; 230 pitch_target = (pitch_target >> 1) + (pitch_target & 1); 231 return pitch_target; 233 232 } 234 233 … … 242 241 static unsigned int emu10k1_select_interprom(unsigned int pitch_target) 243 242 { 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 else 259 243 if (pitch_target == PITCH_48000) 244 return CCCA_INTERPROM_0; 245 else if (pitch_target < PITCH_48000) 246 return CCCA_INTERPROM_1; 247 else if (pitch_target >= PITCH_96000) 248 return CCCA_INTERPROM_0; 249 else if (pitch_target >= PITCH_85000) 250 return CCCA_INTERPROM_6; 251 else if (pitch_target >= PITCH_80726) 252 return CCCA_INTERPROM_5; 253 else if (pitch_target >= PITCH_67882) 254 return CCCA_INTERPROM_4; 255 else if (pitch_target >= PITCH_57081) 256 return CCCA_INTERPROM_3; 257 else 258 return CCCA_INTERPROM_2; 260 259 } 261 260 262 261 /* 263 * calculate cache invalidate size 262 * calculate cache invalidate size 264 263 * 265 264 * stereo: channel is stereo … … 268 267 * returns: cache invalidate size in samples 269 268 */ 270 static in t inlineemu10k1_ccis(int stereo, int w_16)271 { 272 273 274 275 276 269 static inline int emu10k1_ccis(int stereo, int w_16) 270 { 271 if (w_16) { 272 return stereo ? 24 : 26; 273 } else { 274 return stereo ? 24*2 : 26*2; 275 } 277 276 } 278 277 279 278 static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu, 280 int master, int extra, 281 struct snd_emu10k1_voice *evoice, 282 unsigned int start_addr, 283 unsigned int end_addr, 284 struct snd_emu10k1_pcm_mixer *mix) 285 { 286 snd_pcm_substream_t *substream = evoice->epcm->substream; 287 snd_pcm_runtime_t *runtime = substream->runtime; 288 unsigned int silent_page, tmp; 289 int voice, stereo, w_16; 290 unsigned char attn, send_amount[8]; 291 unsigned char send_routing[8]; 292 unsigned long flags; 293 unsigned int pitch_target; 294 unsigned int ccis; 295 296 voice = evoice->number; 297 stereo = runtime->channels == 2; 298 w_16 = snd_pcm_format_width(runtime->format) == 16; 299 300 if (!extra && stereo) { 301 start_addr >>= 1; 302 end_addr >>= 1; 303 } 304 if (w_16) { 305 start_addr >>= 1; 306 end_addr >>= 1; 307 } 308 309 spin_lock_irqsave(&emu->reg_lock, flags); 310 311 /* volume parameters */ 312 if (extra) { 313 attn = 0; 314 memset(send_routing, 0, sizeof(send_routing)); 315 send_routing[0] = 0; 316 send_routing[1] = 1; 317 send_routing[2] = 2; 318 send_routing[3] = 3; 319 memset(send_amount, 0, sizeof(send_amount)); 320 } else { 321 /* mono, left, right (master voice = left) */ 322 tmp = stereo ? (master ? 1 : 2) : 0; 323 memcpy(send_routing, &mix->send_routing[tmp][0], 8); 324 memcpy(send_amount, &mix->send_volume[tmp][0], 8); 325 } 326 327 ccis = emu10k1_ccis(stereo, w_16); 328 329 if (master) { 330 evoice->epcm->ccca_start_addr = start_addr + ccis; 331 if (extra) { 332 start_addr += ccis; 333 end_addr += ccis; 334 } 335 if (stereo && !extra) { 336 snd_emu10k1_ptr_write(emu, CPF, voice, CPF_STEREO_MASK); 337 snd_emu10k1_ptr_write(emu, CPF, (voice + 1), CPF_STEREO_MASK); 338 } else { 339 snd_emu10k1_ptr_write(emu, CPF, voice, 0); 340 } 341 } 342 343 // setup routing 344 if (emu->audigy) { 345 snd_emu10k1_ptr_write(emu, A_FXRT1, voice, 346 snd_emu10k1_compose_audigy_fxrt1(send_routing)); 347 snd_emu10k1_ptr_write(emu, A_FXRT2, voice, 348 snd_emu10k1_compose_audigy_fxrt2(send_routing)); 349 snd_emu10k1_ptr_write(emu, A_SENDAMOUNTS, voice, 350 ((unsigned int)send_amount[4] << 24) | 351 ((unsigned int)send_amount[5] << 16) | 352 ((unsigned int)send_amount[6] << 8) | 353 (unsigned int)send_amount[7]); 354 } else 355 snd_emu10k1_ptr_write(emu, FXRT, voice, 356 snd_emu10k1_compose_send_routing(send_routing)); 357 // Stop CA 358 // Assumption that PT is already 0 so no harm overwriting 359 snd_emu10k1_ptr_write(emu, PTRX, voice, (send_amount[0] << 8) | send_amount[1]); 360 snd_emu10k1_ptr_write(emu, DSL, voice, end_addr | (send_amount[3] << 24)); 361 snd_emu10k1_ptr_write(emu, PSST, voice, start_addr | (send_amount[2] << 24)); 362 pitch_target = emu10k1_calc_pitch_target(runtime->rate); 363 if (extra) 364 snd_emu10k1_ptr_write(emu, CCCA, voice, start_addr | 365 emu10k1_select_interprom(pitch_target) | 366 (w_16 ? 0 : CCCA_8BITSELECT)); 367 else 368 snd_emu10k1_ptr_write(emu, CCCA, voice, (start_addr + ccis) | 369 emu10k1_select_interprom(pitch_target) | 370 (w_16 ? 0 : CCCA_8BITSELECT)); 371 // Clear filter delay memory 372 snd_emu10k1_ptr_write(emu, Z1, voice, 0); 373 snd_emu10k1_ptr_write(emu, Z2, voice, 0); 374 // invalidate maps 375 silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK; 376 snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page); 377 snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page); 378 // modulation envelope 379 snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); 380 snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); 381 snd_emu10k1_ptr_write(emu, ATKHLDM, voice, 0); 382 snd_emu10k1_ptr_write(emu, DCYSUSM, voice, 0x007f); 383 snd_emu10k1_ptr_write(emu, LFOVAL1, voice, 0x8000); 384 snd_emu10k1_ptr_write(emu, LFOVAL2, voice, 0x8000); 385 snd_emu10k1_ptr_write(emu, FMMOD, voice, 0); 386 snd_emu10k1_ptr_write(emu, TREMFRQ, voice, 0); 387 snd_emu10k1_ptr_write(emu, FM2FRQ2, voice, 0); 388 snd_emu10k1_ptr_write(emu, ENVVAL, voice, 0x8000); 389 // volume envelope 390 snd_emu10k1_ptr_write(emu, ATKHLDV, voice, 0x7f7f); 391 snd_emu10k1_ptr_write(emu, ENVVOL, voice, 0x0000); 392 // filter envelope 393 snd_emu10k1_ptr_write(emu, PEFE_FILTERAMOUNT, voice, 0x7f); 394 // pitch envelope 395 snd_emu10k1_ptr_write(emu, PEFE_PITCHAMOUNT, voice, 0); 396 397 spin_unlock_irqrestore(&emu->reg_lock, flags); 398 } 399 400 static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, 401 snd_pcm_hw_params_t * hw_params) 402 { 403 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 404 snd_pcm_runtime_t *runtime = substream->runtime; 405 struct snd_emu10k1_pcm *epcm = runtime->private_data; 406 int err; 407 408 if ((err = snd_emu10k1_pcm_channel_alloc(epcm, params_channels(hw_params))) < 0) 409 return err; 410 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) 411 return err; 412 if (err > 0) { /* change */ 413 snd_util_memblk_t *memblk; 414 if (epcm->memblk != NULL) 415 snd_emu10k1_free_pages(emu, epcm->memblk); 416 memblk = snd_emu10k1_alloc_pages(emu, substream); 417 if ((epcm->memblk = memblk) == NULL || ((struct snd_emu10k1_memblk *)memblk)->mapped_page < 0) { 418 epcm->start_addr = 0; 419 return -ENOMEM; 420 } 421 epcm->start_addr = ((struct snd_emu10k1_memblk *)memblk)->mapped_page << PAGE_SHIFT; 422 } 423 return 0; 424 } 425 426 static int snd_emu10k1_playback_hw_free(snd_pcm_substream_t * substream) 427 { 428 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 429 snd_pcm_runtime_t *runtime = substream->runtime; 430 struct snd_emu10k1_pcm *epcm; 431 432 if (runtime->private_data == NULL) 433 return 0; 434 epcm = runtime->private_data; 435 if (epcm->extra) { 436 snd_emu10k1_voice_free(epcm->emu, epcm->extra); 437 epcm->extra = NULL; 438 } 439 if (epcm->voices[1]) { 440 snd_emu10k1_voice_free(epcm->emu, epcm->voices[1]); 441 epcm->voices[1] = NULL; 442 } 443 if (epcm->voices[0]) { 444 snd_emu10k1_voice_free(epcm->emu, epcm->voices[0]); 445 epcm->voices[0] = NULL; 446 } 447 if (epcm->memblk) { 448 snd_emu10k1_free_pages(emu, epcm->memblk); 449 epcm->memblk = NULL; 450 epcm->start_addr = 0; 451 } 452 snd_pcm_lib_free_pages(substream); 453 return 0; 454 } 455 456 static int snd_emu10k1_efx_playback_hw_free(snd_pcm_substream_t * substream) 457 { 458 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 459 snd_pcm_runtime_t *runtime = substream->runtime; 460 struct snd_emu10k1_pcm *epcm; 461 int i; 462 463 if (runtime->private_data == NULL) 464 return 0; 465 epcm = runtime->private_data; 466 if (epcm->extra) { 467 snd_emu10k1_voice_free(epcm->emu, epcm->extra); 468 epcm->extra = NULL; 469 } 470 for (i=0; i < NUM_EFX_PLAYBACK; i++) { 471 if (epcm->voices[i]) { 472 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 473 epcm->voices[i] = NULL; 474 } 475 } 476 if (epcm->memblk) { 477 snd_emu10k1_free_pages(emu, epcm->memblk); 478 epcm->memblk = NULL; 479 epcm->start_addr = 0; 480 } 481 snd_pcm_lib_free_pages(substream); 482 return 0; 483 } 484 485 static int snd_emu10k1_playback_prepare(snd_pcm_substream_t * substream) 486 { 487 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 488 snd_pcm_runtime_t *runtime = substream->runtime; 489 struct snd_emu10k1_pcm *epcm = runtime->private_data; 490 unsigned int start_addr, end_addr; 491 492 start_addr = epcm->start_addr; 493 end_addr = snd_pcm_lib_period_bytes(substream); 494 if (runtime->channels == 2) { 495 start_addr >>= 1; 496 end_addr >>= 1; 497 } 498 end_addr += start_addr; 499 snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra, 500 start_addr, end_addr, NULL); 501 start_addr = epcm->start_addr; 502 end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream); 503 snd_emu10k1_pcm_init_voice(emu, 1, 0, epcm->voices[0], 504 start_addr, end_addr, 505 &emu->pcm_mixer[substream->number]); 506 if (epcm->voices[1]) 507 snd_emu10k1_pcm_init_voice(emu, 0, 0, epcm->voices[1], 508 start_addr, end_addr, 509 &emu->pcm_mixer[substream->number]); 510 return 0; 511 } 512 513 static int snd_emu10k1_efx_playback_prepare(snd_pcm_substream_t * substream) 514 { 515 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 516 snd_pcm_runtime_t *runtime = substream->runtime; 517 struct snd_emu10k1_pcm *epcm = runtime->private_data; 518 unsigned int start_addr, end_addr; 519 unsigned int channel_size; 520 int i; 521 522 start_addr = epcm->start_addr; 523 end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream); 524 525 /* 526 * the kX driver leaves some space between voices 527 */ 528 channel_size = ( end_addr - start_addr ) / NUM_EFX_PLAYBACK; 529 530 snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra, 531 start_addr, start_addr + (channel_size / 2), NULL); 532 533 /* only difference with the master voice is we use it for the pointer */ 534 snd_emu10k1_pcm_init_voice(emu, 1, 0, epcm->voices[0], 535 start_addr, start_addr + channel_size, 536 &emu->efx_pcm_mixer[0]); 537 538 start_addr += channel_size; 539 for (i = 1; i < NUM_EFX_PLAYBACK; i++) { 540 snd_emu10k1_pcm_init_voice(emu, 0, 0, epcm->voices[i], 541 start_addr, start_addr + channel_size, 542 &emu->efx_pcm_mixer[i]); 543 start_addr += channel_size; 544 } 545 546 return 0; 547 } 548 549 static snd_pcm_hardware_t snd_emu10k1_efx_playback = 550 { 551 /*.info = */ (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | 552 SNDRV_PCM_INFO_BLOCK_TRANSFER | 553 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), 554 /*.formats = */ SNDRV_PCM_FMTBIT_S16_LE, 555 /*.rates = */ SNDRV_PCM_RATE_48000, 556 /*.rate_min = */ 48000, 557 /*.rate_max = */ 48000, 558 /*.channels_min = */ NUM_EFX_PLAYBACK, 559 /*.channels_max = */ NUM_EFX_PLAYBACK, 560 /*.buffer_bytes_max = */ (64*1024), 561 /*.period_bytes_min = */ 64, 562 /*.period_bytes_max = */ (64*1024), 563 /*.periods_min = */ 2, 564 /*.periods_max = */ 2, 565 /*.fifo_size = */ 0 279 int master, int extra, 280 struct snd_emu10k1_voice *evoice, 281 unsigned int start_addr, 282 unsigned int end_addr, 283 struct snd_emu10k1_pcm_mixer *mix) 284 { 285 struct snd_pcm_substream *substream = evoice->epcm->substream; 286 struct snd_pcm_runtime *runtime = substream->runtime; 287 unsigned int silent_page, tmp; 288 int voice, stereo, w_16; 289 unsigned char attn, send_amount[8]; 290 unsigned char send_routing[8]; 291 unsigned long flags; 292 unsigned int pitch_target; 293 unsigned int ccis; 294 295 voice = evoice->number; 296 stereo = runtime->channels == 2; 297 w_16 = snd_pcm_format_width(runtime->format) == 16; 298 299 if (!extra && stereo) { 300 start_addr >>= 1; 301 end_addr >>= 1; 302 } 303 if (w_16) { 304 start_addr >>= 1; 305 end_addr >>= 1; 306 } 307 308 spin_lock_irqsave(&emu->reg_lock, flags); 309 310 /* volume parameters */ 311 if (extra) { 312 attn = 0; 313 memset(send_routing, 0, sizeof(send_routing)); 314 send_routing[0] = 0; 315 send_routing[1] = 1; 316 send_routing[2] = 2; 317 send_routing[3] = 3; 318 memset(send_amount, 0, sizeof(send_amount)); 319 } else { 320 /* mono, left, right (master voice = left) */ 321 tmp = stereo ? (master ? 1 : 2) : 0; 322 memcpy(send_routing, &mix->send_routing[tmp][0], 8); 323 memcpy(send_amount, &mix->send_volume[tmp][0], 8); 324 } 325 326 ccis = emu10k1_ccis(stereo, w_16); 327 328 if (master) { 329 evoice->epcm->ccca_start_addr = start_addr + ccis; 330 if (extra) { 331 start_addr += ccis; 332 end_addr += ccis; 333 } 334 if (stereo && !extra) { 335 snd_emu10k1_ptr_write(emu, CPF, voice, CPF_STEREO_MASK); 336 snd_emu10k1_ptr_write(emu, CPF, (voice + 1), CPF_STEREO_MASK); 337 } else { 338 snd_emu10k1_ptr_write(emu, CPF, voice, 0); 339 } 340 } 341 342 /* setup routing */ 343 if (emu->audigy) { 344 snd_emu10k1_ptr_write(emu, A_FXRT1, voice, 345 snd_emu10k1_compose_audigy_fxrt1(send_routing)); 346 snd_emu10k1_ptr_write(emu, A_FXRT2, voice, 347 snd_emu10k1_compose_audigy_fxrt2(send_routing)); 348 snd_emu10k1_ptr_write(emu, A_SENDAMOUNTS, voice, 349 ((unsigned int)send_amount[4] << 24) | 350 ((unsigned int)send_amount[5] << 16) | 351 ((unsigned int)send_amount[6] << 8) | 352 (unsigned int)send_amount[7]); 353 } else 354 snd_emu10k1_ptr_write(emu, FXRT, voice, 355 snd_emu10k1_compose_send_routing(send_routing)); 356 /* Stop CA */ 357 /* Assumption that PT is already 0 so no harm overwriting */ 358 snd_emu10k1_ptr_write(emu, PTRX, voice, (send_amount[0] << 8) | send_amount[1]); 359 snd_emu10k1_ptr_write(emu, DSL, voice, end_addr | (send_amount[3] << 24)); 360 snd_emu10k1_ptr_write(emu, PSST, voice, start_addr | (send_amount[2] << 24)); 361 if (emu->card_capabilities->emu1010) 362 pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */ 363 else 364 pitch_target = emu10k1_calc_pitch_target(runtime->rate); 365 if (extra) 366 snd_emu10k1_ptr_write(emu, CCCA, voice, start_addr | 367 emu10k1_select_interprom(pitch_target) | 368 (w_16 ? 0 : CCCA_8BITSELECT)); 369 else 370 snd_emu10k1_ptr_write(emu, CCCA, voice, (start_addr + ccis) | 371 emu10k1_select_interprom(pitch_target) | 372 (w_16 ? 0 : CCCA_8BITSELECT)); 373 /* Clear filter delay memory */ 374 snd_emu10k1_ptr_write(emu, Z1, voice, 0); 375 snd_emu10k1_ptr_write(emu, Z2, voice, 0); 376 /* invalidate maps */ 377 silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK; 378 snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page); 379 snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page); 380 /* modulation envelope */ 381 snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); 382 snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); 383 snd_emu10k1_ptr_write(emu, ATKHLDM, voice, 0); 384 snd_emu10k1_ptr_write(emu, DCYSUSM, voice, 0x007f); 385 snd_emu10k1_ptr_write(emu, LFOVAL1, voice, 0x8000); 386 snd_emu10k1_ptr_write(emu, LFOVAL2, voice, 0x8000); 387 snd_emu10k1_ptr_write(emu, FMMOD, voice, 0); 388 snd_emu10k1_ptr_write(emu, TREMFRQ, voice, 0); 389 snd_emu10k1_ptr_write(emu, FM2FRQ2, voice, 0); 390 snd_emu10k1_ptr_write(emu, ENVVAL, voice, 0x8000); 391 /* volume envelope */ 392 snd_emu10k1_ptr_write(emu, ATKHLDV, voice, 0x7f7f); 393 snd_emu10k1_ptr_write(emu, ENVVOL, voice, 0x0000); 394 /* filter envelope */ 395 snd_emu10k1_ptr_write(emu, PEFE_FILTERAMOUNT, voice, 0x7f); 396 /* pitch envelope */ 397 snd_emu10k1_ptr_write(emu, PEFE_PITCHAMOUNT, voice, 0); 398 399 spin_unlock_irqrestore(&emu->reg_lock, flags); 400 } 401 402 static int snd_emu10k1_playback_hw_params(struct snd_pcm_substream *substream, 403 struct snd_pcm_hw_params *hw_params) 404 { 405 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 406 struct snd_pcm_runtime *runtime = substream->runtime; 407 struct snd_emu10k1_pcm *epcm = runtime->private_data; 408 int err; 409 410 if ((err = snd_emu10k1_pcm_channel_alloc(epcm, params_channels(hw_params))) < 0) 411 return err; 412 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) 413 return err; 414 if (err > 0) { /* change */ 415 int mapped; 416 if (epcm->memblk != NULL) 417 snd_emu10k1_free_pages(emu, epcm->memblk); 418 epcm->memblk = snd_emu10k1_alloc_pages(emu, substream); 419 epcm->start_addr = 0; 420 if (! epcm->memblk) 421 return -ENOMEM; 422 mapped = ((struct snd_emu10k1_memblk *)epcm->memblk)->mapped_page; 423 if (mapped < 0) 424 return -ENOMEM; 425 epcm->start_addr = mapped << PAGE_SHIFT; 426 } 427 return 0; 428 } 429 430 static int snd_emu10k1_playback_hw_free(struct snd_pcm_substream *substream) 431 { 432 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 433 struct snd_pcm_runtime *runtime = substream->runtime; 434 struct snd_emu10k1_pcm *epcm; 435 436 if (runtime->private_data == NULL) 437 return 0; 438 epcm = runtime->private_data; 439 if (epcm->extra) { 440 snd_emu10k1_voice_free(epcm->emu, epcm->extra); 441 epcm->extra = NULL; 442 } 443 if (epcm->voices[1]) { 444 snd_emu10k1_voice_free(epcm->emu, epcm->voices[1]); 445 epcm->voices[1] = NULL; 446 } 447 if (epcm->voices[0]) { 448 snd_emu10k1_voice_free(epcm->emu, epcm->voices[0]); 449 epcm->voices[0] = NULL; 450 } 451 if (epcm->memblk) { 452 snd_emu10k1_free_pages(emu, epcm->memblk); 453 epcm->memblk = NULL; 454 epcm->start_addr = 0; 455 } 456 snd_pcm_lib_free_pages(substream); 457 return 0; 458 } 459 460 static int snd_emu10k1_efx_playback_hw_free(struct snd_pcm_substream *substream) 461 { 462 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 463 struct snd_pcm_runtime *runtime = substream->runtime; 464 struct snd_emu10k1_pcm *epcm; 465 int i; 466 467 if (runtime->private_data == NULL) 468 return 0; 469 epcm = runtime->private_data; 470 if (epcm->extra) { 471 snd_emu10k1_voice_free(epcm->emu, epcm->extra); 472 epcm->extra = NULL; 473 } 474 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 475 if (epcm->voices[i]) { 476 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); 477 epcm->voices[i] = NULL; 478 } 479 } 480 if (epcm->memblk) { 481 snd_emu10k1_free_pages(emu, epcm->memblk); 482 epcm->memblk = NULL; 483 epcm->start_addr = 0; 484 } 485 snd_pcm_lib_free_pages(substream); 486 return 0; 487 } 488 489 static int snd_emu10k1_playback_prepare(struct snd_pcm_substream *substream) 490 { 491 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 492 struct snd_pcm_runtime *runtime = substream->runtime; 493 struct snd_emu10k1_pcm *epcm = runtime->private_data; 494 unsigned int start_addr, end_addr; 495 496 start_addr = epcm->start_addr; 497 end_addr = snd_pcm_lib_period_bytes(substream); 498 if (runtime->channels == 2) { 499 start_addr >>= 1; 500 end_addr >>= 1; 501 } 502 end_addr += start_addr; 503 snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra, 504 start_addr, end_addr, NULL); 505 start_addr = epcm->start_addr; 506 end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream); 507 snd_emu10k1_pcm_init_voice(emu, 1, 0, epcm->voices[0], 508 start_addr, end_addr, 509 &emu->pcm_mixer[substream->number]); 510 if (epcm->voices[1]) 511 snd_emu10k1_pcm_init_voice(emu, 0, 0, epcm->voices[1], 512 start_addr, end_addr, 513 &emu->pcm_mixer[substream->number]); 514 return 0; 515 } 516 517 static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream *substream) 518 { 519 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 520 struct snd_pcm_runtime *runtime = substream->runtime; 521 struct snd_emu10k1_pcm *epcm = runtime->private_data; 522 unsigned int start_addr, end_addr; 523 unsigned int channel_size; 524 int i; 525 526 start_addr = epcm->start_addr; 527 end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream); 528 529 /* 530 * the kX driver leaves some space between voices 531 */ 532 channel_size = ( end_addr - start_addr ) / NUM_EFX_PLAYBACK; 533 534 snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra, 535 start_addr, start_addr + (channel_size / 2), NULL); 536 537 /* only difference with the master voice is we use it for the pointer */ 538 snd_emu10k1_pcm_init_voice(emu, 1, 0, epcm->voices[0], 539 start_addr, start_addr + channel_size, 540 &emu->efx_pcm_mixer[0]); 541 542 start_addr += channel_size; 543 for (i = 1; i < NUM_EFX_PLAYBACK; i++) { 544 snd_emu10k1_pcm_init_voice(emu, 0, 0, epcm->voices[i], 545 start_addr, start_addr + channel_size, 546 &emu->efx_pcm_mixer[i]); 547 start_addr += channel_size; 548 } 549 550 return 0; 551 } 552 553 static struct snd_pcm_hardware snd_emu10k1_efx_playback = 554 { 555 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | 556 SNDRV_PCM_INFO_BLOCK_TRANSFER | 557 SNDRV_PCM_INFO_RESUME | 558 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), 559 .formats = SNDRV_PCM_FMTBIT_S16_LE, 560 .rates = SNDRV_PCM_RATE_48000, 561 .rate_min = 48000, 562 .rate_max = 48000, 563 .channels_min = NUM_EFX_PLAYBACK, 564 .channels_max = NUM_EFX_PLAYBACK, 565 .buffer_bytes_max = (64*1024), 566 .period_bytes_min = 64, 567 .period_bytes_max = (64*1024), 568 .periods_min = 2, 569 .periods_max = 2, 570 .fifo_size = 0, 566 571 }; 567 572 568 static int snd_emu10k1_capture_hw_params(s nd_pcm_substream_t *substream,569 snd_pcm_hw_params_t *hw_params)570 { 571 572 } 573 574 static int snd_emu10k1_capture_hw_free(s nd_pcm_substream_t *substream)575 { 576 577 } 578 579 static int snd_emu10k1_capture_prepare(s nd_pcm_substream_t *substream)580 { 581 582 snd_pcm_runtime_t*runtime = substream->runtime;583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 } 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 573 static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream, 574 struct snd_pcm_hw_params *hw_params) 575 { 576 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 577 } 578 579 static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream) 580 { 581 return snd_pcm_lib_free_pages(substream); 582 } 583 584 static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) 585 { 586 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 587 struct snd_pcm_runtime *runtime = substream->runtime; 588 struct snd_emu10k1_pcm *epcm = runtime->private_data; 589 int idx; 590 591 /* zeroing the buffer size will stop capture */ 592 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); 593 switch (epcm->type) { 594 case CAPTURE_AC97ADC: 595 snd_emu10k1_ptr_write(emu, ADCCR, 0, 0); 596 break; 597 case CAPTURE_EFX: 598 if (emu->audigy) { 599 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, 0); 600 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, 0); 601 } else 602 snd_emu10k1_ptr_write(emu, FXWC, 0, 0); 603 break; 604 default: 605 break; 606 } 607 snd_emu10k1_ptr_write(emu, epcm->capture_ba_reg, 0, runtime->dma_addr); 608 epcm->capture_bufsize = snd_pcm_lib_buffer_bytes(substream); 609 epcm->capture_bs_val = 0; 610 for (idx = 0; idx < 31; idx++) { 611 if (capture_period_sizes[idx] == epcm->capture_bufsize) { 612 epcm->capture_bs_val = idx + 1; 613 break; 614 } 615 } 616 if (epcm->capture_bs_val == 0) { 617 snd_BUG(); 618 epcm->capture_bs_val++; 619 } 620 if (epcm->type == CAPTURE_AC97ADC) { 621 epcm->capture_cr_val = emu->audigy ? A_ADCCR_LCHANENABLE : ADCCR_LCHANENABLE; 622 if (runtime->channels > 1) 623 epcm->capture_cr_val |= emu->audigy ? A_ADCCR_RCHANENABLE : ADCCR_RCHANENABLE; 624 epcm->capture_cr_val |= emu->audigy ? 625 snd_emu10k1_audigy_capture_rate_reg(runtime->rate) : 626 snd_emu10k1_capture_rate_reg(runtime->rate); 627 } 628 return 0; 624 629 } 625 630 626 631 static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1 *emu, int extra, struct snd_emu10k1_voice *evoice) 627 632 { 628 snd_pcm_runtime_t*runtime;629 630 631 632 633 634 635 636 637 638 // set cs to 2 * number of cache registers beside the invalidated 639 640 641 642 643 644 645 646 647 // reset cache 648 649 650 651 652 653 654 // fill cache 655 656 657 658 633 struct snd_pcm_runtime *runtime; 634 unsigned int voice, stereo, i, ccis, cra = 64, cs, sample; 635 636 if (evoice == NULL) 637 return; 638 runtime = evoice->epcm->substream->runtime; 639 voice = evoice->number; 640 stereo = (!extra && runtime->channels == 2); 641 sample = snd_pcm_format_width(runtime->format) == 16 ? 0 : 0x80808080; 642 ccis = emu10k1_ccis(stereo, sample == 0); 643 /* set cs to 2 * number of cache registers beside the invalidated */ 644 cs = (sample == 0) ? (32-ccis) : (64-ccis+1) >> 1; 645 if (cs > 16) cs = 16; 646 for (i = 0; i < cs; i++) { 647 snd_emu10k1_ptr_write(emu, CD0 + i, voice, sample); 648 if (stereo) { 649 snd_emu10k1_ptr_write(emu, CD0 + i, voice + 1, sample); 650 } 651 } 652 /* reset cache */ 653 snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, 0); 654 snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice, cra); 655 if (stereo) { 656 snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice + 1, 0); 657 snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice + 1, cra); 658 } 659 /* fill cache */ 660 snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, ccis); 661 if (stereo) { 662 snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice+1, ccis); 663 } 659 664 } 660 665 661 666 static void snd_emu10k1_playback_prepare_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, 662 int master, int extra, 663 struct snd_emu10k1_pcm_mixer *mix) 664 { 665 snd_pcm_substream_t *substream; 666 snd_pcm_runtime_t *runtime; 667 unsigned int attn, vattn; 668 unsigned int voice, tmp; 669 670 if (evoice == NULL) /* skip second voice for mono */ 671 return; 672 substream = evoice->epcm->substream; 673 runtime = substream->runtime; 674 voice = evoice->number; 675 attn = extra ? 0 : 0x00ff; 676 tmp = runtime->channels == 2 ? (master ? 1 : 2) : 0; 677 vattn = mix != NULL ? (mix->attn[tmp] << 16) : 0; 678 snd_emu10k1_ptr_write(emu, IFATN, voice, attn); 679 snd_emu10k1_ptr_write(emu, VTFT, voice, vattn | 0xffff); 680 snd_emu10k1_ptr_write(emu, CVCF, voice, vattn | 0xffff); 681 snd_emu10k1_ptr_write(emu, DCYSUSV, voice, 0x7f7f); 682 snd_emu10k1_voice_clear_loop_stop(emu, voice); 683 } 667 int master, int extra, 668 struct snd_emu10k1_pcm_mixer *mix) 669 { 670 struct snd_pcm_substream *substream; 671 struct snd_pcm_runtime *runtime; 672 unsigned int attn, vattn; 673 unsigned int voice, tmp; 674 675 if (evoice == NULL) /* skip second voice for mono */ 676 return; 677 substream = evoice->epcm->substream; 678 runtime = substream->runtime; 679 voice = evoice->number; 680 681 attn = extra ? 0 : 0x00ff; 682 tmp = runtime->channels == 2 ? (master ? 1 : 2) : 0; 683 vattn = mix != NULL ? (mix->attn[tmp] << 16) : 0; 684 snd_emu10k1_ptr_write(emu, IFATN, voice, attn); 685 snd_emu10k1_ptr_write(emu, VTFT, voice, vattn | 0xffff); 686 snd_emu10k1_ptr_write(emu, CVCF, voice, vattn | 0xffff); 687 snd_emu10k1_ptr_write(emu, DCYSUSV, voice, 0x7f7f); 688 snd_emu10k1_voice_clear_loop_stop(emu, voice); 689 } 684 690 685 691 static void snd_emu10k1_playback_trigger_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra) 686 692 { 687 snd_pcm_substream_t *substream; 688 snd_pcm_runtime_t *runtime; 689 unsigned int voice, pitch, pitch_target; 690 691 if (evoice == NULL) /* skip second voice for mono */ 692 return; 693 substream = evoice->epcm->substream; 694 runtime = substream->runtime; 695 voice = evoice->number; 696 697 pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8; 698 pitch_target = emu10k1_calc_pitch_target(runtime->rate); 699 snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, pitch_target); 700 if (master || evoice->epcm->type == PLAYBACK_EFX) 701 snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, pitch_target); 702 snd_emu10k1_ptr_write(emu, IP, voice, pitch); 703 if (extra) 704 snd_emu10k1_voice_intr_enable(emu, voice); 693 struct snd_pcm_substream *substream; 694 struct snd_pcm_runtime *runtime; 695 unsigned int voice, pitch, pitch_target; 696 697 if (evoice == NULL) /* skip second voice for mono */ 698 return; 699 substream = evoice->epcm->substream; 700 runtime = substream->runtime; 701 voice = evoice->number; 702 703 pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8; 704 if (emu->card_capabilities->emu1010) 705 pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */ 706 else 707 pitch_target = emu10k1_calc_pitch_target(runtime->rate); 708 snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, pitch_target); 709 if (master || evoice->epcm->type == PLAYBACK_EFX) 710 snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, pitch_target); 711 snd_emu10k1_ptr_write(emu, IP, voice, pitch); 712 if (extra) 713 snd_emu10k1_voice_intr_enable(emu, voice); 705 714 } 706 715 707 716 static void snd_emu10k1_playback_stop_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice) 708 717 { 709 unsigned int voice; 710 711 if (evoice == NULL) 712 return; 713 voice = evoice->number; 714 snd_emu10k1_voice_intr_disable(emu, voice); 715 snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, 0); 716 snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, 0); 717 snd_emu10k1_ptr_write(emu, IFATN, voice, 0xffff); 718 snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); 719 snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); 720 snd_emu10k1_ptr_write(emu, IP, voice, 0); 721 } 722 723 static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, 724 int cmd) 725 { 726 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 727 snd_pcm_runtime_t *runtime = substream->runtime; 728 struct snd_emu10k1_pcm *epcm = runtime->private_data; 729 struct snd_emu10k1_pcm_mixer *mix; 730 int result = 0; 731 732 spin_lock(&emu->reg_lock); 733 switch (cmd) { 734 case SNDRV_PCM_TRIGGER_START: 735 // hmm this should cause full and half full interrupt to be raised? 736 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* do we need this? */ 737 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); 738 /* follow thru */ 739 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 740 mix = &emu->pcm_mixer[substream->number]; 741 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 1, 0, mix); 742 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[1], 0, 0, mix); 743 snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); 744 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 1, 0); 745 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[1], 0, 0); 746 snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1); 747 epcm->running = 1; 748 break; 749 case SNDRV_PCM_TRIGGER_STOP: 750 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 751 epcm->running = 0; 752 snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]); 753 snd_emu10k1_playback_stop_voice(emu, epcm->voices[1]); 754 snd_emu10k1_playback_stop_voice(emu, epcm->extra); 755 break; 756 default: 757 result = -EINVAL; 758 break; 759 } 760 spin_unlock(&emu->reg_lock); 761 return result; 762 } 763 764 static int snd_emu10k1_capture_trigger(snd_pcm_substream_t * substream, 765 int cmd) 766 { 767 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 768 snd_pcm_runtime_t *runtime = substream->runtime; 769 struct snd_emu10k1_pcm *epcm = runtime->private_data; 770 int result = 0; 771 772 // printk("trigger - emu10k1 = %p, cmd = %i, pointer = %i\n", emu, cmd, substream->ops->pointer(substream)); 773 spin_lock(&emu->reg_lock); 774 switch (cmd) { 775 case SNDRV_PCM_TRIGGER_START: 776 outl(epcm->capture_ipr, emu->port + IPR); 777 snd_emu10k1_intr_enable(emu, epcm->capture_inte); 778 // printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); 779 switch (epcm->type) { 780 case CAPTURE_AC97ADC: 781 snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val); 782 break; 783 case CAPTURE_EFX: 784 if (emu->audigy) { 785 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val); 786 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2); 787 } else 788 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); 789 break; 790 default: 791 break; 792 } 793 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, epcm->capture_bs_val); 794 epcm->running = 1; 795 epcm->first_ptr = 1; 796 break; 797 case SNDRV_PCM_TRIGGER_STOP: 798 epcm->running = 0; 799 snd_emu10k1_intr_disable(emu, epcm->capture_inte); 800 outl(epcm->capture_ipr, emu->port + IPR); 801 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); 802 switch (epcm->type) { 803 case CAPTURE_AC97ADC: 804 snd_emu10k1_ptr_write(emu, ADCCR, 0, 0); 805 break; 806 case CAPTURE_EFX: 807 if (emu->audigy) { 808 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, 0); 809 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, 0); 810 } else 811 snd_emu10k1_ptr_write(emu, FXWC, 0, 0); 812 break; 813 default: 814 break; 815 } 816 break; 817 default: 818 result = -EINVAL; 819 } 820 spin_unlock(&emu->reg_lock); 821 return result; 822 } 823 824 static snd_pcm_uframes_t snd_emu10k1_playback_pointer(snd_pcm_substream_t * substream) 825 { 826 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 827 snd_pcm_runtime_t *runtime = substream->runtime; 828 struct snd_emu10k1_pcm *epcm = runtime->private_data; 829 unsigned int ptr; 830 831 if (!epcm->running) 832 return 0; 833 ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff; 718 unsigned int voice; 719 720 if (evoice == NULL) 721 return; 722 voice = evoice->number; 723 snd_emu10k1_voice_intr_disable(emu, voice); 724 snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, 0); 725 snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, 0); 726 snd_emu10k1_ptr_write(emu, IFATN, voice, 0xffff); 727 snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); 728 snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); 729 snd_emu10k1_ptr_write(emu, IP, voice, 0); 730 } 731 732 static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, 733 int cmd) 734 { 735 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 736 struct snd_pcm_runtime *runtime = substream->runtime; 737 struct snd_emu10k1_pcm *epcm = runtime->private_data; 738 struct snd_emu10k1_pcm_mixer *mix; 739 int result = 0; 740 741 /* printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); */ 742 spin_lock(&emu->reg_lock); 743 switch (cmd) { 744 case SNDRV_PCM_TRIGGER_START: 745 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* do we need this? */ 746 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); 747 /* follow thru */ 748 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 749 case SNDRV_PCM_TRIGGER_RESUME: 750 mix = &emu->pcm_mixer[substream->number]; 751 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 1, 0, mix); 752 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[1], 0, 0, mix); 753 snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); 754 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 1, 0); 755 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[1], 0, 0); 756 snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1); 757 epcm->running = 1; 758 break; 759 case SNDRV_PCM_TRIGGER_STOP: 760 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 761 case SNDRV_PCM_TRIGGER_SUSPEND: 762 epcm->running = 0; 763 snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]); 764 snd_emu10k1_playback_stop_voice(emu, epcm->voices[1]); 765 snd_emu10k1_playback_stop_voice(emu, epcm->extra); 766 break; 767 default: 768 result = -EINVAL; 769 break; 770 } 771 spin_unlock(&emu->reg_lock); 772 return result; 773 } 774 775 static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream, 776 int cmd) 777 { 778 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 779 struct snd_pcm_runtime *runtime = substream->runtime; 780 struct snd_emu10k1_pcm *epcm = runtime->private_data; 781 int result = 0; 782 783 spin_lock(&emu->reg_lock); 784 switch (cmd) { 785 case SNDRV_PCM_TRIGGER_START: 786 case SNDRV_PCM_TRIGGER_RESUME: 787 /* hmm this should cause full and half full interrupt to be raised? */ 788 outl(epcm->capture_ipr, emu->port + IPR); 789 snd_emu10k1_intr_enable(emu, epcm->capture_inte); 790 /* printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); */ 791 switch (epcm->type) { 792 case CAPTURE_AC97ADC: 793 snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val); 794 break; 795 case CAPTURE_EFX: 796 if (emu->audigy) { 797 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val); 798 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2); 799 snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2); 800 } else 801 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); 802 break; 803 default: 804 break; 805 } 806 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, epcm->capture_bs_val); 807 epcm->running = 1; 808 epcm->first_ptr = 1; 809 break; 810 case SNDRV_PCM_TRIGGER_STOP: 811 case SNDRV_PCM_TRIGGER_SUSPEND: 812 epcm->running = 0; 813 snd_emu10k1_intr_disable(emu, epcm->capture_inte); 814 outl(epcm->capture_ipr, emu->port + IPR); 815 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); 816 switch (epcm->type) { 817 case CAPTURE_AC97ADC: 818 snd_emu10k1_ptr_write(emu, ADCCR, 0, 0); 819 break; 820 case CAPTURE_EFX: 821 if (emu->audigy) { 822 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, 0); 823 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, 0); 824 } else 825 snd_emu10k1_ptr_write(emu, FXWC, 0, 0); 826 break; 827 default: 828 break; 829 } 830 break; 831 default: 832 result = -EINVAL; 833 } 834 spin_unlock(&emu->reg_lock); 835 return result; 836 } 837 838 static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *substream) 839 { 840 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 841 struct snd_pcm_runtime *runtime = substream->runtime; 842 struct snd_emu10k1_pcm *epcm = runtime->private_data; 843 unsigned int ptr; 844 845 if (!epcm->running) 846 return 0; 847 ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff; 834 848 #if 0 /* Perex's code */ 835 836 837 849 ptr += runtime->buffer_size; 850 ptr -= epcm->ccca_start_addr; 851 ptr %= runtime->buffer_size; 838 852 #else /* EMU10K1 Open Source code from Creative */ 839 840 841 842 843 844 845 853 if (ptr < epcm->ccca_start_addr) 854 ptr += runtime->buffer_size - epcm->ccca_start_addr; 855 else { 856 ptr -= epcm->ccca_start_addr; 857 if (ptr >= runtime->buffer_size) 858 ptr -= runtime->buffer_size; 859 } 846 860 #endif 847 // printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); 848 return ptr; 849 } 850 851 static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, 852 int cmd) 853 { 854 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 855 snd_pcm_runtime_t *runtime = substream->runtime; 856 struct snd_emu10k1_pcm *epcm = runtime->private_data; 857 int i; 858 int result = 0; 859 860 spin_lock(&emu->reg_lock); 861 switch (cmd) { 862 case SNDRV_PCM_TRIGGER_START: 863 // prepare voices 864 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 865 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]); 866 } 867 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); 868 869 /* follow thru */ 870 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 871 snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); 872 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 0, 0, 873 &emu->efx_pcm_mixer[0]); 874 for (i = 1; i < NUM_EFX_PLAYBACK; i++) 875 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[i], 0, 0, 876 &emu->efx_pcm_mixer[i]); 877 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 0, 0); 878 snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1); 879 for (i = 1; i < NUM_EFX_PLAYBACK; i++) 880 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[i], 0, 0); 881 epcm->running = 1; 882 break; 883 case SNDRV_PCM_TRIGGER_STOP: 884 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 885 epcm->running = 0; 886 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 887 snd_emu10k1_playback_stop_voice(emu, epcm->voices[i]); 888 } 889 snd_emu10k1_playback_stop_voice(emu, epcm->extra); 890 break; 891 default: 892 result = -EINVAL; 893 break; 894 } 895 spin_unlock(&emu->reg_lock); 896 return result; 897 } 898 899 static snd_pcm_uframes_t snd_emu10k1_capture_pointer(snd_pcm_substream_t * substream) 900 { 901 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 902 snd_pcm_runtime_t *runtime = substream->runtime; 903 struct snd_emu10k1_pcm *epcm = runtime->private_data; 904 unsigned int ptr; 905 906 if (!epcm->running) 907 return 0; 908 if (epcm->first_ptr) { 909 udelay(50); // hack, it takes awhile until capture is started 910 epcm->first_ptr = 0; 911 } 912 ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff; 913 return bytes_to_frames(runtime, ptr); 861 /* printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size); */ 862 return ptr; 863 } 864 865 866 static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, 867 int cmd) 868 { 869 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 870 struct snd_pcm_runtime *runtime = substream->runtime; 871 struct snd_emu10k1_pcm *epcm = runtime->private_data; 872 int i; 873 int result = 0; 874 875 spin_lock(&emu->reg_lock); 876 switch (cmd) { 877 case SNDRV_PCM_TRIGGER_START: 878 /* prepare voices */ 879 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 880 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]); 881 } 882 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); 883 884 /* follow thru */ 885 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 886 case SNDRV_PCM_TRIGGER_RESUME: 887 snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); 888 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 0, 0, 889 &emu->efx_pcm_mixer[0]); 890 for (i = 1; i < NUM_EFX_PLAYBACK; i++) 891 snd_emu10k1_playback_prepare_voice(emu, epcm->voices[i], 0, 0, 892 &emu->efx_pcm_mixer[i]); 893 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 0, 0); 894 snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1); 895 for (i = 1; i < NUM_EFX_PLAYBACK; i++) 896 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[i], 0, 0); 897 epcm->running = 1; 898 break; 899 case SNDRV_PCM_TRIGGER_SUSPEND: 900 case SNDRV_PCM_TRIGGER_STOP: 901 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 902 epcm->running = 0; 903 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 904 snd_emu10k1_playback_stop_voice(emu, epcm->voices[i]); 905 } 906 snd_emu10k1_playback_stop_voice(emu, epcm->extra); 907 break; 908 default: 909 result = -EINVAL; 910 break; 911 } 912 spin_unlock(&emu->reg_lock); 913 return result; 914 } 915 916 917 static snd_pcm_uframes_t snd_emu10k1_capture_pointer(struct snd_pcm_substream *substream) 918 { 919 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 920 struct snd_pcm_runtime *runtime = substream->runtime; 921 struct snd_emu10k1_pcm *epcm = runtime->private_data; 922 unsigned int ptr; 923 924 if (!epcm->running) 925 return 0; 926 if (epcm->first_ptr) { 927 udelay(50); /* hack, it takes awhile until capture is started */ 928 epcm->first_ptr = 0; 929 } 930 ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff; 931 return bytes_to_frames(runtime, ptr); 914 932 } 915 933 … … 918 936 */ 919 937 920 #if 0 921 int snd_emu10k1_playback_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg) 922 { 923 switch(cmd) { 924 case SNDRV_PCM_IOCTL1_SETVOLUME: 925 { 926 struct snd_emu10k1_pcm_mixer *mix; 927 snd_pcm_volume_t *volume = (snd_pcm_volume_t *)arg; 928 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 929 snd_ctl_elem_value_t *ucontrol; 930 snd_ctl_elem_info_t *uinfo; 931 void *iwishihadmorestack; 932 int range; 933 934 935 iwishihadmorestack = kmalloc(sizeof(snd_ctl_elem_value_t) + sizeof(snd_ctl_elem_info_t), GFP_KERNEL); 936 if(iwishihadmorestack == NULL) { 937 kfree(iwishihadmorestack); 938 return -ENOMEM; 939 } 940 ucontrol = (snd_ctl_elem_value_t *)iwishihadmorestack; 941 uinfo = (snd_ctl_elem_info_t *)(ucontrol + 1); 942 943 mix = &emu->pcm_mixer[substream->number]; 944 mix->ctl_attn->info(mix->ctl_attn, uinfo); 945 range = uinfo->value.integer.max - uinfo->value.integer.min; 946 947 if (mix->epcm->voices[0] && mix->epcm->voices[1]) { 948 ucontrol->value.integer.value[1] = (volume->volume[SNDRV_PCM_VOL_FRONT_LEFT] * range)/SNDRV_PCM_VOL_MAX; 949 ucontrol->value.integer.value[2] = (volume->volume[SNDRV_PCM_VOL_FRONT_RIGHT] * range)/SNDRV_PCM_VOL_MAX; 950 } 951 else 952 if (mix->epcm->voices[0]) 953 ucontrol->value.integer.value[0] = (volume->volume[SNDRV_PCM_VOL_FRONT_LEFT] * range)/SNDRV_PCM_VOL_MAX; 954 955 mix->ctl_attn->put(mix->ctl_attn, ucontrol); 956 kfree(iwishihadmorestack); 957 return 0; 958 } 959 case SNDRV_PCM_IOCTL1_GETVOLUME: 960 { 961 struct snd_emu10k1_pcm_mixer *mix; 962 snd_pcm_volume_t *volume = (snd_pcm_volume_t *)arg; 963 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 964 int range; 965 snd_ctl_elem_value_t *ucontrol; 966 snd_ctl_elem_info_t *uinfo; 967 void *iwishihadmorestack; 968 969 iwishihadmorestack = kmalloc(sizeof(snd_ctl_elem_value_t) + sizeof(snd_ctl_elem_info_t), GFP_KERNEL); 970 if(iwishihadmorestack == NULL) { 971 return -ENOMEM; 972 } 973 ucontrol = (snd_ctl_elem_value_t *)iwishihadmorestack; 974 uinfo = (snd_ctl_elem_info_t *)(ucontrol + 1); 975 976 mix = &emu->pcm_mixer[substream->number]; 977 mix->ctl_attn->info(mix->ctl_attn, uinfo); 978 range = uinfo->value.integer.max - uinfo->value.integer.min; 979 if(range == 0) { 980 kfree(iwishihadmorestack); 981 return -EPERM; 982 } 983 mix->ctl_attn->get(mix->ctl_attn, ucontrol); 984 985 if (mix->epcm->voices[0] && mix->epcm->voices[1]) { 986 volume->nrchannels = 2; 987 volume->volume[SNDRV_PCM_VOL_FRONT_LEFT] = (ucontrol->value.integer.value[1] * SNDRV_PCM_VOL_MAX) / range; 988 volume->volume[SNDRV_PCM_VOL_FRONT_RIGHT] = (ucontrol->value.integer.value[2] * SNDRV_PCM_VOL_MAX) / range; 989 volume->volume[SNDRV_PCM_VOL_REAR_LEFT] = volume->volume[SNDRV_PCM_VOL_FRONT_LEFT]; 990 volume->volume[SNDRV_PCM_VOL_REAR_RIGHT] = volume->volume[SNDRV_PCM_VOL_FRONT_RIGHT]; 991 } 992 else 993 if (mix->epcm->voices[0]){ 994 volume->nrchannels = 1; 995 volume->volume[SNDRV_PCM_VOL_FRONT_LEFT] = (ucontrol->value.integer.value[0] * SNDRV_PCM_VOL_MAX) / range; 996 volume->volume[SNDRV_PCM_VOL_FRONT_RIGHT] = volume->volume[SNDRV_PCM_VOL_FRONT_LEFT]; 997 volume->volume[SNDRV_PCM_VOL_REAR_LEFT] = volume->volume[SNDRV_PCM_VOL_FRONT_LEFT]; 998 volume->volume[SNDRV_PCM_VOL_REAR_RIGHT] = volume->volume[SNDRV_PCM_VOL_FRONT_RIGHT]; 999 } 1000 kfree(iwishihadmorestack); 1001 return 0; 1002 } 1003 1004 } 1005 return snd_pcm_lib_ioctl(substream, cmd, arg); 1006 } 1007 #endif 1008 1009 static snd_pcm_hardware_t snd_emu10k1_playback = 1010 { 1011 /* info: */ (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1012 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1013 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), 1014 /* formats: */ SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 1015 SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_96000, 1016 /* rate_min: */ 4000, 1017 /* rate_max: */ 96000, 1018 /* channels_min: */ 1, 1019 /* channels_max: */ 2, 1020 /* buffer_bytes_max: */ (128*1024), 1021 /* period_bytes_min: */ 64, 1022 /* period_bytes_max: */ (128*1024), 1023 /* periods_min: */ 1, 1024 /* periods_max: */ 1024, 1025 /* fifo_size: */ 0, 938 static struct snd_pcm_hardware snd_emu10k1_playback = 939 { 940 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 941 SNDRV_PCM_INFO_BLOCK_TRANSFER | 942 SNDRV_PCM_INFO_RESUME | 943 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), 944 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 945 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_96000, 946 .rate_min = 4000, 947 .rate_max = 96000, 948 .channels_min = 1, 949 .channels_max = 2, 950 .buffer_bytes_max = (128*1024), 951 .period_bytes_min = 64, 952 .period_bytes_max = (128*1024), 953 .periods_min = 1, 954 .periods_max = 1024, 955 .fifo_size = 0, 1026 956 }; 1027 957 … … 1030 960 */ 1031 961 1032 static snd_pcm_hardware_t snd_emu10k1_capture = 1033 { 1034 /* info: */ (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1035 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1036 SNDRV_PCM_INFO_MMAP_VALID), 1037 /* formats: */ SNDRV_PCM_FMTBIT_S16_LE, 1038 /* rates: */ SNDRV_PCM_RATE_8000_48000, 1039 /* rate_min: */ 8000, 1040 /* rate_max: */ 48000, 1041 /* channels_min: */ 1, 1042 /* channels_max: */ 2, 1043 /* buffer_bytes_max: */ (64*1024), 1044 /* period_bytes_min: */ 384, 1045 /* period_bytes_max: */ (64*1024), 1046 /* periods_min: */ 2, 1047 /* periods_max: */ 2, 1048 /* fifo_size: */ 0, 962 static struct snd_pcm_hardware snd_emu10k1_capture = 963 { 964 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 965 SNDRV_PCM_INFO_BLOCK_TRANSFER | 966 SNDRV_PCM_INFO_RESUME | 967 SNDRV_PCM_INFO_MMAP_VALID), 968 .formats = SNDRV_PCM_FMTBIT_S16_LE, 969 .rates = SNDRV_PCM_RATE_8000_48000, 970 .rate_min = 8000, 971 .rate_max = 48000, 972 .channels_min = 1, 973 .channels_max = 2, 974 .buffer_bytes_max = (64*1024), 975 .period_bytes_min = 384, 976 .period_bytes_max = (64*1024), 977 .periods_min = 2, 978 .periods_max = 2, 979 .fifo_size = 0, 980 }; 981 982 static struct snd_pcm_hardware snd_emu10k1_capture_efx = 983 { 984 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 985 SNDRV_PCM_INFO_BLOCK_TRANSFER | 986 SNDRV_PCM_INFO_RESUME | 987 SNDRV_PCM_INFO_MMAP_VALID), 988 .formats = SNDRV_PCM_FMTBIT_S16_LE, 989 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 990 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | 991 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, 992 .rate_min = 44100, 993 .rate_max = 192000, 994 .channels_min = 8, 995 .channels_max = 8, 996 .buffer_bytes_max = (64*1024), 997 .period_bytes_min = 384, 998 .period_bytes_max = (64*1024), 999 .periods_min = 2, 1000 .periods_max = 2, 1001 .fifo_size = 0, 1049 1002 }; 1050 1003 … … 1053 1006 */ 1054 1007 1055 static void snd_emu10k1_pcm_mixer_notify1(struct snd_emu10k1 *emu, s nd_kcontrol_t*kctl, int idx, int activate)1056 { 1057 snd_ctl_elem_id_tid;1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1008 static void snd_emu10k1_pcm_mixer_notify1(struct snd_emu10k1 *emu, struct snd_kcontrol *kctl, int idx, int activate) 1009 { 1010 struct snd_ctl_elem_id id; 1011 1012 if (! kctl) 1013 return; 1014 if (activate) 1015 kctl->vd[idx].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; 1016 else 1017 kctl->vd[idx].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; 1018 snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE | 1019 SNDRV_CTL_EVENT_MASK_INFO, 1020 snd_ctl_build_ioff(&id, kctl, idx)); 1068 1021 } 1069 1022 1070 1023 static void snd_emu10k1_pcm_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) 1071 1024 { 1072 1073 1074 1025 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_routing, idx, activate); 1026 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_volume, idx, activate); 1027 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_attn, idx, activate); 1075 1028 } 1076 1029 1077 1030 static void snd_emu10k1_pcm_efx_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) 1078 1031 { 1079 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate); 1080 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate); 1081 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate); 1082 } 1083 1084 static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) 1085 { 1086 struct snd_emu10k1_pcm *epcm = runtime->private_data; 1087 if (epcm) 1088 kfree(epcm); 1089 } 1090 1091 static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) 1092 { 1093 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1094 struct snd_emu10k1_pcm_mixer *mix; 1095 int i; 1096 1097 for (i=0; i < NUM_EFX_PLAYBACK; i++) { 1098 mix = &emu->efx_pcm_mixer[i]; 1099 mix->epcm = NULL; 1100 snd_emu10k1_pcm_efx_mixer_notify(emu, i, 0); 1101 } 1102 return 0; 1103 } 1104 1105 static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream) 1106 { 1107 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1108 struct snd_emu10k1_pcm *epcm; 1109 struct snd_emu10k1_pcm_mixer *mix; 1110 snd_pcm_runtime_t *runtime = substream->runtime; 1111 int i; 1112 1113 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 1114 if (epcm == NULL) 1115 return -ENOMEM; 1116 epcm->emu = emu; 1117 epcm->type = PLAYBACK_EFX; 1118 epcm->substream = substream; 1119 1120 emu->pcm_playback_efx_substream = substream; 1121 1122 runtime->private_data = epcm; 1123 runtime->private_free = snd_emu10k1_pcm_free_substream; 1124 runtime->hw = snd_emu10k1_efx_playback; 1125 1126 for (i=0; i < NUM_EFX_PLAYBACK; i++) { 1127 mix = &emu->efx_pcm_mixer[i]; 1128 mix->send_routing[0][0] = i; 1129 memset(&mix->send_volume, 0, sizeof(mix->send_volume)); 1130 mix->send_volume[0][0] = 255; 1131 mix->attn[0] = 0xffff; 1132 mix->epcm = epcm; 1133 snd_emu10k1_pcm_efx_mixer_notify(emu, i, 1); 1134 } 1135 return 0; 1136 } 1137 1138 static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream) 1139 { 1140 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1141 struct snd_emu10k1_pcm *epcm; 1142 struct snd_emu10k1_pcm_mixer *mix; 1143 snd_pcm_runtime_t *runtime = substream->runtime; 1144 int i, err; 1145 1146 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 1147 if (epcm == NULL) 1148 return -ENOMEM; 1149 epcm->emu = emu; 1150 epcm->type = PLAYBACK_EMUVOICE; 1151 epcm->substream = substream; 1152 runtime->private_data = epcm; 1153 runtime->private_free = snd_emu10k1_pcm_free_substream; 1154 runtime->hw = snd_emu10k1_playback; 1155 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { 1156 kfree(epcm); 1157 return err; 1158 } 1159 if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0) { 1160 kfree(epcm); 1161 return err; 1162 } 1163 mix = &emu->pcm_mixer[substream->number]; 1164 for (i = 0; i < 4; i++) 1165 mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i; 1166 memset(&mix->send_volume, 0, sizeof(mix->send_volume)); 1167 mix->send_volume[0][0] = mix->send_volume[0][1] = 1168 mix->send_volume[1][0] = mix->send_volume[2][1] = 255; 1169 mix->attn[0] = mix->attn[1] = mix->attn[2] = 0xffff; 1170 mix->epcm = epcm; 1171 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1); 1172 return 0; 1173 } 1174 1175 static int snd_emu10k1_playback_close(snd_pcm_substream_t * substream) 1176 { 1177 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1178 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number]; 1179 1180 mix->epcm = NULL; 1181 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0); 1182 return 0; 1183 } 1184 1185 static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream) 1186 { 1187 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1188 snd_pcm_runtime_t *runtime = substream->runtime; 1189 struct snd_emu10k1_pcm *epcm; 1190 1191 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 1192 if (epcm == NULL) 1193 return -ENOMEM; 1194 epcm->emu = emu; 1195 epcm->type = CAPTURE_AC97ADC; 1196 epcm->substream = substream; 1197 epcm->capture_ipr = IPR_ADCBUFFULL|IPR_ADCBUFHALFFULL; 1198 epcm->capture_inte = INTE_ADCBUFENABLE; 1199 epcm->capture_ba_reg = ADCBA; 1200 epcm->capture_bs_reg = ADCBS; 1201 epcm->capture_idx_reg = emu->audigy ? A_ADCIDX : ADCIDX; 1202 runtime->private_data = epcm; 1203 runtime->private_free = snd_emu10k1_pcm_free_substream; 1204 runtime->hw = snd_emu10k1_capture; 1205 emu->capture_interrupt = snd_emu10k1_pcm_ac97adc_interrupt; 1206 emu->pcm_capture_substream = substream; 1207 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); 1208 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_capture_rates); 1209 return 0; 1210 } 1211 1212 static int snd_emu10k1_capture_close(snd_pcm_substream_t * substream) 1213 { 1214 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1215 1216 emu->capture_interrupt = NULL; 1217 emu->pcm_capture_substream = NULL; 1218 return 0; 1219 } 1220 1221 static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream) 1222 { 1223 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1224 struct snd_emu10k1_pcm *epcm; 1225 snd_pcm_runtime_t *runtime = substream->runtime; 1226 1227 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 1228 if (epcm == NULL) 1229 return -ENOMEM; 1230 epcm->emu = emu; 1231 epcm->type = CAPTURE_AC97MIC; 1232 epcm->substream = substream; 1233 epcm->capture_ipr = IPR_MICBUFFULL|IPR_MICBUFHALFFULL; 1234 epcm->capture_inte = INTE_MICBUFENABLE; 1235 epcm->capture_ba_reg = MICBA; 1236 epcm->capture_bs_reg = MICBS; 1237 epcm->capture_idx_reg = emu->audigy ? A_MICIDX : MICIDX; 1238 substream->runtime->private_data = epcm; 1239 substream->runtime->private_free = snd_emu10k1_pcm_free_substream; 1240 runtime->hw = snd_emu10k1_capture; 1241 runtime->hw.rates = SNDRV_PCM_RATE_8000; 1242 runtime->hw.rate_min = runtime->hw.rate_max = 8000; 1243 runtime->hw.channels_min = 1; 1244 emu->capture_mic_interrupt = snd_emu10k1_pcm_ac97mic_interrupt; 1245 emu->pcm_capture_mic_substream = substream; 1246 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); 1247 return 0; 1248 } 1249 1250 static int snd_emu10k1_capture_mic_close(snd_pcm_substream_t * substream) 1251 { 1252 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1253 1254 emu->capture_interrupt = NULL; 1255 emu->pcm_capture_mic_substream = NULL; 1256 return 0; 1257 } 1258 1259 static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream) 1260 { 1261 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1262 struct snd_emu10k1_pcm *epcm; 1263 snd_pcm_runtime_t *runtime = substream->runtime; 1264 int nefx = emu->audigy ? 64 : 32; 1265 int idx; 1266 1267 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL); 1268 if (epcm == NULL) 1269 return -ENOMEM; 1270 epcm->emu = emu; 1271 epcm->type = CAPTURE_EFX; 1272 epcm->substream = substream; 1273 epcm->capture_ipr = IPR_EFXBUFFULL|IPR_EFXBUFHALFFULL; 1274 epcm->capture_inte = INTE_EFXBUFENABLE; 1275 epcm->capture_ba_reg = FXBA; 1276 epcm->capture_bs_reg = FXBS; 1277 epcm->capture_idx_reg = FXIDX; 1278 substream->runtime->private_data = epcm; 1279 substream->runtime->private_free = snd_emu10k1_pcm_free_substream; 1280 runtime->hw = snd_emu10k1_capture; 1281 runtime->hw.rates = SNDRV_PCM_RATE_48000; 1282 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1283 spin_lock_irq(&emu->reg_lock); 1284 runtime->hw.channels_min = runtime->hw.channels_max = 0; 1285 for (idx = 0; idx < nefx; idx++) { 1286 if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) { 1287 runtime->hw.channels_min++; 1288 runtime->hw.channels_max++; 1289 } 1290 } 1291 epcm->capture_cr_val = emu->efx_voices_mask[0]; 1292 epcm->capture_cr_val2 = emu->efx_voices_mask[1]; 1293 spin_unlock_irq(&emu->reg_lock); 1294 emu->capture_efx_interrupt = snd_emu10k1_pcm_efx_interrupt; 1295 emu->pcm_capture_efx_substream = substream; 1296 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); 1297 return 0; 1298 } 1299 1300 static int snd_emu10k1_capture_efx_close(snd_pcm_substream_t * substream) 1301 { 1302 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1303 1304 emu->capture_interrupt = NULL; 1305 emu->pcm_capture_efx_substream = NULL; 1306 return 0; 1307 } 1308 1309 static snd_pcm_ops_t snd_emu10k1_playback_ops = { 1310 snd_emu10k1_playback_open, 1311 snd_emu10k1_playback_close, 1312 snd_pcm_lib_ioctl, 1313 snd_emu10k1_playback_hw_params, 1314 snd_emu10k1_playback_hw_free, 1315 snd_emu10k1_playback_prepare, 1316 snd_emu10k1_playback_trigger, 1317 snd_emu10k1_playback_pointer,0,0, 1318 snd_pcm_sgbuf_ops_page,0 1032 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate); 1033 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate); 1034 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate); 1035 } 1036 1037 static void snd_emu10k1_pcm_free_substream(struct snd_pcm_runtime *runtime) 1038 { 1039 kfree(runtime->private_data); 1040 } 1041 1042 static int snd_emu10k1_efx_playback_close(struct snd_pcm_substream *substream) 1043 { 1044 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1045 struct snd_emu10k1_pcm_mixer *mix; 1046 int i; 1047 1048 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 1049 mix = &emu->efx_pcm_mixer[i]; 1050 mix->epcm = NULL; 1051 snd_emu10k1_pcm_efx_mixer_notify(emu, i, 0); 1052 } 1053 return 0; 1054 } 1055 1056 static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream *substream) 1057 { 1058 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1059 struct snd_emu10k1_pcm *epcm; 1060 struct snd_emu10k1_pcm_mixer *mix; 1061 struct snd_pcm_runtime *runtime = substream->runtime; 1062 int i; 1063 1064 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 1065 if (epcm == NULL) 1066 return -ENOMEM; 1067 epcm->emu = emu; 1068 epcm->type = PLAYBACK_EFX; 1069 epcm->substream = substream; 1070 1071 emu->pcm_playback_efx_substream = substream; 1072 1073 runtime->private_data = epcm; 1074 runtime->private_free = snd_emu10k1_pcm_free_substream; 1075 runtime->hw = snd_emu10k1_efx_playback; 1076 1077 for (i = 0; i < NUM_EFX_PLAYBACK; i++) { 1078 mix = &emu->efx_pcm_mixer[i]; 1079 mix->send_routing[0][0] = i; 1080 memset(&mix->send_volume, 0, sizeof(mix->send_volume)); 1081 mix->send_volume[0][0] = 255; 1082 mix->attn[0] = 0xffff; 1083 mix->epcm = epcm; 1084 snd_emu10k1_pcm_efx_mixer_notify(emu, i, 1); 1085 } 1086 return 0; 1087 } 1088 1089 static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) 1090 { 1091 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1092 struct snd_emu10k1_pcm *epcm; 1093 struct snd_emu10k1_pcm_mixer *mix; 1094 struct snd_pcm_runtime *runtime = substream->runtime; 1095 int i, err; 1096 1097 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 1098 if (epcm == NULL) 1099 return -ENOMEM; 1100 epcm->emu = emu; 1101 epcm->type = PLAYBACK_EMUVOICE; 1102 epcm->substream = substream; 1103 runtime->private_data = epcm; 1104 runtime->private_free = snd_emu10k1_pcm_free_substream; 1105 runtime->hw = snd_emu10k1_playback; 1106 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { 1107 kfree(epcm); 1108 return err; 1109 } 1110 if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0) { 1111 kfree(epcm); 1112 return err; 1113 } 1114 mix = &emu->pcm_mixer[substream->number]; 1115 for (i = 0; i < 4; i++) 1116 mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i; 1117 memset(&mix->send_volume, 0, sizeof(mix->send_volume)); 1118 mix->send_volume[0][0] = mix->send_volume[0][1] = 1119 mix->send_volume[1][0] = mix->send_volume[2][1] = 255; 1120 mix->attn[0] = mix->attn[1] = mix->attn[2] = 0xffff; 1121 mix->epcm = epcm; 1122 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1); 1123 return 0; 1124 } 1125 1126 static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream) 1127 { 1128 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1129 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number]; 1130 1131 mix->epcm = NULL; 1132 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0); 1133 return 0; 1134 } 1135 1136 static int snd_emu10k1_capture_open(struct snd_pcm_substream *substream) 1137 { 1138 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1139 struct snd_pcm_runtime *runtime = substream->runtime; 1140 struct snd_emu10k1_pcm *epcm; 1141 1142 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 1143 if (epcm == NULL) 1144 return -ENOMEM; 1145 epcm->emu = emu; 1146 epcm->type = CAPTURE_AC97ADC; 1147 epcm->substream = substream; 1148 epcm->capture_ipr = IPR_ADCBUFFULL|IPR_ADCBUFHALFFULL; 1149 epcm->capture_inte = INTE_ADCBUFENABLE; 1150 epcm->capture_ba_reg = ADCBA; 1151 epcm->capture_bs_reg = ADCBS; 1152 epcm->capture_idx_reg = emu->audigy ? A_ADCIDX : ADCIDX; 1153 runtime->private_data = epcm; 1154 runtime->private_free = snd_emu10k1_pcm_free_substream; 1155 runtime->hw = snd_emu10k1_capture; 1156 emu->capture_interrupt = snd_emu10k1_pcm_ac97adc_interrupt; 1157 emu->pcm_capture_substream = substream; 1158 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); 1159 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_capture_rates); 1160 return 0; 1161 } 1162 1163 static int snd_emu10k1_capture_close(struct snd_pcm_substream *substream) 1164 { 1165 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1166 1167 emu->capture_interrupt = NULL; 1168 emu->pcm_capture_substream = NULL; 1169 return 0; 1170 } 1171 1172 static int snd_emu10k1_capture_mic_open(struct snd_pcm_substream *substream) 1173 { 1174 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1175 struct snd_emu10k1_pcm *epcm; 1176 struct snd_pcm_runtime *runtime = substream->runtime; 1177 1178 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 1179 if (epcm == NULL) 1180 return -ENOMEM; 1181 epcm->emu = emu; 1182 epcm->type = CAPTURE_AC97MIC; 1183 epcm->substream = substream; 1184 epcm->capture_ipr = IPR_MICBUFFULL|IPR_MICBUFHALFFULL; 1185 epcm->capture_inte = INTE_MICBUFENABLE; 1186 epcm->capture_ba_reg = MICBA; 1187 epcm->capture_bs_reg = MICBS; 1188 epcm->capture_idx_reg = emu->audigy ? A_MICIDX : MICIDX; 1189 substream->runtime->private_data = epcm; 1190 substream->runtime->private_free = snd_emu10k1_pcm_free_substream; 1191 runtime->hw = snd_emu10k1_capture; 1192 runtime->hw.rates = SNDRV_PCM_RATE_8000; 1193 runtime->hw.rate_min = runtime->hw.rate_max = 8000; 1194 runtime->hw.channels_min = 1; 1195 emu->capture_mic_interrupt = snd_emu10k1_pcm_ac97mic_interrupt; 1196 emu->pcm_capture_mic_substream = substream; 1197 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); 1198 return 0; 1199 } 1200 1201 static int snd_emu10k1_capture_mic_close(struct snd_pcm_substream *substream) 1202 { 1203 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1204 1205 emu->capture_interrupt = NULL; 1206 emu->pcm_capture_mic_substream = NULL; 1207 return 0; 1208 } 1209 1210 static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream) 1211 { 1212 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1213 struct snd_emu10k1_pcm *epcm; 1214 struct snd_pcm_runtime *runtime = substream->runtime; 1215 int nefx = emu->audigy ? 64 : 32; 1216 int idx; 1217 1218 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 1219 if (epcm == NULL) 1220 return -ENOMEM; 1221 epcm->emu = emu; 1222 epcm->type = CAPTURE_EFX; 1223 epcm->substream = substream; 1224 epcm->capture_ipr = IPR_EFXBUFFULL|IPR_EFXBUFHALFFULL; 1225 epcm->capture_inte = INTE_EFXBUFENABLE; 1226 epcm->capture_ba_reg = FXBA; 1227 epcm->capture_bs_reg = FXBS; 1228 epcm->capture_idx_reg = FXIDX; 1229 substream->runtime->private_data = epcm; 1230 substream->runtime->private_free = snd_emu10k1_pcm_free_substream; 1231 runtime->hw = snd_emu10k1_capture_efx; 1232 runtime->hw.rates = SNDRV_PCM_RATE_48000; 1233 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1234 spin_lock_irq(&emu->reg_lock); 1235 if (emu->card_capabilities->emu1010) { 1236 /* TODO 1237 * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE 1238 * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 1239 * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | 1240 * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 1241 * rate_min = 44100, 1242 * rate_max = 192000, 1243 * channels_min = 8, 1244 * channels_max = 8, 1245 * Need to add mixer control to fix sample rate 1246 * 1247 * There are 16 mono channels of 16bits each. 1248 * 24bit Audio uses 2x channels over 16bit 1249 * 96kHz uses 2x channels over 48kHz 1250 * 192kHz uses 4x channels over 48kHz 1251 * So, for 48kHz 24bit, one has 8 channels 1252 * for 96kHz 24bit, one has 4 channels 1253 * for 192kHz 24bit, one has 2 channels 1254 */ 1255 #if 1 1256 switch (emu->emu1010.internal_clock) { 1257 case 0: 1258 /* For 44.1kHz */ 1259 runtime->hw.rates = SNDRV_PCM_RATE_44100; 1260 runtime->hw.rate_min = runtime->hw.rate_max = 44100; 1261 runtime->hw.channels_min = runtime->hw.channels_max = 8; 1262 break; 1263 case 1: 1264 /* For 48kHz */ 1265 runtime->hw.rates = SNDRV_PCM_RATE_48000; 1266 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1267 runtime->hw.channels_min = runtime->hw.channels_max = 8; 1268 break; 1269 }; 1270 #endif 1271 #if 0 1272 /* For 96kHz */ 1273 runtime->hw.rates = SNDRV_PCM_RATE_96000; 1274 runtime->hw.rate_min = runtime->hw.rate_max = 96000; 1275 runtime->hw.channels_min = runtime->hw.channels_max = 4; 1276 #endif 1277 #if 0 1278 /* For 192kHz */ 1279 runtime->hw.rates = SNDRV_PCM_RATE_192000; 1280 runtime->hw.rate_min = runtime->hw.rate_max = 192000; 1281 runtime->hw.channels_min = runtime->hw.channels_max = 2; 1282 #endif 1283 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; 1284 /* efx_voices_mask[0] is expected to be zero 1285 * efx_voices_mask[1] is expected to have 16bits set 1286 */ 1287 } else { 1288 runtime->hw.channels_min = runtime->hw.channels_max = 0; 1289 for (idx = 0; idx < nefx; idx++) { 1290 if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) { 1291 runtime->hw.channels_min++; 1292 runtime->hw.channels_max++; 1293 } 1294 } 1295 } 1296 epcm->capture_cr_val = emu->efx_voices_mask[0]; 1297 epcm->capture_cr_val2 = emu->efx_voices_mask[1]; 1298 spin_unlock_irq(&emu->reg_lock); 1299 emu->capture_efx_interrupt = snd_emu10k1_pcm_efx_interrupt; 1300 emu->pcm_capture_efx_substream = substream; 1301 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); 1302 return 0; 1303 } 1304 1305 static int snd_emu10k1_capture_efx_close(struct snd_pcm_substream *substream) 1306 { 1307 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1308 1309 emu->capture_interrupt = NULL; 1310 emu->pcm_capture_efx_substream = NULL; 1311 return 0; 1312 } 1313 1314 static struct snd_pcm_ops snd_emu10k1_playback_ops = { 1315 .open = snd_emu10k1_playback_open, 1316 .close = snd_emu10k1_playback_close, 1317 .ioctl = snd_pcm_lib_ioctl, 1318 .hw_params = snd_emu10k1_playback_hw_params, 1319 .hw_free = snd_emu10k1_playback_hw_free, 1320 .prepare = snd_emu10k1_playback_prepare, 1321 .trigger = snd_emu10k1_playback_trigger, 1322 .pointer = snd_emu10k1_playback_pointer, 1323 .page = snd_pcm_sgbuf_ops_page, 1319 1324 }; 1320 1325 1321 static s nd_pcm_ops_tsnd_emu10k1_capture_ops = {1322 1323 1324 1325 1326 1327 1328 1329 snd_emu10k1_capture_pointer,0,0,0,0 1326 static struct snd_pcm_ops snd_emu10k1_capture_ops = { 1327 .open = snd_emu10k1_capture_open, 1328 .close = snd_emu10k1_capture_close, 1329 .ioctl = snd_pcm_lib_ioctl, 1330 .hw_params = snd_emu10k1_capture_hw_params, 1331 .hw_free = snd_emu10k1_capture_hw_free, 1332 .prepare = snd_emu10k1_capture_prepare, 1333 .trigger = snd_emu10k1_capture_trigger, 1334 .pointer = snd_emu10k1_capture_pointer, 1330 1335 }; 1331 1336 1332 1337 /* EFX playback */ 1333 static snd_pcm_ops_t snd_emu10k1_efx_playback_ops = { 1334 /*.open = */ snd_emu10k1_efx_playback_open, 1335 /*.close = */ snd_emu10k1_efx_playback_close, 1336 /*.ioctl = */ snd_pcm_lib_ioctl, 1337 /*.hw_params = */ snd_emu10k1_playback_hw_params, 1338 /*.hw_free = */ snd_emu10k1_efx_playback_hw_free, 1339 /*.prepare = */ snd_emu10k1_efx_playback_prepare, 1340 /*.trigger = */ snd_emu10k1_efx_playback_trigger, 1341 /*.pointer = */ snd_emu10k1_efx_playback_pointer, 1342 0,0, 1343 /*.page = */ snd_pcm_sgbuf_ops_page, 1344 0 1338 static struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { 1339 .open = snd_emu10k1_efx_playback_open, 1340 .close = snd_emu10k1_efx_playback_close, 1341 .ioctl = snd_pcm_lib_ioctl, 1342 .hw_params = snd_emu10k1_playback_hw_params, 1343 .hw_free = snd_emu10k1_efx_playback_hw_free, 1344 .prepare = snd_emu10k1_efx_playback_prepare, 1345 .trigger = snd_emu10k1_efx_playback_trigger, 1346 .pointer = snd_emu10k1_efx_playback_pointer, 1347 .page = snd_pcm_sgbuf_ops_page, 1345 1348 }; 1346 1349 1347 static void snd_emu10k1_pcm_free(snd_pcm_t *pcm) 1348 { 1349 struct snd_emu10k1 *emu = pcm->private_data; 1350 emu->pcm = NULL; 1351 snd_pcm_lib_preallocate_free_for_all(pcm); 1352 } 1353 1354 int __devinit snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, snd_pcm_t ** rpcm) 1355 { 1356 snd_pcm_t *pcm; 1357 snd_pcm_substream_t *substream; 1358 int err; 1359 1360 if (rpcm) 1361 *rpcm = NULL; 1362 1363 if ((err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm)) < 0) 1364 return err; 1365 1366 pcm->private_data = emu; 1367 pcm->private_free = snd_emu10k1_pcm_free; 1368 1369 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_playback_ops); 1370 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_ops); 1371 1372 pcm->info_flags = 0; 1373 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1374 strcpy(pcm->name, "EMU10K1"); 1375 emu->pcm = pcm; 1376 1377 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1378 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1379 return err; 1380 1381 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) 1382 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1383 1384 if (rpcm) 1385 *rpcm = pcm; 1386 1387 return 0; 1388 } 1389 1390 int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, snd_pcm_t ** rpcm) 1391 { 1392 snd_pcm_t *pcm; 1393 snd_pcm_substream_t *substream; 1394 int err; 1395 1396 if (rpcm) 1397 *rpcm = NULL; 1398 1399 if ((err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm)) < 0) 1400 return err; 1401 1402 pcm->private_data = emu; 1403 pcm->private_free = snd_emu10k1_pcm_free; 1404 1405 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_efx_playback_ops); 1406 1407 pcm->info_flags = 0; 1408 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1409 strcpy(pcm->name, "EMU10K1 multichannel EFX"); 1410 emu->pcm = pcm; 1411 1412 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1413 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1414 return err; 1415 1416 if (rpcm) 1417 *rpcm = pcm; 1418 1419 return 0; 1420 } 1421 1422 static snd_pcm_ops_t snd_emu10k1_capture_mic_ops = { 1423 snd_emu10k1_capture_mic_open, 1424 snd_emu10k1_capture_mic_close, 1425 snd_pcm_lib_ioctl, 1426 snd_emu10k1_capture_hw_params, 1427 snd_emu10k1_capture_hw_free, 1428 snd_emu10k1_capture_prepare, 1429 snd_emu10k1_capture_trigger, 1430 snd_emu10k1_capture_pointer,0,0,0,0 1350 int __devinit snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) 1351 { 1352 struct snd_pcm *pcm; 1353 struct snd_pcm_substream *substream; 1354 int err; 1355 1356 if (rpcm) 1357 *rpcm = NULL; 1358 1359 if ((err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm)) < 0) 1360 return err; 1361 1362 pcm->private_data = emu; 1363 1364 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_playback_ops); 1365 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_ops); 1366 1367 pcm->info_flags = 0; 1368 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1369 strcpy(pcm->name, "ADC Capture/Standard PCM Playback"); 1370 emu->pcm = pcm; 1371 1372 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1373 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1374 return err; 1375 1376 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) 1377 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1378 1379 if (rpcm) 1380 *rpcm = pcm; 1381 1382 return 0; 1383 } 1384 1385 int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) 1386 { 1387 struct snd_pcm *pcm; 1388 struct snd_pcm_substream *substream; 1389 int err; 1390 1391 if (rpcm) 1392 *rpcm = NULL; 1393 1394 if ((err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm)) < 0) 1395 return err; 1396 1397 pcm->private_data = emu; 1398 1399 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_efx_playback_ops); 1400 1401 pcm->info_flags = 0; 1402 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1403 strcpy(pcm->name, "Multichannel Playback"); 1404 emu->pcm_multi = pcm; 1405 1406 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1407 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1408 return err; 1409 1410 if (rpcm) 1411 *rpcm = pcm; 1412 1413 return 0; 1414 } 1415 1416 1417 static struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { 1418 .open = snd_emu10k1_capture_mic_open, 1419 .close = snd_emu10k1_capture_mic_close, 1420 .ioctl = snd_pcm_lib_ioctl, 1421 .hw_params = snd_emu10k1_capture_hw_params, 1422 .hw_free = snd_emu10k1_capture_hw_free, 1423 .prepare = snd_emu10k1_capture_prepare, 1424 .trigger = snd_emu10k1_capture_trigger, 1425 .pointer = snd_emu10k1_capture_pointer, 1431 1426 }; 1432 1427 1433 static void snd_emu10k1_pcm_mic_free(snd_pcm_t *pcm) 1434 { 1435 struct snd_emu10k1 *emu = pcm->private_data; 1436 emu->pcm_mic = NULL; 1437 snd_pcm_lib_preallocate_free_for_all(pcm); 1438 } 1439 1440 int __devinit snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, snd_pcm_t ** rpcm) 1441 { 1442 snd_pcm_t *pcm; 1443 int err; 1444 1445 if (rpcm) 1446 *rpcm = NULL; 1447 1448 if ((err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm)) < 0) 1449 return err; 1450 1451 pcm->private_data = emu; 1452 pcm->private_free = snd_emu10k1_pcm_mic_free; 1453 1454 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_mic_ops); 1455 1456 pcm->info_flags = 0; 1457 strcpy(pcm->name, "EMU10K1 MIC"); 1458 emu->pcm_mic = pcm; 1459 1460 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1461 1462 if (rpcm) 1463 *rpcm = pcm; 1464 return 0; 1465 } 1466 1467 1468 static int snd_emu10k1_pcm_efx_voices_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1469 { 1470 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1471 int nefx = emu->audigy ? 64 : 32; 1472 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1473 uinfo->count = nefx; 1474 uinfo->value.integer.min = 0; 1475 uinfo->value.integer.max = 1; 1476 return 0; 1477 } 1478 1479 static int snd_emu10k1_pcm_efx_voices_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1480 { 1481 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1482 int nefx = emu->audigy ? 64 : 32; 1483 int idx; 1484 1485 spin_lock_irq(&emu->reg_lock); 1486 for (idx = 0; idx < nefx; idx++) 1487 ucontrol->value.integer.value[idx] = (emu->efx_voices_mask[idx / 32] & (1 << (idx % 32))) ? 1 : 0; 1488 spin_unlock_irq(&emu->reg_lock); 1489 return 0; 1490 } 1491 1492 static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1493 { 1494 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1495 unsigned int nval[2], bits; 1496 int nefx = emu->audigy ? 64 : 32; 1497 int nefxb = emu->audigy ? 7 : 6; 1498 int change, idx; 1499 1500 nval[0] = nval[1] = 0; 1501 for (idx = 0, bits = 0; idx < nefx; idx++) 1502 if (ucontrol->value.integer.value[idx]) { 1503 nval[idx / 32] |= 1 << (idx % 32); 1504 bits++; 1505 } 1506 for (idx = 0; idx < nefxb; idx++) 1507 if (1 << idx == bits) 1508 break; 1509 if (idx >= nefxb) 1510 return -EINVAL; 1511 spin_lock_irq(&emu->reg_lock); 1512 change = (nval[0] != emu->efx_voices_mask[0]) || 1513 (nval[1] != emu->efx_voices_mask[1]); 1514 emu->efx_voices_mask[0] = nval[0]; 1515 emu->efx_voices_mask[1] = nval[1]; 1516 spin_unlock_irq(&emu->reg_lock); 1517 return change; 1518 } 1519 1520 static snd_kcontrol_new_t snd_emu10k1_pcm_efx_voices_mask = { 1521 SNDRV_CTL_ELEM_IFACE_PCM,0,0, 1522 "Captured FX8010 Outputs",0,0, 0, 1523 snd_emu10k1_pcm_efx_voices_mask_info, 1524 snd_emu10k1_pcm_efx_voices_mask_get, 1525 snd_emu10k1_pcm_efx_voices_mask_put,0 1428 int __devinit snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) 1429 { 1430 struct snd_pcm *pcm; 1431 int err; 1432 1433 if (rpcm) 1434 *rpcm = NULL; 1435 1436 if ((err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm)) < 0) 1437 return err; 1438 1439 pcm->private_data = emu; 1440 1441 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_mic_ops); 1442 1443 pcm->info_flags = 0; 1444 strcpy(pcm->name, "Mic Capture"); 1445 emu->pcm_mic = pcm; 1446 1447 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1448 1449 if (rpcm) 1450 *rpcm = pcm; 1451 return 0; 1452 } 1453 1454 static int snd_emu10k1_pcm_efx_voices_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1455 { 1456 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1457 int nefx = emu->audigy ? 64 : 32; 1458 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1459 uinfo->count = nefx; 1460 uinfo->value.integer.min = 0; 1461 uinfo->value.integer.max = 1; 1462 return 0; 1463 } 1464 1465 static int snd_emu10k1_pcm_efx_voices_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1466 { 1467 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1468 int nefx = emu->audigy ? 64 : 32; 1469 int idx; 1470 1471 spin_lock_irq(&emu->reg_lock); 1472 for (idx = 0; idx < nefx; idx++) 1473 ucontrol->value.integer.value[idx] = (emu->efx_voices_mask[idx / 32] & (1 << (idx % 32))) ? 1 : 0; 1474 spin_unlock_irq(&emu->reg_lock); 1475 return 0; 1476 } 1477 1478 static int snd_emu10k1_pcm_efx_voices_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1479 { 1480 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1481 unsigned int nval[2], bits; 1482 int nefx = emu->audigy ? 64 : 32; 1483 int nefxb = emu->audigy ? 7 : 6; 1484 int change, idx; 1485 1486 nval[0] = nval[1] = 0; 1487 for (idx = 0, bits = 0; idx < nefx; idx++) 1488 if (ucontrol->value.integer.value[idx]) { 1489 nval[idx / 32] |= 1 << (idx % 32); 1490 bits++; 1491 } 1492 1493 for (idx = 0; idx < nefxb; idx++) 1494 if (1 << idx == bits) 1495 break; 1496 1497 if (idx >= nefxb) 1498 return -EINVAL; 1499 1500 spin_lock_irq(&emu->reg_lock); 1501 change = (nval[0] != emu->efx_voices_mask[0]) || 1502 (nval[1] != emu->efx_voices_mask[1]); 1503 emu->efx_voices_mask[0] = nval[0]; 1504 emu->efx_voices_mask[1] = nval[1]; 1505 spin_unlock_irq(&emu->reg_lock); 1506 return change; 1507 } 1508 1509 static struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = { 1510 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1511 .name = "Captured FX8010 Outputs", 1512 .info = snd_emu10k1_pcm_efx_voices_mask_info, 1513 .get = snd_emu10k1_pcm_efx_voices_mask_get, 1514 .put = snd_emu10k1_pcm_efx_voices_mask_put 1526 1515 }; 1527 1516 1528 static s nd_pcm_ops_tsnd_emu10k1_capture_efx_ops = {1529 1530 1531 1532 1533 1534 1535 1536 snd_emu10k1_capture_pointer,0,0,0,0 1517 static struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { 1518 .open = snd_emu10k1_capture_efx_open, 1519 .close = snd_emu10k1_capture_efx_close, 1520 .ioctl = snd_pcm_lib_ioctl, 1521 .hw_params = snd_emu10k1_capture_hw_params, 1522 .hw_free = snd_emu10k1_capture_hw_free, 1523 .prepare = snd_emu10k1_capture_prepare, 1524 .trigger = snd_emu10k1_capture_trigger, 1525 .pointer = snd_emu10k1_capture_pointer, 1537 1526 }; 1538 1527 … … 1545 1534 static void snd_emu10k1_fx8010_playback_irq(struct snd_emu10k1 *emu, void *private_data) 1546 1535 { 1547 snd_pcm_substream_t*substream = private_data;1548 1536 struct snd_pcm_substream *substream = private_data; 1537 snd_pcm_period_elapsed(substream); 1549 1538 } 1550 1539 1551 1540 static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left, 1552 1553 1554 1555 1556 { 1557 // printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 } 1570 1571 1572 static void fx8010_pb_trans_copy(snd_pcm_substream_t *substream, 1573 struct snd_pcm_indirect *rec, size_t bytes) 1574 { 1575 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);1576 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];1577 unsigned int tram_size = pcm->buffer_size;1578 unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data);1579 unsigned int frames = bytes >> 2, count;1580 unsigned int tram_pos = pcm->tram_pos;1581 unsigned int tram_shift = pcm->tram_shift; 1582 1583 while (frames > tram_pos) { 1584 count = tram_pos + 1; 1585 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos,1586 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, 1587 src, count, tram_shift);1588 src += count * 2;1589 frames -= count;1590 tram_pos = (tram_size / 2) - 1;1591 tram_shift++; 1592 } 1593 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos,1594 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, 1595 src, frames, tram_shift);1596 tram_pos -= frames;1597 pcm->tram_pos = tram_pos;1598 pcm->tram_shift = tram_shift; 1599 } 1600 1601 static int snd_emu10k1_fx8010_playback_transfer(snd_pcm_substream_t *substream) 1602 { 1603 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);1604 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1605 1606 snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, fx8010_pb_trans_copy);1607 return 0; 1608 } 1609 1610 static int snd_emu10k1_fx8010_playback_hw_params(snd_pcm_substream_t * substream, 1611 snd_pcm_hw_params_t * hw_params) 1612 { 1613 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1614 } 1615 1616 static int snd_emu10k1_fx8010_playback_hw_free(snd_pcm_substream_t * substream) 1617 { 1618 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);1619 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];1620 unsigned int i; 1621 1622 for (i = 0; i < pcm->channels; i++) 1623 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0);1624 snd_pcm_lib_free_pages(substream);1625 return 0; 1626 } 1627 1628 static int snd_emu10k1_fx8010_playback_prepare(snd_pcm_substream_t * substream) 1629 { 1630 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);1631 snd_pcm_runtime_t *runtime = substream->runtime;1632 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];1633 unsigned int i; 1634 1635 // printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2);1636 memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec)); 1637 pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */ 1638 pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream);1639 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size);1640 pcm->tram_shift = 0; 1641 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_running, 0, 0);/* reset */1642 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); /* reset */ 1643 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_size, 0, runtime->buffer_size); 1644 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_ptr, 0, 0); /* reset ptr number */ 1645 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_count, 0, runtime->period_size);1646 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_tmpcount, 0, runtime->period_size); 1647 for (i = 0; i < pcm->channels; i++) 1648 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, (TANKMEMADDRREG_READ|TANKMEMADDRREG_ALIGN) + i * (runtime->buffer_size / pcm->channels));1649 return 0; 1650 } 1651 1652 static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, int cmd) 1653 { 1654 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);1655 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];1656 int result = 0; 1657 1658 spin_lock(&emu->reg_lock); 1659 switch (cmd) { 1660 case SNDRV_PCM_TRIGGER_START: 1661 /* follow thru */ 1662 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:1541 unsigned short *dst_right, 1542 unsigned short *src, 1543 unsigned int count, 1544 unsigned int tram_shift) 1545 { 1546 /* printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); */ 1547 if ((tram_shift & 1) == 0) { 1548 while (count--) { 1549 *dst_left-- = *src++; 1550 *dst_right-- = *src++; 1551 } 1552 } else { 1553 while (count--) { 1554 *dst_right-- = *src++; 1555 *dst_left-- = *src++; 1556 } 1557 } 1558 } 1559 1560 static void fx8010_pb_trans_copy(struct snd_pcm_substream *substream, 1561 struct snd_pcm_indirect *rec, size_t bytes) 1562 { 1563 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1564 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1565 unsigned int tram_size = pcm->buffer_size; 1566 unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data); 1567 unsigned int frames = bytes >> 2, count; 1568 unsigned int tram_pos = pcm->tram_pos; 1569 unsigned int tram_shift = pcm->tram_shift; 1570 1571 while (frames > tram_pos) { 1572 count = tram_pos + 1; 1573 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos, 1574 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, 1575 src, count, tram_shift); 1576 src += count * 2; 1577 frames -= count; 1578 tram_pos = (tram_size / 2) - 1; 1579 tram_shift++; 1580 } 1581 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos, 1582 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, 1583 src, frames, tram_shift); 1584 tram_pos -= frames; 1585 pcm->tram_pos = tram_pos; 1586 pcm->tram_shift = tram_shift; 1587 } 1588 1589 static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream *substream) 1590 { 1591 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1592 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1593 1594 snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, fx8010_pb_trans_copy); 1595 return 0; 1596 } 1597 1598 static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream, 1599 struct snd_pcm_hw_params *hw_params) 1600 { 1601 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1602 } 1603 1604 static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream) 1605 { 1606 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1607 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1608 unsigned int i; 1609 1610 for (i = 0; i < pcm->channels; i++) 1611 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0); 1612 snd_pcm_lib_free_pages(substream); 1613 return 0; 1614 } 1615 1616 static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substream) 1617 { 1618 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1619 struct snd_pcm_runtime *runtime = substream->runtime; 1620 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1621 unsigned int i; 1622 1623 /* printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); */ 1624 memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec)); 1625 pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */ 1626 pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); 1627 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); 1628 pcm->tram_shift = 0; 1629 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_running, 0, 0); /* reset */ 1630 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); /* reset */ 1631 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_size, 0, runtime->buffer_size); 1632 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_ptr, 0, 0); /* reset ptr number */ 1633 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_count, 0, runtime->period_size); 1634 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_tmpcount, 0, runtime->period_size); 1635 for (i = 0; i < pcm->channels; i++) 1636 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, (TANKMEMADDRREG_READ|TANKMEMADDRREG_ALIGN) + i * (runtime->buffer_size / pcm->channels)); 1637 return 0; 1638 } 1639 1640 static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substream, int cmd) 1641 { 1642 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1643 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1644 int result = 0; 1645 1646 spin_lock(&emu->reg_lock); 1647 switch (cmd) { 1648 case SNDRV_PCM_TRIGGER_START: 1649 /* follow thru */ 1650 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1651 case SNDRV_PCM_TRIGGER_RESUME: 1663 1652 #ifdef EMU10K1_SET_AC3_IEC958 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1653 { 1654 int i; 1655 for (i = 0; i < 3; i++) { 1656 unsigned int bits; 1657 bits = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 1658 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 1659 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT | SPCS_NOTAUDIODATA; 1660 snd_emu10k1_ptr_write(emu, SPCS0 + i, 0, bits); 1661 } 1662 } 1674 1663 #endif 1675 result = snd_emu10k1_fx8010_register_irq_handler(emu, snd_emu10k1_fx8010_playback_irq, pcm->gpr_running, substream, &pcm->irq); 1676 if (result < 0) 1677 goto __err; 1678 snd_emu10k1_fx8010_playback_transfer(substream); /* roll the ball */ 1679 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 1); 1680 break; 1681 case SNDRV_PCM_TRIGGER_STOP: 1682 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1683 snd_emu10k1_fx8010_unregister_irq_handler(emu, pcm->irq); pcm->irq = NULL; 1684 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); 1685 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); 1686 pcm->tram_shift = 0; 1687 break; 1688 default: 1689 result = -EINVAL; 1690 break; 1691 } 1692 __err: 1693 spin_unlock(&emu->reg_lock); 1694 return result; 1695 } 1696 1697 static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(snd_pcm_substream_t * substream) 1698 { 1699 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1700 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1701 size_t ptr; /* byte pointer */ 1702 1703 if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0)) 1704 return 0; 1705 ptr = snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_ptr, 0) << 2; 1706 return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); 1664 result = snd_emu10k1_fx8010_register_irq_handler(emu, snd_emu10k1_fx8010_playback_irq, pcm->gpr_running, substream, &pcm->irq); 1665 if (result < 0) 1666 goto __err; 1667 snd_emu10k1_fx8010_playback_transfer(substream); /* roll the ball */ 1668 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 1); 1669 break; 1670 case SNDRV_PCM_TRIGGER_STOP: 1671 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1672 case SNDRV_PCM_TRIGGER_SUSPEND: 1673 snd_emu10k1_fx8010_unregister_irq_handler(emu, pcm->irq); pcm->irq = NULL; 1674 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); 1675 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); 1676 pcm->tram_shift = 0; 1677 break; 1678 default: 1679 result = -EINVAL; 1680 break; 1681 } 1682 __err: 1683 spin_unlock(&emu->reg_lock); 1684 return result; 1685 } 1686 1687 static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_substream *substream) 1688 { 1689 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1690 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1691 size_t ptr; /* byte pointer */ 1692 1693 if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0)) 1694 return 0; 1695 ptr = snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_ptr, 0) << 2; 1696 return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); 1707 1697 } 1708 1698 1709 1699 static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = 1710 1700 { 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1701 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1702 SNDRV_PCM_INFO_RESUME | 1703 /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE), 1704 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, 1705 .rates = SNDRV_PCM_RATE_48000, 1706 .rate_min = 48000, 1707 .rate_max = 48000, 1708 .channels_min = 1, 1709 .channels_max = 1, 1710 .buffer_bytes_max = (128*1024), 1711 .period_bytes_min = 1024, 1712 .period_bytes_max = (128*1024), 1713 .periods_min = 1, 1714 .periods_max = 1024, 1715 .fifo_size = 0, 1726 1716 }; 1727 1717 1728 static int snd_emu10k1_fx8010_playback_open(s nd_pcm_substream_t *substream)1729 { 1730 1731 snd_pcm_runtime_t*runtime = substream->runtime;1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 } 1746 1747 static int snd_emu10k1_fx8010_playback_close(s nd_pcm_substream_t *substream)1748 { 1749 1750 1751 1752 1753 1754 1755 1718 static int snd_emu10k1_fx8010_playback_open(struct snd_pcm_substream *substream) 1719 { 1720 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1721 struct snd_pcm_runtime *runtime = substream->runtime; 1722 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1723 1724 runtime->hw = snd_emu10k1_fx8010_playback; 1725 runtime->hw.channels_min = runtime->hw.channels_max = pcm->channels; 1726 runtime->hw.period_bytes_max = (pcm->buffer_size * 2) / 2; 1727 spin_lock_irq(&emu->reg_lock); 1728 if (pcm->valid == 0) { 1729 spin_unlock_irq(&emu->reg_lock); 1730 return -ENODEV; 1731 } 1732 pcm->opened = 1; 1733 spin_unlock_irq(&emu->reg_lock); 1734 return 0; 1735 } 1736 1737 static int snd_emu10k1_fx8010_playback_close(struct snd_pcm_substream *substream) 1738 { 1739 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 1740 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; 1741 1742 spin_lock_irq(&emu->reg_lock); 1743 pcm->opened = 0; 1744 spin_unlock_irq(&emu->reg_lock); 1745 return 0; 1756 1746 } 1757 1747 … … 1768 1758 }; 1769 1759 1770 static void snd_emu10k1_pcm_efx_free(snd_pcm_t *pcm) 1771 { 1772 struct snd_emu10k1 *emu = pcm->private_data; 1773 emu->pcm_efx = NULL; 1774 snd_pcm_lib_preallocate_free_for_all(pcm); 1775 } 1776 1777 int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, snd_pcm_t ** rpcm) 1778 { 1779 snd_pcm_t *pcm; 1780 snd_kcontrol_t *kctl; 1781 int err; 1782 1783 if (rpcm) 1784 *rpcm = NULL; 1785 1786 if ((err = snd_pcm_new(emu->card, "emu10k1 efx", device, 8, 1, &pcm)) < 0) 1787 return err; 1788 1789 pcm->private_data = emu; 1790 pcm->private_free = snd_emu10k1_pcm_efx_free; 1791 1792 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_fx8010_playback_ops); 1793 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_efx_ops); 1794 1795 pcm->info_flags = 0; 1796 strcpy(pcm->name, "EMU10K1 EFX"); 1797 emu->pcm_efx = pcm; 1798 if (rpcm) 1799 *rpcm = pcm; 1800 1801 /* EFX capture - record the "FXBUS2" channels, by default we connect the EXTINs 1802 * to these 1803 */ 1804 1805 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */ 1806 if (emu->audigy) { 1807 emu->efx_voices_mask[0] = 0; 1808 emu->efx_voices_mask[1] = 0xffff; 1809 } else { 1810 emu->efx_voices_mask[0] = 0xffff0000; 1811 emu->efx_voices_mask[1] = 0; 1812 } 1813 1814 kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu); 1815 if (!kctl) 1816 return -ENOMEM; 1817 kctl->id.device = device; 1818 snd_ctl_add(emu->card, kctl); 1819 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1820 1821 return 0; 1822 } 1823 1760 int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) 1761 { 1762 struct snd_pcm *pcm; 1763 struct snd_kcontrol *kctl; 1764 int err; 1765 1766 if (rpcm) 1767 *rpcm = NULL; 1768 1769 if ((err = snd_pcm_new(emu->card, "emu10k1 efx", device, 8, 1, &pcm)) < 0) 1770 return err; 1771 1772 pcm->private_data = emu; 1773 1774 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_fx8010_playback_ops); 1775 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_efx_ops); 1776 1777 pcm->info_flags = 0; 1778 strcpy(pcm->name, "Multichannel Capture/PT Playback"); 1779 emu->pcm_efx = pcm; 1780 if (rpcm) 1781 *rpcm = pcm; 1782 1783 /* EFX capture - record the "FXBUS2" channels, by default we connect the EXTINs 1784 * to these 1785 */ 1786 1787 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */ 1788 if (emu->audigy) { 1789 emu->efx_voices_mask[0] = 0; 1790 emu->efx_voices_mask[1] = 0xffff; 1791 } else { 1792 emu->efx_voices_mask[0] = 0xffff0000; 1793 emu->efx_voices_mask[1] = 0; 1794 } 1795 kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu); 1796 if (!kctl) 1797 return -ENOMEM; 1798 kctl->id.device = device; 1799 snd_ctl_add(emu->card, kctl); 1800 1801 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1802 1803 return 0; 1804 } -
GPL/trunk/alsa-kernel/pci/emu10k1/io.c
r34 r84 26 26 */ 27 27 28 #define __NO_VERSION__29 28 #include <sound/driver.h> 30 29 #include <linux/time.h> … … 62 61 } 63 62 } 63 64 EXPORT_SYMBOL(snd_emu10k1_ptr_read); 64 65 65 66 void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data) … … 93 94 } 94 95 96 EXPORT_SYMBOL(snd_emu10k1_ptr_write); 97 95 98 unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, 96 99 unsigned int reg, … … 123 126 outl(data, emu->port + 0x20 + DATA); 124 127 spin_unlock_irqrestore(&emu->emu_lock, flags); 128 } 129 130 int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, 131 unsigned int data) 132 { 133 unsigned int reset, set; 134 unsigned int reg, tmp; 135 int n, result; 136 if (emu->card_capabilities->ca0108_chip) 137 reg = 0x3c; /* PTR20, reg 0x3c */ 138 else { 139 /* For other chip types the SPI register 140 * is currently unknown. */ 141 return 1; 142 } 143 if (data > 0xffff) /* Only 16bit values allowed */ 144 return 1; 145 146 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); 147 reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ 148 set = reset | 0x10000; /* Set xxx1xxxx */ 149 snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); 150 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* write post */ 151 snd_emu10k1_ptr20_write(emu, reg, 0, set | data); 152 result = 1; 153 /* Wait for status bit to return to 0 */ 154 for (n = 0; n < 100; n++) { 155 udelay(10); 156 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); 157 if (!(tmp & 0x10000)) { 158 result = 0; 159 break; 160 } 161 } 162 if (result) /* Timed out */ 163 return 1; 164 snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); 165 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* Write post */ 166 return 0; 167 } 168 169 int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value) 170 { 171 if (reg < 0 || reg > 0x3f) 172 return 1; 173 reg += 0x40; /* 0x40 upwards are registers. */ 174 if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */ 175 return 1; 176 outl(reg, emu->port + A_IOCFG); 177 udelay(10); 178 outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 179 udelay(10); 180 outl(value, emu->port + A_IOCFG); 181 udelay(10); 182 outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 183 184 return 0; 185 } 186 187 int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) 188 { 189 if (reg < 0 || reg > 0x3f) 190 return 1; 191 reg += 0x40; /* 0x40 upwards are registers. */ 192 outl(reg, emu->port + A_IOCFG); 193 udelay(10); 194 outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 195 udelay(10); 196 *value = ((inl(emu->port + A_IOCFG) >> 8) & 0x7f); 197 198 return 0; 199 } 200 201 /* Each Destination has one and only one Source, 202 * but one Source can feed any number of Destinations simultaneously. 203 */ 204 int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src) 205 { 206 snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) ); 207 snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) ); 208 snd_emu1010_fpga_write(emu, 0x02, ((src >> 8) & 0x3f) ); 209 snd_emu1010_fpga_write(emu, 0x03, (src & 0x3f) ); 210 211 return 0; 125 212 } 126 213 … … 320 407 } 321 408 322 unsigned short snd_emu10k1_ac97_read( ac97_t*ac97, unsigned short reg)409 unsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg) 323 410 { 324 411 struct snd_emu10k1 *emu = ac97->private_data; … … 333 420 } 334 421 335 void snd_emu10k1_ac97_write( ac97_t*ac97, unsigned short reg, unsigned short data)422 void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data) 336 423 { 337 424 struct snd_emu10k1 *emu = ac97->private_data; … … 403 490 return 0; /* Should never reach this point */ 404 491 } 405 406 /*407 * Returns an attenuation based upon a cumulative volume value408 * Algorithm calculates 0x200 - 0x10 log2 (input)409 */410 411 unsigned char snd_emu10k1_sum_vol_attn(unsigned int value)412 {413 unsigned short count = 16, ans;414 415 if (value == 0)416 return 0xFF;417 418 /* Find first SET bit. This is the integer part of the value */419 while ((value & 0x10000) == 0) {420 value <<= 1;421 count--;422 }423 424 /* The REST of the data is the fractional part. */425 ans = (unsigned short) (0x110 - ((count << 4) + ((value & 0x0FFFFL) >> 12)));426 if (ans > 0xFF)427 ans = 0xFF;428 429 return (unsigned char) ans;430 } -
GPL/trunk/alsa-kernel/pci/emu10k1/irq.c
r34 r84 32 32 #include <sound/emu10k1.h> 33 33 34 irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id , struct pt_regs *regs)34 irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id) 35 35 { 36 36 struct snd_emu10k1 *emu = dev_id; 37 37 unsigned int status, status2, orig_status, orig_status2; 38 38 int handled = 0; 39 #ifdef TARGET_OS240 int fOurIrq = FALSE;41 #endif42 39 43 40 while ((status = inl(emu->port + IPR)) != 0) { 44 // printk("irq - status = 0x%x\n", status); 45 #ifdef TARGET_OS2 46 #if 1 47 if (status & (IPR_CHANNELNUMBERMASK|IPR_A_MIDITRANSBUFEMPTY2|IPR_A_MIDIRECVBUFEMPTY2| 48 IPR_SAMPLERATETRACKER|IPR_FXDSP|IPR_FORCEINT|IPR_PCIERROR|IPR_VOLINCR| 49 IPR_VOLDECR|IPR_MUTE|IPR_MICBUFFULL|IPR_MICBUFHALFFULL|IPR_ADCBUFFULL| 50 IPR_ADCBUFHALFFULL|IPR_EFXBUFFULL|IPR_EFXBUFHALFFULL|IPR_GPSPDIFSTATUSCHANGE| 51 IPR_CDROMSTATUSCHANGE|IPR_INTERVALTIMER|IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY| 52 IPR_CHANNELLOOP)) 53 #else 54 if (status) 55 #endif 56 { 57 fOurIrq = TRUE; 58 } 59 #endif 41 //snd_printk(KERN_INFO "emu10k1 irq - status = 0x%x\n", status); 60 42 orig_status = status; 61 43 handled = 1; 44 if ((status & 0xffffffff) == 0xffffffff) { 45 snd_printk(KERN_INFO "snd-emu10k1: Suspected sound card removal\n"); 46 break; 47 } 62 48 if (status & IPR_PCIERROR) { 63 //snd_printk("interrupt: PCI error\n");49 snd_printk("interrupt: PCI error\n"); 64 50 snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE); 65 51 status &= ~IPR_PCIERROR; -
GPL/trunk/alsa-kernel/pci/emu10k1/memory.c
r34 r84 65 65 /* do not increment ptr */ 66 66 __set_ptb_entry(emu, page, emu->silent_page.addr); 67 // __set_ptb_entry(emu, page, emu->silent_page_dmaaddr);68 67 } 69 68 #endif /* PAGE_SIZE */ … … 290 289 * page allocation for DMA 291 290 */ 292 s nd_util_memblk_t*293 snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, s nd_pcm_substream_t*substream)294 { 295 s nd_pcm_runtime_t*runtime = substream->runtime;291 struct snd_util_memblk * 292 snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream) 293 { 294 struct snd_pcm_runtime *runtime = substream->runtime; 296 295 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); 297 s nd_util_memhdr_t*hdr;296 struct snd_util_memhdr *hdr; 298 297 struct snd_emu10k1_memblk *blk; 299 298 int page, err, idx; … … 338 337 err = snd_emu10k1_memblk_map(emu, blk); 339 338 if (err < 0) { 340 __snd_util_mem_free(hdr, (s nd_util_memblk_t*)blk);339 __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); 341 340 up(&hdr->block_mutex); 342 341 return NULL; 343 342 } 344 343 up(&hdr->block_mutex); 345 return (s nd_util_memblk_t*)blk;344 return (struct snd_util_memblk *)blk; 346 345 } 347 346 … … 350 349 * release DMA buffer from page table 351 350 */ 352 int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, s nd_util_memblk_t*blk)351 int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) 353 352 { 354 353 snd_assert(emu && blk, return -EINVAL); … … 365 364 * allocate a synth sample area 366 365 */ 367 s nd_util_memblk_t*366 struct snd_util_memblk * 368 367 snd_emu10k1_synth_alloc(struct snd_emu10k1 *hw, unsigned int size) 369 368 { 370 371 snd_util_memhdr_t *hdr = hw->memhdr; 369 struct snd_emu10k1_memblk *blk; 370 struct snd_util_memhdr *hdr = hw->memhdr; 372 371 373 372 down(&hdr->block_mutex); … … 377 376 return NULL; 378 377 } 379 380 __snd_util_mem_free(hdr, (snd_util_memblk_t*)blk);378 if (synth_alloc_pages(hw, blk)) { 379 __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); 381 380 up(&hdr->block_mutex); 382 381 return NULL; … … 384 383 snd_emu10k1_memblk_map(hw, blk); 385 384 up(&hdr->block_mutex); 386 return (s nd_util_memblk_t*)blk;385 return (struct snd_util_memblk *)blk; 387 386 } 388 387 -
GPL/trunk/alsa-kernel/pci/emu10k1/p16v.c
r34 r84 100 100 #include <sound/ac97_codec.h> 101 101 #include <sound/info.h> 102 #include <sound/tlv.h> 102 103 #include <sound/emu10k1.h> 103 104 #include "p16v.h" … … 107 108 #define PCM_REAR_CHANNEL 1 108 109 #define PCM_CENTER_LFE_CHANNEL 2 109 #define PCM_ UNKNOWN_CHANNEL 3110 #define PCM_SIDE_CHANNEL 3 110 111 #define CONTROL_FRONT_CHANNEL 0 111 112 #define CONTROL_REAR_CHANNEL 3 112 113 #define CONTROL_CENTER_LFE_CHANNEL 1 113 #define CONTROL_ UNKNOWN_CHANNEL 2114 #define CONTROL_SIDE_CHANNEL 2 114 115 115 116 /* Card IDs: … … 122 123 123 124 /* hardware definition */ 124 static snd_pcm_hardware_t snd_p16v_playback_hw = { 125 /*.info = */ (SNDRV_PCM_INFO_MMAP | 126 SNDRV_PCM_INFO_INTERLEAVED | 127 SNDRV_PCM_INFO_BLOCK_TRANSFER | 128 SNDRV_PCM_INFO_MMAP_VALID), 129 /* .formats = */ SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ 130 /* .rates = */ SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, 131 /* .rate_min = */ 44100, 132 /* .rate_max = */ 192000, 133 /* .channels_min = */ 8, 134 /* .channels_max = */ 8, 135 /* .buffer_bytes_max =*/ ((65536 - 64) * 8), 136 /* .period_bytes_min =*/ 64, 137 /* .period_bytes_max =*/ (65536 - 64), 138 /* .periods_min = */ 2, 139 /* .periods_max = */ 8, 140 /* .fifo_size = */ 0 125 static struct snd_pcm_hardware snd_p16v_playback_hw = { 126 .info = (SNDRV_PCM_INFO_MMAP | 127 SNDRV_PCM_INFO_INTERLEAVED | 128 SNDRV_PCM_INFO_BLOCK_TRANSFER | 129 SNDRV_PCM_INFO_RESUME | 130 SNDRV_PCM_INFO_MMAP_VALID), 131 .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ 132 .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, 133 .rate_min = 44100, 134 .rate_max = 192000, 135 .channels_min = 8, 136 .channels_max = 8, 137 .buffer_bytes_max = ((65536 - 64) * 8), 138 .period_bytes_min = 64, 139 .period_bytes_max = (65536 - 64), 140 .periods_min = 2, 141 .periods_max = 8, 142 .fifo_size = 0, 141 143 }; 142 144 143 static snd_pcm_hardware_t snd_p16v_capture_hw = { 144 /*.info = */ (SNDRV_PCM_INFO_MMAP | 145 SNDRV_PCM_INFO_INTERLEAVED | 146 SNDRV_PCM_INFO_BLOCK_TRANSFER | 147 SNDRV_PCM_INFO_MMAP_VALID), 148 /* .formats = */ SNDRV_PCM_FMTBIT_S32_LE, 149 /* .rates = */ SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, 150 /* .rate_min = */ 44100, 151 /* .rate_max = */ 192000, 152 /* .channels_min = */ 2, 153 /* .channels_max = */ 2, 154 /* .buffer_bytes_max = */ (65536 - 64), 155 /* .period_bytes_min = */ 64, 156 /* .period_bytes_max = */ (65536 - 128) >> 1, /* size has to be N*64 bytes */ 157 /* .periods_min = */ 2, 158 /* .periods_max = */ 2, 159 /* .fifo_size = */ 0 145 static struct snd_pcm_hardware snd_p16v_capture_hw = { 146 .info = (SNDRV_PCM_INFO_MMAP | 147 SNDRV_PCM_INFO_INTERLEAVED | 148 SNDRV_PCM_INFO_BLOCK_TRANSFER | 149 SNDRV_PCM_INFO_RESUME | 150 SNDRV_PCM_INFO_MMAP_VALID), 151 .formats = SNDRV_PCM_FMTBIT_S32_LE, 152 .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, 153 .rate_min = 44100, 154 .rate_max = 192000, 155 .channels_min = 2, 156 .channels_max = 2, 157 .buffer_bytes_max = (65536 - 64), 158 .period_bytes_min = 64, 159 .period_bytes_max = (65536 - 128) >> 1, /* size has to be N*64 bytes */ 160 .periods_min = 2, 161 .periods_max = 2, 162 .fifo_size = 0, 160 163 }; 161 164 162 static void snd_p16v_pcm_free_substream(s nd_pcm_runtime_t*runtime)165 static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime) 163 166 { 164 167 struct snd_emu10k1_pcm *epcm = runtime->private_data; … … 171 174 172 175 /* open_playback callback */ 173 static int snd_p16v_pcm_open_playback_channel(s nd_pcm_substream_t*substream, int channel_id)176 static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substream, int channel_id) 174 177 { 175 178 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 176 179 struct snd_emu10k1_voice *channel = &(emu->p16v_voices[channel_id]); 177 180 struct snd_emu10k1_pcm *epcm; 178 s nd_pcm_runtime_t*runtime = substream->runtime;181 struct snd_pcm_runtime *runtime = substream->runtime; 179 182 int err; 180 183 181 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL);184 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 182 185 //snd_printk("epcm kcalloc: %p\n", epcm); 183 186 … … 208 211 209 212 /* open_capture callback */ 210 static int snd_p16v_pcm_open_capture_channel(s nd_pcm_substream_t*substream, int channel_id)213 static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream, int channel_id) 211 214 { 212 215 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 213 216 struct snd_emu10k1_voice *channel = &(emu->p16v_capture_voice); 214 217 struct snd_emu10k1_pcm *epcm; 215 s nd_pcm_runtime_t*runtime = substream->runtime;218 struct snd_pcm_runtime *runtime = substream->runtime; 216 219 int err; 217 220 218 epcm = (struct snd_emu10k1_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL);221 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 219 222 //snd_printk("epcm kcalloc: %p\n", epcm); 220 223 … … 246 249 247 250 /* close callback */ 248 static int snd_p16v_pcm_close_playback(s nd_pcm_substream_t*substream)249 { 250 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 251 //s nd_pcm_runtime_t*runtime = substream->runtime;251 static int snd_p16v_pcm_close_playback(struct snd_pcm_substream *substream) 252 { 253 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 254 //struct snd_pcm_runtime *runtime = substream->runtime; 252 255 //struct snd_emu10k1_pcm *epcm = runtime->private_data; 253 256 emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; … … 257 260 258 261 /* close callback */ 259 static int snd_p16v_pcm_close_capture(s nd_pcm_substream_t*substream)260 { 261 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 262 //s nd_pcm_runtime_t*runtime = substream->runtime;262 static int snd_p16v_pcm_close_capture(struct snd_pcm_substream *substream) 263 { 264 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 265 //struct snd_pcm_runtime *runtime = substream->runtime; 263 266 //struct snd_emu10k1_pcm *epcm = runtime->private_data; 264 267 emu->p16v_capture_voice.use=0; … … 267 270 } 268 271 269 static int snd_p16v_pcm_open_playback_front(s nd_pcm_substream_t*substream)272 static int snd_p16v_pcm_open_playback_front(struct snd_pcm_substream *substream) 270 273 { 271 274 return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); 272 275 } 273 276 274 static int snd_p16v_pcm_open_capture(s nd_pcm_substream_t*substream)277 static int snd_p16v_pcm_open_capture(struct snd_pcm_substream *substream) 275 278 { 276 279 // Only using channel 0 for now, but the card has 2 channels. … … 279 282 280 283 /* hw_params callback */ 281 static int snd_p16v_pcm_hw_params_playback(s nd_pcm_substream_t*substream,282 snd_pcm_hw_params_t *hw_params)284 static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream, 285 struct snd_pcm_hw_params *hw_params) 283 286 { 284 287 int result; … … 289 292 290 293 /* hw_params callback */ 291 static int snd_p16v_pcm_hw_params_capture(s nd_pcm_substream_t*substream,292 snd_pcm_hw_params_t *hw_params)294 static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream, 295 struct snd_pcm_hw_params *hw_params) 293 296 { 294 297 int result; … … 300 303 301 304 /* hw_free callback */ 302 static int snd_p16v_pcm_hw_free_playback(s nd_pcm_substream_t*substream)305 static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream) 303 306 { 304 307 int result; … … 308 311 309 312 /* hw_free callback */ 310 static int snd_p16v_pcm_hw_free_capture(s nd_pcm_substream_t*substream)313 static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream) 311 314 { 312 315 int result; … … 317 320 318 321 /* prepare playback callback */ 319 static int snd_p16v_pcm_prepare_playback(s nd_pcm_substream_t*substream)320 { 321 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 322 s nd_pcm_runtime_t*runtime = substream->runtime;322 static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) 323 { 324 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 325 struct snd_pcm_runtime *runtime = substream->runtime; 323 326 int channel = substream->pcm->device - emu->p16v_device_offset; 324 327 u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel)); … … 366 369 367 370 /* prepare capture callback */ 368 static int snd_p16v_pcm_prepare_capture(s nd_pcm_substream_t*substream)369 { 370 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 371 s nd_pcm_runtime_t*runtime = substream->runtime;371 static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream) 372 { 373 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 374 struct snd_pcm_runtime *runtime = substream->runtime; 372 375 int channel = substream->pcm->device - emu->p16v_device_offset; 373 376 u32 tmp; … … 423 426 424 427 /* trigger_playback callback */ 425 static int snd_p16v_pcm_trigger_playback(s nd_pcm_substream_t*substream,428 static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream, 426 429 int cmd) 427 430 { 428 431 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 429 s nd_pcm_runtime_t*runtime;432 struct snd_pcm_runtime *runtime; 430 433 struct snd_emu10k1_pcm *epcm; 431 434 int channel; 432 435 int result = 0; 433 436 struct list_head *pos; 434 s nd_pcm_substream_t*s;437 struct snd_pcm_substream *s; 435 438 u32 basic = 0; 436 439 u32 inte = 0; … … 476 479 477 480 /* trigger_capture callback */ 478 static int snd_p16v_pcm_trigger_capture(s nd_pcm_substream_t*substream,481 static int snd_p16v_pcm_trigger_capture(struct snd_pcm_substream *substream, 479 482 int cmd) 480 483 { 481 484 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 482 s nd_pcm_runtime_t*runtime = substream->runtime;485 struct snd_pcm_runtime *runtime = substream->runtime; 483 486 struct snd_emu10k1_pcm *epcm = runtime->private_data; 484 487 int channel = 0; … … 507 510 /* pointer_playback callback */ 508 511 static snd_pcm_uframes_t 509 snd_p16v_pcm_pointer_playback(s nd_pcm_substream_t*substream)510 { 511 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 512 s nd_pcm_runtime_t*runtime = substream->runtime;512 snd_p16v_pcm_pointer_playback(struct snd_pcm_substream *substream) 513 { 514 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 515 struct snd_pcm_runtime *runtime = substream->runtime; 513 516 struct snd_emu10k1_pcm *epcm = runtime->private_data; 514 517 snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; … … 532 535 /* pointer_capture callback */ 533 536 static snd_pcm_uframes_t 534 snd_p16v_pcm_pointer_capture(s nd_pcm_substream_t*substream)535 { 536 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 537 s nd_pcm_runtime_t*runtime = substream->runtime;537 snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream) 538 { 539 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); 540 struct snd_pcm_runtime *runtime = substream->runtime; 538 541 struct snd_emu10k1_pcm *epcm = runtime->private_data; 539 542 snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; … … 556 559 557 560 /* operators */ 558 static snd_pcm_ops_t snd_p16v_playback_front_ops = { 559 /*.open = */snd_p16v_pcm_open_playback_front, 560 /*.close = */snd_p16v_pcm_close_playback, 561 /*.ioctl = */snd_pcm_lib_ioctl, 562 /*.hw_params = */snd_p16v_pcm_hw_params_playback, 563 /*.hw_free = */snd_p16v_pcm_hw_free_playback, 564 /*.prepare = */snd_p16v_pcm_prepare_playback, 565 /*.trigger = */snd_p16v_pcm_trigger_playback, 566 /*.pointer = */snd_p16v_pcm_pointer_playback, 567 0,0,0,0 561 static struct snd_pcm_ops snd_p16v_playback_front_ops = { 562 .open = snd_p16v_pcm_open_playback_front, 563 .close = snd_p16v_pcm_close_playback, 564 .ioctl = snd_pcm_lib_ioctl, 565 .hw_params = snd_p16v_pcm_hw_params_playback, 566 .hw_free = snd_p16v_pcm_hw_free_playback, 567 .prepare = snd_p16v_pcm_prepare_playback, 568 .trigger = snd_p16v_pcm_trigger_playback, 569 .pointer = snd_p16v_pcm_pointer_playback, 568 570 }; 569 571 570 static snd_pcm_ops_t snd_p16v_capture_ops = { 571 /*.open = */snd_p16v_pcm_open_capture, 572 /*.close = */snd_p16v_pcm_close_capture, 573 /*.ioctl = */snd_pcm_lib_ioctl, 574 /*.hw_params = */snd_p16v_pcm_hw_params_capture, 575 /*.hw_free = */snd_p16v_pcm_hw_free_capture, 576 /*.prepare = */snd_p16v_pcm_prepare_capture, 577 /*.trigger = */snd_p16v_pcm_trigger_capture, 578 /*.pointer = */snd_p16v_pcm_pointer_capture, 579 0,0,0,0 572 static struct snd_pcm_ops snd_p16v_capture_ops = { 573 .open = snd_p16v_pcm_open_capture, 574 .close = snd_p16v_pcm_close_capture, 575 .ioctl = snd_pcm_lib_ioctl, 576 .hw_params = snd_p16v_pcm_hw_params_capture, 577 .hw_free = snd_p16v_pcm_hw_free_capture, 578 .prepare = snd_p16v_pcm_prepare_capture, 579 .trigger = snd_p16v_pcm_trigger_capture, 580 .pointer = snd_p16v_pcm_pointer_capture, 580 581 }; 581 582 … … 590 591 } 591 592 592 static void snd_p16v_pcm_free(snd_pcm_t *pcm) 593 { 594 struct snd_emu10k1 *emu = pcm->private_data; 595 //snd_printk("snd_p16v_pcm_free pcm: called\n"); 596 snd_pcm_lib_preallocate_free_for_all(pcm); 597 emu->pcm = NULL; 598 } 599 600 int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, snd_pcm_t **rpcm) 601 { 602 snd_pcm_t *pcm; 603 snd_pcm_substream_t *substream; 593 int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) 594 { 595 struct snd_pcm *pcm; 596 struct snd_pcm_substream *substream; 604 597 int err; 605 598 int capture=1; … … 613 606 614 607 pcm->private_data = emu; 615 pcm->private_free = snd_p16v_pcm_free;616 608 // Single playback 8 channel device. 617 609 // Single capture 2 channel device. … … 622 614 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 623 615 strcpy(pcm->name, "p16v"); 624 emu->pcm = pcm;616 emu->pcm_p16v = pcm; 625 617 626 618 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; … … 652 644 } 653 645 654 static int snd_p16v_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 655 { 656 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 657 uinfo->count = 2; 658 uinfo->value.integer.min = 0; 659 uinfo->value.integer.max = 255; 660 return 0; 661 } 662 663 static int snd_p16v_volume_get(snd_kcontrol_t * kcontrol, 664 snd_ctl_elem_value_t * ucontrol, int reg, int high_low) 665 { 666 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 667 u32 value; 668 669 value = snd_emu10k1_ptr20_read(emu, reg, high_low); 670 if (high_low == 1) { 671 ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ 672 ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */ 673 } else { 674 ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */ 675 ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */ 676 } 677 return 0; 678 } 679 680 static int snd_p16v_volume_get_spdif_front(snd_kcontrol_t * kcontrol, 681 snd_ctl_elem_value_t * ucontrol) 682 { 683 int high_low = 0; 684 int reg = PLAYBACK_VOLUME_MIXER7; 685 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 686 } 687 688 static int snd_p16v_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol, 689 snd_ctl_elem_value_t * ucontrol) 690 { 691 int high_low = 1; 692 int reg = PLAYBACK_VOLUME_MIXER7; 693 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 694 } 695 static int snd_p16v_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol, 696 snd_ctl_elem_value_t * ucontrol) 697 { 698 int high_low = 0; 699 int reg = PLAYBACK_VOLUME_MIXER8; 700 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 701 } 702 static int snd_p16v_volume_get_spdif_rear(snd_kcontrol_t * kcontrol, 703 snd_ctl_elem_value_t * ucontrol) 704 { 705 int high_low = 1; 706 int reg = PLAYBACK_VOLUME_MIXER8; 707 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 708 } 709 710 static int snd_p16v_volume_get_analog_front(snd_kcontrol_t * kcontrol, 711 snd_ctl_elem_value_t * ucontrol) 712 { 713 int high_low = 0; 714 int reg = PLAYBACK_VOLUME_MIXER9; 715 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 716 } 717 718 static int snd_p16v_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol, 719 snd_ctl_elem_value_t * ucontrol) 720 { 721 int high_low = 1; 722 int reg = PLAYBACK_VOLUME_MIXER9; 723 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 724 } 725 static int snd_p16v_volume_get_analog_rear(snd_kcontrol_t * kcontrol, 726 snd_ctl_elem_value_t * ucontrol) 727 { 728 int high_low = 1; 729 int reg = PLAYBACK_VOLUME_MIXER10; 730 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 731 } 732 733 static int snd_p16v_volume_get_analog_unknown(snd_kcontrol_t * kcontrol, 734 snd_ctl_elem_value_t * ucontrol) 735 { 736 int high_low = 0; 737 int reg = PLAYBACK_VOLUME_MIXER10; 738 return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); 739 } 740 741 static int snd_p16v_volume_put(snd_kcontrol_t * kcontrol, 742 snd_ctl_elem_value_t * ucontrol, int reg, int high_low) 743 { 744 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 745 u32 value; 746 value = snd_emu10k1_ptr20_read(emu, reg, 0); 747 //value = value & 0xffff; 748 if (high_low == 1) { 749 value &= 0xffff; 750 value = value | ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16); 751 } else { 752 value &= 0xffff0000; 753 value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) ); 754 } 755 snd_emu10k1_ptr20_write(emu, reg, 0, value); 756 return 1; 757 } 758 759 static int snd_p16v_volume_put_spdif_front(snd_kcontrol_t * kcontrol, 760 snd_ctl_elem_value_t * ucontrol) 761 { 762 int high_low = 0; 763 int reg = PLAYBACK_VOLUME_MIXER7; 764 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 765 } 766 767 static int snd_p16v_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol, 768 snd_ctl_elem_value_t * ucontrol) 769 { 770 int high_low = 1; 771 int reg = PLAYBACK_VOLUME_MIXER7; 772 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 773 } 774 775 static int snd_p16v_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol, 776 snd_ctl_elem_value_t * ucontrol) 777 { 778 int high_low = 0; 779 int reg = PLAYBACK_VOLUME_MIXER8; 780 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 781 } 782 783 static int snd_p16v_volume_put_spdif_rear(snd_kcontrol_t * kcontrol, 784 snd_ctl_elem_value_t * ucontrol) 785 { 786 int high_low = 1; 787 int reg = PLAYBACK_VOLUME_MIXER8; 788 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 789 } 790 791 static int snd_p16v_volume_put_analog_front(snd_kcontrol_t * kcontrol, 792 snd_ctl_elem_value_t * ucontrol) 793 { 794 int high_low = 0; 795 int reg = PLAYBACK_VOLUME_MIXER9; 796 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 797 } 798 799 static int snd_p16v_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol, 800 snd_ctl_elem_value_t * ucontrol) 801 { 802 int high_low = 1; 803 int reg = PLAYBACK_VOLUME_MIXER9; 804 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 805 } 806 807 static int snd_p16v_volume_put_analog_rear(snd_kcontrol_t * kcontrol, 808 snd_ctl_elem_value_t * ucontrol) 809 { 810 int high_low = 1; 811 int reg = PLAYBACK_VOLUME_MIXER10; 812 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 813 } 814 815 static int snd_p16v_volume_put_analog_unknown(snd_kcontrol_t * kcontrol, 816 snd_ctl_elem_value_t * ucontrol) 817 { 818 int high_low = 0; 819 int reg = PLAYBACK_VOLUME_MIXER10; 820 return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); 821 } 822 823 static snd_kcontrol_new_t snd_p16v_volume_control_analog_front = 824 { 825 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 826 "HD Analog Front Playback Volume",0,0,0, 827 snd_p16v_volume_info, 828 snd_p16v_volume_get_analog_front, 829 snd_p16v_volume_put_analog_front,0 830 }; 831 832 static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe = 833 { 834 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 835 "HD Analog Center/LFE Playback Volume",0,0,0, 836 snd_p16v_volume_info, 837 snd_p16v_volume_get_analog_center_lfe, 838 snd_p16v_volume_put_analog_center_lfe 839 }; 840 841 static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown = 842 { 843 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 844 "HD Analog Unknown Playback Volume",0,0,0, 845 snd_p16v_volume_info, 846 snd_p16v_volume_get_analog_unknown, 847 snd_p16v_volume_put_analog_unknown,0 848 }; 849 850 static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear = 851 { 852 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 853 "HD Analog Rear Playback Volume",0,0,0, 854 snd_p16v_volume_info, 855 snd_p16v_volume_get_analog_rear, 856 snd_p16v_volume_put_analog_rear,0 857 }; 858 859 static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front = 860 { 861 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 862 "HD SPDIF Front Playback Volume",0,0,0, 863 snd_p16v_volume_info, 864 snd_p16v_volume_get_spdif_front, 865 snd_p16v_volume_put_spdif_front,0 866 }; 867 868 static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe = 869 { 870 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 871 "HD SPDIF Center/LFE Playback Volume",0,0,0, 872 snd_p16v_volume_info, 873 snd_p16v_volume_get_spdif_center_lfe, 874 snd_p16v_volume_put_spdif_center_lfe,0 875 }; 876 877 static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown = 878 { 879 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 880 "HD SPDIF Unknown Playback Volume",0,0,0, 881 snd_p16v_volume_info, 882 snd_p16v_volume_get_spdif_unknown, 883 snd_p16v_volume_put_spdif_unknown,0 884 }; 885 886 static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear = 887 { 888 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 889 "HD SPDIF Rear Playback Volume",0,0,0, 890 snd_p16v_volume_info, 891 snd_p16v_volume_get_spdif_rear, 892 snd_p16v_volume_put_spdif_rear,0 893 }; 894 895 static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 896 { 897 static char *texts[8] = { "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", "CDIF", "FX", "AC97" }; 646 static int snd_p16v_volume_info(struct snd_kcontrol *kcontrol, 647 struct snd_ctl_elem_info *uinfo) 648 { 649 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 650 uinfo->count = 2; 651 uinfo->value.integer.min = 0; 652 uinfo->value.integer.max = 255; 653 return 0; 654 } 655 656 static int snd_p16v_volume_get(struct snd_kcontrol *kcontrol, 657 struct snd_ctl_elem_value *ucontrol) 658 { 659 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 660 int high_low = (kcontrol->private_value >> 8) & 0xff; 661 int reg = kcontrol->private_value & 0xff; 662 u32 value; 663 664 value = snd_emu10k1_ptr20_read(emu, reg, high_low); 665 if (high_low) { 666 ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ 667 ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */ 668 } else { 669 ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */ 670 ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */ 671 } 672 return 0; 673 } 674 675 static int snd_p16v_volume_put(struct snd_kcontrol *kcontrol, 676 struct snd_ctl_elem_value *ucontrol) 677 { 678 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 679 int high_low = (kcontrol->private_value >> 8) & 0xff; 680 int reg = kcontrol->private_value & 0xff; 681 u32 value, oval; 682 683 oval = value = snd_emu10k1_ptr20_read(emu, reg, 0); 684 if (high_low == 1) { 685 value &= 0xffff; 686 value |= ((0xff - ucontrol->value.integer.value[0]) << 24) | 687 ((0xff - ucontrol->value.integer.value[1]) << 16); 688 } else { 689 value &= 0xffff0000; 690 value |= ((0xff - ucontrol->value.integer.value[0]) << 8) | 691 ((0xff - ucontrol->value.integer.value[1]) ); 692 } 693 if (value != oval) { 694 snd_emu10k1_ptr20_write(emu, reg, 0, value); 695 return 1; 696 } 697 return 0; 698 } 699 700 701 static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, 702 struct snd_ctl_elem_info *uinfo) 703 { 704 static char *texts[8] = { 705 "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", 706 "CDIF", "FX", "AC97" 707 }; 898 708 899 709 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; … … 906 716 } 907 717 908 static int snd_p16v_capture_source_get(s nd_kcontrol_t *kcontrol,909 snd_ctl_elem_value_t *ucontrol)718 static int snd_p16v_capture_source_get(struct snd_kcontrol *kcontrol, 719 struct snd_ctl_elem_value *ucontrol) 910 720 { 911 721 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 915 725 } 916 726 917 static int snd_p16v_capture_source_put(s nd_kcontrol_t *kcontrol,918 snd_ctl_elem_value_t *ucontrol)727 static int snd_p16v_capture_source_put(struct snd_kcontrol *kcontrol, 728 struct snd_ctl_elem_value *ucontrol) 919 729 { 920 730 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 935 745 } 936 746 937 static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata = 938 { 939 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 940 "HD source Capture",0,0,0, 941 snd_p16v_capture_source_info, 942 snd_p16v_capture_source_get, 943 snd_p16v_capture_source_put,0 944 }; 945 946 static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 747 static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, 748 struct snd_ctl_elem_info *uinfo) 947 749 { 948 750 static char *texts[4] = { "0", "1", "2", "3", }; … … 957 759 } 958 760 959 static int snd_p16v_capture_channel_get(s nd_kcontrol_t *kcontrol,960 snd_ctl_elem_value_t *ucontrol)761 static int snd_p16v_capture_channel_get(struct snd_kcontrol *kcontrol, 762 struct snd_ctl_elem_value *ucontrol) 961 763 { 962 764 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 966 768 } 967 769 968 static int snd_p16v_capture_channel_put(s nd_kcontrol_t *kcontrol,969 snd_ctl_elem_value_t *ucontrol)770 static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol, 771 struct snd_ctl_elem_value *ucontrol) 970 772 { 971 773 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); … … 984 786 } 985 787 986 static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata = 987 { 988 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 989 "HD channel Capture",0,0,0, 990 snd_p16v_capture_channel_info, 991 snd_p16v_capture_channel_get, 992 snd_p16v_capture_channel_put,0 788 static DECLARE_TLV_DB_SCALE(snd_p16v_db_scale1, -5175, 25, 1); 789 790 #define P16V_VOL(xname,xreg,xhl) { \ 791 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 792 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 793 SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 794 .info = snd_p16v_volume_info, \ 795 .get = snd_p16v_volume_get, \ 796 .put = snd_p16v_volume_put, \ 797 .tlv = { .p = snd_p16v_db_scale1 }, \ 798 .private_value = ((xreg) | ((xhl) << 8)) \ 799 } 800 801 static struct snd_kcontrol_new p16v_mixer_controls[] __devinitdata = { 802 P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), 803 P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), 804 P16V_VOL("HD Analog Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER9, 1), 805 P16V_VOL("HD Analog Side Playback Volume", PLAYBACK_VOLUME_MIXER10, 0), 806 P16V_VOL("HD SPDIF Front Playback Volume", PLAYBACK_VOLUME_MIXER7, 0), 807 P16V_VOL("HD SPDIF Rear Playback Volume", PLAYBACK_VOLUME_MIXER8, 1), 808 P16V_VOL("HD SPDIF Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER7, 1), 809 P16V_VOL("HD SPDIF Side Playback Volume", PLAYBACK_VOLUME_MIXER8, 0), 810 { 811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 812 .name = "HD source Capture", 813 .info = snd_p16v_capture_source_info, 814 .get = snd_p16v_capture_source_get, 815 .put = snd_p16v_capture_source_put 816 }, 817 { 818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 819 .name = "HD channel Capture", 820 .info = snd_p16v_capture_channel_info, 821 .get = snd_p16v_capture_channel_get, 822 .put = snd_p16v_capture_channel_put 823 }, 993 824 }; 994 825 995 int snd_p16v_mixer(struct snd_emu10k1 *emu) 996 { 997 int err; 998 snd_kcontrol_t *kctl; 999 snd_card_t *card = emu->card; 1000 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_front, emu)) == NULL) 1001 return -ENOMEM; 1002 if ((err = snd_ctl_add(card, kctl))) 1003 return err; 1004 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_rear, emu)) == NULL) 1005 return -ENOMEM; 1006 if ((err = snd_ctl_add(card, kctl))) 1007 return err; 1008 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_center_lfe, emu)) == NULL) 1009 return -ENOMEM; 1010 if ((err = snd_ctl_add(card, kctl))) 1011 return err; 1012 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_unknown, emu)) == NULL) 1013 return -ENOMEM; 1014 if ((err = snd_ctl_add(card, kctl))) 1015 return err; 1016 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_front, emu)) == NULL) 1017 return -ENOMEM; 1018 if ((err = snd_ctl_add(card, kctl))) 1019 return err; 1020 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_rear, emu)) == NULL) 1021 return -ENOMEM; 1022 if ((err = snd_ctl_add(card, kctl))) 1023 return err; 1024 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_center_lfe, emu)) == NULL) 1025 return -ENOMEM; 1026 if ((err = snd_ctl_add(card, kctl))) 1027 return err; 1028 if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_unknown, emu)) == NULL) 1029 return -ENOMEM; 1030 if ((err = snd_ctl_add(card, kctl))) 1031 return err; 1032 if ((kctl = snd_ctl_new1(&snd_p16v_capture_source, emu)) == NULL) 1033 return -ENOMEM; 1034 if ((err = snd_ctl_add(card, kctl))) 1035 return err; 1036 if ((kctl = snd_ctl_new1(&snd_p16v_capture_channel, emu)) == NULL) 1037 return -ENOMEM; 1038 if ((err = snd_ctl_add(card, kctl))) 1039 return err; 1040 return 0; 1041 } 1042 826 int __devinit snd_p16v_mixer(struct snd_emu10k1 *emu) 827 { 828 int i, err; 829 struct snd_card *card = emu->card; 830 831 for (i = 0; i < ARRAY_SIZE(p16v_mixer_controls); i++) { 832 if ((err = snd_ctl_add(card, snd_ctl_new1(&p16v_mixer_controls[i], 833 emu))) < 0) 834 return err; 835 } 836 return 0; 837 } 838 839 #ifdef CONFIG_PM 840 841 #define NUM_CHS 1 /* up to 4, but only first channel is used */ 842 843 int __devinit snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) 844 { 845 emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); 846 if (! emu->p16v_saved) 847 return -ENOMEM; 848 return 0; 849 } 850 851 void snd_p16v_free_pm_buffer(struct snd_emu10k1 *emu) 852 { 853 vfree(emu->p16v_saved); 854 } 855 856 void snd_p16v_suspend(struct snd_emu10k1 *emu) 857 { 858 int i, ch; 859 unsigned int *val; 860 861 val = emu->p16v_saved; 862 for (ch = 0; ch < NUM_CHS; ch++) 863 for (i = 0; i < 0x80; i++, val++) 864 *val = snd_emu10k1_ptr20_read(emu, i, ch); 865 } 866 867 void snd_p16v_resume(struct snd_emu10k1 *emu) 868 { 869 int i, ch; 870 unsigned int *val; 871 872 val = emu->p16v_saved; 873 for (ch = 0; ch < NUM_CHS; ch++) 874 for (i = 0; i < 0x80; i++, val++) 875 snd_emu10k1_ptr20_write(emu, i, ch, *val); 876 } 877 #endif 878 -
GPL/trunk/alsa-kernel/pci/emu10k1/voice.c
r34 r84 47 47 */ 48 48 49 static int voice_alloc(struct snd_emu10k1 *emu, int type, int number, struct snd_emu10k1_voice **rvoice) 49 static int voice_alloc(struct snd_emu10k1 *emu, int type, int number, 50 struct snd_emu10k1_voice **rvoice) 50 51 { 51 52 struct snd_emu10k1_voice *voice; … … 63 64 } 64 65 65 /* make sure the block of voices does not cross the 32 voice boundary */66 //if (((i % 32) + number) > 32)67 // continue;68 69 66 skip = 0; 70 67 for (k = 0; k < number; k++) { … … 72 69 if (voice->use) { 73 70 skip = 1; 71 break; 74 72 } 75 73 } -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.c
r77 r84 1040 1040 runtime->hw.channels_max = hinfo->channels_max; 1041 1041 runtime->hw.formats = hinfo->formats; 1042 runtime->hw.rates = hinfo->rates; 1042 runtime->hw.rates = hinfo->rates; 1043 printk("azx hw rates: %x. ratemin: %i, ratemax: %i\n", 1044 runtime->hw.rates, runtime->hw.rate_min, runtime->hw.rate_max); 1043 1045 snd_pcm_limit_hw_rates(runtime); 1044 1046 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); -
GPL/trunk/alsa-kernel/pci/trident/trident_main.c
r34 r84 33 33 #include <sound/control.h> 34 34 #include <sound/trident.h> 35 36 static inline snd_ctl_elem_id_t *snd_ctl_build_ioff(snd_ctl_elem_id_t *dst_id,37 snd_kcontrol_t *src_kctl,38 unsigned int offset)39 {40 *dst_id = src_kctl->id;41 dst_id->index += offset;42 dst_id->numid += offset;43 return dst_id;44 }45 35 46 36 static int snd_trident_pcm_mixer_build(struct snd_trident *trident, struct snd_trident_voice* voice, snd_pcm_substream_t *substream); -
GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci_main.c
r83 r84 1792 1792 return err; 1793 1793 1794 /* to be sure */ 1795 snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, 1796 AC97_EA_VRA|AC97_EA_VRM, 0); 1794 1797 1795 1798 for (idx = 0; idx < ARRAY_SIZE(snd_ymfpci_controls); idx++) { -
GPL/trunk/drv32/dispatch.c
r32 r84 95 95 ULONG ctl_id; 96 96 97 #ifdef DEBUG 98 printk("StratIOCtl\n"); 99 #endif 97 100 if (rp->Category != CAT_IOCTL_OSS32) 98 101 { -
GPL/trunk/drv32/init.c
r63 r84 283 283 WriteString(szEOL, sizeof(szEOL)-1); 284 284 } 285 285 #ifdef DEBUG 286 dprintf(("DiscardableInit. cp1")); 287 #endif 286 288 // Complete the installation 287 289 rp->Out.FinalCS = _OffsetFinalCS16; 288 290 rp->Out.FinalDS = _OffsetFinalDS16; 291 #ifdef DEBUG 292 dprintf(("DiscardableInit. cp2")); 293 #endif 289 294 290 295 // SaveBuffer(); -
GPL/trunk/drv32/strategy.c
r32 r84 70 70 RPInit __far* rp = (RPInit __far*)_rp; 71 71 rc = DiscardableInit(rp); 72 72 #ifdef DEBUG 73 dprintf(("StratInit. cp1.rc %d", rc)); 74 #endif 73 75 return rc; 74 76 } … … 80 82 #pragma on (unreferenced) 81 83 { 84 #ifdef DEBUG 85 dprintf(("StratInitComplete")); 86 #endif 82 87 return(RPDONE); 83 88 } … … 90 95 RPShutdown __far *rp = (RPShutdown __far *)_rp; 91 96 92 dprintf(("StratShutdown %d", rp->Function)); 97 #ifdef DEBUG 98 dprintf(("StratShutdown %d", rp->Function)); 99 #endif 93 100 if(rp->Function == 1) {//end of shutdown 94 101 OSS32_Shutdown(); -
GPL/trunk/include/ossdefos2.h
r32 r84 86 86 #define OSS_MIXER_3DDEPTH 25 87 87 #define OSS_MIXER_3DCENTER 26 88 #define OSS_MIXER_NRDEVICES 27 88 #define OSS_MIXER_FRONT 27 89 #define OSS_MIXER_NRDEVICES 28 89 90 90 91 #endif -
GPL/trunk/include/version.mak
r83 r84 11 11 BLDLVL_REVISION = 1.1 12 12 BLDLVL_FILEVER = 4 13 BLDLVL_DATETIME = 2 5.09.2006 22:56:5913 BLDLVL_DATETIME = 23.10.2006 23:58:13 14 14 BLDLVL_MACHINE = VLAD -
GPL/trunk/lib32/irq.c
r76 r84 176 176 177 177 #ifdef DEBUG 178 dprintf(("enter int proc %d %d",ulSlotNo, *pulIrq));178 // dprintf(("enter int proc %d %d",ulSlotNo, *pulIrq)); 179 179 #endif 180 180 … … 213 213 OSS32_ProcessIRQ(); 214 214 #ifdef DEBUG 215 dprintf(("exit(1) int proc %d %d",ulSlotNo, *pulIrq));215 // dprintf(("exit(1) int proc %d %d",ulSlotNo, *pulIrq)); 216 216 #endif 217 217 eoiIrq[pSlot->irqNo] = 0; … … 222 222 } 223 223 #ifdef DEBUG 224 dprintf(("exit(0) int proc %d %d",ulSlotNo, *pulIrq));224 // dprintf(("exit(0) int proc %d %d",ulSlotNo, *pulIrq)); 225 225 #endif 226 226 -
GPL/trunk/lib32/ossidc.cpp
r76 r84 283 283 284 284 if(nrCardsDetected != 0) { 285 dprintf(("OSS32_Initialize2")); 285 286 pcm_info(); 287 dprintf(("OSS32_Initialize3")); 286 288 for(int i=0;i<nrCardsDetected;i++) { 289 dprintf(("OSS32_Initialize4 start: %d",i)); 287 290 FillCaps(i); 291 dprintf(("OSS32_Initialize4 end: %d",i)); 288 292 } 293 dprintf(("OSS32_Initialize: SUCCESS. nr. of cards: %d",nrCardsDetected)); 289 294 return OSSERR_SUCCESS; 290 295 } 296 dprintf(("OSS32_Initialize. FAILED")); 291 297 return OSSERR_INIT_FAILED; 292 298 } -
GPL/trunk/lib32/sound.c
r82 r84 754 754 soundhandle *pHandle = (soundhandle *)streamid; 755 755 snd_pcm_hw_params_t params; 756 snd_pcm_status_t status; 756 757 snd_pcm_sw_params_t swparams; 757 758 int ret, ret1, nrperiods, minnrperiods, maxnrperiods, samplesize, i; … … 889 890 } 890 891 } 892 891 893 // ret1 = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file); 892 894 DebugInt3(); … … 1040 1042 total = 0; 1041 1043 per_bytes = periodbytes; 1044 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status)); 1045 if ( ((status.state != SNDRV_PCM_STATE_PREPARED) && 1046 (status.state != SNDRV_PCM_STATE_RUNNING) && 1047 (status.state != SNDRV_PCM_STATE_DRAINING))) { 1048 printk("Device is not in proper state: %i. Calling prepare\n", status.state); 1049 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1050 } 1042 1051 printk("OSS32_WaveSetHwParams return %d after SNDRV_PCM_IOCTL_SW_PARAMS ioctl, streamid %X", ret,(ULONG)pHandle); 1043 1052 return UNIXToOSSError(ret); … … 1133 1142 printk("OSS32_WaveAddBuffer failed on partial transfer %x %i; ret = %i\n", buffer, size, ret); 1134 1143 *pTransferred = transferred; 1135 return OSSERR_SUCCESS; 1144 if (toret) 1145 return OSSERR_SUCCESS; /* avoid infinite loop */ 1146 toret = 1; 1147 goto again; 1136 1148 } 1137 1149 … … 1143 1155 ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1144 1156 printk("OSS32_WaveAddBuffer buffer overrun: size %i, ret %i, trans %i, prev sz %i per sz %i total %i\n", size, ret, transferred, prev_size, per_bytes, total); 1145 ret = size; 1146 transferred = size; 1147 break; /* UGLY hack*/ 1148 //goto again; 1157 //ret = size; 1158 //transferred = size; 1159 if (toret) break; /* avoid infinite loop */ 1160 toret = 1; 1161 goto again; 1149 1162 } 1150 1163 else { … … 1162 1175 break; 1163 1176 } 1177 toret = 0; 1164 1178 transferred += ret; 1165 1179 // printk("written: now: %i, buffer: %i, total: %i\n", ret, transferred, total); -
GPL/trunk/lib32/soundmixer.c
r32 r84 72 72 /* OSS_MIXER_3DDEPTH */ { "3D Control - Depth", 0 , -1}, 73 73 /* OSS_MIXER_3DCENTER */ { "3D Control - Center", 0 , -1}, 74 /* OSS_MIXER_FRONT */ { "Front", 0 , -1}, 74 75 }; 75 76 char *szRecSources[OSS32_MIX_RECSRC_MAX] = { … … 201 202 int controlnamelen = strlen(pHandle->pids[i].name); 202 203 203 if(namelen == controlnamelen) 204 if(namelen == controlnamelen) 204 205 {//control names are identical; found exact match 205 206 pHandle->controls[j].idxVolume = i; … … 392 393 idx = pHandle->controls[OSS_MIXER_VOLUME].idxVolume; 393 394 idxMute = pHandle->controls[OSS_MIXER_VOLUME].idxMute; 395 if (idx == -1) 396 { 397 /* HDA codecs workaround */ 398 idx = pHandle->controls[OSS_MIXER_FRONT].idxVolume; 399 idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute; 400 } 394 401 break; 395 402 case OSS32_MIX_VOLUME_MASTER_REAR: //TODO: … … 400 407 idx = pHandle->controls[OSS_MIXER_PCM].idxVolume; 401 408 idxMute = pHandle->controls[OSS_MIXER_PCM].idxMute; 409 if (idx == -1) 410 { 411 /* HDA codecs workaround */ 412 idx = pHandle->controls[OSS_MIXER_FRONT].idxVolume; 413 idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute; 414 } 402 415 break; 403 416 case OSS32_MIX_VOLUME_MIDI: -
GPL/trunk/lib32/stack.cpp
r76 r84 33 33 #endif 34 34 35 #define MAX_STACK 835 #define MAX_STACK 16 36 36 #define STACKSIZE (16*1024) 37 37 #define TOTAL_STACKSIZE MAX_STACK*(16*1024)
Note:
See TracChangeset
for help on using the changeset viewer.