forked from KolibriOS/kolibrios
sound.asm: additional debug otput
git-svn-id: svn://kolibrios.org@562 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b0980b5535
commit
e83f71a425
@ -31,7 +31,10 @@ proc detect_codec
|
||||
jne .next
|
||||
mov eax, [edi+4]
|
||||
mov [codec.ac_vendor_ids], eax
|
||||
mov esi, eax
|
||||
call SysMsgBoardStr
|
||||
stdcall detect_chip, [edi+8]
|
||||
|
||||
ret
|
||||
.next:
|
||||
add edi, 12
|
||||
@ -39,6 +42,12 @@ proc detect_codec
|
||||
.unknown:
|
||||
mov [codec.ac_vendor_ids], ac_unknown
|
||||
mov [codec.chip_ids], chip_unknown
|
||||
|
||||
mov esi, chip_unknown
|
||||
call SysMsgBoardStr
|
||||
mov eax, [codec.chip_id]
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -64,6 +73,11 @@ proc detect_chip stdcall, chip_tab:dword
|
||||
jmp @b
|
||||
.unknown:
|
||||
mov [codec.chip_ids], chip_unknown
|
||||
mov esi, chip_unknown
|
||||
call SysMsgBoardStr
|
||||
mov eax, [codec.chip_id]
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -93,7 +107,6 @@ proc setup_codec
|
||||
|
||||
|
||||
stdcall codec_read, dword CODEC_EXT_AUDIO_CTRL_REG
|
||||
|
||||
and eax, 0FFFFh - BIT1 ; clear DRA (BIT1)
|
||||
or eax, BIT0 ; set VRA (BIT0)
|
||||
stdcall codec_write, dword CODEC_EXT_AUDIO_CTRL_REG
|
||||
@ -101,7 +114,6 @@ proc setup_codec
|
||||
stdcall set_sample_rate, dword 48000
|
||||
|
||||
.init_error:
|
||||
|
||||
xor eax, eax ; exit with error
|
||||
ret
|
||||
endp
|
||||
@ -153,7 +165,7 @@ ac_unknown db 'unknown manufacturer',13,10,0
|
||||
ac_Realtek db 'Realtek Semiconductor',13,10,0
|
||||
ac_Analog db 'Analog Devices',13,10,0
|
||||
ac_CMedia db 'C-Media Electronics',13,10,0
|
||||
chip_unknown db 'unknown chip', 13,10,0
|
||||
chip_unknown db 'unknown codec id ', 0
|
||||
|
||||
CHIP_ANALOG equ 0x41445300
|
||||
CHIP_REALTEK equ 0x414C4700
|
||||
@ -177,7 +189,8 @@ chips_Analog dd 0x03, chip_AD1819
|
||||
dd 0x75, chip_AD1985
|
||||
dd 0
|
||||
|
||||
chips_Realtek dd 0x20, chip_ALC650
|
||||
chips_Realtek:
|
||||
dd 0x20, chip_ALC650
|
||||
dd 0x21, chip_ALC650D
|
||||
dd 0x22, chip_ALC650E
|
||||
dd 0x23, chip_ALC650F
|
||||
|
@ -16,13 +16,13 @@ API_VERSION equ 0x01000100
|
||||
DEBUG equ 1
|
||||
|
||||
REMAP_IRQ equ 0
|
||||
IRQ_LINE equ 0
|
||||
|
||||
;irq 0,1,2,8,12,13 íåäîñòóïíû
|
||||
; FEDCBA9876543210
|
||||
VALID_IRQ equ 1100111011111000b
|
||||
ATTCH_IRQ equ 0000111010101000b
|
||||
|
||||
IRQ_LINE equ 0
|
||||
|
||||
CPU_FREQ equ 2600d
|
||||
|
||||
@ -282,9 +282,6 @@ end virtual
|
||||
|
||||
EVENT_NOTIFY equ 0x00000200
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
SLOT_BASE equ OS_BASE+0x0080000
|
||||
|
||||
public START
|
||||
public service_proc
|
||||
public version
|
||||
@ -317,23 +314,15 @@ proc START stdcall, state:dword
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgInitCodec
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
; if DEBUG
|
||||
; mov esi, msgInitCodec
|
||||
; call SysMsgBoardStr
|
||||
; end if
|
||||
|
||||
call init_codec
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
if DEBUG
|
||||
mov esi, [codec.ac_vendor_ids]
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, [codec.chip_ids]
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
call reset_controller
|
||||
call setup_codec
|
||||
|
||||
@ -677,19 +666,19 @@ proc detect_controller
|
||||
mov esi, [edi+8]
|
||||
mov [ctrl.ctrl_setup], esi
|
||||
|
||||
cmp ebx, VID_INTEL
|
||||
cmp edx, VID_INTEL
|
||||
jne @F
|
||||
mov [ctrl.vendor_ids], msg_Intel
|
||||
ret
|
||||
@@:
|
||||
cmp ebx, VID_NVIDIA
|
||||
cmp edx, VID_NVIDIA
|
||||
jne @F
|
||||
mov [ctrl.vendor_ids], msg_NVidia
|
||||
@@:
|
||||
mov [ctrl.vendor_ids], 0 ;something wrong ?
|
||||
ret
|
||||
@@:
|
||||
.err:
|
||||
xor eax, eax
|
||||
mov [ctrl.vendor_ids], eax ;something wrong ?
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -742,20 +731,57 @@ proc init_controller
|
||||
shr ebx, 16
|
||||
mov [ctrl.pci_stat], ebx
|
||||
|
||||
mov esi, msgPciCmd
|
||||
call SysMsgBoardStr
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, msgPciStat
|
||||
call SysMsgBoardStr
|
||||
mov eax, [ctrl.pci_stat]
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, msgMixIsaIo
|
||||
call SysMsgBoardStr
|
||||
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
|
||||
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
and eax,0xFFFE
|
||||
mov [ctrl.codec_io_base], eax
|
||||
|
||||
mov esi, msgCtrlIsaIo
|
||||
call SysMsgBoardStr
|
||||
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
|
||||
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
and eax, 0xFFC0
|
||||
mov [ctrl.ctrl_io_base], eax
|
||||
|
||||
mov esi, msgMixMMIo
|
||||
call SysMsgBoardStr
|
||||
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
|
||||
mov [ctrl.codec_mem_base], eax
|
||||
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, msgCtrlMMIo
|
||||
call SysMsgBoardStr
|
||||
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
|
||||
mov [ctrl.ctrl_mem_base], eax
|
||||
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
|
||||
and eax, 0xFF
|
||||
mov [ctrl.int_line], eax
|
||||
@ -855,17 +881,21 @@ proc init_codec
|
||||
|
||||
mov edx, CTRL_STAT
|
||||
call [ctrl.ctrl_read32]
|
||||
|
||||
push eax
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
pop eax
|
||||
cmp eax, 0xFFFFFFFF
|
||||
je .err
|
||||
|
||||
test eax, CTRL_ST_CREADY
|
||||
jnz .ready
|
||||
|
||||
call reset_codec
|
||||
and eax, eax
|
||||
test eax, eax
|
||||
jz .err
|
||||
|
||||
.ready:
|
||||
xor edx, edx ;ac_reg_0
|
||||
call [ctrl.codec_write16]
|
||||
|
||||
@ -875,20 +905,21 @@ proc init_codec
|
||||
|
||||
mov [counter], 200 ; total 200*5 ms = 1s
|
||||
.wait:
|
||||
mov eax, 5000 ; wait 5 ms
|
||||
call StallExec
|
||||
|
||||
mov edx, CODEC_REG_POWERDOWN
|
||||
call [ctrl.codec_read16]
|
||||
and eax, 0x0F
|
||||
cmp eax, 0x0F
|
||||
jz .ready
|
||||
jz .done
|
||||
|
||||
mov eax, 5000 ; wait 5 ms
|
||||
call StallExec
|
||||
sub [counter] , 1
|
||||
jnz .wait
|
||||
.err:
|
||||
xor eax, eax ; timeout error
|
||||
ret
|
||||
.ready:
|
||||
.done:
|
||||
mov eax, 2 ;force set 16-bit 2-channel PCM
|
||||
mov edx, GLOB_CTRL
|
||||
call [ctrl.ctrl_write32]
|
||||
@ -953,30 +984,24 @@ proc warm_reset
|
||||
mov eax, 100000 ; wait 100 ms
|
||||
call StallExec
|
||||
|
||||
mov edx, GLOB_CTRL
|
||||
mov edx, CTRL_STAT
|
||||
call [ctrl.ctrl_read32]
|
||||
test eax, 4
|
||||
jz .ok
|
||||
sub [counter], 1
|
||||
test eax, CTRL_ST_CREADY
|
||||
jnz .ok
|
||||
|
||||
dec [counter]
|
||||
jnz .wait
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgWRFail
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
.fail:
|
||||
stc
|
||||
ret
|
||||
.ok:
|
||||
mov edx, CTRL_STAT
|
||||
call [ctrl.ctrl_read32]
|
||||
and eax, CTRL_ST_CREADY
|
||||
jz .fail
|
||||
clc
|
||||
ret
|
||||
.fail:
|
||||
stc
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
@ -985,7 +1010,7 @@ proc cold_reset
|
||||
counter dd ?
|
||||
endl
|
||||
|
||||
xor eax, eax
|
||||
mov eax, 0x02
|
||||
mov edx, GLOB_CTRL
|
||||
call [ctrl.ctrl_write32]
|
||||
|
||||
@ -994,41 +1019,54 @@ proc cold_reset
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
mov eax, 1000000 ; wait 1 s
|
||||
mov eax, 400000 ; wait 400 ms
|
||||
call StallExec
|
||||
|
||||
mov eax, 2
|
||||
mov edx, GLOB_CTRL
|
||||
call [ctrl.ctrl_write32]
|
||||
|
||||
mov [counter], 10 ; total 10*100 ms = 1s
|
||||
mov [counter], 16 ; total 20*100 ms = 2s
|
||||
.wait:
|
||||
|
||||
mov edx, CTRL_STAT
|
||||
call [ctrl.ctrl_read32]
|
||||
test eax, CTRL_ST_CREADY
|
||||
jnz .ok
|
||||
|
||||
mov eax, 100000 ; wait 100 ms
|
||||
call StallExec
|
||||
|
||||
mov edx, GLOB_CTRL
|
||||
call [ctrl.ctrl_read32]
|
||||
test eax, 4
|
||||
jz .ok
|
||||
sub [counter], 1
|
||||
dec [counter]
|
||||
jnz .wait
|
||||
|
||||
if DEBUG
|
||||
mov esi, msgCRFail
|
||||
call SysMsgBoardStr
|
||||
end if
|
||||
|
||||
.fail:
|
||||
stc
|
||||
ret
|
||||
.ok:
|
||||
mov esi, msgControl
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov edx, GLOB_CTRL
|
||||
call [ctrl.ctrl_read32]
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov esi, msgStatus
|
||||
call SysMsgBoardStr
|
||||
|
||||
mov edx, CTRL_STAT
|
||||
call [ctrl.ctrl_read32]
|
||||
and eax, CTRL_ST_CREADY
|
||||
push eax
|
||||
call dword2str
|
||||
call SysMsgBoardStr
|
||||
pop eax
|
||||
|
||||
test eax, CTRL_ST_CREADY
|
||||
jz .fail
|
||||
clc
|
||||
ret
|
||||
.fail:
|
||||
stc
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
@ -1383,15 +1421,15 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
|
||||
|
||||
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
||||
|
||||
msg_ICH db 'Intel ICH', 13,10, 0
|
||||
msg_ICH0 db 'Intel ICH0', 13,10, 0
|
||||
msg_ICH2 db 'Intel ICH2', 13,10, 0
|
||||
msg_ICH3 db 'Intel ICH3', 13,10, 0
|
||||
msg_ICH4 db 'Intel ICH4', 13,10, 0
|
||||
msg_ICH5 db 'Intel ICH5', 13,10, 0
|
||||
msg_ICH6 db 'Intel ICH6', 13,10, 0
|
||||
msg_ICH7 db 'Intel ICH7', 13,10, 0
|
||||
msg_Intel db 'Intel Corp. ', 0
|
||||
msg_ICH db '802801AA (ICH)', 13,10, 0
|
||||
msg_ICH0 db '802801AB (ICH0)', 13,10, 0
|
||||
msg_ICH2 db '802801BA (ICH2)', 13,10, 0
|
||||
msg_ICH3 db '802801CA (ICH3)', 13,10, 0
|
||||
msg_ICH4 db '802801DB (ICH4)', 13,10, 0
|
||||
msg_ICH5 db '802801EB (ICH5)', 13,10, 0
|
||||
msg_ICH6 db '802801FB (ICH6)', 13,10, 0
|
||||
msg_ICH7 db '802801GB (ICH7)', 13,10, 0
|
||||
msg_Intel db 'Intel ', 0
|
||||
|
||||
msg_NForce db 'NForce', 13,10, 0
|
||||
msg_NForce2 db 'NForce 2', 13,10, 0
|
||||
@ -1413,12 +1451,12 @@ msgAttchIRQ db 'IRQ line not supported', 13,10, 0
|
||||
msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0
|
||||
msgPlay db 'start play', 13,10,0
|
||||
msgStop db 'stop play', 13,10,0
|
||||
msgNotify db 'call notify',13,10,0
|
||||
msgIRQ db 'AC97 IRQ', 13,10,0
|
||||
;msgNotify db 'call notify',13,10,0
|
||||
;msgIRQ db 'AC97 IRQ', 13,10,0
|
||||
msgInitCtrl db 'init controller',13,10,0
|
||||
msgInitCodec db 'init codec',13,10,0
|
||||
;msgInitCodec db 'init codec',13,10,0
|
||||
msgPrimBuff db 'create primary buffer',13,10,0
|
||||
msgReg db 'set service handler',13,10,0
|
||||
;msgReg db 'set service handler',13,10,0
|
||||
msgOk db 'service installed',13,10,0
|
||||
msgCold db 'cold reset',13,10,0
|
||||
msgWarm db 'warm reset',13,10,0
|
||||
@ -1428,6 +1466,12 @@ msgCFail db 'codec not ready',13,10,0
|
||||
msgResetOk db 'reset complete',13,10,0
|
||||
msgStatus db 'global status ',0
|
||||
msgControl db 'global control ',0
|
||||
msgPciCmd db 'PCI command ',0
|
||||
msgPciStat db 'PCI status ',0
|
||||
msgCtrlIsaIo db 'controller io base ',0
|
||||
msgMixIsaIo db 'codec io base ',0
|
||||
msgCtrlMMIo db 'controller mmio base ',0
|
||||
msgMixMMIo db 'codec mmio base ',0
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user