Subversion Repositories Kolibri OS

Rev

Rev 5363 | Go to most recent revision | 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
include '../struct.inc'
11
include '../struct.inc'
12
 
12
 
13
DEBUG           equ 1
13
DEBUG           equ 1
14
 
14
 
15
API_VERSION     equ 0x01000100
15
API_VERSION     equ 0x01000100
16
 
16
 
17
DEBUG_IRQ       equ 0
17
DEBUG_IRQ       equ 0
18
 
-
 
19
USE_COM_IRQ     equ 0    ;make irq 3 and irq 4 available for PCI devices
18
 
20
IRQ_REMAP       equ 0
19
IRQ_REMAP       equ 0
21
IRQ_LINE        equ 0
20
IRQ_LINE        equ 0
22
 
21
 
23
 
22
 
24
;irq 0,1,2,8,12,13 недоступны
23
;irq 0,13 unavailable
25
;                   FEDCBA9876543210
24
;                   FEDCBA9876543210
26
VALID_IRQ       equ 1100111011111000b
-
 
27
ATTCH_IRQ       equ 0000111010100000b
-
 
28
 
-
 
29
if USE_COM_IRQ
-
 
30
ATTCH_IRQ       equ 0000111010111000b
-
 
31
end if
25
VALID_IRQ       equ 1101111111111110b
32
 
26
 
33
CPU_FREQ        equ  2600d
27
CPU_FREQ        equ  2600d
34
 
28
 
35
BIT0  EQU 0x00000001
29
BIT0  EQU 0x00000001
36
BIT1  EQU 0x00000002
30
BIT1  EQU 0x00000002
37
BIT2  EQU 0x00000004
31
BIT2  EQU 0x00000004
38
BIT3  EQU 0x00000008
32
BIT3  EQU 0x00000008
39
BIT4  EQU 0x00000010
33
BIT4  EQU 0x00000010
40
BIT5  EQU 0x00000020
34
BIT5  EQU 0x00000020
41
BIT6  EQU 0x00000040
35
BIT6  EQU 0x00000040
42
BIT7  EQU 0x00000080
36
BIT7  EQU 0x00000080
43
BIT8  EQU 0x00000100
37
BIT8  EQU 0x00000100
44
BIT9  EQU 0x00000200
38
BIT9  EQU 0x00000200
45
BIT10 EQU 0x00000400
39
BIT10 EQU 0x00000400
46
BIT11 EQU 0x00000800
40
BIT11 EQU 0x00000800
47
BIT12 EQU 0x00001000
41
BIT12 EQU 0x00001000
48
BIT13 EQU 0x00002000
42
BIT13 EQU 0x00002000
49
BIT14 EQU 0x00004000
43
BIT14 EQU 0x00004000
50
BIT15 EQU 0x00008000
44
BIT15 EQU 0x00008000
51
BIT16 EQU 0x00010000
45
BIT16 EQU 0x00010000
52
BIT17 EQU 0x00020000
46
BIT17 EQU 0x00020000
53
BIT18 EQU 0x00040000
47
BIT18 EQU 0x00040000
54
BIT19 EQU 0x00080000
48
BIT19 EQU 0x00080000
55
BIT20 EQU 0x00100000
49
BIT20 EQU 0x00100000
56
BIT21 EQU 0x00200000
50
BIT21 EQU 0x00200000
57
BIT22 EQU 0x00400000
51
BIT22 EQU 0x00400000
58
BIT23 EQU 0x00800000
52
BIT23 EQU 0x00800000
59
BIT24 EQU 0x00100000
53
BIT24 EQU 0x00100000
60
BIT25 EQU 0x02000000
54
BIT25 EQU 0x02000000
61
BIT26 EQU 0x04000000
55
BIT26 EQU 0x04000000
62
BIT27 EQU 0x08000000
56
BIT27 EQU 0x08000000
63
BIT28 EQU 0x10000000
57
BIT28 EQU 0x10000000
64
BIT29 EQU 0x20000000
58
BIT29 EQU 0x20000000
65
BIT30 EQU 0x40000000
59
BIT30 EQU 0x40000000
66
BIT31 EQU 0x80000000
60
BIT31 EQU 0x80000000
67
 
61
 
68
PCM_4 equ BIT20
62
PCM_4 equ BIT20
69
PCM_6 equ BIT21
63
PCM_6 equ BIT21
70
 
64
 
71
VID_INTEL         equ 0x8086
65
VID_INTEL         equ 0x8086
72
VID_NVIDIA        equ 0x10DE
66
VID_NVIDIA        equ 0x10DE
73
 
67
 
74
CTRL_ICH          equ 0x2415
68
CTRL_ICH          equ 0x2415
75
CTRL_ICH0         equ 0x2425
69
CTRL_ICH0         equ 0x2425
76
CTRL_ICH2         equ 0x2435
70
CTRL_ICH2         equ 0x2435
77
CTRL_ICH3         equ 0x2445
71
CTRL_ICH3         equ 0x2445
78
CTRL_ICH4         equ 0x24C5
72
CTRL_ICH4         equ 0x24C5
79
CTRL_ICH5         equ 0x24D5
73
CTRL_ICH5         equ 0x24D5
80
CTRL_ICH6         equ 0x266E
74
CTRL_ICH6         equ 0x266E
81
CTRL_ICH7         equ 0x27DE
75
CTRL_ICH7         equ 0x27DE
82
 
76
 
83
CTRL_NFORCE       equ 0x01B1
77
CTRL_NFORCE       equ 0x01B1
84
CTRL_NFORCE2      equ 0x006A
78
CTRL_NFORCE2      equ 0x006A
85
CTRL_NFORCE3      equ 0x00DA
79
CTRL_NFORCE3      equ 0x00DA
86
CTRL_MCP04        equ 0x003A
80
CTRL_MCP04        equ 0x003A
87
CTRL_CK804        equ 0x0059
81
CTRL_CK804        equ 0x0059
88
CTRL_CK8          equ 0x008A
82
CTRL_CK8          equ 0x008A
89
CTRL_CK8S         equ 0x00EA
83
CTRL_CK8S         equ 0x00EA
90
CTRL_MCP51        equ 0x026B
84
CTRL_MCP51        equ 0x026B
91
 
85
 
92
 
86
 
93
PCM_OUT_BDL       equ  0x10  ; PCM out buffer descriptors list
87
PCM_OUT_BDL       equ  0x10  ; PCM out buffer descriptors list
94
PCM_OUT_CR_REG    equ  0x1b  ; PCM out Control Register
88
PCM_OUT_CR_REG    equ  0x1b  ; PCM out Control Register
95
PCM_OUT_LVI_REG   equ  0x15  ; PCM last valid index
89
PCM_OUT_LVI_REG   equ  0x15  ; PCM last valid index
96
PCM_OUT_SR_REG    equ  0x16  ; PCM out Status register
90
PCM_OUT_SR_REG    equ  0x16  ; PCM out Status register
97
PCM_OUT_PIV_REG   equ  0x1a
91
PCM_OUT_PIV_REG   equ  0x1a
98
PCM_OUT_CIV_REG   equ  0x14  ; PCM out current index
92
PCM_OUT_CIV_REG   equ  0x14  ; PCM out current index
99
 
93
 
100
PCM_IN_CR_REG     equ  0x0b  ; PCM in Control Register
94
PCM_IN_CR_REG     equ  0x0b  ; PCM in Control Register
101
MC_IN_CR_REG      equ  0x2b  ; MIC in Control Register
95
MC_IN_CR_REG      equ  0x2b  ; MIC in Control Register
102
RR                equ  BIT1  ; reset registers.  Nukes all regs
96
RR                equ  BIT1  ; reset registers.  Nukes all regs
103
 
97
 
104
CODEC_MASTER_VOL_REG         equ 0x02
98
CODEC_MASTER_VOL_REG         equ 0x02
105
CODEC_AUX_VOL                equ 0x04 ;
99
CODEC_AUX_VOL                equ 0x04 ;
106
CODEC_PCM_OUT_REG            equ 0x18 ; PCM output volume
100
CODEC_PCM_OUT_REG            equ 0x18 ; PCM output volume
107
CODEC_EXT_AUDIO_REG          equ 0x28 ; extended audio
101
CODEC_EXT_AUDIO_REG          equ 0x28 ; extended audio
108
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
102
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
109
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
103
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
110
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
104
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
111
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
105
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
112
 
106
 
113
GLOB_CTRL         equ  0x2C  ;   Global Control
107
GLOB_CTRL         equ  0x2C  ;   Global Control
114
CTRL_STAT         equ  0x30  ;   Global Status
108
CTRL_STAT         equ  0x30  ;   Global Status
115
CTRL_CAS          equ  0x34  ;   Codec Access Semiphore
109
CTRL_CAS          equ  0x34  ;   Codec Access Semiphore
116
 
110
 
117
CAS_FLAG          equ  0x01  ;   Codec Access Semiphore Bit
111
CAS_FLAG          equ  0x01  ;   Codec Access Semiphore Bit
118
 
112
 
119
CTRL_ST_CREADY    equ  BIT8+BIT9+BIT28 ;   Primary Codec Ready
113
CTRL_ST_CREADY    equ  BIT8+BIT9+BIT28 ;   Primary Codec Ready
120
 
114
 
121
CTRL_ST_RCS       equ  0x00008000  ;   Read Completion Status
115
CTRL_ST_RCS       equ  0x00008000  ;   Read Completion Status
122
 
116
 
123
CTRL_CNT_CRIE     equ  BIT4+BIT5+BIT6  ;   Codecs Resume Interrupt Enable
117
CTRL_CNT_CRIE     equ  BIT4+BIT5+BIT6  ;   Codecs Resume Interrupt Enable
124
CTRL_CNT_AC_OFF   equ  0x00000008  ;   ACLINK Off
118
CTRL_CNT_AC_OFF   equ  0x00000008  ;   ACLINK Off
125
CTRL_CNT_WARM     equ  0x00000004  ;   AC97 Warm Reset
119
CTRL_CNT_WARM     equ  0x00000004  ;   AC97 Warm Reset
126
CTRL_CNT_COLD     equ  0x00000002  ;   AC97 Cold Reset
120
CTRL_CNT_COLD     equ  0x00000002  ;   AC97 Cold Reset
127
CTRL_CNT_GIE      equ  0x00000001  ;   GPI Interrupt Enable
121
CTRL_CNT_GIE      equ  0x00000001  ;   GPI Interrupt Enable
128
 
122
 
129
CODEC_REG_POWERDOWN   equ 0x26
123
CODEC_REG_POWERDOWN   equ 0x26
130
CODEC_REG_ST          equ 0x26
124
CODEC_REG_ST          equ 0x26
131
 
125
 
132
SRV_GETVERSION        equ  0
126
SRV_GETVERSION        equ  0
133
DEV_PLAY              equ  1
127
DEV_PLAY              equ  1
134
DEV_STOP              equ  2
128
DEV_STOP              equ  2
135
DEV_CALLBACK          equ  3
129
DEV_CALLBACK          equ  3
136
DEV_SET_BUFF          equ  4
130
DEV_SET_BUFF          equ  4
137
DEV_NOTIFY            equ  5
131
DEV_NOTIFY            equ  5
138
DEV_SET_MASTERVOL     equ  6
132
DEV_SET_MASTERVOL     equ  6
139
DEV_GET_MASTERVOL     equ  7
133
DEV_GET_MASTERVOL     equ  7
140
DEV_GET_INFO          equ  8
134
DEV_GET_INFO          equ  8
141
DEV_GET_POS           equ  9
135
DEV_GET_POS           equ  9
142
 
136
 
