Subversion Repositories Kolibri OS

Rev

Rev 2015 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
802 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
format MS COFF
9
 
10
DEBUG		equ 1
11
 
12
include 'proc32.inc'
13
include 'imports.inc'
14
 
15
API_VERSION	equ 0x01000100
16
 
17
DEBUG_IRQ	equ 0
18
 
19
USE_COM_IRQ	equ 0	 ;make irq 3 and irq 4 available for PCI devices
20
IRQ_REMAP	equ 0
21
IRQ_LINE	equ 0
22
 
23
 
24
;irq 0,1,2,8,12,13 недоступны
25
;                   FEDCBA9876543210
26
VALID_IRQ	equ 1100111011111000b
27
ATTCH_IRQ	equ 0000111010100000b
28
 
29
if USE_COM_IRQ
30
ATTCH_IRQ	equ 0000111010111000b
31
end if
32
 
33
CPU_FREQ	equ  2600d
34
 
35
BIT0  EQU 0x00000001
36
BIT1  EQU 0x00000002
37
BIT2  EQU 0x00000004
38
BIT3  EQU 0x00000008
39
BIT4  EQU 0x00000010
40
BIT5  EQU 0x00000020
41
BIT6  EQU 0x00000040
42
BIT7  EQU 0x00000080
43
BIT8  EQU 0x00000100
44
BIT9  EQU 0x00000200
45
BIT10 EQU 0x00000400
46
BIT11 EQU 0x00000800
47
BIT12 EQU 0x00001000
48
BIT13 EQU 0x00002000
49
BIT14 EQU 0x00004000
50
BIT15 EQU 0x00008000
51
BIT16 EQU 0x00010000
52
BIT17 EQU 0x00020000
53
BIT18 EQU 0x00040000
54
BIT19 EQU 0x00080000
55
BIT20 EQU 0x00100000
56
BIT21 EQU 0x00200000
57
BIT22 EQU 0x00400000
58
BIT23 EQU 0x00800000
59
BIT24 EQU 0x00100000
60
BIT25 EQU 0x02000000
61
BIT26 EQU 0x04000000
62
BIT27 EQU 0x08000000
63
BIT28 EQU 0x10000000
64
BIT29 EQU 0x20000000
65
BIT30 EQU 0x40000000
66
BIT31 EQU 0x80000000
67
 
68
PCM_4 equ BIT20
69
PCM_6 equ BIT21
70
 
71
VID_INTEL	  equ 0x8086
72
VID_NVIDIA	  equ 0x10DE
73
 
74
CTRL_ICH	  equ 0x2415
75
CTRL_ICH0	  equ 0x2425
76
CTRL_ICH2	  equ 0x2435
77
CTRL_ICH3	  equ 0x2445
78
CTRL_ICH4	  equ 0x24C5
79
CTRL_ICH5	  equ 0x24D5
80
CTRL_ICH6	  equ 0x266E
81
CTRL_ICH7	  equ 0x27DE
82
 
83
CTRL_NFORCE	  equ 0x01B1
84
CTRL_NFORCE2	  equ 0x006A
85
CTRL_NFORCE3	  equ 0x00DA
86
CTRL_MCP04	  equ 0x003A
87
CTRL_CK804	  equ 0x0059
88
CTRL_CK8	  equ 0x008A
89
CTRL_CK8S	  equ 0x00EA
90
CTRL_MCP51	  equ 0x026B
91
 
92
 
93
PCM_OUT_BDL	  equ  0x10  ; PCM out buffer descriptors list
94
PCM_OUT_CR_REG	  equ  0x1b  ; PCM out Control Register
95
PCM_OUT_LVI_REG   equ  0x15  ; PCM last valid index
96
PCM_OUT_SR_REG	  equ  0x16  ; PCM out Status register
97
PCM_OUT_PIV_REG   equ  0x1a
98
PCM_OUT_CIV_REG   equ  0x14  ; PCM out current index
99
 
100
PCM_IN_CR_REG	  equ  0x0b  ; PCM in Control Register
101
MC_IN_CR_REG	  equ  0x2b  ; MIC in Control Register
102
RR		  equ  BIT1  ; reset registers.  Nukes all regs
103
 
104
CODEC_MASTER_VOL_REG	     equ 0x02
105
CODEC_AUX_VOL		     equ 0x04 ;
106
CODEC_PCM_OUT_REG	     equ 0x18 ; PCM output volume
107
CODEC_EXT_AUDIO_REG	     equ 0x28 ; extended audio
108
CODEC_EXT_AUDIO_CTRL_REG     equ 0x2a ; extended audio control
109
CODEC_PCM_FRONT_DACRATE_REG  equ 0x2c ; PCM out sample rate
110
CODEC_PCM_SURND_DACRATE_REG  equ 0x2e ; surround sound sample rate
111
CODEC_PCM_LFE_DACRATE_REG    equ 0x30 ; LFE sample rate
112
 
113
GLOB_CTRL	  equ  0x2C  ;   Global Control
114
CTRL_STAT	  equ  0x30  ;   Global Status
115
CTRL_CAS	  equ  0x34  ;   Codec Access Semiphore
116
 
117
CAS_FLAG	  equ  0x01  ;   Codec Access Semiphore Bit
118
 
119
CTRL_ST_CREADY	  equ  BIT8+BIT9+BIT28 ;   Primary Codec Ready
120
 
121
CTRL_ST_RCS	  equ  0x00008000  ;   Read Completion Status
122
 
123
CTRL_CNT_CRIE	  equ  BIT4+BIT5+BIT6  ;   Codecs Resume Interrupt Enable
124
CTRL_CNT_AC_OFF   equ  0x00000008  ;   ACLINK Off
125
CTRL_CNT_WARM	  equ  0x00000004  ;   AC97 Warm Reset
126
CTRL_CNT_COLD	  equ  0x00000002  ;   AC97 Cold Reset
127
CTRL_CNT_GIE	  equ  0x00000001  ;   GPI Interrupt Enable
128
 
129
CODEC_REG_POWERDOWN   equ 0x26
130
CODEC_REG_ST	      equ 0x26
131
 
132
SRV_GETVERSION	      equ  0
133
DEV_PLAY	      equ  1
134
DEV_STOP	      equ  2
135
DEV_CALLBACK	      equ  3
136
DEV_SET_BUFF	      equ  4
137
DEV_NOTIFY	      equ  5
138
DEV_SET_MASTERVOL     equ  6
139
DEV_GET_MASTERVOL     equ  7
140
DEV_GET_INFO	      equ  8
2010 serge 141
DEV_GET_POS           equ  9
802 serge 142
 
