Subversion Repositories Kolibri OS

Rev

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

Rev 4324 Rev 5048
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2012. 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
section '.flat' code readable writable executable
9
 
10
 
10
DEBUG		equ 1
11
DEBUG		equ 1
Line 11... Line 12...
11
FDEBUG		equ 0
12
FDEBUG		equ 0
-
 
13
DEBUG_IRQ	equ 0
Line 12... Line 14...
12
DEBUG_IRQ	equ 0
14
 
Line 13... Line 15...
13
 
15
USE_SINGLE_MODE equ  0	 ; 1 = Single mode; 0 = Normal mode.
14
USE_SINGLE_MODE   equ  0   ; 1 = Single mode; 0 = Normal mode.
16
USE_UNSOL_EV	equ  1	 ; 1 = Use unsolicited events; 0 = Do not use unsolicited events.
15
 
17
 
16
TEST_VERSION_NUMBER  equ '018e'
18
TEST_VERSION_NUMBER  equ '019'
17
 
19
 
18
;Asper+ [
20
;Asper+ [
Line 19... Line 21...
19
SDO_TAG  equ 1	      ;Asper: Output stream tag id (any number except 0)
21
SDO_TAG  equ 1	      ;Output stream tag id (any number except 0)
20
SDO_IDX  equ 4	      ;Asper: Output stream index
22
SDO_IDX  equ 4	      ;Output stream index
21
;According to "Intel® I/O Controller Hub 6 (ICH6) High Definition Audio / AC ’97 Programmer’s Reference Manual (PRM) May 2005 Document"
23
;According to "Intel® I/O Controller Hub 6 (ICH6) High Definition Audio / AC ’97 Programmer’s Reference Manual (PRM) May 2005 Document"
Line 22... Line -...
22
;and "Intel® I/O Controller Hub 6 (ICH6) Family Datasheet" SDO0=4,
-
 
23
;but according to "High Definition Audio Specification Revision 1.0a June 17, 2010" SDO0 depends on the number of SDIs.
-
 
24
 
-
 
25
SDO_INT  equ 1 shl SDO_IDX  ;Asper: Output stream interrupt (must be power of 2)
-
 
26
SDO_OFS  equ 0x80+(SDO_IDX*0x20) ;Asper: Output stream offset
-
 
27
;Asper+ ]
24
;and "Intel® I/O Controller Hub 6 (ICH6) Family Datasheet" SDO0=4,
28
 
25
;but according to "High Definition Audio Specification Revision 1.0a June 17, 2010" SDO0 depends on the number of SDIs.
29
include 'PROC32.INC'
26
 
Line 30... Line 27...
30
include 'IMPORTS.INC'
27
SDO_INT 	equ 1 shl SDO_IDX	;Output stream interrupt (must be power of 2)
Line 342... Line 339...
342
;Asper: Non standard system service. For the tests only! [
339
;Asper: Non standard system service. For the tests only! [
343
DEV_EXEC_CODEC_CMD	 equ  100
340
DEV_EXEC_CODEC_CMD	 equ  100
344
;Asper: Non standard system service. For the tests only! ]
341
;Asper: Non standard system service. For the tests only! ]
Line 345... Line 342...
345
 
342
 
-
 
343
struc AC_CNTRL		    ;AC controller base class
346
struc AC_CNTRL		    ;AC controller base class
344
{
347
{ .bus		      dd ?
345
	.bus		    dd ?
Line 348... Line 346...
348
  .devfn	      dd ?
346
	.devfn		    dd ?
349
 
347
 
350
  .vendor	      dw ?
348
	.vendor 	    dw ?
Line 375... Line 373...
375
 
373
 
376
  .ctrl_write8	      dd ?
374
	.ctrl_write8	    dd ?
377
  .ctrl_write16       dd ?
375
	.ctrl_write16	    dd ?
Line 378... Line -...
378
  .ctrl_write32       dd ?
-
 
379
 
376
	.ctrl_write32	    dd ?
380
;Asper+ [
377
 
381
    .codec_mask       dd ?
378
	.codec_mask	    dd ?
382
    .rb 	      dd ?
379
	.rb		    dd ?
383
    .rirb_rp	      dw 0
380
	.rirb_rp	    dw 0
Line 392... Line 389...
392
    .poll_count       db 0
389
	.poll_count	    db 0
393
    .posbuf	      dd ?
390
	.posbuf 	    dd ?
394
    .start_wallclk    dd ? ; start + minimum wallclk
391
	.start_wallclk	    dd ? ; start + minimum wallclk
395
    .period_wallclk   dd ? ; wallclk for period
392
	.period_wallclk     dd ? ; wallclk for period
396
    .position_fix     db ?
393
	.position_fix	    db ?
397
;Asper+ ]
-
 
398
}
394
}
Line 399... Line 395...
399
 
395
 
400
struc CODEC		   ;Audio Chip base class
396
struc CODEC		   ;Audio Chip base class
401
{
-
 
402
;Asper+ [
397
{
403
  .addr 	      dd ?    ; codec slot index (codec address)
398
	.addr		    dd ?    ; codec slot index (codec address)
404
  .afg		      dd ?    ; AFG node id
399
	.afg		    dd ?    ; AFG node id
Line 405... Line 400...
405
  .mfg		      dd ?    ; MFG node id
400
	.mfg		    dd ?    ; MFG node id
Line 417... Line 412...
417
 
412
 
418
  .init_pins	      dd ?    ; initial (BIOS) pin configurations
413
	.init_pins	    dd ?    ; initial (BIOS) pin configurations
419
  .num_pins	      dd ?    ;Asper +  : word is enough, but for align...
414
	.num_pins	    dd ?    ;Asper +  : word is enough, but for align...
420
  .beeper_nid	      dw ?
415
	.beeper_nid	    dw ?
421
		.pad  dw ?
-
 
Line 422... Line 416...
422
;Asper+ ]
416
		      .pad  dw ?
423
 
417
 
424
  .ac_vendor_ids      dd ?    ;ac vendor id string
418
	.ac_vendor_ids	    dd ?    ;ac vendor id string
Line 425... Line 419...
425
  .chip_ids	      dd ?    ;chip model string
419
	.chip_ids	    dd ?    ;chip model string
-
 
420
}
426
}
421
 
427
 
422
struc CTRL_INFO
428
struc CTRL_INFO
423
{
429
{   .pci_cmd	      dd ?
424
	.pci_cmd	    dd ?
430
    .irq	      dd ?
425
	.irq		    dd ?
431
    .glob_cntrl       dd ?
426
	.glob_cntrl	    dd ?
Line 436... Line 431...
436
    .ctrl_mem_base    dd ?
431
	.ctrl_mem_base	    dd ?
437
    .codec_id	      dd ?
432
	.codec_id	    dd ?
438
}
433
}
Line 439... Line 434...
439
 
434
 
-
 
435
struc IOCTL
440
struc IOCTL
436
{
441
{  .handle	      dd ?
437
	.handle 	    dd ?
442
   .io_code	      dd ?
438
	.io_code	    dd ?
443
   .input	      dd ?
439
	.input		    dd ?
444
   .inp_size	      dd ?
440
	.inp_size	    dd ?
445
   .output	      dd ?
441
	.output 	    dd ?
446
   .out_size	      dd ?
442
	.out_size	    dd ?
Line 447... Line -...
447
}
-
 
448
 
-
 
449
virtual at 0
-
 
450
  IOCTL IOCTL
-
 
451
end virtual
443
}
Line 452... Line 444...
452
 
444
 
453
EVENT_NOTIFY	equ 0x00000200
445
EVENT_NOTIFY	equ 0x00000200
454
 
446
 
Line 496... Line 488...
496
	mov	ebx, SPINLOCK_FREE
488
	mov	ebx, SPINLOCK_FREE
497
lock	xchg	[eax], ebx
489
	lock	xchg	[eax], ebx
498
	pop	ebx eax
490
	pop	ebx eax
499
}
491
}
Line 500... Line 492...
500
 
492
 
501
public START
-
 
502
public service_proc
493
data fixups
Line -... Line 494...
-
 
494
end data
-
 
495
 
-
 
496
include '../../struct.inc'
503
public version
497
include '../../macros.inc'
-
 
498
include '../../proc32.inc'
Line -... Line 499...
-
 
499
include '../../peimport.inc'
504
 
500
include 'CODEC_H.INC'
Line -... Line 501...
-
 
501
 
-
 
502
entry START
-
 
503
section '.flat' readable writable executable
-
 
504
 
-
 
505
;proc START stdcall, state:dword
-
 
