Subversion Repositories Kolibri OS

Rev

Rev 3539 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3539 Rev 5077
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
-
 
8
format PE DLL native 0.05
Line 8... Line 9...
8
format MS COFF
9
entry START
Line 9... Line -...
9
 
-
 
10
DEBUG           equ 1
-
 
11
 
-
 
12
include 'proc32.inc'
10
 
Line 13... Line 11...
13
include 'imports.inc'
11
DEBUG           equ 1
14
 
12
 
15
API_VERSION     equ 0x01000100
13
API_VERSION     equ 0x01000100
Line 313... Line 311...
313
    .codec_mem_base   dd ?
311
    .codec_mem_base   dd ?
314
    .ctrl_mem_base    dd ?
312
    .ctrl_mem_base    dd ?
315
    .codec_id         dd ?
313
    .codec_id         dd ?
316
}
314
}
Line 317... Line -...
317
 
-
 
318
struc IOCTL
-
 
319
{  .handle            dd ?
-
 
320
   .io_code           dd ?
-
 
321
   .input             dd ?
-
 
322
   .inp_size          dd ?
-
 
323
   .output            dd ?
-
 
324
   .out_size          dd ?
-
 
325
}
-
 
326
 
-
 
327
virtual at 0
-
 
328
  IOCTL IOCTL
-
 
329
end virtual
-
 
330
 
315
 
Line -... Line 316...
-
 
316
EVENT_NOTIFY    equ 0x00000200
331
EVENT_NOTIFY    equ 0x00000200
317
 
332
 
318
section '.flat' code readable writable executable
333
public START
319
include '../struct.inc'
-
 
320
include '../macros.inc'
Line 334... Line -...
334
public service_proc
-
 
Line 335... Line 321...
335
public version
321
include '../proc32.inc'
Line 336... Line 322...
336
 
322
include '../peimport.inc'
337
section '.flat' code readable align 16
323
 
Line 338... Line 324...
338
 
324
 
339
proc START stdcall, state:dword
325
proc START c uses ebx esi edi, state:dword, cmdline:dword
340
 
326
 
341
        cmp     [state], 1
327
        cmp     [state], 1
Line 342... Line 328...
342
        jne     .stop
328
        jne     .stop
343
 
329
 
344
     if DEBUG
330
     if DEBUG
Line 345... Line 331...
345
        mov     esi, msgInit
331
        mov     esi, msgInit
346
        call    SysMsgBoardStr
332
        invoke  SysMsgBoardStr
347
     end if
333
     end if
348
 
334
 
349
        call    detect_controller
335
        call    detect_controller
350
        test    eax, eax
336
        test    eax, eax
Line 351... Line 337...
351
        jz      .fail
337
        jz      .fail
352
 
338
 
353
     if DEBUG
339
     if DEBUG
Line 366... Line 352...
366
        jz      .fail
352
        jz      .fail
Line 367... Line 353...
367
 
353
 
Line 368... Line 354...
368
        call    setup_codec
354
        call    setup_codec
369
 
355
 
370
        mov     esi, msgPrimBuff
356
        mov     esi, msgPrimBuff
371
        call    SysMsgBoardStr
357
        invoke  SysMsgBoardStr
372
        call    create_primary_buff
358
        call    create_primary_buff
Line 373... Line 359...
373
        mov     esi, msgDone
359
        mov     esi, msgDone
374
        call    SysMsgBoardStr
360
        invoke  SysMsgBoardStr
375
 
361
 
Line 397... Line 383...
397
        bts     ax, IRQ_LINE
383
        bts     ax, IRQ_LINE
398
        out     dx, al                          ;set level-triggered mode
384
        out     dx, al                          ;set level-triggered mode
399
        mov     [ctrl.int_line], IRQ_LINE
385
        mov     [ctrl.int_line], IRQ_LINE
400
        popf
386
        popf
401
        mov     esi, msgRemap
387
        mov     esi, msgRemap
402
        call    SysMsgBoardStr
388
        invoke  SysMsgBoardStr
403
  end if
389
  end if
Line 404... Line 390...
404
 
390
 
405
        mov     eax, VALID_IRQ