143
struc AC_CNTRL		    ;AC controller base class
144
{ .bus		      dd ?
145
  .devfn	      dd ?
146
 
147
  .vendor	      dd ?
148
  .dev_id	      dd ?
149
  .pci_cmd	      dd ?
150
  .pci_stat	      dd ?
151
 
152
  .codec_io_base      dd ?
153
  .codec_mem_base     dd ?
154
 
155
  .ctrl_io_base       dd ?
156
  .ctrl_mem_base      dd ?
157
  .cfg_reg	      dd ?
158
  .int_line	      dd ?
159
 
160
  .vendor_ids	      dd ?    ;vendor id string
161
  .ctrl_ids	      dd ?    ;hub id string
162
 
163
  .buffer	      dd ?
164
 
165
  .notify_pos	      dd ?
166
  .notify_task	      dd ?
167
 
168
  .lvi_reg	      dd ?
169
  .ctrl_setup	      dd ?
170
  .user_callback      dd ?
171
  .codec_read16       dd ?
172
  .codec_write16      dd ?
173
 
174
  .ctrl_read8	      dd ?
175
  .ctrl_read16	      dd ?
176
  .ctrl_read32	      dd ?
177
 
178
  .ctrl_write8	      dd ?
179
  .ctrl_write16       dd ?
180
  .ctrl_write32       dd ?
181
}
182
 
183
struc CODEC		   ;Audio Chip base class
184
{
185
  .chip_id	      dd ?
186
  .flags	      dd ?
187
  .status	      dd ?
188
 
189
  .ac_vendor_ids      dd ?    ;ac vendor id string
190
  .chip_ids	      dd ?    ;chip model string
191
 
192
  .shadow_flag	      dd ?
193
		      dd ?
194
 
195
  .regs 	      dw ?     ; codec registers
196
  .reg_master_vol     dw ?     ;0x02
197
  .reg_aux_out_vol    dw ?     ;0x04
198
  .reg_mone_vol       dw ?     ;0x06
199
  .reg_master_tone    dw ?     ;0x08
200
  .reg_beep_vol       dw ?     ;0x0A
201
  .reg_phone_vol      dw ?     ;0x0C
202
  .reg_mic_vol	      dw ?     ;0x0E
203
  .reg_line_in_vol    dw ?     ;0x10
204
  .reg_cd_vol	      dw ?     ;0x12
205
  .reg_video_vol      dw ?     ;0x14
206
  .reg_aux_in_vol     dw ?     ;0x16
207
  .reg_pcm_out_vol    dw ?     ;0x18
208
  .reg_rec_select     dw ?     ;0x1A
209
  .reg_rec_gain       dw ?     ;0x1C
210
  .reg_rec_gain_mic   dw ?     ;0x1E
211
  .reg_gen	      dw ?     ;0x20
212
  .reg_3d_ctrl	      dw ?     ;0X22
213
  .reg_page	      dw ?     ;0X24
214
  .reg_powerdown      dw ?     ;0x26
215
  .reg_ext_audio      dw ?     ;0x28
216
  .reg_ext_st	      dw ?     ;0x2a
217
  .reg_pcm_front_rate dw ?     ;0x2c
218
  .reg_pcm_surr_rate  dw ?     ;0x2e
219
  .reg_lfe_rate       dw ?     ;0x30
220
  .reg_pcm_in_rate    dw ?     ;0x32
221
		      dw ?     ;0x34
222
  .reg_cent_lfe_vol   dw ?     ;0x36
223
  .reg_surr_vol       dw ?     ;0x38
224
  .reg_spdif_ctrl     dw ?     ;0x3A
225
		      dw ?     ;0x3C
226
		      dw ?     ;0x3E
227
		      dw ?     ;0x40
228
		      dw ?     ;0x42
229
		      dw ?     ;0x44
230
		      dw ?     ;0x46
231
		      dw ?     ;0x48
232
		      dw ?     ;0x4A
233
		      dw ?     ;0x4C
234
		      dw ?     ;0x4E
235
		      dw ?     ;0x50
236
		      dw ?     ;0x52
237
		      dw ?     ;0x54
238
		      dw ?     ;0x56
239
		      dw ?     ;0x58
240
		      dw ?     ;0x5A
241
		      dw ?     ;0x5C
242
		      dw ?     ;0x5E
243
  .reg_page_0	      dw ?     ;0x60
244
  .reg_page_1	      dw ?     ;0x62
245
  .reg_page_2	      dw ?     ;0x64
246
  .reg_page_3	      dw ?     ;0x66
247
  .reg_page_4	      dw ?     ;0x68
248
  .reg_page_5	      dw ?     ;0x6A
249
  .reg_page_6	      dw ?     ;0x6C
250
  .reg_page_7	      dw ?     ;0x6E
251
		      dw ?     ;0x70
252
		      dw ?     ;0x72
253
		      dw ?     ;0x74
254
		      dw ?     ;0x76
255
		      dw ?     ;0x78
256
		      dw ?     ;0x7A
257
  .reg_vendor_id_1    dw ?     ;0x7C
258
  .reg_vendor_id_2    dw ?     ;0x7E
259
 
260
 
261
  .reset	      dd ?    ;virual
262
  .set_master_vol     dd ?
263
}
264
 
265
struc CTRL_INFO
266
{   .pci_cmd	      dd ?
267
    .irq	      dd ?
268
    .glob_cntrl       dd ?
269
    .glob_sta	      dd ?
270
    .codec_io_base    dd ?
271
    .ctrl_io_base     dd ?
272
    .codec_mem_base   dd ?
273
    .ctrl_mem_base    dd ?
274
    .codec_id	      dd ?
275
}
276
 
277
struc IOCTL
278
{  .handle	      dd ?
279
   .io_code	      dd ?
280
   .input	      dd ?
281
   .inp_size	      dd ?
282
   .output	      dd ?
283
   .out_size	      dd ?
284
}
285
 
286
virtual at 0
287
  IOCTL IOCTL
288
end virtual
289
 
290
EVENT_NOTIFY	equ 0x00000200
291
 
292
public START
293
public service_proc
294
public version
295
 
296
section '.flat' code readable align 16
297
 
298
proc START stdcall, state:dword
299
 
300
	   cmp [state], 1
301
	   jne .stop
302
 
303
     if DEBUG
304
	   mov esi, msgInit