506
proc START c, state:dword, cmdline:dword
-
 
507
	push	ebx esi ; save used registers to be stdcall
-
 
508
virtual at esp
-
 
509
		rd	2 ; saved registers
-
 
510
		dd	? ; return address
505
section '.flat' code readable align 16
511
.reason 	dd	? ; DRV_ENTRY or DRV_EXIT
506
 
512
.cmdline	dd	? ; normally NULL
Line 507... Line 513...
507
proc START stdcall, state:dword
513
end virtual
508
 
514
; 1. Check the reason for the call, do nothing unless initializing.
509
	   cmp [state], 1
515
	;cmp [.reason], DRV_ENTRY
Line 510... Line 516...
510
	   jne .stop
516
	;jne .stop
511
 
517
 
512
     if DEBUG
518
if DEBUG
Line 513... Line 519...
513
	   mov esi, msgTV
519
	mov	esi, msgTV
514
	   call SysMsgBoardStr
520
	invoke	SysMsgBoardStr
515
 
521
 
Line 516... Line 522...
516
	   mov esi, msgInit
522
	mov	esi, msgInit
517
	   call SysMsgBoardStr
523
	invoke	SysMsgBoardStr
518
     end if
524
end if
519
 
525
 
Line 520... Line 526...
520
	   call detect_controller
526
	call	detect_controller
521
	   test eax, eax
527
	test	eax, eax
522
	   jz .fail
528
	jz	.fail
Line 523... Line 529...
523
 
529
 
524
	   mov esi,[ctrl.vendor_ids]
-
 
525
	   call SysMsgBoardStr
530
	mov	esi,[ctrl.vendor_ids]
526
	   mov esi, [ctrl.ctrl_ids]
531
	invoke	SysMsgBoardStr
527
	   call SysMsgBoardStr
532
	mov	esi, [ctrl.ctrl_ids]
528
 
533
	invoke	SysMsgBoardStr
529
	   call init_controller
534
 
Line 552... Line 557...
552
	end if
557
end if
553
  @@:
558
@@:
554
;Asper ]
559
;Asper ]
Line 555... Line 560...
555
 
560
 
556
	   mov esi, msgPrimBuff
561
	mov	esi, msgPrimBuff
557
	   call SysMsgBoardStr
562
	invoke	SysMsgBoardStr
558
	   call create_primary_buff
563
	call	create_primary_buff
559
	   mov esi, msgDone
564
	mov	esi, msgDone
Line 560... Line 565...
560
	   call SysMsgBoardStr
565
	invoke	SysMsgBoardStr
561
 
566
 
562
  if IRQ_REMAP
567
if IRQ_REMAP
Line 569... Line 574...
569
	   in al, 0x21
574
	in	al, 0x21
570
	   test ebx, ebx
575
	test	ebx, ebx
571
	   jz .skip
576
	jz	.skip
572
	   bts ax, bx			   ;mask old line
577
	bts	ax, bx			;mask old line
573
.skip
578
.skip
574
	   bts ax, IRQ_LINE		   ;mask new ine
579
	bts	ax, IRQ_LINE		;mask new line
575
	   out 0x21, al
580
	out	0x21, al
576
	   mov al, ah
581
	mov	al, ah
577
	   out 0xA1, al
582
	out	0xA1, al
578
					   ;remap IRQ
583
					   ;remap IRQ
579
	   stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
584
	invoke	PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
Line 580... Line 585...
580
 
585
 
581
	   mov dx, 0x4d0		   ;8259 ELCR1
586
	mov	dx, 0x4d0		;8259 ELCR1
582
	   in al, dx
587
	in	al, dx
583
	   bts ax, IRQ_LINE
588
	bts	ax, IRQ_LINE
584
	   out dx, al			   ;set level-triggered mode
589
	out	dx, al			;set level-triggered mode
585
	   mov [ctrl.int_line], IRQ_LINE
590
	mov	[ctrl.int_line], IRQ_LINE
586
	   popf
591
	popf
587
	   mov esi, msgRemap
592
	mov	esi, msgRemap
588
	   call SysMsgBoardStr
593
	invoke	SysMsgBoardStr
Line 589... Line 594...
589
  end if
594
end if
590
 
595
 
Line 591... Line 596...
591
	   mov ebx, [ctrl.int_line]
596
	mov	ebx, [ctrl.int_line]
592
	   stdcall AttachIntHandler, ebx, hda_irq, dword 0
597
	invoke	AttachIntHandler, ebx, hda_irq, dword 0
593
 
598
 
594
;Asper This part is from "azx_probe" proc. [
599
;Asper This part is from "azx_probe" proc. [
Line 602... Line 607...
602
;] Asper
607
;] Asper
Line 603... Line 608...
603
 
608
 
604
	   ; create PCM streams
609
	; create PCM streams
605
;Asper+ [
610
;Asper+ [
606
	   mov	   eax, [spec.dac_node]
611
	mov	eax, [spec.dac_node]
607
   if DEBUG
612
if DEBUG ;-
608
       push  eax esi
613
	push	eax esi
609
       mov   esi, msgVal
614
	mov	esi, msgVal
610
       call  SysMsgBoardStr
615
	invoke	SysMsgBoardStr
611
       stdcall	fdword2str, 3
616
	stdcall  fdword2str, 3
612
       call  SysMsgBoardStr
617
	invoke	SysMsgBoardStr
613
       pop   esi eax
618
	pop	esi eax
Line 614... Line 619...
614
   end if
619
end if
615
 
620
 
616
	   test    eax, eax
621
	test	eax, eax
617
	   jz	   .fail
622
	jz	.fail
618
	   mov	   ebx, [spec.dac_node+4]
623
	mov	ebx, [spec.dac_node+4]
619
   if DEBUG
624
if DEBUG ;-
620
       push  eax esi
625
	push	eax esi
621
       mov   esi, msgVal
626
	mov	esi, msgVal
622
       call  SysMsgBoardStr
627
	invoke	SysMsgBoardStr
623
       mov	eax, [spec.dac_node+4]
628
	mov	eax, [spec.dac_node+4]
624
       stdcall	fdword2str, 3
629
	stdcall fdword2str, 3
625
       call  SysMsgBoardStr
630
	invoke	SysMsgBoardStr
Line 626... Line 631...
626
       pop   esi eax
631
	pop	esi eax
627
   end if
632
end if
Line 635... Line 640...
635
	   stdcall hda_codec_setup_stream, eax, SDO_TAG, 0, 0x11   ; Left & Right channels (Back panel)
640
	stdcall hda_codec_setup_stream, eax, SDO_TAG, 0, 0x11	; Left & Right channels (Back panel)
636
;Asper+ ]
641
;Asper+ ]
Line 637... Line 642...
637
 
642
 
638
   if USE_SINGLE_MODE
643
if USE_SINGLE_MODE
639
       mov   esi, msgSingleMode
644
	mov	esi, msgSingleMode
640
       call  SysMsgBoardStr
645
	invoke	SysMsgBoardStr
641
   else
646
else
642
       mov   esi, msgNormalMode
647
	mov	esi, msgNormalMode
643
       call  SysMsgBoardStr
648
	invoke	SysMsgBoardStr
Line 644... Line -...
644
   end if
-
 
645
 
649
end if
646
 
650
 
-
 
651
.reg:
647
.reg:
652
	invoke	RegService, sz_sound_srv, service_proc
648
	   stdcall RegService, sz_sound_srv, service_proc
653
	pop	esi ebx
649
	   ret
654
	ret
650
.fail:
655
.fail:
651
	   mov esi, msgFail
656
	mov	esi, msgFail
-
 
657
.fail_msg:
652
.fail_msg:
658
	invoke	SysMsgBoardStr
653
	   call SysMsgBoardStr
659
	pop	esi ebx
654
	   xor eax, eax
660
	xor	eax, eax
655
	   ret
661
	ret
-
 
662
.stop:
656
.stop:
663
	call	stop
657
	   call stop
664
	pop	esi ebx
658
	   xor eax, eax
665
	xor	eax, eax
Line 659... Line 666...
659
	   ret
666
	ret
Line 684... Line 691...
684
@@:
691
@@:
685
	   cmp eax, DEV_PLAY
692
	cmp	eax, DEV_PLAY
686
	   jne @F
693
	jne	@F
687
     if DEBUG
694
if DEBUG
688
	   mov esi, msgPlay
695
	mov	esi, msgPlay
689
	   call SysMsgBoardStr
696
	invoke	SysMsgBoardStr
690
     end if
697
end if
691
	   call    play