143
struc AC_CNTRL              ;AC controller base class
137
struc AC_CNTRL              ;AC controller base class
144
{ .bus                dd ?
138
{ .bus                dd ?
145
  .devfn              dd ?
139
  .devfn              dd ?
146
 
140
 
147
  .vendor             dd ?
141
  .vendor             dd ?
148
  .dev_id             dd ?
142
  .dev_id             dd ?
149
  .pci_cmd            dd ?
143
  .pci_cmd            dd ?
150
  .pci_stat           dd ?
144
  .pci_stat           dd ?
151
 
145
 
152
  .codec_io_base      dd ?
146
  .codec_io_base      dd ?
153
  .codec_mem_base     dd ?
147
  .codec_mem_base     dd ?
154
 
148
 
155
  .ctrl_io_base       dd ?
149
  .ctrl_io_base       dd ?
156
  .ctrl_mem_base      dd ?
150
  .ctrl_mem_base      dd ?
157
  .cfg_reg            dd ?
151
  .cfg_reg            dd ?
158
  .int_line           dd ?
152
  .int_line           dd ?
159
 
153
 
160
  .vendor_ids         dd ?    ;vendor id string
154
  .vendor_ids         dd ?    ;vendor id string
161
  .ctrl_ids           dd ?    ;hub id string
155
  .ctrl_ids           dd ?    ;hub id string
162
 
156
 
163
  .buffer             dd ?
157
  .buffer             dd ?
164
 
158
 
165
  .notify_pos         dd ?
159
  .notify_pos         dd ?
166
  .notify_task        dd ?
160
  .notify_task        dd ?
167
 
161
 
168
  .lvi_reg            dd ?
162
  .lvi_reg            dd ?
169
  .ctrl_setup         dd ?
163
  .ctrl_setup         dd ?
170
  .user_callback      dd ?
164
  .user_callback      dd ?
171
  .codec_read16       dd ?
165
  .codec_read16       dd ?
172
  .codec_write16      dd ?
166
  .codec_write16      dd ?
173
 
167
 
174
  .ctrl_read8         dd ?
168
  .ctrl_read8         dd ?
175
  .ctrl_read16        dd ?
169
  .ctrl_read16        dd ?
176
  .ctrl_read32        dd ?
170
  .ctrl_read32        dd ?
177
 
171
 
178
  .ctrl_write8        dd ?
172
  .ctrl_write8        dd ?
179
  .ctrl_write16       dd ?
173
  .ctrl_write16       dd ?
180
  .ctrl_write32       dd ?
174
  .ctrl_write32       dd ?
181
}
175
}
182
 
176
 
183
struc CODEC                ;Audio Chip base class
177
struc CODEC                ;Audio Chip base class
184
{
178
{
185
  .chip_id            dd ?
179
  .chip_id            dd ?
186
  .flags              dd ?
180
  .flags              dd ?
187
  .status             dd ?
181
  .status             dd ?
188
 
182
 
189
  .ac_vendor_ids      dd ?    ;ac vendor id string
183
  .ac_vendor_ids      dd ?    ;ac vendor id string
190
  .chip_ids           dd ?    ;chip model string
184
  .chip_ids           dd ?    ;chip model string
191
 
185
 
192
  .shadow_flag        dd ?
186
  .shadow_flag        dd ?
193
                      dd ?
187
                      dd ?
194
 
188
 
195
  .regs               dw ?     ; codec registers
189
  .regs               dw ?     ; codec registers
196
  .reg_master_vol     dw ?     ;0x02
190
  .reg_master_vol     dw ?     ;0x02
197
  .reg_aux_out_vol    dw ?     ;0x04
191
  .reg_aux_out_vol    dw ?     ;0x04
198
  .reg_mone_vol       dw ?     ;0x06
192
  .reg_mone_vol       dw ?     ;0x06
199
  .reg_master_tone    dw ?     ;0x08
193
  .reg_master_tone    dw ?     ;0x08
200
  .reg_beep_vol       dw ?     ;0x0A
194
  .reg_beep_vol       dw ?     ;0x0A
201
  .reg_phone_vol      dw ?     ;0x0C
195
  .reg_phone_vol      dw ?     ;0x0C
202
  .reg_mic_vol        dw ?     ;0x0E
196
  .reg_mic_vol        dw ?     ;0x0E
203
  .reg_line_in_vol    dw ?     ;0x10
197
  .reg_line_in_vol    dw ?     ;0x10
204
  .reg_cd_vol         dw ?     ;0x12
198
  .reg_cd_vol         dw ?     ;0x12
205
  .reg_video_vol      dw ?     ;0x14
199
  .reg_video_vol      dw ?     ;0x14
206
  .reg_aux_in_vol     dw ?     ;0x16
200
  .reg_aux_in_vol     dw ?     ;0x16
207
  .reg_pcm_out_vol    dw ?     ;0x18
201
  .reg_pcm_out_vol    dw ?     ;0x18
208
  .reg_rec_select     dw ?     ;0x1A
202
  .reg_rec_select     dw ?     ;0x1A
209
  .reg_rec_gain       dw ?     ;0x1C
203
  .reg_rec_gain       dw ?     ;0x1C
210
  .reg_rec_gain_mic   dw ?     ;0x1E
204
  .reg_rec_gain_mic   dw ?     ;0x1E
211
  .reg_gen            dw ?     ;0x20
205
  .reg_gen            dw ?     ;0x20
212
  .reg_3d_ctrl        dw ?     ;0X22
206
  .reg_3d_ctrl        dw ?     ;0X22
213
  .reg_page           dw ?     ;0X24
207
  .reg_page           dw ?     ;0X24
214
  .reg_powerdown      dw ?     ;0x26
208
  .reg_powerdown      dw ?     ;0x26
215
  .reg_ext_audio      dw ?     ;0x28
209
  .reg_ext_audio      dw ?     ;0x28
216
  .reg_ext_st         dw ?     ;0x2a
210
  .reg_ext_st         dw ?     ;0x2a
217
  .reg_pcm_front_rate dw ?     ;0x2c
211
  .reg_pcm_front_rate dw ?     ;0x2c
218
  .reg_pcm_surr_rate  dw ?     ;0x2e
212
  .reg_pcm_surr_rate  dw ?     ;0x2e
219
  .reg_lfe_rate       dw ?     ;0x30
213
  .reg_lfe_rate       dw ?     ;0x30
220
  .reg_pcm_in_rate    dw ?     ;0x32
214
  .reg_pcm_in_rate    dw ?     ;0x32
221
                      dw ?     ;0x34
215
                      dw ?     ;0x34
222
  .reg_cent_lfe_vol   dw ?     ;0x36
216
  .reg_cent_lfe_vol   dw ?     ;0x36
223
  .reg_surr_vol       dw ?     ;0x38
217
  .reg_surr_vol       dw ?     ;0x38
224
  .reg_spdif_ctrl     dw ?     ;0x3A
218
  .reg_spdif_ctrl     dw ?     ;0x3A
225
                      dw ?     ;0x3C
219
                      dw ?     ;0x3C
226
                      dw ?     ;0x3E
220
                      dw ?     ;0x3E
227
                      dw ?     ;0x40
221
                      dw ?     ;0x40
228
                      dw ?     ;0x42
222
                      dw ?     ;0x42
229
                      dw ?     ;0x44
223
                      dw ?     ;0x44
230
                      dw ?     ;0x46
224
                      dw ?     ;0x46
231
                      dw ?     ;0x48
225
                      dw ?     ;0x48
232
                      dw ?     ;0x4A
226
                      dw ?     ;0x4A
233
                      dw ?     ;0x4C
227
                      dw ?     ;0x4C
234
                      dw ?     ;0x4E
228
                      dw ?     ;0x4E
235
                      dw ?     ;0x50
229
                      dw ?     ;0x50
236
                      dw ?     ;0x52
230
                      dw ?     ;0x52
237
                      dw ?     ;0x54
231
                      dw ?     ;0x54
238
                      dw ?     ;0x56
232
                      dw ?     ;0x56
239
                      dw ?     ;0x58
233
                      dw ?     ;0x58
240
                      dw ?     ;0x5A
234
                      dw ?     ;0x5A
241
                      dw ?     ;0x5C
235
                      dw ?     ;0x5C
242
                      dw ?     ;0x5E
236
                      dw ?     ;0x5E
243
  .reg_page_0         dw ?     ;0x60
237
  .reg_page_0         dw ?     ;0x60
244
  .reg_page_1         dw ?     ;0x62
238
  .reg_page_1         dw ?     ;0x62
245
  .reg_page_2         dw ?     ;0x64
239
  .reg_page_2         dw ?     ;0x64
246
  .reg_page_3         dw ?     ;0x66
240
  .reg_page_3         dw ?     ;0x66
247
  .reg_page_4         dw ?     ;0x68
241
  .reg_page_4         dw ?     ;0x68
248
  .reg_page_5         dw ?     ;0x6A
242
  .reg_page_5         dw ?     ;0x6A
249
  .reg_page_6         dw ?     ;0x6C
243
  .reg_page_6         dw ?     ;0x6C
250
  .reg_page_7         dw ?     ;0x6E
244
  .reg_page_7         dw ?     ;0x6E
251
                      dw ?     ;0x70
245
                      dw ?     ;0x70
252
                      dw ?     ;0x72
246
                      dw ?     ;0x72
253
                      dw ?     ;0x74
247
                      dw ?     ;0x74
254
                      dw ?     ;0x76
248
                      dw ?     ;0x76
255
                      dw ?     ;0x78
249
                      dw ?     ;0x78
256
                      dw ?     ;0x7A
250
                      dw ?     ;0x7A
257
  .reg_vendor_id_1    dw ?     ;0x7C
251
  .reg_vendor_id_1    dw ?     ;0x7C
258
  .reg_vendor_id_2    dw ?     ;0x7E
252
  .reg_vendor_id_2    dw ?     ;0x7E
259
 
253
 
260
 
254
 
261
  .reset              dd ?    ;virual
255
  .reset              dd ?    ;virual
262
  .set_master_vol     dd ?
256
  .set_master_vol     dd ?
263
}
257
}
264
 
258
 
265
struc CTRL_INFO
259
struc CTRL_INFO
266
{   .pci_cmd          dd ?
260
{   .pci_cmd          dd ?
267
    .irq              dd ?
261
    .irq              dd ?
268
    .glob_cntrl       dd ?
262
    .glob_cntrl       dd ?
269
    .glob_sta         dd ?
263
    .glob_sta         dd ?
270
    .codec_io_base    dd ?
264
    .codec_io_base    dd ?
271
    .ctrl_io_base     dd ?
265
    .ctrl_io_base     dd ?
272
    .codec_mem_base   dd ?
266
    .codec_mem_base   dd ?
273
    .ctrl_mem_base    dd ?
267
    .ctrl_mem_base    dd ?
274
    .codec_id         dd ?
268
    .codec_id         dd ?
275
}
269
}
276
 
270
 
277
EVENT_NOTIFY    equ 0x00000200
271
EVENT_NOTIFY    equ 0x00000200
278
 
272
 
279
section '.flat' code readable executable
273
section '.flat' code readable executable
280
include '../macros.inc'
274
include '../macros.inc'
281
include '../proc32.inc'
275
include '../proc32.inc'
282
include '../peimport.inc'
276
include '../peimport.inc'
283
 
277
 
284
proc START c uses ebx esi edi, state:dword, cmdline:dword
278
proc START c uses ebx esi edi, state:dword, cmdline:dword
285
 
279
 
286
        cmp     [state], 1
280
        cmp     [state], 1
287
        jne     .stop
281
        jne     .stop
288
 
282
 
289
     if DEBUG
283
     if DEBUG
290
        mov     esi, msgInit
284
        mov     esi, msgInit
291
        invoke  SysMsgBoardStr
285
        invoke  SysMsgBoardStr
292
     end if
286
     end if
293
 
287
 
294
        call    detect_controller
288
        call    detect_controller
295
        test    eax, eax
289
        test    eax, eax
296
        jz      .fail
290
        jz      .fail
297
 
291
 
298
     if DEBUG
292
     if DEBUG
299
        mov     esi, [ctrl.vendor_ids]
293
        mov     esi, [ctrl.vendor_ids]
300
        invoke  SysMsgBoardStr
294
        invoke  SysMsgBoardStr
301
        mov     esi, [ctrl.ctrl_ids]
295
        mov     esi, [ctrl.ctrl_ids]
302
        invoke  SysMsgBoardStr
296
        invoke  SysMsgBoardStr
303
 
297
 
304
     end if
298
     end if
305
 
299
 
306
        call    init_controller
300
        call    init_controller
307
        test    eax, eax
301
        test    eax, eax
308
        jz      .fail
302
        jz      .fail
309
 
303
 
310
        call    init_codec
304
        call    init_codec
311
        test    eax, eax
305
        test    eax, eax
312
        jz      .fail
306
        jz      .fail
313
 
307
 
314
        call    reset_controller
308
        call    reset_controller
