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 7584
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 unavailable
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_VIA           equ 0x1106
30
VID_VIA           equ 0x1106
37
 
31
 
38
CTRL_VT82C686     equ 0x3058
32
CTRL_VT82C686     equ 0x3058
39
CTRL_VT8233_5     equ 0x3059
33
CTRL_VT8233_5     equ 0x3059
40
 
34
 
41
 
35
 
42
CODEC_MASTER_VOL_REG         equ 0x02
36
CODEC_MASTER_VOL_REG         equ 0x02
43
CODEC_AUX_VOL                equ 0x04 ;
37
CODEC_AUX_VOL                equ 0x04 ;
44
CODEC_PCM_OUT_REG            equ 0x18 ; PCM output volume
38
CODEC_PCM_OUT_REG            equ 0x18 ; PCM output volume
45
CODEC_EXT_AUDIO_REG          equ 0x28 ; extended audio
39
CODEC_EXT_AUDIO_REG          equ 0x28 ; extended audio
46
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
40
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
47
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
41
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
48
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
42
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
49
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
43
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
50
 
44
 
51
 
45
 
52
;VIA host controller registers set
46
;VIA host controller registers set
53
;; common offsets
47
;; common offsets
54
VIA_REG_OFFSET_STATUS        equ   0x00    ;; byte - channel status
48
VIA_REG_OFFSET_STATUS        equ   0x00    ;; byte - channel status
55
  VIA_REG_STAT_ACTIVE              equ   0x80    ;; RO
49
  VIA_REG_STAT_ACTIVE              equ   0x80    ;; RO
56
  VIA_REG_STAT_PAUSED              equ   0x40    ;; RO
50
  VIA_REG_STAT_PAUSED              equ   0x40    ;; RO
57
  VIA_REG_STAT_TRIGGER_QUEUED      equ   0x08    ;; RO
51
  VIA_REG_STAT_TRIGGER_QUEUED      equ   0x08    ;; RO
58
  VIA_REG_STAT_STOPPED             equ   0x04    ;; RWC
52
  VIA_REG_STAT_STOPPED             equ   0x04    ;; RWC
59
  VIA_REG_STAT_EOL                 equ   0x02    ;; RWC
53
  VIA_REG_STAT_EOL                 equ   0x02    ;; RWC
60
  VIA_REG_STAT_FLAG                equ   0x01    ;; RWC
54
  VIA_REG_STAT_FLAG                equ   0x01    ;; RWC
61
VIA_REG_OFFSET_CONTROL       equ   0x01    ;; byte - channel control
55
VIA_REG_OFFSET_CONTROL       equ   0x01    ;; byte - channel control
62
  VIA_REG_CTRL_START               equ   0x80    ;; WO
56
  VIA_REG_CTRL_START               equ   0x80    ;; WO
63
  VIA_REG_CTRL_TERMINATE           equ   0x40    ;; WO
57
  VIA_REG_CTRL_TERMINATE           equ   0x40    ;; WO
64
  VIA_REG_CTRL_AUTOSTART           equ   0x20
58
  VIA_REG_CTRL_AUTOSTART           equ   0x20
65
  VIA_REG_CTRL_PAUSE               equ   0x08    ;; RW
59
  VIA_REG_CTRL_PAUSE               equ   0x08    ;; RW
66
  VIA_REG_CTRL_INT_STOP            equ   0x04
60
  VIA_REG_CTRL_INT_STOP            equ   0x04
67
  VIA_REG_CTRL_INT_EOL             equ   0x02
61
  VIA_REG_CTRL_INT_EOL             equ   0x02
68
  VIA_REG_CTRL_INT_FLAG            equ   0x01
62
  VIA_REG_CTRL_INT_FLAG            equ   0x01
69
  VIA_REG_CTRL_RESET               equ   0x01    ;; RW - probably reset? undocumented
63
  VIA_REG_CTRL_RESET               equ   0x01    ;; RW - probably reset? undocumented
70
  VIA_REG_CTRL_INT                 equ  (VIA_REG_CTRL_INT_FLAG or \
64
  VIA_REG_CTRL_INT                 equ  (VIA_REG_CTRL_INT_FLAG or \
71
                                         VIA_REG_CTRL_INT_EOL or \
65
                                         VIA_REG_CTRL_INT_EOL or \
72
                                         VIA_REG_CTRL_AUTOSTART)
66
                                         VIA_REG_CTRL_AUTOSTART)
73
VIA_REG_OFFSET_TYPE          equ   0x02    ;; byte - channel type (686 only)
67
VIA_REG_OFFSET_TYPE          equ   0x02    ;; byte - channel type (686 only)
74
  VIA_REG_TYPE_AUTOSTART           equ   0x80    ;; RW - autostart at EOL
68
  VIA_REG_TYPE_AUTOSTART           equ   0x80    ;; RW - autostart at EOL
75
  VIA_REG_TYPE_16BIT               equ   0x20    ;; RW
69
  VIA_REG_TYPE_16BIT               equ   0x20    ;; RW
76
  VIA_REG_TYPE_STEREO              equ   0x10    ;; RW
70
  VIA_REG_TYPE_STEREO              equ   0x10    ;; RW
77
  VIA_REG_TYPE_INT_LLINE           equ   0x00
71
  VIA_REG_TYPE_INT_LLINE           equ   0x00
78
  VIA_REG_TYPE_INT_LSAMPLE         equ   0x04
72
  VIA_REG_TYPE_INT_LSAMPLE         equ   0x04
79
  VIA_REG_TYPE_INT_LESSONE         equ   0x08
73
  VIA_REG_TYPE_INT_LESSONE         equ   0x08
80
  VIA_REG_TYPE_INT_MASK            equ   0x0c
74
  VIA_REG_TYPE_INT_MASK            equ   0x0c
81
  VIA_REG_TYPE_INT_EOL             equ   0x02
75
  VIA_REG_TYPE_INT_EOL             equ   0x02
82
  VIA_REG_TYPE_INT_FLAG            equ   0x01
76
  VIA_REG_TYPE_INT_FLAG            equ   0x01
83
VIA_REG_OFFSET_TABLE_PTR     equ   0x04    ;; dword - channel table pointer
77
VIA_REG_OFFSET_TABLE_PTR     equ   0x04    ;; dword - channel table pointer
84
VIA_REG_OFFSET_CURR_PTR      equ   0x04    ;; dword - channel current pointer
78
VIA_REG_OFFSET_CURR_PTR      equ   0x04    ;; dword - channel current pointer
85
VIA_REG_OFFSET_STOP_IDX      equ   0x08    ;; dword - stop index, channel type, sample rate
79
VIA_REG_OFFSET_STOP_IDX      equ   0x08    ;; dword - stop index, channel type, sample rate
86
  VIA8233_REG_TYPE_16BIT           equ   0x00200000      ;; RW
80
  VIA8233_REG_TYPE_16BIT           equ   0x00200000      ;; RW
87
  VIA8233_REG_TYPE_STEREO          equ   0x00100000      ;; RW
81
  VIA8233_REG_TYPE_STEREO          equ   0x00100000      ;; RW
88
VIA_REG_OFFSET_CURR_COUNT    equ   0x0c    ;; dword - channel current count (24 bit)
82
VIA_REG_OFFSET_CURR_COUNT    equ   0x0c    ;; dword - channel current count (24 bit)
89
VIA_REG_OFFSET_CURR_INDEX    equ   0x0f    ;; byte - channel current index (for via8233 only)
83
VIA_REG_OFFSET_CURR_INDEX    equ   0x0f    ;; byte - channel current index (for via8233 only)
90
 
84
 
91
 
85
 
92
VIADEV_PLAYBACK         equ   0x00
86
VIADEV_PLAYBACK         equ   0x00
93
VIADEV_CAPTURE          equ   0x10
87
VIADEV_CAPTURE          equ   0x10
94
VIADEV_FM               equ   0x20
88
VIADEV_FM               equ   0x20
95
 
89
 
96
;; AC'97 ;;
90
;; AC'97 ;;
97
VIA_REG_AC97             equ   0x80    ; dword
91
VIA_REG_AC97             equ   0x80    ; dword
98
  VIA_REG_AC97_CODEC_ID_MASK       equ  0xC0000000 ;(3<<30)
92
  VIA_REG_AC97_CODEC_ID_MASK       equ  0xC0000000 ;(3<<30)
99
  VIA_REG_AC97_CODEC_ID_SHIFT      equ  30
93
  VIA_REG_AC97_CODEC_ID_SHIFT      equ  30
100
  VIA_REG_AC97_CODEC_ID_PRIMARY    equ  0x00
94
  VIA_REG_AC97_CODEC_ID_PRIMARY    equ  0x00
101
  VIA_REG_AC97_CODEC_ID_SECONDARY  equ  0x01
95
  VIA_REG_AC97_CODEC_ID_SECONDARY  equ  0x01
102
  VIA_REG_AC97_SECONDARY_VALID     equ  0x08000000 ;(1<<27)
96
  VIA_REG_AC97_SECONDARY_VALID     equ  0x08000000 ;(1<<27)
103
  VIA_REG_AC97_PRIMARY_VALID       equ  0x02000000 ;(1<<25)
97
  VIA_REG_AC97_PRIMARY_VALID       equ  0x02000000 ;(1<<25)
104
  VIA_REG_AC97_BUSY                equ  0x01000000 ;(1<<24)
98
  VIA_REG_AC97_BUSY                equ  0x01000000 ;(1<<24)
105
  VIA_REG_AC97_READ                equ  0x00800000 ;(1<<23)
99
  VIA_REG_AC97_READ                equ  0x00800000 ;(1<<23)
106
  VIA_REG_AC97_CMD_SHIFT           equ  16
100
  VIA_REG_AC97_CMD_SHIFT           equ  16
107
  VIA_REG_AC97_CMD_MASK            equ  0x7E
101
  VIA_REG_AC97_CMD_MASK            equ  0x7E
108
  VIA_REG_AC97_DATA_SHIFT          equ  0
102
  VIA_REG_AC97_DATA_SHIFT          equ  0
109
  VIA_REG_AC97_DATA_MASK           equ  0xFFFF
103
  VIA_REG_AC97_DATA_MASK           equ  0xFFFF
110
 
104
 
111
VIA_REG_SGD_SHADOW       equ   0x84    ; dword
105
VIA_REG_SGD_SHADOW       equ   0x84    ; dword
112
 
106
 
113
;; via8233-specific registers ;;
107
;; via8233-specific registers ;;
114
VIA_REG_OFS_PLAYBACK_VOLUME_L   equ  0x02    ;; byte
108
VIA_REG_OFS_PLAYBACK_VOLUME_L   equ  0x02    ;; byte
115
VIA_REG_OFS_PLAYBACK_VOLUME_R   equ  0x03    ;; byte
109
VIA_REG_OFS_PLAYBACK_VOLUME_R   equ  0x03    ;; byte
116
VIA_REG_OFS_MULTPLAY_FORMAT     equ  0x02    ;; byte - format and channels
110
VIA_REG_OFS_MULTPLAY_FORMAT     equ  0x02    ;; byte - format and channels
117
  VIA_REG_MULTPLAY_FMT_8BIT          equ  0x00
111
  VIA_REG_MULTPLAY_FMT_8BIT          equ  0x00
118
  VIA_REG_MULTPLAY_FMT_16BIT         equ  0x80
112
  VIA_REG_MULTPLAY_FMT_16BIT         equ  0x80
