Subversion Repositories Kolibri OS

Rev

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

Rev 2434 Rev 2465
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2011. 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 MS COFF
8
format MS COFF
9
 
9
 
10
DEBUG           equ 1
10
DEBUG           equ 1
11
 
11
 
12
include 'proc32.inc'
12
include 'proc32.inc'
13
include 'imports.inc'
13
include 'imports.inc'
14
 
14
 
15
API_VERSION     equ 0x01000100
15
API_VERSION     equ 0x01000100
16
 
16
 
17
USE_COM_IRQ     equ 0    ;make irq 3 and irq 4 available for PCI devices
17
USE_COM_IRQ     equ 0    ;make irq 3 and irq 4 available for PCI devices
18
IRQ_REMAP       equ 0
18
IRQ_REMAP       equ 0
19
IRQ_LINE        equ 0
19
IRQ_LINE        equ 0
20
 
20
 
21
 
21
 
22
;irq 0,1,2,8,12,13 ­¥¤®áâ㯭ë
22
;irq 0,1,2,8,12,13 ­¥¤®áâ㯭ë
23
;                   FEDCBA9876543210
23
;                   FEDCBA9876543210
24
VALID_IRQ       equ 1100111011111000b
24
VALID_IRQ       equ 1100111011111000b
25
ATTCH_IRQ       equ 0000111010100000b
25
ATTCH_IRQ       equ 0000111010100000b
26
 
26
 
27
if USE_COM_IRQ
27
if USE_COM_IRQ
28
ATTCH_IRQ       equ 0000111010111000b
28
ATTCH_IRQ       equ 0000111010111000b
29
end if
29
end if
30
 
30
 
31
CPU_FREQ        equ  2600d
31
CPU_FREQ        equ  2600d
32
 
32
 
33
BIT0  EQU 0x00000001
33
BIT0  EQU 0x00000001
34
BIT1  EQU 0x00000002
34
BIT1  EQU 0x00000002
35
BIT5  EQU 0x00000020
35
BIT5  EQU 0x00000020
36
BIT10 EQU 0x00000400
36
BIT10 EQU 0x00000400
37
 
37
 
38
VID_VIA           equ 0x1106
38
VID_VIA           equ 0x1106
39
 
39
 
40
CTRL_VT82C686     equ 0x3058
40
CTRL_VT82C686     equ 0x3058
41
CTRL_VT8233_5     equ 0x3059
41
CTRL_VT8233_5     equ 0x3059
42
 
42
 
43
 
43
 
44
CODEC_MASTER_VOL_REG         equ 0x02
44
CODEC_MASTER_VOL_REG         equ 0x02
45
CODEC_AUX_VOL                equ 0x04 ;
45
CODEC_AUX_VOL                equ 0x04 ;
46
CODEC_PCM_OUT_REG            equ 0x18 ; PCM output volume
46
CODEC_PCM_OUT_REG            equ 0x18 ; PCM output volume
47
CODEC_EXT_AUDIO_REG          equ 0x28 ; extended audio
47
CODEC_EXT_AUDIO_REG          equ 0x28 ; extended audio
48
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
48
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
49
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
49
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
50
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
50
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
51
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
51
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
52
 
52
 
53
 
53
 
54
;VIA host controller registers set
54
;VIA host controller registers set
55
;; common offsets
55
;; common offsets
56
VIA_REG_OFFSET_STATUS        equ   0x00    ;; byte - channel status
56
VIA_REG_OFFSET_STATUS        equ   0x00    ;; byte - channel status
57
  VIA_REG_STAT_ACTIVE              equ   0x80    ;; RO
57
  VIA_REG_STAT_ACTIVE              equ   0x80    ;; RO
58
  VIA_REG_STAT_PAUSED              equ   0x40    ;; RO
58
  VIA_REG_STAT_PAUSED              equ   0x40    ;; RO
59
  VIA_REG_STAT_TRIGGER_QUEUED      equ   0x08    ;; RO
59
  VIA_REG_STAT_TRIGGER_QUEUED      equ   0x08    ;; RO
60
  VIA_REG_STAT_STOPPED             equ   0x04    ;; RWC
60
  VIA_REG_STAT_STOPPED             equ   0x04    ;; RWC
61
  VIA_REG_STAT_EOL                 equ   0x02    ;; RWC
61
  VIA_REG_STAT_EOL                 equ   0x02    ;; RWC
62
  VIA_REG_STAT_FLAG                equ   0x01    ;; RWC
62
  VIA_REG_STAT_FLAG                equ   0x01    ;; RWC
63
VIA_REG_OFFSET_CONTROL       equ   0x01    ;; byte - channel control
63
VIA_REG_OFFSET_CONTROL       equ   0x01    ;; byte - channel control
64
  VIA_REG_CTRL_START               equ   0x80    ;; WO
64
  VIA_REG_CTRL_START               equ   0x80    ;; WO
65
  VIA_REG_CTRL_TERMINATE           equ   0x40    ;; WO
65
  VIA_REG_CTRL_TERMINATE           equ   0x40    ;; WO
66
  VIA_REG_CTRL_AUTOSTART           equ   0x20
66
  VIA_REG_CTRL_AUTOSTART           equ   0x20
67
  VIA_REG_CTRL_PAUSE               equ   0x08    ;; RW
67
  VIA_REG_CTRL_PAUSE               equ   0x08    ;; RW
68
  VIA_REG_CTRL_INT_STOP            equ   0x04
68
  VIA_REG_CTRL_INT_STOP            equ   0x04
69
  VIA_REG_CTRL_INT_EOL             equ   0x02
69
  VIA_REG_CTRL_INT_EOL             equ   0x02
70
  VIA_REG_CTRL_INT_FLAG            equ   0x01
70
  VIA_REG_CTRL_INT_FLAG            equ   0x01
71
  VIA_REG_CTRL_RESET               equ   0x01    ;; RW - probably reset? undocumented
71
  VIA_REG_CTRL_RESET               equ   0x01    ;; RW - probably reset? undocumented
72
  VIA_REG_CTRL_INT                 equ  (VIA_REG_CTRL_INT_FLAG or \
72
  VIA_REG_CTRL_INT                 equ  (VIA_REG_CTRL_INT_FLAG or \
73
                                         VIA_REG_CTRL_INT_EOL or \
73
                                         VIA_REG_CTRL_INT_EOL or \
74
                                         VIA_REG_CTRL_AUTOSTART)
74
                                         VIA_REG_CTRL_AUTOSTART)
