Subversion Repositories Kolibri OS

Rev

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