119
  VIA_REG_MULTPLAY_FMT_CH_MASK       equ  0x70    ;; # channels << 4 (valid = 1,2,4,6)
113
  VIA_REG_MULTPLAY_FMT_CH_MASK       equ  0x70    ;; # channels << 4 (valid = 1,2,4,6)
120
VIA_REG_OFS_CAPTURE_FIFO        equ  0x02    ;; byte - bit 6 = fifo  enable
114
VIA_REG_OFS_CAPTURE_FIFO        equ  0x02    ;; byte - bit 6 = fifo  enable
121
  VIA_REG_CAPTURE_FIFO_ENABLE        equ  0x40
115
  VIA_REG_CAPTURE_FIFO_ENABLE        equ  0x40
122
 
116
 
123
VIA_DXS_MAX_VOLUME              equ  31      ;; max. volume (attenuation) of reg 0x32/33
117
VIA_DXS_MAX_VOLUME              equ  31      ;; max. volume (attenuation) of reg 0x32/33
124
 
118
 
125
VIA_TBL_BIT_FLAG          equ   0x40000000
119
VIA_TBL_BIT_FLAG          equ   0x40000000
126
VIA_TBL_BIT_EOL           equ   0x80000000
120
VIA_TBL_BIT_EOL           equ   0x80000000
127
 
121
 
128
;; pci space ;;
122
;; pci space ;;
129
VIA_ACLINK_STAT           equ   0x40
123
VIA_ACLINK_STAT           equ   0x40
130
  ;...
124
  ;...
131
  VIA_ACLINK_C00_READY             equ   0x01 ; primary codec ready
125
  VIA_ACLINK_C00_READY             equ   0x01 ; primary codec ready
132
VIA_ACLINK_CTRL           equ   0x41
126
VIA_ACLINK_CTRL           equ   0x41
133
  VIA_ACLINK_CTRL_ENABLE           equ   0x80 ; 0: disable, 1: enable
127
  VIA_ACLINK_CTRL_ENABLE           equ   0x80 ; 0: disable, 1: enable
134
  VIA_ACLINK_CTRL_RESET            equ   0x40 ; 0: assert, 1: de-assert
128
  VIA_ACLINK_CTRL_RESET            equ   0x40 ; 0: assert, 1: de-assert
135
  VIA_ACLINK_CTRL_SYNC             equ   0x20 ; 0: release SYNC, 1: force SYNC hi
129
  VIA_ACLINK_CTRL_SYNC             equ   0x20 ; 0: release SYNC, 1: force SYNC hi
136
  VIA_ACLINK_CTRL_SDO              equ   0x10 ; 0: release SDO, 1: force SDO hi
130
  VIA_ACLINK_CTRL_SDO              equ   0x10 ; 0: release SDO, 1: force SDO hi
137
  VIA_ACLINK_CTRL_VRA              equ   0x08 ; 0: disable VRA, 1: enable VRA
131
  VIA_ACLINK_CTRL_VRA              equ   0x08 ; 0: disable VRA, 1: enable VRA
138
  VIA_ACLINK_CTRL_PCM              equ   0x04 ; 0: disable PCM, 1: enable PCM
132
  VIA_ACLINK_CTRL_PCM              equ   0x04 ; 0: disable PCM, 1: enable PCM
139
  VIA_ACLINK_CTRL_FM               equ   0x02 ; via686 only
133
  VIA_ACLINK_CTRL_FM               equ   0x02 ; via686 only
140
  VIA_ACLINK_CTRL_SB               equ   0x01 ; via686 only
134
  VIA_ACLINK_CTRL_SB               equ   0x01 ; via686 only
141
  VIA_ACLINK_CTRL_INIT             equ  (VIA_ACLINK_CTRL_ENABLE or \
135
  VIA_ACLINK_CTRL_INIT             equ  (VIA_ACLINK_CTRL_ENABLE or \
142
                                         VIA_ACLINK_CTRL_RESET or \
136
                                         VIA_ACLINK_CTRL_RESET or \
143
                                         VIA_ACLINK_CTRL_PCM or \
137
                                         VIA_ACLINK_CTRL_PCM or \
144
                                         VIA_ACLINK_CTRL_VRA)
138
                                         VIA_ACLINK_CTRL_VRA)
145
VIA_FUNC_ENABLE           equ   0x42
139
VIA_FUNC_ENABLE           equ   0x42
146
  VIA_FUNC_MIDI_PNP                equ   0x80 ; FIXME: it's 0x40 in the datasheet!
140
  VIA_FUNC_MIDI_PNP                equ   0x80 ; FIXME: it's 0x40 in the datasheet!
147
  VIA_FUNC_MIDI_IRQMASK            equ   0x40 ; FIXME: not documented!
141
  VIA_FUNC_MIDI_IRQMASK            equ   0x40 ; FIXME: not documented!
148
  VIA_FUNC_RX2C_WRITE              equ   0x20
142
  VIA_FUNC_RX2C_WRITE              equ   0x20
149
  VIA_FUNC_SB_FIFO_EMPTY           equ   0x10
143
  VIA_FUNC_SB_FIFO_EMPTY           equ   0x10
150
  VIA_FUNC_ENABLE_GAME             equ   0x08
144
  VIA_FUNC_ENABLE_GAME             equ   0x08
151
  VIA_FUNC_ENABLE_FM               equ   0x04
145
  VIA_FUNC_ENABLE_FM               equ   0x04
152
  VIA_FUNC_ENABLE_MIDI             equ   0x02
146
  VIA_FUNC_ENABLE_MIDI             equ   0x02
153
  VIA_FUNC_ENABLE_SB               equ   0x01
147
  VIA_FUNC_ENABLE_SB               equ   0x01
154
VIA_PNP_CONTROL           equ   0x43
148
VIA_PNP_CONTROL           equ   0x43
155
VIA_FM_NMI_CTRL           equ   0x48
149
VIA_FM_NMI_CTRL           equ   0x48
156
VIA8233_VOLCHG_CTRL       equ   0x48
150
VIA8233_VOLCHG_CTRL       equ   0x48
157
VIA8233_SPDIF_CTRL        equ   0x49
151
VIA8233_SPDIF_CTRL        equ   0x49
158
  VIA8233_SPDIF_DX3                equ   0x08
152
  VIA8233_SPDIF_DX3                equ   0x08
159
  VIA8233_SPDIF_SLOT_MASK          equ   0x03
153
  VIA8233_SPDIF_SLOT_MASK          equ   0x03
160
  VIA8233_SPDIF_SLOT_1011          equ   0x00
154
  VIA8233_SPDIF_SLOT_1011          equ   0x00
161
  VIA8233_SPDIF_SLOT_34            equ   0x01
155
  VIA8233_SPDIF_SLOT_34            equ   0x01
162
  VIA8233_SPDIF_SLOT_78            equ   0x02
156
  VIA8233_SPDIF_SLOT_78            equ   0x02
163
  VIA8233_SPDIF_SLOT_69            equ   0x03
157
  VIA8233_SPDIF_SLOT_69            equ   0x03
164
;] Asper
158
;] Asper
165
 
159
 
166
 
160
 
167
SRV_GETVERSION        equ  0
161
SRV_GETVERSION        equ  0
168
DEV_PLAY              equ  1
162
DEV_PLAY              equ  1
169
DEV_STOP              equ  2
163
DEV_STOP              equ  2
170
DEV_CALLBACK          equ  3
164
DEV_CALLBACK          equ  3
171
DEV_SET_BUFF          equ  4
165
DEV_SET_BUFF          equ  4
172
DEV_NOTIFY            equ  5
166
DEV_NOTIFY            equ  5
173
DEV_SET_MASTERVOL     equ  6
167
DEV_SET_MASTERVOL     equ  6
174
DEV_GET_MASTERVOL     equ  7
168
DEV_GET_MASTERVOL     equ  7
175
DEV_GET_INFO          equ  8
169
DEV_GET_INFO          equ  8
176
DEV_GET_POS           equ  9
170
DEV_GET_POS           equ  9
177
 
171
 
178
struc AC_CNTRL              ;AC controller base class
172
struc AC_CNTRL              ;AC controller base class
179
{ .bus                dd ?
173
{ .bus                dd ?
180
  .devfn              dd ?
174
  .devfn              dd ?
181
 
175
 
182
  .vendor             dd ?
176
  .vendor             dd ?
183
  .dev_id             dd ?
177
  .dev_id             dd ?
184
  .pci_cmd            dd ?
178
  .pci_cmd            dd ?
185
  .pci_stat           dd ?
179
  .pci_stat           dd ?
186
 
180
 
187
  .codec_io_base      dd ?
181
  .codec_io_base      dd ?
188
  .codec_mem_base     dd ?
182
  .codec_mem_base     dd ?
189
 
183
 
190
  .ctrl_io_base       dd ?
184
  .ctrl_io_base       dd ?
191
  .ctrl_mem_base      dd ?
185
  .ctrl_mem_base      dd ?
192
  .cfg_reg            dd ?
186
  .cfg_reg            dd ?
193
  .int_line           dd ?
187
  .int_line           dd ?
194
 
188
 
195
  .vendor_ids         dd ?    ;vendor id string
189
  .vendor_ids         dd ?    ;vendor id string
196
  .ctrl_ids           dd ?    ;hub id string
190
  .ctrl_ids           dd ?    ;hub id string
197
 
191
 
198
  .buffer             dd ?
192
  .buffer             dd ?
199
 
193
 
200
  .notify_pos         dd ?
194
  .notify_pos         dd ?
201
  .notify_task        dd ?
195
  .notify_task        dd ?
202
 
196
 
203
  .lvi_reg            dd ?
197
  .lvi_reg            dd ?
204
  .ctrl_setup         dd ?
198
  .ctrl_setup         dd ?
205
  .user_callback      dd ?
199
  .user_callback      dd ?
206
  .codec_read16       dd ?
200
  .codec_read16       dd ?
207
  .codec_write16      dd ?
201
  .codec_write16      dd ?
208
 
202
 
209
  .ctrl_read8         dd ?
203
  .ctrl_read8         dd ?
210
  .ctrl_read16        dd ?
204
  .ctrl_read16        dd ?
211
  .ctrl_read32        dd ?
205
  .ctrl_read32        dd ?
212
 
206
 
213
  .ctrl_write8        dd ?
207
  .ctrl_write8        dd ?
214
  .ctrl_write16       dd ?
208
  .ctrl_write16       dd ?
215
  .ctrl_write32       dd ?
209
  .ctrl_write32       dd ?
216
}
210
}
217
 
211
 
