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