75
VIA_REG_OFFSET_TYPE          equ   0x02    ;; byte - channel type (686 only)
75
VIA_REG_OFFSET_TYPE          equ   0x02    ;; byte - channel type (686 only)
76
  VIA_REG_TYPE_AUTOSTART           equ   0x80    ;; RW - autostart at EOL
76
  VIA_REG_TYPE_AUTOSTART           equ   0x80    ;; RW - autostart at EOL
77
  VIA_REG_TYPE_16BIT               equ   0x20    ;; RW
77
  VIA_REG_TYPE_16BIT               equ   0x20    ;; RW
78
  VIA_REG_TYPE_STEREO              equ   0x10    ;; RW
78
  VIA_REG_TYPE_STEREO              equ   0x10    ;; RW
79
  VIA_REG_TYPE_INT_LLINE           equ   0x00
79
  VIA_REG_TYPE_INT_LLINE           equ   0x00
80
  VIA_REG_TYPE_INT_LSAMPLE         equ   0x04
80
  VIA_REG_TYPE_INT_LSAMPLE         equ   0x04
81
  VIA_REG_TYPE_INT_LESSONE         equ   0x08
81
  VIA_REG_TYPE_INT_LESSONE         equ   0x08
82
  VIA_REG_TYPE_INT_MASK            equ   0x0c
82
  VIA_REG_TYPE_INT_MASK            equ   0x0c
83
  VIA_REG_TYPE_INT_EOL             equ   0x02
83
  VIA_REG_TYPE_INT_EOL             equ   0x02
84
  VIA_REG_TYPE_INT_FLAG            equ   0x01
84
  VIA_REG_TYPE_INT_FLAG            equ   0x01
85
VIA_REG_OFFSET_TABLE_PTR     equ   0x04    ;; dword - channel table pointer
85
VIA_REG_OFFSET_TABLE_PTR     equ   0x04    ;; dword - channel table pointer
86
VIA_REG_OFFSET_CURR_PTR      equ   0x04    ;; dword - channel current pointer
86
VIA_REG_OFFSET_CURR_PTR      equ   0x04    ;; dword - channel current pointer
87
VIA_REG_OFFSET_STOP_IDX      equ   0x08    ;; dword - stop index, channel type, sample rate
87
VIA_REG_OFFSET_STOP_IDX      equ   0x08    ;; dword - stop index, channel type, sample rate
88
  VIA8233_REG_TYPE_16BIT           equ   0x00200000      ;; RW
88
  VIA8233_REG_TYPE_16BIT           equ   0x00200000      ;; RW
89
  VIA8233_REG_TYPE_STEREO          equ   0x00100000      ;; RW
89
  VIA8233_REG_TYPE_STEREO          equ   0x00100000      ;; RW
90
VIA_REG_OFFSET_CURR_COUNT    equ   0x0c    ;; dword - channel current count (24 bit)
90
VIA_REG_OFFSET_CURR_COUNT    equ   0x0c    ;; dword - channel current count (24 bit)
91
VIA_REG_OFFSET_CURR_INDEX    equ   0x0f    ;; byte - channel current index (for via8233 only)
91
VIA_REG_OFFSET_CURR_INDEX    equ   0x0f    ;; byte - channel current index (for via8233 only)
92
 
92
 
93
 
93
 
94
VIADEV_PLAYBACK         equ   0x00
94
VIADEV_PLAYBACK         equ   0x00
95
VIADEV_CAPTURE          equ   0x10
95
VIADEV_CAPTURE          equ   0x10
96
VIADEV_FM               equ   0x20
96
VIADEV_FM               equ   0x20
97
 
97
 
98
;; AC'97 ;;
98
;; AC'97 ;;
99
VIA_REG_AC97             equ   0x80    ; dword
99
VIA_REG_AC97             equ   0x80    ; dword
100
  VIA_REG_AC97_CODEC_ID_MASK       equ  0xC0000000 ;(3<<30)
100
  VIA_REG_AC97_CODEC_ID_MASK       equ  0xC0000000 ;(3<<30)
101
  VIA_REG_AC97_CODEC_ID_SHIFT      equ  30
101
  VIA_REG_AC97_CODEC_ID_SHIFT      equ  30
102
  VIA_REG_AC97_CODEC_ID_PRIMARY    equ  0x00
102
  VIA_REG_AC97_CODEC_ID_PRIMARY    equ  0x00
103
  VIA_REG_AC97_CODEC_ID_SECONDARY  equ  0x01
103
  VIA_REG_AC97_CODEC_ID_SECONDARY  equ  0x01
104
  VIA_REG_AC97_SECONDARY_VALID     equ  0x08000000 ;(1<<27)
104
  VIA_REG_AC97_SECONDARY_VALID     equ  0x08000000 ;(1<<27)
105
  VIA_REG_AC97_PRIMARY_VALID       equ  0x02000000 ;(1<<25)
105
  VIA_REG_AC97_PRIMARY_VALID       equ  0x02000000 ;(1<<25)
106
  VIA_REG_AC97_BUSY                equ  0x01000000 ;(1<<24)
106
  VIA_REG_AC97_BUSY                equ  0x01000000 ;(1<<24)
107
  VIA_REG_AC97_READ                equ  0x00800000 ;(1<<23)
107
  VIA_REG_AC97_READ                equ  0x00800000 ;(1<<23)
108
  VIA_REG_AC97_CMD_SHIFT           equ  16
108
  VIA_REG_AC97_CMD_SHIFT           equ  16
109
  VIA_REG_AC97_CMD_MASK            equ  0x7E
109
  VIA_REG_AC97_CMD_MASK            equ  0x7E
110
  VIA_REG_AC97_DATA_SHIFT          equ  0
110
  VIA_REG_AC97_DATA_SHIFT          equ  0
111
  VIA_REG_AC97_DATA_MASK           equ  0xFFFF
111
  VIA_REG_AC97_DATA_MASK           equ  0xFFFF
112
 
112
 
113
VIA_REG_SGD_SHADOW       equ   0x84    ; dword
113
VIA_REG_SGD_SHADOW       equ   0x84    ; dword
114
 
114
 