218
struc CODEC                ;Audio Chip base class
212
struc CODEC                ;Audio Chip base class
219
{
213
{
220
  .chip_id            dd ?
214
  .chip_id            dd ?
221
  .flags              dd ?
215
  .flags              dd ?
222
  .status             dd ?
216
  .status             dd ?
223
 
217
 
224
  .ac_vendor_ids      dd ?    ;ac vendor id string
218
  .ac_vendor_ids      dd ?    ;ac vendor id string
225
  .chip_ids           dd ?    ;chip model string
219
  .chip_ids           dd ?    ;chip model string
226
 
220
 
227
  .shadow_flag        dd ?
221
  .shadow_flag        dd ?
228
                      dd ?
222
                      dd ?
229
 
223
 
230
  .regs               dw ?     ; codec registers
224
  .regs               dw ?     ; codec registers
231
  .reg_master_vol     dw ?     ;0x02
225
  .reg_master_vol     dw ?     ;0x02
232
  .reg_aux_out_vol    dw ?     ;0x04
226
  .reg_aux_out_vol    dw ?     ;0x04
233
  .reg_mone_vol       dw ?     ;0x06
227
  .reg_mone_vol       dw ?     ;0x06
234
  .reg_master_tone    dw ?     ;0x08
228
  .reg_master_tone    dw ?     ;0x08
235
  .reg_beep_vol       dw ?     ;0x0A
229
  .reg_beep_vol       dw ?     ;0x0A
236
  .reg_phone_vol      dw ?     ;0x0C
230
  .reg_phone_vol      dw ?     ;0x0C
237
  .reg_mic_vol        dw ?     ;0x0E
231
  .reg_mic_vol        dw ?     ;0x0E
238
  .reg_line_in_vol    dw ?     ;0x10
232
  .reg_line_in_vol    dw ?     ;0x10
239
  .reg_cd_vol         dw ?     ;0x12
233
  .reg_cd_vol         dw ?     ;0x12
240
  .reg_video_vol      dw ?     ;0x14
234
  .reg_video_vol      dw ?     ;0x14
241
  .reg_aux_in_vol     dw ?     ;0x16
235
  .reg_aux_in_vol     dw ?     ;0x16
242
  .reg_pcm_out_vol    dw ?     ;0x18
236
  .reg_pcm_out_vol    dw ?     ;0x18
243
  .reg_rec_select     dw ?     ;0x1A
237
  .reg_rec_select     dw ?     ;0x1A
244
  .reg_rec_gain       dw ?     ;0x1C
238
  .reg_rec_gain       dw ?     ;0x1C
245
  .reg_rec_gain_mic   dw ?     ;0x1E
239
  .reg_rec_gain_mic   dw ?     ;0x1E
246
  .reg_gen            dw ?     ;0x20
240
  .reg_gen            dw ?     ;0x20
247
  .reg_3d_ctrl        dw ?     ;0X22
241
  .reg_3d_ctrl        dw ?     ;0X22
248
  .reg_page           dw ?     ;0X24
242
  .reg_page           dw ?     ;0X24
249
  .reg_powerdown      dw ?     ;0x26
243
  .reg_powerdown      dw ?     ;0x26
250
  .reg_ext_audio      dw ?     ;0x28
244
  .reg_ext_audio      dw ?     ;0x28
251
  .reg_ext_st         dw ?     ;0x2a
245
  .reg_ext_st         dw ?     ;0x2a
252
  .reg_pcm_front_rate dw ?     ;0x2c
246
  .reg_pcm_front_rate dw ?     ;0x2c
253
  .reg_pcm_surr_rate  dw ?     ;0x2e
247
  .reg_pcm_surr_rate  dw ?     ;0x2e
254
  .reg_lfe_rate       dw ?     ;0x30
248
  .reg_lfe_rate       dw ?     ;0x30
255
  .reg_pcm_in_rate    dw ?     ;0x32
249
  .reg_pcm_in_rate    dw ?     ;0x32
256
                      dw ?     ;0x34
250
                      dw ?     ;0x34
257
  .reg_cent_lfe_vol   dw ?     ;0x36
251
  .reg_cent_lfe_vol   dw ?     ;0x36
258
  .reg_surr_vol       dw ?     ;0x38
252
  .reg_surr_vol       dw ?     ;0x38
259
  .reg_spdif_ctrl     dw ?     ;0x3A
253
  .reg_spdif_ctrl     dw ?     ;0x3A
260
                      dw ?     ;0x3C
254
                      dw ?     ;0x3C
261
                      dw ?     ;0x3E
255
                      dw ?     ;0x3E
262
                      dw ?     ;0x40
256
                      dw ?     ;0x40
263
                      dw ?     ;0x42
257
                      dw ?     ;0x42
264
                      dw ?     ;0x44
258
                      dw ?     ;0x44
265
                      dw ?     ;0x46
259
                      dw ?     ;0x46
266
                      dw ?     ;0x48
260
                      dw ?     ;0x48
267
                      dw ?     ;0x4A
261
                      dw ?     ;0x4A
268
                      dw ?     ;0x4C
262
                      dw ?     ;0x4C
269
                      dw ?     ;0x4E
263
                      dw ?     ;0x4E
270
                      dw ?     ;0x50
264
                      dw ?     ;0x50
271
                      dw ?     ;0x52
265
                      dw ?     ;0x52
272
                      dw ?     ;0x54
266
                      dw ?     ;0x54
273
                      dw ?     ;0x56
267
                      dw ?     ;0x56
274
                      dw ?     ;0x58
268
                      dw ?     ;0x58
275
                      dw ?     ;0x5A
269
                      dw ?     ;0x5A
276
                      dw ?     ;0x5C
270
                      dw ?     ;0x5C
277
                      dw ?     ;0x5E
271
                      dw ?     ;0x5E
278
  .reg_page_0         dw ?     ;0x60
272
  .reg_page_0         dw ?     ;0x60
279
  .reg_page_1         dw ?     ;0x62
273
  .reg_page_1         dw ?     ;0x62
280
  .reg_page_2         dw ?     ;0x64
274
  .reg_page_2         dw ?     ;0x64
281
  .reg_page_3         dw ?     ;0x66
275
  .reg_page_3         dw ?     ;0x66
282
  .reg_page_4         dw ?     ;0x68
276
  .reg_page_4         dw ?     ;0x68
283
  .reg_page_5         dw ?     ;0x6A
277
  .reg_page_5         dw ?     ;0x6A
284
  .reg_page_6         dw ?     ;0x6C
278
  .reg_page_6         dw ?     ;0x6C
285
  .reg_page_7         dw ?     ;0x6E
279
  .reg_page_7         dw ?     ;0x6E
286
                      dw ?     ;0x70
280
                      dw ?     ;0x70
287
                      dw ?     ;0x72
281
                      dw ?     ;0x72
288
                      dw ?     ;0x74
282
                      dw ?     ;0x74
289
                      dw ?     ;0x76
283
                      dw ?     ;0x76
290
                      dw ?     ;0x78
284
                      dw ?     ;0x78
291
                      dw ?     ;0x7A
285
                      dw ?     ;0x7A
292
  .reg_vendor_id_1    dw ?     ;0x7C
286
  .reg_vendor_id_1    dw ?     ;0x7C
293
  .reg_vendor_id_2    dw ?     ;0x7E
287
  .reg_vendor_id_2    dw ?     ;0x7E
294
 
288
 
295
 
289
 
296
  .reset              dd ?    ;virtual
290
  .reset              dd ?    ;virtual
297
  .set_master_vol     dd ?
291
  .set_master_vol     dd ?
298
}
292
}
299
 
293
 
300
struc CTRL_INFO
294
struc CTRL_INFO
301
{   .pci_cmd          dd ?
295
{   .pci_cmd          dd ?
302
    .irq              dd ?
296
    .irq              dd ?
303
    .glob_cntrl       dd ?
297
    .glob_cntrl       dd ?
304
    .glob_sta         dd ?
298
    .glob_sta         dd ?
305
    .codec_io_base    dd ?
299
    .codec_io_base    dd ?
306
    .ctrl_io_base     dd ?
300
    .ctrl_io_base     dd ?
307
    .codec_mem_base   dd ?
301
    .codec_mem_base   dd ?
308
    .ctrl_mem_base    dd ?
302
    .ctrl_mem_base    dd ?
309
    .codec_id         dd ?
303
    .codec_id         dd ?
310
}
304
}
311
 
305
 
312
EVENT_NOTIFY    equ 0x00000200
306
EVENT_NOTIFY    equ 0x00000200
313
 
307
 
314
section '.flat' code readable writable executable
308
section '.flat' code readable writable executable
315
include '../struct.inc'
309
include '../struct.inc'
316
include '../macros.inc'
310
include '../macros.inc'
317
include '../proc32.inc'
311
include '../proc32.inc'
318
include '../peimport.inc'
312
include '../peimport.inc'
319
 
313
 
320
proc START c, state:dword, cmdline:dword
314
proc START c, state:dword, cmdline:dword
321
 
315
 
322
        cmp     [state], 1
316
        cmp     [state], 1
323
        jne     .stop
317
        jne     .stop
324
 
318
 
325
     if DEBUG
319
     if DEBUG
326
        mov     esi, msgInit
320
        mov     esi, msgInit
327
        invoke  SysMsgBoardStr
321
        invoke  SysMsgBoardStr
328
     end if
322
     end if
329
 
323
 
330
        call    detect_controller
324
        call    detect_controller
331
        test    eax, eax
325
        test    eax, eax
332
        jz      .fail
326
        jz      .fail
333
 
327
 
334
     if DEBUG
328
     if DEBUG
335
        mov     esi, [ctrl.vendor_ids]
329
        mov     esi, [ctrl.vendor_ids]
336
        invoke  SysMsgBoardStr
330
        invoke  SysMsgBoardStr
337
        mov     esi, [ctrl.ctrl_ids]
331
        mov     esi, [ctrl.ctrl_ids]
338
        invoke  SysMsgBoardStr
332
        invoke  SysMsgBoardStr
339
     end if
333
     end if
340
 
334
 
341
        call    init_controller
335
        call    init_controller
342
        test    eax, eax
336
        test    eax, eax
343
        jz      .fail
337
        jz      .fail
344
 
338
 
345
        call    init_codec
339
        call    init_codec
346
        test    eax, eax
340
        test    eax, eax
347
        jz      .fail
341
        jz      .fail
348
 
342
 
349
        call    setup_codec
343
        call    setup_codec
350
 
344
 
351
        mov     esi, msgPrimBuff
345
        mov     esi, msgPrimBuff
352
        invoke  SysMsgBoardStr
346
        invoke  SysMsgBoardStr
353
        call    create_primary_buff
347
        call    create_primary_buff
354
        mov     esi, msgDone
348
        mov     esi, msgDone
355
        invoke  SysMsgBoardStr
349
        invoke  SysMsgBoardStr
356
 
350
 
357
  if IRQ_REMAP
351
  if IRQ_REMAP
358
        pushf
352
        pushf
359
        cli
353
        cli
360
 
354
 
361
        mov     ebx, [ctrl.int_line]
355
        mov     ebx, [ctrl.int_line]
362
        in      al, 0xA1
356
        in      al, 0xA1
363
        mov     ah, al
357
        mov     ah, al
364
        in      al, 0x21
358
        in      al, 0x21
365
        test    ebx, ebx
359
        test    ebx, ebx
366
        jz      .skip
360
        jz      .skip
367
        bts     ax, bx                          ;mask old line
361
        bts     ax, bx                          ;mask old line
368
.skip:
362
.skip:
369
        bts     ax, IRQ_LINE                    ;mask new ine
363
        bts     ax, IRQ_LINE                    ;mask new ine
370
        out     0x21, al
364
        out     0x21, al
371
        mov     al, ah
365
        mov     al, ah
372
        out     0xA1, al
366
        out     0xA1, al
373
 
367
 
374
        invoke  PciWrite8, 0, 0xF8, 0x61, IRQ_LINE      ;remap IRQ
368
        invoke  PciWrite8, 0, 0xF8, 0x61, IRQ_LINE      ;remap IRQ
375
 
369
 
376
        mov     dx, 0x4d0                       ;8259 ELCR1
370
        mov     dx, 0x4d0                       ;8259 ELCR1
377
        in      al, dx
371
        in      al, dx
378
        bts     ax, IRQ_LINE
372
        bts     ax, IRQ_LINE
379
        out     dx, al                          ;set level-triggered mode
