Subversion Repositories Kolibri OS

Rev

Rev 9274 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9274 Rev 9285
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
format PE DLL native 0.05
8
format PE DLL native 0.05
9
section '.flat' code readable writable executable
9
section '.flat' code readable writable executable
10
 
10
 
11
DEBUG		equ 1
11
DEBUG		equ 1
12
FDEBUG		equ 0
12
FDEBUG		equ 0
13
DEBUG_IRQ	equ 0
13
DEBUG_IRQ	equ 0
14
 
14
 
15
USE_SINGLE_MODE equ  0	 ; 1 = Single mode; 0 = Normal mode.
15
USE_SINGLE_MODE equ  0	 ; 1 = Single mode; 0 = Normal mode.
16
USE_UNSOL_EV	equ  1	 ; 1 = Use unsolicited events; 0 = Do not use unsolicited events.
16
USE_UNSOL_EV	equ  1	 ; 1 = Use unsolicited events; 0 = Do not use unsolicited events.
17
 
17
 
18
TEST_VERSION_NUMBER  equ '019a'
18
TEST_VERSION_NUMBER  equ '019a'
19
 
19
 
20
;Asper+ [
20
;Asper+ [
21
SDO_TAG  equ 1	      ;Output stream tag id (any number except 0)
21
SDO_TAG  equ 1	      ;Output stream tag id (any number except 0)
22
SDO_IDX  equ 4	      ;Output stream index
22
SDO_IDX  equ 4	      ;Output stream index
23
;According to "Intel® I/O Controller Hub 6 (ICH6) High Definition Audio / AC ’97 Programmer’s Reference Manual (PRM) May 2005 Document"
23
;According to "Intel� I/O Controller Hub 6 (ICH6) High Definition Audio / AC �97 Programmer�s Reference Manual (PRM) May 2005 Document"
24
;and "Intel® I/O Controller Hub 6 (ICH6) Family Datasheet" SDO0=4,
24
;and "Intel� I/O Controller Hub 6 (ICH6) Family Datasheet" SDO0=4,
25
;but according to "High Definition Audio Specification Revision 1.0a June 17, 2010" SDO0 depends on the number of SDIs.
25
;but according to "High Definition Audio Specification Revision 1.0a June 17, 2010" SDO0 depends on the number of SDIs.
26
 
26
 
27
SDO_INT 	equ 1 shl SDO_IDX	;Output stream interrupt (must be power of 2)
27
SDO_INT 	equ 1 shl SDO_IDX	;Output stream interrupt (must be power of 2)
28
SDO_OFS 	equ 0x80+(SDO_IDX*0x20) ;Output stream offset
28
SDO_OFS 	equ 0x80+(SDO_IDX*0x20) ;Output stream offset
29
;Asper+ ]
29
;Asper+ ]
30
 
30
 
31
CURRENT_API	equ   0x0100	  ;1.00
31
CURRENT_API	equ   0x0100	  ;1.00
32
COMPATIBLE_API	equ   0x0101	  ;1.01
32
COMPATIBLE_API	equ   0x0101	  ;1.01
33
API_VERSION	equ   (COMPATIBLE_API shl 16) or CURRENT_API
33
API_VERSION	equ   (COMPATIBLE_API shl 16) or CURRENT_API
34
 
34
 
35
IRQ_REMAP	equ 0
35
IRQ_REMAP	equ 0
36
IRQ_LINE	equ 0
36
IRQ_LINE	equ 0
37
 
37
 
38
CPU_FREQ	equ  2600d
38
CPU_FREQ	equ  2600d
39
 
39
 
40
; Vendors
40
; Vendors
41
VID_INTEL	  equ 0x8086
41
VID_INTEL	  equ 0x8086
42
VID_NVIDIA	  equ 0x10DE
42
VID_NVIDIA	  equ 0x10DE
43
VID_ATI 	  equ 0x1002
43
VID_ATI 	  equ 0x1002
44
VID_AMD 	  equ 0x1022
44
VID_AMD 	  equ 0x1022
45
VID_VIA 	  equ 0x1106
45
VID_VIA 	  equ 0x1106
46
VID_SIS 	  equ 0x1039
46
VID_SIS 	  equ 0x1039
47
VID_ULI 	  equ 0x10B9
47
VID_ULI 	  equ 0x10B9
48
VID_CREATIVE	  equ 0x1102
48
VID_CREATIVE	  equ 0x1102
49
VID_TERA	  equ 0x6549
49
VID_TERA	  equ 0x6549
50
VID_RDC 	  equ 0x17F3
50
VID_RDC 	  equ 0x17F3
51
VID_VMWARE	  equ 0x15AD
51
VID_VMWARE	  equ 0x15AD
52
 
52
 
53
; Devices
53
; Devices
54
; Intel
54
; Intel
55
CTRL_INTEL_SCH2       equ  0x080a
55
CTRL_INTEL_SCH2       equ  0x080a
56
CTRL_INTEL_HPT	      equ  0x0c0c
56
CTRL_INTEL_HPT	      equ  0x0c0c
57
CTRL_INTEL_0F04       equ  0x0F04
57
CTRL_INTEL_0F04       equ  0x0F04
58
CTRL_INTEL_CPT	      equ  0x1c20
58
CTRL_INTEL_CPT	      equ  0x1c20
59
CTRL_INTEL_PGB	      equ  0x1d20
59
CTRL_INTEL_PGB	      equ  0x1d20
60
CTRL_INTEL_PPT1       equ  0x1e20
60
CTRL_INTEL_PPT1       equ  0x1e20
61
CTRL_INTEL_2284       equ  0x2284
61
CTRL_INTEL_2284       equ  0x2284
62
CTRL_INTEL_ICH6       equ  0x2668
62
CTRL_INTEL_ICH6       equ  0x2668
63
CTRL_INTEL_63XXESB    equ  0x269a
63
CTRL_INTEL_63XXESB    equ  0x269a
64
CTRL_INTEL_ICH7       equ  0x27d8
64
CTRL_INTEL_ICH7       equ  0x27d8
65
CTRL_INTEL_ICH8       equ  0x284b
65
CTRL_INTEL_ICH8       equ  0x284b
66
CTRL_INTEL_82801_UNK1 equ  0x2911
66
CTRL_INTEL_82801_UNK1 equ  0x2911
67
CTRL_INTEL_ICH9       equ  0x293e
67
CTRL_INTEL_ICH9       equ  0x293e
68
CTRL_INTEL_ICH9_2     equ  0x293f
68
CTRL_INTEL_ICH9_2     equ  0x293f
69
CTRL_INTEL_ICH10      equ  0x3a3e
69
CTRL_INTEL_ICH10      equ  0x3a3e
70
CTRL_INTEL_ICH10_2    equ  0x3a6e
70
CTRL_INTEL_ICH10_2    equ  0x3a6e
71
CTRL_INTEL_PCH	      equ  0x3b56
71
CTRL_INTEL_PCH	      equ  0x3b56
72
CTRL_INTEL_PCH2       equ  0x3b57
72
CTRL_INTEL_PCH2       equ  0x3b57
73
CTRL_INTEL_SCH	      equ  0x811b
73
CTRL_INTEL_SCH	      equ  0x811b
74
CTRL_INTEL_LPT	      equ  0x8c20
74
CTRL_INTEL_LPT	      equ  0x8c20
75
CTRL_INTEL_8ca0       equ  0x8cA0
75
CTRL_INTEL_8ca0       equ  0x8cA0
76
CTRL_INTEL_8d20       equ  0x8d20
76
CTRL_INTEL_8d20       equ  0x8d20
77
CTRL_INTEL_8d21       equ  0x8d21
77
CTRL_INTEL_8d21       equ  0x8d21
78
CTRL_INTEL_A1F0       equ  0xA1F0
78
CTRL_INTEL_A1F0       equ  0xA1F0
79
CTRL_INTEL_A270       equ  0xA270
79
CTRL_INTEL_A270       equ  0xA270
80
CTRL_INTEL_9C20       equ  0x9c20
80
CTRL_INTEL_9C20       equ  0x9c20
81
CTRL_INTEL_9C21       equ  0x9c21
81
CTRL_INTEL_9C21       equ  0x9c21
82
CTRL_INTEL_9CA0       equ  0x9cA0
82
CTRL_INTEL_9CA0       equ  0x9cA0
83
CTRL_INTEL_A170       equ  0xA170
83
CTRL_INTEL_A170       equ  0xA170
84
CTRL_INTEL_9D70       equ  0x9D70
84
CTRL_INTEL_9D70       equ  0x9D70
85
CTRL_INTEL_5A98       equ  0x5A98
85
CTRL_INTEL_5A98       equ  0x5A98
86
; Nvidia
86
; Nvidia
87
CTRL_NVIDIA_MCP51	 equ  0x026c
87
CTRL_NVIDIA_MCP51	 equ  0x026c
88
CTRL_NVIDIA_MCP55	 equ  0x0371
88
CTRL_NVIDIA_MCP55	 equ  0x0371
89
CTRL_NVIDIA_MCP61_1	 equ  0x03e4
89
CTRL_NVIDIA_MCP61_1	 equ  0x03e4
90
CTRL_NVIDIA_MCP61_2	 equ  0x03f0
90
CTRL_NVIDIA_MCP61_2	 equ  0x03f0
91
CTRL_NVIDIA_MCP65_1	 equ  0x044a
91
CTRL_NVIDIA_MCP65_1	 equ  0x044a
92
CTRL_NVIDIA_MCP65_2	 equ  0x044b
92
CTRL_NVIDIA_MCP65_2	 equ  0x044b
93
CTRL_NVIDIA_MCP67_1	 equ  0x055c
93
CTRL_NVIDIA_MCP67_1	 equ  0x055c
94
CTRL_NVIDIA_MCP67_2	 equ  0x055d
94
CTRL_NVIDIA_MCP67_2	 equ  0x055d
95
CTRL_NVIDIA_MCP78_1	 equ  0x0774
95
CTRL_NVIDIA_MCP78_1	 equ  0x0774
96
CTRL_NVIDIA_MCP78_2	 equ  0x0775
96
CTRL_NVIDIA_MCP78_2	 equ  0x0775
97
CTRL_NVIDIA_MCP78_3	 equ  0x0776
97
CTRL_NVIDIA_MCP78_3	 equ  0x0776
98
CTRL_NVIDIA_MCP78_4	 equ  0x0777
98
CTRL_NVIDIA_MCP78_4	 equ  0x0777
99
CTRL_NVIDIA_MCP73_1	 equ  0x07fc
99
CTRL_NVIDIA_MCP73_1	 equ  0x07fc
100
CTRL_NVIDIA_MCP73_2	 equ  0x07fd
100
CTRL_NVIDIA_MCP73_2	 equ  0x07fd
101
CTRL_NVIDIA_MCP79_1	 equ  0x0ac0
101
CTRL_NVIDIA_MCP79_1	 equ  0x0ac0
102
CTRL_NVIDIA_MCP79_2	 equ  0x0ac1
102
CTRL_NVIDIA_MCP79_2	 equ  0x0ac1
103
CTRL_NVIDIA_MCP79_3	 equ  0x0ac2
103
CTRL_NVIDIA_MCP79_3	 equ  0x0ac2
104
CTRL_NVIDIA_MCP79_4	 equ  0x0ac3
104
CTRL_NVIDIA_MCP79_4	 equ  0x0ac3
105
CTRL_NVIDIA_0BE2	 equ  0x0be2
105
CTRL_NVIDIA_0BE2	 equ  0x0be2
106
CTRL_NVIDIA_0BE3	 equ  0x0be3
106
CTRL_NVIDIA_0BE3	 equ  0x0be3
107
CTRL_NVIDIA_0BE4	 equ  0x0be4
107
CTRL_NVIDIA_0BE4	 equ  0x0be4
108
CTRL_NVIDIA_GT100	 equ  0x0be5
108
CTRL_NVIDIA_GT100	 equ  0x0be5
109
CTRL_NVIDIA_GT106	 equ  0x0be9
109
CTRL_NVIDIA_GT106	 equ  0x0be9
110
CTRL_NVIDIA_GT108	 equ  0x0bea
110
CTRL_NVIDIA_GT108	 equ  0x0bea
111
CTRL_NVIDIA_GT104	 equ  0x0beb
111
CTRL_NVIDIA_GT104	 equ  0x0beb
112
CTRL_NVIDIA_GT116	 equ  0x0bee
112
CTRL_NVIDIA_GT116	 equ  0x0bee
113
CTRL_NVIDIA_MCP89_1	 equ  0x0d94
113
CTRL_NVIDIA_MCP89_1	 equ  0x0d94
114
CTRL_NVIDIA_MCP89_2	 equ  0x0d95
114
CTRL_NVIDIA_MCP89_2	 equ  0x0d95
115
CTRL_NVIDIA_MCP89_3	 equ  0x0d96
115
CTRL_NVIDIA_MCP89_3	 equ  0x0d96
116
CTRL_NVIDIA_MCP89_4	 equ  0x0d97
116
CTRL_NVIDIA_MCP89_4	 equ  0x0d97
117
CTRL_NVIDIA_GF119	 equ  0x0e08
117
CTRL_NVIDIA_GF119	 equ  0x0e08
118
CTRL_NVIDIA_GF110_1	 equ  0x0e09
118
CTRL_NVIDIA_GF110_1	 equ  0x0e09
119
CTRL_NVIDIA_GF110_2	 equ  0x0e0c
119
CTRL_NVIDIA_GF110_2	 equ  0x0e0c
120
; ATI
120
; ATI
121
CTRL_ATI_SB450		 equ  0x437b
121
CTRL_ATI_SB450		 equ  0x437b
122
CTRL_ATI_SB600		 equ  0x4383
122
CTRL_ATI_SB600		 equ  0x4383
123
; ATI HDMI
123
; ATI HDMI
124
CTRL_ATI_RS600		 equ  0x793b
124
CTRL_ATI_RS600		 equ  0x793b
125
CTRL_ATI_RS690		 equ  0x7919
125
CTRL_ATI_RS690		 equ  0x7919
126
CTRL_ATI_RS780		 equ  0x960f
126
CTRL_ATI_RS780		 equ  0x960f
127
CTRL_ATI_RS_UNK1	 equ  0x970f
127
CTRL_ATI_RS_UNK1	 equ  0x970f
128
CTRL_ATI_R600		 equ  0xaa00
128
CTRL_ATI_R600		 equ  0xaa00
129
CTRL_ATI_RV630		 equ  0xaa08
129
CTRL_ATI_RV630		 equ  0xaa08
130
CTRL_ATI_RV610		 equ  0xaa10
130
CTRL_ATI_RV610		 equ  0xaa10
131
CTRL_ATI_RV670		 equ  0xaa18
131
CTRL_ATI_RV670		 equ  0xaa18
132
CTRL_ATI_RV635		 equ  0xaa20
132
CTRL_ATI_RV635		 equ  0xaa20
133
CTRL_ATI_RV620		 equ  0xaa28
133
CTRL_ATI_RV620		 equ  0xaa28
134
CTRL_ATI_RV770		 equ  0xaa30
134
CTRL_ATI_RV770		 equ  0xaa30
135
CTRL_ATI_RV730		 equ  0xaa38
135
CTRL_ATI_RV730		 equ  0xaa38
136
CTRL_ATI_RV710		 equ  0xaa40
136
CTRL_ATI_RV710		 equ  0xaa40
137
CTRL_ATI_RV740		 equ  0xaa48
137
CTRL_ATI_RV740		 equ  0xaa48
138
; AMD
138
; AMD
139
CTRL_AMD_HUDSON 	 equ  0x780d
139
CTRL_AMD_HUDSON 	 equ  0x780d
140
CTRL_AMD_RAVEN_RIDGE	 equ  0x15e3
140
CTRL_AMD_RAVEN_RIDGE	 equ  0x15e3
-
 
141
CTRL_AMD_MATISSE	 equ  0x1487
141
; VIA
142
; VIA
142
CTRL_VIA_VT82XX 	 equ  0x3288
143
CTRL_VIA_VT82XX 	 equ  0x3288
143
CTRL_VIA_VT61XX 	 equ  0x9140
144
CTRL_VIA_VT61XX 	 equ  0x9140
144
CTRL_VIA_VT71XX 	 equ  0x9170
145
CTRL_VIA_VT71XX 	 equ  0x9170
145
; SiS
146
; SiS
146
CTRL_SIS_966		 equ  0x7502
147
CTRL_SIS_966		 equ  0x7502
147
; ULI
148
; ULI
148
CTRL_ULI_M5461		 equ  0x5461
149
CTRL_ULI_M5461		 equ  0x5461
149
; Creative
150
; Creative
150
CTRL_CREATIVE_CA0110_IBG     equ  0x0009
151
CTRL_CREATIVE_CA0110_IBG     equ  0x0009
151
CTRL_CREATIVE_SOUND_CORE3D_1 equ  0x0010
152
CTRL_CREATIVE_SOUND_CORE3D_1 equ  0x0010
152
CTRL_CREATIVE_SOUND_CORE3D_2 equ  0x0012
153
CTRL_CREATIVE_SOUND_CORE3D_2 equ  0x0012
153
; Teradici
154
; Teradici
154
CTRL_TERA_UNK1		 equ  0x1200
155
CTRL_TERA_UNK1		 equ  0x1200
155
; RDC Semiconductor
156
; RDC Semiconductor
156
CTRL_RDC_R3010		 equ  0x3010
157
CTRL_RDC_R3010		 equ  0x3010
157
;VMware
158
;VMware
158
CTRL_VMWARE_UNK1	 equ  0x1977
159
CTRL_VMWARE_UNK1	 equ  0x1977
159
 
160
 
160
 
161
 
161
; driver types
162
; driver types
162
AZX_DRIVER_ICH		 equ  0
163
AZX_DRIVER_ICH		 equ  0
163
AZX_DRIVER_PCH		 equ  1
164
AZX_DRIVER_PCH		 equ  1
164
AZX_DRIVER_SCH		 equ  2
165
AZX_DRIVER_SCH		 equ  2
165
AZX_DRIVER_ATI		 equ  3
166
AZX_DRIVER_ATI		 equ  3
166
AZX_DRIVER_ATIHDMI	 equ  4
167
AZX_DRIVER_ATIHDMI	 equ  4
167
AZX_DRIVER_VIA		 equ  5
168
AZX_DRIVER_VIA		 equ  5
168
AZX_DRIVER_SIS		 equ  6
169
AZX_DRIVER_SIS		 equ  6
169
AZX_DRIVER_ULI		 equ  7
170
AZX_DRIVER_ULI		 equ  7
170
AZX_DRIVER_NVIDIA	 equ  8
171
AZX_DRIVER_NVIDIA	 equ  8
171
AZX_DRIVER_TERA 	 equ  9
172
AZX_DRIVER_TERA 	 equ  9
172
AZX_DRIVER_CTX		 equ  10
173
AZX_DRIVER_CTX		 equ  10
173
AZX_DRIVER_GENERIC	 equ  11
174
AZX_DRIVER_GENERIC	 equ  11
174
AZX_NUM_DRIVERS 	 equ  12
175
AZX_NUM_DRIVERS 	 equ  12
175
 
176
 
176
 
177
 
177
; registers
178
; registers
178
 
179
 
179
ICH6_REG_GCAP		 equ  0x00
180
ICH6_REG_GCAP		 equ  0x00
180
ICH6_REG_VMIN		 equ  0x02
181
ICH6_REG_VMIN		 equ  0x02
181
ICH6_REG_VMAJ		 equ  0x03
182
ICH6_REG_VMAJ		 equ  0x03
182
ICH6_REG_OUTPAY 	 equ  0x04
183
ICH6_REG_OUTPAY 	 equ  0x04
183
ICH6_REG_INPAY		 equ  0x06
184
ICH6_REG_INPAY		 equ  0x06
184
ICH6_REG_GCTL		 equ  0x08
185
ICH6_REG_GCTL		 equ  0x08
185
  ICH6_GCTL_RESET	   equ	(1 shl 0)  ; controller reset
186
  ICH6_GCTL_RESET	   equ	(1 shl 0)  ; controller reset
186
  ICH6_GCTL_FCNTRL	   equ	(1 shl 1)  ; flush control
187
  ICH6_GCTL_FCNTRL	   equ	(1 shl 1)  ; flush control
187
  ICH6_GCTL_UNSOL	   equ	(1 shl 8)  ; accept unsol. response enable
188
  ICH6_GCTL_UNSOL	   equ	(1 shl 8)  ; accept unsol. response enable
188
ICH6_REG_WAKEEN 	 equ  0x0c
189
ICH6_REG_WAKEEN 	 equ  0x0c
189
ICH6_REG_STATESTS	 equ  0x0e
190
ICH6_REG_STATESTS	 equ  0x0e
190
ICH6_REG_GSTS		 equ  0x10
191
ICH6_REG_GSTS		 equ  0x10
191
  ICH6_GSTS_FSTS	   equ	(1 shl 1)  ; flush status
192
  ICH6_GSTS_FSTS	   equ	(1 shl 1)  ; flush status
192
ICH6_REG_INTCTL 	 equ  0x20
193
ICH6_REG_INTCTL 	 equ  0x20
193
ICH6_REG_INTSTS 	 equ  0x24
194
ICH6_REG_INTSTS 	 equ  0x24
194
ICH6_REG_WALLCLK	 equ  0x30  ; 24Mhz source
195
ICH6_REG_WALLCLK	 equ  0x30  ; 24Mhz source
195
ICH6_REG_OLD_SSYNC	 equ  0x34  ; SSYNC for old ICH
196
ICH6_REG_OLD_SSYNC	 equ  0x34  ; SSYNC for old ICH
196
ICH6_REG_SSYNC		 equ  0x38
197
ICH6_REG_SSYNC		 equ  0x38
197
ICH6_REG_CORBLBASE	 equ  0x40
198
ICH6_REG_CORBLBASE	 equ  0x40
198
ICH6_REG_CORBUBASE	 equ  0x44
199
ICH6_REG_CORBUBASE	 equ  0x44
199
ICH6_REG_CORBWP 	 equ  0x48
200
ICH6_REG_CORBWP 	 equ  0x48
200
ICH6_REG_CORBRP 	 equ  0x4A
201
ICH6_REG_CORBRP 	 equ  0x4A
201
  ICH6_CORBRP_RST	   equ	(1 shl 15)  ; read pointer reset
202
  ICH6_CORBRP_RST	   equ	(1 shl 15)  ; read pointer reset
202
ICH6_REG_CORBCTL	 equ  0x4c
203
ICH6_REG_CORBCTL	 equ  0x4c
203
  ICH6_CORBCTL_RUN	   equ	(1 shl 1)   ; enable DMA
204
  ICH6_CORBCTL_RUN	   equ	(1 shl 1)   ; enable DMA
204
  ICH6_CORBCTL_CMEIE	   equ	(1 shl 0)   ; enable memory error irq
205
  ICH6_CORBCTL_CMEIE	   equ	(1 shl 0)   ; enable memory error irq
205
ICH6_REG_CORBSTS	 equ  0x4d
206
ICH6_REG_CORBSTS	 equ  0x4d
206
  ICH6_CORBSTS_CMEI	   equ	(1 shl 0)   ; memory error indication
207
  ICH6_CORBSTS_CMEI	   equ	(1 shl 0)   ; memory error indication
207
ICH6_REG_CORBSIZE	 equ  0x4e
208
ICH6_REG_CORBSIZE	 equ  0x4e
208
 
209
 
209
ICH6_REG_RIRBLBASE	 equ  0x50
210
ICH6_REG_RIRBLBASE	 equ  0x50
210
ICH6_REG_RIRBUBASE	 equ  0x54
211
ICH6_REG_RIRBUBASE	 equ  0x54
211
ICH6_REG_RIRBWP 	 equ  0x58
212
ICH6_REG_RIRBWP 	 equ  0x58
212
  ICH6_RIRBWP_RST	   equ	(1 shl 15)  ; write pointer reset
213
  ICH6_RIRBWP_RST	   equ	(1 shl 15)  ; write pointer reset
213
ICH6_REG_RINTCNT	 equ  0x5a
214
ICH6_REG_RINTCNT	 equ  0x5a
214
ICH6_REG_RIRBCTL	 equ  0x5c
215
ICH6_REG_RIRBCTL	 equ  0x5c
215
  ICH6_RBCTL_IRQ_EN	   equ	(1 shl 0)   ; enable IRQ
216
  ICH6_RBCTL_IRQ_EN	   equ	(1 shl 0)   ; enable IRQ
216
  ICH6_RBCTL_DMA_EN	   equ	(1 shl 1)   ; enable DMA
217
  ICH6_RBCTL_DMA_EN	   equ	(1 shl 1)   ; enable DMA
217
  ICH6_RBCTL_OVERRUN_EN    equ	(1 shl 2)   ; enable overrun irq
218
  ICH6_RBCTL_OVERRUN_EN    equ	(1 shl 2)   ; enable overrun irq
218
ICH6_REG_RIRBSTS	 equ  0x5d
219
ICH6_REG_RIRBSTS	 equ  0x5d
219
  ICH6_RBSTS_IRQ	   equ	(1 shl 0)   ; response irq
220
  ICH6_RBSTS_IRQ	   equ	(1 shl 0)   ; response irq
220
  ICH6_RBSTS_OVERRUN	   equ	(1 shl 2)   ; overrun irq
221
  ICH6_RBSTS_OVERRUN	   equ	(1 shl 2)   ; overrun irq
221
ICH6_REG_RIRBSIZE	 equ  0x5e
222
ICH6_REG_RIRBSIZE	 equ  0x5e
222
 
223
 
223
ICH6_REG_IC		 equ  0x60
224
ICH6_REG_IC		 equ  0x60
224
ICH6_REG_IR		 equ  0x64
225
ICH6_REG_IR		 equ  0x64
225
ICH6_REG_IRS		 equ  0x68
226
ICH6_REG_IRS		 equ  0x68
226
  ICH6_IRS_VALID	   equ	2
227
  ICH6_IRS_VALID	   equ	2
227
  ICH6_IRS_BUSY 	   equ	1
228
  ICH6_IRS_BUSY 	   equ	1
228
 
229
 
229
ICH6_REG_DPLBASE	 equ  0x70
230
ICH6_REG_DPLBASE	 equ  0x70
230
ICH6_REG_DPUBASE	 equ  0x74
231
ICH6_REG_DPUBASE	 equ  0x74
231
  ICH6_DPLBASE_ENABLE	   equ	1     ; Enable position buffer
232
  ICH6_DPLBASE_ENABLE	   equ	1     ; Enable position buffer
232
 
233
 
233
; SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
234
; SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
234
SDI0_SD_OFFSET	  equ  0x80
235
SDI0_SD_OFFSET	  equ  0x80
235
SDI1_SD_OFFSET	  equ  0xA0
236
SDI1_SD_OFFSET	  equ  0xA0
236
SDI2_SD_OFFSET	  equ  0xC0
237
SDI2_SD_OFFSET	  equ  0xC0
237
SDI3_SD_OFFSET	  equ  0xE0
238
SDI3_SD_OFFSET	  equ  0xE0
238
SDO0_SD_OFFSET	  equ  0x100
239
SDO0_SD_OFFSET	  equ  0x100
239
SDO1_SD_OFFSET	  equ  0x120
240
SDO1_SD_OFFSET	  equ  0x120
240
SDO2_SD_OFFSET	  equ  0X140
241
SDO2_SD_OFFSET	  equ  0X140
241
SDO3_SD_OFFSET	  equ  0x160
242
SDO3_SD_OFFSET	  equ  0x160
242
 
243
 
243
; stream register offsets from stream base
244
; stream register offsets from stream base
244
ICH6_REG_SD_CTL 	 equ  0x00
245
ICH6_REG_SD_CTL 	 equ  0x00
245
ICH6_REG_SD_STS 	 equ  0x03
246
ICH6_REG_SD_STS 	 equ  0x03
246
ICH6_REG_SD_LPIB	 equ  0x04
247
ICH6_REG_SD_LPIB	 equ  0x04
247
ICH6_REG_SD_CBL 	 equ  0x08
248
ICH6_REG_SD_CBL 	 equ  0x08
248
ICH6_REG_SD_LVI 	 equ  0x0c
249
ICH6_REG_SD_LVI 	 equ  0x0c
249
ICH6_REG_SD_FIFOW	 equ  0x0e
250
ICH6_REG_SD_FIFOW	 equ  0x0e
250
ICH6_REG_SD_FIFOSIZE	 equ  0x10
251
ICH6_REG_SD_FIFOSIZE	 equ  0x10
251
ICH6_REG_SD_FORMAT	 equ  0x12
252
ICH6_REG_SD_FORMAT	 equ  0x12
252
ICH6_REG_SD_BDLPL	 equ  0x18
253
ICH6_REG_SD_BDLPL	 equ  0x18
253
ICH6_REG_SD_BDLPU	 equ  0x1c
254
ICH6_REG_SD_BDLPU	 equ  0x1c
254
 
255
 
255
; PCI space
256
; PCI space
256
ICH6_PCIREG_TCSEL	 equ  0x44
257
ICH6_PCIREG_TCSEL	 equ  0x44
257
 
258
 
258
; other constants
259
; other constants
259
ICH6_RIRB_EX_UNSOL_EV	 equ   (1 shl 4)
260
ICH6_RIRB_EX_UNSOL_EV	 equ   (1 shl 4)
260
 
261
 
261
; max number of SDs
262
; max number of SDs
262
MAX_ICH6_DEV		 equ  8
263
MAX_ICH6_DEV		 equ  8
263
; max number of fragments - we may use more if allocating more pages for BDL
264
; max number of fragments - we may use more if allocating more pages for BDL
264
AZX_MAX_FRAG		 equ  (4096 / (MAX_ICH6_DEV * 16))
265
AZX_MAX_FRAG		 equ  (4096 / (MAX_ICH6_DEV * 16))
265
; max buffer size - no h/w limit, you can increase as you like
266
; max buffer size - no h/w limit, you can increase as you like
266
AZX_MAX_BUF_SIZE	 equ  (1024*1024*1024)
267
AZX_MAX_BUF_SIZE	 equ  (1024*1024*1024)
267
; max number of PCM devices per card
268
; max number of PCM devices per card
268
AZX_MAX_PCMS		 equ  8
269
AZX_MAX_PCMS		 equ  8
269
 
270
 
270
; RIRB int mask: overrun[2], response[0]
271
; RIRB int mask: overrun[2], response[0]
271
RIRB_INT_RESPONSE	 equ  0x01
272
RIRB_INT_RESPONSE	 equ  0x01
272
RIRB_INT_OVERRUN	 equ  0x04
273
RIRB_INT_OVERRUN	 equ  0x04
273
RIRB_INT_MASK		 equ  0x05
274
RIRB_INT_MASK		 equ  0x05
274
 
275
 
275
; STATESTS int mask: SD2,SD1,SD0
276
; STATESTS int mask: SD2,SD1,SD0
276
STATESTS_INT_MASK	 equ  0x07
277
STATESTS_INT_MASK	 equ  0x07
277
AZX_MAX_CODECS		 equ  4
278
AZX_MAX_CODECS		 equ  4
278
 
279
 