698
	call	play
692
	   xor	   eax, eax
699
	xor	eax, eax
693
	   ret
700
	ret
694
@@:
701
@@:
695
	   cmp eax, DEV_STOP
702
	cmp	eax, DEV_STOP
696
	   jne @F
703
	jne	@F
697
     if DEBUG
704
if DEBUG
698
	   mov esi, msgStop
705
	mov	esi, msgStop
699
	   call SysMsgBoardStr
706
	invoke	SysMsgBoardStr
700
     end if
707
end if
701
	   call    stop
708
	call	stop
702
	   xor	   eax, eax
709
	xor	eax, eax
703
	   ret
710
	ret
704
@@:
711
@@:
Line 742... Line 749...
742
@@:
749
@@:
743
;           cmp eax, DEV_SET_CHANNEL_VOLUME
750
;        cmp     eax, DEV_SET_CHANNEL_VOLUME
744
;           jne @f
751
;        jne     @f
745
;     if DEBUG
752
;if DEBUG
746
;           mov esi, msgSetChannelVolume
753
;        mov     esi, msgSetChannelVolume
747
;           call SysMsgBoardStr
754
;        invoke  SysMsgBoardStr
748
;     end if
755
;end if
749
;           mov      ebx, [edi+input]
756
;        mov      ebx, [edi+input]
750
;           mov      cl,  byte [ebx]      ; cl=channel
757
;        mov      cl,  byte [ebx]      ; cl=channel
751
;           mov      eax, dword [ebx+1]   ; eax=volume in Db
758
;        mov      eax, dword [ebx+1]   ; eax=volume in Db
752
;     if DEBUG
759
;if DEBUG
753
;           push    eax esi
760
;        push    eax esi
754
;           mov     esi, msgYAHOO1
761
;        mov     esi, msgYAHOO1
755
;           call    SysMsgBoardStr
762
;        invoke  SysMsgBoardStr
756
;           stdcall fdword2str, 1
763
;        stdcall fdword2str, 1
757
;           call    SysMsgBoardStr
764
;        invoke  SysMsgBoardStr
758
;           mov     esi, strSemicolon
765
;        mov     esi, strSemicolon
759
;           call    SysMsgBoardStr
766
;        invoke  SysMsgBoardStr
760
;           movzx   eax, cl
767
;        movzx   eax, cl
761
;           stdcall fdword2str, 3
768
;        stdcall fdword2str, 3
762
;           call    SysMsgBoardStr
769
;        invoke  SysMsgBoardStr
763
;           pop     esi eax
770
;        pop     esi eax
764
;     end if
771
;end if
765
;
-
 
766
;           call    set_channel_volume
772
;    ;        call    set_channel_volume
767
;           xor     eax, eax
773
;        xor     eax, eax
768
;           ret
774
;        ret
769
;@@:
775
;@@:
770
;           cmp     eax, DEV_GET_CHANNEL_VOLUME
776
;        cmp     eax, DEV_GET_CHANNEL_VOLUME
771
;           jne     @f
777
;        jne     @f
Line 788... Line 794...
788
	   xor	    eax, eax
794
	xor	 eax, eax
789
	   ret
795
	ret
790
@@:
796
@@:
791
;Asper: Non standard system service. For the tests only! ]
797
;Asper: Non standard system service. For the tests only! ]
Line 792... Line -...
792
 
-
 
793
 
798
 
794
.fail:
799
.fail:
795
	   or eax, -1
800
	or	 eax, -1
796
	   ret
801
	ret
Line 808... Line 813...
808
proc hda_irq   ;+
813
proc hda_irq   ;+
809
	   spin_lock
814
	spin_lock
810
     if DEBUG_IRQ
815
if DEBUG_IRQ
811
	   push eax esi
816
	push	eax esi
812
	   ;mov esi, msgIRQ
817
	;mov     esi, msgIRQ
813
	   ;call SysMsgBoardStr
818
	;invoke  SysMsgBoardStr
814
	   call GetTimerTicks
819
	call	GetTimerTicks
815
	   stdcall  fdword2str, 2
820
	stdcall fdword2str, 2
816
	   call SysMsgBoardStr
821
	invoke	SysMsgBoardStr
817
	   pop	esi eax
822
	pop	esi eax
818
     end if
823
end if
819
	   mov	 edx, ICH6_REG_INTSTS
824
	mov	edx, ICH6_REG_INTSTS
820
	   call  azx_readl
825
	call	azx_readl
821
	   test  eax, eax
826
	test	eax, eax
Line 846... Line 851...
846
 
851
 
847
	   mov	 ebx, dword [buff_list+eax*4]
852
	mov	ebx, dword [buff_list+eax*4]
848
	   cmp	 [ctrl.user_callback], 0
853
	cmp	[ctrl.user_callback], 0
849
	   je	 @f
854
	je	@f
850
	   stdcall [ctrl.user_callback], ebx
-
 
851
 
855
	stdcall [ctrl.user_callback], ebx
852
  @@:
-
 
853
 
856
@@:
854
	   ; clear rirb int
857
	; clear rirb int
855
	   mov	 edx, ICH6_REG_RIRBSTS
858
	mov	edx, ICH6_REG_RIRBSTS
Line 856... Line 859...
856
	   call  azx_readb
859
	call	azx_readb
Line 863... Line 866...
863
	   cmp	 byte [driver_type], AZX_DRIVER_CTX
866
	cmp	byte [driver_type], AZX_DRIVER_CTX
864
	   jne	 @f
867
	jne	@f
865
	   mov	 eax, 80    ; wait 80 us
868
	mov	eax, 80    ; wait 80 us
866
	   call  StallExec
869
	call	StallExec
867
  @@:
870
@@:
868
 
-
 
869
	   call  azx_update_rirb
871
	call	azx_update_rirb
870
  .l2:
872
.l2:
871
	   mov	  al, RIRB_INT_MASK
873
	mov	al, RIRB_INT_MASK
872
	   mov	 edx, ICH6_REG_RIRBSTS
874
	mov	edx, ICH6_REG_RIRBSTS
873
	   call  azx_writeb
875
	call	azx_writeb
Line 892... Line 894...
892
 
894
 
893
 
895
 
Line 894... Line 896...
894
align 4
896
align 4
895
proc create_primary_buff
897
proc create_primary_buff
Line 896... Line 898...
896
 
898
 
897
	   stdcall KernelAlloc, 4096
899
	invoke	KernelAlloc, 4096
Line 898... Line 900...
898
	   mov [ctrl.posbuf], eax
900
	mov	[ctrl.posbuf], eax
899
 
901
 
900
	   stdcall KernelAlloc, 0x10000 ;0x8000
902
	invoke	KernelAlloc, 0x10000 ;0x8000
901
	   mov [ctrl.buffer], eax
903
	mov	[ctrl.buffer], eax
902
 
904
 
Line 903... Line -...
903
	   mov edi, eax
-
 
904
	   mov ecx, 0x10000/4 ;0x8000/4
905
	mov	edi, eax
905
	   xor eax, eax
906
	mov	ecx, 0x10000/4 ;0x8000/4
Line 906... Line 907...
906
	   cld
907
	xor	eax, eax
907
	   rep stosd
908
	cld
908
 
909
	rep	stosd
909
 
910
 
910
	   stdcall KernelAlloc, 4096
911
	invoke	KernelAlloc, 4096
Line 911... Line -...
911
	   mov [pcmout_bdl], eax
-
 
912
 
912
	mov	[pcmout_bdl], eax
913
	   mov edi, eax
913
 
914
	   mov ecx, 4096/4
914
	mov	edi, eax
915
	   xor eax, eax
915
	mov	ecx, 4096/4
916
	   cld
916
	xor	eax, eax
Line 926... Line 926...
926
	   call  azx_writel
926
	call	azx_writel
Line 927... Line 927...
927
 
927
 
928
	   ; program the initial BDL entries
928
	; program the initial BDL entries
929
	   mov eax, [ctrl.buffer]
929
	mov	eax, [ctrl.buffer]
930
	   mov ebx, eax
930
	mov	ebx, eax
931
	   call GetPgAddr
931
	invoke	GetPgAddr
932
	   and	 ebx, 0xFFF
932
	and	ebx, 0xFFF
Line 933... Line -...
933
	   add	 eax, ebx
-
 
934
 
933
	add	eax, ebx
935
 
934
 
936
	   mov ebx, 0x4000 ;buffer size
935
	mov	ebx, 0x4000 ;buffer size
937
	   mov ecx, 8	   ;number of periods