373
        out     dx, al                          ;set level-triggered mode
380
        mov     [ctrl.int_line], IRQ_LINE
374
        mov     [ctrl.int_line], IRQ_LINE
381
        popf
375
        popf
382
        mov     esi, msgRemap
376
        mov     esi, msgRemap
383
        invoke  SysMsgBoardStr
377
        invoke  SysMsgBoardStr
384
  end if
378
  end if
385
 
379
 
386
        mov     eax, VALID_IRQ
380
        mov     eax, VALID_IRQ
387
        mov     ebx, [ctrl.int_line]
381
        mov     ebx, [ctrl.int_line]
388
        mov     esi, msgInvIRQ
382
        mov     esi, msgInvIRQ
389
        bt      eax, ebx
383
        bt      eax, ebx
390
        jnc     .fail_msg
384
        jnc     .fail_msg
391
        mov     eax, ATTCH_IRQ
-
 
392
        mov     esi, msgAttchIRQ
-
 
393
        bt      eax, ebx
-
 
394
        jnc     .fail_msg
-
 
395
 
385
 
396
        invoke  AttachIntHandler, ebx, ac97_irq_VIA, 0
386
        invoke  AttachIntHandler, ebx, ac97_irq_VIA, 0
397
.reg:
387
.reg:
398
        invoke  RegService, sz_sound_srv, service_proc
388
        invoke  RegService, sz_sound_srv, service_proc
399
        ret
389
        ret
400
.fail:
390
.fail:
401
     if DEBUG
391
     if DEBUG
402
        mov     esi, msgFail
392
        mov     esi, msgFail
403
        invoke  SysMsgBoardStr
393
        invoke  SysMsgBoardStr
404
     end if
394
     end if
405
        xor     eax, eax
395
        xor     eax, eax
406
        ret
396
        ret
407
.fail_msg:
397
.fail_msg:
408
        invoke  SysMsgBoardStr
398
        invoke  SysMsgBoardStr
409
        xor     eax, eax
399
        xor     eax, eax
410
        ret
400
        ret
411
.stop:
401
.stop:
412
        call    stop
402
        call    stop
413
        xor     eax, eax
403
        xor     eax, eax
414
        ret
404
        ret
415
endp
405
endp
416
 
406
 
417
handle     equ  IOCTL.handle
407
handle     equ  IOCTL.handle
418
io_code    equ  IOCTL.io_code
408
io_code    equ  IOCTL.io_code
419
input      equ  IOCTL.input
409
input      equ  IOCTL.input
420
inp_size   equ  IOCTL.inp_size
410
inp_size   equ  IOCTL.inp_size
421
output     equ  IOCTL.output
411
output     equ  IOCTL.output
422
out_size   equ  IOCTL.out_size
412
out_size   equ  IOCTL.out_size
423
 
413
 
424
align 4
414
align 4
425
proc service_proc stdcall, ioctl:dword
415
proc service_proc stdcall, ioctl:dword
426
 
416
 
427
        mov     edi, [ioctl]
417
        mov     edi, [ioctl]
428
        mov     eax, [edi+io_code]
418
        mov     eax, [edi+io_code]
429
 
419
 
430
        cmp     eax, SRV_GETVERSION
420
        cmp     eax, SRV_GETVERSION
431
        jne     @F
421
        jne     @F
432
        mov     eax, [edi+output]
422
        mov     eax, [edi+output]
433
        cmp     [edi+out_size], 4
423
        cmp     [edi+out_size], 4
434
        jne     .fail
424
        jne     .fail
435
 
425
 
436
        mov     [eax], dword API_VERSION
426
        mov     [eax], dword API_VERSION
437
        xor     eax, eax
427
        xor     eax, eax
438
        ret
428
        ret
439
@@:
429
@@:
440
        cmp     eax, DEV_PLAY
430
        cmp     eax, DEV_PLAY
441
        jne     @F
431
        jne     @F
442
     if DEBUG
432
     if DEBUG
443
        mov     esi, msgPlay
433
        mov     esi, msgPlay
444
        invoke  SysMsgBoardStr
434
        invoke  SysMsgBoardStr
445
     end if
435
     end if
446
        call    play
436
        call    play
447
        ret
437
        ret
448
@@:
438
@@:
449
        cmp     eax, DEV_STOP
439
        cmp     eax, DEV_STOP
450
        jne     @F
440
        jne     @F
451
     if DEBUG
441
     if DEBUG
452
        mov     esi, msgStop
442
        mov     esi, msgStop
453
        invoke  SysMsgBoardStr
443
        invoke  SysMsgBoardStr
454
     end if
444
     end if
455
        call    stop
445
        call    stop
456
        ret
446
        ret
457
@@:
447
@@:
458
        cmp     eax, DEV_CALLBACK
448
        cmp     eax, DEV_CALLBACK
459
        jne     @F
449
        jne     @F
460
        mov     ebx, [edi+input]
450
        mov     ebx, [edi+input]
461
        stdcall set_callback, [ebx]
451
        stdcall set_callback, [ebx]
462
        ret
452
        ret
463
@@:
453
@@:
464
        cmp     eax, DEV_SET_MASTERVOL
454
        cmp     eax, DEV_SET_MASTERVOL
465
        jne     @F
455
        jne     @F
466
        mov     eax, [edi+input]
456
        mov     eax, [edi+input]
467
        mov     eax, [eax]
457
        mov     eax, [eax]
468
        call    set_master_vol          ;eax= vol
458
        call    set_master_vol          ;eax= vol
469
        ret
459
        ret
470
@@:
460
@@:
471
        cmp     eax, DEV_GET_MASTERVOL
461
        cmp     eax, DEV_GET_MASTERVOL
472
        jne     @F
462
        jne     @F
473
        mov     ebx, [edi+output]
463
        mov     ebx, [edi+output]
474
        stdcall get_master_vol, ebx
464
        stdcall get_master_vol, ebx
475
        ret
465
        ret
476
@@:
466
@@:
477
        cmp     eax, DEV_GET_INFO
467
        cmp     eax, DEV_GET_INFO
478
        jne     @F
468
        jne     @F
479
        mov     ebx, [edi+output]
469
        mov     ebx, [edi+output]
480
        stdcall get_dev_info, ebx
470
        stdcall get_dev_info, ebx
481
        ret
471
        ret
482
@@:
472
@@:
483
        cmp     eax, DEV_GET_POS
473
        cmp     eax, DEV_GET_POS
484
        jne     @F
474
        jne     @F
485
        push    ebx  edx
475
        push    ebx  edx
486
        mov     edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CURR_COUNT
476
        mov     edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CURR_COUNT
487
        call    [ctrl.ctrl_read32]
477
        call    [ctrl.ctrl_read32]
488
        and     eax, 0x00FFFFFF
478
        and     eax, 0x00FFFFFF
489
        mov     ebx, 4096
479
        mov     ebx, 4096
490
        sub     ebx, eax
480
        sub     ebx, eax
491
        shr     ebx, 2
481
        shr     ebx, 2
492
        mov     edx, [edi+output]
482
        mov     edx, [edi+output]
493
        mov     [edx], ebx
483
        mov     [edx], ebx
494
        pop     edx ebx
484
        pop     edx ebx
495
        ret
485
        ret
496
@@:
486
@@:
497
.fail:
487
.fail:
498
        or      eax, -1
488
        or      eax, -1
499
        ret
489
        ret
500
endp
490
endp
501
 
491
 
502
restore   handle
492
restore   handle
503
restore   io_code
493
restore   io_code
504
restore   input
494
restore   input
505
restore   inp_size
495
restore   inp_size
506
restore   output
496
restore   output
507
restore   out_size
497
restore   out_size
508
 
498
 
509
 
499
 
510
align 4
500
align 4
511
proc ac97_irq_VIA
501
proc ac97_irq_VIA
512
           locals
502
           locals
513
             status db 0
503
             status db 0
514
           endl
504
           endl
515
 
505
 
516
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS
506
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS
517
        call    [ctrl.ctrl_read8]
507
        call    [ctrl.ctrl_read8]
518
        test    al, VIA_REG_STAT_ACTIVE
508
        test    al, VIA_REG_STAT_ACTIVE
519
        jz      @f
509
        jz      @f
520
 
510
 
521
        and     al, VIA_REG_STAT_EOL or VIA_REG_STAT_FLAG or VIA_REG_STAT_STOPPED
511
        and     al, VIA_REG_STAT_EOL or VIA_REG_STAT_FLAG or VIA_REG_STAT_STOPPED
522
        mov     byte [status], al
512
        mov     byte [status], al
523
 
513
 
524
        mov     ebx, dword [buff_list]
514
        mov     ebx, dword [buff_list]
525
        cmp     [ctrl.user_callback], 0
515
        cmp     [ctrl.user_callback], 0
526
        je      @f
516
        je      @f
527
        stdcall [ctrl.user_callback], ebx
517
        stdcall [ctrl.user_callback], ebx
528
       @@:
518
       @@:
529
        mov     al, byte [status]               ;; ack ;;
519
        mov     al, byte [status]               ;; ack ;;
530
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS
520
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS
531
        call    [ctrl.ctrl_write8]
521
        call    [ctrl.ctrl_write8]
532
 
522
 
533
        ret
523
        ret
534
endp
524
endp
535
 
525
 
536
 
526
 
537
align 4
527
align 4
538
proc create_primary_buff
528
proc create_primary_buff
539
 
529
 
540
        invoke  KernelAlloc, 0x10000
530
        invoke  KernelAlloc, 0x10000
541
        mov     [ctrl.buffer], eax
531
        mov     [ctrl.buffer], eax
542
 
532
 
543
        mov     edi, eax
533
        mov     edi, eax
544
        mov     ecx, 0x10000/4
534
        mov     ecx, 0x10000/4
545
        xor     eax, eax
535
        xor     eax, eax
546
        cld
536
        cld
547
        rep stosd
537
        rep stosd
548
 
538
 
549
        mov     eax, [ctrl.buffer]
539
        mov     eax, [ctrl.buffer]
550
        invoke  GetPgAddr
540
        invoke  GetPgAddr
551
        mov     edi, pcmout_bdl
541
        mov     edi, pcmout_bdl
552
        stosd
542
        stosd
553
        mov     eax, 0x80004000
543
        mov     eax, 0x80004000
554
        stosd
544
        stosd
555
 
545
 
556
        mov     edi, buff_list
546
        mov     edi, buff_list
557
        mov     eax, [ctrl.buffer]
547
        mov     eax, [ctrl.buffer]
558
        mov     ecx, 4
548
        mov     ecx, 4
559
@@:
549
@@:
560
        mov     [edi], eax
550
        mov     [edi], eax
561
        mov     [edi+16], eax
551
        mov     [edi+16], eax
562
        mov     [edi+32], eax
552
        mov     [edi+32], eax
563
        mov     [edi+48], eax
553
        mov     [edi+48], eax
564
        mov     [edi+64], eax
554
        mov     [edi+64], eax
565
        mov     [edi+80], eax
555
        mov     [edi+80], eax
566
        mov     [edi+96], eax
556
        mov     [edi+96], eax
567
        mov     [edi+112], eax
557
        mov     [edi+112], eax
568
 
558
 
569
           ;add      eax, 0x4000
559
           ;add      eax, 0x4000
570
        add     edi, 4
560
        add     edi, 4
571
        loop    @B
561
        loop    @B
572
 
562
 
573
        stdcall channel_reset, VIADEV_PLAYBACK