305
	   call SysMsgBoardStr
306
     end if
307
 
308
	   call detect_controller
309
	   test eax, eax
310
	   jz .fail
311
 
312
     if DEBUG
313
	   mov esi,[ctrl.vendor_ids]
314
	   call SysMsgBoardStr
315
	   mov esi, [ctrl.ctrl_ids]
316
	   call SysMsgBoardStr
317
 
318
     end if
319
 
320
	   call init_controller
321
	   test eax, eax
322
	   jz .fail
323
 
324
	   call init_codec
325
	   test eax, eax
326
	   jz .fail
327
 
328
	   call reset_controller
329
	   call setup_codec
330
 
331
	   mov esi, msgPrimBuff
332
	   call SysMsgBoardStr
333
	   call create_primary_buff
334
	   mov esi, msgDone
335
	   call SysMsgBoardStr
336
 
2015 serge 337
  if IRQ_REMAP
338
	   pushf
339
	   cli
340
 
341
	   mov ebx, [ctrl.int_line]
342
	   in al, 0xA1
343
	   mov ah, al
344
	   in al, 0x21
345
	   test ebx, ebx
346
	   jz .skip
347
	   bts ax, bx			   ;mask old line
348
.skip
349
	   bts ax, IRQ_LINE		   ;mask new ine
350
	   out 0x21, al
351
	   mov al, ah
352
	   out 0xA1, al
353
					   ;remap IRQ
354
	   stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
355
 
356
	   mov dx, 0x4d0		   ;8259 ELCR1
357
	   in al, dx
358
	   bts ax, IRQ_LINE
359
	   out dx, al			   ;set level-triggered mode
360
	   mov [ctrl.int_line], IRQ_LINE
361
	   popf
362
	   mov esi, msgRemap
363
	   call SysMsgBoardStr
364
  end if
365
 
366
	   mov ebx, [ctrl.int_line]
367
	   stdcall AttachIntHandler, ebx, ac97_irq, dword 0
802 serge 368
.reg:
369
	   stdcall RegService, sz_sound_srv, service_proc
370
	   ret
371
.fail:
372
     if DEBUG
373
	   mov esi, msgFail
374
	   call SysMsgBoardStr
375
     end if
376
	   xor eax, eax
377
	   ret
378
.fail_msg:
379
	   call SysMsgBoardStr
380
	   xor eax, eax
381
	   ret
382
.stop:
383
	   call stop
384
	   xor eax, eax
385
	   ret
386
endp
387
 
388
handle	   equ	IOCTL.handle
389
io_code    equ	IOCTL.io_code
390
input	   equ	IOCTL.input
391
inp_size   equ	IOCTL.inp_size
392
output	   equ	IOCTL.output
393
out_size   equ	IOCTL.out_size
394
 
395
align 4
396
proc service_proc stdcall, ioctl:dword
397
 
398
	   mov edi, [ioctl]
399
	   mov eax, [edi+io_code]
400
 
401
	   cmp eax, SRV_GETVERSION
402
	   jne @F
403
 
404
	   mov eax, [edi+output]
405
	   cmp [edi+out_size], 4
406
	   jne .fail
407
 
408
	   mov [eax], dword API_VERSION
409
	   xor eax, eax
410
	   ret
411
@@:
412
	   cmp eax, DEV_PLAY
413
	   jne @F
414
     if DEBUG
415
	   mov esi, msgPlay
416
	   call SysMsgBoardStr
417
     end if
418
	   call play
419
	   ret
420
@@:
421
	   cmp eax, DEV_STOP
422
	   jne @F
423
     if DEBUG
424
	   mov esi, msgStop
425
	   call SysMsgBoardStr
426
     end if
427
	   call stop
428
	   ret
429
@@:
430
	   cmp eax, DEV_CALLBACK
431
	   jne @F
432
	   mov ebx, [edi+input]
433
	   stdcall set_callback, [ebx]
434
	   ret
435
@@:
436
	   cmp eax, DEV_SET_MASTERVOL
437
	   jne @F
438
	   mov eax, [edi+input]
439
	   mov eax, [eax]
440
	   call set_master_vol	    ;eax= vol
441
	   ret
442
@@:
443
	   cmp eax, DEV_GET_MASTERVOL
444
	   jne @F
445
	   mov ebx, [edi+output]
446
	   stdcall get_master_vol, ebx
447
	   ret
2010 serge 448
 
449
@@:
450
           cmp eax, DEV_GET_POS
451
           jne @F
452
 
453
           mov ebx, 8192
454
           mov edx, 0x18
455
           xor eax, eax
456
           call [ctrl.ctrl_read16]
457
           sub ebx, eax
458
           shr ebx, 1
459
           mov edx, [edi+output]
460
           mov [edx], ebx
461
           xor eax, eax
462
           ret
802 serge 463
;@@:
464
;           cmp eax, DEV_GET_INFO
465
;           jne @F
466
;           mov ebx, [edi+output]
467
;           stdcall get_dev_info, ebx
468
;           ret
469
@@:
470
.fail:
471
	   or eax, -1
472
	   ret
473
endp
474
 
475
restore   handle
476
restore   io_code
477
restore   input
478
restore   inp_size
479
restore   output
480
restore   out_size
481
 
482
align 4
483
proc ac97_irq
484
 
485
     if DEBUG_IRQ
486
	   mov esi, msgIRQ
487
	   call SysMsgBoardStr
488
     end if
489
 
2010 serge 490
           mov edx, CTRL_STAT
491
           call [ctrl.ctrl_read32]
492
 
2106 serge 493
           cmp eax, 0xffffffff
494
           je .exit
2010 serge 495
 
496
           test eax, 0x40
497
           jnz .do_intr
498
 
499
           test eax, eax
2106 serge 500
           jz .exit
2010 serge 501
 
502
           mov edx, CTRL_STAT
503
           call [ctrl.ctrl_write32]
2106 serge 504
.exit:
505
           xor eax, eax
506
           ret
2010 serge 507
 
508
.do_intr:
2106 serge 509
           push eax
510
 
802 serge 511
	   mov edx, PCM_OUT_CR_REG
512
	   mov al, 0x10;               0x10
513
	   call [ctrl.ctrl_write8]
514
 
515
	   mov ax, 0x1c
516
	   mov edx, PCM_OUT_SR_REG
517
	   call [ctrl.ctrl_write16]
518
 
519
	   mov edx, PCM_OUT_CIV_REG
520
	   call [ctrl.ctrl_read8]
