Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

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