563
        stdcall channel_reset, VIADEV_PLAYBACK
574
        stdcall codec_check_ready
564
        stdcall codec_check_ready
575
 
565
 
576
        mov     eax, pcmout_bdl
566
        mov     eax, pcmout_bdl
577
        mov     ebx, eax
567
        mov     ebx, eax
578
        invoke  GetPgAddr
568
        invoke  GetPgAddr
579
        and     ebx, 0xFFF
569
        and     ebx, 0xFFF
580
        add     eax, ebx
570
        add     eax, ebx
581
 
571
 
582
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR
572
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR
583
        call    [ctrl.ctrl_write32]
573
        call    [ctrl.ctrl_write32]
584
 
574
 
585
        stdcall codec_check_ready
575
        stdcall codec_check_ready
586
 
576
 
587
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_L
577
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_L
588
        mov     eax, 7    ;31
578
        mov     eax, 7    ;31
589
        call    [ctrl.ctrl_write8]
579
        call    [ctrl.ctrl_write8]
590
 
580
 
591
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_R
581
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_R
592
        mov     eax, 7    ;31
582
        mov     eax, 7    ;31
593
        call    [ctrl.ctrl_write8]
583
        call    [ctrl.ctrl_write8]
594
 
584
 
595
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX
585
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX
596
        mov     eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
586
        mov     eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
597
        mov     [ctrl.lvi_reg], 16  ;0xF;eax
587
        mov     [ctrl.lvi_reg], 16  ;0xF;eax
598
        call    [ctrl.ctrl_write32]
588
        call    [ctrl.ctrl_write32]
599
 
589
 
600
        stdcall codec_check_ready
590
        stdcall codec_check_ready
601
        ret
591
        ret
602
endp
592
endp
603
 
593
 
604
 
594
 
605
proc channel_reset channel:dword
595
proc channel_reset channel:dword
606
        mov     esi, dword [channel]
596
        mov     esi, dword [channel]
607
        mov     edx, esi
597
        mov     edx, esi
608
        add     edx, VIA_REG_OFFSET_CONTROL
598
        add     edx, VIA_REG_OFFSET_CONTROL
609
        mov     eax, VIA_REG_CTRL_PAUSE or VIA_REG_CTRL_TERMINATE or VIA_REG_CTRL_RESET
599
        mov     eax, VIA_REG_CTRL_PAUSE or VIA_REG_CTRL_TERMINATE or VIA_REG_CTRL_RESET
610
        call    [ctrl.ctrl_write8]
600
        call    [ctrl.ctrl_write8]
611
 
601
 
612
        mov     edx, esi
602
        mov     edx, esi
613
        add     edx, VIA_REG_OFFSET_CONTROL
603
        add     edx, VIA_REG_OFFSET_CONTROL
614
        call    [ctrl.ctrl_read8]
604
        call    [ctrl.ctrl_read8]
615
 
605
 
616
        mov     eax, 50000       ; wait 50 ms
606
        mov     eax, 50000       ; wait 50 ms
617
        call    StallExec
607
        call    StallExec
618
           ; disable interrupts
608
           ; disable interrupts
619
        mov     edx, esi
609
        mov     edx, esi
620
        add     edx, VIA_REG_OFFSET_CONTROL
610
        add     edx, VIA_REG_OFFSET_CONTROL
621
        xor     eax, eax
611
        xor     eax, eax
622
        call    [ctrl.ctrl_write8]
612
        call    [ctrl.ctrl_write8]
623
 
613
 
624
           ; clear interrupts
614
           ; clear interrupts
625
        mov     edx, esi
615
        mov     edx, esi
626
        add     edx, VIA_REG_OFFSET_STATUS
616
        add     edx, VIA_REG_OFFSET_STATUS
627
        mov     eax, 0x03
617
        mov     eax, 0x03
628
        call    [ctrl.ctrl_write8]
618
        call    [ctrl.ctrl_write8]
629
 
619
 
630
        ;outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */
620
        ;outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */
631
          ; mov      edx, esi                  ;; for via686
621
          ; mov      edx, esi                  ;; for via686
632
          ; add      edx, VIA_REG_OFFSET_TYPE
622
          ; add      edx, VIA_REG_OFFSET_TYPE
633
          ; mov      eax, 0x03
623
          ; mov      eax, 0x03
634
          ; call     [ctrl.ctrl_write8]
624
          ; call     [ctrl.ctrl_write8]
635
 
625
 
636
        ;; outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR));
626
        ;; outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR));
637
           ;mov      edx, esi
627
           ;mov      edx, esi
638
           ;add      edx, VIA_REG_OFFSET_CURR_PTR
628
           ;add      edx, VIA_REG_OFFSET_CURR_PTR
639
           ;xor      eax, eax
629
           ;xor      eax, eax
640
           ;call     [ctrl.ctrl_write8]
630
           ;call     [ctrl.ctrl_write8]
641
 
631
 
642
        ret
632
        ret
643
endp
633
endp
644
 
634
 
645
 
635
 
646
align 4
636
align 4
647
proc detect_controller
637
proc detect_controller
648
           locals
638
           locals
649
             last_bus dd ?
639
             last_bus dd ?
650
             bus      dd ?
640
             bus      dd ?
651
             devfn    dd ?
641
             devfn    dd ?
652
           endl
642
           endl
653
 
643
 
654
        xor     eax, eax
644
        xor     eax, eax
655
        mov     [bus], eax
645
        mov     [bus], eax
656
        inc     eax
646
        inc     eax
657
        invoke  PciApi
647
        invoke  PciApi
658
        cmp     eax, -1
648
        cmp     eax, -1
659
        je      .err
649
        je      .err
660
 
650
 
661
        mov     [last_bus], eax
651
        mov     [last_bus], eax
662
 
652
 
663
.next_bus:
653
.next_bus:
664
        and     [devfn], 0
654
        and     [devfn], 0
665
.next_dev:
655
.next_dev:
666
        invoke  PciRead32, [bus], [devfn], dword 0
656
        invoke  PciRead32, [bus], [devfn], dword 0
667
        test    eax, eax
657
        test    eax, eax
668
        jz      .next
658
        jz      .next
669
        cmp     eax, -1
659
        cmp     eax, -1
670
        je      .next
660
        je      .next
671
 
661
 
672
        mov     edi, devices
662
        mov     edi, devices
673
@@:
663
@@:
674
        mov     ebx, [edi]
664
        mov     ebx, [edi]
675
        test    ebx, ebx
665
        test    ebx, ebx
676
        jz      .next
666
        jz      .next
677
 
667
 
678
        cmp     eax, ebx
668
        cmp     eax, ebx
679
        je      .found
669
        je      .found
680
        add     edi, 12
670
        add     edi, 12
681
        jmp     @B
671
        jmp     @B
682
.next:
672
.next:
683
        inc     [devfn]
673
        inc     [devfn]
684
        cmp     [devfn], 256
674
        cmp     [devfn], 256
685
        jb      .next_dev
675
        jb      .next_dev
686
        mov     eax, [bus]
676
        mov     eax, [bus]
687
        inc     eax
677
        inc     eax
688
        mov     [bus], eax
678
        mov     [bus], eax
689
        cmp     eax, [last_bus]
679
        cmp     eax, [last_bus]
690
        jna     .next_bus
680
        jna     .next_bus
691
        xor     eax, eax
681
        xor     eax, eax
692
        ret
682
        ret
693
.found:
683
.found:
694
        mov     ebx, [bus]
684
        mov     ebx, [bus]
695
        mov     [ctrl.bus], ebx
685
        mov     [ctrl.bus], ebx
696
 
686
 
697
        mov     ecx, [devfn]
687
        mov     ecx, [devfn]
698
        mov     [ctrl.devfn], ecx
688
        mov     [ctrl.devfn], ecx
699
 
689
 
700
        mov     edx, eax
690
        mov     edx, eax
701
        and     edx, 0xFFFF
691
        and     edx, 0xFFFF
702
        mov     [ctrl.vendor], edx
692
        mov     [ctrl.vendor], edx
703
        shr     eax, 16
693
        shr     eax, 16
704
        mov     [ctrl.dev_id], eax
694
        mov     [ctrl.dev_id], eax
705
 
695
 
706
        mov     ebx, [edi+4]
696
        mov     ebx, [edi+4]
707
        mov     [ctrl.ctrl_ids], ebx
697
        mov     [ctrl.ctrl_ids], ebx
708
        mov     esi, [edi+8]
698
        mov     esi, [edi+8]
709
        mov     [ctrl.ctrl_setup], esi
699
        mov     [ctrl.ctrl_setup], esi
710
 
700
 
711
        cmp     edx, VID_VIA
701
        cmp     edx, VID_VIA
712
        jne     @F
702
        jne     @F
713
        mov     [ctrl.vendor_ids], msg_VIA
703
        mov     [ctrl.vendor_ids], msg_VIA
714
        ret
704
        ret
715
@@:
705
@@:
716
 
706
 
717
.err:
707
.err:
718
        xor     eax, eax
708
        xor     eax, eax
719
        mov     [ctrl.vendor_ids], eax    ;something  wrong ?
709
        mov     [ctrl.vendor_ids], eax    ;something  wrong ?
720
        ret
710
        ret
721
endp
711
endp
722
 
712
 
723
align 4
713
align 4
724
proc init_controller
714
proc init_controller
725
 
715
 
726
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
716
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
727
        mov     ebx, eax
717
        mov     ebx, eax
728
        and     eax, 0xFFFF
718
        and     eax, 0xFFFF
729
        mov     [ctrl.pci_cmd], eax
719
        mov     [ctrl.pci_cmd], eax
730
        shr     ebx, 16
720
        shr     ebx, 16
731
        mov     [ctrl.pci_stat], ebx
721
        mov     [ctrl.pci_stat], ebx
732
 
722
 
733
        mov     esi, msgPciCmd
723
        mov     esi, msgPciCmd
734
        invoke  SysMsgBoardStr
724
        invoke  SysMsgBoardStr
735
        call    dword2str
725
        call    dword2str
736
        invoke  SysMsgBoardStr
726
        invoke  SysMsgBoardStr
737
 
727
 
738
        mov     esi, msgPciStat
728
        mov     esi, msgPciStat
739
        invoke  SysMsgBoardStr
729
        invoke  SysMsgBoardStr
740
        mov     eax, [ctrl.pci_stat]
730
        mov     eax, [ctrl.pci_stat]
741
        call    dword2str
731
        call    dword2str
742
        invoke  SysMsgBoardStr
732
        invoke  SysMsgBoardStr
743
 
733
 
744
        mov     esi, msgCtrlIsaIo
734
        mov     esi, msgCtrlIsaIo
745
        invoke  SysMsgBoardStr
735
        invoke  SysMsgBoardStr
746
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
736
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
747
        call    dword2str
737
        call    dword2str
748
        invoke  SysMsgBoardStr
738
        invoke  SysMsgBoardStr
749
 
739
 
750
        and     eax, 0xFFC0
740
        and     eax, 0xFFC0
751
        mov     [ctrl.ctrl_io_base], eax
741
        mov     [ctrl.ctrl_io_base], eax
752
 
742
 
753
.default:
743
.default:
754
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
744
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
755
        and     eax, 0xFF
745
        and     eax, 0xFF
756
@@:
746
@@:
757
        mov     [ctrl.int_line], eax
747
        mov     [ctrl.int_line], eax
758
 
748
 
759
           ;stdcall  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE ;0x42
749
           ;stdcall  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE ;0x42