521
 
522
	   and eax, 0x1F
523
	   cmp eax, [civ_val]
524
	   je .skip
525
 
526
	   mov [civ_val], eax
527
	   dec eax
528
	   and eax, 0x1F
529
	   mov [ctrl.lvi_reg], eax
530
 
531
	   mov edx, PCM_OUT_LVI_REG
532
	   call [ctrl.ctrl_write8]
533
 
534
	   mov edx, PCM_OUT_CR_REG
535
	   mov ax, 0x11 	     ;0x1D
536
	   call [ctrl.ctrl_write8]
537
 
538
	   mov eax, [civ_val]
539
	   add eax, 1
540
	   and eax, 31
541
	   mov ebx, dword [buff_list+eax*4]
542
 
2010 serge 543
           cmp [ctrl.user_callback], 0
544
           je .done
802 serge 545
 
2010 serge 546
           stdcall [ctrl.user_callback], ebx
547
.done:
548
           pop eax
2106 serge 549
           and eax, 0x40
2010 serge 550
           mov edx, CTRL_STAT
551
           call [ctrl.ctrl_write32]
2106 serge 552
           or eax, 1
802 serge 553
	   ret
554
.skip:
555
	   mov edx, PCM_OUT_CR_REG
556
	   mov ax, 0x11 	      ;0x1D
557
	   call [ctrl.ctrl_write8]
2010 serge 558
           jmp .done
802 serge 559
endp
560
 
561
align 4
562
proc create_primary_buff
563
 
564
	   stdcall KernelAlloc, 0x10000
565
	   mov [ctrl.buffer], eax
566
 
567
	   mov edi, eax
568
	   mov ecx, 0x10000/4
569
	   xor eax, eax
570
	   cld
571
	   rep stosd
572
 
573
	   mov eax, [ctrl.buffer]
574
	   call GetPgAddr
575
 
576
	   mov ebx, 0xC0002000
577
	   mov ecx, 4
578
	   mov edi, pcmout_bdl
579
@@:
580
	   mov [edi], eax
581
	   mov [edi+4], ebx
582
 
583
	   mov [edi+32], eax
584
	   mov [edi+4+32], ebx
585
 
586
	   mov [edi+64], eax
587
	   mov [edi+4+64], ebx
588
 
589
	   mov [edi+96], eax
590
	   mov [edi+4+96], ebx
591
 
592
	   mov [edi+128], eax
593
	   mov [edi+4+128], ebx
594
 
595
	   mov [edi+160], eax
596
	   mov [edi+4+160], ebx
597
 
598
	   mov [edi+192], eax
599
	   mov [edi+4+192], ebx
600
 
601
	   mov [edi+224], eax
602
	   mov [edi+4+224], ebx
603
 
604
	   add eax, 0x4000
605
	   add edi, 8
606
	   loop @B
607
 
608
	   mov edi, buff_list
609
	   mov eax, [ctrl.buffer]
610
	   mov ecx, 4
611
@@:
612
	   mov [edi], eax
613
	   mov [edi+16], eax
614
	   mov [edi+32], eax
615
	   mov [edi+48], eax
616
	   mov [edi+64], eax
617
	   mov [edi+80], eax
618
	   mov [edi+96], eax
619
	   mov [edi+112], eax
620
 
621
	   add eax, 0x4000
622
	   add edi, 4
623
	   loop @B
624
 
625
	   mov eax, pcmout_bdl
626
	   mov ebx, eax
627
	   call GetPgAddr     ;eax
628
	   and ebx, 0xFFF
629
	   add eax, ebx
630
 
631
	   mov edx, PCM_OUT_BDL
632
	   call [ctrl.ctrl_write32]
633
 
634
	   mov eax, 16
635
	   mov [ctrl.lvi_reg], eax
636
	   mov edx, PCM_OUT_LVI_REG
637
	   call [ctrl.ctrl_write8]
638
	   ret
639
endp
640
 
641
align 4
642
proc detect_controller
643
	   locals
644
	     last_bus dd ?
645
	     bus      dd ?
646
	     devfn    dd ?
647
	   endl
648
 
649
	   xor eax, eax
650
	   mov [bus], eax
651
	   inc eax
652
	   call PciApi
653
	   cmp eax, -1
654
	   je .err
655
 
656
	   mov [last_bus], eax
657
 
658
.next_bus:
659
	   and [devfn], 0
660
.next_dev:
661
	   stdcall PciRead32, [bus], [devfn], dword 0
662
	   test eax, eax
663
	   jz .next
664
	   cmp eax, -1
665
	   je .next
666
 
667
	   mov edi, devices
668
@@:
669
	   mov ebx, [edi]
670
	   test ebx, ebx
671
	   jz .next
672
 
673
	   cmp eax, ebx
674
	   je .found
675
	   add edi, 12
676
	   jmp @B
677
.next:
678
	   inc [devfn]
679
	   cmp [devfn], 256
680
	   jb .next_dev
681
	   mov eax, [bus]
682
	   inc eax
683
	   mov [bus], eax
684
	   cmp eax, [last_bus]
685
	   jna .next_bus
686
	   xor eax, eax
687
	   ret
688
.found:
689
	   mov ebx, [bus]
690
	   mov [ctrl.bus], ebx
691
 
692
	   mov ecx, [devfn]
693
	   mov [ctrl.devfn], ecx
694
 
695
	   mov edx, eax
696
	   and edx, 0xFFFF
697
	   mov [ctrl.vendor], edx
698
	   shr eax, 16
699
	   mov [ctrl.dev_id], eax
700
 
701
	   mov ebx, [edi+4]
702
	   mov [ctrl.ctrl_ids], ebx
703
	   mov esi, [edi+8]
704
	   mov [ctrl.ctrl_setup], esi
705
 
706
	   cmp edx, VID_INTEL
707
	   jne @F
708
	   mov [ctrl.vendor_ids], msg_Intel
709
	   ret
710
@@:
711
	   cmp edx, VID_NVIDIA
712
	   jne @F
713
	   mov [ctrl.vendor_ids], msg_NVidia
714
	   ret
715
@@:
716
.err:
717
	   xor eax, eax
718
	   mov [ctrl.vendor_ids], eax	  ;something  wrong ?
719
	   ret
720
endp
721
 
722
align 4
723
proc init_controller
724
 
725
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
726
	   mov ebx, eax
727
	   and eax, 0xFFFF
728
	   mov [ctrl.pci_cmd], eax
729
	   shr ebx, 16