315
        call    setup_codec
309
        call    setup_codec
316
 
310
 
317
        mov     esi, msgPrimBuff
311
        mov     esi, msgPrimBuff
318
        invoke  SysMsgBoardStr
312
        invoke  SysMsgBoardStr
319
        call    create_primary_buff
313
        call    create_primary_buff
320
        mov     esi, msgDone
314
        mov     esi, msgDone
321
        invoke  SysMsgBoardStr
315
        invoke  SysMsgBoardStr
322
 
316
 
323
  if IRQ_REMAP
317
  if IRQ_REMAP
324
        pushf
318
        pushf
325
        cli
319
        cli
326
 
320
 
327
        mov     ebx, [ctrl.int_line]
321
        mov     ebx, [ctrl.int_line]
328
        in      al, 0xA1
322
        in      al, 0xA1
329
        mov     ah, al
323
        mov     ah, al
330
        in      al, 0x21
324
        in      al, 0x21
331
        test    ebx, ebx
325
        test    ebx, ebx
332
        jz      .skip
326
        jz      .skip
333
        bts     ax, bx                     ;mask old line
327
        bts     ax, bx                     ;mask old line
334
.skip
328
.skip
335
        bts     ax, IRQ_LINE               ;mask new ine
329
        bts     ax, IRQ_LINE               ;mask new ine
336
        out     0x21, al
330
        out     0x21, al
337
        mov     al, ah
331
        mov     al, ah
338
        out     0xA1, al
332
        out     0xA1, al
339
                                           ;remap IRQ
333
                                           ;remap IRQ
340
        stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
334
        stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
341
 
335
 
342
        mov     dx, 0x4d0                  ;8259 ELCR1
336
        mov     dx, 0x4d0                  ;8259 ELCR1
343
        in      al, dx
337
        in      al, dx
344
        bts     ax, IRQ_LINE
338
        bts     ax, IRQ_LINE
345
        out     dx, al                     ;set level-triggered mode
339
        out     dx, al                     ;set level-triggered mode
346
        mov     [ctrl.int_line], IRQ_LINE
340
        mov     [ctrl.int_line], IRQ_LINE
347
        popf
341
        popf
348
        mov     esi, msgRemap
342
        mov     esi, msgRemap
349
        invoke  SysMsgBoardStr
343
        invoke  SysMsgBoardStr
350
  end if
344
  end if
351
 
345
 
352
        mov     ebx, [ctrl.int_line]
346
        mov     ebx, [ctrl.int_line]
353
        invoke  AttachIntHandler, ebx, ac97_irq, 0
347
        invoke  AttachIntHandler, ebx, ac97_irq, 0
354
.reg:
348
.reg:
355
        invoke  RegService, sz_sound_srv, service_proc
349
        invoke  RegService, sz_sound_srv, service_proc
356
        ret
350
        ret
357
.fail:
351
.fail:
358
     if DEBUG
352
     if DEBUG
359
        mov     esi, msgFail
353
        mov     esi, msgFail
360
        invoke  SysMsgBoardStr
354
        invoke  SysMsgBoardStr
361
     end if
355
     end if
362
        xor     eax, eax
356
        xor     eax, eax
363
        ret
357
        ret
364
.fail_msg:
358
.fail_msg:
365
        invoke  SysMsgBoardStr
359
        invoke  SysMsgBoardStr
366
        xor     eax, eax
360
        xor     eax, eax
367
        ret
361
        ret
368
.stop:
362
.stop:
369
        call    stop
363
        call    stop
370
        xor     eax, eax
364
        xor     eax, eax
371
        ret
365
        ret
372
endp
366
endp
373
 
367
 
374
handle     equ  IOCTL.handle
368
handle     equ  IOCTL.handle
375
io_code    equ  IOCTL.io_code
369
io_code    equ  IOCTL.io_code
376
input      equ  IOCTL.input
370
input      equ  IOCTL.input
377
inp_size   equ  IOCTL.inp_size
371
inp_size   equ  IOCTL.inp_size
378
output     equ  IOCTL.output
372
output     equ  IOCTL.output
379
out_size   equ  IOCTL.out_size
373
out_size   equ  IOCTL.out_size
380
 
374
 
381
align 4
375
align 4
382
proc service_proc stdcall, ioctl:dword
376
proc service_proc stdcall, ioctl:dword
383
 
377
 
384
        mov     edi, [ioctl]
378
        mov     edi, [ioctl]
385
        mov     eax, [edi+io_code]
379
        mov     eax, [edi+io_code]
386
 
380
 
387
        cmp     eax, SRV_GETVERSION
381
        cmp     eax, SRV_GETVERSION
388
        jne     @F
382
        jne     @F
389
 
383
 
390
        mov     eax, [edi+output]
384
        mov     eax, [edi+output]
391
        cmp     [edi+out_size], 4
385
        cmp     [edi+out_size], 4
392
        jne     .fail
386
        jne     .fail
393
 
387
 
394
        mov     [eax], dword API_VERSION
388
        mov     [eax], dword API_VERSION
395
        xor     eax, eax
389
        xor     eax, eax
396
        ret
390
        ret
397
@@:
391
@@:
398
        cmp     eax, DEV_PLAY
392
        cmp     eax, DEV_PLAY
399
        jne     @F
393
        jne     @F
400
     if DEBUG
394
     if DEBUG
401
        mov     esi, msgPlay
395
        mov     esi, msgPlay
402
        invoke  SysMsgBoardStr
396
        invoke  SysMsgBoardStr
403
     end if
397
     end if
404
        call    play
398
        call    play
405
        ret
399
        ret
406
@@:
400
@@:
407
        cmp     eax, DEV_STOP
401
        cmp     eax, DEV_STOP
408
        jne     @F
402
        jne     @F
409
     if DEBUG
403
     if DEBUG
410
        mov     esi, msgStop
404
        mov     esi, msgStop
411
        invoke  SysMsgBoardStr
405
        invoke  SysMsgBoardStr
412
     end if
406
     end if
413
        call    stop
407
        call    stop
414
        ret
408
        ret
415
@@:
409
@@:
416
        cmp     eax, DEV_CALLBACK
410
        cmp     eax, DEV_CALLBACK
417
        jne     @F
411
        jne     @F
418
        mov     ebx, [edi+input]
412
        mov     ebx, [edi+input]
419
        stdcall set_callback, [ebx]
413
        stdcall set_callback, [ebx]
420
        ret
414
        ret
421
@@:
415
@@:
422
        cmp     eax, DEV_SET_MASTERVOL
416
        cmp     eax, DEV_SET_MASTERVOL
423
        jne     @F
417
        jne     @F
424
        mov     eax, [edi+input]
418
        mov     eax, [edi+input]
425
        mov     eax, [eax]
419
        mov     eax, [eax]
426
        call    set_master_vol      ;eax= vol
420
        call    set_master_vol      ;eax= vol
427
        ret
421
        ret
428
@@:
422
@@:
429
        cmp     eax, DEV_GET_MASTERVOL
423
        cmp     eax, DEV_GET_MASTERVOL
430
        jne     @F
424
        jne     @F
431
        mov     ebx, [edi+output]
425
        mov     ebx, [edi+output]
432
        stdcall get_master_vol, ebx
426
        stdcall get_master_vol, ebx
433
        ret
427
        ret
434
 
428
 
435
@@:
429
@@:
436
        cmp     eax, DEV_GET_POS
430
        cmp     eax, DEV_GET_POS
437
        jne     @F
431
        jne     @F
438
 
432
 
439
        mov     ebx, 8192
433
        mov     ebx, 8192
440
        mov     edx, 0x18
434
        mov     edx, 0x18
441
        xor     eax, eax
435
        xor     eax, eax
442
        call    [ctrl.ctrl_read16]
436
        call    [ctrl.ctrl_read16]
443
        sub     ebx, eax
437
        sub     ebx, eax
444
        shr     ebx, 1
438
        shr     ebx, 1
445
        mov     edx, [edi+output]
439
        mov     edx, [edi+output]
446
        mov     [edx], ebx
440
        mov     [edx], ebx
447
        xor     eax, eax
441
        xor     eax, eax
448
        ret
442
        ret
449
;@@:
443
;@@:
450
;           cmp eax, DEV_GET_INFO
444
;           cmp eax, DEV_GET_INFO
451
;           jne @F
445
;           jne @F
452
;           mov ebx, [edi+output]
446
;           mov ebx, [edi+output]
453
;           stdcall get_dev_info, ebx
447
;           stdcall get_dev_info, ebx
454
;           ret
448
;           ret
455
@@:
449
@@:
456
.fail:
450
.fail:
457
        or      eax, -1
451
        or      eax, -1
458
        ret
452
        ret
459
endp
453
endp
460
 
454
 
461
restore   handle
455
restore   handle
462
restore   io_code
456
restore   io_code
463
restore   input
457
restore   input
464
restore   inp_size
458
restore   inp_size
465
restore   output
459
restore   output
466
restore   out_size
460
restore   out_size
467
 
461
 
468
align 4
462
align 4
469
proc ac97_irq
463
proc ac97_irq
470
 
464
 
471
     if DEBUG_IRQ
465
     if DEBUG_IRQ
472
        mov     esi, msgIRQ
466
        mov     esi, msgIRQ
473
        invoke  SysMsgBoardStr
467
        invoke  SysMsgBoardStr
474
     end if
468
     end if
475
 
469
 
476
        mov     edx, CTRL_STAT
470
        mov     edx, CTRL_STAT
477
        call    [ctrl.ctrl_read32]
471
        call    [ctrl.ctrl_read32]
478
 
472
 
479
        cmp     eax, 0xffffffff
473
        cmp     eax, 0xffffffff
480
        je      .exit
474
        je      .exit
481
 
475
 
482
        test    eax, 0x40
476
        test    eax, 0x40
483
        jnz     .do_intr
477
        jnz     .do_intr
484
 
478
 
485
        test    eax, eax
479
        test    eax, eax
486
        jz      .exit
480
        jz      .exit
487
 
481
 
488
        mov     edx, CTRL_STAT
482
        mov     edx, CTRL_STAT
489
        call    [ctrl.ctrl_write32]
483
        call    [ctrl.ctrl_write32]
490
.exit:
484
.exit:
491
        xor     eax, eax
485
        xor     eax, eax
492
        ret
486
        ret
493
 
487
 
494
.do_intr:
488
.do_intr:
495
        push    eax
489
        push    eax
496
 
490
 
497
;        mov     edx, PCM_OUT_CR_REG
491
;        mov     edx, PCM_OUT_CR_REG
498
;        mov     al, 0x10;               0x10
492
;        mov     al, 0x10;               0x10
499
;        call    [ctrl.ctrl_write8]
493
;        call    [ctrl.ctrl_write8]
500
 
494
 
501
        mov     ax, 0x1c
495
        mov     ax, 0x1c
502
        mov     edx, PCM_OUT_SR_REG
496
        mov     edx, PCM_OUT_SR_REG
503
        call    [ctrl.ctrl_write16]
497
        call    [ctrl.ctrl_write16]
504
 
498
 
505
        mov     edx, PCM_OUT_CIV_REG
499
        mov     edx, PCM_OUT_CIV_REG
506
        call    [ctrl.ctrl_read8]
500
        call    [ctrl.ctrl_read8]
507
 
501
 
508
        and     eax, 0x1F
502
        and     eax, 0x1F
509
        cmp     eax, [civ_val]
503
        cmp     eax, [civ_val]
510
        je      .skip
504
        je      .skip
511
 
505
 
512
        mov     [civ_val], eax
506
        mov     [civ_val], eax
513
        dec     eax
507
        dec     eax
514
        and     eax, 0x1F
508
        and     eax, 0x1F
515
        mov     [ctrl.lvi_reg], eax
509
        mov     [ctrl.lvi_reg], eax
516
 
510
 
517
        mov     edx, PCM_OUT_LVI_REG
511
        mov     edx, PCM_OUT_LVI_REG
518
        call    [ctrl.ctrl_write8]
512
        call    [ctrl.ctrl_write8]
519
 
513
 
520
;        mov     edx, PCM_OUT_CR_REG
514
;        mov     edx, PCM_OUT_CR_REG
521
;        mov     ax, 0x11             ;0x1D
515
;        mov     ax, 0x11             ;0x1D
522
;        call    [ctrl.ctrl_write8]
516
;        call    [ctrl.ctrl_write8]
523
 