760
           ;mov      byte [old_legacy], al
750
           ;mov      byte [old_legacy], al
761
 
751
 
762
           ;stdcall  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_PNP_CONTROL ;0x43
752
           ;stdcall  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_PNP_CONTROL ;0x43
763
           ;mov      byte [old_legacy_cfg], al
753
           ;mov      byte [old_legacy_cfg], al
764
 
754
 
765
           ;mov      al, VIA_FUNC_ENABLE_SB or VIA_FUNC_ENABLE_FM
755
           ;mov      al, VIA_FUNC_ENABLE_SB or VIA_FUNC_ENABLE_FM
766
           ;xor      al, 0xFF
756
           ;xor      al, 0xFF
767
           ;and      al, byte [old_legacy]
757
           ;and      al, byte [old_legacy]
768
           ;and      eax, 0xFF
758
           ;and      eax, 0xFF
769
           ;stdcall  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE, eax ;0x42
759
           ;stdcall  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE, eax ;0x42
770
           ;mov      byte [old_legacy], al
760
           ;mov      byte [old_legacy], al
771
 
761
 
772
        call    [ctrl.ctrl_setup]
762
        call    [ctrl.ctrl_setup]
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
align 4
768
align 4
779
proc set_VIA
769
proc set_VIA
780
        mov     [ctrl.codec_read16], codec_io_r16         ;virtual
770
        mov     [ctrl.codec_read16], codec_io_r16         ;virtual
781
        mov     [ctrl.codec_write16], codec_io_w16        ;virtual
771
        mov     [ctrl.codec_write16], codec_io_w16        ;virtual
782
 
772
 
783
        mov     [ctrl.ctrl_read8 ], ctrl_io_r8            ;virtual
773
        mov     [ctrl.ctrl_read8 ], ctrl_io_r8            ;virtual
784
        mov     [ctrl.ctrl_read16], ctrl_io_r16           ;virtual
774
        mov     [ctrl.ctrl_read16], ctrl_io_r16           ;virtual
785
        mov     [ctrl.ctrl_read32], ctrl_io_r32           ;virtual
775
        mov     [ctrl.ctrl_read32], ctrl_io_r32           ;virtual
786
 
776
 
787
        mov     [ctrl.ctrl_write8 ], ctrl_io_w8           ;virtual
777
        mov     [ctrl.ctrl_write8 ], ctrl_io_w8           ;virtual
788
        mov     [ctrl.ctrl_write16], ctrl_io_w16          ;virtual
778
        mov     [ctrl.ctrl_write16], ctrl_io_w16          ;virtual
789
        mov     [ctrl.ctrl_write32], ctrl_io_w32          ;virtual
779
        mov     [ctrl.ctrl_write32], ctrl_io_w32          ;virtual
790
        ret
780
        ret
791
endp
781
endp
792
 
782
 
793
 
783
 
794
align 4
784
align 4
795
proc init_codec
785
proc init_codec
796
           locals
786
           locals
797
             counter dd ?
787
             counter dd ?
798
           endl
788
           endl
799
 
789
 
800
        mov     esi, msgControl
790
        mov     esi, msgControl
801
        invoke  SysMsgBoardStr
791
        invoke  SysMsgBoardStr
802
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
792
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
803
        and     eax, 0xFF
793
        and     eax, 0xFF
804
        call    dword2str
794
        call    dword2str
805
        invoke  SysMsgBoardStr
795
        invoke  SysMsgBoardStr
806
 
796
 
807
        mov     esi, msgStatus
797
        mov     esi, msgStatus
808
        invoke  SysMsgBoardStr
798
        invoke  SysMsgBoardStr
809
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
799
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
810
        and     eax, 0xFF
800
        and     eax, 0xFF
811
        push    eax
801
        push    eax
812
        call    dword2str
802
        call    dword2str
813
        invoke  SysMsgBoardStr
803
        invoke  SysMsgBoardStr
814
        pop     eax
804
        pop     eax
815
 
805
 
816
        test    eax, VIA_ACLINK_C00_READY
806
        test    eax, VIA_ACLINK_C00_READY
817
        jnz     .ready
807
        jnz     .ready
818
 
808
 
819
        call    reset_codec
809
        call    reset_codec
820
        test    eax, eax
810
        test    eax, eax
821
        jz      .err
811
        jz      .err
822
 
812
 
823
.ready:
813
.ready:
824
        xor     edx, edx         ; ac_reg_0
814
        xor     edx, edx         ; ac_reg_0
825
        call    [ctrl.codec_write16]
815
        call    [ctrl.codec_write16]
826
        jmp     .done
816
        jmp     .done
827
 
817
 
828
.err:
818
.err:
829
        xor     eax, eax              ; timeout error
819
        xor     eax, eax              ; timeout error
830
        ret
820
        ret
831
 
821
 
832
.done:
822
.done:
833
        call    detect_codec
823
        call    detect_codec
834
 
824
 
835
        xor     eax, eax
825
        xor     eax, eax
836
        inc     eax
826
        inc     eax
837
        ret
827
        ret
838
endp
828
endp
839
 
829
 
840
align 4
830
align 4
841
proc reset_codec
831
proc reset_codec
842
        invoke  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \
832
        invoke  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \
843
                VIA_ACLINK_CTRL_ENABLE or VIA_ACLINK_CTRL_RESET or VIA_ACLINK_CTRL_SYNC
833
                VIA_ACLINK_CTRL_ENABLE or VIA_ACLINK_CTRL_RESET or VIA_ACLINK_CTRL_SYNC
844
        mov     eax, 100000        ; wait 100 ms
834
        mov     eax, 100000        ; wait 100 ms
845
        call    StallExec
835
        call    StallExec
846
.cold:
836
.cold:
847
        call    cold_reset
837
        call    cold_reset
848
        jnc     .ok
838
        jnc     .ok
849
 
839
 
850
     if DEBUG
840
     if DEBUG
851
        mov     esi, msgCFail
841
        mov     esi, msgCFail
852
        invoke  SysMsgBoardStr
842
        invoke  SysMsgBoardStr
853
     end if
843
     end if
854
        xor     eax, eax         ; timeout error
844
        xor     eax, eax         ; timeout error
855
        ret
845
        ret
856
.ok:
846
.ok:
857
     if DEBUG
847
     if DEBUG
858
        mov     esi, msgResetOk
848
        mov     esi, msgResetOk
859
        invoke  SysMsgBoardStr
849
        invoke  SysMsgBoardStr
860
     end if
850
     end if
861
        xor     eax, eax
851
        xor     eax, eax
862
        inc     eax
852
        inc     eax
863
        ret
853
        ret
864
endp
854
endp
865
 
855
 
866
 
856
 
867
align 4
857
align 4
868
proc cold_reset
858
proc cold_reset
869
           locals
859
           locals
870
             counter dd ?
860
             counter dd ?
871
           endl
861
           endl
872
 
862
 
873
        invoke  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0
863
        invoke  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0
874
 
864
 
875
     if DEBUG
865
     if DEBUG
876
        mov     esi, msgCold
866
        mov     esi, msgCold
877
        invoke  SysMsgBoardStr
867
        invoke  SysMsgBoardStr
878
     end if
868
     end if
879
 
869
 
880
        mov     eax, 100000         ; wait 100 ms ;400000     ; wait 400 ms
870
        mov     eax, 100000         ; wait 100 ms ;400000     ; wait 400 ms
881
        call    StallExec
871
        call    StallExec
882
 
872
 
883
           ;; ACLink on, deassert ACLink reset, VSR, SGD data out
873
           ;; ACLink on, deassert ACLink reset, VSR, SGD data out
884
           ;; note - FM data out has trouble with non VRA codecs !!
874
           ;; note - FM data out has trouble with non VRA codecs !!
885
        invoke  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT
875
        invoke  PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT
886
 
876
 
887
        mov     [counter], 16        ; total 20*100 ms = 2s
877
        mov     [counter], 16        ; total 20*100 ms = 2s
888
.wait:
878
.wait:
889
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
879
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
890
        test    eax, VIA_ACLINK_C00_READY
880
        test    eax, VIA_ACLINK_C00_READY
891
        jnz     .ok
881
        jnz     .ok
892
 
882
 
893
        mov     eax, 100000        ; wait 100 ms
883
        mov     eax, 100000        ; wait 100 ms
894
        call    StallExec
884
        call    StallExec
895
 
885
 
896
        dec     [counter]
886
        dec     [counter]
897
        jnz     .wait
887
        jnz     .wait
898
 
888
 
899
     if DEBUG
889
     if DEBUG
900
        mov     esi, msgCRFail
890
        mov     esi, msgCRFail
901
        invoke  SysMsgBoardStr
891
        invoke  SysMsgBoardStr
902
     end if
892
     end if
903
 
893
 
904
.fail:
894
.fail:
905
        stc
895
        stc
906
        ret
896
        ret
907
.ok:
897
.ok:
908
        mov     esi, msgControl
898
        mov     esi, msgControl
909
        invoke  SysMsgBoardStr
899
        invoke  SysMsgBoardStr
910
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
900
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
911
        call    dword2str
901
        call    dword2str
912
        invoke  SysMsgBoardStr
902
        invoke  SysMsgBoardStr
913
 
903
 
914
        mov     esi, msgStatus
904
        mov     esi, msgStatus
915
        invoke  SysMsgBoardStr
905
        invoke  SysMsgBoardStr
916
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
906
        invoke  PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
917
        and     eax, 0xFF
907
        and     eax, 0xFF
918
        push    eax
908
        push    eax
919
        call    dword2str
909
        call    dword2str
920
        invoke  SysMsgBoardStr
910
        invoke  SysMsgBoardStr
921
        pop     eax
911
        pop     eax
922
 
912
 
923
        test    eax, VIA_ACLINK_C00_READY     ;CTRL_ST_CREADY
913
        test    eax, VIA_ACLINK_C00_READY     ;CTRL_ST_CREADY
924
        jz      .fail
914
        jz      .fail
925
        clc
915
        clc
926
        ret
916
        ret
927
endp
917
endp
928
 
918
 
929
align 4
919
align 4
930
play:
920
play:
931
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX
921
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX
932
        mov     eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
922
        mov     eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
933
        mov     [ctrl.lvi_reg], 16
923
        mov     [ctrl.lvi_reg], 16
934
        call    [ctrl.ctrl_write32]
924
        call    [ctrl.ctrl_write32]
935
 
925
 
936
        mov     eax, VIA_REG_CTRL_INT
926
        mov     eax, VIA_REG_CTRL_INT
937
        or      eax, VIA_REG_CTRL_START
927
        or      eax, VIA_REG_CTRL_START
938
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL
928
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL
939
        call    [ctrl.ctrl_write8]
929
        call    [ctrl.ctrl_write8]
940
 
930
 
941
        xor     eax, eax
931
        xor     eax, eax
942
        ret
932
        ret
943
 
933
 
944
align 4
934
align 4
945
stop:
935
stop:
946
        mov     eax, VIA_REG_CTRL_INT
936
        mov     eax, VIA_REG_CTRL_INT
947
        or      eax, VIA_REG_CTRL_TERMINATE
937
        or      eax, VIA_REG_CTRL_TERMINATE
948
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL
938
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL
949
        call    [ctrl.ctrl_write8]
939
        call    [ctrl.ctrl_write8]
950
 
940
 
951
        stdcall channel_reset, VIADEV_PLAYBACK
941
        stdcall channel_reset, VIADEV_PLAYBACK
952
        xor     eax, eax
