Subversion Repositories Kolibri OS

Rev

Rev 5077 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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