517
 
524
        cmp     [ctrl.user_callback], 0
518
        cmp     [ctrl.user_callback], 0
525
        je      .done
519
        je      .done
526
 
520
 
527
        mov     eax, [ctrl.lvi_reg]
521
        mov     eax, [ctrl.lvi_reg]
528
        stdcall [ctrl.user_callback], [buff_list+eax*4]
522
        stdcall [ctrl.user_callback], [buff_list+eax*4]
529
 
523
 
530
.done:
524
.done:
531
        pop     eax
525
        pop     eax
532
        and     eax, 0x40
526
        and     eax, 0x40
533
        mov     edx, CTRL_STAT
527
        mov     edx, CTRL_STAT
534
        call    [ctrl.ctrl_write32]
528
        call    [ctrl.ctrl_write32]
535
        or      eax, 1
529
        or      eax, 1
536
        ret
530
        ret
537
.skip:
531
.skip:
538
;        mov     edx, PCM_OUT_CR_REG
532
;        mov     edx, PCM_OUT_CR_REG
539
;        mov     ax, 0x11              ;0x1D
533
;        mov     ax, 0x11              ;0x1D
540
;        call    [ctrl.ctrl_write8]
534
;        call    [ctrl.ctrl_write8]
541
        jmp     .done
535
        jmp     .done
542
endp
536
endp
543
 
537
 
544
align 4
538
align 4
545
proc create_primary_buff
539
proc create_primary_buff
546
 
540
 
547
        invoke  KernelAlloc, 0x10000
541
        invoke  KernelAlloc, 0x10000
548
        mov     [ctrl.buffer], eax
542
        mov     [ctrl.buffer], eax
549
 
543
 
550
        mov     edi, eax
544
        mov     edi, eax
551
        mov     ecx, 0x10000/4
545
        mov     ecx, 0x10000/4
552
        xor     eax, eax
546
        xor     eax, eax
553
        cld
547
        cld
554
        rep stosd
548
        rep stosd
555
 
549
 
556
        mov     eax, [ctrl.buffer]
550
        mov     eax, [ctrl.buffer]
557
        invoke  GetPgAddr
551
        invoke  GetPgAddr
558
 
552
 
559
        mov     ebx, 0xC0002000
553
        mov     ebx, 0xC0002000
560
        mov     ecx, 4
554
        mov     ecx, 4
561
        mov     edi, pcmout_bdl
555
        mov     edi, pcmout_bdl
562
@@:
556
@@:
563
        mov     [edi], eax
557
        mov     [edi], eax
564
        mov     [edi+4], ebx
558
        mov     [edi+4], ebx
565
 
559
 
566
        mov     [edi+32], eax
560
        mov     [edi+32], eax
567
        mov     [edi+4+32], ebx
561
        mov     [edi+4+32], ebx
568
 
562
 
569
        mov     [edi+64], eax
563
        mov     [edi+64], eax
570
        mov     [edi+4+64], ebx
564
        mov     [edi+4+64], ebx
571
 
565
 
572
        mov     [edi+96], eax
566
        mov     [edi+96], eax
573
        mov     [edi+4+96], ebx
567
        mov     [edi+4+96], ebx
574
 
568
 
575
        mov     [edi+128], eax
569
        mov     [edi+128], eax
576
        mov     [edi+4+128], ebx
570
        mov     [edi+4+128], ebx
577
 
571
 
578
        mov     [edi+160], eax
572
        mov     [edi+160], eax
579
        mov     [edi+4+160], ebx
573
        mov     [edi+4+160], ebx
580
 
574
 
581
        mov     [edi+192], eax
575
        mov     [edi+192], eax
582
        mov     [edi+4+192], ebx
576
        mov     [edi+4+192], ebx
583
 
577
 
584
        mov     [edi+224], eax
578
        mov     [edi+224], eax
585
        mov     [edi+4+224], ebx
579
        mov     [edi+4+224], ebx
586
 
580
 
587
        add     eax, 0x4000
581
        add     eax, 0x4000
588
        add     edi, 8
582
        add     edi, 8
589
        loop    @B
583
        loop    @B
590
 
584
 
591
        mov     edi, buff_list
585
        mov     edi, buff_list
592
        mov     eax, [ctrl.buffer]
586
        mov     eax, [ctrl.buffer]
593
        mov     ecx, 4
587
        mov     ecx, 4
594
@@:
588
@@:
595
        mov     [edi], eax
589
        mov     [edi], eax
596
        mov     [edi+16], eax
590
        mov     [edi+16], eax
597
        mov     [edi+32], eax
591
        mov     [edi+32], eax
598
        mov     [edi+48], eax
592
        mov     [edi+48], eax
599
        mov     [edi+64], eax
593
        mov     [edi+64], eax
600
        mov     [edi+80], eax
594
        mov     [edi+80], eax
601
        mov     [edi+96], eax
595
        mov     [edi+96], eax
602
        mov     [edi+112], eax
596
        mov     [edi+112], eax
603
 
597
 
604
        add     eax, 0x4000
598
        add     eax, 0x4000
605
        add     edi, 4
599
        add     edi, 4
606
        loop    @B
600
        loop    @B
607
 
601
 
608
        mov     eax, pcmout_bdl
602
        mov     eax, pcmout_bdl
609
        mov     ebx, eax
603
        mov     ebx, eax
610
        invoke  GetPgAddr     ;eax
604
        invoke  GetPgAddr     ;eax
611
        and     ebx, 0xFFF
605
        and     ebx, 0xFFF
612
        add     eax, ebx
606
        add     eax, ebx
613
 
607
 
614
        mov     edx, PCM_OUT_BDL
608
        mov     edx, PCM_OUT_BDL
615
        call    [ctrl.ctrl_write32]
609
        call    [ctrl.ctrl_write32]
616
 
610
 
617
        mov     eax, 16
611
        mov     eax, 16
618
        mov     [ctrl.lvi_reg], eax
612
        mov     [ctrl.lvi_reg], eax
619
        mov     edx, PCM_OUT_LVI_REG
613
        mov     edx, PCM_OUT_LVI_REG
620
        call    [ctrl.ctrl_write8]
614
        call    [ctrl.ctrl_write8]
621
        ret
615
        ret
622
endp
616
endp
623
 
617
 
624
align 4
618
align 4
625
proc detect_controller
619
proc detect_controller
626
        push    ebx edi
620
        push    ebx edi
627
        invoke  GetPCIList
621
        invoke  GetPCIList
628
        mov     ebx, eax
622
        mov     ebx, eax
629
.next_dev:
623
.next_dev:
630
        mov     eax, [eax+PCIDEV.fd]
624
        mov     eax, [eax+PCIDEV.fd]
631
        cmp     eax, ebx
625
        cmp     eax, ebx
632
        jz      .not_found
626
        jz      .not_found
633
        mov     edx, [eax+PCIDEV.vendor_device_id]
627
        mov     edx, [eax+PCIDEV.vendor_device_id]
634
 
628
 
635
        mov     edi, devices
629
        mov     edi, devices
636
@@:
630
@@:
637
        cmp     dword [edi], 0
631
        cmp     dword [edi], 0
638
        jz      .next_dev
632
        jz      .next_dev
639
        cmp     edx, [edi]
633
        cmp     edx, [edi]
640
        jz      .found
634
        jz      .found
641
        add     edi, 12
635
        add     edi, 12
642
        jmp     @B
636
        jmp     @B
643
 
637
 
644
.not_found:
638
.not_found:
645
        xor     eax, eax
639
        xor     eax, eax
646
        pop     edi ebx
640
        pop     edi ebx
647
        ret
641
        ret
648
.found:
642
.found:
649
        movzx   ebx, [eax+PCIDEV.bus]
643
        movzx   ebx, [eax+PCIDEV.bus]
650
        mov     [ctrl.bus], ebx
644
        mov     [ctrl.bus], ebx
651
 
645
 
652
        movzx   ecx, [eax+PCIDEV.devfn]
646
        movzx   ecx, [eax+PCIDEV.devfn]
653
        mov     [ctrl.devfn], ecx
647
        mov     [ctrl.devfn], ecx
654
 
648
 
655
        mov     eax, edx
649
        mov     eax, edx
656
        and     edx, 0xFFFF
650
        and     edx, 0xFFFF
657
        mov     [ctrl.vendor], edx
651
        mov     [ctrl.vendor], edx
658
        shr     eax, 16
652
        shr     eax, 16
659
        mov     [ctrl.dev_id], eax
653
        mov     [ctrl.dev_id], eax
660
 
654
 
661
        mov     ebx, [edi+4]
655
        mov     ebx, [edi+4]
662
        mov     [ctrl.ctrl_ids], ebx
656
        mov     [ctrl.ctrl_ids], ebx
663
        mov     eax, [edi+8]
657
        mov     eax, [edi+8]
664
        mov     [ctrl.ctrl_setup], eax
658
        mov     [ctrl.ctrl_setup], eax
665
 
659
 
666
        cmp     edx, VID_INTEL
660
        cmp     edx, VID_INTEL
667
        jne     @F
661
        jne     @F
668
        mov     [ctrl.vendor_ids], msg_Intel
662
        mov     [ctrl.vendor_ids], msg_Intel
669
        pop     edi ebx
663
        pop     edi ebx
670
        ret
664
        ret
671
@@:
665
@@:
672
        cmp     edx, VID_NVIDIA
666
        cmp     edx, VID_NVIDIA
673
        jne     @F
667
        jne     @F
674
        mov     [ctrl.vendor_ids], msg_NVidia
668
        mov     [ctrl.vendor_ids], msg_NVidia
675
        pop     edi ebx
669
        pop     edi ebx
676
        ret
670
        ret
677
@@:
671
@@:
678
.err:
672
.err:
679
        xor     eax, eax
673
        xor     eax, eax
680
        mov     [ctrl.vendor_ids], eax    ;something  wrong ?
674
        mov     [ctrl.vendor_ids], eax    ;something  wrong ?
681
        pop     edi ebx
675
        pop     edi ebx
682
        ret
676
        ret
683
endp
677
endp
684
 
678
 
685
align 4
679
align 4
686
proc init_controller
680
proc init_controller
687
 
681
 
688
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 4
682
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 4
689
        mov     ebx, eax
683
        mov     ebx, eax
690
        and     eax, 0xFFFF
684
        and     eax, 0xFFFF
691
        mov     [ctrl.pci_cmd], eax
685
        mov     [ctrl.pci_cmd], eax
692
        shr     ebx, 16
686
        shr     ebx, 16
693
        mov     [ctrl.pci_stat], ebx
687
        mov     [ctrl.pci_stat], ebx
694
 
688
 
695
        mov     esi, msgPciCmd
689
        mov     esi, msgPciCmd
696
        invoke  SysMsgBoardStr
690
        invoke  SysMsgBoardStr
697
        call    dword2str
691
        call    dword2str
698
        invoke  SysMsgBoardStr
692
        invoke  SysMsgBoardStr
699
 
693
 
700
        mov     esi, msgPciStat
694
        mov     esi, msgPciStat
701
        invoke  SysMsgBoardStr
695
        invoke  SysMsgBoardStr
702
        mov     eax, [ctrl.pci_stat]
696
        mov     eax, [ctrl.pci_stat]
703
        call    dword2str
697
        call    dword2str
704
        invoke  SysMsgBoardStr
698
        invoke  SysMsgBoardStr
705
 
699
 
706
        mov     esi, msgMixIsaIo
700
        mov     esi, msgMixIsaIo
707
        invoke  SysMsgBoardStr
701
        invoke  SysMsgBoardStr
708
 
702
 
709
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
703
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
710
 
704
 
711
        call    dword2str
705
        call    dword2str
712
        invoke  SysMsgBoardStr
706
        invoke  SysMsgBoardStr
713
 
707
 
714
        and     eax, 0xFFFE
708
        and     eax, 0xFFFE
715
        mov     [ctrl.codec_io_base], eax
709
        mov     [ctrl.codec_io_base], eax
716
 
710
 
717
        mov     esi, msgCtrlIsaIo
711
        mov     esi, msgCtrlIsaIo
718
        invoke  SysMsgBoardStr
712
        invoke  SysMsgBoardStr
719
 
713
 
720
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x14
714
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x14
721
 