942
        xor     eax, eax
953
        ret
943
        ret
954
 
944
 
955
align 4
945
align 4
956
proc get_dev_info stdcall, p_info:dword
946
proc get_dev_info stdcall, p_info:dword
957
           virtual at esi
947
           virtual at esi
958
             CTRL_INFO CTRL_INFO
948
             CTRL_INFO CTRL_INFO
959
           end virtual
949
           end virtual
960
 
950
 
961
        mov     esi, [p_info]
951
        mov     esi, [p_info]
962
        mov     eax, [ctrl.int_line]
952
        mov     eax, [ctrl.int_line]
963
        mov     ecx, [ctrl.ctrl_io_base]
953
        mov     ecx, [ctrl.ctrl_io_base]
964
        mov     [CTRL_INFO.irq], eax
954
        mov     [CTRL_INFO.irq], eax
965
        mov     [CTRL_INFO.ctrl_io_base], ecx
955
        mov     [CTRL_INFO.ctrl_io_base], ecx
966
 
956
 
967
        xor     eax, eax
957
        xor     eax, eax
968
           ;mov      edx, VIADEV_PLAYBACK   +VIA_REG_OFFSET_TABLE_PTR
958
           ;mov      edx, VIADEV_PLAYBACK   +VIA_REG_OFFSET_TABLE_PTR
969
           ;call     [ctrl.ctrl_read32]
959
           ;call     [ctrl.ctrl_read32]
970
        mov     [CTRL_INFO.codec_io_base], eax
960
        mov     [CTRL_INFO.codec_io_base], eax
971
           ;mov      edx, VIADEV_PLAYBACK   +VIA_REG_OFFSET_STOP_IDX
961
           ;mov      edx, VIADEV_PLAYBACK   +VIA_REG_OFFSET_STOP_IDX
972
           ;call     [ctrl.ctrl_read32]
962
           ;call     [ctrl.ctrl_read32]
973
        mov     [CTRL_INFO.codec_mem_base], eax
963
        mov     [CTRL_INFO.codec_mem_base], eax
974
           ;mov      edx, VIADEV_PLAYBACK   +VIA_REG_OFFSET_CURR_COUNT
964
           ;mov      edx, VIADEV_PLAYBACK   +VIA_REG_OFFSET_CURR_COUNT
975
           ;call     [ctrl.ctrl_read32]
965
           ;call     [ctrl.ctrl_read32]
976
        mov     [CTRL_INFO.ctrl_mem_base], eax
966
        mov     [CTRL_INFO.ctrl_mem_base], eax
977
 
967
 
978
        mov     eax, [codec.chip_id]
968
        mov     eax, [codec.chip_id]
979
        mov     [CTRL_INFO.codec_id], eax
969
        mov     [CTRL_INFO.codec_id], eax
980
 
970
 
981
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL
971
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL
982
        call    [ctrl.ctrl_read8]
972
        call    [ctrl.ctrl_read8]
983
        and     eax, 0xFF
973
        and     eax, 0xFF
984
        mov     [CTRL_INFO.glob_cntrl], eax
974
        mov     [CTRL_INFO.glob_cntrl], eax
985
 
975
 
986
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS
976
        mov     edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS
987
        call    [ctrl.ctrl_read8]
977
        call    [ctrl.ctrl_read8]
988
        and     eax, 0xFF
978
        and     eax, 0xFF
989
        mov     [CTRL_INFO.glob_sta], eax
979
        mov     [CTRL_INFO.glob_sta], eax
990
 
980
 
991
        mov     ebx, [ctrl.pci_cmd]
981
        mov     ebx, [ctrl.pci_cmd]
992
        mov     [CTRL_INFO.pci_cmd], ebx
982
        mov     [CTRL_INFO.pci_cmd], ebx
993
        ret
983
        ret
994
endp
984
endp
995
 
985
 
996
align 4
986
align 4
997
proc set_callback stdcall, handler:dword
987
proc set_callback stdcall, handler:dword
998
        mov     eax, [handler]
988
        mov     eax, [handler]
999
        mov     [ctrl.user_callback], eax
989
        mov     [ctrl.user_callback], eax
1000
        ret
990
        ret
1001
endp
991
endp
1002
 
992
 
1003
 
993
 
1004
align 4
994
align 4
1005
proc codec_check_ready stdcall
995
proc codec_check_ready stdcall
1006
           locals
996
           locals
1007
             counter dd ?
997
             counter dd ?
1008
           endl
998
           endl
1009
 
999
 
1010
        mov     [counter], 1000         ; total 1000*1 ms = 1s
1000
        mov     [counter], 1000         ; total 1000*1 ms = 1s
1011
.wait:
1001
.wait:
1012
        call    [ctrl.codec_read16]
1002
        call    [ctrl.codec_read16]
1013
        test    eax, VIA_REG_AC97_BUSY
1003
        test    eax, VIA_REG_AC97_BUSY
1014
        jz      .ok
1004
        jz      .ok
1015
 
1005
 
1016
        mov     eax, 1000       ; wait 1 ms
1006
        mov     eax, 1000       ; wait 1 ms
1017
        call    StallExec
1007
        call    StallExec
1018
 
1008
 
1019
        sub     [counter] , 1
1009
        sub     [counter] , 1
1020
        jnz     .wait
1010
        jnz     .wait
1021
.err:
1011
.err:
1022
        mov     eax, -1
1012
        mov     eax, -1
1023
        ret
1013
        ret
1024
.ok:
1014
.ok:
1025
        and     eax, 0xFFFF
1015
        and     eax, 0xFFFF
1026
        ret
1016
        ret
1027
endp
1017
endp
1028
 
1018
 
1029
 
1019
 
1030
align 4
1020
align 4
1031
proc codec_valid stdcall
1021
proc codec_valid stdcall
1032
        stdcall codec_check_ready
1022
        stdcall codec_check_ready
1033
        ret
1023
        ret
1034
endp
1024
endp
1035
 
1025
 
1036
align 4
1026
align 4
1037
proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
1027
proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
1038
           locals
1028
           locals
1039
             counter dd ?
1029
             counter dd ?
1040
           endl
1030
           endl
1041
 
1031
 
1042
           ;Use only primary codec.
1032
           ;Use only primary codec.
1043
        mov     eax, [ac_reg]
1033
        mov     eax, [ac_reg]
1044
        and     eax, 0x7F
1034
        and     eax, 0x7F
1045
        shl     eax, VIA_REG_AC97_CMD_SHIFT
1035
        shl     eax, VIA_REG_AC97_CMD_SHIFT
1046
        or      eax, VIA_REG_AC97_PRIMARY_VALID or VIA_REG_AC97_READ
1036
        or      eax, VIA_REG_AC97_PRIMARY_VALID or VIA_REG_AC97_READ
1047
 
1037
 
1048
        mov     [counter], 3         ; total 3*20 ms = 60ms
1038
        mov     [counter], 3         ; total 3*20 ms = 60ms
1049
.wait:
1039
.wait:
1050
        push    eax
1040
        push    eax
1051
        call    [ctrl.codec_write16]
1041
        call    [ctrl.codec_write16]
1052
 
1042
 
1053
        mov     eax, 20000       ; wait 20 ms
1043
        mov     eax, 20000       ; wait 20 ms
1054
        call    StallExec
1044
        call    StallExec
1055
 
1045
 
1056
        stdcall codec_valid
1046
        stdcall codec_valid
1057
        cmp     eax, 0
1047
        cmp     eax, 0
1058
        pop     eax
1048
        pop     eax
1059
        jge     .ok
1049
        jge     .ok
1060
 
1050
 
1061
        sub     [counter] , 1
1051
        sub     [counter] , 1
1062
        jnz     .wait
1052
        jnz     .wait
1063
        jmp     .err
1053
        jmp     .err
1064
 
1054
 
1065
.ok:
1055
.ok:
1066
        mov     eax, 25000       ; wait 25 ms
1056
        mov     eax, 25000       ; wait 25 ms
1067
        call    StallExec
1057
        call    StallExec
1068
 
1058
 
1069
        call    [ctrl.codec_read16]      ;change edx !!!
1059
        call    [ctrl.codec_read16]      ;change edx !!!
1070
        and     eax, 0xFFFF
1060
        and     eax, 0xFFFF
1071
        ret
1061
        ret
1072
.err:
1062
.err:
1073
     if DEBUG
1063
     if DEBUG
1074
        mov     esi, msgCInvalid
1064
        mov     esi, msgCInvalid
1075
        invoke  SysMsgBoardStr
1065
        invoke  SysMsgBoardStr
1076
     end if
1066
     end if
1077
        mov     eax, -1            ; invalid codec error
1067
        mov     eax, -1            ; invalid codec error
1078
        ret
1068
        ret
1079
endp
1069
endp
1080
 
1070
 
1081
align 4
1071
align 4
1082
proc codec_write stdcall, ac_reg:dword
1072
proc codec_write stdcall, ac_reg:dword
1083
           ;Use only primary codec.
1073
           ;Use only primary codec.
1084
        mov     esi, [ac_reg]
1074
        mov     esi, [ac_reg]
1085
        mov     edx, esi
1075
        mov     edx, esi
1086
        shl     edx, VIA_REG_AC97_CMD_SHIFT
1076
        shl     edx, VIA_REG_AC97_CMD_SHIFT
1087
 
1077
 
1088
        shl     eax, VIA_REG_AC97_DATA_SHIFT
1078
        shl     eax, VIA_REG_AC97_DATA_SHIFT
1089
        or      edx, eax
1079
        or      edx, eax
1090
 
1080
 
1091
        mov     eax, VIA_REG_AC97_CODEC_ID_PRIMARY     ;not VIA_REG_AC97_CODEC_ID_PRIMARY
1081
        mov     eax, VIA_REG_AC97_CODEC_ID_PRIMARY     ;not VIA_REG_AC97_CODEC_ID_PRIMARY
1092
        shl     eax, VIA_REG_AC97_CODEC_ID_SHIFT
1082
        shl     eax, VIA_REG_AC97_CODEC_ID_SHIFT
1093
        or      edx, eax
1083
        or      edx, eax
1094
 
1084
 
1095
        mov     eax, edx
1085
        mov     eax, edx
1096
        mov     edx, esi
1086
        mov     edx, esi
1097
        call    [ctrl.codec_write16]
1087
        call    [ctrl.codec_write16]
1098
        mov     [codec.regs+esi], ax
1088
        mov     [codec.regs+esi], ax
1099
 
1089
 
1100
        stdcall codec_check_ready
1090
        stdcall codec_check_ready
1101
        cmp     eax, 0
1091
        cmp     eax, 0
1102
        jl      .err
1092
        jl      .err
1103
.ok:
1093
.ok:
1104
        ret
1094
        ret
1105
.err:
1095
.err:
1106
     if DEBUG
1096
     if DEBUG
1107
        mov     esi, msgCFail
1097
        mov     esi, msgCFail
1108
        invoke  SysMsgBoardStr
1098
        invoke  SysMsgBoardStr
1109
     end if
1099
     end if
1110
           ;mov      eax, -1        ; codec not ready error
1100
           ;mov      eax, -1        ; codec not ready error
1111
        ret
1101
        ret
1112
endp
1102
endp
1113
 
1103
 
1114
align 4
1104
align 4
1115
proc StallExec
1105
proc StallExec
1116
        push    ecx
1106
        push    ecx
1117
        push    edx
1107
        push    edx
1118
        push    ebx
1108
        push    ebx