936
	mov	ecx, 8	    ;number of periods
938
	   mov edi, [pcmout_bdl] ;pcmout_bdl
937
	mov	edi, [pcmout_bdl] ;pcmout_bdl
Line 946... Line 945...
946
	   ; program the size field of the BDL entry
945
	; program the size field of the BDL entry
947
	   mov dword [edi+8],  ebx
946
	mov	dword [edi+8],	ebx
948
	   ; program the IOC to enable interrupt when buffer completes
947
	; program the IOC to enable interrupt when buffer completes
949
	   mov dword [edi+12], 0x01
948
	mov	dword [edi+12], 0x01
Line 950... Line -...
950
 
-
 
951
 
949
 
952
	   add	eax, ebx
950
	add	eax, ebx
953
	   add	edi, 16
951
	add	edi, 16
954
	   dec	ecx
952
	dec	ecx
Line 955... Line 953...
955
	   jnz	.next_bdl
953
	jnz	.next_bdl
956
 
954
 
957
	   pop	ecx eax
955
	pop	ecx eax
Line 958... Line -...
958
	   dec	ecx
-
 
959
	   jnz	.next_period
956
	dec	ecx
960
 
957
	jnz	.next_period
961
 
958
 
962
	   mov edi, buff_list
959
	mov	edi, buff_list
963
	   mov eax, [ctrl.buffer]
960
	mov	eax, [ctrl.buffer]
Line 989... Line 986...
989
	   locals
986
locals
990
	     last_bus dd ?
987
	last_bus dd ?
991
	     bus      dd ?
988
	bus	 dd ?
992
	     devfn    dd ?
989
	devfn	 dd ?
993
	   endl
990
endl
994
 
-
 
995
	   xor eax, eax
991
	xor	eax, eax
996
	   mov [bus], eax
992
	mov	[bus], eax
997
	   inc eax
993
	inc	eax
998
	   call PciApi
994
	invoke	PciApi
999
	   cmp eax, -1
995
	cmp	eax, -1
1000
	   je .err
996
	je	.err
Line 1001... Line 997...
1001
 
997
 
Line 1002... Line 998...
1002
	   mov [last_bus], eax
998
	mov	[last_bus], eax
1003
 
999
 
1004
  .next_bus:
1000
.next_bus:
1005
	   and [devfn], 0
1001
	and	[devfn], 0
1006
  .next_dev:
1002
.next_dev:
1007
	   stdcall PciRead32, [bus], [devfn], dword 0
1003
	invoke	PciRead32, [bus], [devfn], dword 0
1008
	   test eax, eax
1004
	test	eax, eax
1009
	   jz .next
1005
	jz	.next
Line 1017... Line 1013...
1017
	   jz .next
1013
	jz	.next
Line 1018... Line 1014...
1018
 
1014
 
1019
	   cmp eax, ebx
1015
	cmp	eax, ebx
1020
	   je .found
1016
	je	.found
1021
	   add edi, 12
1017
	add	edi, 12
1022
	   jmp @B
1018
	jmp	@b
1023
  .next:
1019
.next:
1024
	   inc [devfn]
1020
	inc	[devfn]
1025
	   cmp [devfn], 256
1021
	cmp	[devfn], 256
1026
	   jb .next_dev
1022
	jb	.next_dev
Line 1046... Line 1042...
1046
 
1042
 
1047
	   mov ebx, [edi+4]
1043
	mov	ebx, [edi+4]
Line 1048... Line 1044...
1048
	   mov [ctrl.ctrl_ids], ebx
1044
	mov	[ctrl.ctrl_ids], ebx
1049
 
1045
 
1050
	   cmp edx, VID_INTEL
1046
	cmp	edx, VID_INTEL
1051
	   jne @F
1047
	jne	@f
1052
	   mov [ctrl.vendor_ids], msg_Intel
1048
	mov	[ctrl.vendor_ids], msg_Intel
1053
	   jmp .ok
1049
	jmp	.ok
1054
  @@:
1050
@@:
1055
	   cmp edx, VID_NVIDIA
1051
	cmp	edx, VID_NVIDIA
1056
	   jne @F
1052
	jne	@f
1057
	   mov [ctrl.vendor_ids], msg_NVidia
1053
	mov	[ctrl.vendor_ids], msg_NVidia
1058
	   jmp .ok
1054
	jmp	.ok
1059
  @@:
1055
@@:
1060
	   cmp edx, VID_ATI
1056
	cmp	edx, VID_ATI
1061
	   jne @F
1057
	jne	@f
1062
	   cmp eax, 0x4383
1058
	cmp	eax, 0x4383
1063
	   jg  .ati_hdmi
1059
	jg	.ati_hdmi
1064
	   mov [ctrl.vendor_ids], msg_ATI
1060
	mov	[ctrl.vendor_ids], msg_ATI
1065
	   jmp .ok
1061
	jmp	.ok
1066
  .ati_hdmi:
1062
.ati_hdmi:
1067
	   mov [ctrl.vendor_ids], msg_ATI_HDMI
1063
	mov	[ctrl.vendor_ids], msg_ATI_HDMI
1068
	   jmp .ok
1064
	jmp	.ok
1069
  @@:
1065
@@:
1070
	   cmp edx, VID_AMD
1066
	cmp	edx, VID_AMD
1071
	   jne @F
1067
	jne	@f
1072
	   mov [ctrl.vendor_ids], msg_AMD
1068
	mov	[ctrl.vendor_ids], msg_AMD
1073
	   jmp .ok
1069
	jmp	.ok
1074
  @@:
1070
@@:
1075
	   cmp edx, VID_VIA
1071
	cmp	edx, VID_VIA
1076
	   jne @F
1072
	jne	@f
1077
	   mov [ctrl.vendor_ids], msg_VIA
1073
	mov	[ctrl.vendor_ids], msg_VIA
1078
	   jmp .ok
1074
	jmp	.ok
1079
  @@:
1075
@@:
1080
	   cmp edx, VID_SIS
1076
	cmp	edx, VID_SIS
1081
	   jne @F
1077
	jne	@f
1082
	   mov [ctrl.vendor_ids], msg_SIS
1078
	mov	[ctrl.vendor_ids], msg_SIS
1083
	   jmp .ok
1079
	jmp	.ok
1084
  @@:
1080
@@:
1085
	   cmp edx, VID_ULI
1081
	cmp	edx, VID_ULI
1086
	   jne @F
1082
	jne	@f
1087
	   mov [ctrl.vendor_ids], msg_ULI
1083
	mov	[ctrl.vendor_ids], msg_ULI
1088
	   jmp .ok
1084
	jmp	.ok
1089
  @@:
1085
@@:
1090
	   cmp edx, VID_TERA
1086
	cmp	edx, VID_TERA
1091
	   jne @F
1087
	jne	@f
1092
	   mov [ctrl.vendor_ids], msg_TERA
1088
	mov	[ctrl.vendor_ids], msg_TERA
1093
	   jmp .ok
1089
	jmp	.ok
1094
  @@:
1090
@@:
1095
	   cmp edx, VID_CREATIVE
1091
	cmp	edx, VID_CREATIVE
1096
	   jne @F
1092
	jne	@f
1097
	   mov [ctrl.vendor_ids], msg_CREATIVE
1093
	mov	[ctrl.vendor_ids], msg_CREATIVE
1098
	   jmp .ok
1094
	jmp	.ok
1099
  @@:
1095
@@:
1100
	   cmp edx, VID_RDC
1096
	cmp	edx, VID_RDC
1101
	   jne @F
1097
	jne	@f
1102
	   mov [ctrl.vendor_ids], msg_RDC
1098
	mov	[ctrl.vendor_ids], msg_RDC
1103
	   jmp .ok
1099
	jmp	.ok
1104
  @@:
1100
@@:
1105
	   cmp edx, VID_VMWARE
1101
	cmp	edx, VID_VMWARE
1106
	   jne @F
1102
	jne	@f
1107
	   mov [ctrl.vendor_ids], msg_VMWARE
1103
	mov	[ctrl.vendor_ids], msg_VMWARE
1108
	   jmp .ok
1104
	jmp	.ok
1109
  @@:
1105
@@:
Line 1119... Line 1115...
1119
endp
1115
endp
Line 1120... Line 1116...
1120
 
1116
 
1121
align 4
1117
align 4
Line 1122... Line 1118...
1122
proc init_controller
1118
proc init_controller
1123
 
1119
 
1124
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1120
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1125
	   test eax, 0x4 ; Test Master bit
1121
	test	eax, 0x4 ; Test Master bit