115
;; via8233-specific registers ;;
115
;; via8233-specific registers ;;
116
VIA_REG_OFS_PLAYBACK_VOLUME_L   equ  0x02    ;; byte
116
VIA_REG_OFS_PLAYBACK_VOLUME_L   equ  0x02    ;; byte
117
VIA_REG_OFS_PLAYBACK_VOLUME_R   equ  0x03    ;; byte
117
VIA_REG_OFS_PLAYBACK_VOLUME_R   equ  0x03    ;; byte
118
VIA_REG_OFS_MULTPLAY_FORMAT     equ  0x02    ;; byte - format and channels
118
VIA_REG_OFS_MULTPLAY_FORMAT     equ  0x02    ;; byte - format and channels
119
  VIA_REG_MULTPLAY_FMT_8BIT          equ  0x00
119
  VIA_REG_MULTPLAY_FMT_8BIT          equ  0x00
120
  VIA_REG_MULTPLAY_FMT_16BIT         equ  0x80
120
  VIA_REG_MULTPLAY_FMT_16BIT         equ  0x80
121
  VIA_REG_MULTPLAY_FMT_CH_MASK       equ  0x70    ;; # channels << 4 (valid = 1,2,4,6)
121
  VIA_REG_MULTPLAY_FMT_CH_MASK       equ  0x70    ;; # channels << 4 (valid = 1,2,4,6)
122
VIA_REG_OFS_CAPTURE_FIFO        equ  0x02    ;; byte - bit 6 = fifo  enable
122
VIA_REG_OFS_CAPTURE_FIFO        equ  0x02    ;; byte - bit 6 = fifo  enable
123
  VIA_REG_CAPTURE_FIFO_ENABLE        equ  0x40
123
  VIA_REG_CAPTURE_FIFO_ENABLE        equ  0x40
124
 
124
 
125
VIA_DXS_MAX_VOLUME              equ  31      ;; max. volume (attenuation) of reg 0x32/33
125
VIA_DXS_MAX_VOLUME              equ  31      ;; max. volume (attenuation) of reg 0x32/33
126
 
126
 
127
VIA_TBL_BIT_FLAG          equ   0x40000000
127
VIA_TBL_BIT_FLAG          equ   0x40000000
128
VIA_TBL_BIT_EOL           equ   0x80000000
128
VIA_TBL_BIT_EOL           equ   0x80000000
129
 
129
 
130
;; pci space ;;
130
;; pci space ;;
131
VIA_ACLINK_STAT           equ   0x40
131
VIA_ACLINK_STAT           equ   0x40
132
  ;...
132
  ;...
133
  VIA_ACLINK_C00_READY             equ   0x01 ; primary codec ready
133
  VIA_ACLINK_C00_READY             equ   0x01 ; primary codec ready
134
VIA_ACLINK_CTRL           equ   0x41
134
VIA_ACLINK_CTRL           equ   0x41
135
  VIA_ACLINK_CTRL_ENABLE           equ   0x80 ; 0: disable, 1: enable
135
  VIA_ACLINK_CTRL_ENABLE           equ   0x80 ; 0: disable, 1: enable
136
  VIA_ACLINK_CTRL_RESET            equ   0x40 ; 0: assert, 1: de-assert
136
  VIA_ACLINK_CTRL_RESET            equ   0x40 ; 0: assert, 1: de-assert
137
  VIA_ACLINK_CTRL_SYNC             equ   0x20 ; 0: release SYNC, 1: force SYNC hi
137
  VIA_ACLINK_CTRL_SYNC             equ   0x20 ; 0: release SYNC, 1: force SYNC hi
138
  VIA_ACLINK_CTRL_SDO              equ   0x10 ; 0: release SDO, 1: force SDO hi
138
  VIA_ACLINK_CTRL_SDO              equ   0x10 ; 0: release SDO, 1: force SDO hi
139
  VIA_ACLINK_CTRL_VRA              equ   0x08 ; 0: disable VRA, 1: enable VRA
139
  VIA_ACLINK_CTRL_VRA              equ   0x08 ; 0: disable VRA, 1: enable VRA
140
  VIA_ACLINK_CTRL_PCM              equ   0x04 ; 0: disable PCM, 1: enable PCM
140
  VIA_ACLINK_CTRL_PCM              equ   0x04 ; 0: disable PCM, 1: enable PCM
141
  VIA_ACLINK_CTRL_FM               equ   0x02 ; via686 only
141
  VIA_ACLINK_CTRL_FM               equ   0x02 ; via686 only
142
  VIA_ACLINK_CTRL_SB               equ   0x01 ; via686 only
142
  VIA_ACLINK_CTRL_SB               equ   0x01 ; via686 only
143
  VIA_ACLINK_CTRL_INIT             equ  (VIA_ACLINK_CTRL_ENABLE or \
143
  VIA_ACLINK_CTRL_INIT             equ  (VIA_ACLINK_CTRL_ENABLE or \
144
                                         VIA_ACLINK_CTRL_RESET or \
144
                                         VIA_ACLINK_CTRL_RESET or \
145
                                         VIA_ACLINK_CTRL_PCM or \
145
                                         VIA_ACLINK_CTRL_PCM or \
146
                                         VIA_ACLINK_CTRL_VRA)
146
                                         VIA_ACLINK_CTRL_VRA)
147
VIA_FUNC_ENABLE           equ   0x42
147
VIA_FUNC_ENABLE           equ   0x42
148
  VIA_FUNC_MIDI_PNP                equ   0x80 ; FIXME: it's 0x40 in the datasheet!
148
  VIA_FUNC_MIDI_PNP                equ   0x80 ; FIXME: it's 0x40 in the datasheet!
149
  VIA_FUNC_MIDI_IRQMASK            equ   0x40 ; FIXME: not documented!
149
  VIA_FUNC_MIDI_IRQMASK            equ   0x40 ; FIXME: not documented!
150
  VIA_FUNC_RX2C_WRITE              equ   0x20
150
  VIA_FUNC_RX2C_WRITE              equ   0x20
151
  VIA_FUNC_SB_FIFO_EMPTY           equ   0x10
151
  VIA_FUNC_SB_FIFO_EMPTY           equ   0x10
152
  VIA_FUNC_ENABLE_GAME             equ   0x08
152
  VIA_FUNC_ENABLE_GAME             equ   0x08
153
  VIA_FUNC_ENABLE_FM               equ   0x04
153
  VIA_FUNC_ENABLE_FM               equ   0x04