730
	   mov [ctrl.pci_stat], ebx
731
 
732
	   mov esi, msgPciCmd
733
	   call SysMsgBoardStr
734
	   call dword2str
735
	   call SysMsgBoardStr
736
 
737
	   mov esi, msgPciStat
738
	   call SysMsgBoardStr
739
	   mov eax, [ctrl.pci_stat]
740
	   call dword2str
741
	   call SysMsgBoardStr
742
 
743
	   mov esi, msgMixIsaIo
744
	   call SysMsgBoardStr
745
 
746
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
747
 
748
	   call dword2str
749
	   call SysMsgBoardStr
750
 
751
	   and eax,0xFFFE
752
	   mov [ctrl.codec_io_base], eax
753
 
754
	   mov esi, msgCtrlIsaIo
755
	   call SysMsgBoardStr
756
 
757
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
758
 
759
	   call dword2str
760
	   call SysMsgBoardStr
761
 
762
	   and eax, 0xFFC0
763
	   mov [ctrl.ctrl_io_base], eax
764
 
765
	   mov esi, msgMixMMIo
766
	   call SysMsgBoardStr
767
 
768
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
769
	   mov [ctrl.codec_mem_base], eax
770
 
771
	   call dword2str
772
	   call SysMsgBoardStr
773
 
774
	   mov esi, msgCtrlMMIo
775
	   call SysMsgBoardStr
776
 
777
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
778
	   mov [ctrl.ctrl_mem_base], eax
779
 
780
	   call dword2str
781
	   call SysMsgBoardStr
782
 
783
if 0
784
 
785
;;patch for some ugly BIOS  ICH-ICH5 compatible
786
	   cmp [ctrl.vendor], VID_INTEL
787
	   jne .default
788
 
789
	   mov esi, msgIrqMap
790
	   call SysMsgBoardStr
791
	   stdcall PciRead8, 0, 0xF8, 0x61
792
	   and eax, 0xFF
793
	   call dword2str
794
	   call SysMsgBoardStr
795
	   btr eax, 7		      ;when bit 7 set remap disabled
796
	   jnc @F
797
	   xor eax, eax
798
	   jmp @F
799
end if
800
 
801
.default:
802
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
803
	   and eax, 0xFF
804
@@:
805
	   mov [ctrl.int_line], eax
806
 
807
	   stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
808
	   and eax, 0xFF
809
	   mov [ctrl.cfg_reg], eax
810
 
2010 serge 811
           mov [ctrl.user_callback], 0
812
 
802 serge 813
	   call [ctrl.ctrl_setup]
814
	   xor eax, eax
815
	   inc eax
816
	   ret
817
endp
818
 
819
align 4
820
proc set_ICH
821
	   mov [ctrl.codec_read16],  codec_io_r16    ;virtual
822
	   mov [ctrl.codec_write16], codec_io_w16    ;virtual
823
 
824
	   mov [ctrl.ctrl_read8 ],  ctrl_io_r8	     ;virtual
825
	   mov [ctrl.ctrl_read16],  ctrl_io_r16      ;virtual
826
	   mov [ctrl.ctrl_read32],  ctrl_io_r32      ;virtual
827
 
828
	   mov [ctrl.ctrl_write8 ], ctrl_io_w8	     ;virtual
829
	   mov [ctrl.ctrl_write16], ctrl_io_w16      ;virtual
830
	   mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
831
	   ret
832
endp
833
 
834
PG_SW		 equ 0x003
835
PG_NOCACHE	 equ 0x018
836
 
837
align 4
838
proc set_ICH4
839
 
840
	   stdcall MapIoMem,[ctrl.codec_mem_base],0x1000,PG_SW+PG_NOCACHE
841
	   mov [ctrl.codec_mem_base], eax
842
 
843
	   stdcall MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE
844
	   mov [ctrl.ctrl_mem_base], eax
845
 
846
	   mov [ctrl.codec_read16],  codec_mem_r16    ;virtual
847
	   mov [ctrl.codec_write16], codec_mem_w16    ;virtual
848
 
849
	   mov [ctrl.ctrl_read8 ],  ctrl_mem_r8       ;virtual
850
	   mov [ctrl.ctrl_read16],  ctrl_mem_r16      ;virtual
851
	   mov [ctrl.ctrl_read32],  ctrl_mem_r32      ;virtual
852
 
853
	   mov [ctrl.ctrl_write8 ], ctrl_mem_w8       ;virtual
854
	   mov [ctrl.ctrl_write16], ctrl_mem_w16      ;virtual
855
	   mov [ctrl.ctrl_write32], ctrl_mem_w32      ;virtual
856
	   ret
857
endp
858
 
859
align 4
860
proc reset_controller
861
 
862
	   xor eax, eax
863
	   mov edx, PCM_IN_CR_REG
864
	   call [ctrl.ctrl_write8]
865
 
866
	   mov edx, PCM_OUT_CR_REG
867
	   call [ctrl.ctrl_write8]
868
 
869
	   mov edx, MC_IN_CR_REG
870
	   call [ctrl.ctrl_write8]
871
 
872
	   mov eax, RR
873
	   mov edx, PCM_IN_CR_REG
874
	   call [ctrl.ctrl_write8]
875
 
876
	   mov edx, PCM_OUT_CR_REG
877
	   call [ctrl.ctrl_write8]
878
 
879
	   mov edx, MC_IN_CR_REG
880
	   call [ctrl.ctrl_write8]
881
	   ret
882
endp
883
 
884
align 4
885
proc init_codec
886
	   locals
887
	     counter dd ?
888
	   endl
889
 
890
	   mov esi, msgControl
891
	   call SysMsgBoardStr
892
 
893
	   mov edx, GLOB_CTRL
894
	   call [ctrl.ctrl_read32]
895
	   call dword2str
896
	   call SysMsgBoardStr
897
 
898
	   mov esi, msgStatus
899
	   call SysMsgBoardStr
900
 
901
	   mov edx, CTRL_STAT
902
	   call [ctrl.ctrl_read32]
903
	   push eax
904
	   call dword2str
905
	   call SysMsgBoardStr
906
	   pop eax
907
	   cmp eax, 0xFFFFFFFF
908
	   je .err
909
 
910
	   test eax, CTRL_ST_CREADY
911
	   jnz .ready
912
 
913
	   call reset_codec
914
	   test eax, eax
915
	   jz .err
916
 
917
.ready:
918
	   xor edx, edx     ;ac_reg_0