279
; SD_CTL bits
280
; SD_CTL bits
280
SD_CTL_STREAM_RESET	 equ  0x01    ; stream reset bit
281
SD_CTL_STREAM_RESET	 equ  0x01    ; stream reset bit
281
SD_CTL_DMA_START	 equ  0x02    ; stream DMA start bit
282
SD_CTL_DMA_START	 equ  0x02    ; stream DMA start bit
282
SD_CTL_STREAM_TAG_MASK	 equ  (0xf shl 20)
283
SD_CTL_STREAM_TAG_MASK	 equ  (0xf shl 20)
283
SD_CTL_STREAM_TAG_SHIFT  equ  20
284
SD_CTL_STREAM_TAG_SHIFT  equ  20
284
 
285
 
285
; SD_CTL and SD_STS
286
; SD_CTL and SD_STS
286
SD_INT_DESC_ERR 	 equ  0x10    ; descriptor error interrupt
287
SD_INT_DESC_ERR 	 equ  0x10    ; descriptor error interrupt
287
SD_INT_FIFO_ERR 	 equ  0x08    ; FIFO error interrupt
288
SD_INT_FIFO_ERR 	 equ  0x08    ; FIFO error interrupt
288
SD_INT_COMPLETE 	 equ  0x04    ; completion interrupt
289
SD_INT_COMPLETE 	 equ  0x04    ; completion interrupt
289
SD_INT_MASK		 equ  (SD_INT_DESC_ERR or SD_INT_FIFO_ERR or SD_INT_COMPLETE)
290
SD_INT_MASK		 equ  (SD_INT_DESC_ERR or SD_INT_FIFO_ERR or SD_INT_COMPLETE)
290
 
291
 
291
; SD_STS
292
; SD_STS
292
SD_STS_FIFO_READY	 equ  0x20    ; FIFO ready
293
SD_STS_FIFO_READY	 equ  0x20    ; FIFO ready
293
 
294
 
294
; INTCTL and INTSTS
295
; INTCTL and INTSTS
295
ICH6_INT_ALL_STREAM	 equ  0xff	      ; all stream interrupts
296
ICH6_INT_ALL_STREAM	 equ  0xff	      ; all stream interrupts
296
ICH6_INT_CTRL_EN	 equ  0x40000000      ; controller interrupt enable bit
297
ICH6_INT_CTRL_EN	 equ  0x40000000      ; controller interrupt enable bit
297
ICH6_INT_GLOBAL_EN	 equ  0x80000000      ; global interrupt enable bit
298
ICH6_INT_GLOBAL_EN	 equ  0x80000000      ; global interrupt enable bit
298
 
299
 
299
; GCTL reset bit
300
; GCTL reset bit
300
ICH6_GCTL_RESET 	 equ  1
301
ICH6_GCTL_RESET 	 equ  1
301
 
302
 
302
; CORB/RIRB control, read/write pointer
303
; CORB/RIRB control, read/write pointer
303
ICH6_RBCTL_DMA_EN	 equ  0x02    ; enable DMA
304
ICH6_RBCTL_DMA_EN	 equ  0x02    ; enable DMA
304
ICH6_RBCTL_IRQ_EN	 equ  0x01    ; enable IRQ
305
ICH6_RBCTL_IRQ_EN	 equ  0x01    ; enable IRQ
305
ICH6_RBRWP_CLR		 equ  0x8000  ; read/write pointer clear
306
ICH6_RBRWP_CLR		 equ  0x8000  ; read/write pointer clear
306
; below are so far hardcoded - should read registers in future
307
; below are so far hardcoded - should read registers in future
307
ICH6_MAX_CORB_ENTRIES	 equ  256
308
ICH6_MAX_CORB_ENTRIES	 equ  256
308
ICH6_MAX_RIRB_ENTRIES	 equ  256
309
ICH6_MAX_RIRB_ENTRIES	 equ  256
309
 
310
 
310
; position fix mode
311
; position fix mode
311
POS_FIX_AUTO		 equ  0
312
POS_FIX_AUTO		 equ  0
312
POS_FIX_LPIB		 equ  1
313
POS_FIX_LPIB		 equ  1
313
POS_FIX_POSBUF		 equ  2
314
POS_FIX_POSBUF		 equ  2
314
POS_FIX_VIACOMBO	 equ  4
315
POS_FIX_VIACOMBO	 equ  4
315
POS_FIX_COMBO		 equ  8
316
POS_FIX_COMBO		 equ  8
316
 
317
 
317
; Defines for ATI HD Audio support in SB450 south bridge
318
; Defines for ATI HD Audio support in SB450 south bridge
318
ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR   equ  0x42
319
ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR   equ  0x42
319
ATI_SB450_HDAUDIO_ENABLE_SNOOP	    equ  0x02
320
ATI_SB450_HDAUDIO_ENABLE_SNOOP	    equ  0x02
320
 
321
 
321
; Defines for Nvidia HDA support
322
; Defines for Nvidia HDA support
322
NVIDIA_HDA_TRANSREG_ADDR	    equ  0x4e
323
NVIDIA_HDA_TRANSREG_ADDR	    equ  0x4e
323
NVIDIA_HDA_ENABLE_COHBITS	    equ  0x0f
324
NVIDIA_HDA_ENABLE_COHBITS	    equ  0x0f
324
NVIDIA_HDA_ISTRM_COH		    equ  0x4d
325
NVIDIA_HDA_ISTRM_COH		    equ  0x4d
325
NVIDIA_HDA_OSTRM_COH		    equ  0x4c
326
NVIDIA_HDA_OSTRM_COH		    equ  0x4c
326
NVIDIA_HDA_ENABLE_COHBIT	    equ  0x01
327
NVIDIA_HDA_ENABLE_COHBIT	    equ  0x01
327
 
328
 
328
; Defines for Intel SCH HDA snoop control
329
; Defines for Intel SCH HDA snoop control
329
INTEL_SCH_HDA_DEVC		    equ  0x78
330
INTEL_SCH_HDA_DEVC		    equ  0x78
330
INTEL_SCH_HDA_DEVC_NOSNOOP	    equ  (0x1 shl 11)
331
INTEL_SCH_HDA_DEVC_NOSNOOP	    equ  (0x1 shl 11)
331
 
332
 
332
; Define IN stream 0 FIFO size offset in VIA controller
333
; Define IN stream 0 FIFO size offset in VIA controller
333
VIA_IN_STREAM0_FIFO_SIZE_OFFSET     equ  0x90
334
VIA_IN_STREAM0_FIFO_SIZE_OFFSET     equ  0x90
334
; Define VIA HD Audio Device ID
335
; Define VIA HD Audio Device ID
335
VIA_HDAC_DEVICE_ID		    equ  0x3288
336
VIA_HDAC_DEVICE_ID		    equ  0x3288
336
 
337
 
337
; HD Audio class code
338
; HD Audio class code
338
PCI_CLASS_MULTIMEDIA_HD_AUDIO	    equ  0x0403
339
PCI_CLASS_MULTIMEDIA_HD_AUDIO	    equ  0x0403
339
 
340
 
340
 
341
 
341
SRV_GETVERSION		 equ  0
342
SRV_GETVERSION		 equ  0
342
DEV_PLAY		 equ  1
343
DEV_PLAY		 equ  1
343
DEV_STOP		 equ  2
344
DEV_STOP		 equ  2
344
DEV_CALLBACK		 equ  3
345
DEV_CALLBACK		 equ  3
345
DEV_SET_BUFF		 equ  4
346
DEV_SET_BUFF		 equ  4
346
DEV_NOTIFY		 equ  5
347
DEV_NOTIFY		 equ  5
347
DEV_SET_MASTERVOL	 equ  6
348
DEV_SET_MASTERVOL	 equ  6
348
DEV_GET_MASTERVOL	 equ  7
349
DEV_GET_MASTERVOL	 equ  7
349
DEV_GET_INFO		 equ  8
350
DEV_GET_INFO		 equ  8
350
DEV_GET_POS		 equ  9
351
DEV_GET_POS		 equ  9
351
DEV_SET_CHANNEL_VOLUME	 equ  10
352
DEV_SET_CHANNEL_VOLUME	 equ  10
352
DEV_GET_CHANNEL_VOLUME	 equ  11
353
DEV_GET_CHANNEL_VOLUME	 equ  11
353
;Asper: Non standard system service. For the tests only! [
354
;Asper: Non standard system service. For the tests only! [
354
DEV_EXEC_CODEC_CMD	 equ  100
355
DEV_EXEC_CODEC_CMD	 equ  100
355
;Asper: Non standard system service. For the tests only! ]
356
;Asper: Non standard system service. For the tests only! ]
356
 
357
 
357
struc AC_CNTRL		    ;AC controller base class
358
struc AC_CNTRL		    ;AC controller base class
358
{
359
{
359
	.bus		    dd ?
360
	.bus		    dd ?
360
	.devfn		    dd ?
361
	.devfn		    dd ?
361
 
362
 
362
	.vendor 	    dw ?
363
	.vendor 	    dw ?
363
	.dev_id 	    dw ?
364
	.dev_id 	    dw ?
364
	.pci_cmd	    dd ?
365
	.pci_cmd	    dd ?
365
	.pci_stat	    dd ?
366
	.pci_stat	    dd ?
366
 
367
 
367
	.ctrl_io_base	    dd ?
368
	.ctrl_io_base	    dd ?
368
	.ctrl_mem_base	    dd ?
369
	.ctrl_mem_base	    dd ?
369
	.cfg_reg	    dd ?
370
	.cfg_reg	    dd ?
370
	.int_line	    dd ?
371
	.int_line	    dd ?
371
 
372
 
372
	.vendor_ids	    dd ?    ;vendor id string
373
	.vendor_ids	    dd ?    ;vendor id string
373
	.ctrl_ids	    dd ?    ;hub id string
374
	.ctrl_ids	    dd ?    ;hub id string
374
 
375
 
375
	.buffer 	    dd ?
376
	.buffer 	    dd ?
376
 
377
 
377
	.notify_pos	    dd ?
378
	.notify_pos	    dd ?
378
	.notify_task	    dd ?
379
	.notify_task	    dd ?
379
 
380
 
380
	.lvi_reg	    dd ?
381
	.lvi_reg	    dd ?
381
	.civ_val	    dd 1
382
	.civ_val	    dd 1
382
	.user_callback	    dd ?
383
	.user_callback	    dd ?
383
 
384
 
384
	.ctrl_read8	    dd ?
385
	.ctrl_read8	    dd ?
385
	.ctrl_read16	    dd ?
386
	.ctrl_read16	    dd ?
386
	.ctrl_read32	    dd ?
387
	.ctrl_read32	    dd ?
387
 
388
 
388
	.ctrl_write8	    dd ?
389
	.ctrl_write8	    dd ?
389
	.ctrl_write16	    dd ?
390
	.ctrl_write16	    dd ?
390
	.ctrl_write32	    dd ?
391
	.ctrl_write32	    dd ?
391
 
392
 
392
	.codec_mask	    dd ?
393
	.codec_mask	    dd ?
393
	.rb		    dd ?
394
	.rb		    dd ?
394
	.rirb_rp	    dw 0
395
	.rirb_rp	    dw 0
395
	.rirb_wp	    dw 0
396
	.rirb_wp	    dw 0
396
	.corb_rp	    dw 0
397
	.corb_rp	    dw 0
397
	.corb_wp	    dw 0
398
	.corb_wp	    dw 0
398
	.rirb_cmd	    dd 0
399
	.rirb_cmd	    dd 0
399
	.rirb_res	    dd 0
400
	.rirb_res	    dd 0
400
	.rirb_error	    dd 0
401
	.rirb_error	    dd 0
401
	.response_reset     dd 0
402
	.response_reset     dd 0
402
	.polling_mode	    db 0
403
	.polling_mode	    db 0
403
	.poll_count	    db 0
404
	.poll_count	    db 0
404
	.posbuf 	    dd ?
405
	.posbuf 	    dd ?
405
	.start_wallclk	    dd ? ; start + minimum wallclk
406
	.start_wallclk	    dd ? ; start + minimum wallclk
406
	.period_wallclk     dd ? ; wallclk for period
407
	.period_wallclk     dd ? ; wallclk for period
407
	.position_fix	    db ?
408
	.position_fix	    db ?
408
}
409
}
409
 
410
 
410
struc CODEC		   ;Audio Chip base class
411
struc CODEC		   ;Audio Chip base class
411
{
412
{
412
	.addr		    dd ?    ; codec slot index (codec address)
413
	.addr		    dd ?    ; codec slot index (codec address)
413
	.afg		    dd ?    ; AFG node id
414
	.afg		    dd ?    ; AFG node id
414
	.mfg		    dd ?    ; MFG node id
415
	.mfg		    dd ?    ; MFG node id
415
 
416
 
416
	.function_id	    dd ?
417
	.function_id	    dd ?
417
	.subsystem_id	    dd ?
418
	.subsystem_id	    dd ?
418
	.revision_id	    dd ?
419
	.revision_id	    dd ?
419
	.chip_id	    dw ?
420
	.chip_id	    dw ?
420
	.vendor_id	    dw ?
421
	.vendor_id	    dw ?
421
 
422
 
422
	; widget capabilities cache
423
	; widget capabilities cache
423
	.num_nodes	    dw ?
424
	.num_nodes	    dw ?
424
	.start_nid	    dw ?
425
	.start_nid	    dw ?
425
	.wcaps		    dd ?
426
	.wcaps		    dd ?
426
 
427
 
427
	.init_pins	    dd ?    ; initial (BIOS) pin configurations
428
	.init_pins	    dd ?    ; initial (BIOS) pin configurations
428
	.num_pins	    dd ?    ;Asper +  : word is enough, but for align...
429
	.num_pins	    dd ?    ;Asper +  : word is enough, but for align...
429
	.beeper_nid	    dw ?
430
	.beeper_nid	    dw ?
430
		      .pad  dw ?
431
		      .pad  dw ?
431
 
432
 
432
	.ac_vendor_ids	    dd ?    ;ac vendor id string
433
	.ac_vendor_ids	    dd ?    ;ac vendor id string
433
	.chip_ids	    dd ?    ;chip model string
434
	.chip_ids	    dd ?    ;chip model string
434
}
435
}
435
 
436
 
436
struc CTRL_INFO
437
struc CTRL_INFO
437
{
438
{
438
	.pci_cmd	    dd ?
439
	.pci_cmd	    dd ?
439
	.irq		    dd ?
440
	.irq		    dd ?
440
	.glob_cntrl	    dd ?
441
	.glob_cntrl	    dd ?
441
	.glob_sta	    dd ?
442
	.glob_sta	    dd ?
442
	.codec_io_base	    dd ?
443
	.codec_io_base	    dd ?
443
	.ctrl_io_base	    dd ?
444
	.ctrl_io_base	    dd ?
444
	.codec_mem_base     dd ?
445
	.codec_mem_base     dd ?
445
	.ctrl_mem_base	    dd ?
446
	.ctrl_mem_base	    dd ?
446
	.codec_id	    dd ?
447
	.codec_id	    dd ?
447
}
448
}
448
 
449
 
449
struc IOCTL
450
struc IOCTL
450
{
451
{
451
	.handle 	    dd ?
452
	.handle 	    dd ?
452
	.io_code	    dd ?
453
	.io_code	    dd ?
453
	.input		    dd ?
454
	.input		    dd ?
454
	.inp_size	    dd ?
455
	.inp_size	    dd ?
455
	.output 	    dd ?
456
	.output 	    dd ?
456
	.out_size	    dd ?
457
	.out_size	    dd ?
457
}
458
}
458
 
459
 
459
EVENT_NOTIFY	equ 0x00000200
460
EVENT_NOTIFY	equ 0x00000200
460
 
461
 
461
; Macroses by CleverMouse
462
; Macroses by CleverMouse
462
; The following macro assume that we are on uniprocessor machine.
463
; The following macro assume that we are on uniprocessor machine.
463
; Serious work is needed for multiprocessor machines.
464
; Serious work is needed for multiprocessor machines.
464
macro spin_lock_irqsave spinlock
465
macro spin_lock_irqsave spinlock
465
{
466
{
466
	pushf
467
	pushf
467
	cli
468
	cli
468
}
469
}
469
macro spin_unlock_irqrestore spinlock
470
macro spin_unlock_irqrestore spinlock
470
{
471
{
471
	popf
472
	popf
472
}
473
}
473
macro spin_lock_irq spinlock
474
macro spin_lock_irq spinlock
474
{
475
{
475
	cli
476
	cli
476
}
477
}
477
macro spin_unlock_irq spinlock
478
macro spin_unlock_irq spinlock
478
{
479
{
479
	sti
480
	sti
480
}
481
}
481
 
482
 
482
SPINLOCK_BUSY = 1
483
SPINLOCK_BUSY = 1
483
SPINLOCK_FREE = 0
484
SPINLOCK_FREE = 0
484
 
485
 
485
macro spin_lock
486
macro spin_lock
486
{
487
{
487
	push	eax ebx
488
	push	eax ebx
488
	mov	eax, aspinlock
489
	mov	eax, aspinlock
489
	mov	ebx, SPINLOCK_BUSY
490
	mov	ebx, SPINLOCK_BUSY
490
@@:
491
@@:
491
	lock	xchg [eax], ebx
492
	lock	xchg [eax], ebx
492
	cmp	ebx, SPINLOCK_FREE
493
	cmp	ebx, SPINLOCK_FREE
493
	jnz	@b
494
	jnz	@b
494
	pop	ebx eax
495
	pop	ebx eax
495
}
496
}
496
 
497
 
497
macro spin_unlock
498
macro spin_unlock
498
{
499
{
499
	push	eax ebx
500
	push	eax ebx
500
	mov	eax, aspinlock
501
	mov	eax, aspinlock
501
	mov	eax, aspinlock
502
	mov	eax, aspinlock
502
	mov	ebx, SPINLOCK_FREE
503
	mov	ebx, SPINLOCK_FREE
503
	lock	xchg	[eax], ebx
504
	lock	xchg	[eax], ebx
504
	pop	ebx eax
505
	pop	ebx eax
505
}
506
}
506
 
507
 
507
data fixups
508
data fixups
508
end data
509
end data
509
 
510
 
510
include '../../struct.inc'
511
include '../../struct.inc'
511
include '../../macros.inc'
512
include '../../macros.inc'
512
include '../../proc32.inc'
513
include '../../proc32.inc'
513
include '../../peimport.inc'
514
include '../../peimport.inc'
514
include 'CODEC_H.INC'
515
include 'CODEC_H.INC'
515
 
516
 
516
entry START
517
entry START
517
 
518
 
518
;proc START c, reason:dword, cmdline:dword
519
;proc START c, reason:dword, cmdline:dword
519
proc START
520
proc START
520
	push	ebx esi ; save used registers to be stdcall
521
	push	ebx esi ; save used registers to be stdcall
521
virtual at esp
522
virtual at esp
522
		rd	2 ; saved registers
523
		rd	2 ; saved registers
523
		dd	? ; return address
524
		dd	? ; return address
524
.reason 	dd	? ; DRV_ENTRY or DRV_EXIT
525
.reason 	dd	? ; DRV_ENTRY or DRV_EXIT
525
.cmdline	dd	? ; normally NULL
526
.cmdline	dd	? ; normally NULL
526
end virtual
527
end virtual
527
; 1. Check the reason for the call, do nothing unless initializing.
528
; 1. Check the reason for the call, do nothing unless initializing.
528
	cmp	[.reason], DRV_ENTRY
529
	cmp	[.reason], DRV_ENTRY
529
	jne	.stop
530
	jne	.stop
530
 
531
 
531
if DEBUG
532
if DEBUG
532
	mov	esi, msgTV
533
	mov	esi, msgTV
533
	invoke	SysMsgBoardStr
534
	invoke	SysMsgBoardStr
534
 
535
 
535
	mov	esi, msgInit
536
	mov	esi, msgInit
536
	invoke	SysMsgBoardStr
537
	invoke	SysMsgBoardStr
537
end if
538
end if
538
 
539
 
539
	call	detect_controller
540
	call	detect_controller
540
	test	eax, eax
541
	test	eax, eax
541
	jz	.fail
542
	jz	.fail
542
 
543
 
543
	mov	esi,[ctrl.vendor_ids]
544
	mov	esi,[ctrl.vendor_ids]
544
	invoke	SysMsgBoardStr
545
	invoke	SysMsgBoardStr
545
	mov	esi, [ctrl.ctrl_ids]
546
	mov	esi, [ctrl.ctrl_ids]
546
	invoke	SysMsgBoardStr
547
	invoke	SysMsgBoardStr
547
 
548
 
548
	call	init_controller
549
	call	init_controller
549
	test	eax, eax
550
	test	eax, eax
550
	jz	.fail
551
	jz	.fail
551
 
552
 
552
;Asper This part is from "azx_create" proc. [
553
;Asper This part is from "azx_create" proc. [
553
	mov	[ctrl.position_fix], POS_FIX_LPIB
554
	mov	[ctrl.position_fix], POS_FIX_LPIB
554
	cmp	[driver_type], AZX_DRIVER_VIA
555
	cmp	[driver_type], AZX_DRIVER_VIA
555
	je	.set_via_patch
556
	je	.set_via_patch
556
	cmp	[driver_type], AZX_DRIVER_ATI
557
	cmp	[driver_type], AZX_DRIVER_ATI
557
	jne	.no_via_patch
558
	jne	.no_via_patch
558
.set_via_patch:
559
.set_via_patch:
559
	or	[ctrl.position_fix], POS_FIX_VIACOMBO
560
	or	[ctrl.position_fix], POS_FIX_VIACOMBO
560
.no_via_patch:
561
.no_via_patch:
561
	; codec detection
562
	; codec detection
562
	mov	eax, [ctrl.codec_mask]
563
	mov	eax, [ctrl.codec_mask]
563
	test	eax, eax
564
	test	eax, eax
564
	jnz	@f
565
	jnz	@f
565
if DEBUG
566
if DEBUG
566
	mov	esi, msgNoCodecsFound
567
	mov	esi, msgNoCodecsFound
567
	jmp	.fail_msg
568
	jmp	.fail_msg
568
else
569
else
569
	jmp	.fail
570
	jmp	.fail
570
end if
571
end if
571
@@:
572
@@:
572
;Asper ]
573
;Asper ]
573
 
574
 
574
	mov	esi, msgPrimBuff
575
	mov	esi, msgPrimBuff
575
	invoke	SysMsgBoardStr
576
	invoke	SysMsgBoardStr
576
	call	create_primary_buff
577
	call	create_primary_buff
577
	mov	esi, msgDone
578
	mov	esi, msgDone
578
	invoke	SysMsgBoardStr
579
	invoke	SysMsgBoardStr
579
 
580
 
580
if IRQ_REMAP
581
if IRQ_REMAP
581
	pushf
582
	pushf
582
	cli
583
	cli
583
 
584
 
584
	mov	ebx, [ctrl.int_line]
585
	mov	ebx, [ctrl.int_line]
585
	in	al, 0xA1
586
	in	al, 0xA1
586
	mov	ah, al
587
	mov	ah, al
587
	in	al, 0x21
588
	in	al, 0x21
588
	test	ebx, ebx
589
	test	ebx, ebx
589
	jz	.skip
590
	jz	.skip
590
	bts	ax, bx			;mask old line
591
	bts	ax, bx			;mask old line
591
.skip
592
.skip
592
	bts	ax, IRQ_LINE		;mask new line
593
	bts	ax, IRQ_LINE		;mask new line
593
	out	0x21, al
594
	out	0x21, al
594
	mov	al, ah
595
	mov	al, ah
595
	out	0xA1, al
596
	out	0xA1, al
596
					   ;remap IRQ
597
					   ;remap IRQ
597
	invoke	PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
598
	invoke	PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
598
 
599
 
599
	mov	dx, 0x4d0		;8259 ELCR1
600
	mov	dx, 0x4d0		;8259 ELCR1
600
	in	al, dx
601
	in	al, dx
601
	bts	ax, IRQ_LINE
602
	bts	ax, IRQ_LINE
602
	out	dx, al			;set level-triggered mode
603
	out	dx, al			;set level-triggered mode
603
	mov	[ctrl.int_line], IRQ_LINE
604
	mov	[ctrl.int_line], IRQ_LINE
604
	popf
605
	popf
605
	mov	esi, msgRemap
606
	mov	esi, msgRemap
606
	invoke	SysMsgBoardStr
607
	invoke	SysMsgBoardStr
607
end if
608
end if
608
 
609
 
609
	mov	ebx, [ctrl.int_line]
610
	mov	ebx, [ctrl.int_line]
610
	invoke	AttachIntHandler, ebx, hda_irq, dword 0
611
	invoke	AttachIntHandler, ebx, hda_irq, dword 0
611
 
612
 
612
;Asper This part is from "azx_probe" proc. [
613
;Asper This part is from "azx_probe" proc. [
613
	call	azx_codec_create
614
	call	azx_codec_create
614
	cmp	eax, 0
615
	cmp	eax, 0
615
	jl	.fail
616
	jl	.fail
616
 
617
 
617
	call	azx_codec_configure
618
	call	azx_codec_configure
618
	cmp	eax, 0
619
	cmp	eax, 0
619
	jl	.fail
620
	jl	.fail
620
;] Asper
621
;] Asper
621
 
622
 
622
	; create PCM streams
623
	; create PCM streams
623
;Asper+ [
624
;Asper+ [
624
	mov	eax, [spec.dac_node]
625
	mov	eax, [spec.dac_node]
625
if DEBUG ;-
626
if DEBUG ;-
626
	push	eax esi
627
	push	eax esi
627
	mov	esi, msgVal
628
	mov	esi, msgVal
628
	invoke	SysMsgBoardStr
629
	invoke	SysMsgBoardStr
629
	stdcall  fdword2str, 3
630
	stdcall  fdword2str, 3
630
	invoke	SysMsgBoardStr
631
	invoke	SysMsgBoardStr
631
	pop	esi eax
632
	pop	esi eax
632
end if
633
end if
633
 
634
 
634
	test	eax, eax
635
	test	eax, eax
635
	jz	.fail
636
	jz	.fail
636
	mov	ebx, [spec.dac_node+4]
637
	mov	ebx, [spec.dac_node+4]
637
if DEBUG ;-
638
if DEBUG ;-
638
	push	eax esi
639
	push	eax esi
639
	mov	esi, msgVal
640
	mov	esi, msgVal
640
	invoke	SysMsgBoardStr
641
	invoke	SysMsgBoardStr
641
	mov	eax, [spec.dac_node+4]
642
	mov	eax, [spec.dac_node+4]
642
	stdcall fdword2str, 3
643
	stdcall fdword2str, 3
643
	invoke	SysMsgBoardStr
644
	invoke	SysMsgBoardStr
644
	pop	esi eax
645
	pop	esi eax
645
end if
646
end if
646
 
647
 
647
	test	ebx, ebx
648
	test	ebx, ebx
648
	jz	@f
649
	jz	@f
649
	cmp	eax, ebx
650
	cmp	eax, ebx
650
	je	@f
651
	je	@f
651
	stdcall hda_codec_setup_stream, ebx, SDO_TAG, 0, 0x11	; Left & Right channels (Front panel)
652
	stdcall hda_codec_setup_stream, ebx, SDO_TAG, 0, 0x11	; Left & Right channels (Front panel)
652
@@:
653
@@:
653
	stdcall hda_codec_setup_stream, eax, SDO_TAG, 0, 0x11	; Left & Right channels (Back panel)
654
	stdcall hda_codec_setup_stream, eax, SDO_TAG, 0, 0x11	; Left & Right channels (Back panel)
654
;Asper+ ]
655
;Asper+ ]
655
 
656
 
656
	invoke	TimerHS, 1, 0, snd_hda_automute, 0
657
	invoke	TimerHS, 1, 0, snd_hda_automute, 0
657
if USE_SINGLE_MODE
658
if USE_SINGLE_MODE
658
	mov	esi, msgSingleMode
659
	mov	esi, msgSingleMode
659
	invoke	SysMsgBoardStr
660
	invoke	SysMsgBoardStr
660
else
661
else
661
	mov	esi, msgNormalMode
662
	mov	esi, msgNormalMode
662
	invoke	SysMsgBoardStr
663
	invoke	SysMsgBoardStr
663
end if
664
end if
664
 
665
 
665
.reg:
666
.reg:
666
	invoke	RegService, sz_sound_srv, service_proc
667
	invoke	RegService, sz_sound_srv, service_proc
667
	pop	esi ebx
668
	pop	esi ebx
668
	ret
669
	ret
669
.fail:
670
.fail:
670
	mov	esi, msgFail
671
	mov	esi, msgFail
671
.fail_msg:
672
.fail_msg:
672
	invoke	SysMsgBoardStr
673
	invoke	SysMsgBoardStr
673
	pop	esi ebx
674
	pop	esi ebx
674
	xor	eax, eax
675
	xor	eax, eax
675
	ret
676
	ret
676
.stop:
677
.stop:
677
	call	stop
678
	call	stop
678
	pop	esi ebx
679
	pop	esi ebx
679
	xor	eax, eax
680
	xor	eax, eax
680
	ret
681
	ret
681
endp
682
endp
682
 
683
 
683
handle	   equ	IOCTL.handle
684
handle	   equ	IOCTL.handle
684
io_code    equ	IOCTL.io_code
685
io_code    equ	IOCTL.io_code
685
input	   equ	IOCTL.input
686
input	   equ	IOCTL.input
686
inp_size   equ	IOCTL.inp_size
687
inp_size   equ	IOCTL.inp_size
687
output	   equ	IOCTL.output
688
output	   equ	IOCTL.output
688
out_size   equ	IOCTL.out_size
689
out_size   equ	IOCTL.out_size
689
 
690
 
690
align 4
691
align 4
691
proc service_proc stdcall, ioctl:dword
692
proc service_proc stdcall, ioctl:dword
692
	mov	edi, [ioctl]
693
	mov	edi, [ioctl]
693
	mov	eax, [edi+io_code]
694
	mov	eax, [edi+io_code]
694
 
695
 
695
	cmp	eax, SRV_GETVERSION
696
	cmp	eax, SRV_GETVERSION
696
	jne	@F
697
	jne	@F
697
 
698
 
698
	mov	eax, [edi+output]
699
	mov	eax, [edi+output]
699
	cmp	[edi+out_size], 4
700
	cmp	[edi+out_size], 4
700
	jne	.fail
701
	jne	.fail
701
 
702
 
702
	mov	[eax], dword API_VERSION
703
	mov	[eax], dword API_VERSION
703
	xor	eax, eax
704
	xor	eax, eax
704
	ret
705
	ret
705
@@:
706
@@:
706
	cmp	eax, DEV_PLAY
707
	cmp	eax, DEV_PLAY
707
	jne	@F
708
	jne	@F
708
if DEBUG
709
if DEBUG
709
	mov	esi, msgPlay
710
	mov	esi, msgPlay
710
	invoke	SysMsgBoardStr
711
	invoke	SysMsgBoardStr
711
end if
712
end if
712
	call	play
713
	call	play
713
	xor	eax, eax
714
	xor	eax, eax
714
	ret
715
	ret
715
@@:
716
@@:
716
	cmp	eax, DEV_STOP
717
	cmp	eax, DEV_STOP
717
	jne	@F
718
	jne	@F
718
if DEBUG
719
if DEBUG
719
	mov	esi, msgStop
720
	mov	esi, msgStop
720
	invoke	SysMsgBoardStr
721
	invoke	SysMsgBoardStr
721
end if
722
end if
722
	call	stop
723
	call	stop
723
	xor	eax, eax
724
	xor	eax, eax
724
	ret
725
	ret
725
@@:
726
@@:
726
	cmp	eax, DEV_CALLBACK