154
  VIA_FUNC_ENABLE_MIDI             equ   0x02
154
  VIA_FUNC_ENABLE_MIDI             equ   0x02
155
  VIA_FUNC_ENABLE_SB               equ   0x01
155
  VIA_FUNC_ENABLE_SB               equ   0x01
156
VIA_PNP_CONTROL           equ   0x43
156
VIA_PNP_CONTROL           equ   0x43
157
VIA_FM_NMI_CTRL           equ   0x48
157
VIA_FM_NMI_CTRL           equ   0x48
158
VIA8233_VOLCHG_CTRL       equ   0x48
158
VIA8233_VOLCHG_CTRL       equ   0x48
159
VIA8233_SPDIF_CTRL        equ   0x49
159
VIA8233_SPDIF_CTRL        equ   0x49
160
  VIA8233_SPDIF_DX3                equ   0x08
160
  VIA8233_SPDIF_DX3                equ   0x08
161
  VIA8233_SPDIF_SLOT_MASK          equ   0x03
161
  VIA8233_SPDIF_SLOT_MASK          equ   0x03
162
  VIA8233_SPDIF_SLOT_1011          equ   0x00
162
  VIA8233_SPDIF_SLOT_1011          equ   0x00
163
  VIA8233_SPDIF_SLOT_34            equ   0x01
163
  VIA8233_SPDIF_SLOT_34            equ   0x01
164
  VIA8233_SPDIF_SLOT_78            equ   0x02
164
  VIA8233_SPDIF_SLOT_78            equ   0x02
165
  VIA8233_SPDIF_SLOT_69            equ   0x03
165
  VIA8233_SPDIF_SLOT_69            equ   0x03
166
;] Asper
166
;] Asper
167
 
167
 
168
 
168
 
169
SRV_GETVERSION        equ  0
169
SRV_GETVERSION        equ  0
170
DEV_PLAY              equ  1
170
DEV_PLAY              equ  1
171
DEV_STOP              equ  2
171
DEV_STOP              equ  2
172
DEV_CALLBACK          equ  3
172
DEV_CALLBACK          equ  3
173
DEV_SET_BUFF          equ  4
173
DEV_SET_BUFF          equ  4
174
DEV_NOTIFY            equ  5
174
DEV_NOTIFY            equ  5
175
DEV_SET_MASTERVOL     equ  6
175
DEV_SET_MASTERVOL     equ  6
176
DEV_GET_MASTERVOL     equ  7
176
DEV_GET_MASTERVOL     equ  7
177
DEV_GET_INFO          equ  8
177
DEV_GET_INFO          equ  8
178
 
178
 
179
struc AC_CNTRL              ;AC controller base class
179
struc AC_CNTRL              ;AC controller base class
180
{ .bus                dd ?
180
{ .bus                dd ?
181
  .devfn              dd ?
181
  .devfn              dd ?
182
 
182
 
183
  .vendor             dd ?
183
  .vendor             dd ?
184
  .dev_id             dd ?
184
  .dev_id             dd ?
185
  .pci_cmd            dd ?
185
  .pci_cmd            dd ?
186
  .pci_stat           dd ?
186
  .pci_stat           dd ?
187
 
187
 
188
  .codec_io_base      dd ?
188
  .codec_io_base      dd ?
189
  .codec_mem_base     dd ?
189
  .codec_mem_base     dd ?
190
 
190
 
191
  .ctrl_io_base       dd ?
191
  .ctrl_io_base       dd ?
192
  .ctrl_mem_base      dd ?
192
  .ctrl_mem_base      dd ?
193
  .cfg_reg            dd ?
193
  .cfg_reg            dd ?
194
  .int_line           dd ?
194
  .int_line           dd ?
195
 
195
 
196
  .vendor_ids         dd ?    ;vendor id string
196
  .vendor_ids         dd ?    ;vendor id string
197
  .ctrl_ids           dd ?    ;hub id string
197
  .ctrl_ids           dd ?    ;hub id string
198
 
198
 
199
  .buffer             dd ?
199
  .buffer             dd ?
200
 
200
 
201
  .notify_pos         dd ?
201
  .notify_pos         dd ?
202
  .notify_task        dd ?
202
  .notify_task        dd ?
203
 
203
 
204
  .lvi_reg            dd ?
204
  .lvi_reg            dd ?
205
  .ctrl_setup         dd ?
205
  .ctrl_setup         dd ?
206
  .user_callback      dd ?
206
  .user_callback      dd ?
207
  .codec_read16       dd ?
207
  .codec_read16       dd ?
208
  .codec_write16      dd ?
208
  .codec_write16      dd ?
209
 
209
 
210
  .ctrl_read8         dd ?
210
  .ctrl_read8         dd ?
211
  .ctrl_read16        dd ?
211
  .ctrl_read16        dd ?
212
  .ctrl_read32        dd ?
212
  .ctrl_read32        dd ?
213
 
213
 
214
  .ctrl_write8        dd ?
214
  .ctrl_write8        dd ?
215
  .ctrl_write16       dd ?
215
  .ctrl_write16       dd ?
216
  .ctrl_write32       dd ?
216
  .ctrl_write32       dd ?
217
}
217
}
218
 
218
 