715
 
722
        call    dword2str
716
        call    dword2str
723
        invoke  SysMsgBoardStr
717
        invoke  SysMsgBoardStr
724
 
718
 
725
        and     eax, 0xFFC0
719
        and     eax, 0xFFC0
726
        mov     [ctrl.ctrl_io_base], eax
720
        mov     [ctrl.ctrl_io_base], eax
727
 
721
 
728
        mov     esi, msgMixMMIo
722
        mov     esi, msgMixMMIo
729
        invoke  SysMsgBoardStr
723
        invoke  SysMsgBoardStr
730
 
724
 
731
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x18
725
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x18
732
        mov     [ctrl.codec_mem_base], eax
726
        mov     [ctrl.codec_mem_base], eax
733
 
727
 
734
        call    dword2str
728
        call    dword2str
735
        invoke  SysMsgBoardStr
729
        invoke  SysMsgBoardStr
736
 
730
 
737
        mov     esi, msgCtrlMMIo
731
        mov     esi, msgCtrlMMIo
738
        invoke  SysMsgBoardStr
732
        invoke  SysMsgBoardStr
739
 
733
 
740
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x1C
734
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x1C
741
        mov     [ctrl.ctrl_mem_base], eax
735
        mov     [ctrl.ctrl_mem_base], eax
742
 
736
 
743
        call    dword2str
737
        call    dword2str
744
        invoke  SysMsgBoardStr
738
        invoke  SysMsgBoardStr
745
 
739
 
746
if 0
740
if 0
747
 
741
 
748
;;patch for some ugly BIOS  ICH-ICH5 compatible
742
;;patch for some ugly BIOS  ICH-ICH5 compatible
749
        cmp     [ctrl.vendor], VID_INTEL
743
        cmp     [ctrl.vendor], VID_INTEL
750
        jne     .default
744
        jne     .default
751
 
745
 
752
        mov     esi, msgIrqMap
746
        mov     esi, msgIrqMap
753
        invoke  SysMsgBoardStr
747
        invoke  SysMsgBoardStr
754
        invoke  PciRead8, 0, 0xF8, 0x61
748
        invoke  PciRead8, 0, 0xF8, 0x61
755
        and     eax, 0xFF
749
        and     eax, 0xFF
756
        call    dword2str
750
        call    dword2str
757
        invoke  SysMsgBoardStr
751
        invoke  SysMsgBoardStr
758
        btr     eax, 7                ;when bit 7 set remap disabled
752
        btr     eax, 7                ;when bit 7 set remap disabled
759
        jnc     @F
753
        jnc     @F
760
        xor     eax, eax
754
        xor     eax, eax
761
        jmp     @F
755
        jmp     @F
762
end if
756
end if
763
 
757
 
764
.default:
758
.default:
765
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x3C
759
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x3C
766
        and     eax, 0xFF
760
        and     eax, 0xFF
767
@@:
761
@@:
768
        mov     [ctrl.int_line], eax
762
        mov     [ctrl.int_line], eax
769
 
763
 
770
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], 0x41
764
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], 0x41
771
        and     eax, 0xFF
765
        and     eax, 0xFF
772
        mov     [ctrl.cfg_reg], eax
766
        mov     [ctrl.cfg_reg], eax
773
 
767
 
774
        mov     [ctrl.user_callback], 0
768
        mov     [ctrl.user_callback], 0
775
 
769
 
776
        call    [ctrl.ctrl_setup]
770
        call    [ctrl.ctrl_setup]
777
        xor     eax, eax
771
        xor     eax, eax
778
        inc     eax
772
        inc     eax
779
        ret
773
        ret
780
endp
774
endp
781
 
775
 
782
align 4
776
align 4
783
proc set_ICH
777
proc set_ICH
784
        mov     [ctrl.codec_read16], codec_io_r16    ;virtual
778
        mov     [ctrl.codec_read16], codec_io_r16    ;virtual
785
        mov     [ctrl.codec_write16], codec_io_w16   ;virtual
779
        mov     [ctrl.codec_write16], codec_io_w16   ;virtual
786
 
780
 
787
        mov     [ctrl.ctrl_read8 ], ctrl_io_r8       ;virtual
781
        mov     [ctrl.ctrl_read8 ], ctrl_io_r8       ;virtual
788
        mov     [ctrl.ctrl_read16], ctrl_io_r16      ;virtual
782
        mov     [ctrl.ctrl_read16], ctrl_io_r16      ;virtual
789
        mov     [ctrl.ctrl_read32], ctrl_io_r32      ;virtual
783
        mov     [ctrl.ctrl_read32], ctrl_io_r32      ;virtual
790
 
784
 
791
        mov     [ctrl.ctrl_write8 ], ctrl_io_w8      ;virtual
785
        mov     [ctrl.ctrl_write8 ], ctrl_io_w8      ;virtual
792
        mov     [ctrl.ctrl_write16], ctrl_io_w16     ;virtual
786
        mov     [ctrl.ctrl_write16], ctrl_io_w16     ;virtual
793
        mov     [ctrl.ctrl_write32], ctrl_io_w32     ;virtual
787
        mov     [ctrl.ctrl_write32], ctrl_io_w32     ;virtual
794
        ret
788
        ret
795
endp
789
endp
796
 
790
 
797
PG_SW            equ 0x003
791
PG_SW            equ 0x003
798
PG_NOCACHE       equ 0x018
792
PG_NOCACHE       equ 0x018
799
 
793
 
800
align 4
794
align 4
801
proc set_ICH4
795
proc set_ICH4
802
 
796
 
803
        invoke  MapIoMem, [ctrl.codec_mem_base], 0x1000, PG_SW+PG_NOCACHE
797
        invoke  MapIoMem, [ctrl.codec_mem_base], 0x1000, PG_SW+PG_NOCACHE
804
        mov     [ctrl.codec_mem_base], eax
798
        mov     [ctrl.codec_mem_base], eax
805
 
799
 
806
        invoke  MapIoMem, [ctrl.ctrl_mem_base], 0x1000, PG_SW+PG_NOCACHE
800
        invoke  MapIoMem, [ctrl.ctrl_mem_base], 0x1000, PG_SW+PG_NOCACHE
807
        mov     [ctrl.ctrl_mem_base], eax
801
        mov     [ctrl.ctrl_mem_base], eax
808
 
802
 
809
        mov     [ctrl.codec_read16], codec_mem_r16    ;virtual
803
        mov     [ctrl.codec_read16], codec_mem_r16    ;virtual
810
        mov     [ctrl.codec_write16], codec_mem_w16   ;virtual
804
        mov     [ctrl.codec_write16], codec_mem_w16   ;virtual
811
 
805
 
812
        mov     [ctrl.ctrl_read8 ], ctrl_mem_r8       ;virtual
806
        mov     [ctrl.ctrl_read8 ], ctrl_mem_r8       ;virtual
813
        mov     [ctrl.ctrl_read16], ctrl_mem_r16      ;virtual
807
        mov     [ctrl.ctrl_read16], ctrl_mem_r16      ;virtual
814
        mov     [ctrl.ctrl_read32], ctrl_mem_r32      ;virtual
808
        mov     [ctrl.ctrl_read32], ctrl_mem_r32      ;virtual
815
 
809
 
816
        mov     [ctrl.ctrl_write8 ], ctrl_mem_w8      ;virtual
810
        mov     [ctrl.ctrl_write8 ], ctrl_mem_w8      ;virtual
817
        mov     [ctrl.ctrl_write16], ctrl_mem_w16     ;virtual
811
        mov     [ctrl.ctrl_write16], ctrl_mem_w16     ;virtual
818
        mov     [ctrl.ctrl_write32], ctrl_mem_w32     ;virtual
812
        mov     [ctrl.ctrl_write32], ctrl_mem_w32     ;virtual
819
        ret
813
        ret
820
endp
814
endp
821
 
815
 
822
align 4
816
align 4
823
proc reset_controller
817
proc reset_controller
824
 
818
 
825
        xor     eax, eax
819
        xor     eax, eax
826
        mov     edx, PCM_IN_CR_REG
820
        mov     edx, PCM_IN_CR_REG
827
        call    [ctrl.ctrl_write8]
821
        call    [ctrl.ctrl_write8]
828
 
822
 
829
        mov     edx, PCM_OUT_CR_REG
823
        mov     edx, PCM_OUT_CR_REG
830
        call    [ctrl.ctrl_write8]
824
        call    [ctrl.ctrl_write8]
831
 
825
 
832
        mov     edx, MC_IN_CR_REG
826
        mov     edx, MC_IN_CR_REG
833
        call    [ctrl.ctrl_write8]
827
        call    [ctrl.ctrl_write8]
834
 
828
 
835
        mov     eax, RR
829
        mov     eax, RR
836
        mov     edx, PCM_IN_CR_REG
830
        mov     edx, PCM_IN_CR_REG
837
        call    [ctrl.ctrl_write8]
831
        call    [ctrl.ctrl_write8]
838
 
832
 
839
        mov     edx, PCM_OUT_CR_REG
833
        mov     edx, PCM_OUT_CR_REG
840
        call    [ctrl.ctrl_write8]
834
        call    [ctrl.ctrl_write8]
841
 
835
 
842
        mov     edx, MC_IN_CR_REG
836
        mov     edx, MC_IN_CR_REG
843
        call    [ctrl.ctrl_write8]
837
        call    [ctrl.ctrl_write8]
844
        ret
838
        ret
845
endp
839
endp
846
 
840
 
847
align 4
841
align 4
848
proc init_codec
842
proc init_codec
849
           locals
843
           locals
850
             counter dd ?
844
             counter dd ?
851
           endl
845
           endl
852
 
846
 
853
        mov     esi, msgControl
847
        mov     esi, msgControl
854
        invoke  SysMsgBoardStr
848
        invoke  SysMsgBoardStr
855
 
849
 
856
        mov     edx, GLOB_CTRL
850
        mov     edx, GLOB_CTRL
857
        call    [ctrl.ctrl_read32]
851
        call    [ctrl.ctrl_read32]
858
        call    dword2str
852
        call    dword2str
859
        invoke  SysMsgBoardStr
853
        invoke  SysMsgBoardStr
860
 
854
 
861
        mov     esi, msgStatus
855
        mov     esi, msgStatus
862
        invoke  SysMsgBoardStr
856
        invoke  SysMsgBoardStr
863
 
857
 
864
        mov     edx, CTRL_STAT
858
        mov     edx, CTRL_STAT
865
        call    [ctrl.ctrl_read32]
859
        call    [ctrl.ctrl_read32]
866
        push    eax
860
        push    eax
867
        call    dword2str
861
        call    dword2str
868
        invoke  SysMsgBoardStr
862
        invoke  SysMsgBoardStr
869
        pop     eax
863
        pop     eax
870
        cmp     eax, 0xFFFFFFFF
864
        cmp     eax, 0xFFFFFFFF
871
        je      .err
865
        je      .err
872
 
866
 
873
        test    eax, CTRL_ST_CREADY
867
        test    eax, CTRL_ST_CREADY
874
        jnz     .ready
868
        jnz     .ready
875
 
869
 
876
        call    reset_codec
870
        call    reset_codec
877
        test    eax, eax
871
        test    eax, eax
878
        jz      .err
872
        jz      .err
879
 
873
 
880
.ready:
874
.ready:
881
        xor     edx, edx    ;ac_reg_0
875
        xor     edx, edx    ;ac_reg_0
882
        call    [ctrl.codec_write16]
876
        call    [ctrl.codec_write16]
883
 
877
 
884
        xor     eax, eax
878
        xor     eax, eax
885
        mov     edx, CODEC_REG_POWERDOWN
879
        mov     edx, CODEC_REG_POWERDOWN
886
        call    [ctrl.codec_write16]
880
        call    [ctrl.codec_write16]
887
 
881
 
888
        mov     [counter], 200    ; total 200*5 ms = 1s
882
        mov     [counter], 200    ; total 200*5 ms = 1s
889
.wait:
883
.wait:
890
        mov     eax, 5000  ; wait 5 ms
884
        mov     eax, 5000  ; wait 5 ms
891
        call    StallExec
885
        call    StallExec
892
 
886
 
893
        mov     edx, CODEC_REG_POWERDOWN
887
        mov     edx, CODEC_REG_POWERDOWN