727
	cmp	eax, DEV_CALLBACK
727
	jne	@f
728
	jne	@f
728
	mov	ebx, [edi+input]
729
	mov	ebx, [edi+input]
729
	stdcall set_callback, [ebx]
730
	stdcall set_callback, [ebx]
730
	xor	eax, eax
731
	xor	eax, eax
731
	ret
732
	ret
732
@@:
733
@@:
733
	cmp	eax, DEV_SET_MASTERVOL
734
	cmp	eax, DEV_SET_MASTERVOL
734
	jne	@f
735
	jne	@f
735
	mov	eax, [edi+input]
736
	mov	eax, [edi+input]
736
	mov	eax, [eax]
737
	mov	eax, [eax]
737
	call	set_master_vol
738
	call	set_master_vol
738
	xor	eax, eax
739
	xor	eax, eax
739
	ret
740
	ret
740
@@:
741
@@:
741
	cmp	eax, DEV_GET_MASTERVOL
742
	cmp	eax, DEV_GET_MASTERVOL
742
	jne	@f
743
	jne	@f
743
	mov	ebx, [edi+output]
744
	mov	ebx, [edi+output]
744
	stdcall get_master_vol, ebx
745
	stdcall get_master_vol, ebx
745
	xor	eax, eax
746
	xor	eax, eax
746
	ret
747
	ret
747
;@@:
748
;@@:
748
;        cmp     eax, DEV_GET_INFO
749
;        cmp     eax, DEV_GET_INFO
749
;        jne     @f
750
;        jne     @f
750
;        mov     ebx, [edi+output]
751
;        mov     ebx, [edi+output]
751
;        stdcall get_dev_info, ebx
752
;        stdcall get_dev_info, ebx
752
;        xor     eax, eax
753
;        xor     eax, eax
753
;        ret
754
;        ret
754
@@:
755
@@:
755
	cmp	eax, DEV_GET_POS
756
	cmp	eax, DEV_GET_POS
756
	jne	@f
757
	jne	@f
757
	stdcall azx_get_position
758
	stdcall azx_get_position
758
	shr	eax, 2
759
	shr	eax, 2
759
	mov	ebx, [edi+output]
760
	mov	ebx, [edi+output]
760
	mov	[ebx], eax
761
	mov	[ebx], eax
761
	xor	eax, eax
762
	xor	eax, eax
762
	ret
763
	ret
763
@@:
764
@@:
764
;        cmp     eax, DEV_SET_CHANNEL_VOLUME
765
;        cmp     eax, DEV_SET_CHANNEL_VOLUME
765
;        jne     @f
766
;        jne     @f
766
;if DEBUG
767
;if DEBUG
767
;        mov     esi, msgSetChannelVolume
768
;        mov     esi, msgSetChannelVolume
768
;        invoke  SysMsgBoardStr
769
;        invoke  SysMsgBoardStr
769
;end if
770
;end if
770
;        mov      ebx, [edi+input]
771
;        mov      ebx, [edi+input]
771
;        mov      cl,  byte [ebx]      ; cl=channel
772
;        mov      cl,  byte [ebx]      ; cl=channel
772
;        mov      eax, dword [ebx+1]   ; eax=volume in Db
773
;        mov      eax, dword [ebx+1]   ; eax=volume in Db
773
;if DEBUG
774
;if DEBUG
774
;        push    eax esi
775
;        push    eax esi
775
;        mov     esi, msgYAHOO1
776
;        mov     esi, msgYAHOO1
776
;        invoke  SysMsgBoardStr
777
;        invoke  SysMsgBoardStr
777
;        stdcall fdword2str, 1
778
;        stdcall fdword2str, 1
778
;        invoke  SysMsgBoardStr
779
;        invoke  SysMsgBoardStr
779
;        mov     esi, strSemicolon
780
;        mov     esi, strSemicolon
780
;        invoke  SysMsgBoardStr
781
;        invoke  SysMsgBoardStr
781
;        movzx   eax, cl
782
;        movzx   eax, cl
782
;        stdcall fdword2str, 3
783
;        stdcall fdword2str, 3
783
;        invoke  SysMsgBoardStr
784
;        invoke  SysMsgBoardStr
784
;        pop     esi eax
785
;        pop     esi eax
785
;end if
786
;end if
786
;    ;        call    set_channel_volume
787
;    ;        call    set_channel_volume
787
;        xor     eax, eax
788
;        xor     eax, eax
788
;        ret
789
;        ret
789
;@@:
790
;@@:
790
;        cmp     eax, DEV_GET_CHANNEL_VOLUME
791
;        cmp     eax, DEV_GET_CHANNEL_VOLUME
791
;        jne     @f
792
;        jne     @f
792
;        mov     cl,  byte [edi+input]  ; cl=channel
793
;        mov     cl,  byte [edi+input]  ; cl=channel
793
;        call    get_channel_volume
794
;        call    get_channel_volume
794
;        mov     ebx, [edi+output]
795
;        mov     ebx, [edi+output]
795
;        mov     [ebx], eax
796
;        mov     [ebx], eax
796
;        xor     eax, eax
797
;        xor     eax, eax
797
;        ret
798
;        ret
798
;@@:
799
;@@:
799
 
800
 
800
;Asper: Non standard system service. For the tests only! [
801
;Asper: Non standard system service. For the tests only! [
801
@@:
802
@@:
802
	cmp	 eax, DEV_EXEC_CODEC_CMD
803
	cmp	 eax, DEV_EXEC_CODEC_CMD
803
	jne	 @f
804
	jne	 @f
804
 
805
 
805
	mov	 eax, [edi+input]
806
	mov	 eax, [edi+input]
806
	mov	 eax, [eax]
807
	mov	 eax, [eax]
807
	stdcall  codec_exec_verb, eax
808
	stdcall  codec_exec_verb, eax
808
	xor	 eax, eax
809
	xor	 eax, eax
809
	ret
810
	ret
810
@@:
811
@@:
811
;Asper: Non standard system service. For the tests only! ]
812
;Asper: Non standard system service. For the tests only! ]
812
 
813
 
813
.fail:
814
.fail:
814
	or	 eax, -1
815
	or	 eax, -1
815
	ret
816
	ret
816
endp
817
endp
817
 
818
 
818
restore handle
819
restore handle
819
restore io_code
820
restore io_code
820
restore input
821
restore input
821
restore inp_size
822
restore inp_size
822
restore output
823
restore output
823
restore out_size
824
restore out_size
824
 
825
 
825
 
826
 
826
align 4
827
align 4
827
proc hda_irq   ;+
828
proc hda_irq   ;+
828
	spin_lock
829
	spin_lock
829
if DEBUG_IRQ
830
if DEBUG_IRQ
830
	push	eax esi
831
	push	eax esi
831
	;mov     esi, msgIRQ
832
	;mov     esi, msgIRQ
832
	;invoke  SysMsgBoardStr
833
	;invoke  SysMsgBoardStr
833
	invoke	GetTimerTicks
834
	invoke	GetTimerTicks
834
	stdcall fdword2str, 2
835
	stdcall fdword2str, 2
835
	invoke	SysMsgBoardStr
836
	invoke	SysMsgBoardStr
836
	pop	esi eax
837
	pop	esi eax
837
end if
838
end if
838
	mov	edx, ICH6_REG_INTSTS
839
	mov	edx, ICH6_REG_INTSTS
839
	call	azx_readl
840
	call	azx_readl
840
	test	eax, eax
841
	test	eax, eax
841
	jnz	@f
842
	jnz	@f
842
	spin_unlock
843
	spin_unlock
843
	ret
844
	ret
844
@@:
845
@@:
845
	mov	ebx, eax ; status
846
	mov	ebx, eax ; status
846
	mov	eax, SDO_INT
847
	mov	eax, SDO_INT
847
	test	ebx, eax
848
	test	ebx, eax
848
	jz	@f
849
	jz	@f
849
 
850
 
850
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
851
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
851
	call	azx_readb
852
	call	azx_readb
852
	mov	bl, al
853
	mov	bl, al
853
 
854
 
854
	mov	al, SD_INT_MASK
855
	mov	al, SD_INT_MASK
855
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
856
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
856
	call	azx_writeb
857
	call	azx_writeb
857
 
858
 
858
	test	bl, SD_INT_COMPLETE
859
	test	bl, SD_INT_COMPLETE
859
	jz	@f
860
	jz	@f
860
 
861
 
861
	mov	eax, [ctrl.civ_val]
862
	mov	eax, [ctrl.civ_val]
862
	inc	eax
863
	inc	eax
863
	and	eax, 4-1 ;2-1
864
	and	eax, 4-1 ;2-1
864
	mov	[ctrl.civ_val], eax
865
	mov	[ctrl.civ_val], eax
865
 
866
 
866
	mov	ebx, dword [buff_list+eax*4]
867
	mov	ebx, dword [buff_list+eax*4]
867
	cmp	[ctrl.user_callback], 0
868
	cmp	[ctrl.user_callback], 0
868
	je	@f
869
	je	@f
869
	stdcall [ctrl.user_callback], ebx
870
	stdcall [ctrl.user_callback], ebx
870
@@:
871
@@:
871
	; clear rirb int
872
	; clear rirb int
872
	mov	edx, ICH6_REG_RIRBSTS
873
	mov	edx, ICH6_REG_RIRBSTS
873
	call	azx_readb
874
	call	azx_readb
874
 
875
 
875
	test	al, RIRB_INT_MASK
876
	test	al, RIRB_INT_MASK
876
	jz	.l1
877
	jz	.l1
877
	test	al, RIRB_INT_RESPONSE
878
	test	al, RIRB_INT_RESPONSE
878
	jz	.l2
879
	jz	.l2
879
 
880
 
880
	cmp	byte [driver_type], AZX_DRIVER_CTX
881
	cmp	byte [driver_type], AZX_DRIVER_CTX
881
	jne	@f
882
	jne	@f
882
	mov	eax, 80    ; wait 80 us
883
	mov	eax, 80    ; wait 80 us
883
	call	StallExec
884
	call	StallExec
884
@@:
885
@@:
885
	call	azx_update_rirb
886
	call	azx_update_rirb
886
.l2:
887
.l2:
887
	mov	al, RIRB_INT_MASK
888
	mov	al, RIRB_INT_MASK
888
	mov	edx, ICH6_REG_RIRBSTS
889
	mov	edx, ICH6_REG_RIRBSTS
889
	call	azx_writeb
890
	call	azx_writeb
890
.l1:
891
.l1:
891
 
892
 
892
;if 0
893
;if 0
893
	; clear state status int
894
	; clear state status int
894
	mov	edx, ICH6_REG_STATESTS
895
	mov	edx, ICH6_REG_STATESTS
895
	call	azx_readb
896
	call	azx_readb
896
	test	al, 0x04
897
	test	al, 0x04
897
	jz	@f
898
	jz	@f
898
 
899
 
899
	mov	al, 0x04
900
	mov	al, 0x04
900
	mov	edx, ICH6_REG_STATESTS
901
	mov	edx, ICH6_REG_STATESTS
901
	call	azx_writeb
902
	call	azx_writeb
902
@@:
903
@@:
903
;end if
904
;end if
904
	or	eax, 1
905
	or	eax, 1
905
	spin_unlock
906
	spin_unlock
906
	ret
907
	ret
907
endp
908
endp
908
 
909
 
909
 
910
 
910
align 4
911
align 4
911
proc create_primary_buff
912
proc create_primary_buff
912
 
913
 
913
	invoke	KernelAlloc, 4096
914
	invoke	KernelAlloc, 4096
914
	mov	[ctrl.posbuf], eax
915
	mov	[ctrl.posbuf], eax
915
 
916
 
916
	invoke	KernelAlloc, 0x10000 ;0x8000
917
	invoke	KernelAlloc, 0x10000 ;0x8000
917
	mov	[ctrl.buffer], eax
918
	mov	[ctrl.buffer], eax
918
 
919
 
919
	mov	edi, eax
920
	mov	edi, eax
920
	mov	ecx, 0x10000/4 ;0x8000/4
921
	mov	ecx, 0x10000/4 ;0x8000/4
921
	xor	eax, eax
922
	xor	eax, eax
922
	cld
923
	cld
923
	rep	stosd
924
	rep	stosd
924
 
925
 
925
	invoke	KernelAlloc, 4096
926
	invoke	KernelAlloc, 4096
926
	mov	[pcmout_bdl], eax
927
	mov	[pcmout_bdl], eax
927
 
928
 
928
	mov	edi, eax
929
	mov	edi, eax
929
	mov	ecx, 4096/4
930
	mov	ecx, 4096/4
930
	xor	eax, eax
931
	xor	eax, eax
931
	cld
932
	cld
932
	rep	stosd
933
	rep	stosd
933
 
934
 
934
	; reset BDL address
935
	; reset BDL address
935
	xor	eax, eax
936
	xor	eax, eax
936
	mov	edx, ICH6_REG_SD_BDLPL + SDO_OFS
937
	mov	edx, ICH6_REG_SD_BDLPL + SDO_OFS
937
	call	azx_writel
938
	call	azx_writel
938
	xor	eax, eax
939
	xor	eax, eax
939
	mov	edx, ICH6_REG_SD_BDLPU + SDO_OFS
940
	mov	edx, ICH6_REG_SD_BDLPU + SDO_OFS
940
	call	azx_writel
941
	call	azx_writel
941
 
942
 
942
	; program the initial BDL entries
943
	; program the initial BDL entries
943
	mov	eax, [ctrl.buffer]
944
	mov	eax, [ctrl.buffer]
944
	mov	ebx, eax
945
	mov	ebx, eax
945
	invoke	GetPgAddr
946
	invoke	GetPgAddr
946
	and	ebx, 0xFFF
947
	and	ebx, 0xFFF
947
	add	eax, ebx
948
	add	eax, ebx
948
 
949
 
949
	mov	ebx, 0x4000 ;buffer size
950
	mov	ebx, 0x4000 ;buffer size
950
	mov	ecx, 8	    ;number of periods
951
	mov	ecx, 8	    ;number of periods
951
	mov	edi, [pcmout_bdl] ;pcmout_bdl
952
	mov	edi, [pcmout_bdl] ;pcmout_bdl
952
.next_period:
953
.next_period:
953
	push	eax ecx
954
	push	eax ecx
954
	mov	ecx, 4 ;2  ;number of bdl in a period
955
	mov	ecx, 4 ;2  ;number of bdl in a period
955
.next_bdl:
956
.next_bdl:
956
	; program the address field of the BDL entry
957
	; program the address field of the BDL entry
957
	mov	dword [edi], eax
958
	mov	dword [edi], eax
958
	mov	dword [edi+4], 0
959
	mov	dword [edi+4], 0
959
	; program the size field of the BDL entry
960
	; program the size field of the BDL entry
960
	mov	dword [edi+8],	ebx
961
	mov	dword [edi+8],	ebx
961
	; program the IOC to enable interrupt when buffer completes
962
	; program the IOC to enable interrupt when buffer completes
962
	mov	dword [edi+12], 0x01
963
	mov	dword [edi+12], 0x01
963
 
964
 
964
	add	eax, ebx
965
	add	eax, ebx
965
	add	edi, 16
966
	add	edi, 16
966
	dec	ecx
967
	dec	ecx
967
	jnz	.next_bdl
968
	jnz	.next_bdl
968
 
969
 
969
	pop	ecx eax
970
	pop	ecx eax
970
	dec	ecx
971
	dec	ecx
971
	jnz	.next_period
972
	jnz	.next_period
972
 
973
 
973
	mov	edi, buff_list
974
	mov	edi, buff_list
974
	mov	eax, [ctrl.buffer]
975
	mov	eax, [ctrl.buffer]
975
	mov	ecx, 4 ;2
976
	mov	ecx, 4 ;2
976
@@:
977
@@:
977
	mov	[edi], eax
978
	mov	[edi], eax
978
	mov	[edi+8], eax
979
	mov	[edi+8], eax
979
	mov	[edi+16], eax
980
	mov	[edi+16], eax
980
	mov	[edi+24], eax
981
	mov	[edi+24], eax
981
	mov	[edi+32], eax
982
	mov	[edi+32], eax
982
	mov	[edi+40], eax
983
	mov	[edi+40], eax
983
	mov	[edi+48], eax
984
	mov	[edi+48], eax
984
	mov	[edi+56], eax
985
	mov	[edi+56], eax
985
 
986
 
986
	add	eax, ebx
987
	add	eax, ebx
987
	add	edi, 4
988
	add	edi, 4
988
	loop	@B
989
	loop	@B
989
 
990
 
990
	; wallclk has 24Mhz clock source
991
	; wallclk has 24Mhz clock source
991
	mov	[ctrl.period_wallclk], ((0x4000 * 24000) / 48000) * 1000
992
	mov	[ctrl.period_wallclk], ((0x4000 * 24000) / 48000) * 1000
992
 
993
 
993
	call	azx_stream_reset
994
	call	azx_stream_reset
994
	call	azx_setup_controller
995
	call	azx_setup_controller
995
	ret
996
	ret
996
endp
997
endp
997
 
998
 
998
align 4
999
align 4
999
proc detect_controller
1000
proc detect_controller
1000
locals
1001
locals
1001
	last_bus dd ?
1002
	last_bus dd ?
1002
	bus	 dd ?
1003
	bus	 dd ?
1003
	devfn	 dd ?
1004
	devfn	 dd ?
1004
endl
1005
endl
1005
	xor	eax, eax
1006
	xor	eax, eax
1006
	mov	[bus], eax
1007
	mov	[bus], eax
1007
	inc	eax
1008
	inc	eax
1008
	invoke	PciApi
1009
	invoke	PciApi
1009
	cmp	eax, -1
1010
	cmp	eax, -1
1010
	je	.err
1011
	je	.err
1011
 
1012
 
1012
	mov	[last_bus], eax
1013
	mov	[last_bus], eax
1013
 
1014
 
1014
.next_bus:
1015
.next_bus:
1015
	and	[devfn], 0
1016
	and	[devfn], 0
1016
.next_dev:
1017
.next_dev:
1017
	invoke	PciRead32, [bus], [devfn], dword 0
1018
	invoke	PciRead32, [bus], [devfn], dword 0
1018
	test	eax, eax
1019
	test	eax, eax
1019
	jz	.next
1020
	jz	.next
1020
	cmp	eax, -1
1021
	cmp	eax, -1
1021
	je	.next
1022
	je	.next
1022
 
1023
 
1023
	mov	edi, devices
1024
	mov	edi, devices
1024
@@:
1025
@@:
1025
	mov	ebx, [edi]
1026
	mov	ebx, [edi]
1026
	test	ebx, ebx
1027
	test	ebx, ebx
1027
	jz	.next
1028
	jz	.next
1028
 
1029
 
1029
	cmp	eax, ebx
1030
	cmp	eax, ebx
1030
	je	.found
1031
	je	.found
1031
	add	edi, 12
1032
	add	edi, 12
1032
	jmp	@b
1033
	jmp	@b
1033
.next:
1034
.next:
1034
	inc	[devfn]
1035
	inc	[devfn]
1035
	cmp	[devfn], 256
1036
	cmp	[devfn], 256
1036
	jb	.next_dev
1037
	jb	.next_dev
1037
	mov	eax, [bus]
1038
	mov	eax, [bus]
1038
	inc	eax
1039
	inc	eax
1039
	mov	[bus], eax
1040
	mov	[bus], eax
1040
	cmp	eax, [last_bus]
1041
	cmp	eax, [last_bus]
1041
	jna	.next_bus
1042
	jna	.next_bus
1042
	xor	eax, eax
1043
	xor	eax, eax
1043
	ret
1044
	ret
1044
.found:
1045
.found:
1045
	mov	ebx, [bus]
1046
	mov	ebx, [bus]
1046
	mov	[ctrl.bus], ebx
1047
	mov	[ctrl.bus], ebx
1047
 
1048
 
1048
	mov	ecx, [devfn]
1049
	mov	ecx, [devfn]
1049
	mov	[ctrl.devfn], ecx
1050
	mov	[ctrl.devfn], ecx
1050
 
1051
 
1051
	mov	edx, eax
1052
	mov	edx, eax
1052
	and	edx, 0xFFFF
1053
	and	edx, 0xFFFF
1053
	mov	[ctrl.vendor], dx
1054
	mov	[ctrl.vendor], dx
1054
	shr	eax, 16
1055
	shr	eax, 16
1055
	mov	[ctrl.dev_id], ax
1056
	mov	[ctrl.dev_id], ax
1056
 
1057
 
1057
	mov	ebx, [edi+4]
1058
	mov	ebx, [edi+4]
1058
	mov	[ctrl.ctrl_ids], ebx
1059
	mov	[ctrl.ctrl_ids], ebx
1059
 
1060
 
1060
	cmp	edx, VID_INTEL
1061
	cmp	edx, VID_INTEL
1061
	jne	@f
1062
	jne	@f
1062
	mov	[ctrl.vendor_ids], msg_Intel
1063
	mov	[ctrl.vendor_ids], msg_Intel
1063
	jmp	.ok
1064
	jmp	.ok
1064
@@:
1065
@@:
1065
	cmp	edx, VID_NVIDIA
1066
	cmp	edx, VID_NVIDIA
1066
	jne	@f
1067
	jne	@f
1067
	mov	[ctrl.vendor_ids], msg_NVidia
1068
	mov	[ctrl.vendor_ids], msg_NVidia
1068
	jmp	.ok
1069
	jmp	.ok
1069
@@:
1070
@@:
1070
	cmp	edx, VID_ATI
1071
	cmp	edx, VID_ATI
1071
	jne	@f
1072
	jne	@f
1072
	cmp	eax, 0x4383
1073
	cmp	eax, 0x4383
1073
	jg	.ati_hdmi
1074
	jg	.ati_hdmi
1074
	mov	[ctrl.vendor_ids], msg_ATI
1075
	mov	[ctrl.vendor_ids], msg_ATI
1075
	jmp	.ok
1076
	jmp	.ok
1076
.ati_hdmi:
1077
.ati_hdmi:
1077
	mov	[ctrl.vendor_ids], msg_ATI_HDMI
1078
	mov	[ctrl.vendor_ids], msg_ATI_HDMI
1078
	jmp	.ok
1079
	jmp	.ok
1079
@@:
1080
@@:
1080
	cmp	edx, VID_AMD
1081
	cmp	edx, VID_AMD
1081
	jne	@f
1082
	jne	@f
1082
	mov	[ctrl.vendor_ids], msg_AMD
1083
	mov	[ctrl.vendor_ids], msg_AMD
1083
	jmp	.ok
1084
	jmp	.ok
1084
@@:
1085
@@:
1085
	cmp	edx, VID_VIA
1086
	cmp	edx, VID_VIA
1086
	jne	@f
1087
	jne	@f
1087
	mov	[ctrl.vendor_ids], msg_VIA
1088
	mov	[ctrl.vendor_ids], msg_VIA
1088
	jmp	.ok
1089
	jmp	.ok
1089
@@:
1090
@@:
1090
	cmp	edx, VID_SIS
1091
	cmp	edx, VID_SIS
1091
	jne	@f
1092
	jne	@f
1092
	mov	[ctrl.vendor_ids], msg_SIS
1093
	mov	[ctrl.vendor_ids], msg_SIS
1093
	jmp	.ok
1094
	jmp	.ok
1094
@@:
1095
@@:
1095
	cmp	edx, VID_ULI
1096
	cmp	edx, VID_ULI
1096
	jne	@f
1097
	jne	@f
1097
	mov	[ctrl.vendor_ids], msg_ULI
1098
	mov	[ctrl.vendor_ids], msg_ULI
1098
	jmp	.ok
1099
	jmp	.ok
1099
@@:
1100
@@:
1100
	cmp	edx, VID_TERA
1101
	cmp	edx, VID_TERA
1101
	jne	@f
1102
	jne	@f
1102
	mov	[ctrl.vendor_ids], msg_TERA
1103
	mov	[ctrl.vendor_ids], msg_TERA
1103
	jmp	.ok
1104
	jmp	.ok
1104
@@:
1105
@@:
1105
	cmp	edx, VID_CREATIVE
1106
	cmp	edx, VID_CREATIVE
1106
	jne	@f
1107
	jne	@f
1107
	mov	[ctrl.vendor_ids], msg_CREATIVE
1108
	mov	[ctrl.vendor_ids], msg_CREATIVE
1108
	jmp	.ok
1109
	jmp	.ok
1109
@@:
1110
@@:
1110
	cmp	edx, VID_RDC
1111
	cmp	edx, VID_RDC
1111
	jne	@f
1112
	jne	@f
1112
	mov	[ctrl.vendor_ids], msg_RDC
1113
	mov	[ctrl.vendor_ids], msg_RDC
1113
	jmp	.ok
1114
	jmp	.ok
1114
@@:
1115
@@:
1115
	cmp	edx, VID_VMWARE
1116
	cmp	edx, VID_VMWARE
1116
	jne	@f
1117
	jne	@f
1117
	mov	[ctrl.vendor_ids], msg_VMWARE
1118
	mov	[ctrl.vendor_ids], msg_VMWARE
1118
	jmp	.ok
1119
	jmp	.ok
1119
@@:
1120
@@:
1120
.err:
1121
.err:
1121
	xor	eax, eax
1122
	xor	eax, eax
1122
	mov	[ctrl.vendor_ids], eax	   ;something  wrong ?
1123
	mov	[ctrl.vendor_ids], eax	   ;something  wrong ?
1123
	mov	[driver_type], -1
1124
	mov	[driver_type], -1
1124
	ret
1125
	ret
1125
.ok:
1126
.ok:
1126
	mov	ebx, [edi+8]
1127
	mov	ebx, [edi+8]
1127
	mov	[driver_type], ebx
1128
	mov	[driver_type], ebx
1128
	ret
1129
	ret
1129
endp
1130
endp
1130
 
1131
 
1131
align 4
1132
align 4
1132
proc init_controller
1133
proc init_controller
1133
 
1134
 
1134
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1135
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1135
	movi	ebx, 0x6
1136
	movi	ebx, 0x6
1136
	and	ebx, eax
1137
	and	ebx, eax
1137
	cmp	ebx, 0x6 ; Test Master and Memory bits
1138
	cmp	ebx, 0x6 ; Test Master and Memory bits
1138
	jz	@f
1139
	jz	@f
1139
	or	eax, 0x6 ; Set Master and Memory bits
1140
	or	eax, 0x6 ; Set Master and Memory bits
1140
	invoke	PciWrite32, [ctrl.bus], [ctrl.devfn], dword 4, eax
1141
	invoke	PciWrite32, [ctrl.bus], [ctrl.devfn], dword 4, eax
1141
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1142
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1142
@@:
1143
@@:
1143
	mov	ebx, eax
1144
	mov	ebx, eax
1144
	and	eax, 0xFFFF
1145
	and	eax, 0xFFFF
1145
	mov	[ctrl.pci_cmd], eax
1146
	mov	[ctrl.pci_cmd], eax
1146
	shr	ebx, 16
1147
	shr	ebx, 16
1147
	mov	[ctrl.pci_stat], ebx
1148
	mov	[ctrl.pci_stat], ebx
1148
 
1149
 
1149
	mov	esi, msgPciCmd
1150
	mov	esi, msgPciCmd
1150
	invoke	SysMsgBoardStr
1151
	invoke	SysMsgBoardStr
1151
	stdcall fdword2str, 2
1152
	stdcall fdword2str, 2
1152
	invoke	SysMsgBoardStr
1153
	invoke	SysMsgBoardStr
1153
 
1154
 
1154
	mov	esi, msgPciStat
1155
	mov	esi, msgPciStat
1155
	invoke	SysMsgBoardStr
1156
	invoke	SysMsgBoardStr
1156
	mov	eax, [ctrl.pci_stat]
1157
	mov	eax, [ctrl.pci_stat]
1157
	stdcall fdword2str, 2
1158
	stdcall fdword2str, 2
1158
	invoke	SysMsgBoardStr
1159
	invoke	SysMsgBoardStr
1159
 
1160
 
1160
	mov	esi, msgHDALowMMIo
1161
	mov	esi, msgHDALowMMIo
1161
	invoke	SysMsgBoardStr
1162
	invoke	SysMsgBoardStr
1162
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
1163
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
1163
	stdcall fdword2str, 2
1164
	stdcall fdword2str, 2
1164
	invoke	SysMsgBoardStr
1165
	invoke	SysMsgBoardStr
1165
 
1166
 
1166
	and	eax, 0xFFFFC000
1167
	and	eax, 0xFFFFC000
1167
	mov	[ctrl.ctrl_mem_base], eax
1168
	mov	[ctrl.ctrl_mem_base], eax
1168
 
1169
 
1169
	mov	esi, msgHDAUpMMIo
1170
	mov	esi, msgHDAUpMMIo
1170
	invoke	SysMsgBoardStr
1171
	invoke	SysMsgBoardStr
1171
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
1172
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
1172
	;-mov     [ctrl.hda_upper_mem_base], eax
1173
	;-mov     [ctrl.hda_upper_mem_base], eax
1173
	stdcall fdword2str, 2
1174
	stdcall fdword2str, 2
1174
	invoke	SysMsgBoardStr
1175
	invoke	SysMsgBoardStr
1175
 
1176
 
1176
.default:
1177
.default:
1177
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
1178
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
1178
	and	eax, 0xFF
1179
	and	eax, 0xFF
1179
@@:
1180
@@:
1180
	mov	[ctrl.int_line], eax
1181
	mov	[ctrl.int_line], eax
1181
	mov	[ctrl.user_callback], 0
1182
	mov	[ctrl.user_callback], 0
1182
 
1183
 
1183
	call	set_HDA
1184
	call	set_HDA
1184
;Asper This is from "azx_create" proc. [
1185
;Asper This is from "azx_create" proc. [
1185
	xor	eax, eax
1186
	xor	eax, eax
1186
	mov	edx, ICH6_REG_GCAP
1187
	mov	edx, ICH6_REG_GCAP
1187
	call	azx_readw
1188
	call	azx_readw
1188
if DEBUG
1189
if DEBUG
1189
	mov	esi, msgGCap
1190
	mov	esi, msgGCap
1190
	invoke	SysMsgBoardStr
1191
	invoke	SysMsgBoardStr
1191
	stdcall fdword2str, 2
1192
	stdcall fdword2str, 2
1192
	invoke	SysMsgBoardStr
1193
	invoke	SysMsgBoardStr
1193
end if
1194
end if
1194
	; allocate CORB/RIRB
1195
	; allocate CORB/RIRB
1195
	call	azx_alloc_cmd_io
1196
	call	azx_alloc_cmd_io
1196
 
1197
 
1197
	; initialize chip
1198
	; initialize chip
1198
	call	azx_init_pci
1199
	call	azx_init_pci
1199
 
1200
 
1200
	xor	eax, eax
1201
	xor	eax, eax
1201
	call	azx_init_chip
1202
	call	azx_init_chip
1202
;] Asper
1203
;] Asper
1203
 
1204
 
1204
	xor	eax, eax
1205
	xor	eax, eax
1205
	inc	eax
1206
	inc	eax
1206
	ret
1207
	ret
1207
endp
1208
endp
1208
 
1209
 
1209
 
1210
 
1210
 
1211
 
1211
PG_SW		equ 0x003
1212
PG_SW		equ 0x003
1212
PG_NOCACHE	equ 0x018
1213
PG_NOCACHE	equ 0x018
1213
 
1214
 