219
struc CODEC                ;Audio Chip base class
219
struc CODEC                ;Audio Chip base class
220
{
220
{
221
  .chip_id            dd ?
221
  .chip_id            dd ?
222
  .flags              dd ?
222
  .flags              dd ?
223
  .status             dd ?
223
  .status             dd ?
224
 
224
 
225
  .ac_vendor_ids      dd ?    ;ac vendor id string
225
  .ac_vendor_ids      dd ?    ;ac vendor id string
226
  .chip_ids           dd ?    ;chip model string
226
  .chip_ids           dd ?    ;chip model string
227
 
227
 
228
  .shadow_flag        dd ?
228
  .shadow_flag        dd ?
229
                      dd ?
229
                      dd ?
230
 
230
 
231
  .regs               dw ?     ; codec registers
231
  .regs               dw ?     ; codec registers
232
  .reg_master_vol     dw ?     ;0x02
232
  .reg_master_vol     dw ?     ;0x02
233
  .reg_aux_out_vol    dw ?     ;0x04
233
  .reg_aux_out_vol    dw ?     ;0x04
234
  .reg_mone_vol       dw ?     ;0x06
234
  .reg_mone_vol       dw ?     ;0x06
235
  .reg_master_tone    dw ?     ;0x08
235
  .reg_master_tone    dw ?     ;0x08
236
  .reg_beep_vol       dw ?     ;0x0A
236
  .reg_beep_vol       dw ?     ;0x0A
237
  .reg_phone_vol      dw ?     ;0x0C
237
  .reg_phone_vol      dw ?     ;0x0C
238
  .reg_mic_vol        dw ?     ;0x0E
238
  .reg_mic_vol        dw ?     ;0x0E
239
  .reg_line_in_vol    dw ?     ;0x10
239
  .reg_line_in_vol    dw ?     ;0x10
240
  .reg_cd_vol         dw ?     ;0x12
240
  .reg_cd_vol         dw ?     ;0x12
241
  .reg_video_vol      dw ?     ;0x14
241
  .reg_video_vol      dw ?     ;0x14
242
  .reg_aux_in_vol     dw ?     ;0x16
242
  .reg_aux_in_vol     dw ?     ;0x16
243
  .reg_pcm_out_vol    dw ?     ;0x18
243
  .reg_pcm_out_vol    dw ?     ;0x18
244
  .reg_rec_select     dw ?     ;0x1A
244
  .reg_rec_select     dw ?     ;0x1A
245
  .reg_rec_gain       dw ?     ;0x1C
245
  .reg_rec_gain       dw ?     ;0x1C
246
  .reg_rec_gain_mic   dw ?     ;0x1E
246
  .reg_rec_gain_mic   dw ?     ;0x1E
247
  .reg_gen            dw ?     ;0x20
247
  .reg_gen            dw ?     ;0x20
248
  .reg_3d_ctrl        dw ?     ;0X22
248
  .reg_3d_ctrl        dw ?     ;0X22
249
  .reg_page           dw ?     ;0X24
249
  .reg_page           dw ?     ;0X24
250
  .reg_powerdown      dw ?     ;0x26
250
  .reg_powerdown      dw ?     ;0x26
251
  .reg_ext_audio      dw ?     ;0x28
251
  .reg_ext_audio      dw ?     ;0x28
252
  .reg_ext_st         dw ?     ;0x2a
252
  .reg_ext_st         dw ?     ;0x2a
253
  .reg_pcm_front_rate dw ?     ;0x2c
253
  .reg_pcm_front_rate dw ?     ;0x2c
254
  .reg_pcm_surr_rate  dw ?     ;0x2e
254
  .reg_pcm_surr_rate  dw ?     ;0x2e
255
  .reg_lfe_rate       dw ?     ;0x30
255
  .reg_lfe_rate       dw ?     ;0x30
256
  .reg_pcm_in_rate    dw ?     ;0x32
256
  .reg_pcm_in_rate    dw ?     ;0x32
257
                      dw ?     ;0x34
257
                      dw ?     ;0x34
258
  .reg_cent_lfe_vol   dw ?     ;0x36
258
  .reg_cent_lfe_vol   dw ?     ;0x36
259
  .reg_surr_vol       dw ?     ;0x38
259
  .reg_surr_vol       dw ?     ;0x38
260
  .reg_spdif_ctrl     dw ?     ;0x3A
260
  .reg_spdif_ctrl     dw ?     ;0x3A
261
                      dw ?     ;0x3C
261
                      dw ?     ;0x3C
262
                      dw ?     ;0x3E
262
                      dw ?     ;0x3E
263
                      dw ?     ;0x40
263
                      dw ?     ;0x40
264
                      dw ?     ;0x42
264
                      dw ?     ;0x42
265
                      dw ?     ;0x44
265
                      dw ?     ;0x44
266
                      dw ?     ;0x46
266
                      dw ?     ;0x46
267
                      dw ?     ;0x48
267
                      dw ?     ;0x48
268
                      dw ?     ;0x4A
268
                      dw ?     ;0x4A
269
                      dw ?     ;0x4C
269
                      dw ?     ;0x4C
270
                      dw ?     ;0x4E
270
                      dw ?     ;0x4E
271
                      dw ?     ;0x50
271
                      dw ?     ;0x50
272
                      dw ?     ;0x52
272
                      dw ?     ;0x52
273
                      dw ?     ;0x54
273
                      dw ?     ;0x54
274
                      dw ?     ;0x56
274
                      dw ?     ;0x56
275
                      dw ?     ;0x58
275
                      dw ?     ;0x58
276
                      dw ?     ;0x5A
276
                      dw ?     ;0x5A
277
                      dw ?     ;0x5C
277
                      dw ?     ;0x5C
278
                      dw ?     ;0x5E
278
                      dw ?     ;0x5E
279
  .reg_page_0         dw ?     ;0x60
279
  .reg_page_0         dw ?     ;0x60
280
  .reg_page_1         dw ?     ;0x62
280
  .reg_page_1         dw ?     ;0x62
281
  .reg_page_2         dw ?     ;0x64
281
  .reg_page_2         dw ?     ;0x64
282
  .reg_page_3         dw ?     ;0x66
282
  .reg_page_3         dw ?     ;0x66
283
  .reg_page_4         dw ?     ;0x68
283
  .reg_page_4         dw ?     ;0x68
284
  .reg_page_5         dw ?     ;0x6A
284
  .reg_page_5         dw ?     ;0x6A
285
  .reg_page_6         dw ?     ;0x6C
285
  .reg_page_6         dw ?     ;0x6C
286
  .reg_page_7         dw ?     ;0x6E
286
  .reg_page_7         dw ?     ;0x6E
287
                      dw ?     ;0x70
287
                      dw ?     ;0x70
288
                      dw ?     ;0x72
288
                      dw ?     ;0x72
289
                      dw ?     ;0x74
289
                      dw ?     ;0x74
290
                      dw ?     ;0x76
290
                      dw ?     ;0x76
291
                      dw ?     ;0x78
291
                      dw ?     ;0x78
292
                      dw ?     ;0x7A
292
                      dw ?     ;0x7A
293
  .reg_vendor_id_1    dw ?     ;0x7C
293
  .reg_vendor_id_1    dw ?     ;0x7C
294
  .reg_vendor_id_2    dw ?     ;0x7E
294
  .reg_vendor_id_2    dw ?     ;0x7E
295
 
295
 
296
 
296
 
297
  .reset              dd ?    ;virual
297
  .reset              dd ?    ;virual
298
  .set_master_vol     dd ?
298
  .set_master_vol     dd ?
299
}
299
}
300
 
