Rev 5077 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1546 | Asper | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
1546 | Asper | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
5077 | clevermous | 8 | format PE DLL native 0.05 |
9 | entry START |
||
1546 | Asper | 10 | |
2288 | clevermous | 11 | DEBUG equ 1 |
1546 | Asper | 12 | |
2288 | clevermous | 13 | API_VERSION equ 0x01000100 |
1546 | Asper | 14 | |
2288 | clevermous | 15 | USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices |
16 | IRQ_REMAP equ 0 |
||
17 | IRQ_LINE equ 0 |
||
1546 | Asper | 18 | |
19 | |||
3539 | clevermous | 20 | ;irq 0,1,2,8,12,13 недоступны |
1546 | Asper | 21 | ; FEDCBA9876543210 |
2288 | clevermous | 22 | VALID_IRQ equ 1100111011111000b |
23 | ATTCH_IRQ equ 0000111010100000b |
||
1546 | Asper | 24 | |
25 | if USE_COM_IRQ |
||
2288 | clevermous | 26 | ATTCH_IRQ equ 0000111010111000b |
1546 | Asper | 27 | end if |
28 | |||
2288 | clevermous | 29 | CPU_FREQ equ 2600d |
1546 | Asper | 30 | |
31 | BIT0 EQU 0x00000001 |
||
32 | BIT1 EQU 0x00000002 |
||
33 | BIT5 EQU 0x00000020 |
||
34 | BIT10 EQU 0x00000400 |
||
35 | |||
2288 | clevermous | 36 | VID_Creative equ 0x1102 |
1546 | Asper | 37 | |
2288 | clevermous | 38 | CTRL_CT0200 equ 0x0006 ; Dell OEM version (EMU10K1X) |
1546 | Asper | 39 | |
40 | |||
2288 | clevermous | 41 | CODEC_MASTER_VOL_REG equ 0x02 |
42 | CODEC_AUX_VOL equ 0x04 ; |
||
43 | CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume |
||
44 | CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio |
||
1546 | Asper | 45 | CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control |
46 | CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate |
||
47 | CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate |
||
48 | CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate |
||
49 | |||
50 | |||
51 | ;EMU10K1(X) host controller registers set |
||
52 | ;; common offsets |
||
53 | ;; some definitions were borrowed from emu10k1 driver as they seem to be the same |
||
54 | ;;**********************************************************************************************;; |
||
55 | ;; PCI function 0 registers, address = |
||
56 | ;;**********************************************************************************************;; |
||
57 | |||
2288 | clevermous | 58 | PTR equ 0x00 ;; Indexed register set pointer register ;; |
59 | ;; NOTE: The CHANNELNUM and ADDRESS words can ;; |
||
60 | ;; be modified independently of each other. ;; |
||
1546 | Asper | 61 | |
2288 | clevermous | 62 | DATA equ 0x04 ;; Indexed register set data register ;; |
1546 | Asper | 63 | |
2288 | clevermous | 64 | IPR equ 0x08 ;; Global interrupt pending register ;; |
65 | ;; Clear pending interrupts by writing a 1 to ;; |
||
66 | ;; the relevant bits and zero to the other bits ;; |
||
67 | IPR_MIDITRANSBUFEMPTY equ 0x00000001 ;; MIDI UART transmit buffer empty ;; |
||
68 | IPR_MIDIRECVBUFEMPTY equ 0x00000002 ;; MIDI UART receive buffer empty ;; |
||
69 | IPR_CH_0_LOOP equ 0x00000800 ;; Channel 0 loop ;; |
||
70 | IPR_CH_0_HALF_LOOP equ 0x00000100 ;; Channel 0 half loop ;; |
||
71 | IPR_CAP_0_LOOP equ 0x00080000 ;; Channel capture loop ;; |
||
72 | IPR_CAP_0_HALF_LOOP equ 0x00010000 ;; Channel capture half loop ;; |
||
1546 | Asper | 73 | |
2288 | clevermous | 74 | INTE equ 0x0c ;; Interrupt enable register ;; |
75 | INTE_MIDITXENABLE equ 0x00000001 ;; Enable MIDI transmit-buffer-empty interrupts ;; |
||
76 | INTE_MIDIRXENABLE equ 0x00000002 ;; Enable MIDI receive-buffer-empty interrupts ;; |
||
77 | INTE_CH_0_LOOP equ 0x00000800 ;; Channel 0 loop ;; |
||
78 | INTE_CH_0_HALF_LOOP equ 0x00000100 ;; Channel 0 half loop ;; |
||
79 | INTE_CAP_0_LOOP equ 0x00080000 ;; Channel capture loop ;; |
||
80 | INTE_CAP_0_HALF_LOOP equ 0x00010000 ;; Channel capture half loop ;; |
||
1546 | Asper | 81 | |
2288 | clevermous | 82 | HCFG equ 0x14 ;; Hardware config register ;; |
1546 | Asper | 83 | |
2288 | clevermous | 84 | HCFG_LOCKSOUNDCACHE equ 0x00000008 ;; 1 = Cancel bustmaster accesses to soundcache ;; |
85 | ;; NOTE: This should generally never be used. ;; |
||
86 | HCFG_AUDIOENABLE equ 0x00000001 ;; 0 = CODECs transmit zero-valued samples ;; |
||
87 | ;; Should be set to 1 when the EMU10K1 is ;; |
||
88 | ;; completely initialized. ;; |
||
89 | GPIO equ 0x18 ;; Defaults: 00001080-Analog, 00001000-SPDIF. ;; |
||
1546 | Asper | 90 | |
91 | |||
2288 | clevermous | 92 | AC97DATA equ 0x1c ;; AC97 register set data register (16 bit) ;; |
1546 | Asper | 93 | |
2288 | clevermous | 94 | AC97ADDRESS equ 0x1e ;; AC97 register set address register (8 bit) ;; |
1546 | Asper | 95 | |
96 | ;;******************************************************************************************************;; |
||
97 | ;; Emu10k1x pointer-offset register set, accessed through the PTR and DATA registers ;; |
||
98 | ;;******************************************************************************************************;; |
||
2288 | clevermous | 99 | PLAYBACK_LIST_ADDR equ 0x00 ;; Base DMA address of a list of pointers to each period/size ;; |
100 | ;; One list entry: 4 bytes for DMA address, |
||
101 | ;; 4 bytes for period_size << 16. |
||
102 | ;; One list entry is 8 bytes long. |
||
103 | ;; One list entry for each period in the buffer. |
||
104 | ;; |
||
105 | PLAYBACK_LIST_SIZE equ 0x01 ;; Size of list in bytes << 19. E.g. 8 periods -> 0x00380000 ;; |
||
106 | PLAYBACK_LIST_PTR equ 0x02 ;; Pointer to the current period being played ;; |
||
107 | PLAYBACK_DMA_ADDR equ 0x04 ;; Playback DMA addresss ;; |
||
108 | PLAYBACK_PERIOD_SIZE equ 0x05 ;; Playback period size ;; |
||
109 | PLAYBACK_POINTER equ 0x06 ;; Playback period pointer. Sample currently in DAC ;; |
||
110 | PLAYBACK_UNKNOWN1 equ 0x07 |
||
111 | PLAYBACK_UNKNOWN2 equ 0x08 |
||
1546 | Asper | 112 | |
113 | ;; Only one capture channel supported ;; |
||
2288 | clevermous | 114 | CAPTURE_DMA_ADDR equ 0x10 ;; Capture DMA address ;; |
115 | CAPTURE_BUFFER_SIZE equ 0x11 ;; Capture buffer size ;; |
||
116 | CAPTURE_POINTER equ 0x12 ;; Capture buffer pointer. Sample currently in ADC ;; |
||
117 | CAPTURE_UNKNOWN equ 0x13 |
||
1546 | Asper | 118 | |
119 | ;; From 0x20 - 0x3f, last samples played on each channel ;; |
||
120 | |||
2288 | clevermous | 121 | TRIGGER_CHANNEL equ 0x40 ;; Trigger channel playback ;; |
122 | TRIGGER_CHANNEL_0 equ 0x00000001 ;; Trigger channel 0 ;; |
||
123 | TRIGGER_CHANNEL_1 equ 0x00000002 ;; Trigger channel 1 ;; |
||
124 | TRIGGER_CHANNEL_2 equ 0x00000004 ;; Trigger channel 2 ;; |
||
125 | TRIGGER_CAPTURE equ 0x00000100 ;; Trigger capture channel ;; |
||
1546 | Asper | 126 | |
2288 | clevermous | 127 | ROUTING equ 0x41 ;; Setup sound routing ? ;; |
128 | ROUTING_FRONT_LEFT equ 0x00000001 |
||
129 | ROUTING_FRONT_RIGHT equ 0x00000002 |
||
130 | ROUTING_REAR_LEFT equ 0x00000004 |
||
131 | ROUTING_REAR_RIGHT equ 0x00000008 |
||
132 | ROUTING_CENTER_LFE equ 0x00010000 |
||
1546 | Asper | 133 | |
2288 | clevermous | 134 | SPCS0 equ 0x42 ;; SPDIF output Channel Status 0 register ;; |
135 | SPCS1 equ 0x43 ;; SPDIF output Channel Status 1 register ;; |
||
136 | SPCS2 equ 0x44 ;; SPDIF output Channel Status 2 register ;; |
||
1546 | Asper | 137 | |
2288 | clevermous | 138 | SPCS_CLKACCYMASK equ 0x30000000 ;; Clock accuracy ;; |
139 | SPCS_CLKACCY_1000PPM equ 0x00000000 ;; 1000 parts per million ;; |
||
140 | SPCS_CLKACCY_50PPM equ 0x10000000 ;; 50 parts per million ;; |
||
141 | SPCS_CLKACCY_VARIABLE equ 0x20000000 ;; Variable accuracy ;; |
||
142 | SPCS_SAMPLERATEMASK equ 0x0f000000 ;; Sample rate ;; |
||
143 | SPCS_SAMPLERATE_44 equ 0x00000000 ;; 44.1kHz sample rate ;; |
||
144 | SPCS_SAMPLERATE_48 equ 0x02000000 ;; 48kHz sample rate ;; |
||
145 | SPCS_SAMPLERATE_32 equ 0x03000000 ;; 32kHz sample rate ;; |
||
146 | SPCS_CHANNELNUMMASK equ 0x00f00000 ;; Channel number ;; |
||
147 | SPCS_CHANNELNUM_UNSPEC equ 0x00000000 ;; Unspecified channel number ;; |
||
148 | SPCS_CHANNELNUM_LEFT equ 0x00100000 ;; Left channel ;; |
||
149 | SPCS_CHANNELNUM_RIGHT equ 0x00200000 ;; Right channel ;; |
||
150 | SPCS_SOURCENUMMASK equ 0x000f0000 ;; Source number ;; |
||
151 | SPCS_SOURCENUM_UNSPEC equ 0x00000000 ;; Unspecified source number ;; |
||
152 | SPCS_GENERATIONSTATUS equ 0x00008000 ;; Originality flag (see IEC-958 spec) ;; |
||
153 | SPCS_CATEGORYCODEMASK equ 0x00007f00 ;; Category code (see IEC-958 spec) ;; |
||
154 | SPCS_MODEMASK equ 0x000000c0 ;; Mode (see IEC-958 spec) ;; |
||
155 | SPCS_EMPHASISMASK equ 0x00000038 ;; Emphasis ;; |
||
156 | SPCS_EMPHASIS_NONE equ 0x00000000 ;; No emphasis ;; |
||
157 | SPCS_EMPHASIS_50_15 equ 0x00000008 ;; 50/15 usec 2 channel ;; |
||
158 | SPCS_COPYRIGHT equ 0x00000004 ;; Copyright asserted flag -- do not modify ;; |
||
159 | SPCS_NOTAUDIODATA equ 0x00000002 ;; 0 = Digital audio, 1 = not audio ;; |
||
160 | SPCS_PROFESSIONAL equ 0x00000001 ;; 0 = Consumer (IEC-958), 1 = pro (AES3-1992) ;; |
||
1546 | Asper | 161 | |
2288 | clevermous | 162 | SPDIF_SELECT equ 0x45 ;; Enables SPDIF or Analogue outputs 0-Analogue, 0x700-SPDIF ;; |
1546 | Asper | 163 | |
164 | ;; This is the MPU port on the card ;; |
||
2288 | clevermous | 165 | MUDATA equ 0x47 |
166 | MUCMD equ 0x48 |
||
167 | MUSTAT equ MUCMD |
||
1546 | Asper | 168 | |
169 | ;; From 0x50 - 0x5f, last samples captured ;; |
||
170 | |||
171 | |||
2288 | clevermous | 172 | SRV_GETVERSION equ 0 |
173 | DEV_PLAY equ 1 |
||
174 | DEV_STOP equ 2 |
||
175 | DEV_CALLBACK equ 3 |
||
176 | DEV_SET_BUFF equ 4 |
||
177 | DEV_NOTIFY equ 5 |
||
1546 | Asper | 178 | DEV_SET_MASTERVOL equ 6 |
179 | DEV_GET_MASTERVOL equ 7 |
||
2288 | clevermous | 180 | DEV_GET_INFO equ 8 |
1546 | Asper | 181 | |
2288 | clevermous | 182 | struc AC_CNTRL ;AC controller base class |
183 | { .bus dd ? |
||
184 | .devfn dd ? |
||
1546 | Asper | 185 | |
2288 | clevermous | 186 | .vendor dd ? |
187 | .dev_id dd ? |
||
188 | .pci_cmd dd ? |
||
189 | .pci_stat dd ? |
||
1546 | Asper | 190 | |
191 | .codec_io_base dd ? |
||
192 | .codec_mem_base dd ? |
||
193 | |||
194 | .ctrl_io_base dd ? |
||
195 | .ctrl_mem_base dd ? |
||
2288 | clevermous | 196 | .cfg_reg dd ? |
197 | .int_line dd ? |
||
1546 | Asper | 198 | |
2288 | clevermous | 199 | .vendor_ids dd ? ;vendor id string |
200 | .ctrl_ids dd ? ;hub id string |
||
1546 | Asper | 201 | |
2288 | clevermous | 202 | .buffer dd ? |
1546 | Asper | 203 | |
2288 | clevermous | 204 | .notify_pos dd ? |
205 | .notify_task dd ? |
||
1546 | Asper | 206 | |
2288 | clevermous | 207 | .lvi_reg dd ? |
208 | .ctrl_setup dd ? |
||
1546 | Asper | 209 | .user_callback dd ? |
210 | .codec_read16 dd ? |
||
211 | .codec_write16 dd ? |
||
212 | |||
2288 | clevermous | 213 | .ctrl_read8 dd ? |
214 | .ctrl_read16 dd ? |
||
215 | .ctrl_read32 dd ? |
||
1546 | Asper | 216 | |
2288 | clevermous | 217 | .ctrl_write8 dd ? |
1546 | Asper | 218 | .ctrl_write16 dd ? |
219 | .ctrl_write32 dd ? |
||
220 | } |
||
221 | |||
2288 | clevermous | 222 | struc CODEC ;Audio Chip base class |
1546 | Asper | 223 | { |
2288 | clevermous | 224 | .chip_id dd ? |
225 | .flags dd ? |
||
226 | .status dd ? |
||
1546 | Asper | 227 | |
228 | .ac_vendor_ids dd ? ;ac vendor id string |
||
2288 | clevermous | 229 | .chip_ids dd ? ;chip model string |
1546 | Asper | 230 | |
2288 | clevermous | 231 | .shadow_flag dd ? |
232 | dd ? |
||
1546 | Asper | 233 | |
2288 | clevermous | 234 | .regs dw ? ; codec registers |
1546 | Asper | 235 | .reg_master_vol dw ? ;0x02 |
236 | .reg_aux_out_vol dw ? ;0x04 |
||
237 | .reg_mone_vol dw ? ;0x06 |
||
238 | .reg_master_tone dw ? ;0x08 |
||
239 | .reg_beep_vol dw ? ;0x0A |
||
240 | .reg_phone_vol dw ? ;0x0C |
||
2288 | clevermous | 241 | .reg_mic_vol dw ? ;0x0E |
1546 | Asper | 242 | .reg_line_in_vol dw ? ;0x10 |
2288 | clevermous | 243 | .reg_cd_vol dw ? ;0x12 |
1546 | Asper | 244 | .reg_video_vol dw ? ;0x14 |
245 | .reg_aux_in_vol dw ? ;0x16 |
||
246 | .reg_pcm_out_vol dw ? ;0x18 |
||
247 | .reg_rec_select dw ? ;0x1A |
||
248 | .reg_rec_gain dw ? ;0x1C |
||
249 | .reg_rec_gain_mic dw ? ;0x1E |
||
2288 | clevermous | 250 | .reg_gen dw ? ;0x20 |
251 | .reg_3d_ctrl dw ? ;0X22 |
||
252 | .reg_page dw ? ;0X24 |
||
1546 | Asper | 253 | .reg_powerdown dw ? ;0x26 |
254 | .reg_ext_audio dw ? ;0x28 |
||
2288 | clevermous | 255 | .reg_ext_st dw ? ;0x2a |
1546 | Asper | 256 | .reg_pcm_front_rate dw ? ;0x2c |
257 | .reg_pcm_surr_rate dw ? ;0x2e |
||
258 | .reg_lfe_rate dw ? ;0x30 |
||
259 | .reg_pcm_in_rate dw ? ;0x32 |
||
2288 | clevermous | 260 | dw ? ;0x34 |
1546 | Asper | 261 | .reg_cent_lfe_vol dw ? ;0x36 |
262 | .reg_surr_vol dw ? ;0x38 |
||
263 | .reg_spdif_ctrl dw ? ;0x3A |
||
2288 | clevermous | 264 | dw ? ;0x3C |
265 | dw ? ;0x3E |
||
266 | dw ? ;0x40 |
||
267 | dw ? ;0x42 |
||
268 | dw ? ;0x44 |
||
269 | dw ? ;0x46 |
||
270 | dw ? ;0x48 |
||
271 | dw ? ;0x4A |
||
272 | dw ? ;0x4C |
||
273 | dw ? ;0x4E |
||
274 | dw ? ;0x50 |
||
275 | dw ? ;0x52 |
||
276 | dw ? ;0x54 |
||
277 | dw ? ;0x56 |
||
278 | dw ? ;0x58 |
||
279 | dw ? ;0x5A |
||
280 | dw ? ;0x5C |
||
281 | dw ? ;0x5E |
||
282 | .reg_page_0 dw ? ;0x60 |
||
283 | .reg_page_1 dw ? ;0x62 |
||
284 | .reg_page_2 dw ? ;0x64 |
||
285 | .reg_page_3 dw ? ;0x66 |
||
286 | .reg_page_4 dw ? ;0x68 |
||
287 | .reg_page_5 dw ? ;0x6A |
||
288 | .reg_page_6 dw ? ;0x6C |
||
289 | .reg_page_7 dw ? ;0x6E |
||
290 | dw ? ;0x70 |
||
291 | dw ? ;0x72 |
||
292 | dw ? ;0x74 |
||
293 | dw ? ;0x76 |
||
294 | dw ? ;0x78 |
||
295 | dw ? ;0x7A |
||
1546 | Asper | 296 | .reg_vendor_id_1 dw ? ;0x7C |
297 | .reg_vendor_id_2 dw ? ;0x7E |
||
298 | |||
299 | |||
2288 | clevermous | 300 | .reset dd ? ;virual |
1546 | Asper | 301 | .set_master_vol dd ? |
302 | } |
||
303 | |||
304 | struc CTRL_INFO |
||
2288 | clevermous | 305 | { .pci_cmd dd ? |
306 | .irq dd ? |
||
1546 | Asper | 307 | .glob_cntrl dd ? |
2288 | clevermous | 308 | .glob_sta dd ? |
1546 | Asper | 309 | .codec_io_base dd ? |
310 | .ctrl_io_base dd ? |
||
311 | .codec_mem_base dd ? |
||
312 | .ctrl_mem_base dd ? |
||
2288 | clevermous | 313 | .codec_id dd ? |
1546 | Asper | 314 | } |
315 | |||
2288 | clevermous | 316 | EVENT_NOTIFY equ 0x00000200 |
1546 | Asper | 317 | |
5077 | clevermous | 318 | section '.flat' code readable writable executable |
319 | include '../struct.inc' |
||
320 | include '../macros.inc' |
||
321 | include '../proc32.inc' |
||
322 | include '../peimport.inc' |
||
1546 | Asper | 323 | |
324 | |||
5077 | clevermous | 325 | proc START c uses ebx esi edi, state:dword, cmdline:dword |
1546 | Asper | 326 | |
2288 | clevermous | 327 | cmp [state], 1 |
328 | jne .stop |
||
1546 | Asper | 329 | |
330 | if DEBUG |
||
2288 | clevermous | 331 | mov esi, msgInit |
5077 | clevermous | 332 | invoke SysMsgBoardStr |
1546 | Asper | 333 | end if |
334 | |||
2288 | clevermous | 335 | call detect_controller |
336 | test eax, eax |
||
337 | jz .fail |
||
1546 | Asper | 338 | |
339 | if DEBUG |
||
2288 | clevermous | 340 | mov esi, [ctrl.vendor_ids] |
5077 | clevermous | 341 | invoke SysMsgBoardStr |
2288 | clevermous | 342 | mov esi, [ctrl.ctrl_ids] |
5077 | clevermous | 343 | invoke SysMsgBoardStr |
1546 | Asper | 344 | end if |
345 | |||
2288 | clevermous | 346 | call init_controller |
347 | test eax, eax |
||
348 | jz .fail |
||
1546 | Asper | 349 | |
2288 | clevermous | 350 | call init_codec |
351 | test eax, eax |
||
352 | jz .fail |
||
1546 | Asper | 353 | |
2288 | clevermous | 354 | call setup_codec |
1546 | Asper | 355 | |
2288 | clevermous | 356 | mov esi, msgPrimBuff |
5077 | clevermous | 357 | invoke SysMsgBoardStr |
2288 | clevermous | 358 | call create_primary_buff |
359 | mov esi, msgDone |
||
5077 | clevermous | 360 | invoke SysMsgBoardStr |
1546 | Asper | 361 | |
362 | if IRQ_REMAP |
||
2288 | clevermous | 363 | pushf |
364 | cli |
||
1546 | Asper | 365 | |
2288 | clevermous | 366 | mov ebx, [ctrl.int_line] |
367 | in al, 0xA1 |
||
368 | mov ah, al |
||
369 | in al, 0x21 |
||
370 | test ebx, ebx |
||
371 | jz .skip |
||
372 | bts ax, bx ;mask old line |
||
1546 | Asper | 373 | .skip: |
2288 | clevermous | 374 | bts ax, IRQ_LINE ;mask new ine |
375 | out 0x21, al |
||
376 | mov al, ah |
||
377 | out 0xA1, al |
||
1546 | Asper | 378 | |
2288 | clevermous | 379 | stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE ;remap IRQ |
1546 | Asper | 380 | |
2288 | clevermous | 381 | mov dx, 0x4d0 ;8259 ELCR1 |
382 | in al, dx |
||
383 | bts ax, IRQ_LINE |
||
384 | out dx, al ;set level-triggered mode |
||
385 | mov [ctrl.int_line], IRQ_LINE |
||
386 | popf |
||
387 | mov esi, msgRemap |
||
5077 | clevermous | 388 | invoke SysMsgBoardStr |
1546 | Asper | 389 | end if |
390 | |||
2288 | clevermous | 391 | mov eax, VALID_IRQ |
392 | mov ebx, [ctrl.int_line] |
||
393 | mov esi, msgInvIRQ |
||
394 | bt eax, ebx |
||
395 | jnc .fail_msg |
||
396 | mov eax, ATTCH_IRQ |
||
397 | mov esi, msgAttchIRQ |
||
398 | bt eax, ebx |
||
399 | jnc .fail_msg |
||
1546 | Asper | 400 | |
5077 | clevermous | 401 | invoke AttachIntHandler, ebx, ac97_irq, dword 0 |
2288 | clevermous | 402 | stdcall create |
1546 | Asper | 403 | |
404 | .reg: |
||
5077 | clevermous | 405 | invoke RegService, sz_sound_srv, service_proc |
2288 | clevermous | 406 | ret |
1546 | Asper | 407 | .fail: |
408 | if DEBUG |
||
2288 | clevermous | 409 | mov esi, msgFail |
5077 | clevermous | 410 | invoke SysMsgBoardStr |
1546 | Asper | 411 | end if |
2288 | clevermous | 412 | xor eax, eax |
413 | ret |
||
1546 | Asper | 414 | .fail_msg: |
5077 | clevermous | 415 | invoke SysMsgBoardStr |
2288 | clevermous | 416 | xor eax, eax |
417 | ret |
||
1546 | Asper | 418 | .stop: |
2288 | clevermous | 419 | call stop |
420 | xor eax, eax |
||
421 | ret |
||
1546 | Asper | 422 | endp |
423 | |||
2288 | clevermous | 424 | handle equ IOCTL.handle |
425 | io_code equ IOCTL.io_code |
||
426 | input equ IOCTL.input |
||
427 | inp_size equ IOCTL.inp_size |
||
428 | output equ IOCTL.output |
||
429 | out_size equ IOCTL.out_size |
||
1546 | Asper | 430 | |
431 | align 4 |
||
432 | proc service_proc stdcall, ioctl:dword |
||
433 | |||
2288 | clevermous | 434 | mov edi, [ioctl] |
435 | mov eax, [edi+io_code] |
||
1546 | Asper | 436 | |
2288 | clevermous | 437 | cmp eax, SRV_GETVERSION |
438 | jne @F |
||
439 | mov eax, [edi+output] |
||
440 | cmp [edi+out_size], 4 |
||
441 | jne .fail |
||
1546 | Asper | 442 | |
2288 | clevermous | 443 | mov [eax], dword API_VERSION |
444 | xor eax, eax |
||
445 | ret |
||
1546 | Asper | 446 | @@: |
2288 | clevermous | 447 | cmp eax, DEV_PLAY |
448 | jne @F |
||
1546 | Asper | 449 | if DEBUG |
2288 | clevermous | 450 | mov esi, msgPlay |
5077 | clevermous | 451 | invoke SysMsgBoardStr |
1546 | Asper | 452 | end if |
2288 | clevermous | 453 | call play |
454 | ret |
||
1546 | Asper | 455 | @@: |
2288 | clevermous | 456 | cmp eax, DEV_STOP |
457 | jne @F |
||
1546 | Asper | 458 | if DEBUG |
2288 | clevermous | 459 | mov esi, msgStop |
5077 | clevermous | 460 | invoke SysMsgBoardStr |
1546 | Asper | 461 | end if |
2288 | clevermous | 462 | call stop |
463 | ret |
||
1546 | Asper | 464 | @@: |
2288 | clevermous | 465 | cmp eax, DEV_CALLBACK |
466 | jne @F |
||
467 | mov ebx, [edi+input] |
||
468 | stdcall set_callback, [ebx] |
||
469 | ret |
||
1546 | Asper | 470 | @@: |
2288 | clevermous | 471 | cmp eax, DEV_SET_MASTERVOL |
472 | jne @F |
||
473 | mov eax, [edi+input] |
||
474 | mov eax, [eax] |
||
475 | call set_master_vol ;eax= vol |
||
476 | ret |
||
1546 | Asper | 477 | @@: |
2288 | clevermous | 478 | cmp eax, DEV_GET_MASTERVOL |
479 | jne @F |
||
480 | mov ebx, [edi+output] |
||
481 | stdcall get_master_vol, ebx |
||
482 | ret |
||
1546 | Asper | 483 | @@: |
2288 | clevermous | 484 | cmp eax, DEV_GET_INFO |
485 | jne @F |
||
486 | mov ebx, [edi+output] |
||
487 | stdcall get_dev_info, ebx |
||
488 | ret |
||
1546 | Asper | 489 | @@: |
490 | .fail: |
||
2288 | clevermous | 491 | or eax, -1 |
492 | ret |
||
1546 | Asper | 493 | endp |
494 | |||
495 | restore handle |
||
496 | restore io_code |
||
497 | restore input |
||
498 | restore inp_size |
||
499 | restore output |
||
500 | restore out_size |
||
501 | |||
502 | |||
503 | align 4 |
||
504 | proc ac97_irq |
||
2288 | clevermous | 505 | locals |
506 | status dd 0 |
||
507 | endl |
||
1546 | Asper | 508 | |
509 | ; status = inl(chip->port + IPR); |
||
2288 | clevermous | 510 | mov edx, IPR |
511 | call [ctrl.ctrl_read32] |
||
512 | test eax, eax |
||
513 | jz @f |
||
1546 | Asper | 514 | |
2288 | clevermous | 515 | mov dword [status], eax |
1546 | Asper | 516 | |
2288 | clevermous | 517 | mov ebx, dword [buff_list] |
518 | cmp [ctrl.user_callback], 0 |
||
519 | je @f |
||
520 | stdcall [ctrl.user_callback], ebx |
||
1546 | Asper | 521 | @@: |
2288 | clevermous | 522 | mov eax, dword [status] ;; ack ;; |
523 | mov edx, IPR |
||
524 | call [ctrl.ctrl_write32] |
||
525 | ret |
||
1546 | Asper | 526 | endp |
527 | |||
528 | |||
529 | align 4 |
||
530 | proc create_primary_buff |
||
531 | |||
5077 | clevermous | 532 | invoke KernelAlloc, 0x10000 |
2288 | clevermous | 533 | mov [ctrl.buffer], eax |
1546 | Asper | 534 | |
2288 | clevermous | 535 | mov edi, eax |
536 | mov ecx, 0x10000/4 |
||
537 | xor eax, eax |
||
538 | cld |
||
539 | rep stosd |
||
1546 | Asper | 540 | |
2288 | clevermous | 541 | mov eax, [ctrl.buffer] |
5077 | clevermous | 542 | invoke GetPgAddr |
1546 | Asper | 543 | |
2288 | clevermous | 544 | mov edi, pcmout_bdl |
545 | stosd |
||
546 | mov eax, 0x4000000 |
||
547 | stosd |
||
1546 | Asper | 548 | |
2288 | clevermous | 549 | mov edi, buff_list |
550 | mov eax, [ctrl.buffer] |
||
551 | stosd ;1.] |
||
1546 | Asper | 552 | |
2288 | clevermous | 553 | mov eax, [ctrl.buffer] |
5077 | clevermous | 554 | invoke GetPgAddr |
1546 | Asper | 555 | |
2288 | clevermous | 556 | stdcall ptr_write, PLAYBACK_POINTER, 0, 0 |
557 | stdcall ptr_write, PLAYBACK_UNKNOWN1, 0, 0 |
||
558 | stdcall ptr_write, PLAYBACK_UNKNOWN2, 0, 0 |
||
559 | stdcall ptr_write, PLAYBACK_DMA_ADDR, 0, eax |
||
1546 | Asper | 560 | |
2288 | clevermous | 561 | mov eax, pcmout_bdl |
562 | mov ebx, eax |
||
5077 | clevermous | 563 | invoke GetPgAddr |
2288 | clevermous | 564 | and ebx, 0xFFF |
565 | add eax, ebx |
||
1546 | Asper | 566 | |
2288 | clevermous | 567 | stdcall ptr_write, PLAYBACK_LIST_ADDR, 0, eax |
568 | stdcall ptr_write, PLAYBACK_LIST_SIZE, 0, 0 |
||
569 | stdcall ptr_write, PLAYBACK_LIST_PTR, 0, 0 |
||
1546 | Asper | 570 | |
2288 | clevermous | 571 | ;mov eax, 0x00004000 |
572 | ;shl eax, 16 |
||
573 | stdcall ptr_write, PLAYBACK_PERIOD_SIZE, 0, 0x40000000 ;eax |
||
1546 | Asper | 574 | |
2288 | clevermous | 575 | ret |
1546 | Asper | 576 | endp |
577 | |||
578 | |||
579 | align 4 |
||
580 | proc detect_controller |
||
2288 | clevermous | 581 | locals |
582 | last_bus dd ? |
||
583 | bus dd ? |
||
584 | devfn dd ? |
||
585 | endl |
||
1546 | Asper | 586 | |
2288 | clevermous | 587 | xor eax, eax |
588 | mov [bus], eax |
||
589 | inc eax |
||
5077 | clevermous | 590 | invoke PciApi |
2288 | clevermous | 591 | cmp eax, -1 |
592 | je .err |
||
1546 | Asper | 593 | |
2288 | clevermous | 594 | mov [last_bus], eax |
1546 | Asper | 595 | |
596 | .next_bus: |
||
2288 | clevermous | 597 | and [devfn], 0 |
1546 | Asper | 598 | .next_dev: |
5077 | clevermous | 599 | invoke PciRead32, [bus], [devfn], dword 0 |
2288 | clevermous | 600 | test eax, eax |
601 | jz .next |
||
602 | cmp eax, -1 |
||
603 | je .next |
||
1546 | Asper | 604 | |
2288 | clevermous | 605 | mov edi, devices |
1546 | Asper | 606 | @@: |
2288 | clevermous | 607 | mov ebx, [edi] |
608 | test ebx, ebx |
||
609 | jz .next |
||
1546 | Asper | 610 | |
2288 | clevermous | 611 | cmp eax, ebx |
612 | je .found |
||
613 | add edi, 12 |
||
614 | jmp @B |
||
1546 | Asper | 615 | .next: |
2288 | clevermous | 616 | inc [devfn] |
617 | cmp [devfn], 256 |
||
618 | jb .next_dev |
||
619 | mov eax, [bus] |
||
620 | inc eax |
||
621 | mov [bus], eax |
||
622 | cmp eax, [last_bus] |
||
623 | jna .next_bus |
||
624 | xor eax, eax |
||
625 | ret |
||
1546 | Asper | 626 | .found: |
2288 | clevermous | 627 | mov ebx, [bus] |
628 | mov [ctrl.bus], ebx |
||
1546 | Asper | 629 | |
2288 | clevermous | 630 | mov ecx, [devfn] |
631 | mov [ctrl.devfn], ecx |
||
1546 | Asper | 632 | |
2288 | clevermous | 633 | mov edx, eax |
634 | and edx, 0xFFFF |
||
635 | mov [ctrl.vendor], edx |
||
636 | shr eax, 16 |
||
637 | mov [ctrl.dev_id], eax |
||
1546 | Asper | 638 | |
2288 | clevermous | 639 | mov ebx, [edi+4] |
640 | mov [ctrl.ctrl_ids], ebx |
||
641 | mov esi, [edi+8] |
||
642 | mov [ctrl.ctrl_setup], esi |
||
1546 | Asper | 643 | |
2288 | clevermous | 644 | cmp edx, VID_Creative |
645 | jne @F |
||
646 | mov [ctrl.vendor_ids], msg_Creative |
||
647 | ret |
||
1546 | Asper | 648 | @@: |
649 | |||
650 | .err: |
||
2288 | clevermous | 651 | xor eax, eax |
652 | mov [ctrl.vendor_ids], eax ;something wrong ? |
||
653 | ret |
||
1546 | Asper | 654 | endp |
655 | |||
656 | align 4 |
||
657 | proc init_controller |
||
658 | |||
5077 | clevermous | 659 | invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x2C |
2288 | clevermous | 660 | mov esi, msgPciSubsys |
5077 | clevermous | 661 | invoke SysMsgBoardStr |
2288 | clevermous | 662 | call dword2str |
5077 | clevermous | 663 | invoke SysMsgBoardStr |
1546 | Asper | 664 | |
5077 | clevermous | 665 | invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 |
2288 | clevermous | 666 | mov ebx, eax |
667 | and eax, 0xFFFF |
||
668 | mov [ctrl.pci_cmd], eax |
||
669 | shr ebx, 16 |
||
670 | mov [ctrl.pci_stat], ebx |
||
1546 | Asper | 671 | |
2288 | clevermous | 672 | mov esi, msgPciCmd |
5077 | clevermous | 673 | invoke SysMsgBoardStr |
2288 | clevermous | 674 | call dword2str |
5077 | clevermous | 675 | invoke SysMsgBoardStr |
1546 | Asper | 676 | |
2288 | clevermous | 677 | mov esi, msgPciStat |
5077 | clevermous | 678 | invoke SysMsgBoardStr |
2288 | clevermous | 679 | mov eax, [ctrl.pci_stat] |
680 | call dword2str |
||
5077 | clevermous | 681 | invoke SysMsgBoardStr |
1546 | Asper | 682 | |
2288 | clevermous | 683 | mov esi, msgCtrlIsaIo |
5077 | clevermous | 684 | invoke SysMsgBoardStr |
685 | invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 |
||
2288 | clevermous | 686 | call dword2str |
5077 | clevermous | 687 | invoke SysMsgBoardStr |
1546 | Asper | 688 | |
2288 | clevermous | 689 | and eax, 0xFFC0 |
690 | mov [ctrl.ctrl_io_base], eax |
||
1546 | Asper | 691 | |
692 | .default: |
||
5077 | clevermous | 693 | invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C |
2288 | clevermous | 694 | and eax, 0xFF |
1546 | Asper | 695 | @@: |
2288 | clevermous | 696 | mov [ctrl.int_line], eax |
1546 | Asper | 697 | |
2288 | clevermous | 698 | call [ctrl.ctrl_setup] |
699 | xor eax, eax |
||
700 | inc eax |
||
701 | ret |
||
1546 | Asper | 702 | endp |
703 | |||
704 | align 4 |
||
705 | proc set_Creative |
||
2288 | clevermous | 706 | mov [ctrl.codec_read16], codec_io_r16 ;virtual |
707 | mov [ctrl.codec_write16], codec_io_w16 ;virtual |
||
1546 | Asper | 708 | |
2288 | clevermous | 709 | mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual |
710 | mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual |
||
711 | mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual |
||
1546 | Asper | 712 | |
2288 | clevermous | 713 | mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual |
714 | mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual |
||
715 | mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual |
||
716 | ret |
||
1546 | Asper | 717 | endp |
718 | |||
719 | |||
720 | align 4 |
||
721 | proc init_codec |
||
2288 | clevermous | 722 | call reset_codec |
723 | test eax, eax |
||
724 | jz .err |
||
725 | call detect_codec |
||
726 | xor eax, eax |
||
727 | inc eax |
||
728 | ret |
||
1546 | Asper | 729 | .err: |
2288 | clevermous | 730 | xor eax, eax |
731 | ret |
||
1546 | Asper | 732 | endp |
733 | |||
734 | align 4 |
||
735 | proc reset_codec |
||
2288 | clevermous | 736 | locals |
737 | counter dd ? |
||
738 | endl |
||
1546 | Asper | 739 | |
740 | if DEBUG |
||
2288 | clevermous | 741 | mov esi, msgCold |
5077 | clevermous | 742 | invoke SysMsgBoardStr |
1546 | Asper | 743 | end if |
744 | |||
2288 | clevermous | 745 | mov eax, 100000 ; wait 100 ms ;400000 ; wait 400 ms |
746 | call StallExec |
||
1546 | Asper | 747 | |
2288 | clevermous | 748 | stdcall ptr_read, TRIGGER_CHANNEL, 0 |
1546 | Asper | 749 | |
2288 | clevermous | 750 | mov [counter], 16 ; total 20*100 ms = 2s |
1546 | Asper | 751 | .wait: |
2288 | clevermous | 752 | stdcall codec_read, dword 0x26 |
753 | test eax, 1 |
||
754 | jnz .ok |
||
1546 | Asper | 755 | |
2288 | clevermous | 756 | mov eax, 100000 ; wait 100 ms |
757 | call StallExec |
||
1546 | Asper | 758 | |
2288 | clevermous | 759 | dec [counter] |
760 | jnz .wait |
||
1546 | Asper | 761 | |
762 | if DEBUG |
||
2288 | clevermous | 763 | mov esi, msgCRFail |
5077 | clevermous | 764 | invoke SysMsgBoardStr |
1546 | Asper | 765 | end if |
766 | |||
767 | .fail: |
||
2288 | clevermous | 768 | stc |
769 | ret |
||
1546 | Asper | 770 | .ok: |
771 | |||
772 | |||
2288 | clevermous | 773 | xor eax, eax |
774 | inc eax |
||
775 | ret |
||
1546 | Asper | 776 | endp |
777 | |||
778 | |||
779 | align 4 |
||
780 | play: |
||
2288 | clevermous | 781 | mov eax, INTE_CH_0_LOOP |
782 | stdcall intr_enable, eax |
||
1546 | Asper | 783 | |
2288 | clevermous | 784 | stdcall ptr_read, TRIGGER_CHANNEL, 0 |
785 | mov ebx, TRIGGER_CHANNEL_0 |
||
786 | or eax, ebx |
||
787 | stdcall ptr_write, TRIGGER_CHANNEL, 0, eax |
||
1546 | Asper | 788 | |
2288 | clevermous | 789 | xor eax, eax |
790 | ret |
||
1546 | Asper | 791 | |
792 | align 4 |
||
793 | stop: |
||
2288 | clevermous | 794 | mov eax, INTE_CH_0_LOOP or INTE_CH_0_HALF_LOOP |
795 | stdcall intr_disable, eax |
||
1546 | Asper | 796 | |
2288 | clevermous | 797 | stdcall ptr_read, TRIGGER_CHANNEL, 0 |
798 | mov ebx, TRIGGER_CHANNEL_0 |
||
799 | xor ebx, -1 |
||
800 | or eax, ebx |
||
801 | stdcall ptr_write, TRIGGER_CHANNEL, 0, eax |
||
802 | xor eax, eax |
||
803 | ret |
||
1546 | Asper | 804 | |
805 | align 4 |
||
806 | proc get_dev_info stdcall, p_info:dword |
||
2288 | clevermous | 807 | virtual at esi |
808 | CTRL_INFO CTRL_INFO |
||
809 | end virtual |
||
1546 | Asper | 810 | |
2288 | clevermous | 811 | mov esi, [p_info] |
812 | mov eax, [ctrl.int_line] |
||
813 | mov ecx, [ctrl.ctrl_io_base] |
||
814 | mov [CTRL_INFO.irq], eax |
||
815 | mov [CTRL_INFO.ctrl_io_base], ecx |
||
816 | mov eax, [codec.chip_id] |
||
817 | mov [CTRL_INFO.codec_id], eax |
||
818 | mov ebx, [ctrl.pci_cmd] |
||
819 | mov [CTRL_INFO.pci_cmd], ebx |
||
1546 | Asper | 820 | |
2288 | clevermous | 821 | xor eax, eax |
822 | mov [CTRL_INFO.codec_io_base], eax |
||
823 | mov [CTRL_INFO.codec_mem_base], eax |
||
824 | mov [CTRL_INFO.ctrl_mem_base], eax |
||
825 | mov [CTRL_INFO.glob_cntrl], eax |
||
826 | mov [CTRL_INFO.glob_sta], eax |
||
827 | ret |
||
1546 | Asper | 828 | endp |
829 | |||
830 | align 4 |
||
831 | proc set_callback stdcall, handler:dword |
||
2288 | clevermous | 832 | mov eax, [handler] |
833 | mov [ctrl.user_callback], eax |
||
834 | ret |
||
1546 | Asper | 835 | endp |
836 | |||
837 | |||
838 | align 4 |
||
839 | proc create stdcall |
||
5077 | clevermous | 840 | invoke PciRead16, [ctrl.bus], [ctrl.devfn], 4 |
2288 | clevermous | 841 | test eax, 4 ; test master bit |
842 | jnz @f |
||
843 | or eax, 4 |
||
5077 | clevermous | 844 | invoke PciWrite16, [ctrl.bus], [ctrl.devfn], 4, eax ; set master bit |
2288 | clevermous | 845 | @@: |
1546 | Asper | 846 | |
2288 | clevermous | 847 | xor eax, eax |
848 | mov edx, INTE |
||
849 | call [ctrl.ctrl_write32] |
||
1546 | Asper | 850 | |
2288 | clevermous | 851 | stdcall ptr_write, SPCS0, 0, \ |
852 | SPCS_CLKACCY_1000PPM or SPCS_SAMPLERATE_48 or \ |
||
853 | SPCS_CHANNELNUM_LEFT or SPCS_SOURCENUM_UNSPEC or \ |
||
854 | SPCS_GENERATIONSTATUS or 0x00001200 or \ |
||
855 | 0x00000000 or SPCS_EMPHASIS_NONE or SPCS_COPYRIGHT |
||
856 | stdcall ptr_write, SPCS1, 0, \ |
||
857 | SPCS_CLKACCY_1000PPM or SPCS_SAMPLERATE_48 or \ |
||
858 | SPCS_CHANNELNUM_LEFT or SPCS_SOURCENUM_UNSPEC or \ |
||
859 | SPCS_GENERATIONSTATUS or 0x00001200 or \ |
||
860 | 0x00000000 or SPCS_EMPHASIS_NONE or SPCS_COPYRIGHT |
||
861 | stdcall ptr_write, SPCS2, 0, \ |
||
862 | SPCS_CLKACCY_1000PPM or SPCS_SAMPLERATE_48 or \ |
||
863 | SPCS_CHANNELNUM_LEFT or SPCS_SOURCENUM_UNSPEC or \ |
||
864 | SPCS_GENERATIONSTATUS or 0x00001200 or \ |
||
865 | 0x00000000 or SPCS_EMPHASIS_NONE or SPCS_COPYRIGHT |
||
1546 | Asper | 866 | |
2288 | clevermous | 867 | stdcall ptr_write, SPDIF_SELECT, 0, 0x700 ; disable SPDIF |
868 | stdcall ptr_write, ROUTING, 0, 0x1003F ; routing |
||
869 | stdcall gpio_write, 0x1080 ; analog mode |
||
1546 | Asper | 870 | |
2288 | clevermous | 871 | mov eax, dword HCFG_LOCKSOUNDCACHE or HCFG_AUDIOENABLE |
872 | mov edx, HCFG |
||
873 | call [ctrl.ctrl_write32] |
||
874 | ret |
||
1546 | Asper | 875 | endp |
876 | |||
877 | align 4 |
||
878 | proc codec_read stdcall, reg:dword |
||
2288 | clevermous | 879 | stdcall ac97_read, dword [reg] |
880 | ret |
||
1546 | Asper | 881 | endp |
882 | |||
883 | |||
884 | align 4 |
||
885 | proc codec_write stdcall, reg:dword |
||
2288 | clevermous | 886 | stdcall ac97_write, dword [reg], eax |
887 | ret |
||
1546 | Asper | 888 | endp |
889 | |||
890 | |||
891 | align 4 |
||
892 | proc ac97_read stdcall, reg:dword |
||
2288 | clevermous | 893 | push edx |
894 | mov eax, dword [reg] |
||
895 | mov edx, AC97ADDRESS |
||
896 | call [ctrl.ctrl_write8] |
||
1546 | Asper | 897 | |
2288 | clevermous | 898 | mov edx, AC97DATA |
899 | call [ctrl.ctrl_read16] |
||
900 | and eax, 0xFFFF |
||
901 | pop edx |
||
902 | ret |
||
1546 | Asper | 903 | endp |
904 | |||
905 | align 4 |
||
906 | proc ac97_write stdcall, reg:dword, val:dword |
||
2288 | clevermous | 907 | push eax edx |
908 | mov eax, dword [reg] |
||
909 | mov edx, AC97ADDRESS |
||
910 | call [ctrl.ctrl_write8] |
||
1546 | Asper | 911 | |
2288 | clevermous | 912 | mov eax, dword [val] |
913 | mov edx, AC97DATA |
||
914 | call [ctrl.ctrl_write16] |
||
915 | pop edx eax |
||
916 | ret |
||
1546 | Asper | 917 | endp |
918 | |||
919 | align 4 |
||
920 | proc ptr_read stdcall, reg:dword, chn:dword |
||
2288 | clevermous | 921 | push edx |
922 | mov eax, dword [reg] |
||
923 | shl eax, 16 |
||
924 | or eax, dword [chn] |
||
1546 | Asper | 925 | |
2288 | clevermous | 926 | mov edx, PTR |
927 | call [ctrl.ctrl_write32] |
||
1546 | Asper | 928 | |
2288 | clevermous | 929 | mov edx, DATA |
930 | call [ctrl.ctrl_read32] |
||
931 | pop edx |
||
932 | ret |
||
1546 | Asper | 933 | endp |
934 | |||
935 | align 4 |
||
936 | proc ptr_write stdcall, reg:dword, chn:dword, data:dword |
||
2288 | clevermous | 937 | push eax edx |
938 | mov eax, dword [reg] |
||
939 | shl eax, 16 |
||
940 | or eax, dword [chn] |
||
1546 | Asper | 941 | |
2288 | clevermous | 942 | mov edx, PTR |
943 | call [ctrl.ctrl_write32] |
||
1546 | Asper | 944 | |
2288 | clevermous | 945 | mov eax, dword [data] |
946 | mov edx, DATA |
||
947 | call [ctrl.ctrl_write32] |
||
948 | pop edx eax |
||
949 | ret |
||
1546 | Asper | 950 | endp |
951 | |||
952 | align 4 |
||
953 | proc intr_enable stdcall, intrenb:dword |
||
2288 | clevermous | 954 | push edx |
955 | mov edx, INTE |
||
956 | call [ctrl.ctrl_read32] |
||
1546 | Asper | 957 | |
2288 | clevermous | 958 | or eax, dword [intrenb] |
959 | mov edx, INTE |
||
960 | call [ctrl.ctrl_write32] |
||
961 | pop edx |
||
962 | ret |
||
1546 | Asper | 963 | endp |
964 | |||
965 | align 4 |
||
966 | proc intr_disable stdcall, intrenb:dword |
||
2288 | clevermous | 967 | push eax ebx edx |
968 | mov edx, INTE |
||
969 | call [ctrl.ctrl_read32] |
||
1546 | Asper | 970 | |
2288 | clevermous | 971 | mov ebx, dword [intrenb] |
972 | xor ebx, -1 |
||
973 | and eax, ebx |
||
974 | mov edx, INTE |
||
975 | call [ctrl.ctrl_write32] |
||
976 | pop edx ebx eax |
||
977 | ret |
||
1546 | Asper | 978 | endp |
979 | |||
980 | align 4 |
||
981 | proc gpio_write stdcall, value:dword |
||
2288 | clevermous | 982 | push eax edx |
983 | mov eax, dword [value] |
||
984 | mov edx, GPIO |
||
985 | call [ctrl.ctrl_write32] |
||
986 | pop edx eax |
||
987 | ret |
||
1546 | Asper | 988 | endp |
989 | |||
990 | |||
991 | align 4 |
||
992 | proc StallExec |
||
2288 | clevermous | 993 | push ecx |
994 | push edx |
||
995 | push ebx |
||
996 | push eax |
||
1546 | Asper | 997 | |
2288 | clevermous | 998 | mov ecx, CPU_FREQ |
999 | mul ecx |
||
1000 | mov ebx, eax ;low |
||
1001 | mov ecx, edx ;high |
||
1002 | rdtsc |
||
1003 | add ebx, eax |
||
1004 | adc ecx, edx |
||
1546 | Asper | 1005 | @@: |
2288 | clevermous | 1006 | rdtsc |
1007 | sub eax, ebx |
||
1008 | sbb edx, ecx |
||
1009 | js @B |
||
1546 | Asper | 1010 | |
2288 | clevermous | 1011 | pop eax |
1012 | pop ebx |
||
1013 | pop edx |
||
1014 | pop ecx |
||
1015 | ret |
||
1546 | Asper | 1016 | endp |
1017 | |||
1018 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1019 | ; CONTROLLER IO functions |
||
1020 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1021 | |||
1022 | align 4 |
||
1023 | proc codec_io_r16 ;Not used. |
||
2288 | clevermous | 1024 | ;mov edx, [ctrl.ctrl_io_base] |
1025 | ;in eax, dx |
||
1026 | ret |
||
1546 | Asper | 1027 | endp |
1028 | |||
1029 | align 4 |
||
1030 | proc codec_io_w16 ;Not used. |
||
2288 | clevermous | 1031 | ;mov edx, [ctrl.ctrl_io_base] |
1032 | ;out dx, eax |
||
1033 | ret |
||
1546 | Asper | 1034 | endp |
1035 | |||
1036 | align 4 |
||
1037 | proc ctrl_io_r8 |
||
2288 | clevermous | 1038 | add edx, [ctrl.ctrl_io_base] |
1039 | in al, dx |
||
1040 | ret |
||
1546 | Asper | 1041 | endp |
1042 | |||
1043 | align 4 |
||
1044 | proc ctrl_io_r16 |
||
2288 | clevermous | 1045 | add edx, [ctrl.ctrl_io_base] |
1046 | in ax, dx |
||
1047 | ret |
||
1546 | Asper | 1048 | endp |
1049 | |||
1050 | align 4 |
||
1051 | proc ctrl_io_r32 |
||
2288 | clevermous | 1052 | add edx, [ctrl.ctrl_io_base] |
1053 | in eax, dx |
||
1054 | ret |
||
1546 | Asper | 1055 | endp |
1056 | |||
1057 | align 4 |
||
1058 | proc ctrl_io_w8 |
||
2288 | clevermous | 1059 | add edx, [ctrl.ctrl_io_base] |
1060 | out dx, al |
||
1061 | ret |
||
1546 | Asper | 1062 | endp |
1063 | |||
1064 | align 4 |
||
1065 | proc ctrl_io_w16 |
||
2288 | clevermous | 1066 | add edx, [ctrl.ctrl_io_base] |
1067 | out dx, ax |
||
1068 | ret |
||
1546 | Asper | 1069 | endp |
1070 | |||
1071 | align 4 |
||
1072 | proc ctrl_io_w32 |
||
2288 | clevermous | 1073 | add edx, [ctrl.ctrl_io_base] |
1074 | out dx, eax |
||
1075 | ret |
||
1546 | Asper | 1076 | endp |
1077 | |||
1078 | |||
1079 | align 4 |
||
1080 | dword2str: |
||
2288 | clevermous | 1081 | push eax ebx ecx |
1082 | mov esi, hex_buff |
||
1083 | mov ecx, -8 |
||
1546 | Asper | 1084 | @@: |
2288 | clevermous | 1085 | rol eax, 4 |
1086 | mov ebx, eax |
||
1087 | and ebx, 0x0F |
||
1088 | mov bl, [ebx+hexletters] |
||
1089 | mov [8+esi+ecx], bl |
||
1090 | inc ecx |
||
1091 | jnz @B |
||
1092 | pop ecx ebx eax |
||
1093 | ret |
||
1546 | Asper | 1094 | |
1095 | hexletters db '0123456789ABCDEF' |
||
1096 | hex_buff db 8 dup(0),13,10,0 |
||
1097 | |||
1098 | |||
1099 | include "codec.inc" |
||
1100 | |||
1101 | align 4 |
||
1102 | devices dd (CTRL_CT0200 shl 16)+VID_Creative,msg_CT_EMU10K1X,set_Creative |
||
2288 | clevermous | 1103 | dd 0 ;terminator |
1546 | Asper | 1104 | |
1105 | |||
1106 | msg_CT_EMU10K1X db 'SB Live! Dell OEM', 13,10, 0 |
||
2288 | clevermous | 1107 | msg_Creative db 'Creative ', 0 |
1546 | Asper | 1108 | |
2288 | clevermous | 1109 | szKernel db 'KERNEL', 0 |
1110 | sz_sound_srv db 'SOUND',0 |
||
1546 | Asper | 1111 | |
1112 | msgInit db 'detect hardware...',13,10,0 |
||
1113 | msgFail db 'device not found',13,10,0 |
||
1114 | msgAttchIRQ db 'IRQ line not supported', 13,10, 0 |
||
1115 | msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 |
||
1116 | msgPlay db 'start play', 13,10,0 |
||
1117 | msgStop db 'stop play', 13,10,0 |
||
2288 | clevermous | 1118 | msgIRQ db 'AC97 IRQ', 13,10,0 |
1546 | Asper | 1119 | ;msgInitCtrl db 'init controller',13,10,0 |
1120 | ;msgInitCodec db 'init codec',13,10,0 |
||
1121 | msgPrimBuff db 'create primary buffer ...',0 |
||
1122 | msgDone db 'done',13,10,0 |
||
1123 | msgRemap db 'Remap IRQ',13,10,0 |
||
1124 | ;msgReg db 'set service handler',13,10,0 |
||
1125 | ;msgOk db 'service installed',13,10,0 |
||
1126 | msgCold db 'cold reset',13,10,0 |
||
1127 | ;msgWarm db 'warm reset',13,10,0 |
||
1128 | ;msgWRFail db 'warm reset failed',13,10,0 |
||
1129 | msgCRFail db 'cold reset failed',13,10,0 |
||
1130 | ;msgCFail db 'codec not ready',13,10,0 |
||
1131 | ;msgCInvalid db 'codec is not valid',13,10,0 ;Asper |
||
1132 | ;msgResetOk db 'reset complete',13,10,0 |
||
1133 | ;msgStatus db 'global status ',0 |
||
1134 | ;msgControl db 'global control ',0 |
||
1135 | msgPciCmd db 'PCI command ',0 |
||
1136 | msgPciStat db 'PCI status ',0 |
||
1137 | msgPciSubsys db 'PCI subsystem ',0 |
||
1138 | msgCtrlIsaIo db 'controller io base ',0 |
||
1139 | ;msgMixIsaIo db 'codec io base ',0 |
||
1140 | ;msgCtrlMMIo db 'controller mmio base ',0 |
||
1141 | ;msgMixMMIo db 'codec mmio base ',0 |
||
1142 | ;msgIrqMap db 'AC97 irq map as ',0 |
||
1143 | |||
5077 | clevermous | 1144 | align 4 |
1145 | data fixups |
||
1146 | end data |
||
1546 | Asper | 1147 | |
5077 | clevermous | 1148 | align 8 |
2288 | clevermous | 1149 | pcmout_bdl rq 32 |
1150 | buff_list rd 32 |
||
1546 | Asper | 1151 | |
1152 | codec CODEC |
||
1153 | ctrl AC_CNTRL><>><> |