919
	   call [ctrl.codec_write16]
920
 
921
	   xor eax, eax
922
	   mov edx, CODEC_REG_POWERDOWN
923
	   call [ctrl.codec_write16]
924
 
925
	   mov [counter], 200	  ; total 200*5 ms = 1s
926
.wait:
927
	   mov eax, 5000   ; wait 5 ms
928
	   call StallExec
929
 
930
	   mov edx, CODEC_REG_POWERDOWN
931
	   call [ctrl.codec_read16]
932
	   and eax, 0x0F
933
	   cmp eax, 0x0F
934
	   jz .done
935
 
936
	   sub [counter] , 1
937
	   jnz .wait
938
.err:
939
	   xor eax, eax        ; timeout error
940
	   ret
941
.done:
942
	   mov eax, 2	   ;force set 16-bit 2-channel PCM
943
	   mov edx, GLOB_CTRL
944
	   call [ctrl.ctrl_write32]
945
	   mov eax, 5000   ; wait 5 ms
946
	   call StallExec
947
 
948
	   call detect_codec
949
 
950
	   xor eax, eax
951
	   inc eax
952
	   ret
953
endp
954
 
955
align 4
956
proc reset_codec
957
	   mov edx, GLOB_CTRL
958
	   call [ctrl.ctrl_read32]
959
 
960
	   test eax, 0x02
961
	   jz .cold
962
 
963
	   call warm_reset
964
	   jnc .ok
965
.cold:
966
	   call cold_reset
967
	   jnc .ok
968
 
969
     if DEBUG
970
	   mov esi, msgCFail
971
	   call SysMsgBoardStr
972
	   end if
973
	   xor eax, eax     ; timeout error
974
	   ret
975
.ok:
976
     if DEBUG
977
	   mov esi, msgResetOk
978
	   call SysMsgBoardStr
979
     end if
980
 
981
	   xor eax, eax
982
	   inc eax
983
	   ret
984
endp
985
 
986
align 4
987
proc warm_reset
988
	   locals
989
	     counter dd ?
990
	   endl
991
 
992
	   mov eax, 0x06
993
	   mov edx, GLOB_CTRL
994
	   call [ctrl.ctrl_write32]
995
 
996
     if DEBUG
997
	   mov esi, msgWarm
998
	   call SysMsgBoardStr
999
     end if
1000
 
1001
	   mov [counter], 10	; total 10*100 ms = 1s
1002
.wait:
1003
	   mov eax, 100000    ; wait 100 ms
1004
	   call StallExec
1005
 
1006
	   mov edx, CTRL_STAT
1007
	   call [ctrl.ctrl_read32]
1008
	   test eax, CTRL_ST_CREADY
1009
	   jnz .ok
1010
 
1011
	   dec [counter]
1012
	   jnz .wait
1013
 
1014
     if DEBUG
1015
	   mov esi, msgWRFail
1016
	   call SysMsgBoardStr
1017
     end if
1018
.fail:
1019
	   stc
1020
	   ret
1021
.ok:
1022
	   clc
1023
	   ret
1024
endp
1025
 
1026
align 4
1027
proc cold_reset
1028
	   locals
1029
	     counter dd ?
1030
	   endl
1031
 
1032
	   mov eax, 0x02
1033
	   mov edx, GLOB_CTRL
1034
	   call [ctrl.ctrl_write32]
1035
 
1036
     if DEBUG
1037
	   mov esi, msgCold
1038
	   call SysMsgBoardStr
1039
     end if
1040
 
1041
	   mov eax, 400000     ; wait 400 ms
1042
	   call StallExec
1043
 
1044
	   mov [counter], 16	; total 20*100 ms = 2s
1045
.wait:
1046
 
1047
	   mov edx, CTRL_STAT
1048
	   call [ctrl.ctrl_read32]
1049
	   test eax, CTRL_ST_CREADY
1050
	   jnz .ok
1051
 
1052
	   mov eax, 100000    ; wait 100 ms
1053
	   call StallExec
1054
 
1055
	   dec [counter]
1056
	   jnz .wait
1057
 
1058
     if DEBUG
1059
	   mov esi, msgCRFail
1060
	   call SysMsgBoardStr
1061
     end if
1062
 
1063
.fail:
1064
	   stc
1065
	   ret
1066
.ok:
1067
	   mov esi, msgControl
1068
	   call SysMsgBoardStr
1069
 
1070
	   mov edx, GLOB_CTRL
1071
	   call [ctrl.ctrl_read32]
1072
	   call dword2str
1073
	   call SysMsgBoardStr
1074
 
1075
	   mov esi, msgStatus
1076
	   call SysMsgBoardStr
1077
 
1078
	   mov edx, CTRL_STAT
1079
	   call [ctrl.ctrl_read32]
1080
	   push eax
1081
	   call dword2str
1082
	   call SysMsgBoardStr
1083
	   pop eax
1084
 
1085
	   test eax, CTRL_ST_CREADY
1086
	   jz .fail
1087
	   clc
1088
	   ret
1089
endp
1090
 
1091
align 4
1092
play:
1093
	   mov eax, 16
1094
	   mov [ctrl.lvi_reg], eax
1095
	   mov edx, PCM_OUT_LVI_REG
1096
	   call [ctrl.ctrl_write8]
1097
 
1098
	   mov edx, PCM_OUT_CR_REG
1099
	   mov ax, 0x1D
1100
	   call [ctrl.ctrl_write8]
1101
	   xor eax, eax
1102
	   ret
1103
 
1104
align 4
1105
stop:
1106
	   mov edx, PCM_OUT_CR_REG
1107
	   mov ax, 0x0
1108
	   call [ctrl.ctrl_write8]
1109
 
1110
	   mov ax, 0x1c
1111
	   mov edx, PCM_OUT_SR_REG
1112
	   call [ctrl.ctrl_write16]
1113
	   xor eax, eax
1114
	   ret
1115
 
1116
align 4
1117
proc get_dev_info stdcall, p_info:dword
1118
	   virtual at esi
1119
	     CTRL_INFO CTRL_INFO
1120
	   end virtual
1121
 
1122
	   mov esi, [p_info]
1123
	   mov eax, [ctrl.int_line]
1124
	   mov ebx, [ctrl.codec_io_base]
1125
	   mov ecx, [ctrl.ctrl_io_base]
1126
	   mov edx, [ctrl.codec_mem_base]
1127
	   mov edi, [ctrl.ctrl_mem_base]
1128
 
