Subversion Repositories Kolibri OS

Rev

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

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