1126
	   jnz	@f
1122
	jnz	@f
1127
	   or	eax, 0x4 ; Set Master bit
1123
	or	eax, 0x4 ; Set Master bit
1128
	   stdcall PciWrite32, [ctrl.bus], [ctrl.devfn], dword 4, eax
1124
	invoke	PciWrite32, [ctrl.bus], [ctrl.devfn], dword 4, eax
1129
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
-
 
1130
  @@:
1125
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
1131
 
1126
@@:
1132
	   mov ebx, eax
1127
	mov	ebx, eax
1133
	   and eax, 0xFFFF
1128
	and	eax, 0xFFFF
1134
	   mov [ctrl.pci_cmd], eax
1129
	mov	[ctrl.pci_cmd], eax
Line 1135... Line 1130...
1135
	   shr ebx, 16
1130
	shr	ebx, 16
1136
	   mov [ctrl.pci_stat], ebx
1131
	mov	[ctrl.pci_stat], ebx
1137
 
1132
 
1138
	   mov esi, msgPciCmd
1133
	mov	esi, msgPciCmd
Line 1139... Line 1134...
1139
	   call SysMsgBoardStr
1134
	invoke	SysMsgBoardStr
1140
	   stdcall  fdword2str, 2
1135
	stdcall fdword2str, 2
1141
	   call SysMsgBoardStr
1136
	invoke	SysMsgBoardStr
1142
 
1137
 
1143
	   mov esi, msgPciStat
1138
	mov	esi, msgPciStat
Line 1144... Line 1139...
1144
	   call SysMsgBoardStr
1139
	invoke	SysMsgBoardStr
1145
	   mov eax, [ctrl.pci_stat]
1140
	mov	eax, [ctrl.pci_stat]
1146
	   stdcall  fdword2str, 2
1141
	stdcall fdword2str, 2
1147
	   call SysMsgBoardStr
1142
	invoke	SysMsgBoardStr
1148
 
1143
 
Line 1149... Line 1144...
1149
	   mov esi, msgHDALowMMIo
1144
	mov	esi, msgHDALowMMIo
1150
	   call SysMsgBoardStr
1145
	invoke	SysMsgBoardStr
Line 1151... Line 1146...
1151
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
1146
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
1152
	   stdcall  fdword2str, 2
1147
	stdcall fdword2str, 2
1153
	   call SysMsgBoardStr
1148
	invoke	SysMsgBoardStr
1154
 
1149
 
1155
	   and eax, 0xFFFFC000
1150
	and	eax, 0xFFFFC000
1156
	   mov [ctrl.ctrl_mem_base], eax
1151
	mov	[ctrl.ctrl_mem_base], eax
Line 1157... Line 1152...
1157
 
1152
 
1158
	   mov esi, msgHDAUpMMIo
1153
	mov	esi, msgHDAUpMMIo
1159
	   call SysMsgBoardStr
1154
	invoke	SysMsgBoardStr
1160
	   stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
1155
	invoke	PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
1161
	   ;-mov [ctrl.hda_upper_mem_base], eax
1156
	;-mov     [ctrl.hda_upper_mem_base], eax
1162
	   stdcall  fdword2str, 2
1157
	stdcall fdword2str, 2
Line 1174... Line 1169...
1174
	   xor	   eax, eax
1169
	xor	eax, eax
1175
	   mov	   edx, ICH6_REG_GCAP
1170
	mov	edx, ICH6_REG_GCAP
1176
	   call    azx_readw
1171
	call	azx_readw
1177
	if DEBUG
1172
if DEBUG
1178
	   mov	   esi, msgGCap
1173
	mov	esi, msgGCap
1179
	   call    SysMsgBoardStr
1174
	invoke	SysMsgBoardStr
1180
	   stdcall fdword2str, 2
1175
	stdcall fdword2str, 2
1181
	   call    SysMsgBoardStr
1176
	invoke	SysMsgBoardStr
1182
	end if
1177
end if
1183
 
-
 
1184
	   ; allocate CORB/RIRB
1178
	; allocate CORB/RIRB
1185
	   call    azx_alloc_cmd_io
1179
	call	azx_alloc_cmd_io
Line 1186... Line 1180...
1186
 
1180
 
1187
	   ; initialize chip
1181
	; initialize chip
Line 1196... Line 1190...
1196
	   ret
1190
	ret
1197
endp
1191
endp
Line 1198... Line -...
1198
 
-
 
1199
 
1192
 
1200
 
1193
 
Line 1201... Line 1194...
1201
 
1194
 
1202
PG_SW		 equ 0x003
1195
PG_SW		equ 0x003
1203
PG_NOCACHE	 equ 0x018
-
 
1204
 
1196
PG_NOCACHE	equ 0x018
1205
align 4
1197
 
1206
proc set_HDA
1198
align 4
1207
 
1199
proc set_HDA
Line 1289... Line 1281...
1289
	   test  eax, eax
1281
	test	eax, eax
1290
	   jz	 .fail
1282
	jz	.fail
Line 1291... Line 1283...
1291
 
1283
 
1292
	   ; Accept unsolicited responses
1284
	; Accept unsolicited responses
1293
       if USE_SINGLE_MODE
1285
if USE_SINGLE_MODE
1294
       else
1286
else if USE_UNSOL_EV
1295
;UNSUPPORTED YET! [
1287
;UNSUPPORTED YET! [
1296
;           mov   edx, ICH6_REG_GCTL
1288
	mov	edx, ICH6_REG_GCTL
1297
;           call  azx_readl
1289
	call	azx_readl
1298
;           or    eax, ICH6_GCTL_UNSOL
1290
	or	eax, ICH6_GCTL_UNSOL
1299
;           mov   edx, ICH6_REG_GCTL
1291
	mov	edx, ICH6_REG_GCTL
1300
;           call  azx_writel
1292
	call	azx_writel
1301
;UNSUPPORTED YET! ]
1293
;UNSUPPORTED YET! ]
Line 1302... Line 1294...
1302
       end if
1294
end if
1303
 
1295
 
Line 1310... Line 1302...
1310
	   call  azx_readw
1302
	call	azx_readw
1311
	   mov	 [ctrl.codec_mask], eax
1303
	mov	[ctrl.codec_mask], eax
Line 1312... Line 1304...
1312
 
1304
 
1313
     if DEBUG
1305
if DEBUG
1314
	   mov	 esi, msgCodecMask
1306
	mov	esi, msgCodecMask
1315
	   call  SysMsgBoardStr
1307
	invoke	SysMsgBoardStr
1316
	   stdcall  fdword2str, 2
1308
	stdcall fdword2str, 2
1317
	   call  SysMsgBoardStr
1309
	invoke	SysMsgBoardStr
Line 1318... Line 1310...
1318
     end if
1310
end if
Line 1319... Line 1311...
1319
 
1311
 
1320
  @@:
1312
@@:
1321
 
1313
 
1322
  .ok:
1314
.ok:
1323
	   clc
1315
	clc
1324
	   ret
1316
	ret
1325
  .fail:
1317
.fail:
1326
     if DEBUG
1318
if DEBUG
1327
	   mov	 esi, msgHDARFail
1319
	mov	esi, msgHDARFail
1328
	   call  SysMsgBoardStr
1320
	invoke	SysMsgBoardStr
1329
     end if
1321
end if
Line 1388... Line 1380...
1388
	   xor	 eax, eax
1380
	xor	eax, eax
1389
	   spin_unlock_irq
1381
	spin_unlock_irq
1390
	   ret
1382
	ret
Line 1391... Line 1383...
1391
 
1383
 
1392
;align 4
1384
;align 4
1393
;proc get_dev_info stdcall, p_info:dword
1385
;proc get_dev_info stdcall, p_info:dword ;deprecated
1394
;           virtual at esi
1386
;virtual at esi
1395
;             CTRL_INFO CTRL_INFO
1387
;        CTRL_INFO CTRL_INFO
1396
;           end virtual
1388
;end virtual
1397
;
1389
;
Line 1436... Line 1428...
1436
;;;;;;;;;;;;;;;;;;;;;;;;;;;
1428
;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 1437... Line 1429...
1437
 
1429
 
1438
proc  azx_alloc_cmd_io
1430
proc azx_alloc_cmd_io
1439
	   push  eax ecx edx
1431
	push	eax ecx edx
1440
	   ; single page (at least 4096 bytes) must suffice for both ringbuffers
1432
	; single page (at least 4096 bytes) must suffice for both ringbuffers
1441
	   stdcall KernelAlloc, 4096