1214
align 4
1215
align 4
1215
proc set_HDA
1216
proc set_HDA
1216
	invoke	MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE
1217
	invoke	MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE
1217
	mov	[ctrl.ctrl_mem_base], eax
1218
	mov	[ctrl.ctrl_mem_base], eax
1218
	ret
1219
	ret
1219
endp
1220
endp
1220
 
1221
 
1221
 
1222
 
1222
; in:  eax - fullreset_flag
1223
; in:  eax - fullreset_flag
1223
;
1224
;
1224
; reset codec link
1225
; reset codec link
1225
align 4
1226
align 4
1226
proc reset_controller
1227
proc reset_controller
1227
locals
1228
locals
1228
	counter dd ?
1229
	counter dd ?
1229
endl
1230
endl
1230
 
1231
 
1231
	test	eax, eax
1232
	test	eax, eax
1232
	jz	.skip
1233
	jz	.skip
1233
 
1234
 
1234
	; clear STATESTS
1235
	; clear STATESTS
1235
	mov	eax, STATESTS_INT_MASK
1236
	mov	eax, STATESTS_INT_MASK
1236
	mov	edx, ICH6_REG_STATESTS
1237
	mov	edx, ICH6_REG_STATESTS
1237
	call	azx_writeb
1238
	call	azx_writeb
1238
 
1239
 
1239
	; reset controller
1240
	; reset controller
1240
	mov	edx, ICH6_REG_GCTL
1241
	mov	edx, ICH6_REG_GCTL
1241
	call	azx_readl
1242
	call	azx_readl
1242
	mov	ebx, ICH6_GCTL_RESET
1243
	mov	ebx, ICH6_GCTL_RESET
1243
	xor	ebx, -1
1244
	xor	ebx, -1
1244
	and	eax, ebx
1245
	and	eax, ebx
1245
	mov	edx, ICH6_REG_GCTL
1246
	mov	edx, ICH6_REG_GCTL
1246
	call	azx_writel
1247
	call	azx_writel
1247
 
1248
 
1248
	mov	[counter], 50	 ; total 50*100 us = 0.5s
1249
	mov	[counter], 50	 ; total 50*100 us = 0.5s
1249
.wait0:
1250
.wait0:
1250
 
1251
 
1251
	mov	edx, ICH6_REG_GCTL
1252
	mov	edx, ICH6_REG_GCTL
1252
	call	azx_readb
1253
	call	azx_readb
1253
	test	eax, eax
1254
	test	eax, eax
1254
	jz	@f
1255
	jz	@f
1255
 
1256
 
1256
	mov	eax, 100    ; wait 100 us
1257
	mov	eax, 100    ; wait 100 us
1257
	call	StallExec
1258
	call	StallExec
1258
 
1259
 
1259
	dec	[counter]
1260
	dec	[counter]
1260
	jnz	.wait0
1261
	jnz	.wait0
1261
@@:
1262
@@:
1262
	; delay for >= 100us for codec PLL to settle per spec
1263
	; delay for >= 100us for codec PLL to settle per spec
1263
	; Rev 0.9 section 5.5.1
1264
	; Rev 0.9 section 5.5.1
1264
	mov	eax, 100    ; wait 100 us
1265
	mov	eax, 100    ; wait 100 us
1265
	call	StallExec
1266
	call	StallExec
1266
 
1267
 
1267
	; Bring controller out of reset
1268
	; Bring controller out of reset
1268
	mov	edx, ICH6_REG_GCTL
1269
	mov	edx, ICH6_REG_GCTL
1269
	call	azx_readb
1270
	call	azx_readb
1270
	or	eax, ICH6_GCTL_RESET
1271
	or	eax, ICH6_GCTL_RESET
1271
	mov	edx, ICH6_REG_GCTL
1272
	mov	edx, ICH6_REG_GCTL
1272
	call	azx_writeb
1273
	call	azx_writeb
1273
 
1274
 
1274
	mov	[counter], 50	 ; total 50*100 us = 0.5s
1275
	mov	[counter], 50	 ; total 50*100 us = 0.5s
1275
.wait1:
1276
.wait1:
1276
 
1277
 
1277
	mov	edx, ICH6_REG_GCTL
1278
	mov	edx, ICH6_REG_GCTL
1278
	call	azx_readb
1279
	call	azx_readb
1279
	test	eax, eax
1280
	test	eax, eax
1280
	jnz	@f
1281
	jnz	@f
1281
 
1282
 
1282
	mov	eax, 100    ; wait 100 us
1283
	mov	eax, 100    ; wait 100 us
1283
	call	StallExec
1284
	call	StallExec
1284
 
1285
 
1285
	dec	[counter]
1286
	dec	[counter]
1286
	jnz	.wait1
1287
	jnz	.wait1
1287
@@:
1288
@@:
1288
 
1289
 
1289
	; Brent Chartrand said to wait >= 540us for codecs to intialize
1290
	; Brent Chartrand said to wait >= 540us for codecs to intialize
1290
	mov	eax, 540    ; wait 540 us
1291
	mov	eax, 540    ; wait 540 us
1291
	call	StallExec
1292
	call	StallExec
1292
 
1293
 
1293
.skip:
1294
.skip:
1294
	; check to see if controller is ready
1295
	; check to see if controller is ready
1295
	mov	edx, ICH6_REG_GCTL
1296
	mov	edx, ICH6_REG_GCTL
1296
	call	azx_readb
1297
	call	azx_readb
1297
	test	eax, eax
1298
	test	eax, eax
1298
	jz	.fail
1299
	jz	.fail
1299
 
1300
 
1300
	; Accept unsolicited responses
1301
	; Accept unsolicited responses
1301
if USE_SINGLE_MODE
1302
if USE_SINGLE_MODE
1302
else if USE_UNSOL_EV
1303
else if USE_UNSOL_EV
1303
;UNSUPPORTED YET! [
1304
;UNSUPPORTED YET! [
1304
	mov	edx, ICH6_REG_GCTL
1305
	mov	edx, ICH6_REG_GCTL
1305
	call	azx_readl
1306
	call	azx_readl
1306
	or	eax, ICH6_GCTL_UNSOL
1307
	or	eax, ICH6_GCTL_UNSOL
1307
	mov	edx, ICH6_REG_GCTL
1308
	mov	edx, ICH6_REG_GCTL
1308
	call	azx_writel
1309
	call	azx_writel
1309
;UNSUPPORTED YET! ]
1310
;UNSUPPORTED YET! ]
1310
end if
1311
end if
1311
 
1312
 
1312
	; detect codecs
1313
	; detect codecs
1313
	mov	eax, [ctrl.codec_mask]
1314
	mov	eax, [ctrl.codec_mask]
1314
	test	ax, ax
1315
	test	ax, ax
1315
	jnz	@f
1316
	jnz	@f
1316
 
1317
 
1317
	mov	edx, ICH6_REG_STATESTS
1318
	mov	edx, ICH6_REG_STATESTS
1318
	call	azx_readw
1319
	call	azx_readw
1319
	mov	[ctrl.codec_mask], eax
1320
	mov	[ctrl.codec_mask], eax
1320
 
1321
 
1321
if DEBUG
1322
if DEBUG
1322
	mov	esi, msgCodecMask
1323
	mov	esi, msgCodecMask
1323
	invoke	SysMsgBoardStr
1324
	invoke	SysMsgBoardStr
1324
	stdcall fdword2str, 2
1325
	stdcall fdword2str, 2
1325
	invoke	SysMsgBoardStr
1326
	invoke	SysMsgBoardStr
1326
end if
1327
end if
1327
 
1328
 
1328
@@:
1329
@@:
1329
 
1330
 
1330
.ok:
1331
.ok:
1331
	clc
1332
	clc
1332
	ret
1333
	ret
1333
.fail:
1334
.fail:
1334
if DEBUG
1335
if DEBUG
1335
	mov	esi, msgHDARFail
1336
	mov	esi, msgHDARFail
1336
	invoke	SysMsgBoardStr
1337
	invoke	SysMsgBoardStr
1337
end if
1338
end if
1338
	stc
1339
	stc
1339
	ret
1340
	ret
1340
endp
1341
endp
1341
 
1342
 
1342
 
1343
 
1343
align 4
1344
align 4
1344
play:
1345
play:
1345
	spin_lock_irq
1346
	spin_lock_irq
1346
	mov	edx, ICH6_REG_WALLCLK
1347
	mov	edx, ICH6_REG_WALLCLK
1347
	call	azx_readl
1348
	call	azx_readl
1348
	mov	[ctrl.start_wallclk], eax
1349
	mov	[ctrl.start_wallclk], eax
1349
 
1350
 
1350
	call	azx_stream_start
1351
	call	azx_stream_start
1351
	xor	eax, eax
1352
	xor	eax, eax
1352
	spin_unlock_irq
1353
	spin_unlock_irq
1353
	ret
1354
	ret
1354
 
1355
 
1355
align 4
1356
align 4
1356
stop:
1357
stop:
1357
	spin_lock_irq
1358
	spin_lock_irq
1358
;*        call    azx_stream_stop        ;Asper: Hangs system
1359
;*        call    azx_stream_stop        ;Asper: Hangs system
1359
;R        push    ebx ecx edx
1360
;R        push    ebx ecx edx
1360
;R        ; stop DMA
1361
;R        ; stop DMA
1361
;R        mov     edx, ICH6_REG_SD_CTL
1362
;R        mov     edx, ICH6_REG_SD_CTL
1362
;R        call    azx_sd_readb
1363
;R        call    azx_sd_readb
1363
;R        mov     bl, SD_CTL_DMA_START or SD_INT_MASK
1364
;R        mov     bl, SD_CTL_DMA_START or SD_INT_MASK
1364
;R        xor     bl, -1
1365
;R        xor     bl, -1
1365
;R        and     al, bl
1366
;R        and     al, bl
1366
;R        mov     edx, ICH6_REG_SD_CTL
1367
;R        mov     edx, ICH6_REG_SD_CTL
1367
;R        call    azx_sd_writeb
1368
;R        call    azx_sd_writeb
1368
;R        mov     edx, ICH6_REG_SD_STS
1369
;R        mov     edx, ICH6_REG_SD_STS
1369
;R        mov     al, SD_INT_MASK
1370
;R        mov     al, SD_INT_MASK
1370
;R        call    azx_sd_writeb  ; to be sure
1371
;R        call    azx_sd_writeb  ; to be sure
1371
	  ; disable SIE
1372
	  ; disable SIE
1372
;N        mov     edx, ICH6_REG_INTCTL
1373
;N        mov     edx, ICH6_REG_INTCTL
1373
;N        call    azx_readb
1374
;N        call    azx_readb
1374
;N        mov     bl, SDO_INT ;shl azx_dev->index
1375
;N        mov     bl, SDO_INT ;shl azx_dev->index
1375
;N        xor     bl, -1
1376
;N        xor     bl, -1
1376
;N        and     al, bl
1377
;N        and     al, bl
1377
;N        mov     edx, ICH6_REG_INTCTL
1378
;N        mov     edx, ICH6_REG_INTCTL
1378
;N        call    azx_writeb
1379
;N        call    azx_writeb
1379
 
1380
 
1380
	;     int timeout = 5000;
1381
	;     int timeout = 5000;
1381
	;     while (azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START && --timeout) ;
1382
	;     while (azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START && --timeout) ;
1382
;Asper: Hangs system   [
1383
;Asper: Hangs system   [
1383
;*        mov     ecx, 5000
1384
;*        mov     ecx, 5000
1384
;*.l1:
1385
;*.l1:
1385
;*        mov     edx, ICH6_REG_SD_CTL
1386
;*        mov     edx, ICH6_REG_SD_CTL
1386
;*        call    azx_sd_readb
1387
;*        call    azx_sd_readb
1387
;*        test    al, SD_CTL_DMA_START
1388
;*        test    al, SD_CTL_DMA_START
1388
;*        jz      @f
1389
;*        jz      @f
1389
;*        dec     ecx
1390
;*        dec     ecx
1390
;*        jnz     .l1
1391
;*        jnz     .l1
1391
;*@@:
1392
;*@@:
1392
;*
1393
;*
1393
;*        pop     edx ecx ebx
1394
;*        pop     edx ecx ebx
1394
;Asper ]
1395
;Asper ]
1395
 
1396
 
1396
	xor	eax, eax
1397
	xor	eax, eax
1397
	spin_unlock_irq
1398
	spin_unlock_irq
1398
	ret
1399
	ret
1399
 
1400
 
1400
;align 4
1401
;align 4
1401
;proc get_dev_info stdcall, p_info:dword ;deprecated
1402
;proc get_dev_info stdcall, p_info:dword ;deprecated
1402
;virtual at esi
1403
;virtual at esi
1403
;        CTRL_INFO CTRL_INFO
1404
;        CTRL_INFO CTRL_INFO
1404
;end virtual
1405
;end virtual
1405
;
1406
;
1406
;        mov     esi, [p_info]
1407
;        mov     esi, [p_info]
1407
;        mov     eax, [ctrl.int_line]
1408
;        mov     eax, [ctrl.int_line]
1408
;        mov     bx,  [ctrl.dev_id]
1409
;        mov     bx,  [ctrl.dev_id]
1409
;        shl     ebx, 16
1410
;        shl     ebx, 16
1410
;        and     bx,  [ctrl.vendor]
1411
;        and     bx,  [ctrl.vendor]
1411
;        mov     ecx, [ctrl.pci_cmd]
1412
;        mov     ecx, [ctrl.pci_cmd]
1412
;        mov     edx, [ctrl.codec_mem_base] ;[ctrl.hda_lower_mem_base]
1413
;        mov     edx, [ctrl.codec_mem_base] ;[ctrl.hda_lower_mem_base]
1413
;        mov     edi, [ctrl.ctrl_mem_base] ;[ctrl.hda_upper_mem_base]
1414
;        mov     edi, [ctrl.ctrl_mem_base] ;[ctrl.hda_upper_mem_base]
1414
;
1415
;
1415
;        mov     [CTRL_INFO.irq], eax
1416
;        mov     [CTRL_INFO.irq], eax
1416
;        mov     [CTRL_INFO.codec_id], ebx
1417
;        mov     [CTRL_INFO.codec_id], ebx
1417
;        mov     [CTRL_INFO.pci_cmd], ecx
1418
;        mov     [CTRL_INFO.pci_cmd], ecx
1418
;        mov     [CTRL_INFO.codec_mem_base], edx
1419
;        mov     [CTRL_INFO.codec_mem_base], edx
1419
;        mov     [CTRL_INFO.ctrl_mem_base], edi
1420
;        mov     [CTRL_INFO.ctrl_mem_base], edi
1420
;
1421
;
1421
;        xor     eax, eax
1422
;        xor     eax, eax
1422
;        mov     [CTRL_INFO.codec_io_base], eax
1423
;        mov     [CTRL_INFO.codec_io_base], eax
1423
;        mov     [CTRL_INFO.ctrl_io_base], eax
1424
;        mov     [CTRL_INFO.ctrl_io_base], eax
1424
;        mov     [CTRL_INFO.glob_cntrl], eax
1425
;        mov     [CTRL_INFO.glob_cntrl], eax
1425
;        mov     [CTRL_INFO.glob_sta], eax
1426
;        mov     [CTRL_INFO.glob_sta], eax
1426
;        ret
1427
;        ret
1427
;endp
1428
;endp
1428
 
1429
 
1429
align 4
1430
align 4
1430
proc set_callback stdcall, handler:dword
1431
proc set_callback stdcall, handler:dword
1431
	mov	eax, [handler]
1432
	mov	eax, [handler]
1432
	mov	[ctrl.user_callback], eax
1433
	mov	[ctrl.user_callback], eax
1433
	ret
1434
	ret
1434
endp
1435
endp
1435
 
1436
 
1436
 
1437
 
1437
 
1438
 
1438
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1439
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1439
;; Interface for HD codec ;;
1440
;; Interface for HD codec ;;
1440
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1441
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1441
 
1442
 
1442
;;;;;;;;;;;;;;;;;;;;;;;;;;;
1443
;;;;;;;;;;;;;;;;;;;;;;;;;;;
1443
;; CORB / RIRB interface ;;
1444
;; CORB / RIRB interface ;;
1444
;;;;;;;;;;;;;;;;;;;;;;;;;;;
1445
;;;;;;;;;;;;;;;;;;;;;;;;;;;
1445
 
1446
 
1446
proc azx_alloc_cmd_io
1447
proc azx_alloc_cmd_io
1447
	push	eax ecx edx
1448
	push	eax ecx edx
1448
	; single page (at least 4096 bytes) must suffice for both ringbuffers
1449
	; single page (at least 4096 bytes) must suffice for both ringbuffers
1449
	invoke	KernelAlloc, 4096
1450
	invoke	KernelAlloc, 4096
1450
	mov	[ctrl.rb], eax
1451
	mov	[ctrl.rb], eax
1451
 
1452
 
1452
	mov	edi, eax
1453
	mov	edi, eax
1453
	mov	ecx, 4096/4
1454
	mov	ecx, 4096/4
1454
	xor	eax, eax
1455
	xor	eax, eax
1455
	cld
1456
	cld
1456
	rep	stosd
1457
	rep	stosd
1457
 
1458
 
1458
	pop	edx ecx eax
1459
	pop	edx ecx eax
1459
	ret
1460
	ret
1460
endp
1461
endp
1461
 
1462
 
1462
proc azx_init_cmd_io
1463
proc azx_init_cmd_io
1463
	spin_lock_irq
1464
	spin_lock_irq
1464
	pusha
1465
	pusha
1465
	; CORB set up
1466
	; CORB set up
1466
	mov	eax, [ctrl.rb]
1467
	mov	eax, [ctrl.rb]
1467
	mov	ebx, eax
1468
	mov	ebx, eax
1468
	invoke	GetPgAddr
1469
	invoke	GetPgAddr
1469
	and	ebx, 0xFFF
1470
	and	ebx, 0xFFF
1470
	add	eax, ebx
1471
	add	eax, ebx
1471
	push	eax  ; save corb address
1472
	push	eax  ; save corb address
1472
	mov	edx, ICH6_REG_CORBLBASE
1473
	mov	edx, ICH6_REG_CORBLBASE
1473
	call	azx_writel
1474
	call	azx_writel
1474
	xor	eax, eax
1475
	xor	eax, eax
1475
	mov	edx, ICH6_REG_CORBUBASE
1476
	mov	edx, ICH6_REG_CORBUBASE
1476
	call	azx_writel
1477
	call	azx_writel
1477
 
1478
 
1478
	; set the corb size to 256 entries (ULI requires explicitly)
1479
	; set the corb size to 256 entries (ULI requires explicitly)
1479
	mov	al, 0x02
1480
	mov	al, 0x02
1480
	mov	edx, ICH6_REG_CORBSIZE
1481
	mov	edx, ICH6_REG_CORBSIZE
1481
	call	azx_writeb
1482
	call	azx_writeb
1482
	; set the corb write pointer to 0
1483
	; set the corb write pointer to 0
1483
	xor	ax, ax
1484
	xor	ax, ax
1484
	mov	edx, ICH6_REG_CORBWP
1485
	mov	edx, ICH6_REG_CORBWP
1485
	call	azx_writew
1486
	call	azx_writew
1486
	; reset the corb hw read pointer
1487
	; reset the corb hw read pointer
1487
	mov	ax, ICH6_CORBRP_RST
1488
	mov	ax, ICH6_CORBRP_RST
1488
	mov	edx, ICH6_REG_CORBRP
1489
	mov	edx, ICH6_REG_CORBRP
1489
	call	azx_writew
1490
	call	azx_writew
1490
	; enable corb dma
1491
	; enable corb dma
1491
	mov	al, ICH6_CORBCTL_RUN
1492
	mov	al, ICH6_CORBCTL_RUN
1492
	mov	edx, ICH6_REG_CORBCTL
1493
	mov	edx, ICH6_REG_CORBCTL
1493
	call	azx_writeb
1494
	call	azx_writeb
1494
 
1495
 
1495
	; RIRB set up
1496
	; RIRB set up
1496
	mov	[ctrl.rirb_rp], 0
1497
	mov	[ctrl.rirb_rp], 0
1497
	mov	[ctrl.rirb_wp], 0
1498
	mov	[ctrl.rirb_wp], 0
1498
	mov	[ctrl.rirb_cmd], 0
1499
	mov	[ctrl.rirb_cmd], 0
1499
 
1500
 
1500
	pop	eax  ; restore corb address
1501
	pop	eax  ; restore corb address
1501
	add	eax, 2048
1502
	add	eax, 2048
1502
	mov	edx, ICH6_REG_RIRBLBASE
1503
	mov	edx, ICH6_REG_RIRBLBASE
1503
	call	azx_writel
1504
	call	azx_writel
1504
	xor	eax, eax
1505
	xor	eax, eax
1505
	mov	edx, ICH6_REG_RIRBUBASE
1506
	mov	edx, ICH6_REG_RIRBUBASE
1506
	call	azx_writel
1507
	call	azx_writel
1507
 
1508
 
1508
	; set the rirb size to 256 entries (ULI requires explicitly)
1509
	; set the rirb size to 256 entries (ULI requires explicitly)
1509
	mov	al, 0x02
1510
	mov	al, 0x02
1510
	mov	edx, ICH6_REG_RIRBSIZE
1511
	mov	edx, ICH6_REG_RIRBSIZE
1511
	call	azx_writeb
1512
	call	azx_writeb
1512
	; reset the rirb hw write pointer
1513
	; reset the rirb hw write pointer
1513
	mov	ax, ICH6_RIRBWP_RST
1514
	mov	ax, ICH6_RIRBWP_RST
1514
	mov	edx, ICH6_REG_RIRBWP
1515
	mov	edx, ICH6_REG_RIRBWP
1515
	call	azx_writew
1516
	call	azx_writew
1516
	; set N=1, get RIRB response interrupt for new entry
1517
	; set N=1, get RIRB response interrupt for new entry
1517
	xor	ax, ax
1518
	xor	ax, ax
1518
	cmp	byte [driver_type], AZX_DRIVER_CTX
1519
	cmp	byte [driver_type], AZX_DRIVER_CTX
1519
	jne	@f
1520
	jne	@f
1520
	mov	ax, 0xC0-1
1521
	mov	ax, 0xC0-1
1521
  @@:
1522
  @@:
1522
	inc	ax
1523
	inc	ax
1523
	mov	edx, ICH6_REG_RINTCNT
1524
	mov	edx, ICH6_REG_RINTCNT
1524
	call	azx_writew
1525
	call	azx_writew
1525
	; enable rirb dma and response irq
1526
	; enable rirb dma and response irq
1526
	mov	al, ICH6_RBCTL_DMA_EN or ICH6_RBCTL_IRQ_EN
1527
	mov	al, ICH6_RBCTL_DMA_EN or ICH6_RBCTL_IRQ_EN
1527
	mov	edx, ICH6_REG_RIRBCTL
1528
	mov	edx, ICH6_REG_RIRBCTL
1528
	call	azx_writeb
1529
	call	azx_writeb
1529
 
1530
 
1530
	popa
1531
	popa
1531
	spin_unlock_irq
1532
	spin_unlock_irq
1532
	ret
1533
	ret
1533
endp
1534
endp
1534
 
1535
 
1535
proc azx_free_cmd_io
1536
proc azx_free_cmd_io
1536
	spin_lock_irq
1537
	spin_lock_irq
1537
	push	eax edx
1538
	push	eax edx
1538
	; disable ringbuffer DMAs
1539
	; disable ringbuffer DMAs
1539
	xor	al, al
1540
	xor	al, al
1540
	mov	edx, ICH6_REG_RIRBCTL
1541
	mov	edx, ICH6_REG_RIRBCTL
1541
	call	azx_writeb
1542
	call	azx_writeb
1542
	mov	edx, ICH6_REG_CORBCTL
1543
	mov	edx, ICH6_REG_CORBCTL
1543
	call	azx_writeb
1544
	call	azx_writeb
1544
	pop	edx eax
1545
	pop	edx eax
1545
	spin_unlock_irq
1546
	spin_unlock_irq
1546
	ret
1547
	ret
1547
endp
1548
endp
1548
 
1549
 
1549
 
1550
 
1550
; send a command
1551
; send a command
1551
proc azx_corb_send_cmd	stdcall, val:dword
1552
proc azx_corb_send_cmd	stdcall, val:dword
1552
	spin_lock_irq
1553
	spin_lock_irq
1553
	push	edx edi
1554
	push	edx edi
1554
	xor	eax, eax
1555
	xor	eax, eax
1555
	; add command to corb
1556
	; add command to corb
1556
	mov	edx, ICH6_REG_CORBWP
1557
	mov	edx, ICH6_REG_CORBWP
1557
	call	azx_readb
1558
	call	azx_readb
1558
	inc	al
1559
	inc	al
1559
	inc	dword [ctrl.rirb_cmd]
1560
	inc	dword [ctrl.rirb_cmd]
1560
	mov	edi, dword [ctrl.rb]
1561
	mov	edi, dword [ctrl.rb]
1561
 
1562
 
1562
	push	eax
1563
	push	eax
1563
	shl	eax, 2 ;wp=wp*sizeof(corb entry)=wp*4
1564
	shl	eax, 2 ;wp=wp*sizeof(corb entry)=wp*4
1564
	add	edi, eax
1565
	add	edi, eax
1565
	mov	eax, dword [val]
1566
	mov	eax, dword [val]
1566
	stosd
1567
	stosd
1567
	pop	eax
1568
	pop	eax
1568
	mov	edx, ICH6_REG_CORBWP
1569
	mov	edx, ICH6_REG_CORBWP
1569
	call	azx_writel
1570
	call	azx_writel
1570
 
1571
 
1571
	pop	edi edx
1572
	pop	edi edx
1572
	xor	eax, eax ;Asper+
1573
	xor	eax, eax ;Asper+
1573
	spin_unlock_irq
1574
	spin_unlock_irq
1574
	ret
1575
	ret
1575
endp
1576
endp
1576
 
1577
 
1577
 
1578
 
1578
; retrieve RIRB entry - called from interrupt handler
1579
; retrieve RIRB entry - called from interrupt handler
1579
proc azx_update_rirb
1580
proc azx_update_rirb
1580
	pusha
1581
	pusha
1581
	xor	eax, eax
1582
	xor	eax, eax
1582
	mov	edx, ICH6_REG_RIRBWP
1583
	mov	edx, ICH6_REG_RIRBWP
1583
	call	azx_readb ;call  azx_readw
1584
	call	azx_readb ;call  azx_readw
1584
 
1585
 
1585
	cmp	ax, [ctrl.rirb_wp]
1586
	cmp	ax, [ctrl.rirb_wp]
1586
	je	.done
1587
	je	.done
1587
	mov	[ctrl.rirb_wp], ax
1588
	mov	[ctrl.rirb_wp], ax
1588
	mov	bx, [ctrl.rirb_rp]
1589
	mov	bx, [ctrl.rirb_rp]
1589
 
1590
 
1590
.l1:
1591
.l1:
1591
	cmp	bx, [ctrl.rirb_wp]
1592
	cmp	bx, [ctrl.rirb_wp]
1592
	je	.l3
1593
	je	.l3
1593
 
1594
 
1594
	inc	bl
1595
	inc	bl
1595
.l2:
1596
.l2:
1596
	cmp	bx, ICH6_MAX_RIRB_ENTRIES
1597
	cmp	bx, ICH6_MAX_RIRB_ENTRIES
1597
	jl	@f
1598
	jl	@f
1598
	sub	bx, ICH6_MAX_RIRB_ENTRIES
1599
	sub	bx, ICH6_MAX_RIRB_ENTRIES
1599
	jmp	.l2
1600
	jmp	.l2
1600
@@:
1601
@@:
1601
 
1602
 
1602
	movzx	edx, bx
1603
	movzx	edx, bx
1603
	shl	edx, 1 + 2 ; an RIRB entry is 8-bytes
1604
	shl	edx, 1 + 2 ; an RIRB entry is 8-bytes
1604
	mov	esi, dword [ctrl.rb]
1605
	mov	esi, dword [ctrl.rb]
1605
	add	esi, 2048
1606
	add	esi, 2048
1606
	add	esi, edx
1607
	add	esi, edx
1607
	lodsd	; res
1608
	lodsd	; res
1608
	mov	edx, eax
1609
	mov	edx, eax
1609
	lodsd	; res_ex
1610
	lodsd	; res_ex
1610
 
1611
 
1611
	test	eax, ICH6_RIRB_EX_UNSOL_EV
1612
	test	eax, ICH6_RIRB_EX_UNSOL_EV
1612
	jz	@f
1613
	jz	@f
1613
	stdcall snd_hda_queue_unsol_event, edx, eax
1614
	stdcall snd_hda_queue_unsol_event, edx, eax
1614
	jmp	.l1
1615
	jmp	.l1
1615
@@:
1616
@@:
1616
	mov	ecx, [ctrl.rirb_cmd]
1617
	mov	ecx, [ctrl.rirb_cmd]
1617
	test	ecx, ecx
1618
	test	ecx, ecx
1618
	jz	@f
1619
	jz	@f
1619
	mov	[ctrl.rirb_res], edx
1620
	mov	[ctrl.rirb_res], edx
1620
	dec	dword [ctrl.rirb_cmd]
1621
	dec	dword [ctrl.rirb_cmd]
1621
	jmp	.l1
1622
	jmp	.l1
1622
@@:
1623
@@:
1623
if DEBUG
1624
if DEBUG
1624
	push	esi
1625
	push	esi
1625
	mov	esi, msgSpuriousResponce
1626
	mov	esi, msgSpuriousResponce
1626
	invoke	SysMsgBoardStr
1627
	invoke	SysMsgBoardStr
1627
	pop	esi
1628
	pop	esi
1628
end if
1629
end if
1629
	jmp	.l1
1630
	jmp	.l1
1630
.l3:
1631
.l3:
1631
	mov	[ctrl.rirb_rp], bx
1632
	mov	[ctrl.rirb_rp], bx
1632
.done:
1633
.done:
1633
	popa
1634
	popa
1634
	ret
1635
	ret
1635
endp
1636
endp
1636
 
1637
 
1637
; receive a response
1638
; receive a response
1638
proc azx_rirb_get_response
1639
proc azx_rirb_get_response
1639
locals
1640
locals
1640
	do_poll db 0
1641
	do_poll db 0
1641
endl
1642
endl
1642
 
1643
 
1643
	push	ebx ecx edx
1644
	push	ebx ecx edx
1644
.again:
1645
.again:
1645
	mov	ecx, 1000;+1000
1646
	mov	ecx, 1000;+1000
1646
.next_try:
1647
.next_try:
1647
	mov	al, [ctrl.polling_mode]
1648
	mov	al, [ctrl.polling_mode]
1648
	test	al, al
1649
	test	al, al
1649
	jnz	.poll
1650
	jnz	.poll
1650
	mov	ah, [do_poll]
1651
	mov	ah, [do_poll]
1651
	test	ah, ah
1652
	test	ah, ah
1652
	jz	@f
1653
	jz	@f
1653
.poll:
1654
.poll:
1654
	spin_lock_irq
1655
	spin_lock_irq
1655
	call	azx_update_rirb
1656
	call	azx_update_rirb
1656
	spin_unlock_irq
1657
	spin_unlock_irq
1657
@@:
1658
@@:
1658
	mov	eax, [ctrl.rirb_cmd]
1659
	mov	eax, [ctrl.rirb_cmd]
1659
	test	eax, eax
