Subversion Repositories Kolibri OS

Rev

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