1433
	invoke	KernelAlloc, 4096
Line 1442... Line 1434...
1442
	   mov	 [ctrl.rb], eax
1434
	mov	[ctrl.rb], eax
1443
 
1435
 
1444
	   mov	 edi, eax
1436
	mov	edi, eax
Line 1455... Line 1447...
1455
	   spin_lock_irq
1447
	spin_lock_irq
1456
	   pusha
1448
	pusha
1457
	   ; CORB set up
1449
	; CORB set up
1458
	   mov	 eax, [ctrl.rb]
1450
	mov	eax, [ctrl.rb]
1459
	   mov	 ebx, eax
1451
	mov	ebx, eax
1460
	   call  GetPgAddr
1452
	invoke	GetPgAddr
1461
	   and	 ebx, 0xFFF
1453
	and	ebx, 0xFFF
1462
	   add	 eax, ebx
1454
	add	eax, ebx
1463
	   push  eax  ; save corb address
1455
	push	eax  ; save corb address
1464
	   mov	 edx, ICH6_REG_CORBLBASE
1456
	mov	edx, ICH6_REG_CORBLBASE
1465
	   call  azx_writel
1457
	call	azx_writel
Line 1613... Line 1605...
1613
	   jmp	 .l1
1605
	jmp	.l1
1614
  @@:
1606
@@:
1615
       if DEBUG
1607
if DEBUG
1616
	   push  esi
1608
	push	esi
1617
	   mov	 esi, msgSpuriousResponce
1609
	mov	esi, msgSpuriousResponce
1618
	   call  SysMsgBoardStr
1610
	invoke	SysMsgBoardStr
1619
	   pop	 esi
1611
	pop	esi
1620
       end if
1612
end if
1621
	   jmp	 .l1
1613
	jmp	.l1
1622
  .l3:
1614
.l3:
1623
	   mov	  [ctrl.rirb_rp], bx
1615
	mov	[ctrl.rirb_rp], bx
Line 1674... Line 1666...
1674
      cmp     al, 2
1666
	cmp	al, 2
1675
      jge     .poll_count_overflow
1667
	jge	.poll_count_overflow
1676
    if DEBUG
1668
if DEBUG
1677
      push    eax esi
1669
	push	eax esi
1678
      mov     esi, msgGetResponceTimeout
1670
	mov	esi, msgGetResponceTimeout
1679
      call    SysMsgBoardStr
1671
	invoke	SysMsgBoardStr
1680
      mov     esi, msgPollingCodecOnce
1672
	mov	esi, msgPollingCodecOnce
1681
      call    SysMsgBoardStr
1673
	invoke	SysMsgBoardStr
1682
      pop     esi eax
1674
	pop	esi eax
1683
    end if
1675
end if
1684
      mov     [do_poll], 1
1676
	mov	[do_poll], 1
1685
      inc     [ctrl.poll_count]
1677
	inc	[ctrl.poll_count]
1686
      jmp     .again
1678
	jmp	.again
Line 1687... Line 1679...
1687
 
1679
 
1688
  .poll_count_overflow:
1680
.poll_count_overflow:
1689
    if DEBUG
1681
if DEBUG
1690
      push    eax esi
1682
	push	eax esi
1691
      mov     esi, msgGetResponceTimeout
1683
	mov	esi, msgGetResponceTimeout
1692
      call    SysMsgBoardStr
1684
	invoke	SysMsgBoardStr
1693
      mov     esi, msgSwitchToPollMode
1685
	mov	esi, msgSwitchToPollMode
1694
      call    SysMsgBoardStr
1686
	invoke	SysMsgBoardStr
1695
      pop     esi eax
1687
	pop	esi eax
1696
    end if
1688
end if
1697
      mov     [ctrl.polling_mode], 1
1689
	mov	[ctrl.polling_mode], 1
Line 1704... Line 1696...
1704
      jz      @f
1696
	jz	@f
1705
      mov     eax, -1
1697
	mov	eax, -1
1706
      jmp     .out
1698
	jmp	.out
1707
  @@:
1699
@@:
Line 1708... Line -...
1708
 
-
 
1709
 
1700
 
1710
      ; a fatal communication error; need either to reset or to fallback
1701
	; a fatal communication error; need either to reset or to fallback
1711
      ; to the single_cmd mode
1702
	; to the single_cmd mode
1712
      mov     [ctrl.rirb_error], 1
1703
	mov	[ctrl.rirb_error], 1