1660
	test	eax, eax
1660
	jnz	.l1
1661
	jnz	.l1
1661
	mov	[ctrl.rirb_error], 0
1662
	mov	[ctrl.rirb_error], 0
1662
	mov	al, [do_poll]
1663
	mov	al, [do_poll]
1663
	test	al, al
1664
	test	al, al
1664
	jnz	@f
1665
	jnz	@f
1665
	mov	[ctrl.poll_count], 0
1666
	mov	[ctrl.poll_count], 0
1666
@@:
1667
@@:
1667
	mov	eax, [ctrl.rirb_res] ; the last value
1668
	mov	eax, [ctrl.rirb_res] ; the last value
1668
	jmp	.out
1669
	jmp	.out
1669
.l1:
1670
.l1:
1670
	push	eax
1671
	push	eax
1671
	mov	eax, 2000  ; temporary workaround
1672
	mov	eax, 2000  ; temporary workaround
1672
	call	StallExec
1673
	call	StallExec
1673
	pop	eax
1674
	pop	eax
1674
	dec	ecx
1675
	dec	ecx
1675
	jnz	.next_try
1676
	jnz	.next_try
1676
.no_next_try:
1677
.no_next_try:
1677
	mov	al, [ctrl.polling_mode]
1678
	mov	al, [ctrl.polling_mode]
1678
	test	al, al
1679
	test	al, al
1679
	jnz	.no_poll
1680
	jnz	.no_poll
1680
 
1681
 
1681
	mov	al, [ctrl.poll_count]
1682
	mov	al, [ctrl.poll_count]
1682
	cmp	al, 2
1683
	cmp	al, 2
1683
	jge	.poll_count_overflow
1684
	jge	.poll_count_overflow
1684
if DEBUG
1685
if DEBUG
1685
	push	eax esi
1686
	push	eax esi
1686
	mov	esi, msgGetResponceTimeout
1687
	mov	esi, msgGetResponceTimeout
1687
	invoke	SysMsgBoardStr
1688
	invoke	SysMsgBoardStr
1688
	mov	esi, msgPollingCodecOnce
1689
	mov	esi, msgPollingCodecOnce
1689
	invoke	SysMsgBoardStr
1690
	invoke	SysMsgBoardStr
1690
	pop	esi eax
1691
	pop	esi eax
1691
end if
1692
end if
1692
	mov	[do_poll], 1
1693
	mov	[do_poll], 1
1693
	inc	[ctrl.poll_count]
1694
	inc	[ctrl.poll_count]
1694
	jmp	.again
1695
	jmp	.again
1695
 
1696
 
1696
.poll_count_overflow:
1697
.poll_count_overflow:
1697
if DEBUG
1698
if DEBUG
1698
	push	eax esi
1699
	push	eax esi
1699
	mov	esi, msgGetResponceTimeout
1700
	mov	esi, msgGetResponceTimeout
1700
	invoke	SysMsgBoardStr
1701
	invoke	SysMsgBoardStr
1701
	mov	esi, msgSwitchToPollMode
1702
	mov	esi, msgSwitchToPollMode
1702
	invoke	SysMsgBoardStr
1703
	invoke	SysMsgBoardStr
1703
	pop	esi eax
1704
	pop	esi eax
1704
end if
1705
end if
1705
	mov	[ctrl.polling_mode], 1
1706
	mov	[ctrl.polling_mode], 1
1706
	jmp	.again
1707
	jmp	.again
1707
 
1708
 
1708
.no_poll:
1709
.no_poll:
1709
 
1710
 
1710
	mov	al, [ctrl.polling_mode]
1711
	mov	al, [ctrl.polling_mode]
1711
	test	al, al
1712
	test	al, al
1712
	jz	@f
1713
	jz	@f
1713
	mov	eax, -1
1714
	mov	eax, -1
1714
	jmp	.out
1715
	jmp	.out
1715
@@:
1716
@@:
1716
 
1717
 
1717
	; a fatal communication error; need either to reset or to fallback
1718
	; a fatal communication error; need either to reset or to fallback
1718
	; to the single_cmd mode
1719
	; to the single_cmd mode
1719
	mov	[ctrl.rirb_error], 1
1720
	mov	[ctrl.rirb_error], 1
1720
	;Asper~ -?  [
1721
	;Asper~ -?  [
1721
	mov	[ctrl.response_reset], 1
1722
	mov	[ctrl.response_reset], 1
1722
	mov	eax, -1  ; give a chance to retry
1723
	mov	eax, -1  ; give a chance to retry
1723
	jmp	.out
1724
	jmp	.out
1724
	;Asper~ -?  ]
1725
	;Asper~ -?  ]
1725
 
1726
 
1726
	;-? mov     [ctrl.single_cmd], 1
1727
	;-? mov     [ctrl.single_cmd], 1
1727
	mov	[ctrl.response_reset], 0
1728
	mov	[ctrl.response_reset], 0
1728
 
1729
 
1729
	; release CORB/RIRB
1730
	; release CORB/RIRB
1730
	call	azx_free_cmd_io
1731
	call	azx_free_cmd_io
1731
	; disable unsolicited responses
1732
	; disable unsolicited responses
1732
	mov	edx, ICH6_REG_GCTL
1733
	mov	edx, ICH6_REG_GCTL
1733
	call	azx_readl
1734
	call	azx_readl
1734
	mov	ebx, ICH6_GCTL_UNSOL
1735
	mov	ebx, ICH6_GCTL_UNSOL
1735
	xor	ebx, -1
1736
	xor	ebx, -1
1736
	and	eax, ebx
1737
	and	eax, ebx
1737
	mov	edx, ICH6_REG_GCTL
1738
	mov	edx, ICH6_REG_GCTL
1738
	call	azx_writel
1739
	call	azx_writel
1739
	mov	eax, -1
1740
	mov	eax, -1
1740
.out:
1741
.out:
1741
	pop	edx ecx ebx
1742
	pop	edx ecx ebx
1742
	ret
1743
	ret
1743
endp
1744
endp
1744
 
1745
 
1745
;
1746
;
1746
; Use the single immediate command instead of CORB/RIRB for simplicity
1747
; Use the single immediate command instead of CORB/RIRB for simplicity
1747
;
1748
;
1748
; Note: according to Intel, this is not preferred use.  The command was
1749
; Note: according to Intel, this is not preferred use.  The command was
1749
;       intended for the BIOS only, and may get confused with unsolicited
1750
;       intended for the BIOS only, and may get confused with unsolicited
1750
;       responses.  So, we shouldn't use it for normal operation from the
1751
;       responses.  So, we shouldn't use it for normal operation from the
1751
;       driver.
1752
;       driver.
1752
;       I left the codes, however, for debugging/testing purposes.
1753
;       I left the codes, however, for debugging/testing purposes.
1753
;
1754
;
1754
 
1755
 
1755
; receive a response
1756
; receive a response
1756
proc azx_single_wait_for_response
1757
proc azx_single_wait_for_response
1757
	push	ecx edx esi
1758
	push	ecx edx esi
1758
 
1759
 
1759
	mov	ecx, 50
1760
	mov	ecx, 50
1760
.l1:
1761
.l1:
1761
	test	ecx, ecx
1762
	test	ecx, ecx
1762
	jz	.timeout
1763
	jz	.timeout
1763
 
1764
 
1764
	; check IRV busy bit
1765
	; check IRV busy bit
1765
	mov	edx, ICH6_REG_IRS
1766
	mov	edx, ICH6_REG_IRS
1766
	call	azx_readw
1767
	call	azx_readw
1767
	test	ax, ICH6_IRS_VALID
1768
	test	ax, ICH6_IRS_VALID
1768
	jz	@f
1769
	jz	@f
1769
	; reuse rirb.res as the response return value
1770
	; reuse rirb.res as the response return value
1770
	mov	edx, ICH6_REG_IR
1771
	mov	edx, ICH6_REG_IR
1771
	call	azx_readl
1772
	call	azx_readl
1772
	mov	[ctrl.rirb_res], eax
1773
	mov	[ctrl.rirb_res], eax
1773
 
1774
 
1774
	pop	esi edx ecx
1775
	pop	esi edx ecx
1775
	xor	eax, eax
1776
	xor	eax, eax
1776
	ret
1777
	ret
1777
@@:
1778
@@:
1778
	xor	eax, eax
1779
	xor	eax, eax
1779
	inc	eax
1780
	inc	eax
1780
	call	StallExec
1781
	call	StallExec
1781
 
1782
 
1782
	dec	ecx
1783
	dec	ecx
1783
	jmp	.l1
1784
	jmp	.l1
1784
.timeout:
1785
.timeout:
1785
if DEBUG
1786
if DEBUG
1786
	xor	eax, eax
1787
	xor	eax, eax
1787
	mov	edx, ICH6_REG_IRS
1788
	mov	edx, ICH6_REG_IRS
1788
	call	azx_readw
1789
	call	azx_readw
1789
	mov	esi, msgGetResponceTimeout
1790
	mov	esi, msgGetResponceTimeout
1790
	invoke	SysMsgBoardStr
1791
	invoke	SysMsgBoardStr
1791
	mov	esi, msgIRS
1792
	mov	esi, msgIRS
1792
	invoke	SysMsgBoardStr
1793
	invoke	SysMsgBoardStr
1793
	stdcall fdword2str, 2
1794
	stdcall fdword2str, 2
1794
	invoke	SysMsgBoardStr
1795
	invoke	SysMsgBoardStr
1795
end if
1796
end if
1796
 
1797
 
1797
	pop	esi edx ecx
1798
	pop	esi edx ecx
1798
	mov	eax, -1
1799
	mov	eax, -1
1799
	mov	[ctrl.rirb_res], eax
1800
	mov	[ctrl.rirb_res], eax
1800
	ret
1801
	ret
1801
endp
1802
endp
1802
 
1803
 
1803
; send a command
1804
; send a command
1804
proc azx_single_send_cmd  stdcall, val:dword
1805
proc azx_single_send_cmd  stdcall, val:dword
1805
	push	ecx edx esi
1806
	push	ecx edx esi
1806
 
1807
 
1807
	mov	ecx, 50
1808
	mov	ecx, 50
1808
.l1:
1809
.l1:
1809
	test	ecx, ecx
1810
	test	ecx, ecx
1810
	jz	.timeout
1811
	jz	.timeout
1811
 
1812
 
1812
	; check ICB busy bit
1813
	; check ICB busy bit
1813
	mov	edx, ICH6_REG_IRS
1814
	mov	edx, ICH6_REG_IRS
1814
	call	azx_readw
1815
	call	azx_readw
1815
	test	ax, ICH6_IRS_BUSY
1816
	test	ax, ICH6_IRS_BUSY
1816
	jnz	@f
1817
	jnz	@f
1817
	; Clear IRV valid bit
1818
	; Clear IRV valid bit
1818
	mov	edx, ICH6_REG_IRS
1819
	mov	edx, ICH6_REG_IRS
1819
	call	azx_readw
1820
	call	azx_readw
1820
	or	ax, ICH6_IRS_VALID
1821
	or	ax, ICH6_IRS_VALID
1821
	mov	edx, ICH6_REG_IRS
1822
	mov	edx, ICH6_REG_IRS
1822
	call	azx_writew
1823
	call	azx_writew
1823
 
1824
 
1824
	mov	eax, dword [val]
1825
	mov	eax, dword [val]
1825
	mov	edx, ICH6_REG_IC
1826
	mov	edx, ICH6_REG_IC
1826
	call	azx_writel
1827
	call	azx_writel
1827
 
1828
 
1828
	mov	edx, ICH6_REG_IRS
1829
	mov	edx, ICH6_REG_IRS
1829
	call	azx_readw
1830
	call	azx_readw
1830
	or	ax, ICH6_IRS_BUSY
1831
	or	ax, ICH6_IRS_BUSY
1831
	mov	edx, ICH6_REG_IRS
1832
	mov	edx, ICH6_REG_IRS
1832
	call	azx_writew
1833
	call	azx_writew
1833
 
1834
 
1834
	stdcall azx_single_wait_for_response
1835
	stdcall azx_single_wait_for_response
1835
	pop	esi edx ecx
1836
	pop	esi edx ecx
1836
	ret
1837
	ret
1837
@@:
1838
@@:
1838
	dec	ecx
1839
	dec	ecx
1839
	jmp	.l1
1840
	jmp	.l1
1840
.timeout:
1841
.timeout:
1841
if DEBUG
1842
if DEBUG
1842
	xor	eax, eax
1843
	xor	eax, eax
1843
	mov	edx, ICH6_REG_IRS
1844
	mov	edx, ICH6_REG_IRS
1844
	call	azx_readw
1845
	call	azx_readw
1845
	mov	esi, msgSendCmdTimeout
1846
	mov	esi, msgSendCmdTimeout
1846
	invoke	SysMsgBoardStr
1847
	invoke	SysMsgBoardStr
1847
	stdcall fdword2str, 2
1848
	stdcall fdword2str, 2
1848
	invoke	SysMsgBoardStr
1849
	invoke	SysMsgBoardStr
1849
	mov	esi, msgVal
1850
	mov	esi, msgVal
1850
	invoke	SysMsgBoardStr
1851
	invoke	SysMsgBoardStr
1851
	mov	eax, dword [val]
1852
	mov	eax, dword [val]
1852
	stdcall fdword2str, 2
1853
	stdcall fdword2str, 2
1853
	invoke	SysMsgBoardStr
1854
	invoke	SysMsgBoardStr
1854
end if
1855
end if
1855
 
1856
 
1856
	pop	esi edx ecx
1857
	pop	esi edx ecx
1857
	mov	eax, -1
1858
	mov	eax, -1
1858
	ret
1859
	ret
1859
endp
1860
endp
1860
 
1861
 
1861
; receive a response
1862
; receive a response
1862
proc azx_single_get_response
1863
proc azx_single_get_response
1863
	mov	eax, [ctrl.rirb_res]
1864
	mov	eax, [ctrl.rirb_res]
1864
	ret
1865
	ret
1865
endp
1866
endp
1866
 
1867
 
1867
;
1868
;
1868
; The below are the main callbacks from hda_codec.
1869
; The below are the main callbacks from hda_codec.
1869
;
1870
;
1870
; They are just the skeleton to call sub-callbacks according to the
1871
; They are just the skeleton to call sub-callbacks according to the
1871
; current setting of chip->single_cmd.
1872
; current setting of chip->single_cmd.
1872
;
1873
;
1873
 
1874
 
1874
; send a command
1875
; send a command
1875
proc azx_send_cmd  stdcall, val:dword
1876
proc azx_send_cmd  stdcall, val:dword
1876
if USE_SINGLE_MODE
1877
if USE_SINGLE_MODE
1877
	stdcall azx_single_send_cmd, [val]
1878
	stdcall azx_single_send_cmd, [val]
1878
else
1879
else
1879
	stdcall azx_corb_send_cmd, [val]
1880
	stdcall azx_corb_send_cmd, [val]
1880
end if
1881
end if
1881
	ret
1882
	ret
1882
endp
1883
endp
1883
 
1884
 
1884
; get a response
1885
; get a response
1885
proc azx_get_response
1886
proc azx_get_response
1886
if USE_SINGLE_MODE
1887
if USE_SINGLE_MODE
1887
	call	azx_single_get_response
1888
	call	azx_single_get_response
1888
else
1889
else
1889
	call	azx_rirb_get_response
1890
	call	azx_rirb_get_response
1890
end if
1891
end if
1891
	ret
1892
	ret
1892
endp
1893
endp
1893
 
1894
 
1894
 
1895
 
1895
;;;;;;;;;;;;;;;;;;;;;;;;
1896
;;;;;;;;;;;;;;;;;;;;;;;;
1896
;; Lowlevel interface ;;
1897
;; Lowlevel interface ;;
1897
;;;;;;;;;;;;;;;;;;;;;;;;
1898
;;;;;;;;;;;;;;;;;;;;;;;;
1898
 
1899
 
1899
; enable interrupts
1900
; enable interrupts
1900
proc azx_int_enable
1901
proc azx_int_enable
1901
	push	 eax edx
1902
	push	 eax edx
1902
	; enable controller CIE and GIE
1903
	; enable controller CIE and GIE
1903
	mov	edx, ICH6_REG_INTCTL
1904
	mov	edx, ICH6_REG_INTCTL
1904
	call	azx_readl
1905
	call	azx_readl
1905
	or	eax, ICH6_INT_CTRL_EN or ICH6_INT_GLOBAL_EN
1906
	or	eax, ICH6_INT_CTRL_EN or ICH6_INT_GLOBAL_EN
1906
	mov	edx, ICH6_REG_INTCTL
1907
	mov	edx, ICH6_REG_INTCTL
1907
	call	azx_writel
1908
	call	azx_writel
1908
	pop	edx eax
1909
	pop	edx eax
1909
	ret
1910
	ret
1910
endp
1911
endp
1911
 
1912
 
1912
; disable interrupts
1913
; disable interrupts
1913
proc azx_int_disable
1914
proc azx_int_disable
1914
	push	eax ebx edx
1915
	push	eax ebx edx
1915
 
1916
 
1916
	; disable interrupts in stream descriptor
1917
	; disable interrupts in stream descriptor
1917
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1918
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1918
	call	azx_readb
1919
	call	azx_readb
1919
	mov	bl, SD_INT_MASK
1920
	mov	bl, SD_INT_MASK
1920
	xor	bl, -1
1921
	xor	bl, -1
1921
	and	al, bl
1922
	and	al, bl
1922
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1923
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1923
	call	azx_writeb
1924
	call	azx_writeb
1924
 
1925
 
1925
	; disable SIE for all streams
1926
	; disable SIE for all streams
1926
	xor	al, al
1927
	xor	al, al
1927
	mov	edx, ICH6_REG_INTCTL
1928
	mov	edx, ICH6_REG_INTCTL
1928
	call	azx_writeb
1929
	call	azx_writeb
1929
 
1930
 
1930
	; disable controller CIE and GIE
1931
	; disable controller CIE and GIE
1931
	mov	edx, ICH6_REG_INTCTL
1932
	mov	edx, ICH6_REG_INTCTL
1932
	call	azx_readl
1933
	call	azx_readl
1933
	mov	ebx, ICH6_INT_CTRL_EN or ICH6_INT_GLOBAL_EN
1934
	mov	ebx, ICH6_INT_CTRL_EN or ICH6_INT_GLOBAL_EN
1934
	xor	ebx, -1
1935
	xor	ebx, -1
1935
	and	eax, ebx
1936
	and	eax, ebx
1936
	call	azx_writel
1937
	call	azx_writel
1937
	pop	edx ebx eax
1938
	pop	edx ebx eax
1938
	ret
1939
	ret
1939
endp
1940
endp
1940
 
1941
 
1941
; clear interrupts
1942
; clear interrupts
1942
proc azx_int_clear
1943
proc azx_int_clear
1943
	push	eax edx
1944
	push	eax edx
1944
 
1945
 
1945
	; clear stream status
1946
	; clear stream status
1946
	mov	al, SD_INT_MASK
1947
	mov	al, SD_INT_MASK
1947
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
1948
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
1948
	call	azx_writeb
1949
	call	azx_writeb
1949
 
1950
 
1950
	; clear STATESTS
1951
	; clear STATESTS
1951
	mov	al, STATESTS_INT_MASK
1952
	mov	al, STATESTS_INT_MASK
1952
	mov	edx, ICH6_REG_STATESTS
1953
	mov	edx, ICH6_REG_STATESTS
1953
	call	azx_writeb
1954
	call	azx_writeb
1954
 
1955
 
1955
	; clear rirb status
1956
	; clear rirb status
1956
	mov	al, RIRB_INT_MASK
1957
	mov	al, RIRB_INT_MASK
1957
	mov	edx, ICH6_REG_RIRBSTS
1958
	mov	edx, ICH6_REG_RIRBSTS
1958
	call	azx_writeb
1959
	call	azx_writeb
1959
 
1960
 
1960
	; clear int status
1961
	; clear int status
1961
	mov	eax, ICH6_INT_CTRL_EN or ICH6_INT_ALL_STREAM
1962
	mov	eax, ICH6_INT_CTRL_EN or ICH6_INT_ALL_STREAM
1962
	mov	edx, ICH6_REG_INTSTS
1963
	mov	edx, ICH6_REG_INTSTS
1963
	call	azx_writel
1964
	call	azx_writel
1964
	pop	edx eax
1965
	pop	edx eax
1965
	ret
1966
	ret
1966
endp
1967
endp
1967
 
1968
 
1968
 
1969
 
1969
; start a stream
1970
; start a stream
1970
proc azx_stream_start
1971
proc azx_stream_start
1971
	push	eax edx
1972
	push	eax edx
1972
 
1973
 
1973
	; enable SIE
1974
	; enable SIE
1974
	mov	edx, ICH6_REG_INTCTL
1975
	mov	edx, ICH6_REG_INTCTL
1975
	call	azx_readl
1976
	call	azx_readl
1976
 
1977
 
1977
	or	eax, 0xC0000000 ;Asper+
1978
	or	eax, 0xC0000000 ;Asper+
1978
	or	eax, SDO_INT  ; Asper: output stream interrupt index
1979
	or	eax, SDO_INT  ; Asper: output stream interrupt index
1979
	mov	edx, ICH6_REG_INTCTL
1980
	mov	edx, ICH6_REG_INTCTL
1980
	call	azx_writel
1981
	call	azx_writel
1981
	; set DMA start and interrupt mask
1982
	; set DMA start and interrupt mask
1982
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1983
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1983
	call	azx_readb
1984
	call	azx_readb
1984
 
1985
 
1985
	or	al, SD_CTL_DMA_START or SD_INT_MASK
1986
	or	al, SD_CTL_DMA_START or SD_INT_MASK
1986
 
1987
 
1987
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1988
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1988
	call	azx_writeb
1989
	call	azx_writeb
1989
 
1990
 
1990
	pop	edx eax
1991
	pop	edx eax
1991
	ret
1992
	ret
1992
endp
1993
endp
1993
 
1994
 
1994
; stop DMA
1995
; stop DMA
1995
proc azx_stream_clear
1996
proc azx_stream_clear
1996
	push	eax ebx edx
1997
	push	eax ebx edx
1997
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1998
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
1998
	call	azx_readb
1999
	call	azx_readb
1999
	mov	bl, SD_CTL_DMA_START or SD_INT_MASK
2000
	mov	bl, SD_CTL_DMA_START or SD_INT_MASK
2000
	xor	bl, -1
2001
	xor	bl, -1
2001
	and	al, bl
2002
	and	al, bl
2002
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2003
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2003
	call	azx_writeb
2004
	call	azx_writeb
2004
	mov	al, SD_INT_MASK
2005
	mov	al, SD_INT_MASK
2005
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
2006
	mov	edx, ICH6_REG_SD_STS + SDO_OFS
2006
	call	azx_writeb
2007
	call	azx_writeb
2007
	pop	edx ebx eax
2008
	pop	edx ebx eax
2008
	ret
2009
	ret
2009
endp
2010
endp
2010
 
2011
 
2011
; stop a stream
2012
; stop a stream
2012
proc azx_stream_stop
2013
proc azx_stream_stop
2013
	push	eax ebx edx
2014
	push	eax ebx edx
2014
	call	azx_stream_clear
2015
	call	azx_stream_clear
2015
	; disable SIE
2016
	; disable SIE
2016
	mov	edx, ICH6_REG_INTCTL
2017
	mov	edx, ICH6_REG_INTCTL
2017
	call	azx_readl
2018
	call	azx_readl
2018
	mov	ebx, (SDO_INT)
2019
	mov	ebx, (SDO_INT)
2019
	xor	ebx, -1
2020
	xor	ebx, -1
2020
	and	eax, ebx
2021
	and	eax, ebx
2021
	mov	edx, ICH6_REG_INTCTL
2022
	mov	edx, ICH6_REG_INTCTL
2022
	call	azx_writel
2023
	call	azx_writel
2023
	pop	edx ebx eax
2024
	pop	edx ebx eax
2024
	ret
2025
	ret
2025
endp
2026
endp
2026
 
2027
 
2027
;
2028
;
2028
;in: eax = full_reset
2029
;in: eax = full_reset
2029
;
2030
;
2030
; initialize the chip
2031
; initialize the chip
2031
proc azx_init_chip
2032
proc azx_init_chip
2032
	push	eax
2033
	push	eax
2033
 
2034
 
2034
	; reset controller
2035
	; reset controller
2035
	mov	eax, 1 ;full reset
2036
	mov	eax, 1 ;full reset
2036
	call	reset_controller
2037
	call	reset_controller
2037
 
2038
 
2038
	; initialize interrupts
2039
	; initialize interrupts
2039
	call	azx_int_clear
2040
	call	azx_int_clear
2040
	call	azx_int_enable
2041
	call	azx_int_enable
2041
 
2042
 
2042
	; initialize the codec command I/O
2043
	; initialize the codec command I/O
2043
if USE_SINGLE_MODE
2044
if USE_SINGLE_MODE
2044
else
2045
else
2045
	call	azx_init_cmd_io
2046
	call	azx_init_cmd_io
2046
end if
2047
end if
2047
 
2048
 
2048
	; program the position buffer
2049
	; program the position buffer
2049
	mov	eax, dword [ctrl.posbuf]
2050
	mov	eax, dword [ctrl.posbuf]
2050
	mov	ebx, eax
2051
	mov	ebx, eax
2051
	invoke	GetPgAddr
2052
	invoke	GetPgAddr
2052
	and	ebx, 0xFFF
2053
	and	ebx, 0xFFF
2053
	add	eax, ebx
2054
	add	eax, ebx
2054
	mov	edx, ICH6_REG_DPLBASE
2055
	mov	edx, ICH6_REG_DPLBASE
2055
	call	azx_writel
2056
	call	azx_writel
2056
	xor	eax, eax
2057
	xor	eax, eax
2057
	mov	edx, ICH6_REG_DPUBASE
2058
	mov	edx, ICH6_REG_DPUBASE
2058
	call	azx_writel
2059
	call	azx_writel
2059
 
2060
 
2060
	pop	eax
2061
	pop	eax
2061
	ret
2062
	ret
2062
endp
2063
endp
2063
 
2064
 
2064
 
2065
 
2065
; initialize the PCI registers
2066
; initialize the PCI registers
2066
 
2067
 
2067
; update bits in a PCI register byte
2068
; update bits in a PCI register byte
2068
proc update_pci_byte  stdcall, reg:dword, mask:dword, val:dword
2069
proc update_pci_byte  stdcall, reg:dword, mask:dword, val:dword
2069
	push	ax bx
2070
	push	ax bx
2070
	invoke	PciRead8, [ctrl.bus], [ctrl.devfn], [reg]
2071
	invoke	PciRead8, [ctrl.bus], [ctrl.devfn], [reg]
2071
	mov	bl, byte [mask]
2072
	mov	bl, byte [mask]
2072
	mov	bh, bl
2073
	mov	bh, bl
2073
	xor	bl, -1
2074
	xor	bl, -1
2074
	and	al, bl
2075
	and	al, bl
2075
	shr	bx, 8
2076
	shr	bx, 8
2076
	and	bl, byte [val]
2077
	and	bl, byte [val]
2077
	or	al, bl
2078
	or	al, bl
2078
	invoke	PciWrite8, [ctrl.bus], [ctrl.devfn], [reg], eax
2079
	invoke	PciWrite8, [ctrl.bus], [ctrl.devfn], [reg], eax
2079
	pop	bx ax
2080
	pop	bx ax
2080
	ret
2081
	ret
2081
endp
2082
endp
2082
 
2083
 
2083
 
2084
 
2084
proc azx_init_pci
2085
proc azx_init_pci
2085
	; Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
2086
	; Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
2086
	; TCSEL == Traffic Class Select Register, which sets PCI express QOS
2087
	; TCSEL == Traffic Class Select Register, which sets PCI express QOS
2087
	; Ensuring these bits are 0 clears playback static on some HD Audio
2088
	; Ensuring these bits are 0 clears playback static on some HD Audio
2088
	; codecs
2089
	; codecs
2089
	push	eax
2090
	push	eax
2090
	stdcall update_pci_byte, ICH6_PCIREG_TCSEL, 0x07, 0
2091
	stdcall update_pci_byte, ICH6_PCIREG_TCSEL, 0x07, 0
2091
 
2092
 
2092
	mov	eax, [driver_type]
2093
	mov	eax, [driver_type]
2093
	cmp	eax, AZX_DRIVER_ATI
2094
	cmp	eax, AZX_DRIVER_ATI
2094
	jne	@f
2095
	jne	@f
2095
	; For ATI SB450 azalia HD audio, we need to enable snoop
2096
	; For ATI SB450 azalia HD audio, we need to enable snoop
2096
	stdcall update_pci_byte, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07, ATI_SB450_HDAUDIO_ENABLE_SNOOP
2097
	stdcall update_pci_byte, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07, ATI_SB450_HDAUDIO_ENABLE_SNOOP
2097
	jmp	.done
2098
	jmp	.done
2098
@@:
2099
@@:
2099
	cmp	eax, AZX_DRIVER_NVIDIA
2100
	cmp	eax, AZX_DRIVER_NVIDIA
2100
	jne	@f
2101
	jne	@f
2101
	; For NVIDIA HDA, enable snoop
2102
	; For NVIDIA HDA, enable snoop
2102
	stdcall update_pci_byte, NVIDIA_HDA_TRANSREG_ADDR, 0x0f, NVIDIA_HDA_ENABLE_COHBITS
2103
	stdcall update_pci_byte, NVIDIA_HDA_TRANSREG_ADDR, 0x0f, NVIDIA_HDA_ENABLE_COHBITS
2103
	stdcall update_pci_byte, NVIDIA_HDA_ISTRM_COH, 0x01, NVIDIA_HDA_ENABLE_COHBIT
2104
	stdcall update_pci_byte, NVIDIA_HDA_ISTRM_COH, 0x01, NVIDIA_HDA_ENABLE_COHBIT
2104
	stdcall update_pci_byte, NVIDIA_HDA_OSTRM_COH, 0x01, NVIDIA_HDA_ENABLE_COHBIT
2105
	stdcall update_pci_byte, NVIDIA_HDA_OSTRM_COH, 0x01, NVIDIA_HDA_ENABLE_COHBIT
2105
	jmp	.done
2106
	jmp	.done
2106
@@:
2107
@@:
2107
	cmp	eax, AZX_DRIVER_SCH
2108
	cmp	eax, AZX_DRIVER_SCH
2108
	je	.l1
2109
	je	.l1
2109
	cmp	eax, AZX_DRIVER_PCH
2110
	cmp	eax, AZX_DRIVER_PCH
2110
	jne	@f
2111
	jne	@f
2111
.l1:
2112
.l1:
2112
	invoke	PciRead16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2113
	invoke	PciRead16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2113
	test	ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2114
	test	ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2114
	jz	@f
2115
	jz	@f
2115
	push	ebx
2116
	push	ebx
2116
	mov	ebx, INTEL_SCH_HDA_DEVC_NOSNOOP
2117
	mov	ebx, INTEL_SCH_HDA_DEVC_NOSNOOP
2117
	xor	ebx, -1
2118
	xor	ebx, -1
2118
	and	eax, ebx
2119
	and	eax, ebx
2119
	pop	ebx
2120
	pop	ebx
2120
	invoke	PciWrite16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC, eax
2121
	invoke	PciWrite16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC, eax
2121
	invoke	PciRead16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2122
	invoke	PciRead16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2122
 