391
        mov     eax, VALID_IRQ
406
        mov     ebx, [ctrl.int_line]
392
        mov     ebx, [ctrl.int_line]
Line 410... Line 396...
410
        mov     eax, ATTCH_IRQ
396
        mov     eax, ATTCH_IRQ
411
        mov     esi, msgAttchIRQ
397
        mov     esi, msgAttchIRQ
412
        bt      eax, ebx
398
        bt      eax, ebx
413
        jnc     .fail_msg
399
        jnc     .fail_msg
Line 414... Line 400...
414
 
400
 
415
        stdcall AttachIntHandler, ebx, ac97_irq, dword 0
401
        invoke  AttachIntHandler, ebx, ac97_irq, dword 0
Line 416... Line 402...
416
        stdcall create
402
        stdcall create
417
 
403
 
418
.reg:
404
.reg:
419
        stdcall RegService, sz_sound_srv, service_proc
405
        invoke  RegService, sz_sound_srv, service_proc
420
        ret
406
        ret
421
.fail:
407
.fail:
422
     if DEBUG
408
     if DEBUG
423
        mov     esi, msgFail
409
        mov     esi, msgFail
424
        call    SysMsgBoardStr
410
        invoke  SysMsgBoardStr
425
     end if
411
     end if
426
        xor     eax, eax
412
        xor     eax, eax
427
        ret
413
        ret
428
.fail_msg:
414
.fail_msg:
429
        call    SysMsgBoardStr
415
        invoke  SysMsgBoardStr
430
        xor     eax, eax
416
        xor     eax, eax
431
        ret
417
        ret
432
.stop:
418
.stop:
Line 460... Line 446...
460
@@:
446
@@:
461
        cmp     eax, DEV_PLAY
447
        cmp     eax, DEV_PLAY
462
        jne     @F
448
        jne     @F
463
     if DEBUG
449
     if DEBUG
464
        mov     esi, msgPlay
450
        mov     esi, msgPlay
465
        call    SysMsgBoardStr
451
        invoke  SysMsgBoardStr
466
     end if
452
     end if
467
        call    play
453
        call    play
468
        ret
454
        ret
469
@@:
455
@@:
470
        cmp     eax, DEV_STOP
456
        cmp     eax, DEV_STOP
471
        jne     @F
457
        jne     @F
472
     if DEBUG
458
     if DEBUG
473
        mov     esi, msgStop
459
        mov     esi, msgStop
474
        call    SysMsgBoardStr
460
        invoke  SysMsgBoardStr
475
     end if
461
     end if
476
        call    stop
462
        call    stop
477
        ret
463
        ret
478
@@:
464
@@:
479
        cmp     eax, DEV_CALLBACK
465
        cmp     eax, DEV_CALLBACK
Line 541... Line 527...
541
 
527
 
542
 
528
 
Line 543... Line 529...
543
align 4
529
align 4
544
proc create_primary_buff
530
proc create_primary_buff
Line 545... Line 531...
545
 
531
 
546
        stdcall KernelAlloc, 0x10000
532
        invoke  KernelAlloc, 0x10000
547
        mov     [ctrl.buffer], eax
533
        mov     [ctrl.buffer], eax
548
 
534
 
549
        mov     edi, eax
535
        mov     edi, eax
Line 550... Line 536...
550
        mov     ecx, 0x10000/4
536
        mov     ecx, 0x10000/4
551
        xor     eax, eax
537
        xor     eax, eax
Line 552... Line 538...
552
        cld
538
        cld
553
        rep stosd
539
        rep stosd
554
 
540
 
555
        mov     eax, [ctrl.buffer]
541
        mov     eax, [ctrl.buffer]
Line 563... Line 549...
563
        mov     edi, buff_list
549
        mov     edi, buff_list
564
        mov     eax, [ctrl.buffer]
550
        mov     eax, [ctrl.buffer]
565
        stosd                        ;1.]
551
        stosd                        ;1.]
Line 566... Line 552...
566
 
552
 
567
        mov     eax, [ctrl.buffer]
553
        mov     eax, [ctrl.buffer]
Line 568... Line 554...
568
        call    GetPgAddr
