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