2123
 
2123
if DEBUG
2124
if DEBUG
2124
	push	esi
2125
	push	esi
2125
	mov	esi, msgHDASnoopDisabled
2126
	mov	esi, msgHDASnoopDisabled
2126
	invoke	SysMsgBoardStr
2127
	invoke	SysMsgBoardStr
2127
	mov	esi, msg_OK
2128
	mov	esi, msg_OK
2128
	test	ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2129
	test	ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2129
	jz	.snoop_ok
2130
	jz	.snoop_ok
2130
	mov	esi, msg_Fail
2131
	mov	esi, msg_Fail
2131
.snoop_ok:
2132
.snoop_ok:
2132
	invoke	SysMsgBoardStr
2133
	invoke	SysMsgBoardStr
2133
	pop	esi
2134
	pop	esi
2134
end if
2135
end if
2135
@@:
2136
@@:
2136
.done:
2137
.done:
2137
	pop	eax
2138
	pop	eax
2138
	ret
2139
	ret
2139
endp
2140
endp
2140
 
2141
 
2141
 
2142
 
2142
; reset stream
2143
; reset stream
2143
proc azx_stream_reset
2144
proc azx_stream_reset
2144
	push	eax ebx ecx edx
2145
	push	eax ebx ecx edx
2145
 
2146
 
2146
	call	azx_stream_clear
2147
	call	azx_stream_clear
2147
 
2148
 
2148
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2149
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2149
	call	azx_readb
2150
	call	azx_readb
2150
	or	al, SD_CTL_STREAM_RESET
2151
	or	al, SD_CTL_STREAM_RESET
2151
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2152
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2152
	call	azx_writeb
2153
	call	azx_writeb
2153
 
2154
 
2154
	mov	eax, 3
2155
	mov	eax, 3
2155
	call	StallExec
2156
	call	StallExec
2156
 
2157
 
2157
	mov	ecx, 300
2158
	mov	ecx, 300
2158
.l1:
2159
.l1:
2159
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2160
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2160
	call	azx_readb
2161
	call	azx_readb
2161
	test	al, SD_CTL_STREAM_RESET
2162
	test	al, SD_CTL_STREAM_RESET
2162
	jnz	@f
2163
	jnz	@f
2163
	dec	ecx
2164
	dec	ecx
2164
	jnz	.l1
2165
	jnz	.l1
2165
@@:
2166
@@:
2166
	mov	bl, SD_CTL_STREAM_RESET
2167
	mov	bl, SD_CTL_STREAM_RESET
2167
	xor	bl, -1
2168
	xor	bl, -1
2168
	and	al, bl
2169
	and	al, bl
2169
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2170
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2170
	call	azx_writeb
2171
	call	azx_writeb
2171
 
2172
 
2172
	mov	eax, 3
2173
	mov	eax, 3
2173
	call	StallExec
2174
	call	StallExec
2174
 
2175
 
2175
	mov	ecx, 300
2176
	mov	ecx, 300
2176
	; waiting for hardware to report that the stream is out of reset
2177
	; waiting for hardware to report that the stream is out of reset
2177
.l2:
2178
.l2:
2178
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2179
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2179
	call	azx_readb
2180
	call	azx_readb
2180
	test	al, SD_CTL_STREAM_RESET
2181
	test	al, SD_CTL_STREAM_RESET
2181
	jnz	@f
2182
	jnz	@f
2182
	dec	ecx
2183
	dec	ecx
2183
	jnz	.l2
2184
	jnz	.l2
2184
@@:
2185
@@:
2185
	; reset first position - may not be synced with hw at this time
2186
	; reset first position - may not be synced with hw at this time
2186
	mov	edx, [ctrl.posbuf]
2187
	mov	edx, [ctrl.posbuf]
2187
	mov	dword [edx], 0
2188
	mov	dword [edx], 0
2188
	pop	edx ecx ebx eax
2189
	pop	edx ecx ebx eax
2189
	ret
2190
	ret
2190
endp
2191
endp
2191
 
2192
 
2192
 
2193
 
2193
; set up the SD for streaming
2194
; set up the SD for streaming
2194
proc azx_setup_controller
2195
proc azx_setup_controller
2195
	push	eax ebx ecx edx
2196
	push	eax ebx ecx edx
2196
	; make sure the run bit is zero for SD
2197
	; make sure the run bit is zero for SD
2197
	call	azx_stream_clear
2198
	call	azx_stream_clear
2198
 
2199
 
2199
	; program the stream_tag
2200
	; program the stream_tag
2200
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2201
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2201
	call	azx_readl
2202
	call	azx_readl
2202
	mov	ecx, SD_CTL_STREAM_TAG_MASK
2203
	mov	ecx, SD_CTL_STREAM_TAG_MASK
2203
	xor	ecx, -1
2204
	xor	ecx, -1
2204
	and	eax, ecx
2205
	and	eax, ecx
2205
	mov	ecx, SDO_TAG
2206
	mov	ecx, SDO_TAG
2206
	shl	ecx, SD_CTL_STREAM_TAG_SHIFT
2207
	shl	ecx, SD_CTL_STREAM_TAG_SHIFT
2207
	or	eax, ecx
2208
	or	eax, ecx
2208
	; Asper stream_tag = SDO_TAG
2209
	; Asper stream_tag = SDO_TAG
2209
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2210
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2210
	call	azx_writel
2211
	call	azx_writel
2211
 
2212
 
2212
	; program the length of samples in cyclic buffer
2213
	; program the length of samples in cyclic buffer
2213
	mov	eax, 0x4000*32
2214
	mov	eax, 0x4000*32
2214
	mov	edx, ICH6_REG_SD_CBL + SDO_OFS
2215
	mov	edx, ICH6_REG_SD_CBL + SDO_OFS
2215
	call	azx_writel
2216
	call	azx_writel
2216
 
2217
 
2217
	; program the stream format
2218
	; program the stream format
2218
	; this value needs to be the same as the one programmed
2219
	; this value needs to be the same as the one programmed
2219
	mov	ax, 0x11
2220
	mov	ax, 0x11
2220
	mov	edx, ICH6_REG_SD_FORMAT + SDO_OFS
2221
	mov	edx, ICH6_REG_SD_FORMAT + SDO_OFS
2221
	call	azx_writew
2222
	call	azx_writew
2222
 
2223
 
2223
	; program the stream LVI (last valid index) of the BDL
2224
	; program the stream LVI (last valid index) of the BDL
2224
	mov	eax, 32-1 ;4-1 ;2-1
2225
	mov	eax, 32-1 ;4-1 ;2-1
2225
	mov	[ctrl.lvi_reg], eax
2226
	mov	[ctrl.lvi_reg], eax
2226
	mov	edx, ICH6_REG_SD_LVI + SDO_OFS
2227
	mov	edx, ICH6_REG_SD_LVI + SDO_OFS
2227
	call	azx_writew
2228
	call	azx_writew
2228
 
2229
 
2229
	; program the BDL address
2230
	; program the BDL address
2230
	; lower BDL address
2231
	; lower BDL address
2231
	mov	eax, [pcmout_bdl]
2232
	mov	eax, [pcmout_bdl]
2232
	mov	ebx, eax
2233
	mov	ebx, eax
2233
	invoke	GetPgAddr
2234
	invoke	GetPgAddr
2234
	and	ebx, 0xFFF
2235
	and	ebx, 0xFFF
2235
	add	eax, ebx
2236
	add	eax, ebx
2236
	mov	edx, ICH6_REG_SD_BDLPL + SDO_OFS
2237
	mov	edx, ICH6_REG_SD_BDLPL + SDO_OFS
2237
	call	azx_writel
2238
	call	azx_writel
2238
	; upper BDL address
2239
	; upper BDL address
2239
	xor	eax, eax       ;upper_32bit(azx_dev->bdl_addr)
2240
	xor	eax, eax       ;upper_32bit(azx_dev->bdl_addr)
2240
	mov	edx, ICH6_REG_SD_BDLPU + SDO_OFS
2241
	mov	edx, ICH6_REG_SD_BDLPU + SDO_OFS
2241
	call	azx_writel
2242
	call	azx_writel
2242
 
2243
 
2243
	; enable the position buffer
2244
	; enable the position buffer
2244
	cmp	[ctrl.position_fix], POS_FIX_LPIB
2245
	cmp	[ctrl.position_fix], POS_FIX_LPIB
2245
	jz	@f
2246
	jz	@f
2246
	mov	edx, ICH6_REG_DPLBASE
2247
	mov	edx, ICH6_REG_DPLBASE
2247
	call	azx_readl
2248
	call	azx_readl
2248
	and	eax, ICH6_DPLBASE_ENABLE
2249
	and	eax, ICH6_DPLBASE_ENABLE
2249
	jnz	@f
2250
	jnz	@f
2250
	mov	eax, dword [ctrl.posbuf]
2251
	mov	eax, dword [ctrl.posbuf]
2251
	mov	ebx, eax
2252
	mov	ebx, eax
2252
	invoke	GetPgAddr
2253
	invoke	GetPgAddr
2253
	and	ebx, 0xFFF
2254
	and	ebx, 0xFFF
2254
	add	eax, ebx
2255
	add	eax, ebx
2255
	or	eax, ICH6_DPLBASE_ENABLE
2256
	or	eax, ICH6_DPLBASE_ENABLE
2256
	mov	edx, ICH6_REG_DPLBASE
2257
	mov	edx, ICH6_REG_DPLBASE
2257
	call	azx_writel
2258
	call	azx_writel
2258
@@:
2259
@@:
2259
	; set the interrupt enable bits in the descriptor control register
2260
	; set the interrupt enable bits in the descriptor control register
2260
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2261
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2261
	call	azx_readl
2262
	call	azx_readl
2262
	or	eax, SD_INT_MASK
2263
	or	eax, SD_INT_MASK
2263
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2264
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2264
	call	azx_writel
2265
	call	azx_writel
2265
 
2266
 
2266
	pop	edx ecx ebx eax
2267
	pop	edx ecx ebx eax
2267
	ret
2268
	ret
2268
endp
2269
endp
2269
 
2270
 
2270
 
2271
 
2271
;(...)
2272
;(...)
2272
 
2273
 
2273
; Probe the given codec address
2274
; Probe the given codec address
2274
proc probe_codec, addr:dword
2275
proc probe_codec, addr:dword
2275
	push	edx
2276
	push	edx
2276
	mov	eax, [addr]
2277
	mov	eax, [addr]
2277
	shl	eax, 28
2278
	shl	eax, 28
2278
	mov	edx, (AC_NODE_ROOT shl 20) or (AC_VERB_PARAMETERS shl 8) or AC_PAR_VENDOR_ID
2279
	mov	edx, (AC_NODE_ROOT shl 20) or (AC_VERB_PARAMETERS shl 8) or AC_PAR_VENDOR_ID
2279
	or	eax, edx
2280
	or	eax, edx
2280
	stdcall azx_send_cmd, eax
2281
	stdcall azx_send_cmd, eax
2281
	stdcall azx_get_response
2282
	stdcall azx_get_response
2282
 
2283
 
2283
	cmp	eax, -1
2284
	cmp	eax, -1
2284
	je	.out
2285
	je	.out
2285
	mov	eax, [addr]
2286
	mov	eax, [addr]
2286
	mov	[codec.addr], eax ;Asper+
2287
	mov	[codec.addr], eax ;Asper+
2287
if DEBUG
2288
if DEBUG
2288
	push	esi
2289
	push	esi
2289
	mov	esi, msgCodecOK
2290
	mov	esi, msgCodecOK
2290
	invoke	SysMsgBoardStr
2291
	invoke	SysMsgBoardStr
2291
	mov	esi, msgCAd
2292
	mov	esi, msgCAd
2292
	invoke	SysMsgBoardStr
2293
	invoke	SysMsgBoardStr
2293
	stdcall fdword2str, 3
2294
	stdcall fdword2str, 3
2294
	invoke	SysMsgBoardStr
2295
	invoke	SysMsgBoardStr
2295
	pop	esi
2296
	pop	esi
2296
end if
2297
end if
2297
	xor	eax, eax
2298
	xor	eax, eax
2298
.out:
2299
.out:
2299
	pop	edx
2300
	pop	edx
2300
	ret
2301
	ret
2301
endp
2302
endp
2302
 
2303
 
2303
 
2304
 
2304
proc  azx_bus_reset
2305
proc  azx_bus_reset
2305
	call	azx_stop_chip
2306
	call	azx_stop_chip
2306
	call	azx_init_chip
2307
	call	azx_init_chip
2307
	ret
2308
	ret
2308
endp
2309
endp
2309
 
2310
 
2310
 
2311
 
2311
; Codec initialization
2312
; Codec initialization
2312
proc azx_codec_create
2313
proc azx_codec_create
2313
	push	ebx  ecx  edx
2314
	push	ebx  ecx  edx
2314
	;(...)
2315
	;(...)
2315
	; First try to probe all given codec slots
2316
	; First try to probe all given codec slots
2316
	; Asper: We asume for now that max slots for codecs = 4
2317
	; Asper: We asume for now that max slots for codecs = 4
2317
	xor	ecx, ecx
2318
	xor	ecx, ecx
2318
	xor	edx, edx
2319
	xor	edx, edx
2319
	inc	edx
2320
	inc	edx
2320
.next_slot:
2321
.next_slot:
2321
	test	edx, [ctrl.codec_mask]
2322
	test	edx, [ctrl.codec_mask]
2322
	jz	@f
2323
	jz	@f
2323
	stdcall probe_codec, ecx
2324
	stdcall probe_codec, ecx
2324
	test	eax, eax
2325
	test	eax, eax
2325
	jz	.init ;@f
2326
	jz	.init ;@f
2326
	; Some BIOSen give you wrong codec addresses that don't exist
2327
	; Some BIOSen give you wrong codec addresses that don't exist
2327
if DEBUG
2328
if DEBUG
2328
	mov	esi, msgCodecError
2329
	mov	esi, msgCodecError
2329
	invoke	SysMsgBoardStr
2330
	invoke	SysMsgBoardStr
2330
end if
2331
end if
2331
	mov	ebx, edx
2332
	mov	ebx, edx
2332
	xor	ebx, -1
2333
	xor	ebx, -1
2333
	and	[ctrl.codec_mask], ebx
2334
	and	[ctrl.codec_mask], ebx
2334
 
2335
 
2335
	; More badly, accessing to a non-existing
2336
	; More badly, accessing to a non-existing
2336
	; codec often screws up the controller chip,
2337
	; codec often screws up the controller chip,
2337
	; and disturbs the further communications.
2338
	; and disturbs the further communications.
2338
	; Thus if an error occurs during probing,
2339
	; Thus if an error occurs during probing,
2339
	; better to reset the controller chip to
2340
	; better to reset the controller chip to
2340
	; get back to the sanity state.
2341
	; get back to the sanity state.
2341
	;call    azx_bus_reset
2342
	;call    azx_bus_reset
2342
@@:
2343
@@:
2343
	shl	edx, 1
2344
	shl	edx, 1
2344
	inc	ecx
2345
	inc	ecx
2345
;if USE_FIRST_CODEC
2346
;if USE_FIRST_CODEC
2346
;        cmp     ecx, 1
2347
;        cmp     ecx, 1
2347
;else
2348
;else
2348
	cmp	ecx, 4
2349
	cmp	ecx, 4
2349
;end if
2350
;end if
2350
	jl	.next_slot
2351
	jl	.next_slot
2351
	mov	eax, -1
2352
	mov	eax, -1
2352
	jmp	.out
2353
	jmp	.out
2353
.init:
2354
.init:
2354
	push	ecx edx
2355
	push	ecx edx
2355
	stdcall snd_hda_codec_init
2356
	stdcall snd_hda_codec_init
2356
	pop	edx ecx
2357
	pop	edx ecx
2357
	test	eax, eax
2358
	test	eax, eax
2358
	jnz	@b
2359
	jnz	@b
2359
.out:
2360
.out:
2360
	pop	edx  ecx  ebx
2361
	pop	edx  ecx  ebx
2361
	ret
2362
	ret
2362
endp
2363
endp
2363
 
2364
 
2364
 
2365
 
2365
proc azx_codec_configure
2366
proc azx_codec_configure
2366
	;(...)
2367
	;(...)
2367
	call	snd_hda_codec_configure
2368
	call	snd_hda_codec_configure
2368
	ret
2369
	ret
2369
endp
2370
endp
2370
 
2371
 
2371
 
2372
 
2372
proc azx_get_position
2373
proc azx_get_position
2373
	test	[ctrl.position_fix], POS_FIX_LPIB
2374
	test	[ctrl.position_fix], POS_FIX_LPIB
2374
	jz	@f
2375
	jz	@f
2375
	; read LPIB
2376
	; read LPIB
2376
	mov	edx, ICH6_REG_SD_LPIB + SDO_OFS
2377
	mov	edx, ICH6_REG_SD_LPIB + SDO_OFS
2377
	call	azx_readl
2378
	call	azx_readl
2378
	jmp	.out
2379
	jmp	.out
2379
@@:
2380
@@:
2380
	test	[ctrl.position_fix], POS_FIX_VIACOMBO
2381
	test	[ctrl.position_fix], POS_FIX_VIACOMBO
2381
	jz	@f
2382
	jz	@f
2382
;        call    azx_get_via_position
2383
;        call    azx_get_via_position
2383
;        jmp     .out
2384
;        jmp     .out
2384
@@:
2385
@@:
2385
	; use the position buffer
2386
	; use the position buffer
2386
	push	edx
2387
	push	edx
2387
	mov	edx, dword [ctrl.posbuf]
2388
	mov	edx, dword [ctrl.posbuf]
2388
	mov	eax, dword [edx]
2389
	mov	eax, dword [edx]
2389
	pop	edx
2390
	pop	edx
2390
.out:
2391
.out:
2391
	cmp	eax, 0x4000 ; bufsize
2392
	cmp	eax, 0x4000 ; bufsize
2392
	jl	@f
2393
	jl	@f
2393
	xor	eax, eax
2394
	xor	eax, eax
2394
@@:
2395
@@:
2395
	ret
2396
	ret
2396
endp
2397
endp
2397
 
2398
 
2398
 
2399
 
2399
proc azx_stop_chip
2400
proc azx_stop_chip
2400
	push	eax edx
2401
	push	eax edx
2401
 
2402
 
2402
	; disable interrupts
2403
	; disable interrupts
2403
	call	azx_int_disable
2404
	call	azx_int_disable
2404
	call	azx_int_clear
2405
	call	azx_int_clear
2405
 
2406
 
2406
	; disable CORB/RIRB
2407
	; disable CORB/RIRB
2407
	call	azx_free_cmd_io
2408
	call	azx_free_cmd_io
2408
 
2409
 
2409
	; disable position buffer
2410
	; disable position buffer
2410
	xor	eax, eax
2411
	xor	eax, eax
2411
	mov	edx, ICH6_REG_DPLBASE
2412
	mov	edx, ICH6_REG_DPLBASE
2412
	call	azx_writel
2413
	call	azx_writel
2413
	mov	edx, ICH6_REG_DPUBASE
2414
	mov	edx, ICH6_REG_DPUBASE
2414
	call	azx_writel
2415
	call	azx_writel
2415
	pop	edx eax
2416
	pop	edx eax
2416
	ret
2417
	ret
2417
endp
2418
endp
2418
 
2419
 
2419
 
2420
 
2420
; in:  eax = volume (-10000 - 0)
2421
; in:  eax = volume (-10000 - 0)
2421
align 4
2422
align 4
2422
set_master_vol:
2423
set_master_vol:
2423
	mov	ecx, 3
2424
	mov	ecx, 3
2424
	call	set_channel_volume
2425
	call	set_channel_volume
2425
	ret
2426
	ret
2426
 
2427
 
2427
 
2428
 
2428
; out:  [pvol] = volume (-10000 - 0)
2429
; out:  [pvol] = volume (-10000 - 0)
2429
align 4
2430
align 4
2430
proc  get_master_vol stdcall, pvol:dword
2431
proc  get_master_vol stdcall, pvol:dword
2431
	xor	ecx, ecx
2432
	xor	ecx, ecx
2432
	call	get_channel_volume
2433
	call	get_channel_volume
2433
	mov	ebx, [pvol]
2434
	mov	ebx, [pvol]
2434
	mov	[ebx], eax
2435
	mov	[ebx], eax
2435
	xor	eax, eax
2436
	xor	eax, eax
2436
	ret
2437
	ret
2437
endp
2438
endp
2438
 
2439
 
2439
 
2440
 
2440
; in:   ecx = channel mask (1 - Left; 2 - Right; 3-Both)
2441
; in:   ecx = channel mask (1 - Left; 2 - Right; 3-Both)
2441
;       eax = volume (-10000 - 0)
2442
;       eax = volume (-10000 - 0)
2442
align 4
2443
align 4
2443
set_channel_volume:
2444
set_channel_volume:
2444
	push	eax ebx ecx edx
2445
	push	eax ebx ecx edx
2445
	mov	ebx, [volume.maxDb]
2446
	mov	ebx, [volume.maxDb]
2446
	neg	eax
2447
	neg	eax
2447
if DEBUG ;-
2448
if DEBUG ;-
2448
	push	eax esi
2449
	push	eax esi
2449
	mov	esi, msgNewVolume
2450
	mov	esi, msgNewVolume
2450
	invoke	SysMsgBoardStr
2451
	invoke	SysMsgBoardStr
2451
	stdcall fdword2str, 2
2452
	stdcall fdword2str, 2
2452
	invoke	SysMsgBoardStr
2453
	invoke	SysMsgBoardStr
2453
 
2454
 
2454
	mov	esi, msgMinVolume
2455
	mov	esi, msgMinVolume
2455
	invoke	SysMsgBoardStr
2456
	invoke	SysMsgBoardStr
2456
	mov	eax, ebx
2457
	mov	eax, ebx
2457
	stdcall fdword2str, 2
2458
	stdcall fdword2str, 2
2458
	invoke	SysMsgBoardStr
2459
	invoke	SysMsgBoardStr
2459
	pop	esi eax
2460
	pop	esi eax
2460
end if
2461
end if
2461
	test	ebx, ebx
2462
	test	ebx, ebx
2462
	jz	.err_out
2463
	jz	.err_out
2463
 
2464
 
2464
	cmp	eax, 0
2465
	cmp	eax, 0
2465
	jg	@f
2466
	jg	@f
2466
	xor	eax, eax
2467
	xor	eax, eax
2467
	jmp	.set
2468
	jmp	.set
2468
@@:
2469
@@:
2469
	cmp	eax, ebx
2470
	cmp	eax, ebx
2470
	jng	.set
2471
	jng	.set
2471
	mov	eax, ebx
2472
	mov	eax, ebx
2472
.set:
2473
.set:
2473
	sub	ebx, eax
2474
	sub	ebx, eax
2474
	mov	eax, ebx
2475
	mov	eax, ebx
2475
	;cdq
2476
	;cdq
2476
	xor	edx, edx
2477
	xor	edx, edx
2477
	push	eax
2478
	push	eax
2478
	movzx	eax, [volume.step_size]
2479
	movzx	eax, [volume.step_size]
2479
	imul	eax, (100/4)
2480
	imul	eax, (100/4)
2480
	mov	ebx, eax
2481
	mov	ebx, eax
2481
	pop	eax
2482
	pop	eax
2482
	xor	edx, edx
2483
	xor	edx, edx
2483
	idiv	ebx
2484
	idiv	ebx
2484
 
2485
 
2485
	mov	edx, [volume.out_amp_node]
2486
	mov	edx, [volume.out_amp_node]
2486
	test	edx, edx
2487
	test	edx, edx
2487
	jz	.out
2488
	jz	.out
2488
	movzx	ebx, [edx+HDA_GNODE.nid]
2489
	movzx	ebx, [edx+HDA_GNODE.nid]
2489
 
2490
 
2490
	test	ecx, 1	 ; Left channel ?
2491
	test	ecx, 1	 ; Left channel ?
2491
	jz	@f
2492
	jz	@f
2492
	stdcall put_volume_mute, ebx, 0, HDA_OUTPUT, 0, eax
2493
	stdcall put_volume_mute, ebx, 0, HDA_OUTPUT, 0, eax
2493
@@:
2494
@@:
2494
	test	ecx, 2	 ; Right channel ?
2495
	test	ecx, 2	 ; Right channel ?
2495
	jz	.out
2496
	jz	.out
2496
	stdcall put_volume_mute, ebx, 1, HDA_OUTPUT, 0, eax
2497
	stdcall put_volume_mute, ebx, 1, HDA_OUTPUT, 0, eax
2497
.out:
2498
.out:
2498
	pop	edx ecx ebx eax
2499
	pop	edx ecx ebx eax
2499
	ret
2500
	ret
2500
.err_out:
2501
.err_out:
2501
if DEBUG  ;-
2502
if DEBUG  ;-
2502
	push	esi
2503
	push	esi
2503
	mov	esi, emsgNoVolCtrl
2504
	mov	esi, emsgNoVolCtrl
2504
	invoke	SysMsgBoardStr
2505
	invoke	SysMsgBoardStr
2505
	pop	esi
2506
	pop	esi
2506
end if
2507
end if
2507
	jmp	.out
2508
	jmp	.out
2508
 
2509
 
2509
; in:   ecx = channel (1 - Left; 2 - Right)
2510
; in:   ecx = channel (1 - Left; 2 - Right)
2510
; out:  eax = volume (-10000 - 0)
2511
; out:  eax = volume (-10000 - 0)
2511
align 4
2512
align 4
2512
get_channel_volume:
2513
get_channel_volume:
2513
	push	ebx ecx edx
2514
	push	ebx ecx edx
2514
	cmp	ecx, 2
2515
	cmp	ecx, 2
2515
	jg	.out
2516
	jg	.out
2516
	dec	cl
2517
	dec	cl
2517
	xor	eax, eax
2518
	xor	eax, eax
2518
	mov	edx, [volume.out_amp_node]
2519
	mov	edx, [volume.out_amp_node]
2519
	test	edx, edx
2520
	test	edx, edx
2520
	jz	.out
2521
	jz	.out
2521
	movzx	ebx, [edx+HDA_GNODE.nid]
2522
	movzx	ebx, [edx+HDA_GNODE.nid]
2522
	stdcall get_volume_mute, ebx, ecx, HDA_OUTPUT, 0
2523
	stdcall get_volume_mute, ebx, ecx, HDA_OUTPUT, 0
2523
	and	eax, 0x7F ;get gain
2524
	and	eax, 0x7F ;get gain
2524
	mov	cl, [volume.step_size]
2525
	mov	cl, [volume.step_size]
2525
	mul	cl
2526
	mul	cl
2526
	imul	eax, (-100/4)
2527
	imul	eax, (-100/4)
2527
.out:
2528
.out:
2528
	pop	edx ecx ebx
2529
	pop	edx ecx ebx
2529
	ret
2530
	ret
2530
 
2531
 
2531
 
2532
 
2532
; in:  ecx = delay
2533
; in:  ecx = delay
2533
udelay:
2534
udelay:
2534
	push	eax ecx edx
2535
	push	eax ecx edx
2535
	test	ecx, ecx
2536
	test	ecx, ecx
2536
	jnz	@f
2537
	jnz	@f
2537
	inc	ecx
2538
	inc	ecx
2538
@@:
2539
@@:
2539
	mov	eax, ecx
2540
	mov	eax, ecx
2540
	mov	cx, 500
2541
	mov	cx, 500
2541
	mul	cl
2542
	mul	cl
2542
	mov	ecx, edx
2543
	mov	ecx, edx
2543
	shl	ecx, 16
2544
	shl	ecx, 16
2544
	or	ecx, eax
2545
	or	ecx, eax
2545
@@:
2546
@@:
2546
	xor	eax, eax
2547
	xor	eax, eax
2547
	cpuid
2548
	cpuid
2548
	dec	ecx
2549
	dec	ecx
2549
	jz	@b
2550
	jz	@b
2550
	pop	edx ecx eax
2551
	pop	edx ecx eax
2551
	ret
2552
	ret
2552
 
2553
 
2553
align 4
2554
align 4
2554
proc StallExec
2555
proc StallExec
2555
	push	ecx edx ebx eax
2556
	push	ecx edx ebx eax
2556
 
2557
 
2557
	mov	ecx, CPU_FREQ
2558
	mov	ecx, CPU_FREQ
2558
	mul	ecx
2559
	mul	ecx
2559
	mov	ebx, eax       ;low
2560
	mov	ebx, eax       ;low
2560
	mov	ecx, edx       ;high
2561
	mov	ecx, edx       ;high
2561
	rdtsc
2562
	rdtsc
2562
	add	ebx, eax
2563
	add	ebx, eax
2563
	adc	ecx,edx
2564
	adc	ecx,edx
2564
@@:
2565
@@:
2565
	rdtsc
2566
	rdtsc
2566
	sub	eax, ebx
2567
	sub	eax, ebx
2567
	sbb	edx, ecx
2568
	sbb	edx, ecx
2568
	js	@B
2569
	js	@B
2569
 
2570
 
2570
	pop	eax ebx edx ecx
2571
	pop	eax ebx edx ecx
2571
	ret
2572
	ret
2572
endp
2573
endp
2573
 
2574
 
2574
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2575
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2575
;         MEMORY MAPPED IO    (os depended) ;
2576
;         MEMORY MAPPED IO    (os depended) ;
2576
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2577
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2577
 
2578
 
2578
align 4
2579
align 4
2579
proc azx_readb
2580
proc azx_readb
2580
	add	edx, [ctrl.ctrl_mem_base]
2581
	add	edx, [ctrl.ctrl_mem_base]
2581
	mov	al, [edx]
2582
	mov	al, [edx]
2582
	ret
2583
	ret
2583
endp
2584
endp
2584
 
2585
 
2585
align 4
2586
align 4
2586
proc azx_readw
2587
proc azx_readw
2587
	add	edx, [ctrl.ctrl_mem_base]
2588
	add	edx, [ctrl.ctrl_mem_base]
2588
	mov	ax, [edx]
2589
	mov	ax, [edx]
2589
	ret
2590
	ret
2590
endp
2591
endp
2591
 
2592
 
2592
align 4
2593
align 4
2593
proc azx_readl
2594
proc azx_readl
2594
	add	edx, [ctrl.ctrl_mem_base]
2595
	add	edx, [ctrl.ctrl_mem_base]
2595
	mov	eax, [edx]
2596
	mov	eax, [edx]
2596
	ret
2597
	ret
2597
endp
2598
endp
2598
 
2599
 
2599
align 4
2600
align 4
2600
proc azx_writeb
2601
proc azx_writeb
2601
	add	edx, [ctrl.ctrl_mem_base]
2602
	add	edx, [ctrl.ctrl_mem_base]
2602
	mov	[edx], al
2603
	mov	[edx], al
2603
	ret
2604
	ret
2604
endp
2605
endp
2605
 
2606
 
2606
align 4
2607
align 4
2607
proc azx_writew
2608
proc azx_writew
2608
	add	edx, [ctrl.ctrl_mem_base]
2609
	add	edx, [ctrl.ctrl_mem_base]
2609
	mov	[edx], ax
2610
	mov	[edx], ax
2610
	ret
2611
	ret
2611
endp
2612
endp
2612
 
2613
 
2613
align 4
2614
align 4
2614
proc azx_writel
2615
proc azx_writel
2615
	add	edx, [ctrl.ctrl_mem_base]
2616
	add	edx, [ctrl.ctrl_mem_base]