1129
	   mov [CTRL_INFO.irq], eax
1130
	   mov [CTRL_INFO.codec_io_base], ebx
1131
	   mov [CTRL_INFO.ctrl_io_base], ecx
1132
	   mov [CTRL_INFO.codec_mem_base], edx
1133
	   mov [CTRL_INFO.ctrl_mem_base], edi
1134
 
1135
	   mov eax, [codec.chip_id]
1136
	   mov [CTRL_INFO.codec_id], eax
1137
 
1138
	   mov edx, GLOB_CTRL
1139
	   call [ctrl.ctrl_read32]
1140
	   mov [CTRL_INFO.glob_cntrl], eax
1141
 
1142
	   mov edx, CTRL_STAT
1143
	   call [ctrl.ctrl_read32]
1144
	   mov [CTRL_INFO.glob_sta], eax
1145
 
1146
	   mov ebx, [ctrl.pci_cmd]
1147
	   mov [CTRL_INFO.pci_cmd], ebx
1148
	   ret
1149
endp
1150
 
1151
align 4
1152
proc set_callback stdcall, handler:dword
1153
	   mov eax, [handler]
1154
	   mov [ctrl.user_callback], eax
1155
	   ret
1156
endp
1157
 
1158
align 4
1159
proc codec_read stdcall, ac_reg:dword	   ; reg = edx, reval = eax
1160
 
1161
	   mov edx, [ac_reg]
1162
 
1163
	   mov ebx, edx
1164
	   shr ebx, 1
1165
	   bt [codec.shadow_flag], ebx
1166
	   jc .use_shadow
1167
 
1168
	   call [ctrl.codec_read16]  ;change edx !!!
1169
	   mov ecx, eax
1170
 
1171
	   mov edx, CTRL_STAT
1172
	   call [ctrl.ctrl_read32]
1173
	   test eax, CTRL_ST_RCS
1174
	   jz .read_ok
1175
 
1176
	   mov edx, CTRL_STAT
1177
	   call [ctrl.ctrl_write32]
1178
	   xor eax,eax
1179
	   not eax  ;timeout
1180
	   ret
1181
.read_ok:
1182
	   mov edx, [ac_reg]
1183
	   mov [codec.regs+edx], cx
1184
	   bts [codec.shadow_flag], ebx
1185
	   mov eax, ecx
1186
	   ret
1187
.use_shadow:
1188
	   movzx eax, word [codec.regs+edx]
1189
	   ret
1190
endp
1191
 
1192
align 4
1193
proc codec_write stdcall, ac_reg:dword
1194
	   push eax
1195
	   call check_semafore
1196
	   and eax, eax
1197
	   jz .err
1198
	   pop eax
1199
 
1200
	   mov esi, [ac_reg]
1201
	   mov edx, esi
1202
	   call [ctrl.codec_write16]
1203
	   mov [codec.regs+esi], ax
1204
	   shr esi, 1
1205
	   bts [codec.shadow_flag], esi
1206
	   ret
1207
.err:
1208
	   pop eax
1209
	   ret
1210
endp
1211
 
1212
align 4
1213
proc codec_check_ready
1214
 
1215
	   mov edx, CTRL_ST
1216
	   call [ctrl.ctrl_read32]
1217
	   and eax, CTRL_ST_CREADY
1218
	   jz .not_ready
1219
 
1220
	   xor eax, wax
1221
	   inc eax
1222
	   ret
1223
.not_ready:
1224
	   xor eax, eax
1225
	   ret
1226
endp
1227
 
1228
align 4
1229
proc check_semafore
1230
	   local counter:DWORD
1231
 
1232
	   mov [counter], 100
1233
.l1:
1234
	   mov edx, CTRL_CAS
1235
	   call [ctrl.ctrl_read8]
1236
	   and eax, CAS_FLAG
1237
	   jz .ok
1238
 
1239
	   mov eax, 1
1240
	   call StallExec
1241
	   sub [counter], 1
1242
	   jnz .l1
1243
	   xor eax, eax
1244
	   ret
1245
align 4
1246
.ok:
1247
	   xor eax,eax
1248
	   inc eax
1249
	   ret
1250
endp
1251
 
1252
align 4
1253
proc StallExec
1254
	   push ecx
1255
	   push edx
1256
	   push ebx
1257
	   push eax
1258
 
1259
	   mov ecx, CPU_FREQ
1260
	   mul ecx
1261
	   mov ebx, eax       ;low
1262
	   mov ecx, edx       ;high
1263
	   rdtsc
1264
	   add ebx, eax
1265
	   adc ecx,edx
1266
@@:
1267
	   rdtsc
1268
	   sub eax, ebx
1269
	   sbb edx, ecx
1270
	   js @B
1271
 
1272
	   pop eax
1273
	   pop ebx
1274
	   pop edx
1275
	   pop ecx
1276
	   ret
1277
endp
1278
 
1279
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1280
;          CONTROLLER IO functions
1281
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1282
 
1283
align 4
1284
proc codec_io_r16
1285
	   add edx, [ctrl.codec_io_base]
1286
	   in  ax, dx
1287
	   ret
1288
endp
1289
 
1290
align 4
1291
proc codec_io_w16
1292
	   add edx, [ctrl.codec_io_base]
1293
	   out dx, ax
1294
	   ret
1295
endp
1296
 
1297
align 4
1298
proc ctrl_io_r8
1299
	   add edx, [ctrl.ctrl_io_base]
1300
	   in  al, dx
1301
	   ret
1302
endp
1303
 
1304
align 4
1305
proc ctrl_io_r16
1306
	   add edx, [ctrl.ctrl_io_base]
1307
	   in  ax, dx
1308
	   ret
1309
endp
1310
 
1311
align 4
1312
proc ctrl_io_r32
1313
	   add edx, [ctrl.ctrl_io_base]
1314
	   in  eax, dx
1315
	   ret
1316
endp
1317
 
1318
align 4
1319
proc ctrl_io_w8
1320
	   add edx, [ctrl.ctrl_io_base]
1321
	   out dx, al
1322
	   ret
1323
endp
1324
 
1325
align 4
1326
proc ctrl_io_w16
1327
	   add edx, [ctrl.ctrl_io_base]
1328
	   out dx, ax
1329
	   ret
1330
endp
1331
 
1332
align 4
1333
proc ctrl_io_w32
1334
	   add edx, [ctrl.ctrl_io_base]
1335
	   out dx, eax
1336
	   ret
1337
endp
1338
 
