Rev 406 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 406 | Rev 412 | ||
---|---|---|---|
1 | ;alpha version |
1 | ;alpha version |
2 | 2 | ||
3 | format MS COFF |
3 | format MS COFF |
4 | 4 | ||
5 | 5 | ||
6 | include 'proc32.inc' |
6 | include 'proc32.inc' |
7 | include 'imports.inc' |
7 | include 'imports.inc' |
8 | 8 | ||
9 | DEBUG equ 1 |
9 | DEBUG equ 1 |
10 | 10 | ||
11 | REMAP_IRQ equ 0 |
11 | REMAP_IRQ equ 0 |
12 | 12 | ||
13 | ;irq 0,1,2,8,12,13 íåäîñòóïíû |
13 | ;irq 0,1,2,8,12,13 íåäîñòóïíû |
14 | ; FEDCBA9876543210 |
14 | ; FEDCBA9876543210 |
15 | VALID_IRQ equ 1100111011111000b |
15 | VALID_IRQ equ 1100111011111000b |
16 | ATTCH_IRQ equ 0000111010101000b |
16 | ATTCH_IRQ equ 0000111010101000b |
17 | 17 | ||
18 | IRQ_LINE equ 0 |
18 | IRQ_LINE equ 0 |
19 | 19 | ||
20 | CPU_FREQ equ 2600d |
20 | CPU_FREQ equ 2600d |
21 | 21 | ||
22 | BIT0 EQU 0x00000001 |
22 | BIT0 EQU 0x00000001 |
23 | BIT1 EQU 0x00000002 |
23 | BIT1 EQU 0x00000002 |
24 | BIT2 EQU 0x00000004 |
24 | BIT2 EQU 0x00000004 |
25 | BIT3 EQU 0x00000008 |
25 | BIT3 EQU 0x00000008 |
26 | BIT4 EQU 0x00000010 |
26 | BIT4 EQU 0x00000010 |
27 | BIT5 EQU 0x00000020 |
27 | BIT5 EQU 0x00000020 |
28 | BIT6 EQU 0x00000040 |
28 | BIT6 EQU 0x00000040 |
29 | BIT7 EQU 0x00000080 |
29 | BIT7 EQU 0x00000080 |
30 | BIT8 EQU 0x00000100 |
30 | BIT8 EQU 0x00000100 |
31 | BIT9 EQU 0x00000200 |
31 | BIT9 EQU 0x00000200 |
32 | BIT10 EQU 0x00000400 |
32 | BIT10 EQU 0x00000400 |
33 | BIT11 EQU 0x00000800 |
33 | BIT11 EQU 0x00000800 |
34 | BIT12 EQU 0x00001000 |
34 | BIT12 EQU 0x00001000 |
35 | BIT13 EQU 0x00002000 |
35 | BIT13 EQU 0x00002000 |
36 | BIT14 EQU 0x00004000 |
36 | BIT14 EQU 0x00004000 |
37 | BIT15 EQU 0x00008000 |
37 | BIT15 EQU 0x00008000 |
38 | BIT16 EQU 0x00010000 |
38 | BIT16 EQU 0x00010000 |
39 | BIT17 EQU 0x00020000 |
39 | BIT17 EQU 0x00020000 |
40 | BIT18 EQU 0x00040000 |
40 | BIT18 EQU 0x00040000 |
41 | BIT19 EQU 0x00080000 |
41 | BIT19 EQU 0x00080000 |
42 | BIT20 EQU 0x00100000 |
42 | BIT20 EQU 0x00100000 |
43 | BIT21 EQU 0x00200000 |
43 | BIT21 EQU 0x00200000 |
44 | BIT22 EQU 0x00400000 |
44 | BIT22 EQU 0x00400000 |
45 | BIT23 EQU 0x00800000 |
45 | BIT23 EQU 0x00800000 |
46 | BIT24 EQU 0x00100000 |
46 | BIT24 EQU 0x00100000 |
47 | BIT25 EQU 0x02000000 |
47 | BIT25 EQU 0x02000000 |
48 | BIT26 EQU 0x04000000 |
48 | BIT26 EQU 0x04000000 |
49 | BIT27 EQU 0x08000000 |
49 | BIT27 EQU 0x08000000 |
50 | BIT28 EQU 0x10000000 |
50 | BIT28 EQU 0x10000000 |
51 | BIT29 EQU 0x20000000 |
51 | BIT29 EQU 0x20000000 |
52 | BIT30 EQU 0x40000000 |
52 | BIT30 EQU 0x40000000 |
53 | BIT31 EQU 0x80000000 |
53 | BIT31 EQU 0x80000000 |
54 | 54 | ||
55 | 55 | ||
56 | PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list |
56 | PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list |
57 | PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register |
57 | PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register |
58 | PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index |
58 | PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index |
59 | PCM_OUT_SR_REG equ 0x16 ; PCM out Status register |
59 | PCM_OUT_SR_REG equ 0x16 ; PCM out Status register |
60 | PCM_OUT_PIV_REG equ 0x1a |
60 | PCM_OUT_PIV_REG equ 0x1a |
61 | PCM_OUT_CIV_REG equ 0x14 ; PCM out current index |
61 | PCM_OUT_CIV_REG equ 0x14 ; PCM out current index |
62 | 62 | ||
63 | PCM_IN_CR_REG equ 0x0b ; PCM in Control Register |
63 | PCM_IN_CR_REG equ 0x0b ; PCM in Control Register |
64 | MC_IN_CR_REG equ 0x2b ; MIC in Control Register |
64 | MC_IN_CR_REG equ 0x2b ; MIC in Control Register |
65 | RR equ BIT1 ; reset registers. Nukes all regs |
65 | RR equ BIT1 ; reset registers. Nukes all regs |
66 | 66 | ||
67 | CODEC_MASTER_VOL_REG equ 0x02 |
67 | CODEC_MASTER_VOL_REG equ 0x02 |
68 | CODEC_AUX_VOL equ 0x04 ; |
68 | CODEC_AUX_VOL equ 0x04 ; |
69 | CODEC_PCM_OUT_REG equ 18h ; PCM output volume |
69 | CODEC_PCM_OUT_REG equ 18h ; PCM output volume |
70 | CODEC_EXT_AUDIO_REG equ 28h ; extended audio |
70 | CODEC_EXT_AUDIO_REG equ 28h ; extended audio |
71 | CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control |
71 | CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control |
72 | CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate |
72 | CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate |
73 | CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate |
73 | CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate |
74 | CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate |
74 | CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate |
75 | 75 | ||
76 | GLOB_CTRL equ 0x2C ; Global Control |
76 | GLOB_CTRL equ 0x2C ; Global Control |
77 | CTRL_STAT equ 0x30 ; Global Status |
77 | CTRL_STAT equ 0x30 ; Global Status |
78 | CTRL_CAS equ 0x34 ; Codec Access Semiphore |
78 | CTRL_CAS equ 0x34 ; Codec Access Semiphore |
79 | 79 | ||
80 | CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit |
80 | CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit |
81 | 81 | ||
82 | CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready |
82 | CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready |
83 | 83 | ||
84 | CTRL_ST_RCS equ 0x00008000 ; Read Completion Status |
84 | CTRL_ST_RCS equ 0x00008000 ; Read Completion Status |
85 | 85 | ||
86 | CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable |
86 | CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable |
87 | CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off |
87 | CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off |
88 | CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset |
88 | CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset |
89 | CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset |
89 | CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset |
90 | CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable |
90 | CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable |
91 | 91 | ||
92 | CODEC_REG_POWERDOWN equ 0x26 |
92 | CODEC_REG_POWERDOWN equ 0x26 |
93 | CODEC_REG_ST equ 0x26 |
93 | CODEC_REG_ST equ 0x26 |
94 | 94 | ||
95 | DEV_PLAY equ 1 |
95 | DEV_PLAY equ 1 |
96 | DEV_STOP equ 2 |
96 | DEV_STOP equ 2 |
97 | DEV_CALLBACK equ 3 |
97 | DEV_CALLBACK equ 3 |
98 | DEV_SET_BUFF equ 4 |
98 | DEV_SET_BUFF equ 4 |
99 | DEV_NOTIFY equ 5 |
99 | DEV_NOTIFY equ 5 |
100 | DEV_SET_MASTERVOL equ 6 |
100 | DEV_SET_MASTERVOL equ 6 |
101 | DEV_GET_MASTERVOL equ 7 |
101 | DEV_GET_MASTERVOL equ 7 |
102 | DEV_GET_INFO equ 8 |
102 | DEV_GET_INFO equ 8 |
103 | 103 | ||
104 | struc AC_CNTRL ;AC controller base class |
104 | struc AC_CNTRL ;AC controller base class |
105 | { .bus dd ? |
105 | { .bus dd ? |
106 | .devfn dd ? |
106 | .devfn dd ? |
107 | 107 | ||
108 | .vendor dd ? |
108 | .vendor dd ? |
109 | .dev_id dd ? |
109 | .dev_id dd ? |
110 | .pci_cmd dd ? |
110 | .pci_cmd dd ? |
111 | .pci_stat dd ? |
111 | .pci_stat dd ? |
112 | 112 | ||
113 | .codec_io_base dd ? |
113 | .codec_io_base dd ? |
114 | .codec_mem_base dd ? |
114 | .codec_mem_base dd ? |
115 | 115 | ||
116 | .ctrl_io_base dd ? |
116 | .ctrl_io_base dd ? |
117 | .ctrl_mem_base dd ? |
117 | .ctrl_mem_base dd ? |
118 | .cfg_reg dd ? |
118 | .cfg_reg dd ? |
119 | .int_line dd ? |
119 | .int_line dd ? |
120 | 120 | ||
121 | .vendor_ids dd ? ;vendor id string |
121 | .vendor_ids dd ? ;vendor id string |
122 | .ctrl_ids dd ? ;hub id string |
122 | .ctrl_ids dd ? ;hub id string |
123 | 123 | ||
124 | .buffer dd ? |
124 | .buffer dd ? |
125 | 125 | ||
126 | .notify_pos dd ? |
126 | .notify_pos dd ? |
127 | .notify_task dd ? |
127 | .notify_task dd ? |
128 | 128 | ||
129 | .lvi_reg dd ? |
129 | .lvi_reg dd ? |
130 | .ctrl_setup dd ? |
130 | .ctrl_setup dd ? |
131 | .user_callback dd ? |
131 | .user_callback dd ? |
132 | .codec_read16 dd ? |
132 | .codec_read16 dd ? |
133 | .codec_write16 dd ? |
133 | .codec_write16 dd ? |
134 | 134 | ||
135 | .ctrl_read8 dd ? |
135 | .ctrl_read8 dd ? |
136 | .ctrl_read16 dd ? |
136 | .ctrl_read16 dd ? |
137 | .ctrl_read32 dd ? |
137 | .ctrl_read32 dd ? |
138 | 138 | ||
139 | .ctrl_write8 dd ? |
139 | .ctrl_write8 dd ? |
140 | .ctrl_write16 dd ? |
140 | .ctrl_write16 dd ? |
141 | .ctrl_write32 dd ? |
141 | .ctrl_write32 dd ? |
142 | } |
142 | } |
143 | 143 | ||
144 | struc CODEC ;Audio Chip base class |
144 | struc CODEC ;Audio Chip base class |
145 | { |
145 | { |
146 | .chip_id dd ? |
146 | .chip_id dd ? |
147 | .flags dd ? |
147 | .flags dd ? |
148 | .status dd ? |
148 | .status dd ? |
149 | 149 | ||
150 | .ac_vendor_ids dd ? ;ac vendor id string |
150 | .ac_vendor_ids dd ? ;ac vendor id string |
151 | .chip_ids dd ? ;chip model string |
151 | .chip_ids dd ? ;chip model string |
152 | 152 | ||
153 | .shadow_flag dd ? |
153 | .shadow_flag dd ? |
154 | dd ? |
154 | dd ? |
155 | 155 | ||
156 | .regs dw ? ; codec registers |
156 | .regs dw ? ; codec registers |
157 | .reg_master_vol dw ? ;0x02 |
157 | .reg_master_vol dw ? ;0x02 |
158 | .reg_aux_out_vol dw ? ;0x04 |
158 | .reg_aux_out_vol dw ? ;0x04 |
159 | .reg_mone_vol dw ? ;0x06 |
159 | .reg_mone_vol dw ? ;0x06 |
160 | .reg_master_tone dw ? ;0x08 |
160 | .reg_master_tone dw ? ;0x08 |
161 | .reg_beep_vol dw ? ;0x0A |
161 | .reg_beep_vol dw ? ;0x0A |
162 | .reg_phone_vol dw ? ;0x0C |
162 | .reg_phone_vol dw ? ;0x0C |
163 | .reg_mic_vol dw ? ;0x0E |
163 | .reg_mic_vol dw ? ;0x0E |
164 | .reg_line_in_vol dw ? ;0x10 |
164 | .reg_line_in_vol dw ? ;0x10 |
165 | .reg_cd_vol dw ? ;0x12 |
165 | .reg_cd_vol dw ? ;0x12 |
166 | .reg_video_vol dw ? ;0x14 |
166 | .reg_video_vol dw ? ;0x14 |
167 | .reg_aux_in_vol dw ? ;0x16 |
167 | .reg_aux_in_vol dw ? ;0x16 |
168 | .reg_pcm_out_vol dw ? ;0x18 |
168 | .reg_pcm_out_vol dw ? ;0x18 |
169 | .reg_rec_select dw ? ;0x1A |
169 | .reg_rec_select dw ? ;0x1A |
170 | .reg_rec_gain dw ? ;0x1C |
170 | .reg_rec_gain dw ? ;0x1C |
171 | .reg_rec_gain_mic dw ? ;0x1E |
171 | .reg_rec_gain_mic dw ? ;0x1E |
172 | .reg_gen dw ? ;0x20 |
172 | .reg_gen dw ? ;0x20 |
173 | .reg_3d_ctrl dw ? ;0X22 |
173 | .reg_3d_ctrl dw ? ;0X22 |
174 | .reg_page dw ? ;0X24 |
174 | .reg_page dw ? ;0X24 |
175 | .reg_powerdown dw ? ;0x26 |
175 | .reg_powerdown dw ? ;0x26 |
176 | .reg_ext_audio dw ? ;0x28 |
176 | .reg_ext_audio dw ? ;0x28 |
177 | .reg_ext_st dw ? ;0x2a |
177 | .reg_ext_st dw ? ;0x2a |
178 | .reg_pcm_front_rate dw ? ;0x2c |
178 | .reg_pcm_front_rate dw ? ;0x2c |
179 | .reg_pcm_surr_rate dw ? ;0x2e |
179 | .reg_pcm_surr_rate dw ? ;0x2e |
180 | .reg_lfe_rate dw ? ;0x30 |
180 | .reg_lfe_rate dw ? ;0x30 |
181 | .reg_pcm_in_rate dw ? ;0x32 |
181 | .reg_pcm_in_rate dw ? ;0x32 |
182 | dw ? ;0x34 |
182 | dw ? ;0x34 |
183 | .reg_cent_lfe_vol dw ? ;0x36 |
183 | .reg_cent_lfe_vol dw ? ;0x36 |
184 | .reg_surr_vol dw ? ;0x38 |
184 | .reg_surr_vol dw ? ;0x38 |
185 | .reg_spdif_ctrl dw ? ;0x3A |
185 | .reg_spdif_ctrl dw ? ;0x3A |
186 | dw ? ;0x3C |
186 | dw ? ;0x3C |
187 | dw ? ;0x3E |
187 | dw ? ;0x3E |
188 | dw ? ;0x40 |
188 | dw ? ;0x40 |
189 | dw ? ;0x42 |
189 | dw ? ;0x42 |
190 | dw ? ;0x44 |
190 | dw ? ;0x44 |
191 | dw ? ;0x46 |
191 | dw ? ;0x46 |
192 | dw ? ;0x48 |
192 | dw ? ;0x48 |
193 | dw ? ;0x4A |
193 | dw ? ;0x4A |
194 | dw ? ;0x4C |
194 | dw ? ;0x4C |
195 | dw ? ;0x4E |
195 | dw ? ;0x4E |
196 | dw ? ;0x50 |
196 | dw ? ;0x50 |
197 | dw ? ;0x52 |
197 | dw ? ;0x52 |
198 | dw ? ;0x54 |
198 | dw ? ;0x54 |
199 | dw ? ;0x56 |
199 | dw ? ;0x56 |
200 | dw ? ;0x58 |
200 | dw ? ;0x58 |
201 | dw ? ;0x5A |
201 | dw ? ;0x5A |
202 | dw ? ;0x5C |
202 | dw ? ;0x5C |
203 | dw ? ;0x5E |
203 | dw ? ;0x5E |
204 | .reg_page_0 dw ? ;0x60 |
204 | .reg_page_0 dw ? ;0x60 |
205 | .reg_page_1 dw ? ;0x62 |
205 | .reg_page_1 dw ? ;0x62 |
206 | .reg_page_2 dw ? ;0x64 |
206 | .reg_page_2 dw ? ;0x64 |
207 | .reg_page_3 dw ? ;0x66 |
207 | .reg_page_3 dw ? ;0x66 |
208 | .reg_page_4 dw ? ;0x68 |
208 | .reg_page_4 dw ? ;0x68 |
209 | .reg_page_5 dw ? ;0x6A |
209 | .reg_page_5 dw ? ;0x6A |
210 | .reg_page_6 dw ? ;0x6C |
210 | .reg_page_6 dw ? ;0x6C |
211 | .reg_page_7 dw ? ;0x6E |
211 | .reg_page_7 dw ? ;0x6E |
212 | dw ? ;0x70 |
212 | dw ? ;0x70 |
213 | dw ? ;0x72 |
213 | dw ? ;0x72 |
214 | dw ? ;0x74 |
214 | dw ? ;0x74 |
215 | dw ? ;0x76 |
215 | dw ? ;0x76 |
216 | dw ? ;0x78 |
216 | dw ? ;0x78 |
217 | dw ? ;0x7A |
217 | dw ? ;0x7A |
218 | .reg_vendor_id_1 dw ? ;0x7C |
218 | .reg_vendor_id_1 dw ? ;0x7C |
219 | .reg_vendor_id_2 dw ? ;0x7E |
219 | .reg_vendor_id_2 dw ? ;0x7E |
220 | 220 | ||
221 | 221 | ||
222 | .reset dd ? ;virual |
222 | .reset dd ? ;virual |
223 | .set_master_vol dd ? |
223 | .set_master_vol dd ? |
224 | } |
224 | } |
225 | 225 | ||
226 | struc CTRL_INFO |
226 | struc CTRL_INFO |
227 | { .pci_cmd dd ? |
227 | { .pci_cmd dd ? |
228 | .irq dd ? |
228 | .irq dd ? |
229 | .glob_cntrl dd ? |
229 | .glob_cntrl dd ? |
230 | .glob_sta dd ? |
230 | .glob_sta dd ? |
231 | .codec_io_base dd ? |
231 | .codec_io_base dd ? |
232 | .ctrl_io_base dd ? |
232 | .ctrl_io_base dd ? |
233 | .codec_mem_base dd ? |
233 | .codec_mem_base dd ? |
234 | .ctrl_mem_base dd ? |
234 | .ctrl_mem_base dd ? |
235 | .codec_id dd ? |
235 | .codec_id dd ? |
236 | } |
236 | } |
237 | 237 | ||
238 | struc IOCTL |
238 | struc IOCTL |
239 | { .handle dd ? |
239 | { .handle dd ? |
240 | .io_code dd ? |
240 | .io_code dd ? |
241 | .input dd ? |
241 | .input dd ? |
242 | .inp_size dd ? |
242 | .inp_size dd ? |
243 | .output dd ? |
243 | .output dd ? |
244 | .out_size dd ? |
244 | .out_size dd ? |
245 | } |
245 | } |
246 | 246 | ||
247 | virtual at 0 |
247 | virtual at 0 |
248 | IOCTL IOCTL |
248 | IOCTL IOCTL |
249 | end virtual |
249 | end virtual |
250 | 250 | ||
251 | EVENT_NOTIFY equ 0x00000200 |
251 | EVENT_NOTIFY equ 0x00000200 |
252 | 252 | ||
253 | OS_BASE equ 0; |
253 | OS_BASE equ 0; |
254 | SLOT_BASE equ OS_BASE+0x0080000 |
254 | SLOT_BASE equ OS_BASE+0x0080000 |
255 | new_app_base equ 0x80000000 |
255 | new_app_base equ 0x80000000 |
256 | 256 | ||
257 | public START |
257 | public START |
258 | public service_proc |
258 | public service_proc |
259 | public version |
259 | public version |
260 | 260 | ||
261 | section '.flat' code readable align 16 |
261 | section '.flat' code readable align 16 |
262 | 262 | ||
263 | proc START stdcall, state:dword |
263 | proc START stdcall, state:dword |
264 | 264 | ||
265 | cmp [state], 1 |
265 | cmp [state], 1 |
266 | jne .stop |
266 | jne .stop |
267 | 267 | ||
268 | if DEBUG |
268 | if DEBUG |
269 | mov esi, msgDetect |
269 | mov esi, msgDetect |
270 | call SysMsgBoardStr |
270 | call SysMsgBoardStr |
271 | end if |
271 | end if |
272 | 272 | ||
273 | call detect_controller |
273 | call detect_controller |
274 | test eax, eax |
274 | test eax, eax |
275 | jz .fail |
275 | jz .fail |
276 | 276 | ||
277 | if DEBUG |
277 | if DEBUG |
278 | mov esi,[ctrl.vendor_ids] |
278 | mov esi,[ctrl.vendor_ids] |
279 | call SysMsgBoardStr |
279 | call SysMsgBoardStr |
280 | mov esi, [ctrl.ctrl_ids] |
280 | mov esi, [ctrl.ctrl_ids] |
281 | call SysMsgBoardStr |
281 | call SysMsgBoardStr |
282 | 282 | ||
283 | end if |
283 | end if |
284 | call init_controller |
284 | call init_controller |
285 | test eax, eax |
285 | test eax, eax |
286 | jz .fail |
286 | jz .fail |
287 | jmp .fail ;force fail |
287 | |
288 | - | ||
- | 288 | jmp .fail ;force fail |
|
289 | 289 | ||
290 | if DEBUG |
290 | if DEBUG |
291 | mov esi, msgInitCodec |
291 | mov esi, msgInitCodec |
292 | call SysMsgBoardStr |
292 | call SysMsgBoardStr |
293 | end if |
293 | end if |
294 | 294 | ||
295 | call init_codec |
295 | call init_codec |
296 | test eax, eax |
296 | test eax, eax |
297 | jz .fail |
297 | jz .fail |
298 | 298 | ||
299 | if DEBUG |
299 | if DEBUG |
300 | mov esi, [codec.ac_vendor_ids] |
300 | mov esi, [codec.ac_vendor_ids] |
301 | call SysMsgBoardStr |
301 | call SysMsgBoardStr |
302 | 302 | ||
303 | mov esi, [codec.chip_ids] |
303 | mov esi, [codec.chip_ids] |
304 | call SysMsgBoardStr |
304 | call SysMsgBoardStr |
305 | end if |
305 | end if |
306 | 306 | ||
307 | call reset_controller |
307 | call reset_controller |
308 | call setup_codec |
308 | call setup_codec |
309 | 309 | ||
310 | mov esi, msgPrimBuff |
310 | mov esi, msgPrimBuff |
311 | call SysMsgBoardStr |
311 | call SysMsgBoardStr |
312 | 312 | ||
313 | call create_primary_buff |
313 | call create_primary_buff |
314 | 314 | ||
315 | mov eax, VALID_IRQ |
315 | mov eax, VALID_IRQ |
316 | mov ebx, [ctrl.int_line] |
316 | mov ebx, [ctrl.int_line] |
317 | mov esi, msgInvIRQ |
317 | mov esi, msgInvIRQ |
318 | bt eax, ebx |
318 | bt eax, ebx |
319 | jnc .fail |
319 | jnc .fail |
320 | mov eax, ATTCH_IRQ |
320 | mov eax, ATTCH_IRQ |
321 | mov esi, msgAttchIRQ |
321 | mov esi, msgAttchIRQ |
322 | bt eax, ebx |
322 | bt eax, ebx |
323 | jnc .fail |
323 | jnc .fail |
324 | 324 | ||
325 | stdcall AttachIntHandler, ebx, ac97_irq |
325 | stdcall AttachIntHandler, ebx, ac97_irq |
326 | stdcall RegService, sz_sound_srv, service_proc |
326 | stdcall RegService, sz_sound_srv, service_proc |
327 | ret |
327 | ret |
328 | .fail: |
328 | .fail: |
329 | if DEBUG |
329 | if DEBUG |
330 | mov esi, msgFail |
330 | mov esi, msgFail |
331 | call SysMsgBoardStr |
331 | call SysMsgBoardStr |
332 | end if |
332 | end if |
333 | xor eax, eax |
333 | xor eax, eax |
334 | ret |
334 | ret |
335 | .stop: |
335 | .stop: |
336 | call stop |
336 | call stop |
337 | xor eax, eax |
337 | xor eax, eax |
338 | ret |
338 | ret |
339 | endp |
339 | endp |
340 | 340 | ||
341 | handle equ IOCTL.handle |
341 | handle equ IOCTL.handle |
342 | io_code equ IOCTL.io_code |
342 | io_code equ IOCTL.io_code |
343 | input equ IOCTL.input |
343 | input equ IOCTL.input |
344 | inp_size equ IOCTL.inp_size |
344 | inp_size equ IOCTL.inp_size |
345 | output equ IOCTL.output |
345 | output equ IOCTL.output |
346 | out_size equ IOCTL.out_size |
346 | out_size equ IOCTL.out_size |
347 | 347 | ||
348 | align 4 |
348 | align 4 |
349 | proc service_proc stdcall, ioctl:dword |
349 | proc service_proc stdcall, ioctl:dword |
350 | 350 | ||
351 | mov edi, [ioctl] |
351 | mov edi, [ioctl] |
352 | mov eax, [edi+io_code] |
352 | mov eax, [edi+io_code] |
353 | cmp eax, DEV_PLAY |
353 | cmp eax, DEV_PLAY |
354 | jne @F |
354 | jne @F |
355 | if DEBUG |
355 | if DEBUG |
356 | mov esi, msgPlay |
356 | mov esi, msgPlay |
357 | call SysMsgBoardStr |
357 | call SysMsgBoardStr |
358 | end if |
358 | end if |
359 | call play |
359 | call play |
360 | ret |
360 | ret |
361 | @@: |
361 | @@: |
362 | cmp eax, DEV_STOP |
362 | cmp eax, DEV_STOP |
363 | jne @F |
363 | jne @F |
364 | if DEBUG |
364 | if DEBUG |
365 | mov esi, msgStop |
365 | mov esi, msgStop |
366 | call SysMsgBoardStr |
366 | call SysMsgBoardStr |
367 | end if |
367 | end if |
368 | call stop |
368 | call stop |
369 | ret |
369 | ret |
370 | @@: |
370 | @@: |
371 | cmp eax, DEV_CALLBACK |
371 | cmp eax, DEV_CALLBACK |
372 | jne @F |
372 | jne @F |
373 | mov ebx, [edi+input] |
373 | mov ebx, [edi+input] |
374 | stdcall set_callback, [ebx] |
374 | stdcall set_callback, [ebx] |
375 | ret |
375 | ret |
376 | @@: |
376 | @@: |
377 | cmp eax, DEV_SET_MASTERVOL |
377 | cmp eax, DEV_SET_MASTERVOL |
378 | jne @F |
378 | jne @F |
379 | mov eax, [edi+input] |
379 | mov eax, [edi+input] |
380 | mov eax, [eax] |
380 | mov eax, [eax] |
381 | call set_master_vol ;eax= vol |
381 | call set_master_vol ;eax= vol |
382 | ret |
382 | ret |
383 | @@: |
383 | @@: |
384 | cmp eax, DEV_GET_MASTERVOL |
384 | cmp eax, DEV_GET_MASTERVOL |
385 | jne @F |
385 | jne @F |
386 | mov ebx, [edi+output] |
386 | mov ebx, [edi+output] |
387 | add ebx, new_app_base |
387 | add ebx, new_app_base |
388 | stdcall get_master_vol, ebx |
388 | stdcall get_master_vol, ebx |
389 | ret |
389 | ret |
390 | ;@@: |
390 | ;@@: |
391 | ; cmp eax, DEV_GET_INFO |
391 | ; cmp eax, DEV_GET_INFO |
392 | ; jne @F |
392 | ; jne @F |
393 | ; mov ebx, [edi+output] |
393 | ; mov ebx, [edi+output] |
394 | ; stdcall get_dev_info, ebx |
394 | ; stdcall get_dev_info, ebx |
395 | ; ret |
395 | ; ret |
396 | @@: |
396 | @@: |
397 | .fail: |
397 | .fail: |
398 | or eax, -1 |
398 | or eax, -1 |
399 | ret |
399 | ret |
400 | endp |
400 | endp |
401 | 401 | ||
402 | restore handle |
402 | restore handle |
403 | restore io_code |
403 | restore io_code |
404 | restore input |
404 | restore input |
405 | restore inp_size |
405 | restore inp_size |
406 | restore output |
406 | restore output |
407 | restore out_size |
407 | restore out_size |
408 | 408 | ||
409 | 409 | ||
410 | align 4 |
410 | align 4 |
411 | proc ac97_irq |
411 | proc ac97_irq |
412 | 412 | ||
413 | ; if DEBUG |
413 | ; if DEBUG |
414 | ; mov esi, msgIRQ |
414 | ; mov esi, msgIRQ |
415 | ; call SysMsgBoardStr |
415 | ; call SysMsgBoardStr |
416 | ; end if |
416 | ; end if |
417 | 417 | ||
418 | 418 | ||
419 | cmp [ctrl.user_callback], 0 |
419 | cmp [ctrl.user_callback], 0 |
420 | je @f |
420 | je @f |
421 | 421 | ||
422 | stdcall [ctrl.user_callback], ebx |
422 | stdcall [ctrl.user_callback], ebx |
423 | @@: |
423 | @@: |
424 | ret |
424 | ret |
425 | 425 | ||
426 | .skip: |
426 | .skip: |
427 | mov edx, PCM_OUT_CR_REG |
427 | mov edx, PCM_OUT_CR_REG |
428 | mov ax, 0x11 ;0x1D |
428 | mov ax, 0x11 ;0x1D |
429 | call [ctrl.ctrl_write8] |
429 | call [ctrl.ctrl_write8] |
430 | ret |
430 | ret |
431 | endp |
431 | endp |
432 | 432 | ||
433 | align 4 |
433 | align 4 |
434 | proc create_primary_buff |
434 | proc create_primary_buff |
435 | 435 | ||
436 | stdcall KernelAlloc, 0x10000 |
436 | stdcall KernelAlloc, 0x10000 |
437 | mov [ctrl.buffer], eax |
437 | mov [ctrl.buffer], eax |
438 | 438 | ||
439 | mov edi, eax |
439 | mov edi, eax |
440 | mov ecx, 0x10000/4 |
440 | mov ecx, 0x10000/4 |
441 | xor eax, eax |
441 | xor eax, eax |
442 | cld |
442 | cld |
443 | rep stosd |
443 | rep stosd |
444 | 444 | ||
445 | mov eax, [ctrl.buffer] |
445 | mov eax, [ctrl.buffer] |
446 | call GetPgAddr |
446 | call GetPgAddr |
447 | 447 | ||
448 | mov ebx, 0xC0002000 |
448 | mov ebx, 0xC0002000 |
449 | mov ecx, 4 |
449 | mov ecx, 4 |
450 | mov edi, pcmout_bdl |
450 | mov edi, pcmout_bdl |
451 | @@: |
451 | @@: |
452 | mov [edi], eax |
452 | mov [edi], eax |
453 | mov [edi+4], ebx |
453 | mov [edi+4], ebx |
454 | 454 | ||
455 | mov [edi+32], eax |
455 | mov [edi+32], eax |
456 | mov [edi+4+32], ebx |
456 | mov [edi+4+32], ebx |
457 | 457 | ||
458 | mov [edi+64], eax |
458 | mov [edi+64], eax |
459 | mov [edi+4+64], ebx |
459 | mov [edi+4+64], ebx |
460 | 460 | ||
461 | mov [edi+96], eax |
461 | mov [edi+96], eax |
462 | mov [edi+4+96], ebx |
462 | mov [edi+4+96], ebx |
463 | 463 | ||
464 | mov [edi+128], eax |
464 | mov [edi+128], eax |
465 | mov [edi+4+128], ebx |
465 | mov [edi+4+128], ebx |
466 | 466 | ||
467 | mov [edi+160], eax |
467 | mov [edi+160], eax |
468 | mov [edi+4+160], ebx |
468 | mov [edi+4+160], ebx |
469 | 469 | ||
470 | mov [edi+192], eax |
470 | mov [edi+192], eax |
471 | mov [edi+4+192], ebx |
471 | mov [edi+4+192], ebx |
472 | 472 | ||
473 | mov [edi+224], eax |
473 | mov [edi+224], eax |
474 | mov [edi+4+224], ebx |
474 | mov [edi+4+224], ebx |
475 | 475 | ||
476 | add eax, 0x4000 |
476 | add eax, 0x4000 |
477 | add edi, 8 |
477 | add edi, 8 |
478 | loop @B |
478 | loop @B |
479 | 479 | ||
480 | mov edi, buff_list |
480 | mov edi, buff_list |
481 | mov eax, [ctrl.buffer] |
481 | mov eax, [ctrl.buffer] |
482 | mov ecx, 4 |
482 | mov ecx, 4 |
483 | @@: |
483 | @@: |
484 | mov [edi], eax |
484 | mov [edi], eax |
485 | mov [edi+16], eax |
485 | mov [edi+16], eax |
486 | mov [edi+32], eax |
486 | mov [edi+32], eax |
487 | mov [edi+48], eax |
487 | mov [edi+48], eax |
488 | mov [edi+64], eax |
488 | mov [edi+64], eax |
489 | mov [edi+80], eax |
489 | mov [edi+80], eax |
490 | mov [edi+96], eax |
490 | mov [edi+96], eax |
491 | mov [edi+112], eax |
491 | mov [edi+112], eax |
492 | 492 | ||
493 | add eax, 0x4000 |
493 | add eax, 0x4000 |
494 | add edi, 4 |
494 | add edi, 4 |
495 | loop @B |
495 | loop @B |
496 | 496 | ||
497 | mov eax, pcmout_bdl |
497 | mov eax, pcmout_bdl |
498 | mov ebx, eax |
498 | mov ebx, eax |
499 | call GetPgAddr ;eax |
499 | call GetPgAddr ;eax |
500 | and ebx, 0xFFF |
500 | and ebx, 0xFFF |
501 | add eax, ebx |
501 | add eax, ebx |
502 | 502 | ||
503 | mov edx, PCM_OUT_BDL |
503 | mov edx, PCM_OUT_BDL |
504 | call [ctrl.ctrl_write32] |
504 | call [ctrl.ctrl_write32] |
505 | 505 | ||
506 | mov eax, 16 |
506 | mov eax, 16 |
507 | mov [ctrl.lvi_reg], eax |
507 | mov [ctrl.lvi_reg], eax |
508 | mov edx, PCM_OUT_LVI_REG |
508 | mov edx, PCM_OUT_LVI_REG |
509 | call [ctrl.ctrl_write8] |
509 | call [ctrl.ctrl_write8] |
510 | ret |
510 | ret |
511 | endp |
511 | endp |
512 | 512 | ||
513 | align 4 |
513 | align 4 |
514 | proc detect_controller |
514 | proc detect_controller |
515 | locals |
515 | locals |
516 | last_bus dd ? |
516 | last_bus dd ? |
517 | bus dd ? |
517 | bus dd ? |
518 | devfn dd ? |
518 | devfn dd ? |
519 | endl |
519 | endl |
520 | 520 | ||
521 | xor eax, eax |
521 | xor eax, eax |
522 | mov [bus], eax |
522 | mov [bus], eax |
523 | inc eax |
523 | inc eax |
524 | call PciApi |
524 | call PciApi |
525 | cmp eax, -1 |
525 | cmp eax, -1 |
526 | je .err |
526 | je .err |
527 | 527 | ||
528 | mov [last_bus], eax |
528 | mov [last_bus], eax |
529 | 529 | ||
530 | .next_bus: |
530 | .next_bus: |
531 | and [devfn], 0 |
531 | and [devfn], 0 |
532 | .next_dev: |
532 | .next_dev: |
533 | stdcall PciRead32, [bus], [devfn], dword 0 |
533 | stdcall PciRead32, [bus], [devfn], dword 0 |
534 | test eax, eax |
534 | test eax, eax |
535 | jz .next |
535 | jz .next |
536 | cmp eax, -1 |
536 | cmp eax, -1 |
537 | je .next |
537 | je .next |
538 | 538 | ||
539 | mov edi, devices |
539 | mov edi, devices |
540 | @@: |
540 | @@: |
541 | mov ebx, [edi] |
541 | mov ebx, [edi] |
542 | test ebx, ebx |
542 | test ebx, ebx |
543 | jz .next |
543 | jz .next |
544 | 544 | ||
545 | cmp eax, ebx |
545 | cmp eax, ebx |
546 | je .found |
546 | je .found |
547 | add edi, 12 |
547 | add edi, 12 |
548 | jmp @B |
548 | jmp @B |
549 | 549 | ||
550 | .next: |
550 | .next: |
551 | inc [devfn] |
551 | inc [devfn] |
552 | cmp [devfn], 256 |
552 | cmp [devfn], 256 |
553 | jb .next_dev |
553 | jb .next_dev |
554 | mov eax, [bus] |
554 | mov eax, [bus] |
555 | inc eax |
555 | inc eax |
556 | mov [bus], eax |
556 | mov [bus], eax |
557 | cmp eax, [last_bus] |
557 | cmp eax, [last_bus] |
558 | jna .next_bus |
558 | jna .next_bus |
559 | xor eax, eax |
559 | xor eax, eax |
560 | ret |
560 | ret |
561 | .found: |
561 | .found: |
562 | mov ebx, [bus] |
562 | mov ebx, [bus] |
563 | mov [ctrl.bus], ebx |
563 | mov [ctrl.bus], ebx |
564 | 564 | ||
565 | mov ecx, [devfn] |
565 | mov ecx, [devfn] |
566 | mov [ctrl.devfn], ecx |
566 | mov [ctrl.devfn], ecx |
567 | 567 | ||
568 | mov edx, eax |
568 | mov edx, eax |
569 | and edx, 0xFFFF |
569 | and edx, 0xFFFF |
570 | mov [ctrl.vendor], edx |
570 | mov [ctrl.vendor], edx |
571 | shr eax, 16 |
571 | shr eax, 16 |
572 | mov [ctrl.dev_id], eax |
572 | mov [ctrl.dev_id], eax |
573 | 573 | ||
574 | mov ebx, [edi+4] |
574 | mov ebx, [edi+4] |
575 | mov [ctrl.ctrl_ids], ebx |
575 | mov [ctrl.ctrl_ids], ebx |
576 | mov esi, [edi+8] |
576 | mov esi, [edi+8] |
577 | mov [ctrl.ctrl_setup], esi |
577 | mov [ctrl.ctrl_setup], esi |
578 | 578 | ||
579 | cmp ebx, 0x1274 |
579 | cmp ebx, 0x1274 |
580 | jne @F |
580 | jne @F |
581 | mov [ctrl.vendor_ids], msgEnsoniq |
581 | mov [ctrl.vendor_ids], msgEnsoniq |
582 | ret |
582 | ret |
583 | @@: |
583 | @@: |
584 | mov [ctrl.vendor_ids], 0 ;something wrong ? |
584 | mov [ctrl.vendor_ids], 0 ;something wrong ? |
585 | ret |
585 | ret |
586 | .err: |
586 | .err: |
587 | xor eax, eax |
587 | xor eax, eax |
588 | ret |
588 | ret |
589 | endp |
589 | endp |
590 | 590 | ||
591 | align 4 |
591 | align 4 |
592 | proc init_controller |
592 | proc init_controller |
593 | 593 | ||
594 | mov esi, msgPCIcmd |
594 | mov esi, msgPCIcmd |
595 | call SysMsgBoardStr |
595 | call SysMsgBoardStr |
596 | 596 | ||
597 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 |
597 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 |
598 | mov ebx, eax |
598 | mov ebx, eax |
599 | and eax, 0xFFFF |
599 | and eax, 0xFFFF |
600 | mov [ctrl.pci_cmd], eax |
600 | mov [ctrl.pci_cmd], eax |
601 | shr ebx, 16 |
601 | shr ebx, 16 |
602 | mov [ctrl.pci_stat], ebx |
602 | mov [ctrl.pci_stat], ebx |
603 | 603 | ||
604 | call dword2str |
604 | call dword2str |
605 | call SysMsgBoardStr |
605 | call SysMsgBoardStr |
606 | 606 | ||
607 | mov esi, msgIObase |
607 | mov esi, msgIObase |
608 | call SysMsgBoardStr |
608 | call SysMsgBoardStr |
609 | 609 | ||
610 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 |
610 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 |
611 | and eax,0xFFFE |
611 | ; and eax, -16 |
612 | mov [ctrl.codec_io_base], eax |
612 | mov [ctrl.ctrl_io_base], eax |
613 | 613 | ||
614 | call dword2str |
614 | call dword2str |
615 | call SysMsgBoardStr |
615 | call SysMsgBoardStr |
616 | 616 | ||
617 | mov esi, msgIntline |
617 | mov esi, msgIRQline |
618 | call SysMsgBoardStr |
618 | call SysMsgBoardStr |
619 | 619 | ||
620 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C |
620 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C |
621 | and eax, 0xFF |
621 | and eax, 0xFF |
622 | mov [ctrl.int_line], eax |
622 | mov [ctrl.int_line], eax |
623 | 623 | ||
624 | call dword2str |
624 | call dword2str |
625 | call SysMsgBoardStr |
625 | call SysMsgBoardStr |
626 | 626 | ||
627 | call [ctrl.ctrl_setup] |
627 | call [ctrl.ctrl_setup] |
628 | xor eax, eax |
628 | xor eax, eax |
629 | inc eax |
629 | inc eax |
630 | ret |
630 | ret |
631 | endp |
631 | endp |
632 | 632 | ||
633 | align 4 |
633 | align 4 |
634 | proc set_ICH |
634 | proc set_ICH |
635 | mov [ctrl.codec_read16], codec_io_r16 ;virtual |
635 | mov [ctrl.codec_read16], codec_io_r16 ;virtual |
636 | mov [ctrl.codec_write16], codec_io_w16 ;virtual |
636 | mov [ctrl.codec_write16], codec_io_w16 ;virtual |
637 | 637 | ||
638 | mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual |
638 | mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual |
639 | mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual |
639 | mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual |
640 | mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual |
640 | mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual |
641 | 641 | ||
642 | mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual |
642 | mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual |
643 | mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual |
643 | mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual |
644 | mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual |
644 | mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual |
645 | ret |
645 | ret |
646 | endp |
646 | endp |
647 | 647 | ||
648 | PG_SW equ 0x003 |
- | |
649 | PG_NOCACHE equ 0x018 |
- | |
650 | - | ||
651 | - | ||
652 | align 4 |
648 | align 4 |
653 | proc reset_controller |
649 | proc reset_controller |
654 | 650 | ||
655 | xor eax, eax |
651 | xor eax, eax |
656 | mov edx, PCM_IN_CR_REG |
652 | mov edx, PCM_IN_CR_REG |
657 | call [ctrl.ctrl_write8] |
653 | call [ctrl.ctrl_write8] |
658 | 654 | ||
659 | mov edx, PCM_OUT_CR_REG |
655 | mov edx, PCM_OUT_CR_REG |
660 | call [ctrl.ctrl_write8] |
656 | call [ctrl.ctrl_write8] |
661 | 657 | ||
662 | mov edx, MC_IN_CR_REG |
658 | mov edx, MC_IN_CR_REG |
663 | call [ctrl.ctrl_write8] |
659 | call [ctrl.ctrl_write8] |
664 | 660 | ||
665 | mov eax, RR |
661 | mov eax, RR |
666 | mov edx, PCM_IN_CR_REG |
662 | mov edx, PCM_IN_CR_REG |
667 | call [ctrl.ctrl_write8] |
663 | call [ctrl.ctrl_write8] |
668 | 664 | ||
669 | mov edx, PCM_OUT_CR_REG |
665 | mov edx, PCM_OUT_CR_REG |
670 | call [ctrl.ctrl_write8] |
666 | call [ctrl.ctrl_write8] |
671 | 667 | ||
672 | mov edx, MC_IN_CR_REG |
668 | mov edx, MC_IN_CR_REG |
673 | call [ctrl.ctrl_write8] |
669 | call [ctrl.ctrl_write8] |
674 | ret |
670 | ret |
675 | endp |
671 | endp |
676 | 672 | ||
677 | align 4 |
673 | align 4 |
678 | proc init_codec |
674 | proc init_codec |
679 | locals |
675 | locals |
680 | counter dd ? |
676 | counter dd ? |
681 | endl |
677 | endl |
682 | 678 | ||
683 | mov esi, msgControl |
679 | mov esi, msgControl |
684 | call SysMsgBoardStr |
680 | call SysMsgBoardStr |
685 | 681 | ||
686 | mov edx, GLOB_CTRL |
682 | mov edx, GLOB_CTRL |
687 | call [ctrl.ctrl_read32] |
683 | call [ctrl.ctrl_read32] |
688 | call dword2str |
684 | call dword2str |
689 | call SysMsgBoardStr |
685 | call SysMsgBoardStr |
690 | 686 | ||
691 | mov esi, msgStatus |
687 | mov esi, msgStatus |
692 | call SysMsgBoardStr |
688 | call SysMsgBoardStr |
693 | 689 | ||
694 | mov edx, CTRL_STAT |
690 | mov edx, CTRL_STAT |
695 | call [ctrl.ctrl_read32] |
691 | call [ctrl.ctrl_read32] |
696 | 692 | ||
697 | call dword2str |
693 | call dword2str |
698 | call SysMsgBoardStr |
694 | call SysMsgBoardStr |
699 | 695 | ||
700 | test eax, CTRL_ST_CREADY |
696 | test eax, CTRL_ST_CREADY |
701 | jnz .ready |
697 | jnz .ready |
702 | 698 | ||
703 | call reset_codec |
699 | call reset_codec |
704 | and eax, eax |
700 | and eax, eax |
705 | jz .err |
701 | jz .err |
706 | 702 | ||
707 | xor edx, edx ;ac_reg_0 |
703 | xor edx, edx ;ac_reg_0 |
708 | call [ctrl.codec_write16] |
704 | call [ctrl.codec_write16] |
709 | 705 | ||
710 | xor eax, eax |
706 | xor eax, eax |
711 | mov edx, CODEC_REG_POWERDOWN |
707 | mov edx, CODEC_REG_POWERDOWN |
712 | call [ctrl.codec_write16] |
708 | call [ctrl.codec_write16] |
713 | 709 | ||
714 | mov [counter], 200 ; total 200*5 ms = 1s |
710 | mov [counter], 200 ; total 200*5 ms = 1s |
715 | .wait: |
711 | .wait: |
716 | mov edx, CODEC_REG_POWERDOWN |
712 | mov edx, CODEC_REG_POWERDOWN |
717 | call [ctrl.codec_read16] |
713 | call [ctrl.codec_read16] |
718 | and eax, 0x0F |
714 | and eax, 0x0F |
719 | cmp eax, 0x0F |
715 | cmp eax, 0x0F |
720 | jz .ready |
716 | jz .ready |
721 | 717 | ||
722 | mov eax, 5000 ; wait 5 ms |
718 | mov eax, 5000 ; wait 5 ms |
723 | call StallExec |
719 | call StallExec |
724 | sub [counter] , 1 |
720 | sub [counter] , 1 |
725 | jnz .wait |
721 | jnz .wait |
726 | .err: |
722 | .err: |
727 | xor eax, eax ; timeout error |
723 | xor eax, eax ; timeout error |
728 | ret |
724 | ret |
729 | .ready: |
725 | .ready: |
730 | call detect_codec |
726 | call detect_codec |
731 | 727 | ||
732 | xor eax, eax |
728 | xor eax, eax |
733 | inc eax |
729 | inc eax |
734 | ret |
730 | ret |
735 | endp |
731 | endp |
736 | 732 | ||
737 | align 4 |
733 | align 4 |
738 | proc reset_codec |
734 | proc reset_codec |
739 | mov edx, GLOB_CTRL |
735 | mov edx, GLOB_CTRL |
740 | call [ctrl.ctrl_read32] |
736 | call [ctrl.ctrl_read32] |
741 | 737 | ||
742 | test eax, 0x02 |
738 | test eax, 0x02 |
743 | jz .cold |
739 | jz .cold |
744 | 740 | ||
745 | call warm_reset |
741 | call warm_reset |
746 | jnc .ok |
742 | jnc .ok |
747 | .cold: |
743 | .cold: |
748 | call cold_reset |
744 | call cold_reset |
749 | jnc .ok |
745 | jnc .ok |
750 | 746 | ||
751 | if DEBUG |
747 | if DEBUG |
752 | mov esi, msgCFail |
748 | mov esi, msgCFail |
753 | call SysMsgBoardStr |
749 | call SysMsgBoardStr |
754 | end if |
750 | end if |
755 | xor eax, eax ; timeout error |
751 | xor eax, eax ; timeout error |
756 | ret |
752 | ret |
757 | .ok: |
753 | .ok: |
758 | if DEBUG |
754 | if DEBUG |
759 | mov esi, msgResetOk |
755 | mov esi, msgResetOk |
760 | call SysMsgBoardStr |
756 | call SysMsgBoardStr |
761 | end if |
757 | end if |
762 | 758 | ||
763 | xor eax, eax |
759 | xor eax, eax |
764 | inc eax |
760 | inc eax |
765 | ret |
761 | ret |
766 | endp |
762 | endp |
767 | 763 | ||
768 | align 4 |
764 | align 4 |
769 | proc warm_reset |
765 | proc warm_reset |
770 | locals |
766 | locals |
771 | counter dd ? |
767 | counter dd ? |
772 | endl |
768 | endl |
773 | 769 | ||
774 | mov eax, 0x06 |
770 | mov eax, 0x06 |
775 | mov edx, GLOB_CTRL |
771 | mov edx, GLOB_CTRL |
776 | call [ctrl.ctrl_write32] |
772 | call [ctrl.ctrl_write32] |
777 | 773 | ||
778 | if DEBUG |
774 | if DEBUG |
779 | mov esi, msgWarm |
775 | mov esi, msgWarm |
780 | call SysMsgBoardStr |
776 | call SysMsgBoardStr |
781 | end if |
777 | end if |
782 | 778 | ||
783 | mov [counter], 10 ; total 10*100 ms = 1s |
779 | mov [counter], 10 ; total 10*100 ms = 1s |
784 | .wait: |
780 | .wait: |
785 | mov eax, 100000 ; wait 100 ms |
781 | mov eax, 100000 ; wait 100 ms |
786 | call StallExec |
782 | call StallExec |
787 | 783 | ||
788 | mov edx, GLOB_CTRL |
784 | mov edx, GLOB_CTRL |
789 | call [ctrl.ctrl_read32] |
785 | call [ctrl.ctrl_read32] |
790 | test eax, 4 |
786 | test eax, 4 |
791 | jz .ok |
787 | jz .ok |
792 | sub [counter], 1 |
788 | sub [counter], 1 |
793 | jnz .wait |
789 | jnz .wait |
794 | 790 | ||
795 | if DEBUG |
791 | if DEBUG |
796 | mov esi, msgWRFail |
792 | mov esi, msgWRFail |
797 | call SysMsgBoardStr |
793 | call SysMsgBoardStr |
798 | end if |
794 | end if |
799 | 795 | ||
800 | stc |
796 | stc |
801 | ret |
797 | ret |
802 | .ok: |
798 | .ok: |
803 | mov edx, CTRL_STAT |
799 | mov edx, CTRL_STAT |
804 | call [ctrl.ctrl_read32] |
800 | call [ctrl.ctrl_read32] |
805 | and eax, CTRL_ST_CREADY |
801 | and eax, CTRL_ST_CREADY |
806 | jz .fail |
802 | jz .fail |
807 | clc |
803 | clc |
808 | ret |
804 | ret |
809 | .fail: |
805 | .fail: |
810 | stc |
806 | stc |
811 | ret |
807 | ret |
812 | endp |
808 | endp |
813 | 809 | ||
814 | align 4 |
810 | align 4 |
815 | proc cold_reset |
811 | proc cold_reset |
816 | locals |
812 | locals |
817 | counter dd ? |
813 | counter dd ? |
818 | endl |
814 | endl |
819 | 815 | ||
820 | xor eax, eax |
816 | xor eax, eax |
821 | mov edx, GLOB_CTRL |
817 | mov edx, GLOB_CTRL |
822 | call [ctrl.ctrl_write32] |
818 | call [ctrl.ctrl_write32] |
823 | 819 | ||
824 | if DEBUG |
820 | if DEBUG |
825 | mov esi, msgCold |
821 | mov esi, msgCold |
826 | call SysMsgBoardStr |
822 | call SysMsgBoardStr |
827 | end if |
823 | end if |
828 | 824 | ||
829 | mov eax, 1000000 ; wait 1 s |
825 | mov eax, 1000000 ; wait 1 s |
830 | call StallExec |
826 | call StallExec |
831 | 827 | ||
832 | mov eax, 2 |
828 | mov eax, 2 |
833 | mov edx, GLOB_CTRL |
829 | mov edx, GLOB_CTRL |
834 | call [ctrl.ctrl_write32] |
830 | call [ctrl.ctrl_write32] |
835 | 831 | ||
836 | mov [counter], 10 ; total 10*100 ms = 1s |
832 | mov [counter], 10 ; total 10*100 ms = 1s |
837 | .wait: |
833 | .wait: |
838 | mov eax, 100000 ; wait 100 ms |
834 | mov eax, 100000 ; wait 100 ms |
839 | call StallExec |
835 | call StallExec |
840 | 836 | ||
841 | mov edx, GLOB_CTRL |
837 | mov edx, GLOB_CTRL |
842 | call [ctrl.ctrl_read32] |
838 | call [ctrl.ctrl_read32] |
843 | test eax, 4 |
839 | test eax, 4 |
844 | jz .ok |
840 | jz .ok |
845 | sub [counter], 1 |
841 | sub [counter], 1 |
846 | jnz .wait |
842 | jnz .wait |
847 | 843 | ||
848 | if DEBUG |
844 | if DEBUG |
849 | mov esi, msgCRFail |
845 | mov esi, msgCRFail |
850 | call SysMsgBoardStr |
846 | call SysMsgBoardStr |
851 | end if |
847 | end if |
852 | stc |
848 | stc |
853 | ret |
849 | ret |
854 | .ok: |
850 | .ok: |
855 | mov edx, CTRL_STAT |
851 | mov edx, CTRL_STAT |
856 | call [ctrl.ctrl_read32] |
852 | call [ctrl.ctrl_read32] |
857 | and eax, CTRL_ST_CREADY |
853 | and eax, CTRL_ST_CREADY |
858 | jz .fail |
854 | jz .fail |
859 | clc |
855 | clc |
860 | ret |
856 | ret |
861 | .fail: |
857 | .fail: |
862 | stc |
858 | stc |
863 | ret |
859 | ret |
864 | endp |
860 | endp |
865 | 861 | ||
866 | align 4 |
862 | align 4 |
867 | play: |
863 | play: |
868 | mov eax, 16 |
864 | mov eax, 16 |
869 | mov [ctrl.lvi_reg], eax |
865 | mov [ctrl.lvi_reg], eax |
870 | mov edx, PCM_OUT_LVI_REG |
866 | mov edx, PCM_OUT_LVI_REG |
871 | call [ctrl.ctrl_write8] |
867 | call [ctrl.ctrl_write8] |
872 | 868 | ||
873 | mov edx, PCM_OUT_CR_REG |
869 | mov edx, PCM_OUT_CR_REG |
874 | mov ax, 0x1D |
870 | mov ax, 0x1D |
875 | call [ctrl.ctrl_write8] |
871 | call [ctrl.ctrl_write8] |
876 | xor eax, eax |
872 | xor eax, eax |
877 | ret |
873 | ret |
878 | 874 | ||
879 | align 4 |
875 | align 4 |
880 | stop: |
876 | stop: |
881 | mov edx, PCM_OUT_CR_REG |
877 | mov edx, PCM_OUT_CR_REG |
882 | mov ax, 0x0 |
878 | mov ax, 0x0 |
883 | call [ctrl.ctrl_write8] |
879 | call [ctrl.ctrl_write8] |
884 | 880 | ||
885 | mov ax, 0x1c |
881 | mov ax, 0x1c |
886 | mov edx, PCM_OUT_SR_REG |
882 | mov edx, PCM_OUT_SR_REG |
887 | call [ctrl.ctrl_write16] |
883 | call [ctrl.ctrl_write16] |
888 | xor eax, eax |
884 | xor eax, eax |
889 | ret |
885 | ret |
890 | 886 | ||
891 | align 4 |
887 | align 4 |
892 | proc get_dev_info stdcall, p_info:dword |
888 | proc get_dev_info stdcall, p_info:dword |
893 | virtual at esi |
889 | virtual at esi |
894 | CTRL_INFO CTRL_INFO |
890 | CTRL_INFO CTRL_INFO |
895 | end virtual |
891 | end virtual |
896 | 892 | ||
897 | mov esi, [p_info] |
893 | mov esi, [p_info] |
898 | mov eax, [ctrl.int_line] |
894 | mov eax, [ctrl.int_line] |
899 | mov ebx, [ctrl.codec_io_base] |
895 | mov ebx, [ctrl.codec_io_base] |
900 | mov ecx, [ctrl.ctrl_io_base] |
896 | mov ecx, [ctrl.ctrl_io_base] |
901 | mov edx, [ctrl.codec_mem_base] |
897 | mov edx, [ctrl.codec_mem_base] |
902 | mov edi, [ctrl.ctrl_mem_base] |
898 | mov edi, [ctrl.ctrl_mem_base] |
903 | 899 | ||
904 | mov [CTRL_INFO.irq], eax |
900 | mov [CTRL_INFO.irq], eax |
905 | mov [CTRL_INFO.codec_io_base], ebx |
901 | mov [CTRL_INFO.codec_io_base], ebx |
906 | mov [CTRL_INFO.ctrl_io_base], ecx |
902 | mov [CTRL_INFO.ctrl_io_base], ecx |
907 | mov [CTRL_INFO.codec_mem_base], edx |
903 | mov [CTRL_INFO.codec_mem_base], edx |
908 | mov [CTRL_INFO.ctrl_mem_base], edi |
904 | mov [CTRL_INFO.ctrl_mem_base], edi |
909 | 905 | ||
910 | mov eax, [codec.chip_id] |
906 | mov eax, [codec.chip_id] |
911 | mov [CTRL_INFO.codec_id], eax |
907 | mov [CTRL_INFO.codec_id], eax |
912 | 908 | ||
913 | mov edx, GLOB_CTRL |
909 | mov edx, GLOB_CTRL |
914 | call [ctrl.ctrl_read32] |
910 | call [ctrl.ctrl_read32] |
915 | mov [CTRL_INFO.glob_cntrl], eax |
911 | mov [CTRL_INFO.glob_cntrl], eax |
916 | 912 | ||
917 | mov edx, CTRL_STAT |
913 | mov edx, CTRL_STAT |
918 | call [ctrl.ctrl_read32] |
914 | call [ctrl.ctrl_read32] |
919 | mov [CTRL_INFO.glob_sta], eax |
915 | mov [CTRL_INFO.glob_sta], eax |
920 | 916 | ||
921 | mov ebx, [ctrl.pci_cmd] |
917 | mov ebx, [ctrl.pci_cmd] |
922 | mov [CTRL_INFO.pci_cmd], ebx |
918 | mov [CTRL_INFO.pci_cmd], ebx |
923 | ret |
919 | ret |
924 | endp |
920 | endp |
925 | 921 | ||
926 | align 4 |
922 | align 4 |
927 | proc set_callback stdcall, handler:dword |
923 | proc set_callback stdcall, handler:dword |
928 | mov eax, [handler] |
924 | mov eax, [handler] |
929 | mov [ctrl.user_callback], eax |
925 | mov [ctrl.user_callback], eax |
930 | ret |
926 | ret |
931 | endp |
927 | endp |
932 | 928 | ||
933 | align 4 |
929 | align 4 |
934 | proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax |
930 | proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax |
935 | 931 | ||
936 | mov edx, [ac_reg] |
932 | mov edx, [ac_reg] |
937 | 933 | ||
938 | mov ebx, edx |
934 | mov ebx, edx |
939 | shr ebx, 1 |
935 | shr ebx, 1 |
940 | bt [codec.shadow_flag], ebx |
936 | bt [codec.shadow_flag], ebx |
941 | jc .use_shadow |
937 | jc .use_shadow |
942 | 938 | ||
943 | call [ctrl.codec_read16] ;change edx !!! |
939 | call [ctrl.codec_read16] ;change edx !!! |
944 | mov ecx, eax |
940 | mov ecx, eax |
945 | 941 | ||
946 | mov edx, CTRL_STAT |
942 | mov edx, CTRL_STAT |
947 | call [ctrl.ctrl_read32] |
943 | call [ctrl.ctrl_read32] |
948 | test eax, CTRL_ST_RCS |
944 | test eax, CTRL_ST_RCS |
949 | jz .read_ok |
945 | jz .read_ok |
950 | 946 | ||
951 | mov edx, CTRL_STAT |
947 | mov edx, CTRL_STAT |
952 | call [ctrl.ctrl_write32] |
948 | call [ctrl.ctrl_write32] |
953 | xor eax,eax |
949 | xor eax,eax |
954 | not eax ;timeout |
950 | not eax ;timeout |
955 | ret |
951 | ret |
956 | .read_ok: |
952 | .read_ok: |
957 | mov edx, [ac_reg] |
953 | mov edx, [ac_reg] |
958 | mov [codec.regs+edx], cx |
954 | mov [codec.regs+edx], cx |
959 | bts [codec.shadow_flag], ebx |
955 | bts [codec.shadow_flag], ebx |
960 | mov eax, ecx |
956 | mov eax, ecx |
961 | ret |
957 | ret |
962 | .use_shadow: |
958 | .use_shadow: |
963 | movzx eax, word [codec.regs+edx] |
959 | movzx eax, word [codec.regs+edx] |
964 | ret |
960 | ret |
965 | endp |
961 | endp |
966 | 962 | ||
967 | align 4 |
963 | align 4 |
968 | proc codec_write stdcall, ac_reg:dword |
964 | proc codec_write stdcall, ac_reg:dword |
969 | push eax |
965 | push eax |
970 | call check_semafore |
966 | call check_semafore |
971 | and eax, eax |
967 | and eax, eax |
972 | jz .err |
968 | jz .err |
973 | pop eax |
969 | pop eax |
974 | 970 | ||
975 | mov esi, [ac_reg] |
971 | mov esi, [ac_reg] |
976 | mov edx, esi |
972 | mov edx, esi |
977 | call [ctrl.codec_write16] |
973 | call [ctrl.codec_write16] |
978 | mov [codec.regs+esi], ax |
974 | mov [codec.regs+esi], ax |
979 | shr esi, 1 |
975 | shr esi, 1 |
980 | bts [codec.shadow_flag], esi |
976 | bts [codec.shadow_flag], esi |
981 | ret |
977 | ret |
982 | .err: |
978 | .err: |
983 | pop eax |
979 | pop eax |
984 | ret |
980 | ret |
985 | endp |
981 | endp |
986 | 982 | ||
987 | align 4 |
983 | align 4 |
988 | proc codec_check_ready |
984 | proc codec_check_ready |
989 | 985 | ||
990 | mov edx, CTRL_ST |
986 | mov edx, CTRL_ST |
991 | call [ctrl.ctrl_read32] |
987 | call [ctrl.ctrl_read32] |
992 | and eax, CTRL_ST_CREADY |
988 | and eax, CTRL_ST_CREADY |
993 | jz .not_ready |
989 | jz .not_ready |
994 | 990 | ||
995 | xor eax, wax |
991 | xor eax, wax |
996 | inc eax |
992 | inc eax |
997 | ret |
993 | ret |
998 | .not_ready: |
994 | .not_ready: |
999 | xor eax, eax |
995 | xor eax, eax |
1000 | ret |
996 | ret |
1001 | endp |
997 | endp |
1002 | 998 | ||
1003 | align 4 |
999 | align 4 |
1004 | proc check_semafore |
1000 | proc check_semafore |
1005 | local counter:DWORD |
1001 | local counter:DWORD |
1006 | 1002 | ||
1007 | mov [counter], 100 |
1003 | mov [counter], 100 |
1008 | .l1: |
1004 | .l1: |
1009 | mov edx, CTRL_CAS |
1005 | mov edx, CTRL_CAS |
1010 | call [ctrl.ctrl_read8] |
1006 | call [ctrl.ctrl_read8] |
1011 | and eax, CAS_FLAG |
1007 | and eax, CAS_FLAG |
1012 | jz .ok |
1008 | jz .ok |
1013 | 1009 | ||
1014 | mov eax, 1 |
1010 | mov eax, 1 |
1015 | call StallExec |
1011 | call StallExec |
1016 | sub [counter], 1 |
1012 | sub [counter], 1 |
1017 | jnz .l1 |
1013 | jnz .l1 |
1018 | xor eax, eax |
1014 | xor eax, eax |
1019 | ret |
1015 | ret |
1020 | align 4 |
1016 | align 4 |
1021 | .ok: |
1017 | .ok: |
1022 | xor eax,eax |
1018 | xor eax,eax |
1023 | inc eax |
1019 | inc eax |
1024 | ret |
1020 | ret |
1025 | endp |
1021 | endp |
1026 | 1022 | ||
1027 | align 4 |
1023 | align 4 |
1028 | proc StallExec |
1024 | proc StallExec |
1029 | push ecx |
1025 | push ecx |
1030 | push edx |
1026 | push edx |
1031 | push ebx |
1027 | push ebx |
1032 | push eax |
1028 | push eax |
1033 | 1029 | ||
1034 | mov ecx, CPU_FREQ |
1030 | mov ecx, CPU_FREQ |
1035 | mul ecx |
1031 | mul ecx |
1036 | mov ebx, eax ;low |
1032 | mov ebx, eax ;low |
1037 | mov ecx, edx ;high |
1033 | mov ecx, edx ;high |
1038 | rdtsc |
1034 | rdtsc |
1039 | add ebx, eax |
1035 | add ebx, eax |
1040 | adc ecx,edx |
1036 | adc ecx,edx |
1041 | @@: |
1037 | @@: |
1042 | rdtsc |
1038 | rdtsc |
1043 | sub eax, ebx |
1039 | sub eax, ebx |
1044 | sbb edx, ecx |
1040 | sbb edx, ecx |
1045 | js @B |
1041 | js @B |
1046 | 1042 | ||
1047 | pop eax |
1043 | pop eax |
1048 | pop ebx |
1044 | pop ebx |
1049 | pop edx |
1045 | pop edx |
1050 | pop ecx |
1046 | pop ecx |
1051 | ret |
1047 | ret |
1052 | endp |
1048 | endp |
1053 | 1049 | ||
1054 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1050 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1055 | ; CONTROLLER IO functions |
1051 | ; CONTROLLER IO functions |
1056 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1052 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1057 | 1053 | ||
1058 | align 4 |
1054 | align 4 |
1059 | proc codec_io_r16 |
1055 | codec_io_r16: |
1060 | add edx, [ctrl.codec_io_base] |
1056 | add edx, [ctrl.codec_io_base] |
1061 | in ax, dx |
1057 | in ax, dx |
1062 | ret |
1058 | ret |
1063 | endp |
1059 | |
1064 | - | ||
1065 | align 4 |
1060 | align 4 |
1066 | proc codec_io_w16 |
1061 | codec_io_w16: |
1067 | add edx, [ctrl.codec_io_base] |
1062 | add edx, [ctrl.codec_io_base] |
1068 | out dx, ax |
1063 | out dx, ax |
1069 | ret |
1064 | ret |
1070 | endp |
1065 | |
1071 | - | ||
1072 | align 4 |
1066 | align 4 |
1073 | proc ctrl_io_r8 |
1067 | ctrl_io_r8: |
1074 | add edx, [ctrl.ctrl_io_base] |
1068 | add edx, [ctrl.ctrl_io_base] |
1075 | in al, dx |
1069 | in al, dx |
1076 | ret |
1070 | ret |
1077 | endp |
1071 | |
1078 | - | ||
1079 | align 4 |
1072 | align 4 |
1080 | proc ctrl_io_r16 |
1073 | ctrl_io_r16: |
1081 | add edx, [ctrl.ctrl_io_base] |
1074 | add edx, [ctrl.ctrl_io_base] |
1082 | in ax, dx |
1075 | in ax, dx |
1083 | ret |
1076 | ret |
1084 | endp |
1077 | |
1085 | - | ||
1086 | align 4 |
1078 | align 4 |
1087 | proc ctrl_io_r32 |
1079 | ctrl_io_r32: |
1088 | add edx, [ctrl.ctrl_io_base] |
1080 | add edx, [ctrl.ctrl_io_base] |
1089 | in eax, dx |
1081 | in eax, dx |
1090 | ret |
1082 | ret |
1091 | endp |
1083 | |
1092 | - | ||
1093 | align 4 |
1084 | align 4 |
1094 | proc ctrl_io_w8 |
1085 | ctrl_io_w8: |
1095 | add edx, [ctrl.ctrl_io_base] |
1086 | add edx, [ctrl.ctrl_io_base] |
1096 | out dx, al |
1087 | out dx, al |
1097 | ret |
1088 | ret |
1098 | endp |
1089 | |
1099 | - | ||
1100 | align 4 |
1090 | align 4 |
1101 | proc ctrl_io_w16 |
1091 | ctrl_io_w16: |
1102 | add edx, [ctrl.ctrl_io_base] |
1092 | add edx, [ctrl.ctrl_io_base] |
1103 | out dx, ax |
1093 | out dx, ax |
1104 | ret |
1094 | ret |
1105 | endp |
1095 | |
1106 | - | ||
1107 | align 4 |
1096 | align 4 |
1108 | proc ctrl_io_w32 |
1097 | ctrl_io_w32: |
1109 | add edx, [ctrl.ctrl_io_base] |
1098 | add edx, [ctrl.ctrl_io_base] |
1110 | out dx, eax |
1099 | out dx, eax |
1111 | ret |
1100 | ret |
1112 | endp |
1101 | |
1113 | - | ||
1114 | 1102 | ||
1115 | align 4 |
1103 | align 4 |
1116 | dword2str: |
1104 | dword2str: |
1117 | mov esi, hex_buff |
1105 | mov esi, hex_buff |
1118 | mov ecx, -8 |
1106 | mov ecx, -8 |
1119 | @@: |
1107 | @@: |
1120 | rol eax, 4 |
1108 | rol eax, 4 |
1121 | mov ebx, eax |
1109 | mov ebx, eax |
1122 | and ebx, 0x0F |
1110 | and ebx, 0x0F |
1123 | mov bl, [ebx+hexletters] |
1111 | mov bl, [ebx+hexletters] |
1124 | mov [8+esi+ecx], bl |
1112 | mov [8+esi+ecx], bl |
1125 | inc ecx |
1113 | inc ecx |
1126 | jnz @B |
1114 | jnz @B |
1127 | ret |
1115 | ret |
1128 | 1116 | ||
1129 | hexletters db '0123456789ABCDEF' |
1117 | hexletters db '0123456789ABCDEF' |
1130 | hex_buff db 8 dup(0),13,10,0 |
1118 | hex_buff db 8 dup(0),13,10,0 |
1131 | 1119 | ||
1132 | 1120 | ||
1133 | include "codec.inc" |
1121 | include "codec.inc" |
1134 | 1122 | ||
1135 | align 4 |
1123 | align 4 |
1136 | devices dd (0x5000 shl 16)+0x1274,msgEnsoniq,set_ICH |
1124 | devices dd (0x5000 shl 16)+0x1274,msgEnsoniq,set_ICH |
1137 | dd (0x5880 shl 16)+0x1274,msgVibra128,set_ICH |
1125 | dd (0x5880 shl 16)+0x1274,msgVibra128,set_ICH |
1138 | dd 0 ;terminator |
1126 | dd 0 ;terminator |
1139 | 1127 | ||
1140 | version dd 0x00040000 |
1128 | version dd 0x00040004 |
1141 | 1129 | ||
1142 | msgEnsoniq db 'Ensonic 1371',0 |
1130 | msgEnsoniq db 'Ensonic 1371',13,10,0 |
1143 | msgVibra128 db 'Sound Blaster AudioPCI Vibra 128',0 |
1131 | msgVibra128 db 'Sound Blaster AudioPCI Vibra 128',13,10,0 |
1144 | 1132 | ||
1145 | sz_sound_srv db 'SOUND',0 |
1133 | sz_sound_srv db 'SOUND',0 |
1146 | 1134 | ||
1147 | msgDetect db 'detect hardware...',13,10,0 |
1135 | msgDetect db 'detect hardware...',13,10,0 |
1148 | msgFail db 'device not found',13,10,0 |
1136 | msgFail db 'device not found',13,10,0 |
1149 | msgAttchIRQ db 'IRQ line not supported', 13,10, 0 |
1137 | msgAttchIRQ db 'IRQ line not supported', 13,10, 0 |
1150 | msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 |
1138 | msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 |
1151 | msgPlay db 'start play', 13,10,0 |
1139 | msgPlay db 'start play', 13,10,0 |
1152 | msgStop db 'stop play', 13,10,0 |
1140 | msgStop db 'stop play', 13,10,0 |
1153 | msgNotify db 'call notify',13,10,0 |
1141 | msgNotify db 'call notify',13,10,0 |
1154 | msgIRQ db 'AC97 IRQ', 13,10,0 |
1142 | msgIRQ db 'AC97 IRQ', 13,10,0 |
1155 | msgInitCtrl db 'init controller',13,10,0 |
1143 | msgInitCtrl db 'init controller',13,10,0 |
1156 | msgInitCodec db 'init codec',13,10,0 |
1144 | msgInitCodec db 'init codec',13,10,0 |
1157 | msgPrimBuff db 'create primary buffer',13,10,0 |
1145 | msgPrimBuff db 'create primary buffer',13,10,0 |
1158 | msgReg db 'set service handler',13,10,0 |
1146 | msgReg db 'set service handler',13,10,0 |
1159 | msgOk db 'service installed',13,10,0 |
1147 | msgOk db 'service installed',13,10,0 |
1160 | msgCold db 'cold reset',13,10,0 |
1148 | msgCold db 'cold reset',13,10,0 |
1161 | msgWarm db 'warm reset',13,10,0 |
1149 | msgWarm db 'warm reset',13,10,0 |
1162 | msgWRFail db 'warm reset failed',13,10,0 |
1150 | msgWRFail db 'warm reset failed',13,10,0 |
1163 | msgCRFail db 'cold reset failed',13,10,0 |
1151 | msgCRFail db 'cold reset failed',13,10,0 |
1164 | msgCFail db 'codec not ready',13,10,0 |
1152 | msgCFail db 'codec not ready',13,10,0 |
1165 | msgResetOk db 'reset complete',13,10,0 |
1153 | msgResetOk db 'reset complete',13,10,0 |
1166 | msgStatus db 'global status ',0 |
1154 | msgStatus db 'global status ',0 |
1167 | msgControl db 'global control ',0 |
1155 | msgControl db 'global control ',0 |
1168 | msgPCIcmd db 'PCI command ',0 |
1156 | msgPCIcmd db 'PCI command ',0 |
1169 | msgIObase db 'IO base ',0 |
1157 | msgIObase db 'IO base ',0 |
1170 | msgIntline db 'Interrupt line ',0 |
1158 | msgIRQline db 'IRQ line ',0 |
1171 | 1159 | ||
1172 | section '.data' data readable writable align 16 |
1160 | section '.data' data readable writable align 16 |
1173 | 1161 | ||
1174 | pcmout_bdl rq 32 |
1162 | pcmout_bdl rq 32 |
1175 | buff_list rd 32 |
1163 | buff_list rd 32 |
1176 | 1164 | ||
1177 | codec CODEC |
1165 | codec CODEC |
1178 | ctrl AC_CNTRL |
1166 | ctrl AC_CNTRL |
1179 | 1167 | ||
1180 | lpc_bus rd 1 |
1168 | lpc_bus rd 1 |
1181 | civ_val rd 1 |
1169 | civ_val rd 1 |