2616
	mov	[edx], eax
2617
	mov	[edx], eax
2617
	ret
2618
	ret
2618
endp
2619
endp
2619
 
2620
 
2620
;_______
2621
;_______
2621
 
2622
 
2622
proc  snd_hda_automute stdcall, data:dword
2623
proc  snd_hda_automute stdcall, data:dword
2623
	push	eax ebx ecx edx esi
2624
	push	eax ebx ecx edx esi
2624
	mov	esi, [spec.out_pin_node+4]
2625
	mov	esi, [spec.out_pin_node+4]
2625
	mov	ecx, [spec.out_pin_node]
2626
	mov	ecx, [spec.out_pin_node]
2626
	test	esi, esi
2627
	test	esi, esi
2627
	jnz	@f
2628
	jnz	@f
2628
	xchg	ecx, esi
2629
	xchg	ecx, esi
2629
	test	esi, esi
2630
	test	esi, esi
2630
	jz	.out
2631
	jz	.out
2631
@@:
2632
@@:
2632
	movzx	edx, word [esi + HDA_GNODE.nid]
2633
	movzx	edx, word [esi + HDA_GNODE.nid]
2633
	stdcall is_jack_detectable, edx
2634
	stdcall is_jack_detectable, edx
2634
	test	eax, eax
2635
	test	eax, eax
2635
	jz	.out
2636
	jz	.out
2636
 
2637
 
2637
	stdcall snd_hda_read_pin_sense, edx, 1
2638
	stdcall snd_hda_read_pin_sense, edx, 1
2638
	test	eax, AC_PINSENSE_PRESENCE
2639
	test	eax, AC_PINSENSE_PRESENCE
2639
	jnz	@f
2640
	jnz	@f
2640
	xchg	ecx, esi
2641
	xchg	ecx, esi
2641
@@:
2642
@@:
2642
	; set PIN-Out enable
2643
	; set PIN-Out enable
2643
	test	esi, esi
2644
	test	esi, esi
2644
	jz	.out
2645
	jz	.out
2645
	xor	edx, edx
2646
	xor	edx, edx
2646
	test	[esi + HDA_GNODE.pin_caps], AC_PINCAP_HP_DRV
2647
	test	[esi + HDA_GNODE.pin_caps], AC_PINCAP_HP_DRV
2647
	jz	@f
2648
	jz	@f
2648
	mov	edx, AC_PINCTL_HP_EN
2649
	mov	edx, AC_PINCTL_HP_EN
2649
@@:
2650
@@:
2650
	or	edx, AC_PINCTL_OUT_EN
2651
	or	edx, AC_PINCTL_OUT_EN
2651
	movzx	eax, [esi + HDA_GNODE.nid]
2652
	movzx	eax, [esi + HDA_GNODE.nid]
2652
	stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, edx
2653
	stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, edx
2653
 
2654
 
2654
	; set PIN-Out disable
2655
	; set PIN-Out disable
2655
	test	ecx, ecx
2656
	test	ecx, ecx
2656
	jz	.out
2657
	jz	.out
2657
	xor	edx, edx
2658
	xor	edx, edx
2658
	movzx	eax, [ecx + HDA_GNODE.nid]
2659
	movzx	eax, [ecx + HDA_GNODE.nid]
2659
	stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, edx
2660
	stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, edx
2660
.out:
2661
.out:
2661
	pop	esi edx ecx ebx eax
2662
	pop	esi edx ecx ebx eax
2662
	ret
2663
	ret
2663
endp
2664
endp
2664
 
2665
 
2665
 
2666
 
2666
;Asper remember to add this functions:
2667
;Asper remember to add this functions:
2667
proc  snd_hda_queue_unsol_event stdcall, par1:dword, par2:dword
2668
proc  snd_hda_queue_unsol_event stdcall, par1:dword, par2:dword
2668
;if DEBUG
2669
;if DEBUG
2669
;        push    esi
2670
;        push    esi
2670
;        mov     esi, msgUnsolEvent
2671
;        mov     esi, msgUnsolEvent
2671
;        invoke  SysMsgBoardStr
2672
;        invoke  SysMsgBoardStr
2672
;        pop     esi
2673
;        pop     esi
2673
;end if
2674
;end if
2674
if USE_UNSOL_EV = 1
2675
if USE_UNSOL_EV = 1
2675
	;Test. Do not make queue, process immediately!
2676
	;Test. Do not make queue, process immediately!
2676
	;stdcall here snd_hda_read_pin_sense stdcall, nid:dword, trigger_sense:dword
2677
	;stdcall here snd_hda_read_pin_sense stdcall, nid:dword, trigger_sense:dword
2677
	;and then mute/unmute pin based on the results
2678
	;and then mute/unmute pin based on the results
2678
	invoke	TimerHS, 1, 0, snd_hda_automute, 0
2679
	invoke	TimerHS, 1, 0, snd_hda_automute, 0
2679
end if
2680
end if
2680
	ret
2681
	ret
2681
endp
2682
endp
2682
;...
2683
;...
2683
 
2684
 
2684
 
2685
 
2685
align 4
2686
align 4
2686
proc  fdword2str stdcall, flags:dword	; bit 0 - skipLeadZeroes; bit 1 - newLine; other bits undefined
2687
proc  fdword2str stdcall, flags:dword	; bit 0 - skipLeadZeroes; bit 1 - newLine; other bits undefined
2687
	push	eax ebx ecx
2688
	push	eax ebx ecx
2688
	mov	esi, hex_buff
2689
	mov	esi, hex_buff
2689
	mov	ecx, -8
2690
	mov	ecx, -8
2690
	push	eax
2691
	push	eax
2691
@@:
2692
@@:
2692
	rol	eax, 4
2693
	rol	eax, 4
2693
	mov	ebx, eax
2694
	mov	ebx, eax
2694
	and	ebx, 0x0F
2695
	and	ebx, 0x0F
2695
	mov	bl, [ebx+hexletters]
2696
	mov	bl, [ebx+hexletters]
2696
	mov	[8+esi+ecx], bl
2697
	mov	[8+esi+ecx], bl
2697
	inc	ecx
2698
	inc	ecx
2698
	jnz	@b
2699
	jnz	@b
2699
	pop	eax
2700
	pop	eax
2700
 
2701
 
2701
	mov	dword [esi+8], 0
2702
	mov	dword [esi+8], 0
2702
	test	[flags], 0x2 ; new line ?
2703
	test	[flags], 0x2 ; new line ?
2703
	jz	.no_newline
2704
	jz	.no_newline
2704
	mov	dword [esi+8], 0x00000A0D
2705
	mov	dword [esi+8], 0x00000A0D
2705
.no_newline:
2706
.no_newline:
2706
 
2707
 
2707
	push	eax
2708
	push	eax
2708
	test	[flags], 0x1 ; skip zero bits ?
2709
	test	[flags], 0x1 ; skip zero bits ?
2709
	jz	.no_skipz
2710
	jz	.no_skipz
2710
	mov	ecx, 8
2711
	mov	ecx, 8
2711
@@:
2712
@@:
2712
	test	eax, 0xF0000000
2713
	test	eax, 0xF0000000
2713
	jnz	.skipz_done
2714
	jnz	.skipz_done
2714
	rol	eax, 4
2715
	rol	eax, 4
2715
	inc	esi
2716
	inc	esi
2716
	dec	ecx
2717
	dec	ecx
2717
	jnz	@b
2718
	jnz	@b
2718
	dec	esi
2719
	dec	esi
2719
.skipz_done:
2720
.skipz_done:
2720
.no_skipz:
2721
.no_skipz:
2721
	pop	eax
2722
	pop	eax
2722
 
2723
 
2723
	pop	ecx ebx eax
2724
	pop	ecx ebx eax
2724
	ret
2725
	ret
2725
endp
2726
endp
2726
 
2727
 
2727
hexletters   db '0123456789ABCDEF'
2728
hexletters   db '0123456789ABCDEF'
2728
hex_buff     db 8 dup(0),13,10,0,0
2729
hex_buff     db 8 dup(0),13,10,0,0
2729
 
2730
 
2730
 
2731
 
2731
include "CODEC.INC"
2732
include "CODEC.INC"
2732
include "hda_generic.inc"
2733
include "hda_generic.inc"
2733
 
2734
 
2734
align 4
2735
align 4
2735
devices:
2736
devices:
2736
; Intel
2737
; Intel
2737
	dd (CTRL_INTEL_SCH2    shl 16)+VID_INTEL,msg_INTEL_SCH2,	   AZX_DRIVER_SCH
2738
	dd (CTRL_INTEL_SCH2    shl 16)+VID_INTEL,msg_INTEL_SCH2,	   AZX_DRIVER_SCH
2738
	dd (CTRL_INTEL_HPT     shl 16)+VID_INTEL,msg_INTEL_HPT, 	   AZX_DRIVER_SCH
2739
	dd (CTRL_INTEL_HPT     shl 16)+VID_INTEL,msg_INTEL_HPT, 	   AZX_DRIVER_SCH
2739
	dd (CTRL_INTEL_CPT     shl 16)+VID_INTEL,msg_INTEL_CPT, 	   AZX_DRIVER_PCH
2740
	dd (CTRL_INTEL_CPT     shl 16)+VID_INTEL,msg_INTEL_CPT, 	   AZX_DRIVER_PCH
2740
	dd (CTRL_INTEL_PGB     shl 16)+VID_INTEL,msg_INTEL_PGB, 	   AZX_DRIVER_PCH
2741
	dd (CTRL_INTEL_PGB     shl 16)+VID_INTEL,msg_INTEL_PGB, 	   AZX_DRIVER_PCH
2741
	dd (CTRL_INTEL_PPT1    shl 16)+VID_INTEL,msg_INTEL_PPT1,	   AZX_DRIVER_PCH
2742
	dd (CTRL_INTEL_PPT1    shl 16)+VID_INTEL,msg_INTEL_PPT1,	   AZX_DRIVER_PCH
2742
    dd (CTRL_INTEL_ICH6    shl 16)+VID_INTEL,msg_INTEL_ICH6,	   AZX_DRIVER_ICH
2743
    dd (CTRL_INTEL_ICH6    shl 16)+VID_INTEL,msg_INTEL_ICH6,	   AZX_DRIVER_ICH
2743
	dd (CTRL_INTEL_63XXESB shl 16)+VID_INTEL,msg_INTEL_63XXESB,	   AZX_DRIVER_ICH
2744
	dd (CTRL_INTEL_63XXESB shl 16)+VID_INTEL,msg_INTEL_63XXESB,	   AZX_DRIVER_ICH
2744
    dd (CTRL_INTEL_ICH7    shl 16)+VID_INTEL,msg_INTEL_ICH7,	   AZX_DRIVER_ICH
2745
    dd (CTRL_INTEL_ICH7    shl 16)+VID_INTEL,msg_INTEL_ICH7,	   AZX_DRIVER_ICH
2745
    dd (CTRL_INTEL_ICH8    shl 16)+VID_INTEL,msg_INTEL_ICH8,	   AZX_DRIVER_ICH
2746
    dd (CTRL_INTEL_ICH8    shl 16)+VID_INTEL,msg_INTEL_ICH8,	   AZX_DRIVER_ICH
2746
	dd (CTRL_INTEL_82801_UNK1  shl 16)+VID_INTEL,msg_INTEL_82801_UNK1, AZX_DRIVER_ICH
2747
	dd (CTRL_INTEL_82801_UNK1  shl 16)+VID_INTEL,msg_INTEL_82801_UNK1, AZX_DRIVER_ICH
2747
    dd (CTRL_INTEL_ICH9    shl 16)+VID_INTEL,msg_INTEL_ICH9,	   AZX_DRIVER_ICH
2748
    dd (CTRL_INTEL_ICH9    shl 16)+VID_INTEL,msg_INTEL_ICH9,	   AZX_DRIVER_ICH
2748
    dd (CTRL_INTEL_ICH9_2  shl 16)+VID_INTEL,msg_INTEL_ICH9,	   AZX_DRIVER_ICH
2749
    dd (CTRL_INTEL_ICH9_2  shl 16)+VID_INTEL,msg_INTEL_ICH9,	   AZX_DRIVER_ICH
2749
    dd (CTRL_INTEL_ICH10   shl 16)+VID_INTEL,msg_INTEL_ICH10,	   AZX_DRIVER_ICH
2750
    dd (CTRL_INTEL_ICH10   shl 16)+VID_INTEL,msg_INTEL_ICH10,	   AZX_DRIVER_ICH
2750
    dd (CTRL_INTEL_ICH10_2 shl 16)+VID_INTEL,msg_INTEL_ICH10,	   AZX_DRIVER_ICH
2751
    dd (CTRL_INTEL_ICH10_2 shl 16)+VID_INTEL,msg_INTEL_ICH10,	   AZX_DRIVER_ICH
2751
	dd (CTRL_INTEL_PCH     shl 16)+VID_INTEL,msg_INTEL_PCH, 	   AZX_DRIVER_PCH
2752
	dd (CTRL_INTEL_PCH     shl 16)+VID_INTEL,msg_INTEL_PCH, 	   AZX_DRIVER_PCH
2752
	dd (CTRL_INTEL_PCH2    shl 16)+VID_INTEL,msg_INTEL_PCH2,	   AZX_DRIVER_PCH
2753
	dd (CTRL_INTEL_PCH2    shl 16)+VID_INTEL,msg_INTEL_PCH2,	   AZX_DRIVER_PCH
2753
	dd (CTRL_INTEL_SCH     shl 16)+VID_INTEL,msg_INTEL_SCH, 	   AZX_DRIVER_SCH
2754
	dd (CTRL_INTEL_SCH     shl 16)+VID_INTEL,msg_INTEL_SCH, 	   AZX_DRIVER_SCH
2754
	dd (CTRL_INTEL_LPT     shl 16)+VID_INTEL,msg_INTEL_LPT, 	   AZX_DRIVER_PCH
2755
	dd (CTRL_INTEL_LPT     shl 16)+VID_INTEL,msg_INTEL_LPT, 	   AZX_DRIVER_PCH
2755
    dd (CTRL_INTEL_0F04    shl 16)+VID_INTEL,msg_INTEL_BAYTRAIL,   AZX_DRIVER_PCH
2756
    dd (CTRL_INTEL_0F04    shl 16)+VID_INTEL,msg_INTEL_BAYTRAIL,   AZX_DRIVER_PCH
2756
    dd (CTRL_INTEL_2284    shl 16)+VID_INTEL,msg_INTEL_BRASWELL,   AZX_DRIVER_PCH
2757
    dd (CTRL_INTEL_2284    shl 16)+VID_INTEL,msg_INTEL_BRASWELL,   AZX_DRIVER_PCH
2757
    dd (CTRL_INTEL_8ca0    shl 16)+VID_INTEL,msg_INTEL_9SERIES,    AZX_DRIVER_PCH
2758
    dd (CTRL_INTEL_8ca0    shl 16)+VID_INTEL,msg_INTEL_9SERIES,    AZX_DRIVER_PCH
2758
    dd (CTRL_INTEL_8d20    shl 16)+VID_INTEL,msg_INTEL_WELLSBURG,  AZX_DRIVER_PCH
2759
    dd (CTRL_INTEL_8d20    shl 16)+VID_INTEL,msg_INTEL_WELLSBURG,  AZX_DRIVER_PCH
2759
    dd (CTRL_INTEL_8d21    shl 16)+VID_INTEL,msg_INTEL_WELLSBURG,  AZX_DRIVER_PCH
2760
    dd (CTRL_INTEL_8d21    shl 16)+VID_INTEL,msg_INTEL_WELLSBURG,  AZX_DRIVER_PCH
2760
    dd (CTRL_INTEL_A1F0    shl 16)+VID_INTEL,msg_INTEL_LEWISBURG,  AZX_DRIVER_PCH
2761
    dd (CTRL_INTEL_A1F0    shl 16)+VID_INTEL,msg_INTEL_LEWISBURG,  AZX_DRIVER_PCH
2761
    dd (CTRL_INTEL_A270    shl 16)+VID_INTEL,msg_INTEL_LEWISBURG,  AZX_DRIVER_PCH
2762
    dd (CTRL_INTEL_A270    shl 16)+VID_INTEL,msg_INTEL_LEWISBURG,  AZX_DRIVER_PCH
2762
    dd (CTRL_INTEL_9C20    shl 16)+VID_INTEL,msg_INTEL_LYNX_LP,    AZX_DRIVER_PCH
2763
    dd (CTRL_INTEL_9C20    shl 16)+VID_INTEL,msg_INTEL_LYNX_LP,    AZX_DRIVER_PCH
2763
    dd (CTRL_INTEL_9C21    shl 16)+VID_INTEL,msg_INTEL_LYNX_LP,    AZX_DRIVER_PCH
2764
    dd (CTRL_INTEL_9C21    shl 16)+VID_INTEL,msg_INTEL_LYNX_LP,    AZX_DRIVER_PCH
2764
    dd (CTRL_INTEL_9CA0    shl 16)+VID_INTEL,msg_INTEL_WILD_LP,    AZX_DRIVER_PCH
2765
    dd (CTRL_INTEL_9CA0    shl 16)+VID_INTEL,msg_INTEL_WILD_LP,    AZX_DRIVER_PCH
2765
    dd (CTRL_INTEL_A170    shl 16)+VID_INTEL,msg_INTEL_SUNRISE,    AZX_DRIVER_PCH
2766
    dd (CTRL_INTEL_A170    shl 16)+VID_INTEL,msg_INTEL_SUNRISE,    AZX_DRIVER_PCH
2766
    dd (CTRL_INTEL_9D70    shl 16)+VID_INTEL,msg_INTEL_SUN_LP,	   AZX_DRIVER_PCH
2767
    dd (CTRL_INTEL_9D70    shl 16)+VID_INTEL,msg_INTEL_SUN_LP,	   AZX_DRIVER_PCH
2767
    dd (CTRL_INTEL_5A98    shl 16)+VID_INTEL,msg_INTEL_BROXTON,    AZX_DRIVER_PCH
2768
    dd (CTRL_INTEL_5A98    shl 16)+VID_INTEL,msg_INTEL_BROXTON,    AZX_DRIVER_PCH
2768
 
2769
 
2769
; Nvidia
2770
; Nvidia
2770
	dd (CTRL_NVIDIA_MCP51	 shl 16)+VID_NVIDIA,msg_NVIDIA_MCP51,	   AZX_DRIVER_NVIDIA
2771
	dd (CTRL_NVIDIA_MCP51	 shl 16)+VID_NVIDIA,msg_NVIDIA_MCP51,	   AZX_DRIVER_NVIDIA
2771
	dd (CTRL_NVIDIA_MCP55	 shl 16)+VID_NVIDIA,msg_NVIDIA_MCP55,	   AZX_DRIVER_NVIDIA
2772
	dd (CTRL_NVIDIA_MCP55	 shl 16)+VID_NVIDIA,msg_NVIDIA_MCP55,	   AZX_DRIVER_NVIDIA