894
        call    [ctrl.codec_read16]
888
        call    [ctrl.codec_read16]
895
        and     eax, 0x0F
889
        and     eax, 0x0F
896
        cmp     eax, 0x0F
890
        cmp     eax, 0x0F
897
        jz      .done
891
        jz      .done
898
 
892
 
899
        sub     [counter] , 1
893
        sub     [counter] , 1
900
        jnz     .wait
894
        jnz     .wait
901
.err:
895
.err:
902
        xor     eax, eax       ; timeout error
896
        xor     eax, eax       ; timeout error
903
        ret
897
        ret
904
.done:
898
.done:
905
        mov     eax, 2     ;force set 16-bit 2-channel PCM
899
        mov     eax, 2     ;force set 16-bit 2-channel PCM
906
        mov     edx, GLOB_CTRL
900
        mov     edx, GLOB_CTRL
907
        call    [ctrl.ctrl_write32]
901
        call    [ctrl.ctrl_write32]
908
        mov     eax, 5000  ; wait 5 ms
902
        mov     eax, 5000  ; wait 5 ms
909
        call    StallExec
903
        call    StallExec
910
 
904
 
911
        call    detect_codec
905
        call    detect_codec
912
 
906
 
913
        xor     eax, eax
907
        xor     eax, eax
914
        inc     eax
908
        inc     eax
915
        ret
909
        ret
916
endp
910
endp
917
 
911
 
918
align 4
912
align 4
919
proc reset_codec
913
proc reset_codec
920
        mov     edx, GLOB_CTRL
914
        mov     edx, GLOB_CTRL
921
        call    [ctrl.ctrl_read32]
915
        call    [ctrl.ctrl_read32]
922
 
916
 
923
        test    eax, 0x02
917
        test    eax, 0x02
924
        jz      .cold
918
        jz      .cold
925
 
919
 
926
        call    warm_reset
920
        call    warm_reset
927
        jnc     .ok
921
        jnc     .ok
928
.cold:
922
.cold:
929
        call    cold_reset
923
        call    cold_reset
930
        jnc     .ok
924
        jnc     .ok
931
 
925
 
932
     if DEBUG
926
     if DEBUG
933
        mov     esi, msgCFail
927
        mov     esi, msgCFail
934
        invoke  SysMsgBoardStr
928
        invoke  SysMsgBoardStr
935
           end if
929
           end if
936
        xor     eax, eax    ; timeout error
930
        xor     eax, eax    ; timeout error
937
        ret
931
        ret
938
.ok:
932
.ok:
939
     if DEBUG
933
     if DEBUG
940
        mov     esi, msgResetOk
934
        mov     esi, msgResetOk
941
        invoke  SysMsgBoardStr
935
        invoke  SysMsgBoardStr
942
     end if
936
     end if
943
 
937
 
944
        xor     eax, eax
938
        xor     eax, eax
945
        inc     eax
939
        inc     eax
946
        ret
940
        ret
947
endp
941
endp
948
 
942
 
949
align 4
943
align 4
950
proc warm_reset
944
proc warm_reset
951
           locals
945
           locals
952
             counter dd ?
946
             counter dd ?
953
           endl
947
           endl
954
 
948
 
955
        mov     eax, 0x06
949
        mov     eax, 0x06
956
        mov     edx, GLOB_CTRL
950
        mov     edx, GLOB_CTRL
957
        call    [ctrl.ctrl_write32]
951
        call    [ctrl.ctrl_write32]
958
 
952
 
959
     if DEBUG
953
     if DEBUG
960
        mov     esi, msgWarm
954
        mov     esi, msgWarm
961
        invoke  SysMsgBoardStr
955
        invoke  SysMsgBoardStr
962
     end if
956
     end if
963
 
957
 
964
        mov     [counter], 10   ; total 10*100 ms = 1s
958
        mov     [counter], 10   ; total 10*100 ms = 1s
965
.wait:
959
.wait:
966
        mov     eax, 100000   ; wait 100 ms
960
        mov     eax, 100000   ; wait 100 ms
967
        call    StallExec
961
        call    StallExec
968
 
962
 
969
        mov     edx, CTRL_STAT
963
        mov     edx, CTRL_STAT
970
        call    [ctrl.ctrl_read32]
964
        call    [ctrl.ctrl_read32]
971
        test    eax, CTRL_ST_CREADY
965
        test    eax, CTRL_ST_CREADY
972
        jnz     .ok
966
        jnz     .ok
973
 
967
 
974
        dec     [counter]
968
        dec     [counter]
975
        jnz     .wait
969
        jnz     .wait
976
 
970
 
977
     if DEBUG
971
     if DEBUG
978
        mov     esi, msgWRFail
972
        mov     esi, msgWRFail
979
        invoke  SysMsgBoardStr
973
        invoke  SysMsgBoardStr
980
     end if
974
     end if
981
.fail:
975
.fail:
982
        stc
976
        stc
983
        ret
977
        ret
984
.ok:
978
.ok:
985
        clc
979
        clc
986
        ret
980
        ret
987
endp
981
endp
988
 
982
 
989
align 4
983
align 4
990
proc cold_reset
984
proc cold_reset
991
           locals
985
           locals
992
             counter dd ?
986
             counter dd ?
993
           endl
987
           endl
994
 
988
 
995
        mov     eax, 0x02
989
        mov     eax, 0x02
996
        mov     edx, GLOB_CTRL
990
        mov     edx, GLOB_CTRL
997
        call    [ctrl.ctrl_write32]
991
        call    [ctrl.ctrl_write32]
998
 
992
 
999
     if DEBUG
993
     if DEBUG
1000
        mov     esi, msgCold
994
        mov     esi, msgCold
1001
        invoke  SysMsgBoardStr
995
        invoke  SysMsgBoardStr
1002
     end if
996
     end if
1003
 
997
 
1004
        mov     eax, 400000    ; wait 400 ms
998
        mov     eax, 400000    ; wait 400 ms
1005
        call    StallExec
999
        call    StallExec
1006
 
1000
 
1007
        mov     [counter], 16   ; total 20*100 ms = 2s
1001
        mov     [counter], 16   ; total 20*100 ms = 2s
1008
.wait:
1002
.wait:
1009
 
1003
 
1010
        mov     edx, CTRL_STAT
1004
        mov     edx, CTRL_STAT
1011
        call    [ctrl.ctrl_read32]
1005
        call    [ctrl.ctrl_read32]
1012
        test    eax, CTRL_ST_CREADY
1006
        test    eax, CTRL_ST_CREADY
1013
        jnz     .ok
1007
        jnz     .ok
1014
 
1008
 
1015
        mov     eax, 100000   ; wait 100 ms
1009
        mov     eax, 100000   ; wait 100 ms
1016
        call    StallExec
1010
        call    StallExec
1017
 
1011
 
1018
        dec     [counter]
1012
        dec     [counter]
1019
        jnz     .wait
1013
        jnz     .wait
1020
 
1014
 
1021
     if DEBUG
1015
     if DEBUG
1022
        mov     esi, msgCRFail
1016
        mov     esi, msgCRFail
1023
        invoke  SysMsgBoardStr
1017
        invoke  SysMsgBoardStr
1024
     end if
1018
     end if
1025
 
1019
 
1026
.fail:
1020
.fail:
1027
        stc
1021
        stc
1028
        ret
1022
        ret
1029
.ok:
1023
.ok:
1030
        mov     esi, msgControl
1024
        mov     esi, msgControl
1031
        invoke  SysMsgBoardStr
1025
        invoke  SysMsgBoardStr
1032
 
1026
 
1033
        mov     edx, GLOB_CTRL
1027
        mov     edx, GLOB_CTRL
1034
        call    [ctrl.ctrl_read32]
1028
        call    [ctrl.ctrl_read32]
1035
        call    dword2str
1029
        call    dword2str
1036
        invoke  SysMsgBoardStr
1030
        invoke  SysMsgBoardStr
1037
 
1031
 
1038
        mov     esi, msgStatus
1032
        mov     esi, msgStatus
1039
        invoke  SysMsgBoardStr
1033
        invoke  SysMsgBoardStr
1040
 
1034
 
1041
        mov     edx, CTRL_STAT
1035
        mov     edx, CTRL_STAT
1042
        call    [ctrl.ctrl_read32]
1036
        call    [ctrl.ctrl_read32]
1043
        push    eax
1037
        push    eax
1044
        call    dword2str
1038
        call    dword2str
1045
        invoke  SysMsgBoardStr
1039
        invoke  SysMsgBoardStr
1046
        pop     eax
1040
        pop     eax
1047
 
1041
 
1048
        test    eax, CTRL_ST_CREADY
1042
        test    eax, CTRL_ST_CREADY
1049
        jz      .fail
1043
        jz      .fail
1050
        clc
1044
        clc
1051
        ret
1045
        ret
1052
endp
1046
endp
1053
 
1047
 
1054
align 4
1048
align 4
1055
play:
1049
play:
1056
        mov     eax, 16
1050
        mov     eax, 16
1057
        mov     [ctrl.lvi_reg], eax
1051
        mov     [ctrl.lvi_reg], eax
1058
        mov     edx, PCM_OUT_LVI_REG
1052
        mov     edx, PCM_OUT_LVI_REG
1059
        call    [ctrl.ctrl_write8]
1053
        call    [ctrl.ctrl_write8]
1060
 
1054
 
1061
        mov     edx, PCM_OUT_CR_REG
1055
        mov     edx, PCM_OUT_CR_REG
1062
        mov     ax, 0x1D
1056
        mov     ax, 0x1D
1063
        call    [ctrl.ctrl_write8]
1057
        call    [ctrl.ctrl_write8]
1064
        xor     eax, eax
1058
        xor     eax, eax
1065
        ret
1059
        ret
1066
 
1060
 
1067
align 4
1061
align 4
1068
stop:
1062
stop:
1069
        mov     edx, PCM_OUT_CR_REG
1063
        mov     edx, PCM_OUT_CR_REG
1070
        mov     ax, 0x0
1064
        mov     ax, 0x0
1071
        call    [ctrl.ctrl_write8]
1065
        call    [ctrl.ctrl_write8]
1072
 
1066
 
1073
        mov     ax, 0x1c
1067
        mov     ax, 0x1c
1074
        mov     edx, PCM_OUT_SR_REG
1068
        mov     edx, PCM_OUT_SR_REG
1075
        call    [ctrl.ctrl_write16]
1069
        call    [ctrl.ctrl_write16]
1076
        xor     eax, eax
1070
        xor     eax, eax
1077
        ret
1071
        ret
1078
 
1072
 
1079
align 4
1073
align 4
1080
proc get_dev_info stdcall, p_info:dword
1074
proc get_dev_info stdcall, p_info:dword
1081
           virtual at esi
1075
           virtual at esi
1082
             CTRL_INFO CTRL_INFO
1076
             CTRL_INFO CTRL_INFO
1083
           end virtual
1077
           end virtual
1084
 
1078
 
1085
        mov     esi, [p_info]
1079
        mov     esi, [p_info]
1086
        mov     eax, [ctrl.int_line]
1080
        mov     eax, [ctrl.int_line]
1087
        mov     ebx, [ctrl.codec_io_base]
1081
        mov     ebx, [ctrl.codec_io_base]
1088
        mov     ecx, [ctrl.ctrl_io_base]
1082
        mov     ecx, [ctrl.ctrl_io_base]
1089
        mov     edx, [ctrl.codec_mem_base]
1083
        mov     edx, [ctrl.codec_mem_base]
1090
        mov     edi, [ctrl.ctrl_mem_base]
1084
        mov     edi, [ctrl.ctrl_mem_base]
1091
 
1085
 
1092
        mov     [CTRL_INFO.irq], eax
1086
        mov     [CTRL_INFO.irq], eax
1093
        mov     [CTRL_INFO.codec_io_base], ebx
1087
        mov     [CTRL_INFO.codec_io_base], ebx
1094
        mov     [CTRL_INFO.ctrl_io_base], ecx
1088
        mov     [CTRL_INFO.ctrl_io_base], ecx
1095
        mov     [CTRL_INFO.codec_mem_base], edx
1089
        mov     [CTRL_INFO.codec_mem_base], edx
1096
        mov     [CTRL_INFO.ctrl_mem_base], edi
1090
        mov     [CTRL_INFO.ctrl_mem_base], edi