1713
      ;Asper~ -?  [
1704
	;Asper~ -?  [
Line 1778... Line 1769...
1778
      if DEBUG
1769
if DEBUG
1779
	xor   eax, eax
1770
	xor	eax, eax
1780
	mov   edx, ICH6_REG_IRS
1771
	mov	edx, ICH6_REG_IRS
1781
	call  azx_readw
1772
	call	azx_readw
1782
	mov   esi, msgGetResponceTimeout
1773
	mov	esi, msgGetResponceTimeout
1783
	call  SysMsgBoardStr
1774
	invoke	SysMsgBoardStr
1784
	mov   esi, msgIRS
1775
	mov	esi, msgIRS
1785
	call  SysMsgBoardStr
1776
	invoke	SysMsgBoardStr
1786
	stdcall  fdword2str, 2
1777
	stdcall fdword2str, 2
1787
	call  SysMsgBoardStr
1778
	invoke	SysMsgBoardStr
1788
      end if
1779
end if
Line 1789... Line 1780...
1789
 
1780
 
1790
	pop   esi edx ecx
1781
	pop	esi edx ecx
1791
	mov   eax, -1
1782
	mov	eax, -1
Line 1834... Line 1825...
1834
      if DEBUG
1825
if DEBUG
1835
	xor    eax, eax
1826
	xor	eax, eax
1836
	mov    edx, ICH6_REG_IRS
1827
	mov	edx, ICH6_REG_IRS
1837
	call   azx_readw
1828
	call	azx_readw
1838
	mov    esi, msgSendCmdTimeout
1829
	mov	esi, msgSendCmdTimeout
1839
	call   SysMsgBoardStr
1830
	invoke	SysMsgBoardStr
1840
	stdcall  fdword2str, 2
1831
	stdcall fdword2str, 2
1841
	call   SysMsgBoardStr
1832
	invoke	SysMsgBoardStr
1842
	mov    esi, msgVal
1833
	mov	esi, msgVal
1843
	call   SysMsgBoardStr
1834
	invoke	SysMsgBoardStr
1844
	mov    eax, dword [val]
1835
	mov	eax, dword [val]
1845
	stdcall  fdword2str, 2
1836
	stdcall fdword2str, 2
1846
	call   SysMsgBoardStr
1837
	invoke	SysMsgBoardStr
1847
      end if
1838
end if
Line 1848... Line 1839...
1848
 
1839
 
1849
	pop    esi edx ecx
1840
	pop	esi edx ecx
1850
	mov    eax, -1
1841
	mov	eax, -1
Line 2039... Line 2030...
2039
	end if
2030
end if
Line 2040... Line 2031...
2040
 
2031
 
2041
	   ; program the position buffer
2032
	; program the position buffer
2042
	   mov	 eax, dword [ctrl.posbuf]
2033
	mov	eax, dword [ctrl.posbuf]
2043
	   mov	 ebx, eax
2034
	mov	ebx, eax
2044
	   call  GetPgAddr
2035
	invoke	GetPgAddr
2045
	   and	 ebx, 0xFFF
2036
	and	ebx, 0xFFF
2046
	   add	 eax, ebx
2037
	add	eax, ebx
2047
	   mov	 edx, ICH6_REG_DPLBASE
2038
	mov	edx, ICH6_REG_DPLBASE
2048
	   call  azx_writel
2039
	call	azx_writel
Line 2058... Line 2049...
2058
; initialize the PCI registers
2049
; initialize the PCI registers
Line 2059... Line 2050...
2059
 
2050
 
2060
; update bits in a PCI register byte
2051
; update bits in a PCI register byte
2061
proc   update_pci_byte	stdcall, reg:dword, mask:dword, val:dword
2052
proc update_pci_byte  stdcall, reg:dword, mask:dword, val:dword
2062
	   push  ax bx
2053
	push	ax bx
2063
	   stdcall  PciRead8,  [ctrl.bus], [ctrl.devfn], [reg]
2054
	invoke	PciRead8, [ctrl.bus], [ctrl.devfn], [reg]
2064
	   mov	 bl, byte [mask]
2055
	mov	bl, byte [mask]
2065
	   mov	 bh, bl
2056
	mov	bh, bl
2066
	   xor	 bl, -1
2057
	xor	bl, -1
2067
	   and	 al, bl
2058
	and	al, bl
2068
	   shr	 bx, 8
2059
	shr	bx, 8
2069
	   and	 bl, byte [val]
2060
	and	bl, byte [val]
2070
	   or	 al, bl
2061
	or	al, bl
2071
	   stdcall  PciWrite8, [ctrl.bus], [ctrl.devfn], [reg], eax
2062
	invoke	PciWrite8, [ctrl.bus], [ctrl.devfn], [reg], eax
2072
	   pop	 bx ax
2063
	pop	bx ax
2073
	   ret
2064
	ret
Line 2100... Line 2091...
2100
	   cmp	 eax, AZX_DRIVER_SCH
2091
	cmp	eax, AZX_DRIVER_SCH
2101
	   je	 .l1
2092
	je	.l1
2102
	   cmp	 eax, AZX_DRIVER_PCH
2093
	cmp	eax, AZX_DRIVER_PCH
2103
	   jne	 @f
2094
	jne	@f
2104
  .l1:
2095
.l1:
2105
	   stdcall  PciRead16,	[ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2096
	invoke	PciRead16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2106
	   test   ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2097
	test	ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2107
	   jz	  @f
2098
	jz	@f
2108
	   push   ebx
2099
	push	ebx
2109
	   mov	  ebx, INTEL_SCH_HDA_DEVC_NOSNOOP
2100
	mov	ebx, INTEL_SCH_HDA_DEVC_NOSNOOP
2110
	   xor	  ebx, -1
2101
	xor	ebx, -1
2111
	   and	  eax, ebx
2102
	and	eax, ebx
2112
	   pop	  ebx
2103
	pop	ebx
2113
	   stdcall  PciWrite16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC, eax
2104
	invoke	PciWrite16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC, eax
2114
	   stdcall  PciRead16,	[ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
2105
	invoke	PciRead16,  [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
Line 2115... Line 2106...
2115
 
2106
 
2116
       if DEBUG
2107
if DEBUG
2117
	   push  esi
2108
	push	esi
2118
	   mov	 esi, msgHDASnoopDisabled
2109
	mov	esi, msgHDASnoopDisabled
2119
	   call  SysMsgBoardStr
2110
	invoke	SysMsgBoardStr
2120
	   mov	 esi, msg_OK
2111
	mov	esi, msg_OK
2121
	   test   ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2112
	test	ax, INTEL_SCH_HDA_DEVC_NOSNOOP
2122
	   jz	 .snoop_ok
2113
	jz	.snoop_ok
2123
	   mov	 esi, msg_Fail
2114
	mov	esi, msg_Fail
2124
	 .snoop_ok:
2115
.snoop_ok:
2125
	   call  SysMsgBoardStr
2116
	invoke	SysMsgBoardStr
2126
	   pop	 esi
2117
	pop	esi
2127
       end if
2118
end if
2128
  @@:
2119
@@:
2129
  .done:
2120
.done:
Line 2221... Line 2212...
2221
 
2212
 
2222
	   ; program the BDL address
2213
	; program the BDL address
2223
	   ; lower BDL address
2214
	; lower BDL address
2224
	   mov	 eax, [pcmout_bdl]
2215
	mov	eax, [pcmout_bdl]
2225
	   mov	 ebx, eax
2216
	mov	ebx, eax
2226
	   call  GetPgAddr
2217
	invoke	GetPgAddr
2227
	   and	 ebx, 0xFFF
2218
	and	ebx, 0xFFF
2228
	   add	 eax, ebx
2219
	add	eax, ebx
2229
	   mov	 edx, ICH6_REG_SD_BDLPL + SDO_OFS
2220
	mov	edx, ICH6_REG_SD_BDLPL + SDO_OFS
2230
	   call  azx_writel
2221
	call	azx_writel
Line 2240... Line 2231...
2240
	   call  azx_readl
2231
	call	azx_readl
2241
	   and	 eax, ICH6_DPLBASE_ENABLE
2232
	and	eax, ICH6_DPLBASE_ENABLE
2242
	   jnz	 @f
2233
	jnz	@f
2243
	   mov	 eax, dword [ctrl.posbuf]
2234
	mov	eax, dword [ctrl.posbuf]
2244
	   mov	 ebx, eax
2235
	mov	ebx, eax
2245
	   call  GetPgAddr
2236
	invoke	GetPgAddr
2246
	   and	 ebx, 0xFFF
2237
	and	ebx, 0xFFF
2247
	   add	 eax, ebx
2238
	add	eax, ebx
2248
	   or	 eax, ICH6_DPLBASE_ENABLE
2239
	or	eax, ICH6_DPLBASE_ENABLE
2249
	   mov	 edx, ICH6_REG_DPLBASE
2240
	mov	edx, ICH6_REG_DPLBASE
2250
	   call  azx_writel
2241
	call	azx_writel
2251
  @@:
2242
@@:
2252
 
-
 
2253
	   ; set the interrupt enable bits in the descriptor control register
2243
	; set the interrupt enable bits in the descriptor control register
2254
	   mov	 edx, ICH6_REG_SD_CTL + SDO_OFS
2244
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
2255
	   call  azx_readl
2245
	call	azx_readl
2256
	   or	 eax, SD_INT_MASK
2246
	or	eax, SD_INT_MASK
2257
	   mov	 edx, ICH6_REG_SD_CTL + SDO_OFS
2247
	mov	edx, ICH6_REG_SD_CTL + SDO_OFS
Line 2279... Line 2269...
2279
	   mov	   eax, [addr]
2269
	mov	eax, [addr]
2280
	   mov	   [codec.addr], eax ;Asper+
2270
	mov	[codec.addr], eax ;Asper+
2281
	if DEBUG
2271
if DEBUG
2282
	   push    esi
2272
	push	esi
2283
	   mov	   esi, msgCodecOK
2273
	mov	esi, msgCodecOK
2284
	   call    SysMsgBoardStr
2274
	invoke	SysMsgBoardStr
2285
	   mov	   esi, msgCAd
2275
	mov	esi, msgCAd
2286
	   call    SysMsgBoardStr
2276
	invoke	SysMsgBoardStr
2287
	   stdcall  fdword2str, 3
2277
	stdcall fdword2str, 3
2288
	   call    SysMsgBoardStr
2278
	invoke	SysMsgBoardStr
2289
	   pop	   esi
2279
	pop	esi
2290
	end if
2280
end if
2291
	   xor	   eax, eax
2281
	xor	eax, eax
2292
  .out:
2282
.out:
2293
	   pop	   edx
2283
	pop	edx
Line 2317... Line 2307...
2317
	   test    eax, eax
2307
	test	eax, eax
2318
	   jz	   .init ;@f
2308
	jz	.init ;@f
2319
	   ; Some BIOSen give you wrong codec addresses that don't exist
2309
	; Some BIOSen give you wrong codec addresses that don't exist
2320
	if DEBUG
2310
if DEBUG
2321
	   mov	   esi, msgCodecError
2311
	mov	esi, msgCodecError
2322
	   call    SysMsgBoardStr
2312
	invoke	SysMsgBoardStr
2323
	end if
2313
end if
2324
	   mov	    ebx, edx
2314
	mov	ebx, edx
2325
	   xor	    ebx, -1
2315
	xor	ebx, -1
2326
	   and	    [ctrl.codec_mask], ebx
2316
	and	[ctrl.codec_mask], ebx
Line 2393... Line 2383...
2393
	   push  eax edx
2383
	push	eax edx
Line 2394... Line 2384...
2394
 
2384
 
2395
	   ; disable interrupts
2385
	; disable interrupts
2396
	   call  azx_int_disable
2386
	call	azx_int_disable
-
 
2387
	call	azx_int_clear
2397
	   call  azx_int_clear
2388
 
2398
	   ; disable CORB/RIRB
2389
	; disable CORB/RIRB
-
 
2390
	call	azx_free_cmd_io
2399
	   call  azx_free_cmd_io
2391
 
2400
	   ; disable position buffer
2392
	; disable position buffer
2401
	   xor	 eax, eax
2393
	xor	eax, eax
2402
	   mov	 edx, ICH6_REG_DPLBASE
2394
	mov	edx, ICH6_REG_DPLBASE
2403
	   call  azx_writel
2395
	call	azx_writel
2404
	   mov	 edx, ICH6_REG_DPUBASE
2396
	mov	edx, ICH6_REG_DPUBASE
2405
	   call  azx_writel
-
 
2406
 
2397
	call	azx_writel
2407
	   pop	 edx eax
2398
	pop	edx eax
2408
	   ret
2399
	ret
Line 2434... Line 2425...
2434
align 4
2425
align 4
2435
set_channel_volume:
2426
set_channel_volume:
2436
	   push  eax ebx ecx edx
2427
	push	eax ebx ecx edx
2437
	   mov	 ebx, [volume.maxDb]
2428
	mov	ebx, [volume.maxDb]
2438
	   neg	 eax
2429
	neg	eax
2439
     if 0;DEBUG ;YAHOO
2430
if DEBUG ;-
2440
	   push eax esi
2431
	push	eax esi
2441
	   mov	esi, msgNewVolume
2432
	mov	esi, msgNewVolume
2442
	   call SysMsgBoardStr
2433
	invoke	SysMsgBoardStr
2443
	   stdcall  fdword2str, 2
2434
	stdcall fdword2str, 2
2444
	   call SysMsgBoardStr
2435
	invoke	SysMsgBoardStr
Line 2445... Line 2436...
2445
 
2436
 
2446
	   mov	esi, msgMaxVolume
2437
	mov	esi, msgMinVolume
2447
	   call SysMsgBoardStr
2438
	invoke	SysMsgBoardStr
2448
	   mov	eax, ebx
2439
	mov	eax, ebx
2449
	   stdcall  fdword2str, 2
2440
	stdcall fdword2str, 2
2450
	   call SysMsgBoardStr
2441
	invoke	SysMsgBoardStr
2451
	   pop	esi eax
2442
	pop	esi eax
2452
     end if
2443
end if
2453
	   test  ebx, ebx
2444
	test	ebx, ebx
Line 2457... Line 2448...
2457
	   jg	 @f
2448
	jg	@f
2458
	   xor	 eax, eax
2449
	xor	eax, eax
2459
	   jmp	 .set
2450
	jmp	.set
2460
  @@:
2451
@@:
2461
	   cmp	 eax, ebx
2452
	cmp	eax, ebx
2462
	   jl	 .set
2453
	jng	.set
2463
	   mov	 eax, ebx
2454
	mov	eax, ebx
2464
  .set:
2455
.set:
-
 
2456
	sub	ebx, eax
-
 
2457
	mov	eax, ebx
2465
	   ;cdq
2458
	;cdq
2466
	   xor	 edx, edx
2459
	xor	edx, edx
2467
	   shl	 eax, 2
2460
	push	eax
-
 
2461
	movzx	eax, [volume.step_size]
-
 
2462
	imul	eax, (100/4)
2468
	   mov	 ebx, 100
2463
	mov	ebx, eax
2469
	   div	 bx
2464
	pop	eax
2470
	   mov	 bl, [volume.step_size]
2465
	xor	edx, edx
2471
	   div	 bl
2466
	idiv	ebx
Line 2472... Line 2467...
2472
 
2467
 
2473
	   mov	 edx, [volume.out_amp_node]
2468
	mov	edx, [volume.out_amp_node]
2474
	   test  edx, edx
2469
	test	edx, edx
2475
	   jz	 .out
2470
	jz	.out
Line 2484... Line 2479...
2484
	   stdcall put_volume_mute, ebx, 1, HDA_OUTPUT, 0, eax
2479
	stdcall put_volume_mute, ebx, 1, HDA_OUTPUT, 0, eax
2485
  .out:
2480
.out:
2486
	   pop	 edx ecx ebx eax
2481
	pop	edx ecx ebx eax
2487
	   ret
2482
	ret
2488
  .err_out:
2483
.err_out:
2489
       if 0;DEBUG  ;YAHOO
2484
if DEBUG  ;-
2490
	   push  esi
2485
	push	esi
2491
	   mov	 esi, emsgNoVolCtrl
2486
	mov	esi, emsgNoVolCtrl
2492
	   call  SysMsgBoardStr
2487
	invoke	SysMsgBoardStr
2493
	   pop	 esi
2488
	pop	esi
2494
       end if
2489
end if
2495
	   jmp	 .out
2490
	jmp	.out
Line 2496... Line 2491...
2496
 
2491
 
Line 2506... Line 2501...
2506
      mov     edx, [volume.out_amp_node]
2501
	mov	edx, [volume.out_amp_node]
2507
      test    edx, edx
2502
	test	edx, edx
2508
      jz      .out
2503
	jz	.out
2509
      movzx   ebx, [edx+HDA_GNODE.nid]
2504
	movzx	ebx, [edx+HDA_GNODE.nid]
2510
      stdcall get_volume_mute, ebx, ecx, HDA_OUTPUT, 0
2505
	stdcall get_volume_mute, ebx, ecx, HDA_OUTPUT, 0
-
 
2506
	and	eax, 0x7F ;get gain
2511
      mov     cl, [volume.step_size]
2507
	mov	cl, [volume.step_size]
2512
      mul     cl
2508
	mul	cl
2513
 
-
 
2514
      mov     cx, 100
-
 
2515
      mul     cx
-
 
2516
      shr     eax, 2 ; *0.25
2509
	imul	eax, (-100/4)
2517
      neg     eax
-
 
2518
  .out:
2510
.out:
2519
	   pop	   edx ecx ebx
2511
	pop	edx ecx ebx
2520
	   ret
2512
	ret
Line 2614... Line 2606...
2614
;Asper remember to add this functions:
2606
;Asper remember to add this functions:
2615
proc  snd_hda_queue_unsol_event stdcall, par1:dword, par2:dword
2607
proc  snd_hda_queue_unsol_event stdcall, par1:dword, par2:dword
2616
  if DEBUG
2608
if DEBUG
2617
	push	esi
2609
	push	esi
2618
	mov	esi, msgUnsolEvent
2610
	mov	esi, msgUnsolEvent
2619
	call	SysMsgBoardStr
2611
	invoke	SysMsgBoardStr
2620
	pop	esi
2612
	pop	esi
2621
  end if
2613
end if
-
 
2614
if USE_UNSOL_EV = 0
-
 
2615
	;Test. Do not make queue, process immediately!
-
 
2616
	;stdcall here snd_hda_read_pin_sense stdcall, nid:dword, trigger_sense:dword
-
 
2617
	;and then mute/unmute pin based on the results
-
 
2618
end if
2622
	ret
2619
	ret
2623
endp
2620
endp
2624
;...
2621
;...
Line 2943... Line 2940...
2943
    msgNormalMode	     db 'Normal mode !',13,10,0
2940
    msgNormalMode	     db 'Normal mode !',13,10,0
2944
end if
2941
end if
Line 2945... Line 2942...
2945
 
2942
 
2946
if DEBUG
2943
if DEBUG
2947
    msgYAHOO2		     db 'YAHOO2: ',0
2944
    msgYAHOO2		     db 'YAHOO2: ',0
2948
    msgMaxVolume	     db 'MaxVolume: ',0
2945
    msgMinVolume	     db 'MinVolume: ',0
Line 2949... Line 2946...
2949
    msgNewVolume	     db 'NewVolume: ',0
2946
    msgNewVolume	     db 'NewVolume: ',0
2950
 
2947
 
2951
    msgVerbQuery	     db 'Q: ',0
2948
    msgVerbQuery	     db 'Q: ',0
Line 2958... Line 2955...
2958
    msgAmpVal		     db 'Amp val = ',0
2955
    msgAmpVal		     db 'Amp val = ',0
2959
    msgEnableEAPD	     db 'Enable EAPD: NID=',0
2956
    msgEnableEAPD	     db 'Enable EAPD: NID=',0
2960
    msgBeeperNid	     db 'Beeper found: NID=',0
2957
    msgBeeperNid	     db 'Beeper found: NID=',0
2961
    msgBeeperValue	     db 'Beeper initial value: ',0
2958
    msgBeeperValue	     db 'Beeper initial value: ',0
2962
    msgBeepNow		     db 'Beep!',13,10,0
2959
    msgBeepNow		     db 'Beep!',13,10,0
-
 
2960
 
-
 
2961
    msgNodeSeq		     db 'Sequence of codec nodes:',13,10,0
-
 
2962
    msgNID		     db 'NID: 0x',0
2963
end if
2963
end if
Line 2964... Line 2964...
2964
 
2964
 
Line 2965... Line -...
2965
;] Asper
-
 
2966
 
-
 
2967
 
-
 
2968
section '.data' data readable writable align 16
2965
;] Asper
Line 2969... Line 2966...
2969
 
2966
 
2970
aspinlock	 dd SPINLOCK_FREE
2967
aspinlock	 dd SPINLOCK_FREE