1339
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1340
;         MEMORY MAPPED IO    (os depended)
1341
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1342
 
1343
align 4
1344
proc codec_mem_r16
1345
	   add edx, [ctrl.codec_mem_base]
1346
	   mov ax, word [edx]
1347
	   ret
1348
endp
1349
 
1350
align 4
1351
proc codec_mem_w16
1352
	   add edx, [ctrl.codec_mem_base]
1353
	   mov word [edx], ax
1354
	   ret
1355
endp
1356
 
1357
align 4
1358
proc ctrl_mem_r8
1359
	   add edx, [ctrl.ctrl_mem_base]
1360
	   mov al, [edx]
1361
	   ret
1362
endp
1363
 
1364
align 4
1365
proc ctrl_mem_r16
1366
	   add edx, [ctrl.ctrl_mem_base]
1367
	   mov ax, [edx]
1368
	   ret
1369
endp
1370
 
1371
align 4
1372
proc ctrl_mem_r32
1373
	   add edx, [ctrl.ctrl_mem_base]
1374
	   mov eax, [edx]
1375
	   ret
1376
endp
1377
 
1378
align 4
1379
proc ctrl_mem_w8
1380
	   add edx, [ctrl.ctrl_mem_base]
1381
	   mov [edx], al
1382
	   ret
1383
endp
1384
 
1385
align 4
1386
proc ctrl_mem_w16
1387
	   add edx, [ctrl.ctrl_mem_base]
1388
	   mov [edx], ax
1389
	   ret
1390
endp
1391
 
1392
align 4
1393
proc ctrl_mem_w32
1394
	   add edx, [ctrl.ctrl_mem_base]
1395
	   mov [edx], eax
1396
	   ret
1397
endp
1398
 
1399
align 4
1400
dword2str:
1401
      mov  esi, hex_buff
1402
      mov ecx, -8
1403
@@:
1404
      rol eax, 4
1405
      mov ebx, eax
1406
      and ebx, 0x0F
1407
      mov bl, [ebx+hexletters]
1408
      mov [8+esi+ecx], bl
1409
      inc ecx
1410
      jnz @B
1411
      ret
1412
 
1413
hexletters   db '0123456789ABCDEF'
1414
hex_buff     db 8 dup(0),13,10,0
1415
 
1416
 
1417
include "codec.inc"
1418
 
1419
align 4
1420
devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
1421
	dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
1422
	dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
1423
	dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
1424
	dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
1425
	dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
1426
	dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
1427
	dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
1428
 
1429
	dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
1430
	dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
1431
	dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
1432
	dd (CTRL_MCP04	 shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
1433
	dd (CTRL_CK804	 shl 16)+VID_NVIDIA,msg_CK804,set_ICH
1434
	dd (CTRL_CK8	 shl 16)+VID_NVIDIA,msg_CK8,set_ICH
1435
	dd (CTRL_CK8S	 shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
1436
	dd (CTRL_MCP51	 shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
1437
 
1438
	dd 0	;terminator
1439
 
1440
 
1441
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
1442
 
1443
msg_ICH      db '802801AA (ICH)',  13,10, 0
1444
msg_ICH0     db '802801AB (ICH0)', 13,10, 0
1445
msg_ICH2     db '802801BA (ICH2)', 13,10, 0
1446
msg_ICH3     db '802801CA (ICH3)', 13,10, 0
1447
msg_ICH4     db '802801DB (ICH4)', 13,10, 0
1448
msg_ICH5     db '802801EB (ICH5)', 13,10, 0
1449
msg_ICH6     db '802801FB (ICH6)', 13,10, 0
1450
msg_ICH7     db '802801GB (ICH7)', 13,10, 0
1451
msg_Intel    db 'Intel ', 0
1452
 
1453
msg_NForce   db 'NForce',      13,10, 0
1454
msg_NForce2  db 'NForce 2',    13,10, 0
1455
msg_NForce3  db 'NForce 3',    13,10, 0
1456
msg_MCP04    db 'NForce MCP04',13,10, 0
1457
msg_CK804    db 'NForce CK804',13,10, 0
1458
msg_CK8      db 'NForce CK8',  13,10, 0
1459
msg_CK8S     db 'NForce CK8S', 13,10, 0
1460
msg_MCP51    db 'NForce MCP51',13,10, 0
1461
 
1462
msg_NVidia   db 'NVidia', 0
1463
 
1464
szKernel	    db 'KERNEL', 0
1465
sz_sound_srv	    db 'SOUND',0
1466
 
1467
msgInit      db 'detect hardware...',13,10,0
1468
msgFail      db 'device not found',13,10,0
1469
msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
1470
msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
1471
msgPlay      db 'start play', 13,10,0
1472
msgStop      db 'stop play',  13,10,0
1473
;msgNotify    db 'call notify',13,10,0
1474
msgIRQ	     db 'AC97 IRQ', 13,10,0
1475
msgInitCtrl  db 'init controller',13,10,0
1476
;msgInitCodec db 'init codec',13,10,0
1477
msgPrimBuff  db 'create primary buffer ...',0
1478
msgDone      db 'done',13,10,0
1479
msgRemap     db 'Remap IRQ',13,10,0
1480
;msgReg       db 'set service handler',13,10,0
1481
msgOk	     db 'service installed',13,10,0
1482
msgCold      db 'cold reset',13,10,0
1483
msgWarm      db 'warm reset',13,10,0
1484
msgWRFail    db 'warm reset failed',13,10,0
1485
msgCRFail    db 'cold reset failed',13,10,0
1486
msgCFail     db 'codec not ready',13,10,0
1487
msgResetOk   db 'reset complete',13,10,0
1488
msgStatus    db 'global status   ',0
1489
msgControl   db 'global control  ',0
1490
msgPciCmd    db 'PCI command     ',0
1491
msgPciStat   db 'PCI status      ',0
1492
msgCtrlIsaIo db 'controller io base   ',0
1493
msgMixIsaIo  db 'codec io base        ',0
1494
msgCtrlMMIo  db 'controller mmio base ',0
1495
msgMixMMIo   db 'codec mmio base      ',0
1496
msgIrqMap    db 'AC97 irq map as      ',0
1497
 
1498
section '.data' data readable writable align 16
1499
 
1500
pcmout_bdl	 rq 32
1501
buff_list	 rd 32
1502
 
1503
codec CODEC
1504
ctrl AC_CNTRL
1505
 
1506
lpc_bus  rd 1
1507
civ_val  rd 1