1097
 
1091
 
1098
        mov     eax, [codec.chip_id]
1092
        mov     eax, [codec.chip_id]
1099
        mov     [CTRL_INFO.codec_id], eax
1093
        mov     [CTRL_INFO.codec_id], eax
1100
 
1094
 
1101
        mov     edx, GLOB_CTRL
1095
        mov     edx, GLOB_CTRL
1102
        call    [ctrl.ctrl_read32]
1096
        call    [ctrl.ctrl_read32]
1103
        mov     [CTRL_INFO.glob_cntrl], eax
1097
        mov     [CTRL_INFO.glob_cntrl], eax
1104
 
1098
 
1105
        mov     edx, CTRL_STAT
1099
        mov     edx, CTRL_STAT
1106
        call    [ctrl.ctrl_read32]
1100
        call    [ctrl.ctrl_read32]
1107
        mov     [CTRL_INFO.glob_sta], eax
1101
        mov     [CTRL_INFO.glob_sta], eax
1108
 
1102
 
1109
        mov     ebx, [ctrl.pci_cmd]
1103
        mov     ebx, [ctrl.pci_cmd]
1110
        mov     [CTRL_INFO.pci_cmd], ebx
1104
        mov     [CTRL_INFO.pci_cmd], ebx
1111
        ret
1105
        ret
1112
endp
1106
endp
1113
 
1107
 
1114
align 4
1108
align 4
1115
proc set_callback stdcall, handler:dword
1109
proc set_callback stdcall, handler:dword
1116
        mov     eax, [handler]
1110
        mov     eax, [handler]
1117
        mov     [ctrl.user_callback], eax
1111
        mov     [ctrl.user_callback], eax
1118
        ret
1112
        ret
1119
endp
1113
endp
1120
 
1114
 
1121
align 4
1115
align 4
1122
proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
1116
proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
1123
 
1117
 
1124
        mov     edx, [ac_reg]
1118
        mov     edx, [ac_reg]
1125
 
1119
 
1126
        mov     ebx, edx
1120
        mov     ebx, edx
1127
        shr     ebx, 1
1121
        shr     ebx, 1
1128
        bt      [codec.shadow_flag], ebx
1122
        bt      [codec.shadow_flag], ebx
1129
        jc      .use_shadow
1123
        jc      .use_shadow
1130
 
1124
 
1131
        call    [ctrl.codec_read16]  ;change edx !!!
1125
        call    [ctrl.codec_read16]  ;change edx !!!
1132
        mov     ecx, eax
1126
        mov     ecx, eax
1133
 
1127
 
1134
        mov     edx, CTRL_STAT
1128
        mov     edx, CTRL_STAT
1135
        call    [ctrl.ctrl_read32]
1129
        call    [ctrl.ctrl_read32]
1136
        test    eax, CTRL_ST_RCS
1130
        test    eax, CTRL_ST_RCS
1137
        jz      .read_ok
1131
        jz      .read_ok
1138
 
1132
 
1139
        mov     edx, CTRL_STAT
1133
        mov     edx, CTRL_STAT
1140
        call    [ctrl.ctrl_write32]
1134
        call    [ctrl.ctrl_write32]
1141
        xor     eax, eax
1135
        xor     eax, eax
1142
        not     eax ;timeout
1136
        not     eax ;timeout
1143
        ret
1137
        ret
1144
.read_ok:
1138
.read_ok:
1145
        mov     edx, [ac_reg]
1139
        mov     edx, [ac_reg]
1146
        mov     [codec.regs+edx], cx
1140
        mov     [codec.regs+edx], cx
1147
        bts     [codec.shadow_flag], ebx
1141
        bts     [codec.shadow_flag], ebx
1148
        mov     eax, ecx
1142
        mov     eax, ecx
1149
        ret
1143
        ret
1150
.use_shadow:
1144
.use_shadow:
1151
        movzx   eax, word [codec.regs+edx]
1145
        movzx   eax, word [codec.regs+edx]
1152
        ret
1146
        ret
1153
endp
1147
endp
1154
 
1148
 
1155
align 4
1149
align 4
1156
proc codec_write stdcall, ac_reg:dword
1150
proc codec_write stdcall, ac_reg:dword
1157
        push    eax
1151
        push    eax
1158
        call    check_semafore
1152
        call    check_semafore
1159
        and     eax, eax
1153
        and     eax, eax
1160
        jz      .err
1154
        jz      .err
1161
        pop     eax
1155
        pop     eax
1162
 
1156
 
1163
        mov     esi, [ac_reg]
1157
        mov     esi, [ac_reg]
1164
        mov     edx, esi
1158
        mov     edx, esi
1165
        call    [ctrl.codec_write16]
1159
        call    [ctrl.codec_write16]
1166
        mov     [codec.regs+esi], ax
1160
        mov     [codec.regs+esi], ax
1167
        shr     esi, 1
1161
        shr     esi, 1
1168
        bts     [codec.shadow_flag], esi
1162
        bts     [codec.shadow_flag], esi
1169
        ret
1163
        ret
1170
.err:
1164
.err:
1171
        pop     eax
1165
        pop     eax
1172
        ret
1166
        ret
1173
endp
1167
endp
1174
 
1168
 
1175
align 4
1169
align 4
1176
proc codec_check_ready
1170
proc codec_check_ready
1177
 
1171
 
1178
        mov     edx, CTRL_ST
1172
        mov     edx, CTRL_ST
1179
        call    [ctrl.ctrl_read32]
1173
        call    [ctrl.ctrl_read32]
1180
        and     eax, CTRL_ST_CREADY
1174
        and     eax, CTRL_ST_CREADY
1181
        jz      .not_ready
1175
        jz      .not_ready
1182
 
1176
 
1183
        xor     eax, wax
1177
        xor     eax, wax
1184
        inc     eax
1178
        inc     eax
1185
        ret
1179
        ret
1186
.not_ready:
1180
.not_ready:
1187
        xor     eax, eax
1181
        xor     eax, eax
1188
        ret
1182
        ret
1189
endp
1183
endp
1190
 
1184
 
1191
align 4
1185
align 4
1192
proc check_semafore
1186
proc check_semafore
1193
           local counter:DWORD
1187
           local counter:DWORD
1194
 
1188
 
1195
        mov     [counter], 100
1189
        mov     [counter], 100
1196
.l1:
1190
.l1:
1197
        mov     edx, CTRL_CAS
1191
        mov     edx, CTRL_CAS
1198
        call    [ctrl.ctrl_read8]
1192
        call    [ctrl.ctrl_read8]
1199
        and     eax, CAS_FLAG
1193
        and     eax, CAS_FLAG
1200
        jz      .ok
1194
        jz      .ok
1201
 
1195
 
1202
        mov     eax, 1
1196
        mov     eax, 1
1203
        call    StallExec
1197
        call    StallExec
1204
        sub     [counter], 1
1198
        sub     [counter], 1
1205
        jnz     .l1
1199
        jnz     .l1
1206
        xor     eax, eax
1200
        xor     eax, eax
1207
        ret
1201
        ret
1208
align 4
1202
align 4
1209
.ok:
1203
.ok:
1210
        xor     eax, eax
1204
        xor     eax, eax
1211
        inc     eax
1205
        inc     eax
1212
        ret
1206
        ret
1213
endp
1207
endp
1214
 
1208
 
1215
align 4
1209
align 4
1216
proc StallExec
1210
proc StallExec
1217
        push    ecx
1211
        push    ecx
1218
        push    edx
1212
        push    edx
1219
        push    ebx
1213
        push    ebx
1220
        push    eax
1214
        push    eax
1221
 
1215
 
1222
        mov     ecx, CPU_FREQ
1216
        mov     ecx, CPU_FREQ
1223
        mul     ecx
1217
        mul     ecx
1224
        mov     ebx, eax      ;low
1218
        mov     ebx, eax      ;low
1225
        mov     ecx, edx      ;high
1219
        mov     ecx, edx      ;high
1226
        rdtsc
1220
        rdtsc
1227
        add     ebx, eax
1221
        add     ebx, eax
1228
        adc     ecx, edx
1222
        adc     ecx, edx
1229
@@:
1223
@@:
1230
        rdtsc
1224
        rdtsc
1231
        sub     eax, ebx
1225
        sub     eax, ebx
1232
        sbb     edx, ecx
1226
        sbb     edx, ecx
1233
        js      @B
1227
        js      @B
1234
 
1228
 
1235
        pop     eax
1229
        pop     eax
1236
        pop     ebx
1230
        pop     ebx
1237
        pop     edx
1231
        pop     edx
1238
        pop     ecx
1232
        pop     ecx
1239
        ret
1233
        ret
1240
endp
1234
endp
1241
 
1235
 
1242
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1236
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1243
;          CONTROLLER IO functions
1237
;          CONTROLLER IO functions
1244
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1238
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1245
 
1239
 
1246
align 4
1240
align 4
1247
proc codec_io_r16
1241
proc codec_io_r16
1248
        add     edx, [ctrl.codec_io_base]
1242
        add     edx, [ctrl.codec_io_base]
1249
        in      ax, dx
1243
        in      ax, dx
1250
        ret
1244
        ret
1251
endp
1245
endp
1252
 
1246
 
1253
align 4
1247
align 4
1254
proc codec_io_w16
1248
proc codec_io_w16
1255
        add     edx, [ctrl.codec_io_base]
1249
        add     edx, [ctrl.codec_io_base]
1256
        out     dx, ax
1250
        out     dx, ax
1257
        ret
1251
        ret
1258
endp
1252
endp
1259
 
1253
 
1260
align 4
1254
align 4
1261
proc ctrl_io_r8
1255
proc ctrl_io_r8
1262
        add     edx, [ctrl.ctrl_io_base]
1256
        add     edx, [ctrl.ctrl_io_base]
1263
        in      al, dx
1257
        in      al, dx
1264
        ret
1258
        ret
1265
endp
1259
endp
1266
 
1260
 
1267
align 4
1261
align 4
1268
proc ctrl_io_r16
1262
proc ctrl_io_r16
1269
        add     edx, [ctrl.ctrl_io_base]
1263
        add     edx, [ctrl.ctrl_io_base]
1270
        in      ax, dx
1264
        in      ax, dx
1271
        ret
1265
        ret
1272
endp
1266
endp
1273
 
1267
 
1274
align 4
1268
align 4
1275
proc ctrl_io_r32
1269
proc ctrl_io_r32
1276
        add     edx, [ctrl.ctrl_io_base]
1270
        add     edx, [ctrl.ctrl_io_base]
1277
        in      eax, dx
1271
        in      eax, dx
1278
        ret
1272
        ret
1279
endp
1273
endp
1280
 
1274
 
1281
align 4
1275
align 4
1282
proc ctrl_io_w8
1276
proc ctrl_io_w8
1283
        add     edx, [ctrl.ctrl_io_base]
1277
        add     edx, [ctrl.ctrl_io_base]
1284
        out     dx, al
1278
        out     dx, al
1285
        ret
1279
        ret
1286
endp
1280
endp
1287
 
1281
 
1288
align 4
1282
align 4
1289
proc ctrl_io_w16
1283
proc ctrl_io_w16
1290
        add     edx, [ctrl.ctrl_io_base]
1284
        add     edx, [ctrl.ctrl_io_base]
1291
        out     dx, ax
1285
        out     dx, ax
1292
        ret
1286
        ret
1293
endp
1287
endp
1294
 
1288
 
1295
align 4
1289
align 4
1296
proc ctrl_io_w32
1290
proc ctrl_io_w32
1297
        add     edx, [ctrl.ctrl_io_base]
1291
        add     edx, [ctrl.ctrl_io_base]
1298
        out     dx, eax
1292
        out     dx, eax
1299
        ret
1293
        ret
1300
endp
1294
endp
1301
 
1295
 
1302
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1296
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1303
;         MEMORY MAPPED IO    (os depended)
1297
;         MEMORY MAPPED IO    (os depended)
1304
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1298
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1305
 
1299
 
1306
align 4
1300
align 4
1307
proc codec_mem_r16
1301
proc codec_mem_r16
1308
        add     edx, [ctrl.codec_mem_base]
1302
        add     edx, [ctrl.codec_mem_base]
1309
        mov     ax, word [edx]
1303
        mov     ax, word [edx]
