Subversion Repositories Kolibri OS

Rev

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