Subversion Repositories Kolibri OS

Rev

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

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