554
        invoke  GetPgAddr
569
 
555
 
570
        stdcall ptr_write, PLAYBACK_POINTER, 0, 0
556
        stdcall ptr_write, PLAYBACK_POINTER, 0, 0
571
        stdcall ptr_write, PLAYBACK_UNKNOWN1, 0, 0
557
        stdcall ptr_write, PLAYBACK_UNKNOWN1, 0, 0
Line 572... Line 558...
572
        stdcall ptr_write, PLAYBACK_UNKNOWN2, 0, 0
558
        stdcall ptr_write, PLAYBACK_UNKNOWN2, 0, 0
573
        stdcall ptr_write, PLAYBACK_DMA_ADDR, 0, eax
559
        stdcall ptr_write, PLAYBACK_DMA_ADDR, 0, eax
574
 
560
 
575
        mov     eax, pcmout_bdl
561
        mov     eax, pcmout_bdl
576
        mov     ebx, eax
562
        mov     ebx, eax
Line 577... Line 563...
577
        call    GetPgAddr
563
        invoke  GetPgAddr
578
        and     ebx, 0xFFF
564
        and     ebx, 0xFFF
Line 599... Line 585...
599
           endl
585
           endl
Line 600... Line 586...
600
 
586
 
601
        xor     eax, eax
587
        xor     eax, eax
602
        mov     [bus], eax
588
        mov     [bus], eax
603
        inc     eax
589
        inc     eax
604
        call    PciApi
590
        invoke  PciApi
605
        cmp     eax, -1
591
        cmp     eax, -1
Line 606... Line 592...
606
        je      .err
592
        je      .err
Line 607... Line 593...
607
 
593
 
608
        mov     [last_bus], eax
594
        mov     [last_bus], eax
609
 
595
 
610
.next_bus:
596
.next_bus:
611
        and     [devfn], 0
597
        and     [devfn], 0
612
.next_dev:
598
.next_dev:
613
        stdcall PciRead32, [bus], [devfn], dword 0
599
        invoke  PciRead32, [bus], [devfn], dword 0
614
        test    eax, eax
600
        test    eax, eax
Line 668... Line 654...
668
endp
654
endp
Line 669... Line 655...
669
 
655
 
670
align 4
656
align 4
Line 671... Line 657...
671
proc init_controller
657
proc init_controller
672
 
658
 
673
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x2C
659
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x2C
674
        mov     esi, msgPciSubsys
660
        mov     esi, msgPciSubsys
675
        call    SysMsgBoardStr
661
        invoke  SysMsgBoardStr
Line 676... Line 662...
676
        call    dword2str
662
        call    dword2str
677
        call    SysMsgBoardStr
663
        invoke  SysMsgBoardStr
678
 
664
 
679
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
665
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
680
        mov     ebx, eax
666
        mov     ebx, eax
681
        and     eax, 0xFFFF
667
        and     eax, 0xFFFF
Line 682... Line 668...
682
        mov     [ctrl.pci_cmd], eax
668
        mov     [ctrl.pci_cmd], eax
683
        shr     ebx, 16
669
        shr     ebx, 16
684
        mov     [ctrl.pci_stat], ebx
670
        mov     [ctrl.pci_stat], ebx
685
 
671
 
Line 686... Line 672...
686
        mov     esi, msgPciCmd
672
        mov     esi, msgPciCmd
687
        call    SysMsgBoardStr
673
        invoke  SysMsgBoardStr
688
        call    dword2str
674
        call    dword2str
689
        call    SysMsgBoardStr
675
        invoke  SysMsgBoardStr
690
 
676
 
Line 691... Line 677...
691
        mov     esi, msgPciStat
677
        mov     esi, msgPciStat
692
        call    SysMsgBoardStr
678
        invoke  SysMsgBoardStr
693
        mov     eax, [ctrl.pci_stat]
679
        mov     eax, [ctrl.pci_stat]
694
        call    dword2str
680
        call    dword2str
695
        call    SysMsgBoardStr
681
        invoke  SysMsgBoardStr
Line 696... Line 682...
696
 
682
 
697
        mov     esi, msgCtrlIsaIo
683
        mov     esi, msgCtrlIsaIo