2772
	dd (CTRL_NVIDIA_MCP61_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP61,	   AZX_DRIVER_NVIDIA
2773
	dd (CTRL_NVIDIA_MCP61_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP61,	   AZX_DRIVER_NVIDIA
2773
	dd (CTRL_NVIDIA_MCP61_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP61,	   AZX_DRIVER_NVIDIA
2774
	dd (CTRL_NVIDIA_MCP61_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP61,	   AZX_DRIVER_NVIDIA
2774
	dd (CTRL_NVIDIA_MCP65_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP65,	   AZX_DRIVER_NVIDIA
2775
	dd (CTRL_NVIDIA_MCP65_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP65,	   AZX_DRIVER_NVIDIA
2775
	dd (CTRL_NVIDIA_MCP65_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP65,	   AZX_DRIVER_NVIDIA
2776
	dd (CTRL_NVIDIA_MCP65_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP65,	   AZX_DRIVER_NVIDIA
2776
	dd (CTRL_NVIDIA_MCP67_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP67,	   AZX_DRIVER_NVIDIA
2777
	dd (CTRL_NVIDIA_MCP67_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP67,	   AZX_DRIVER_NVIDIA
2777
	dd (CTRL_NVIDIA_MCP67_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP67,	   AZX_DRIVER_NVIDIA
2778
	dd (CTRL_NVIDIA_MCP67_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP67,	   AZX_DRIVER_NVIDIA
2778
	dd (CTRL_NVIDIA_MCP73_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP73,	   AZX_DRIVER_NVIDIA
2779
	dd (CTRL_NVIDIA_MCP73_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP73,	   AZX_DRIVER_NVIDIA
2779
	dd (CTRL_NVIDIA_MCP73_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP73,	   AZX_DRIVER_NVIDIA
2780
	dd (CTRL_NVIDIA_MCP73_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP73,	   AZX_DRIVER_NVIDIA
2780
	dd (CTRL_NVIDIA_MCP78_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2781
	dd (CTRL_NVIDIA_MCP78_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2781
	dd (CTRL_NVIDIA_MCP78_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2782
	dd (CTRL_NVIDIA_MCP78_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2782
	dd (CTRL_NVIDIA_MCP78_3  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2783
	dd (CTRL_NVIDIA_MCP78_3  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2783
	dd (CTRL_NVIDIA_MCP78_4  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2784
	dd (CTRL_NVIDIA_MCP78_4  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP78,	   AZX_DRIVER_NVIDIA
2784
	dd (CTRL_NVIDIA_MCP79_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2785
	dd (CTRL_NVIDIA_MCP79_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2785
	dd (CTRL_NVIDIA_MCP79_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2786
	dd (CTRL_NVIDIA_MCP79_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2786
	dd (CTRL_NVIDIA_MCP79_3  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2787
	dd (CTRL_NVIDIA_MCP79_3  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2787
	dd (CTRL_NVIDIA_MCP79_4  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2788
	dd (CTRL_NVIDIA_MCP79_4  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP79,	   AZX_DRIVER_NVIDIA
2788
	dd (CTRL_NVIDIA_0BE2	 shl 16)+VID_NVIDIA,msg_NVIDIA_0BE2,	   AZX_DRIVER_NVIDIA
2789
	dd (CTRL_NVIDIA_0BE2	 shl 16)+VID_NVIDIA,msg_NVIDIA_0BE2,	   AZX_DRIVER_NVIDIA
2789
	dd (CTRL_NVIDIA_0BE3	 shl 16)+VID_NVIDIA,msg_NVIDIA_0BE3,	   AZX_DRIVER_NVIDIA
2790
	dd (CTRL_NVIDIA_0BE3	 shl 16)+VID_NVIDIA,msg_NVIDIA_0BE3,	   AZX_DRIVER_NVIDIA
2790
	dd (CTRL_NVIDIA_0BE4	 shl 16)+VID_NVIDIA,msg_NVIDIA_0BE4,	   AZX_DRIVER_NVIDIA
2791
	dd (CTRL_NVIDIA_0BE4	 shl 16)+VID_NVIDIA,msg_NVIDIA_0BE4,	   AZX_DRIVER_NVIDIA
2791
	dd (CTRL_NVIDIA_GT100	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT100,	   AZX_DRIVER_NVIDIA
2792
	dd (CTRL_NVIDIA_GT100	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT100,	   AZX_DRIVER_NVIDIA
2792
	dd (CTRL_NVIDIA_GT106	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT106,	   AZX_DRIVER_NVIDIA
2793
	dd (CTRL_NVIDIA_GT106	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT106,	   AZX_DRIVER_NVIDIA
2793
	dd (CTRL_NVIDIA_GT108	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT108,	   AZX_DRIVER_NVIDIA
2794
	dd (CTRL_NVIDIA_GT108	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT108,	   AZX_DRIVER_NVIDIA
2794
	dd (CTRL_NVIDIA_GT104	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT104,	   AZX_DRIVER_NVIDIA
2795
	dd (CTRL_NVIDIA_GT104	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT104,	   AZX_DRIVER_NVIDIA
2795
	dd (CTRL_NVIDIA_GT116	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT116,	   AZX_DRIVER_NVIDIA
2796
	dd (CTRL_NVIDIA_GT116	 shl 16)+VID_NVIDIA,msg_NVIDIA_GT116,	   AZX_DRIVER_NVIDIA
2796
	dd (CTRL_NVIDIA_MCP89_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2797
	dd (CTRL_NVIDIA_MCP89_1  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2797
	dd (CTRL_NVIDIA_MCP89_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2798
	dd (CTRL_NVIDIA_MCP89_2  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2798
	dd (CTRL_NVIDIA_MCP89_3  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2799
	dd (CTRL_NVIDIA_MCP89_3  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2799
	dd (CTRL_NVIDIA_MCP89_4  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2800
	dd (CTRL_NVIDIA_MCP89_4  shl 16)+VID_NVIDIA,msg_NVIDIA_MCP89,	   AZX_DRIVER_NVIDIA
2800
	dd (CTRL_NVIDIA_GF119	 shl 16)+VID_NVIDIA,msg_NVIDIA_GF119,	   AZX_DRIVER_NVIDIA
2801
	dd (CTRL_NVIDIA_GF119	 shl 16)+VID_NVIDIA,msg_NVIDIA_GF119,	   AZX_DRIVER_NVIDIA
2801
	dd (CTRL_NVIDIA_GF110_1  shl 16)+VID_NVIDIA,msg_NVIDIA_GF110,	   AZX_DRIVER_NVIDIA
2802
	dd (CTRL_NVIDIA_GF110_1  shl 16)+VID_NVIDIA,msg_NVIDIA_GF110,	   AZX_DRIVER_NVIDIA
2802
	dd (CTRL_NVIDIA_GF110_2  shl 16)+VID_NVIDIA,msg_NVIDIA_GF110,	   AZX_DRIVER_NVIDIA
2803
	dd (CTRL_NVIDIA_GF110_2  shl 16)+VID_NVIDIA,msg_NVIDIA_GF110,	   AZX_DRIVER_NVIDIA
2803
; ATI
2804
; ATI
2804
	dd (CTRL_ATI_SB450  shl 16)+VID_ATI,msg_ATI_SB450,		   AZX_DRIVER_ATI
2805
	dd (CTRL_ATI_SB450  shl 16)+VID_ATI,msg_ATI_SB450,		   AZX_DRIVER_ATI
2805
	dd (CTRL_ATI_SB600  shl 16)+VID_ATI,msg_ATI_SB600,		   AZX_DRIVER_ATI
2806
	dd (CTRL_ATI_SB600  shl 16)+VID_ATI,msg_ATI_SB600,		   AZX_DRIVER_ATI
2806
	dd (CTRL_ATI_RS600  shl 16)+VID_ATI,msg_ATI_RS600,		   AZX_DRIVER_ATIHDMI
2807
	dd (CTRL_ATI_RS600  shl 16)+VID_ATI,msg_ATI_RS600,		   AZX_DRIVER_ATIHDMI
2807
	dd (CTRL_ATI_RS690  shl 16)+VID_ATI,msg_ATI_RS690,		   AZX_DRIVER_ATIHDMI
2808
	dd (CTRL_ATI_RS690  shl 16)+VID_ATI,msg_ATI_RS690,		   AZX_DRIVER_ATIHDMI
2808
	dd (CTRL_ATI_RS780  shl 16)+VID_ATI,msg_ATI_RS780,		   AZX_DRIVER_ATIHDMI
2809
	dd (CTRL_ATI_RS780  shl 16)+VID_ATI,msg_ATI_RS780,		   AZX_DRIVER_ATIHDMI
2809
	dd (CTRL_ATI_RS_UNK1  shl 16)+VID_ATI,msg_ATI_RS_UNK1,		   AZX_DRIVER_ATIHDMI
2810
	dd (CTRL_ATI_RS_UNK1  shl 16)+VID_ATI,msg_ATI_RS_UNK1,		   AZX_DRIVER_ATIHDMI
2810
	dd (CTRL_ATI_R600   shl 16)+VID_ATI,msg_ATI_R600,		   AZX_DRIVER_ATIHDMI
2811
	dd (CTRL_ATI_R600   shl 16)+VID_ATI,msg_ATI_R600,		   AZX_DRIVER_ATIHDMI
2811
	dd (CTRL_ATI_RV610  shl 16)+VID_ATI,msg_ATI_RV610,		   AZX_DRIVER_ATIHDMI
2812
	dd (CTRL_ATI_RV610  shl 16)+VID_ATI,msg_ATI_RV610,		   AZX_DRIVER_ATIHDMI
2812
	dd (CTRL_ATI_RV620  shl 16)+VID_ATI,msg_ATI_RV620,		   AZX_DRIVER_ATIHDMI
2813
	dd (CTRL_ATI_RV620  shl 16)+VID_ATI,msg_ATI_RV620,		   AZX_DRIVER_ATIHDMI
2813
	dd (CTRL_ATI_RV630  shl 16)+VID_ATI,msg_ATI_RV630,		   AZX_DRIVER_ATIHDMI
2814
	dd (CTRL_ATI_RV630  shl 16)+VID_ATI,msg_ATI_RV630,		   AZX_DRIVER_ATIHDMI
2814
	dd (CTRL_ATI_RV635  shl 16)+VID_ATI,msg_ATI_RV635,		   AZX_DRIVER_ATIHDMI
2815
	dd (CTRL_ATI_RV635  shl 16)+VID_ATI,msg_ATI_RV635,		   AZX_DRIVER_ATIHDMI
2815
	dd (CTRL_ATI_RV670  shl 16)+VID_ATI,msg_ATI_RV670,		   AZX_DRIVER_ATIHDMI
2816
	dd (CTRL_ATI_RV670  shl 16)+VID_ATI,msg_ATI_RV670,		   AZX_DRIVER_ATIHDMI
2816
	dd (CTRL_ATI_RV710  shl 16)+VID_ATI,msg_ATI_RV710,		   AZX_DRIVER_ATIHDMI
2817
	dd (CTRL_ATI_RV710  shl 16)+VID_ATI,msg_ATI_RV710,		   AZX_DRIVER_ATIHDMI
2817
	dd (CTRL_ATI_RV730  shl 16)+VID_ATI,msg_ATI_RV730,		   AZX_DRIVER_ATIHDMI
2818
	dd (CTRL_ATI_RV730  shl 16)+VID_ATI,msg_ATI_RV730,		   AZX_DRIVER_ATIHDMI
2818
	dd (CTRL_ATI_RV740  shl 16)+VID_ATI,msg_ATI_RV740,		   AZX_DRIVER_ATIHDMI
2819
	dd (CTRL_ATI_RV740  shl 16)+VID_ATI,msg_ATI_RV740,		   AZX_DRIVER_ATIHDMI
2819
	dd (CTRL_ATI_RV770  shl 16)+VID_ATI,msg_ATI_RV770,		   AZX_DRIVER_ATIHDMI
2820
	dd (CTRL_ATI_RV770  shl 16)+VID_ATI,msg_ATI_RV770,		   AZX_DRIVER_ATIHDMI
2820
; AMD
2821
; AMD
2821
	dd (CTRL_AMD_HUDSON shl 16)+VID_AMD,msg_AMD_HUDSON,		   AZX_DRIVER_GENERIC
2822
	dd (CTRL_AMD_HUDSON shl 16)+VID_AMD,msg_AMD_HUDSON,		   AZX_DRIVER_GENERIC
2822
	dd (CTRL_AMD_RAVEN_RIDGE shl 16)+VID_AMD,msg_AMD_RAVEN_RIDGE,	   AZX_DRIVER_GENERIC
2823
	dd (CTRL_AMD_RAVEN_RIDGE shl 16)+VID_AMD,msg_AMD_RAVEN_RIDGE,	   AZX_DRIVER_GENERIC
-
 
2824
	dd (CTRL_AMD_MATISSE shl 16)+VID_AMD,msg_AMD_MATISSE,	   AZX_DRIVER_GENERIC
2823
; VIA
2825
; VIA
2824
	dd (CTRL_VIA_VT82XX shl 16)+VID_VIA,msg_VIA_VT82XX,		   AZX_DRIVER_VIA
2826
	dd (CTRL_VIA_VT82XX shl 16)+VID_VIA,msg_VIA_VT82XX,		   AZX_DRIVER_VIA
2825
	dd (CTRL_VIA_VT61XX shl 16)+VID_VIA,msg_VIA_VT61XX,		   AZX_DRIVER_GENERIC
2827
	dd (CTRL_VIA_VT61XX shl 16)+VID_VIA,msg_VIA_VT61XX,		   AZX_DRIVER_GENERIC
2826
	dd (CTRL_VIA_VT71XX shl 16)+VID_VIA,msg_VIA_VT71XX,		   AZX_DRIVER_GENERIC
2828
	dd (CTRL_VIA_VT71XX shl 16)+VID_VIA,msg_VIA_VT71XX,		   AZX_DRIVER_GENERIC
2827
; SiS
2829
; SiS
2828
	dd (CTRL_SIS_966    shl 16)+VID_SIS,msg_SIS_966,		   AZX_DRIVER_SIS
2830
	dd (CTRL_SIS_966    shl 16)+VID_SIS,msg_SIS_966,		   AZX_DRIVER_SIS
2829
; ULI
2831
; ULI
2830
	dd (CTRL_ULI_M5461  shl 16)+VID_ULI,msg_ULI_M5461,		   AZX_DRIVER_ULI
2832
	dd (CTRL_ULI_M5461  shl 16)+VID_ULI,msg_ULI_M5461,		   AZX_DRIVER_ULI
2831
; Teradici
2833
; Teradici
2832
	dd (CTRL_TERA_UNK1  shl 16)+VID_ULI,msg_TERA_UNK1,		   AZX_DRIVER_TERA
2834
	dd (CTRL_TERA_UNK1  shl 16)+VID_ULI,msg_TERA_UNK1,		   AZX_DRIVER_TERA
2833
; Creative
2835
; Creative
2834
	dd (CTRL_CREATIVE_CA0110_IBG	 shl 16)+VID_CREATIVE,msg_CREATIVE_CA0110_IBG,	 AZX_DRIVER_CTX
2836
	dd (CTRL_CREATIVE_CA0110_IBG	 shl 16)+VID_CREATIVE,msg_CREATIVE_CA0110_IBG,	 AZX_DRIVER_CTX
2835
	dd (CTRL_CREATIVE_SOUND_CORE3D_1 shl 16)+VID_CREATIVE,msg_CREATIVE_SOUND_CORE3D, AZX_DRIVER_GENERIC
2837
	dd (CTRL_CREATIVE_SOUND_CORE3D_1 shl 16)+VID_CREATIVE,msg_CREATIVE_SOUND_CORE3D, AZX_DRIVER_GENERIC
2836
	dd (CTRL_CREATIVE_SOUND_CORE3D_2 shl 16)+VID_CREATIVE,msg_CREATIVE_SOUND_CORE3D, AZX_DRIVER_GENERIC
2838
	dd (CTRL_CREATIVE_SOUND_CORE3D_2 shl 16)+VID_CREATIVE,msg_CREATIVE_SOUND_CORE3D, AZX_DRIVER_GENERIC
2837
; RDC Semiconductor
2839
; RDC Semiconductor
2838
	dd (CTRL_RDC_R3010  shl 16)+VID_RDC,msg_RDC_R3010,		   AZX_DRIVER_GENERIC
2840
	dd (CTRL_RDC_R3010  shl 16)+VID_RDC,msg_RDC_R3010,		   AZX_DRIVER_GENERIC
2839
; VMware
2841
; VMware
2840
	dd (CTRL_VMWARE_UNK1  shl 16)+VID_VMWARE,msg_VMWARE_UNK1,	   AZX_DRIVER_GENERIC
2842
	dd (CTRL_VMWARE_UNK1  shl 16)+VID_VMWARE,msg_VMWARE_UNK1,	   AZX_DRIVER_GENERIC
2841
 
2843
 
2842
	dd 0	;terminator
2844
	dd 0	;terminator
2843
 
2845
 
2844
 
2846
 
2845
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
2847
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
2846
 
2848
 
2847
msg_Intel		db 'Intel ',0
2849
msg_Intel		db 'Intel ',0
2848
msg_INTEL_CPT		db 'Cougar Point',13,10,0
2850
msg_INTEL_CPT		db 'Cougar Point',13,10,0
2849
msg_INTEL_PGB		db 'Patsburg',13,10,0
2851
msg_INTEL_PGB		db 'Patsburg',13,10,0
2850
msg_INTEL_PPT1		db 'Panther Point',13,10,0
2852
msg_INTEL_PPT1		db 'Panther Point',13,10,0
2851
msg_INTEL_LPT		db 'Lynx Point',13,10,0
2853
msg_INTEL_LPT		db 'Lynx Point',13,10,0
2852
msg_INTEL_HPT		db 'Haswell',13,10,0
2854
msg_INTEL_HPT		db 'Haswell',13,10,0
2853
msg_INTEL_ICH6	    db 'ICH6',13,10,0
2855
msg_INTEL_ICH6	    db 'ICH6',13,10,0
2854
msg_INTEL_63XXESB	db '631x/632xESB',13,10,0
2856
msg_INTEL_63XXESB	db '631x/632xESB',13,10,0
2855
msg_INTEL_ICH7	    db 'ICH7', 13,10,0
2857
msg_INTEL_ICH7	    db 'ICH7', 13,10,0
2856
msg_INTEL_ICH8	    db 'ICH8', 13,10,0
2858
msg_INTEL_ICH8	    db 'ICH8', 13,10,0
2857
msg_INTEL_ICH9	    db 'ICH9', 13,10,0
2859
msg_INTEL_ICH9	    db 'ICH9', 13,10,0
2858
msg_INTEL_ICH10     db 'ICH10',13,10,0
2860
msg_INTEL_ICH10     db 'ICH10',13,10,0
2859
msg_INTEL_PCH		db 'PCH',13,10,0
2861
msg_INTEL_PCH		db 'PCH',13,10,0
2860
msg_INTEL_PCH2		db 'PCH2',13,10,0
2862
msg_INTEL_PCH2		db 'PCH2',13,10,0
2861
msg_INTEL_SCH		db 'Poulsbo',13,10,0
2863
msg_INTEL_SCH		db 'Poulsbo',13,10,0
2862
msg_INTEL_SCH2		db 'Oaktrail',13,10,0
2864
msg_INTEL_SCH2		db 'Oaktrail',13,10,0
2863
msg_INTEL_BAYTRAIL  db 'BayTrail',  13,10,0
2865
msg_INTEL_BAYTRAIL  db 'BayTrail',  13,10,0
2864
msg_INTEL_BRASWELL  db 'Braswell',  13,10,0
2866
msg_INTEL_BRASWELL  db 'Braswell',  13,10,0
2865
msg_INTEL_9SERIES   db '9 Series',  13,10,0
2867
msg_INTEL_9SERIES   db '9 Series',  13,10,0
2866
msg_INTEL_WELLSBURG db 'Wellsburg',  13,10,0
2868
msg_INTEL_WELLSBURG db 'Wellsburg',  13,10,0
2867
msg_INTEL_LEWISBURG db 'Lewisburg',  13,10,0
2869
msg_INTEL_LEWISBURG db 'Lewisburg',  13,10,0
2868
msg_INTEL_LYNX_LP   db 'Lynx Point-LP',13,10,0
2870
msg_INTEL_LYNX_LP   db 'Lynx Point-LP',13,10,0
2869
msg_INTEL_WILD_LP   db 'Wildcat Point-LP',13,10,0
2871
msg_INTEL_WILD_LP   db 'Wildcat Point-LP',13,10,0
2870
msg_INTEL_SUNRISE   db 'Sunrise Point',13,10,0
2872
msg_INTEL_SUNRISE   db 'Sunrise Point',13,10,0
2871
msg_INTEL_SUN_LP    db 'Sunrise Point-LP',13,10,0
2873
msg_INTEL_SUN_LP    db 'Sunrise Point-LP',13,10,0
2872
msg_INTEL_BROXTON   db 'Broxton-P',13,10,0
2874
msg_INTEL_BROXTON   db 'Broxton-P',13,10,0
2873
 
2875
 
2874
msg_INTEL_82801_UNK1	db '82801_UNK1',  13,10,0
2876
msg_INTEL_82801_UNK1	db '82801_UNK1',  13,10,0
2875
 
2877
 
2876
msg_NVidia		db 'NVidia ',0
2878
msg_NVidia		db 'NVidia ',0
2877
msg_NVIDIA_MCP51	db 'MCP51',	 13,10,0
2879
msg_NVIDIA_MCP51	db 'MCP51',	 13,10,0
2878
msg_NVIDIA_MCP55	db 'MCP55',	 13,10,0
2880
msg_NVIDIA_MCP55	db 'MCP55',	 13,10,0
2879
msg_NVIDIA_MCP61	db 'MCP61',	 13,10,0
2881
msg_NVIDIA_MCP61	db 'MCP61',	 13,10,0
2880
msg_NVIDIA_MCP65	db 'MCP65',	 13,10,0
2882
msg_NVIDIA_MCP65	db 'MCP65',	 13,10,0
2881
msg_NVIDIA_MCP67	db 'MCP67',	 13,10,0
2883
msg_NVIDIA_MCP67	db 'MCP67',	 13,10,0
2882
msg_NVIDIA_MCP73	db 'MCP73',	 13,10,0
2884
msg_NVIDIA_MCP73	db 'MCP73',	 13,10,0
2883
msg_NVIDIA_MCP78	db 'MCP78',	 13,10,0
2885
msg_NVIDIA_MCP78	db 'MCP78',	 13,10,0
2884
msg_NVIDIA_MCP79	db 'MCP79',	 13,10,0
2886
msg_NVIDIA_MCP79	db 'MCP79',	 13,10,0
2885
msg_NVIDIA_MCP89	db 'MCP89',	 13,10,0
2887
msg_NVIDIA_MCP89	db 'MCP89',	 13,10,0
2886
msg_NVIDIA_0BE2 	db '(0x0be2)',	 13,10,0
2888
msg_NVIDIA_0BE2 	db '(0x0be2)',	 13,10,0
2887
msg_NVIDIA_0BE3 	db '(0x0be3)',	 13,10,0
2889
msg_NVIDIA_0BE3 	db '(0x0be3)',	 13,10,0
2888
msg_NVIDIA_0BE4 	db '(0x0be4)',	 13,10,0
2890
msg_NVIDIA_0BE4 	db '(0x0be4)',	 13,10,0
2889
msg_NVIDIA_GT100	db 'GT100',	 13,10,0
2891
msg_NVIDIA_GT100	db 'GT100',	 13,10,0
2890
msg_NVIDIA_GT104	db 'GT104',	 13,10,0
2892
msg_NVIDIA_GT104	db 'GT104',	 13,10,0
2891
msg_NVIDIA_GT106	db 'GT106',	 13,10,0
2893
msg_NVIDIA_GT106	db 'GT106',	 13,10,0
2892
msg_NVIDIA_GT108	db 'GT108',	 13,10,0
2894
msg_NVIDIA_GT108	db 'GT108',	 13,10,0
2893
msg_NVIDIA_GT116	db 'GT116',	 13,10,0
2895
msg_NVIDIA_GT116	db 'GT116',	 13,10,0
2894
msg_NVIDIA_GF119	db 'GF119',	 13,10,0
2896
msg_NVIDIA_GF119	db 'GF119',	 13,10,0
2895
msg_NVIDIA_GF110	db 'GF110',	 13,10,0
2897
msg_NVIDIA_GF110	db 'GF110',	 13,10,0
2896
 
2898
 
2897
msg_ATI 	     db 'ATI ',0
2899
msg_ATI 	     db 'ATI ',0
2898
msg_ATI_SB450	     db 'SB450',      13,10,0
2900
msg_ATI_SB450	     db 'SB450',      13,10,0
2899
msg_ATI_SB600	     db 'SB600',      13,10,0
2901
msg_ATI_SB600	     db 'SB600',      13,10,0
2900
 
2902
 
2901
msg_ATI_HDMI	     db 'ATI HDMI ',0
2903
msg_ATI_HDMI	     db 'ATI HDMI ',0
2902
msg_ATI_RS600	     db 'RS600',      13,10,0
2904
msg_ATI_RS600	     db 'RS600',      13,10,0
2903
msg_ATI_RS690	     db 'RS690',      13,10,0
2905
msg_ATI_RS690	     db 'RS690',      13,10,0
2904
msg_ATI_RS780	     db 'RS780',      13,10,0
2906
msg_ATI_RS780	     db 'RS780',      13,10,0
2905
msg_ATI_RS_UNK1      db 'RS_UNK1',    13,10,0
2907
msg_ATI_RS_UNK1      db 'RS_UNK1',    13,10,0
2906
msg_ATI_R600	     db 'R600',       13,10,0
2908
msg_ATI_R600	     db 'R600',       13,10,0
2907
msg_ATI_RV610	     db 'RV610',      13,10,0
2909
msg_ATI_RV610	     db 'RV610',      13,10,0
2908
msg_ATI_RV620	     db 'RV620',      13,10,0
2910
msg_ATI_RV620	     db 'RV620',      13,10,0
2909
msg_ATI_RV630	     db 'RV630',      13,10,0
2911
msg_ATI_RV630	     db 'RV630',      13,10,0
2910
msg_ATI_RV635	     db 'RV635',      13,10,0
2912
msg_ATI_RV635	     db 'RV635',      13,10,0
2911
msg_ATI_RV670	     db 'RV670',      13,10,0
2913
msg_ATI_RV670	     db 'RV670',      13,10,0
2912
msg_ATI_RV710	     db 'RV710',      13,10,0
2914
msg_ATI_RV710	     db 'RV710',      13,10,0
2913
msg_ATI_RV730	     db 'RV730',      13,10,0
2915
msg_ATI_RV730	     db 'RV730',      13,10,0
2914
msg_ATI_RV740	     db 'RV740',      13,10,0
2916
msg_ATI_RV740	     db 'RV740',      13,10,0
2915
msg_ATI_RV770	     db 'RV770',      13,10,0
2917
msg_ATI_RV770	     db 'RV770',      13,10,0
2916
 
2918
 
2917
msg_AMD 	     db 'AMD ',0
2919
msg_AMD 	     db 'AMD ',0
2918
msg_AMD_HUDSON	     db 'Hudson',     13,10,0
2920
msg_AMD_HUDSON	     db 'Hudson',     13,10,0
2919
msg_AMD_RAVEN_RIDGE  db 'RavenRidge', 13,10,0
2921
msg_AMD_RAVEN_RIDGE  db 'RavenRidge', 13,10,0
-
 
2922
msg_AMD_MATISSE	     db 'Matisse',    13,10,0
2920
 
2923
 
2921
msg_VIA 	     db 'VIA ',0
2924
msg_VIA 	     db 'VIA ',0
2922
msg_VIA_VT82XX	     db 'VT8251/8237A',     13,10,0
2925
msg_VIA_VT82XX	     db 'VT8251/8237A',     13,10,0
2923
msg_VIA_VT61XX	     db 'GFX VT6122/VX11',  13,10,0
2926
msg_VIA_VT61XX	     db 'GFX VT6122/VX11',  13,10,0
2924
msg_VIA_VT71XX	     db 'GFX VT7122/VX900', 13,10,0
2927
msg_VIA_VT71XX	     db 'GFX VT7122/VX900', 13,10,0
2925
 
2928
 
2926
msg_SIS 	     db 'SIS ',0
2929
msg_SIS 	     db 'SIS ',0
2927
msg_SIS_966	     db '966',	    13,10,0
2930
msg_SIS_966	     db '966',	    13,10,0
2928
 
2931
 
2929
msg_ULI 	     db 'ULI ',0
2932
msg_ULI 	     db 'ULI ',0
2930
msg_ULI_M5461	     db 'M5461',      13,10,0
2933
msg_ULI_M5461	     db 'M5461',      13,10,0
2931
 
2934
 
2932
msg_TERA	     db 'Teradici ',0
2935
msg_TERA	     db 'Teradici ',0
2933
msg_TERA_UNK1	     db 'UNK1',      13,10,0
2936
msg_TERA_UNK1	     db 'UNK1',      13,10,0
2934
 
2937
 
2935
msg_CREATIVE		      db 'Creative ',0
2938
msg_CREATIVE		      db 'Creative ',0
2936
msg_CREATIVE_CA0110_IBG       db 'CA0110-IBG',13,10,0 ;SB X-Fi Xtreme Audio
2939
msg_CREATIVE_CA0110_IBG       db 'CA0110-IBG',13,10,0 ;SB X-Fi Xtreme Audio
2937
msg_CREATIVE_SOUND_CORE3D     db 'Sound Core3D'
2940
msg_CREATIVE_SOUND_CORE3D     db 'Sound Core3D'
2938
 
2941
 
2939
msg_RDC 	     db 'RDC ',0
2942
msg_RDC 	     db 'RDC ',0
2940
msg_RDC_R3010	     db 'R3010', 13,10,0
2943
msg_RDC_R3010	     db 'R3010', 13,10,0
2941
 
2944
 
2942
msg_VMWARE	     db 'VMware ',0
2945
msg_VMWARE	     db 'VMware ',0
2943
msg_VMWARE_UNK1      db 'UNK1', 13,10,0
2946
msg_VMWARE_UNK1      db 'UNK1', 13,10,0
2944
 
2947
 
2945
szKernel	     db 'KERNEL',0
2948
szKernel	     db 'KERNEL',0
2946
sz_sound_srv	     db 'SOUND',0
2949
sz_sound_srv	     db 'SOUND',0
2947
 
2950
 
2948
msgInit      db 'detect hardware...',13,10,0
2951
msgInit      db 'detect hardware...',13,10,0
2949
msgFail      db 'device not found',13,10,0
2952
msgFail      db 'device not found',13,10,0
2950
msgAttchIRQ  db 'IRQ line not supported', 13,10,0
2953
msgAttchIRQ  db 'IRQ line not supported', 13,10,0
2951
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10,0
2954
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10,0
2952
msgPlay      db 'start play', 13,10,0
2955
msgPlay      db 'start play', 13,10,0
2953
msgStop      db 'stop play',  13,10,0
2956
msgStop      db 'stop play',  13,10,0
2954
msgSetChannelVolume  db 'Set Channel Volume', 13,10,0
2957
msgSetChannelVolume  db 'Set Channel Volume', 13,10,0
2955
msgIRQ	     db 'HDA IRQ', 13,10,0
2958
msgIRQ	     db 'HDA IRQ', 13,10,0
2956
msgInitCtrl  db 'init controller',13,10,0
2959
msgInitCtrl  db 'init controller',13,10,0
2957
msgPrimBuff  db 'create primary buffer ...',0
2960
msgPrimBuff  db 'create primary buffer ...',0
2958
msgDone      db 'done',13,10,0
2961
msgDone      db 'done',13,10,0
2959
msgRemap     db 'Remap IRQ',13,10,0
2962
msgRemap     db 'Remap IRQ',13,10,0
2960
msgOk	     db 'service installed',13,10,0
2963
msgOk	     db 'service installed',13,10,0
2961
msgCold      db 'cold reset',13,10,0
2964
msgCold      db 'cold reset',13,10,0
2962
    msgHDARFail    db 'controller not ready',13,10,0
2965
    msgHDARFail    db 'controller not ready',13,10,0
2963
msgCFail     db 'codec not ready',13,10,0
2966
msgCFail     db 'codec not ready',13,10,0
2964
msgResetOk   db 'reset complete',13,10,0
2967
msgResetOk   db 'reset complete',13,10,0
2965
msgPciCmd    db 'PCI command     ',0
2968
msgPciCmd    db 'PCI command     ',0
2966
msgPciStat   db 'PCI status      ',0
2969
msgPciStat   db 'PCI status      ',0
2967
    msgHDALowMMIo db 'lower mmio base ',0
2970
    msgHDALowMMIo db 'lower mmio base ',0
2968
    msgHDAUpMMIo  db 'upper mmio base ',0
2971
    msgHDAUpMMIo  db 'upper mmio base ',0
2969
msgIrqMap    db 'HDA irq map as      ',0
2972
msgIrqMap    db 'HDA irq map as      ',0
2970
;msgUnsolEvent db 'Unsolicited event!',13,10,0
2973
;msgUnsolEvent db 'Unsolicited event!',13,10,0
2971
 
2974
 
2972
;Asper [
2975
;Asper [
2973
if DEBUG
2976
if DEBUG
2974
    msgCodecMask	     db 'codec_mask = ',0
2977
    msgCodecMask	     db 'codec_mask = ',0
2975
    msgNoCodecsFound	     db 'no codecs found!',13,10,0
2978
    msgNoCodecsFound	     db 'no codecs found!',13,10,0
2976
    msgHDASnoopDisabled      db 'HDA snoop disabled, enabling ... ',0
2979
    msgHDASnoopDisabled      db 'HDA snoop disabled, enabling ... ',0
2977
    msg_OK		     db 'OK',13,10,0
2980
    msg_OK		     db 'OK',13,10,0
2978
    msg_Fail		     db 'Failed',13,10,0
2981
    msg_Fail		     db 'Failed',13,10,0
2979
    msgSpuriousResponce      db 'spurious responce ',0
2982
    msgSpuriousResponce      db 'spurious responce ',0
2980
    emsgInvalidAFGSubtree    db 'Invalid AFG subtree',13,10,0
2983
    emsgInvalidAFGSubtree    db 'Invalid AFG subtree',13,10,0
2981
    emsgConnListNotAvailable db 'connection list not available for ',0
2984
    emsgConnListNotAvailable db 'connection list not available for ',0
2982
    msgUnmuteOut	     db 'UNMUTE OUT: NID=',0
2985
    msgUnmuteOut	     db 'UNMUTE OUT: NID=',0
2983
    msgUnmuteIn 	     db 'UNMUTE IN: NID=',0
2986
    msgUnmuteIn 	     db 'UNMUTE IN: NID=',0
2984
    msgGetResponceTimeout    db 'get_response timeout: ',0
2987
    msgGetResponceTimeout    db 'get_response timeout: ',0
2985
    msgVal		     db ' val=',0
2988
    msgVal		     db ' val=',0
2986
    emsgBusResetFatalComm    db 'resetting BUS due to fatal communication error',13,10,0
2989
    emsgBusResetFatalComm    db 'resetting BUS due to fatal communication error',13,10,0
2987
    msgCodecOK		     db 'codec probed OK',13,10,0
2990
    msgCodecOK		     db 'codec probed OK',13,10,0
2988
    msgCodecError	     db 'codec probe error disabling it...',13,10,0
2991
    msgCodecError	     db 'codec probe error disabling it...',13,10,0
2989
    emsgNoAFGorMFGFound      db 'no AFG or MFG node found',13,10,0
2992
    emsgNoAFGorMFGFound      db 'no AFG or MFG node found',13,10,0
2990
    msgNoAFGFound	     db 'no AFG node found, trying another codec',13,10,0
2993
    msgNoAFGFound	     db 'no AFG node found, trying another codec',13,10,0
2991
    emsgNoMem		     db 'hda_codec: cannot malloc',13,10,0
2994
    emsgNoMem		     db 'hda_codec: cannot malloc',13,10,0
2992
    msgConnect		     db 'CONNECT: NID=',0
2995
    msgConnect		     db 'CONNECT: NID=',0
2993
    msgIdx		     db ' IDX=',0
2996
    msgIdx		     db ' IDX=',0
2994
    msgSkipDigitalOutNode    db 'Skip Digital OUT node ',0
2997
    msgSkipDigitalOutNode    db 'Skip Digital OUT node ',0
2995
    msgAudOutFound	     db 'AUD_OUT found ',0
2998
    msgAudOutFound	     db 'AUD_OUT found ',0
2996
    emsgNoParserAvailable    db 'No codec parser is available',13,10,0
2999
    emsgNoParserAvailable    db 'No codec parser is available',13,10,0
2997
    emsgNoProperOutputPathFound  db 'hda_generic: no proper output path found',13,10,0
3000
    emsgNoProperOutputPathFound  db 'hda_generic: no proper output path found',13,10,0
2998
    emsgInvConnList	     db 'hda_codec: invalid CONNECT_LIST verb ',0
3001
    emsgInvConnList	     db 'hda_codec: invalid CONNECT_LIST verb ',0
2999
    emsgInvDepRangeVal	     db 'hda_codec: invalid dep_range_val ',0
3002
    emsgInvDepRangeVal	     db 'hda_codec: invalid dep_range_val ',0
3000
    emsgTooManyConns	     db 'Too many connections',13,10,0
3003
    emsgTooManyConns	     db 'Too many connections',13,10,0
3001
	emsgNoVolCtrl	     db 'No volume control',13,10,0
3004
	emsgNoVolCtrl	     db 'No volume control',13,10,0
3002
    msgHDACodecSetupStream   db 'hda_codec_setup_stream: NID=',0
3005
    msgHDACodecSetupStream   db 'hda_codec_setup_stream: NID=',0
3003
    msgStream		     db 'stream=',0
3006
    msgStream		     db 'stream=',0
3004
    msgChannel		     db 'channel=',0
3007
    msgChannel		     db 'channel=',0
3005
    msgFormat		     db 'format=',0
3008
    msgFormat		     db 'format=',0
3006
 
3009
 
3007
    msgPollingCodecOnce      db 'polling the codec once',13,10,0 ;Asper~
3010
    msgPollingCodecOnce      db 'polling the codec once',13,10,0 ;Asper~
3008
    msgSwitchToPollMode      db 'switching to polling mode',13,10,0 ;Asper~
3011
    msgSwitchToPollMode      db 'switching to polling mode',13,10,0 ;Asper~
3009
 
3012
 
3010
    strSemicolon	     db ':',0
3013
    strSemicolon	     db ':',0
3011
    msgSETUP_FG_NODES	     db 'Setup FG nodes = start_nid:total_nodes = ',0
3014
    msgSETUP_FG_NODES	     db 'Setup FG nodes = start_nid:total_nodes = ',0
3012
    msgFG_TYPE		     db 'FG type = ',0
3015
    msgFG_TYPE		     db 'FG type = ',0
3013
    msgPinCfgs		     db 'Pin configurations:',13,10,0
3016
    msgPinCfgs		     db 'Pin configurations:',13,10,0
3014
    msgWCaps		     db 'Widget capabilities:',13,10,0
3017
    msgWCaps		     db 'Widget capabilities:',13,10,0
3015
    msgCAd		     db 'CAd = ',0
3018
    msgCAd		     db 'CAd = ',0
3016
    msgTCSEL		     db 'PCI TCSEL     ',0
3019
    msgTCSEL		     db 'PCI TCSEL     ',0
3017
    msgTV		     db 'HDA test version ',TEST_VERSION_NUMBER,13,10,0
3020
    msgTV		     db 'HDA test version ',TEST_VERSION_NUMBER,13,10,0
3018
    msgGCap		     db 'GCAP = ',0
3021
    msgGCap		     db 'GCAP = ',0
3019
end if
3022
end if
3020
 
3023
 
3021
if USE_SINGLE_MODE
3024
if USE_SINGLE_MODE
3022
    msgSingleMode	     db 'Single mode !',13,10,0
3025
    msgSingleMode	     db 'Single mode !',13,10,0
3023
    msgIRS		     db 'IRS=',0
3026
    msgIRS		     db 'IRS=',0
3024
    msgSendCmdTimeout	     db 'send_cmd timeout: IRS=',0
3027
    msgSendCmdTimeout	     db 'send_cmd timeout: IRS=',0
3025
else
3028
else
3026
    msgNormalMode	     db 'Normal mode !',13,10,0
3029
    msgNormalMode	     db 'Normal mode !',13,10,0
3027
end if
3030
end if
3028
 
3031
 
3029
if DEBUG
3032
if DEBUG
3030
    msgYAHOO2		     db 'YAHOO2: ',0
3033
    msgYAHOO2		     db 'YAHOO2: ',0
3031
    msgMinVolume	     db 'MinVolume: ',0
3034
    msgMinVolume	     db 'MinVolume: ',0
3032
    msgNewVolume	     db 'NewVolume: ',0
3035
    msgNewVolume	     db 'NewVolume: ',0
3033
 
3036
 
3034
    msgVerbQuery	     db 'Q: ',0
3037
    msgVerbQuery	     db 'Q: ',0
3035
    msgVerbAnswer	     db 'A: ',0
3038
    msgVerbAnswer	     db 'A: ',0
3036
    msgPin_Nid		     db 'Pin Nid = ',0
3039
    msgPin_Nid		     db 'Pin Nid = ',0
3037
    msgPin_Ctl		     db 'Pin Control = ',0
3040
    msgPin_Ctl		     db 'Pin Control = ',0
3038
    msgPin_Caps 	     db 'Pin Capabilities = ',0
3041
    msgPin_Caps 	     db 'Pin Capabilities = ',0
3039
    msgDef_Cfg		     db 'Pin def_cfg = ',0
3042
    msgDef_Cfg		     db 'Pin def_cfg = ',0
3040
    msgAmp_Out_Caps	     db 'Pin Amp Out caps = ',0
3043
    msgAmp_Out_Caps	     db 'Pin Amp Out caps = ',0
3041
    msgAmpVal		     db 'Amp val = ',0
3044
    msgAmpVal		     db 'Amp val = ',0
3042
    msgEnableEAPD	     db 'Enable EAPD: NID=',0
3045
    msgEnableEAPD	     db 'Enable EAPD: NID=',0
3043
    msgBeeperNid	     db 'Beeper found: NID=',0
3046
    msgBeeperNid	     db 'Beeper found: NID=',0
3044
    msgBeeperValue	     db 'Beeper initial value: ',0
3047
    msgBeeperValue	     db 'Beeper initial value: ',0
3045
    msgBeepNow		     db 'Beep!',13,10,0
3048
    msgBeepNow		     db 'Beep!',13,10,0
3046
 
3049
 
3047
    msgNodeSeq		     db 'Sequence of codec nodes:',13,10,0
3050
    msgNodeSeq		     db 'Sequence of codec nodes:',13,10,0
3048
    msgNID		     db 'NID: 0x',0
3051
    msgNID		     db 'NID: 0x',0
3049
end if
3052
end if
3050
 
3053
 
3051
;] Asper
3054
;] Asper
3052
 
3055
 
3053
aspinlock	 dd SPINLOCK_FREE
3056
aspinlock	 dd SPINLOCK_FREE
3054
 
3057
 
3055
codec CODEC
3058
codec CODEC
3056
ctrl AC_CNTRL
3059
ctrl AC_CNTRL
3057
 
3060
 
3058
;Asper: BDL must be aligned to 128 according to HDA specification.
3061
;Asper: BDL must be aligned to 128 according to HDA specification.
3059
pcmout_bdl	 rd 1
3062
pcmout_bdl	 rd 1
3060
buff_list	 rd 32
3063
buff_list	 rd 32
3061
 
3064
 
3062
driver_type	 rd 1
3065
driver_type	 rd 1