300
 
301
struc CTRL_INFO
301
struc CTRL_INFO
302
{   .pci_cmd          dd ?
302
{   .pci_cmd          dd ?
303
    .irq              dd ?
303
    .irq              dd ?
304
    .glob_cntrl       dd ?
304
    .glob_cntrl       dd ?
305
    .glob_sta         dd ?
305
    .glob_sta         dd ?
306
    .codec_io_base    dd ?
306
    .codec_io_base    dd ?
307
    .ctrl_io_base     dd ?
307
    .ctrl_io_base     dd ?
308
    .codec_mem_base   dd ?
308
    .codec_mem_base   dd ?
309
    .ctrl_mem_base    dd ?
309
    .ctrl_mem_base    dd ?
310
    .codec_id         dd ?
310
    .codec_id         dd ?
311
}
311
}
312
 
312
 
313
struc IOCTL
313
struc IOCTL
314
{  .handle            dd ?
314
{  .handle            dd ?
315
   .io_code           dd ?
315
   .io_code           dd ?
316
   .input             dd ?
316
   .input             dd ?
317
   .inp_size          dd ?
317
   .inp_size          dd ?
318
   .output            dd ?
318
   .output            dd ?
319
   .out_size          dd ?
319
   .out_size          dd ?
320
}
320
}
321
 
321
 
322
virtual at 0
322
virtual at 0
323
  IOCTL IOCTL
323
  IOCTL IOCTL
324
end virtual
324
end virtual
325
 
325
 
326
EVENT_NOTIFY    equ 0x00000200
326
EVENT_NOTIFY    equ 0x00000200
327
 
327
 
328
public START
328
public START
329
public service_proc
329
public service_proc
330
public version
330
public version
331
 
331
 
332
section '.flat' code readable align 16
332
section '.flat' code readable align 16
333
 
333
 
334
proc START stdcall, state:dword
334
proc START stdcall, state:dword
335
 
335
 
336
        cmp     [state], 1
336
        cmp     [state], 1
337
        jne     .stop
337
        jne     .stop
338
 
338
 
339
     if DEBUG
339
     if DEBUG
340
        mov     esi, msgInit
340
        mov     esi, msgInit
341
        call    SysMsgBoardStr
341
        call    SysMsgBoardStr
342
     end if
342
     end if
343
 
343
 
344
        call    detect_controller
344
        call    detect_controller
345
        test    eax, eax
345
        test    eax, eax
346
        jz      .fail
346
        jz      .fail
347
 
347
 
348
     if DEBUG
348
     if DEBUG
349
        mov     esi, [ctrl.vendor_ids]
349
        mov     esi, [ctrl.vendor_ids]
350
        call    SysMsgBoardStr
350
        call    SysMsgBoardStr
351
        mov     esi, [ctrl.ctrl_ids]
351
        mov     esi, [ctrl.ctrl_ids]
352
        call    SysMsgBoardStr
352
        call    SysMsgBoardStr
353
     end if
353
     end if
354
 
354
 
355
        call    init_controller
355
        call    init_controller
356
        test    eax, eax
356
        test    eax, eax
357
        jz      .fail
357
        jz      .fail
358
 
358
 
359
        call    init_codec
359
        call    init_codec
360
        test    eax, eax
360
        test    eax, eax
361
        jz      .fail
361
        jz      .fail
362
 
362
 
363
        call    setup_codec
363
        call    setup_codec
364
 
364
 
365
        mov     esi, msgPrimBuff
365
        mov     esi, msgPrimBuff
366
        call    SysMsgBoardStr
366
        call    SysMsgBoardStr
367
        call    create_primary_buff
367
        call    create_primary_buff
368
        mov     esi, msgDone
368
        mov     esi, msgDone
369
        call    SysMsgBoardStr
369
        call    SysMsgBoardStr
370
 
370
 
371
  if IRQ_REMAP
371
  if IRQ_REMAP
372
        pushf
372
        pushf
373
        cli
373
        cli
374
 
374
 
375
        mov     ebx, [ctrl.int_line]
375
        mov     ebx, [ctrl.int_line]
376
        in      al, 0xA1
376
        in      al, 0xA1
377
        mov     ah, al
377
        mov     ah, al
378
        in      al, 0x21
378
        in      al, 0x21
379
        test    ebx, ebx
379
        test    ebx, ebx
380
        jz      .skip
380
        jz      .skip
381
        bts     ax, bx                          ;mask old line
381
        bts     ax, bx                          ;mask old line
382
.skip:
382
.skip:
383
        bts     ax, IRQ_LINE                    ;mask new ine
383
        bts     ax, IRQ_LINE                    ;mask new ine
384
        out     0x21, al
384
        out     0x21, al
385
        mov     al, ah
385
        mov     al, ah
386
        out     0xA1, al
386
        out     0xA1, al
387
 
387
 
388
        stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE      ;remap IRQ
388
        stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE      ;remap IRQ
389
 
389
 
390
        mov     dx, 0x4d0                       ;8259 ELCR1
390
        mov     dx, 0x4d0                       ;8259 ELCR1
391
        in      al, dx
391
        in      al, dx
392
        bts     ax, IRQ_LINE
392
        bts     ax, IRQ_LINE
393
        out     dx, al                          ;set level-triggered mode
393
        out     dx, al                          ;set level-triggered mode
394
        mov     [ctrl.int_line], IRQ_LINE
394
        mov     [ctrl.int_line], IRQ_LINE
395
        popf
395
        popf
396
        mov     esi, msgRemap
396
        mov     esi, msgRemap
397
        call    SysMsgBoardStr
397
        call    SysMsgBoardStr
398
  end if
398
  end if
399
 
399
 
400
        mov     eax, VALID_IRQ
400
        mov     eax, VALID_IRQ
401
        mov     ebx, [ctrl.int_line]
401
        mov     ebx, [ctrl.int_line]
402
        mov     esi, msgInvIRQ
402
        mov     esi, msgInvIRQ
403
        bt      eax, ebx
403
        bt      eax, ebx
404
        jnc     .fail_msg
404
        jnc     .fail_msg
405
        mov     eax, ATTCH_IRQ
405
        mov     eax, ATTCH_IRQ
406
        mov     esi, msgAttchIRQ
406
        mov     esi, msgAttchIRQ
407
        bt      eax, ebx