Line 698... Line 684...
698
        call    SysMsgBoardStr
684
        invoke  SysMsgBoardStr
699
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
685
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
700
        call    dword2str
686
        call    dword2str
701
        call    SysMsgBoardStr
687
        invoke  SysMsgBoardStr
702
 
688
 
Line 703... Line 689...
703
        and     eax, 0xFFC0
689
        and     eax, 0xFFC0
Line 751... Line 737...
751
             counter dd ?
737
             counter dd ?
752
           endl
738
           endl
Line 753... Line 739...
753
 
739
 
754
     if DEBUG
740
     if DEBUG
755
        mov     esi, msgCold
741
        mov     esi, msgCold
756
        call    SysMsgBoardStr
742
        invoke  SysMsgBoardStr
Line 757... Line 743...
757
     end if
743
     end if
758
 
744
 
Line 773... Line 759...
773
        dec     [counter]
759
        dec     [counter]
774
        jnz     .wait
760
        jnz     .wait
Line 775... Line 761...
775
 
761
 
776
     if DEBUG
762
     if DEBUG
777
        mov     esi, msgCRFail
763
        mov     esi, msgCRFail
778
        call    SysMsgBoardStr
764
        invoke  SysMsgBoardStr
Line 779... Line 765...
779
     end if
765
     end if
780
 
766
 
781
.fail:
767
.fail:
Line 849... Line 835...
849
endp
835
endp
Line 850... Line 836...
850
 
836
 
851
 
837
 
852
align 4
838
align 4
853
proc create stdcall
839
proc create stdcall
854
        stdcall PciRead16, [ctrl.bus], [ctrl.devfn], dword 4
840
        invoke  PciRead16, [ctrl.bus], [ctrl.devfn], 4
855
        test    eax, 4     ; test master bit
841
        test    eax, 4     ; test master bit
856
        jnz     @f
842
        jnz     @f
857
        or      eax, 4
843
        or      eax, 4
Line 858... Line 844...
858
        stdcall PciWrite16, [ctrl.bus], [ctrl.devfn], dword 4, eax     ; set master bit
844
        invoke  PciWrite16, [ctrl.bus], [ctrl.devfn], 4, eax     ; set master bit
859
         @@:
845
         @@:
860
 
846
 
Line 1115... Line 1101...
1115
align 4
1101
align 4
1116
devices dd (CTRL_CT0200 shl 16)+VID_Creative,msg_CT_EMU10K1X,set_Creative
1102
devices dd (CTRL_CT0200 shl 16)+VID_Creative,msg_CT_EMU10K1X,set_Creative
1117
        dd 0    ;terminator
1103
        dd 0    ;terminator
Line 1118... Line -...
1118
 
-
 
1119
 
-
 
1120
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
1104
 
1121
 
1105
 
Line 1122... Line 1106...
1122
msg_CT_EMU10K1X  db 'SB Live! Dell OEM', 13,10, 0
1106
msg_CT_EMU10K1X  db 'SB Live! Dell OEM', 13,10, 0
1123
msg_Creative     db 'Creative ', 0
1107
msg_Creative     db 'Creative ', 0
Line 1155... Line 1139...
1155
;msgMixIsaIo  db 'codec io base        ',0
1139
;msgMixIsaIo  db 'codec io base        ',0
1156
;msgCtrlMMIo  db 'controller mmio base ',0
1140
;msgCtrlMMIo  db 'controller mmio base ',0
1157
;msgMixMMIo   db 'codec mmio base      ',0
1141
;msgMixMMIo   db 'codec mmio base      ',0
1158
;msgIrqMap    db 'AC97 irq map as      ',0
1142
;msgIrqMap    db 'AC97 irq map as      ',0
Line -... Line 1143...
-
 
1143
 
-
 
1144
align 4
1159
 
1145
data fixups
Line -... Line 1146...
-
 
1146
end data
1160
section '.data' data readable writable align 16
1147
 
1161
 
1148
align 8
Line 1162... Line 1149...
1162
pcmout_bdl       rq 32
1149
pcmout_bdl       rq 32
1163
buff_list        rd 32
1150
buff_list        rd 32