Subversion Repositories Kolibri OS

Rev

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