407
        bt      eax, ebx
408
        jnc     .fail_msg
408
        jnc     .fail_msg
409
 
409
 
410
        stdcall AttachIntHandler, ebx, ac97_irq_VIA, dword 0
410
        stdcall AttachIntHandler, ebx, ac97_irq_VIA, dword 0
411
.reg:
411
.reg:
412
        stdcall RegService, sz_sound_srv, service_proc
412
        stdcall RegService, sz_sound_srv, service_proc
413
        ret
413
        ret
414
.fail:
414
.fail:
415
     if DEBUG
415
     if DEBUG
416
        mov     esi, msgFail
416
        mov     esi, msgFail
417
        call    SysMsgBoardStr
417
        call    SysMsgBoardStr
418
     end if
418
     end if
419
        xor     eax, eax
419
        xor     eax, eax
420
        ret
420
        ret
421
.fail_msg:
421
.fail_msg:
422
        call    SysMsgBoardStr
422
        call    SysMsgBoardStr
423
        xor     eax, eax
423
        xor     eax, eax
424
        ret
424
        ret
425
.stop:
425
.stop:
426
        call    stop
426
        call    stop
427
        xor     eax, eax
427
        xor     eax, eax
428
        ret
428
        ret
429
endp
429
endp
430
 
430
 
431
handle     equ  IOCTL.handle
431
handle     equ  IOCTL.handle
432
io_code    equ  IOCTL.io_code
432
io_code    equ  IOCTL.io_code
433
input      equ  IOCTL.input
433
input      equ  IOCTL.input
434
inp_size   equ  IOCTL.inp_size
434
inp_size   equ  IOCTL.inp_size
435
output     equ  IOCTL.output
435
output     equ  IOCTL.output
436
out_size   equ  IOCTL.out_size
436
out_size   equ  IOCTL.out_size
437
 
437
 
438
align 4
438
align 4
439
proc service_proc stdcall, ioctl:dword
439
proc service_proc stdcall, ioctl:dword
440
 
440
 
441
        mov     edi, [ioctl]
441
        mov     edi, [ioctl]
442
        mov     eax, [edi+io_code]
442
        mov     eax, [edi+io_code]
443
 
443
 
444
        cmp     eax, SRV_GETVERSION
444
        cmp     eax, SRV_GETVERSION
445
        jne     @F
445
        jne     @F
446
        mov     eax, [edi+output]
446
        mov     eax, [edi+output]
447
        cmp     [edi+out_size], 4
447
        cmp     [edi+out_size], 4
448
        jne     .fail
448
        jne     .fail
449
 
449
 
450
        mov     [eax], dword API_VERSION
450
        mov     [eax], dword API_VERSION
451
        xor     eax, eax
451
        xor     eax, eax
452
        ret
452
        ret
453
@@:
453
@@:
454
        cmp     eax, DEV_PLAY
454
        cmp     eax, DEV_PLAY
455
        jne     @F
455
        jne     @F
456
     if DEBUG
456
     if DEBUG
457
        mov     esi, msgPlay
457
        mov     esi, msgPlay
458
        call    SysMsgBoardStr
458
        call    SysMsgBoardStr
459
     end if
459
     end if
460
        call    play
460
        call    play
461
        ret
461
        ret
462
@@:
462
@@:
463
        cmp     eax, DEV_STOP
463
        cmp     eax, DEV_STOP
464
        jne     @F
464
        jne     @F
465
     if DEBUG
465
     if DEBUG
466
        mov     esi, msgStop
466
        mov     esi, msgStop
467
        call    SysMsgBoardStr
467
        call    SysMsgBoardStr
468
     end if
468
     end if
469
        call    stop
469
        call    stop
470
        ret
470
        ret
471
@@:
471
@@:
472
        cmp     eax, DEV_CALLBACK
472
        cmp     eax, DEV_CALLBACK
473
        jne     @F
473
        jne     @F
474
        mov     ebx, [edi+input]
474
        mov     ebx, [edi+input]
475
        stdcall set_callback, [ebx]
475
        stdcall set_callback, [ebx]
476
        ret
476
        ret
477
@@:
477
@@:
478
        cmp     eax, DEV_SET_MASTERVOL
478
        cmp     eax, DEV_SET_MASTERVOL
479
        jne     @F
479
        jne     @F
480
        mov     eax, [edi+input]
480
        mov     eax, [edi+input]
481
        mov     eax, [eax]
481
        mov     eax, [eax]
482
        call    set_master_vol          ;eax= vol
482
        call    set_master_vol          ;eax= vol
483
        ret
483
        ret
484
@@:
484
@@:
485
        cmp     eax, DEV_GET_MASTERVOL
485
        cmp     eax, DEV_GET_MASTERVOL
486
        jne     @F
486
        jne     @F
487
        mov     ebx, [edi+output]
487
        mov     ebx, [edi+output]
488
        stdcall get_master_vol, ebx
488
        stdcall get_master_vol, ebx
489
        ret
489
        ret
490
@@:
490
@@:
491
        cmp     eax, DEV_GET_INFO
491
        cmp     eax, DEV_GET_INFO
492
        jne     @F
492
        jne     @F
493
        mov     ebx, [edi+output]
493
        mov     ebx, [edi+output]
494
        stdcall get_dev_info, ebx
494
        stdcall get_dev_info, 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
        stdcall KernelAlloc, 0x10000
540
        stdcall 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
        call    GetPgAddr
550
        call    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
        call    GetPgAddr
578
        call    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
        call    PciApi
657
        call    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
        stdcall PciRead32, [bus], [devfn], dword 0
666
        stdcall 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
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
726
        stdcall 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
        call    SysMsgBoardStr
734
        call    SysMsgBoardStr
735
        call    dword2str
735
        call    dword2str
736
        call    SysMsgBoardStr
736
        call    SysMsgBoardStr
737
 
737
 
738
        mov     esi, msgPciStat
738
        mov     esi, msgPciStat
739
        call    SysMsgBoardStr
739
        call    SysMsgBoardStr
740
        mov     eax, [ctrl.pci_stat]
740
        mov     eax, [ctrl.pci_stat]
741
        call    dword2str
741
        call    dword2str
742
        call    SysMsgBoardStr
742
        call    SysMsgBoardStr
743
 
743
 
744
        mov     esi, msgCtrlIsaIo
744
        mov     esi, msgCtrlIsaIo