1310
        ret
1304
        ret
1311
endp
1305
endp
1312
 
1306
 
1313
align 4
1307
align 4
1314
proc codec_mem_w16
1308
proc codec_mem_w16
1315
        add     edx, [ctrl.codec_mem_base]
1309
        add     edx, [ctrl.codec_mem_base]
1316
        mov     word [edx], ax
1310
        mov     word [edx], ax
1317
        ret
1311
        ret
1318
endp
1312
endp
1319
 
1313
 
1320
align 4
1314
align 4
1321
proc ctrl_mem_r8
1315
proc ctrl_mem_r8
1322
        add     edx, [ctrl.ctrl_mem_base]
1316
        add     edx, [ctrl.ctrl_mem_base]
1323
        mov     al, [edx]
1317
        mov     al, [edx]
1324
        ret
1318
        ret
1325
endp
1319
endp
1326
 
1320
 
1327
align 4
1321
align 4
1328
proc ctrl_mem_r16
1322
proc ctrl_mem_r16
1329
        add     edx, [ctrl.ctrl_mem_base]
1323
        add     edx, [ctrl.ctrl_mem_base]
1330
        mov     ax, [edx]
1324
        mov     ax, [edx]
1331
        ret
1325
        ret
1332
endp
1326
endp
1333
 
1327
 
1334
align 4
1328
align 4
1335
proc ctrl_mem_r32
1329
proc ctrl_mem_r32
1336
        add     edx, [ctrl.ctrl_mem_base]
1330
        add     edx, [ctrl.ctrl_mem_base]
1337
        mov     eax, [edx]
1331
        mov     eax, [edx]
1338
        ret
1332
        ret
1339
endp
1333
endp
1340
 
1334
 
1341
align 4
1335
align 4
1342
proc ctrl_mem_w8
1336
proc ctrl_mem_w8
1343
        add     edx, [ctrl.ctrl_mem_base]
1337
        add     edx, [ctrl.ctrl_mem_base]
1344
        mov     [edx], al
1338
        mov     [edx], al
1345
        ret
1339
        ret
1346
endp
1340
endp
1347
 
1341
 
1348
align 4
1342
align 4
1349
proc ctrl_mem_w16
1343
proc ctrl_mem_w16
1350
        add     edx, [ctrl.ctrl_mem_base]
1344
        add     edx, [ctrl.ctrl_mem_base]
1351
        mov     [edx], ax
1345
        mov     [edx], ax
1352
        ret
1346
        ret
1353
endp
1347
endp
1354
 
1348
 
1355
align 4
1349
align 4
1356
proc ctrl_mem_w32
1350
proc ctrl_mem_w32
1357
        add     edx, [ctrl.ctrl_mem_base]
1351
        add     edx, [ctrl.ctrl_mem_base]
1358
        mov     [edx], eax
1352
        mov     [edx], eax
1359
        ret
1353
        ret
1360
endp
1354
endp
1361
 
1355
 
1362
align 4
1356
align 4
1363
dword2str:
1357
dword2str:
1364
        mov     esi, hex_buff
1358
        mov     esi, hex_buff
1365
        mov     ecx, -8
1359
        mov     ecx, -8
1366
@@:
1360
@@:
1367
        rol     eax, 4
1361
        rol     eax, 4
1368
        mov     ebx, eax
1362
        mov     ebx, eax
1369
        and     ebx, 0x0F
1363
        and     ebx, 0x0F
1370
        mov     bl, [ebx+hexletters]
1364
        mov     bl, [ebx+hexletters]
1371
        mov     [8+esi+ecx], bl
1365
        mov     [8+esi+ecx], bl
1372
        inc     ecx
1366
        inc     ecx
1373
        jnz     @B
1367
        jnz     @B
1374
        ret
1368
        ret
1375
 
1369
 
1376
hexletters   db '0123456789ABCDEF'
1370
hexletters   db '0123456789ABCDEF'
1377
hex_buff     db 8 dup(0),13,10,0
1371
hex_buff     db 8 dup(0),13,10,0
1378
 
1372
 
1379
 
1373
 
1380
include "codec.inc"
1374
include "codec.inc"
1381
 
1375
 
1382
align 4
1376
align 4
1383
devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
1377
devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
1384
        dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
1378
        dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
1385
        dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
1379
        dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
1386
        dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
1380
        dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
1387
        dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
1381
        dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
1388
        dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
1382
        dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
1389
        dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
1383
        dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
1390
        dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
1384
        dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
1391
 
1385
 
1392
        dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
1386
        dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
1393
        dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
1387
        dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
1394
        dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
1388
        dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
1395
        dd (CTRL_MCP04   shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
1389
        dd (CTRL_MCP04   shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
1396
        dd (CTRL_CK804   shl 16)+VID_NVIDIA,msg_CK804,set_ICH
1390
        dd (CTRL_CK804   shl 16)+VID_NVIDIA,msg_CK804,set_ICH
1397
        dd (CTRL_CK8     shl 16)+VID_NVIDIA,msg_CK8,set_ICH
1391
        dd (CTRL_CK8     shl 16)+VID_NVIDIA,msg_CK8,set_ICH
1398
        dd (CTRL_CK8S    shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
1392
        dd (CTRL_CK8S    shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
1399
        dd (CTRL_MCP51   shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
1393
        dd (CTRL_MCP51   shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
1400
 
1394
 
1401
        dd 0    ;terminator
1395
        dd 0    ;terminator
1402
 
1396
 
1403
 
1397
 
1404
msg_ICH      db '802801AA (ICH)',  13,10, 0
1398
msg_ICH      db '802801AA (ICH)',  13,10, 0
1405
msg_ICH0     db '802801AB (ICH0)', 13,10, 0
1399
msg_ICH0     db '802801AB (ICH0)', 13,10, 0
1406
msg_ICH2     db '802801BA (ICH2)', 13,10, 0
1400
msg_ICH2     db '802801BA (ICH2)', 13,10, 0
1407
msg_ICH3     db '802801CA (ICH3)', 13,10, 0
1401
msg_ICH3     db '802801CA (ICH3)', 13,10, 0
1408
msg_ICH4     db '802801DB (ICH4)', 13,10, 0
1402
msg_ICH4     db '802801DB (ICH4)', 13,10, 0
1409
msg_ICH5     db '802801EB (ICH5)', 13,10, 0
1403
msg_ICH5     db '802801EB (ICH5)', 13,10, 0
1410
msg_ICH6     db '802801FB (ICH6)', 13,10, 0
1404
msg_ICH6     db '802801FB (ICH6)', 13,10, 0
1411
msg_ICH7     db '802801GB (ICH7)', 13,10, 0
1405
msg_ICH7     db '802801GB (ICH7)', 13,10, 0
1412
msg_Intel    db 'Intel ', 0
1406
msg_Intel    db 'Intel ', 0
1413
 
1407
 
1414
msg_NForce   db 'NForce',      13,10, 0
1408
msg_NForce   db 'NForce',      13,10, 0
1415
msg_NForce2  db 'NForce 2',    13,10, 0
1409
msg_NForce2  db 'NForce 2',    13,10, 0
1416
msg_NForce3  db 'NForce 3',    13,10, 0
1410
msg_NForce3  db 'NForce 3',    13,10, 0
1417
msg_MCP04    db 'NForce MCP04',13,10, 0
1411
msg_MCP04    db 'NForce MCP04',13,10, 0
1418
msg_CK804    db 'NForce CK804',13,10, 0
1412
msg_CK804    db 'NForce CK804',13,10, 0
1419
msg_CK8      db 'NForce CK8',  13,10, 0
1413
msg_CK8      db 'NForce CK8',  13,10, 0
1420
msg_CK8S     db 'NForce CK8S', 13,10, 0
1414
msg_CK8S     db 'NForce CK8S', 13,10, 0
1421
msg_MCP51    db 'NForce MCP51',13,10, 0
1415
msg_MCP51    db 'NForce MCP51',13,10, 0
1422
 
1416
 
1423
msg_NVidia   db 'NVidia', 0
1417
msg_NVidia   db 'NVidia', 0
1424
 
1418
 
1425
szKernel            db 'KERNEL', 0
1419
szKernel            db 'KERNEL', 0
1426
sz_sound_srv        db 'SOUND',0
1420
sz_sound_srv        db 'SOUND',0
1427
 
1421
 
1428
msgInit      db 'detect hardware...',13,10,0
1422
msgInit      db 'detect hardware...',13,10,0
1429
msgFail      db 'device not found',13,10,0
1423
msgFail      db 'device not found',13,10,0
1430
msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
-
 
1431
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1424
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1432
msgPlay      db 'start play', 13,10,0
1425
msgPlay      db 'start play', 13,10,0
1433
msgStop      db 'stop play',  13,10,0
1426
msgStop      db 'stop play',  13,10,0
1434
;msgNotify    db 'call notify',13,10,0
1427
;msgNotify    db 'call notify',13,10,0
1435
msgIRQ       db 'AC97 IRQ', 13,10,0
1428
msgIRQ       db 'AC97 IRQ', 13,10,0
1436
msgInitCtrl  db 'init controller',13,10,0
1429
msgInitCtrl  db 'init controller',13,10,0
1437
;msgInitCodec db 'init codec',13,10,0
1430
;msgInitCodec db 'init codec',13,10,0
1438
msgPrimBuff  db 'create primary buffer ...',0
1431
msgPrimBuff  db 'create primary buffer ...',0
1439
msgDone      db 'done',13,10,0
1432
msgDone      db 'done',13,10,0
1440
msgRemap     db 'Remap IRQ',13,10,0
1433
msgRemap     db 'Remap IRQ',13,10,0
1441
;msgReg       db 'set service handler',13,10,0
1434
;msgReg       db 'set service handler',13,10,0
1442
msgOk        db 'service installed',13,10,0
1435
msgOk        db 'service installed',13,10,0
1443
msgCold      db 'cold reset',13,10,0
1436
msgCold      db 'cold reset',13,10,0
1444
msgWarm      db 'warm reset',13,10,0
1437
msgWarm      db 'warm reset',13,10,0
1445
msgWRFail    db 'warm reset failed',13,10,0
1438
msgWRFail    db 'warm reset failed',13,10,0
1446
msgCRFail    db 'cold reset failed',13,10,0
1439
msgCRFail    db 'cold reset failed',13,10,0
1447
msgCFail     db 'codec not ready',13,10,0
1440
msgCFail     db 'codec not ready',13,10,0
1448
msgResetOk   db 'reset complete',13,10,0
1441
msgResetOk   db 'reset complete',13,10,0
1449
msgStatus    db 'global status   ',0
1442
msgStatus    db 'global status   ',0
1450
msgControl   db 'global control  ',0
1443
msgControl   db 'global control  ',0
1451
msgPciCmd    db 'PCI command     ',0
1444
msgPciCmd    db 'PCI command     ',0
1452
msgPciStat   db 'PCI status      ',0
1445
msgPciStat   db 'PCI status      ',0
1453
msgCtrlIsaIo db 'controller io base   ',0
1446
msgCtrlIsaIo db 'controller io base   ',0
1454
msgMixIsaIo  db 'codec io base        ',0
1447
msgMixIsaIo  db 'codec io base        ',0
1455
msgCtrlMMIo  db 'controller mmio base ',0
1448
msgCtrlMMIo  db 'controller mmio base ',0
1456
msgMixMMIo   db 'codec mmio base      ',0
1449
msgMixMMIo   db 'codec mmio base      ',0
1457
msgIrqMap    db 'AC97 irq map as      ',0
1450
msgIrqMap    db 'AC97 irq map as      ',0
1458
 
1451
 
1459
align 4
1452
align 4
1460
data fixups
1453
data fixups
1461
end data
1454
end data
1462
 
1455
 
1463
section '.data' data readable writable
1456
section '.data' data readable writable
1464
 
1457
 
1465
pcmout_bdl       rq 32
1458
pcmout_bdl       rq 32
1466
buff_list        rd 32
1459
buff_list        rd 32
1467
 
1460
 
1468
codec CODEC
1461
codec CODEC
1469
ctrl AC_CNTRL
1462
ctrl AC_CNTRL
1470
 
1463
 
1471
lpc_bus  rd 1
1464
lpc_bus  rd 1
1472
civ_val  rd 1
1465
civ_val  rd 1