1119
        push    eax
1109
        push    eax
1120
 
1110
 
1121
        mov     ecx, CPU_FREQ
1111
        mov     ecx, CPU_FREQ
1122
        mul     ecx
1112
        mul     ecx
1123
        mov     ebx, eax           ;low
1113
        mov     ebx, eax           ;low
1124
        mov     ecx, edx           ;high
1114
        mov     ecx, edx           ;high
1125
        rdtsc
1115
        rdtsc
1126
        add     ebx, eax
1116
        add     ebx, eax
1127
        adc     ecx, edx
1117
        adc     ecx, edx
1128
@@:
1118
@@:
1129
        rdtsc
1119
        rdtsc
1130
        sub     eax, ebx
1120
        sub     eax, ebx
1131
        sbb     edx, ecx
1121
        sbb     edx, ecx
1132
        js      @B
1122
        js      @B
1133
 
1123
 
1134
        pop     eax
1124
        pop     eax
1135
        pop     ebx
1125
        pop     ebx
1136
        pop     edx
1126
        pop     edx
1137
        pop     ecx
1127
        pop     ecx
1138
        ret
1128
        ret
1139
endp
1129
endp
1140
 
1130
 
1141
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1142
;          CONTROLLER IO functions
1132
;          CONTROLLER IO functions
1143
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1133
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1144
 
1134
 
1145
align 4
1135
align 4
1146
proc codec_io_r16 ;r32
1136
proc codec_io_r16 ;r32
1147
        mov     edx, [ctrl.ctrl_io_base]
1137
        mov     edx, [ctrl.ctrl_io_base]
1148
        add     edx, VIA_REG_AC97
1138
        add     edx, VIA_REG_AC97
1149
        in      eax, dx
1139
        in      eax, dx
1150
        ret
1140
        ret
1151
endp
1141
endp
1152
 
1142
 
1153
align 4
1143
align 4
1154
proc codec_io_w16 ;w32
1144
proc codec_io_w16 ;w32
1155
        mov     edx, [ctrl.ctrl_io_base]
1145
        mov     edx, [ctrl.ctrl_io_base]
1156
        add     edx, VIA_REG_AC97
1146
        add     edx, VIA_REG_AC97
1157
        out     dx, eax
1147
        out     dx, eax
1158
        ret
1148
        ret
1159
endp
1149
endp
1160
 
1150
 
1161
align 4
1151
align 4
1162
proc ctrl_io_r8
1152
proc ctrl_io_r8
1163
        add     edx, [ctrl.ctrl_io_base]
1153
        add     edx, [ctrl.ctrl_io_base]
1164
        in      al, dx
1154
        in      al, dx
1165
        ret
1155
        ret
1166
endp
1156
endp
1167
 
1157
 
1168
align 4
1158
align 4
1169
proc ctrl_io_r16
1159
proc ctrl_io_r16
1170
        add     edx, [ctrl.ctrl_io_base]
1160
        add     edx, [ctrl.ctrl_io_base]
1171
        in      ax, dx
1161
        in      ax, dx
1172
        ret
1162
        ret
1173
endp
1163
endp
1174
 
1164
 
1175
align 4
1165
align 4
1176
proc ctrl_io_r32
1166
proc ctrl_io_r32
1177
        add     edx, [ctrl.ctrl_io_base]
1167
        add     edx, [ctrl.ctrl_io_base]
1178
        in      eax, dx
1168
        in      eax, dx
1179
        ret
1169
        ret
1180
endp
1170
endp
1181
 
1171
 
1182
align 4
1172
align 4
1183
proc ctrl_io_w8
1173
proc ctrl_io_w8
1184
        add     edx, [ctrl.ctrl_io_base]
1174
        add     edx, [ctrl.ctrl_io_base]
1185
        out     dx, al
1175
        out     dx, al
1186
        ret
1176
        ret
1187
endp
1177
endp
1188
 
1178
 
1189
align 4
1179
align 4
1190
proc ctrl_io_w16
1180
proc ctrl_io_w16
1191
        add     edx, [ctrl.ctrl_io_base]
1181
        add     edx, [ctrl.ctrl_io_base]
1192
        out     dx, ax
1182
        out     dx, ax
1193
        ret
1183
        ret
1194
endp
1184
endp
1195
 
1185
 
1196
align 4
1186
align 4
1197
proc ctrl_io_w32
1187
proc ctrl_io_w32
1198
        add     edx, [ctrl.ctrl_io_base]
1188
        add     edx, [ctrl.ctrl_io_base]
1199
        out     dx, eax
1189
        out     dx, eax
1200
        ret
1190
        ret
1201
endp
1191
endp
1202
 
1192
 
1203
 
1193
 
1204
align 4
1194
align 4
1205
dword2str:
1195
dword2str:
1206
        push    eax ebx ecx
1196
        push    eax ebx ecx
1207
        mov     esi, hex_buff
1197
        mov     esi, hex_buff
1208
        mov     ecx, -8
1198
        mov     ecx, -8
1209
   @@:
1199
   @@:
1210
        rol     eax, 4
1200
        rol     eax, 4
1211
        mov     ebx, eax
1201
        mov     ebx, eax
1212
        and     ebx, 0x0F
1202
        and     ebx, 0x0F
1213
        mov     bl, [ebx+hexletters]
1203
        mov     bl, [ebx+hexletters]
1214
        mov     [8+esi+ecx], bl
1204
        mov     [8+esi+ecx], bl
1215
        inc     ecx
1205
        inc     ecx
1216
        jnz     @B
1206
        jnz     @B
1217
        pop     ecx ebx eax
1207
        pop     ecx ebx eax
1218
        ret
1208
        ret
1219
 
1209
 
1220
hexletters   db '0123456789ABCDEF'
1210
hexletters   db '0123456789ABCDEF'
1221
hex_buff     db 8 dup(0),13,10,0
1211
hex_buff     db 8 dup(0),13,10,0
1222
 
1212
 
1223
 
1213
 
1224
include "codec.inc"
1214
include "codec.inc"
1225
 
1215
 
1226
align 4
1216
align 4
1227
devices dd (CTRL_VT82C686  shl 16)+VID_VIA,msg_VT82C686,set_VIA
1217
devices dd (CTRL_VT82C686  shl 16)+VID_VIA,msg_VT82C686,set_VIA
1228
        dd (CTRL_VT8233_5  shl 16)+VID_VIA,msg_VT8233,set_VIA
1218
        dd (CTRL_VT8233_5  shl 16)+VID_VIA,msg_VT8233,set_VIA
1229
        dd 0    ;terminator
1219
        dd 0    ;terminator
1230
 
1220
 
1231
 
1221
 
1232
msg_VT82C686 db 'VT82C686', 13,10, 0
1222
msg_VT82C686 db 'VT82C686', 13,10, 0
1233
msg_VT8233   db 'VT8233',   13,10, 0
1223
msg_VT8233   db 'VT8233',   13,10, 0
1234
msg_VIA      db 'VIA'   ,   13,10, 0
1224
msg_VIA      db 'VIA'   ,   13,10, 0
1235
 
1225
 
1236
szKernel            db 'KERNEL', 0
1226
szKernel            db 'KERNEL', 0
1237
sz_sound_srv        db 'SOUND',0
1227
sz_sound_srv        db 'SOUND',0
1238
 
1228
 
1239
msgInit      db 'detect hardware...',13,10,0
1229
msgInit      db 'detect hardware...',13,10,0
1240
msgFail      db 'device not found',13,10,0
1230
msgFail      db 'device not found',13,10,0
1241
msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
-
 
1242
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1231
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1243
msgPlay      db 'start play', 13,10,0
1232
msgPlay      db 'start play', 13,10,0
1244
msgStop      db 'stop play',  13,10,0
1233
msgStop      db 'stop play',  13,10,0
1245
;msgIRQ       db 'AC97 IRQ', 13,10,0
1234
;msgIRQ       db 'AC97 IRQ', 13,10,0
1246
;msgInitCtrl  db 'init controller',13,10,0
1235
;msgInitCtrl  db 'init controller',13,10,0
1247
;msgInitCodec db 'init codec',13,10,0
1236
;msgInitCodec db 'init codec',13,10,0
1248
msgPrimBuff  db 'create primary buffer ...',0
1237
msgPrimBuff  db 'create primary buffer ...',0
1249
msgDone      db 'done',13,10,0
1238
msgDone      db 'done',13,10,0
1250
msgRemap     db 'Remap IRQ',13,10,0
1239
msgRemap     db 'Remap IRQ',13,10,0
1251
;msgReg       db 'set service handler',13,10,0
1240
;msgReg       db 'set service handler',13,10,0
1252
;msgOk        db 'service installed',13,10,0
1241
;msgOk        db 'service installed',13,10,0
1253
msgCold      db 'cold reset',13,10,0
1242
msgCold      db 'cold reset',13,10,0
1254
;msgWarm      db 'warm reset',13,10,0
1243
;msgWarm      db 'warm reset',13,10,0
1255
;msgWRFail    db 'warm reset failed',13,10,0
1244
;msgWRFail    db 'warm reset failed',13,10,0
1256
msgCRFail    db 'cold reset failed',13,10,0
1245
msgCRFail    db 'cold reset failed',13,10,0
1257
msgCFail     db 'codec not ready',13,10,0
1246
msgCFail     db 'codec not ready',13,10,0
1258
msgCInvalid  db 'codec is not valid',13,10,0 ;Asper
1247
msgCInvalid  db 'codec is not valid',13,10,0 ;Asper
1259
msgResetOk   db 'reset complete',13,10,0
1248
msgResetOk   db 'reset complete',13,10,0
1260
msgStatus    db 'global status   ',0
1249
msgStatus    db 'global status   ',0
1261
msgControl   db 'global control  ',0
1250
msgControl   db 'global control  ',0
1262
msgPciCmd    db 'PCI command     ',0
1251
msgPciCmd    db 'PCI command     ',0
1263
msgPciStat   db 'PCI status      ',0
1252
msgPciStat   db 'PCI status      ',0
1264
msgCtrlIsaIo db 'controller io base   ',0
1253
msgCtrlIsaIo db 'controller io base   ',0
1265
;msgMixIsaIo  db 'codec io base        ',0
1254
;msgMixIsaIo  db 'codec io base        ',0
1266
;msgCtrlMMIo  db 'controller mmio base ',0
1255
;msgCtrlMMIo  db 'controller mmio base ',0
1267
;msgMixMMIo   db 'codec mmio base      ',0
1256
;msgMixMMIo   db 'codec mmio base      ',0
1268
;msgIrqMap    db 'AC97 irq map as      ',0
1257
;msgIrqMap    db 'AC97 irq map as      ',0
1269
 
1258
 
1270
align 4
1259
align 4
1271
data fixups
1260
data fixups
1272
end data
1261
end data
1273
 
1262
 
1274
align 8
1263
align 8
1275
pcmout_bdl       rq 32
1264
pcmout_bdl       rq 32
1276
buff_list        rd 32
1265
buff_list        rd 32
1277
 
1266
 
1278
codec CODEC
1267
codec CODEC
1279
ctrl AC_CNTRL
1268
ctrl AC_CNTRL
1280
 
1269
 
1281
chip_type        rb 1
1270
chip_type        rb 1
1282
>
1271
>
1283
>
1272
>
1284
>
1273
>
1285
>
1274
>
1286
>
1275
>
1287
>
1276
>
1288
>
1277
>
1289
>
1278
>
1290
>
1279
>
1291
>
1280
>