745
        call    SysMsgBoardStr
745
        call    SysMsgBoardStr
746
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
746
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
747
        call    dword2str
747
        call    dword2str
748
        call    SysMsgBoardStr
748
        call    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
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
754
        stdcall 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
        call    SysMsgBoardStr
801
        call    SysMsgBoardStr
802
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
802
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
803
        and     eax, 0xFF
803
        and     eax, 0xFF
804
        call    dword2str
804
        call    dword2str
805
        call    SysMsgBoardStr
805
        call    SysMsgBoardStr
806
 
806
 
807
        mov     esi, msgStatus
807
        mov     esi, msgStatus
808
        call    SysMsgBoardStr
808
        call    SysMsgBoardStr
809
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
809
        stdcall 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
        call    SysMsgBoardStr
813
        call    SysMsgBoardStr
814
        pop     eax
814
        pop     eax
815
 
815
 
816
        test    eax, VIA_ACLINK_C00_READY
816
        test    eax, VIA_ACLINK_C00_READY
817
        jz      .ready
817
        jz      .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
        stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \
842
        stdcall 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
        call    SysMsgBoardStr
852
        call    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
        call    SysMsgBoardStr
859
        call    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
        stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0
873
        stdcall 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
        call    SysMsgBoardStr
877
        call    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
        stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT
885
        stdcall 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
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
889
        stdcall 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
        call    SysMsgBoardStr
901
        call    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
        call    SysMsgBoardStr
909
        call    SysMsgBoardStr
910
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
910
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
911
        call    dword2str
911
        call    dword2str
912
        call    SysMsgBoardStr
912
        call    SysMsgBoardStr
913
 
913
 
914
        mov     esi, msgStatus
914
        mov     esi, msgStatus
915
        call    SysMsgBoardStr
915
        call    SysMsgBoardStr
916
        stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
916
        stdcall 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
        call    SysMsgBoardStr
920
        call    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
        call    SysMsgBoardStr
1075
        call    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
        call    SysMsgBoardStr
1108
        call    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
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
1232
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
1233
 
1233
 
1234
msg_VT82C686 db 'VT82C686', 13,10, 0
1234
msg_VT82C686 db 'VT82C686', 13,10, 0
1235
msg_VT8233   db 'VT8233',   13,10, 0
1235
msg_VT8233   db 'VT8233',   13,10, 0
1236
msg_VIA      db 'VIA'   ,   13,10, 0
1236
msg_VIA      db 'VIA'   ,   13,10, 0
1237
 
1237
 
1238
szKernel            db 'KERNEL', 0
1238
szKernel            db 'KERNEL', 0
1239
sz_sound_srv        db 'SOUND',0
1239
sz_sound_srv        db 'SOUND',0
1240
 
1240
 
1241
msgInit      db 'detect hardware...',13,10,0
1241
msgInit      db 'detect hardware...',13,10,0
1242
msgFail      db 'device not found',13,10,0
1242
msgFail      db 'device not found',13,10,0
1243
msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
1243
msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
1244
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1244
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1245
msgPlay      db 'start play', 13,10,0
1245
msgPlay      db 'start play', 13,10,0
1246
msgStop      db 'stop play',  13,10,0
1246
msgStop      db 'stop play',  13,10,0
1247
;msgIRQ       db 'AC97 IRQ', 13,10,0
1247
;msgIRQ       db 'AC97 IRQ', 13,10,0
1248
;msgInitCtrl  db 'init controller',13,10,0
1248
;msgInitCtrl  db 'init controller',13,10,0
1249
;msgInitCodec db 'init codec',13,10,0
1249
;msgInitCodec db 'init codec',13,10,0
1250
msgPrimBuff  db 'create primary buffer ...',0
1250
msgPrimBuff  db 'create primary buffer ...',0
1251
msgDone      db 'done',13,10,0
1251
msgDone      db 'done',13,10,0
1252
msgRemap     db 'Remap IRQ',13,10,0
1252
msgRemap     db 'Remap IRQ',13,10,0
1253
;msgReg       db 'set service handler',13,10,0
1253
;msgReg       db 'set service handler',13,10,0
1254
;msgOk        db 'service installed',13,10,0
1254
;msgOk        db 'service installed',13,10,0
1255
msgCold      db 'cold reset',13,10,0
1255
msgCold      db 'cold reset',13,10,0
1256
;msgWarm      db 'warm reset',13,10,0
1256
;msgWarm      db 'warm reset',13,10,0
1257
;msgWRFail    db 'warm reset failed',13,10,0
1257
;msgWRFail    db 'warm reset failed',13,10,0
1258
msgCRFail    db 'cold reset failed',13,10,0
1258
msgCRFail    db 'cold reset failed',13,10,0
1259
msgCFail     db 'codec not ready',13,10,0
1259
msgCFail     db 'codec not ready',13,10,0
1260
msgCInvalid  db 'codec is not valid',13,10,0 ;Asper
1260
msgCInvalid  db 'codec is not valid',13,10,0 ;Asper
1261
msgResetOk   db 'reset complete',13,10,0
1261
msgResetOk   db 'reset complete',13,10,0
1262
msgStatus    db 'global status   ',0
1262
msgStatus    db 'global status   ',0
1263
msgControl   db 'global control  ',0
1263
msgControl   db 'global control  ',0
1264
msgPciCmd    db 'PCI command     ',0
1264
msgPciCmd    db 'PCI command     ',0
1265
msgPciStat   db 'PCI status      ',0
1265
msgPciStat   db 'PCI status      ',0
1266
msgCtrlIsaIo db 'controller io base   ',0
1266
msgCtrlIsaIo db 'controller io base   ',0
1267
;msgMixIsaIo  db 'codec io base        ',0
1267
;msgMixIsaIo  db 'codec io base        ',0
1268
;msgCtrlMMIo  db 'controller mmio base ',0
1268
;msgCtrlMMIo  db 'controller mmio base ',0
1269
;msgMixMMIo   db 'codec mmio base      ',0
1269
;msgMixMMIo   db 'codec mmio base      ',0
1270
;msgIrqMap    db 'AC97 irq map as      ',0
1270
;msgIrqMap    db 'AC97 irq map as      ',0
1271
 
1271
 
1272
 
1272
 
1273
section '.data' data readable writable align 16
1273
section '.data' data readable writable align 16
1274
 
1274
 
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
>