update ensoniq

git-svn-id: svn://kolibrios.org@406 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-03-09 11:20:38 +00:00
parent 2ff588abea
commit 32d40918ac

View File

@ -5,6 +5,7 @@ format MS COFF
include 'proc32.inc' include 'proc32.inc'
include 'imports.inc'
DEBUG equ 1 DEBUG equ 1
@ -52,22 +53,6 @@ BIT29 EQU 0x20000000
BIT30 EQU 0x40000000 BIT30 EQU 0x40000000
BIT31 EQU 0x80000000 BIT31 EQU 0x80000000
VID_INTEL equ 0x8086
VID_NVIDIA equ 0x10DE
CTRL_ICH equ 0x2415
CTRL_ICH0 equ 0x2425
CTRL_ICH2 equ 0x2435
CTRL_ICH3 equ 0x2445
CTRL_ICH4 equ 0x24C5
CTRL_ICH5 equ 0x24D5
CTRL_ICH6 equ 0x266E
CTRL_ICH7 equ 0x27DE
CTRL_NFORCE equ 0x01B1
CTRL_NFORCE2 equ 0x006A
CTRL_NFORCE3 equ 0x00DA
PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list
PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register
@ -266,32 +251,23 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; 0x80400000 OS_BASE equ 0;
new_app_base equ 0x60400000; 0x01000000 SLOT_BASE equ OS_BASE+0x0080000
PROC_BASE equ OS_BASE+0x0080000 new_app_base equ 0x80000000
public START public START
public STOP
public service_proc public service_proc
public version
extrn AttachIntHandler
extrn SysMsgBoardStr
extrn PciApi
extrn PciRead32
extrn PciRead8
extrn PciWrite8
extrn AllocKernelSpace
extrn MapPage
extrn RegService
extrn KernelAlloc
extrn GetPgAddr
extrn GetCurrentTask
section '.flat' code readable align 16 section '.flat' code readable align 16
START: proc START stdcall, state:dword
cmp [state], 1
jne .stop
if DEBUG if DEBUG
mov esi, msgInit mov esi, msgDetect
call SysMsgBoardStr call SysMsgBoardStr
end if end if
@ -306,10 +282,11 @@ START:
call SysMsgBoardStr call SysMsgBoardStr
end if end if
call init_controller call init_controller
test eax, eax test eax, eax
jz .fail jz .fail
jmp .fail ;force fail
if DEBUG if DEBUG
mov esi, msgInitCodec mov esi, msgInitCodec
@ -336,16 +313,6 @@ START:
call create_primary_buff call create_primary_buff
; if REMAP_IRQ
; call get_LPC_bus
; cmp eax, -1
; jz .fail
; mov [lpc_bus], 0 ;eax
; call remap_irq
; end if
mov eax, VALID_IRQ mov eax, VALID_IRQ
mov ebx, [ctrl.int_line] mov ebx, [ctrl.int_line]
mov esi, msgInvIRQ mov esi, msgInvIRQ
@ -365,8 +332,12 @@ START:
call SysMsgBoardStr call SysMsgBoardStr
end if end if
xor eax, eax xor eax, eax
STOP:
ret ret
.stop:
call stop
xor eax, eax
ret
endp
handle equ IOCTL.handle handle equ IOCTL.handle
io_code equ IOCTL.io_code io_code equ IOCTL.io_code
@ -406,27 +377,26 @@ proc service_proc stdcall, ioctl:dword
@@: @@:
cmp eax, DEV_SET_MASTERVOL cmp eax, DEV_SET_MASTERVOL
jne @F jne @F
mov ebx, [edi+input] mov eax, [edi+input]
stdcall set_master_vol, [ebx] mov eax, [eax]
call set_master_vol ;eax= vol
ret ret
@@: @@:
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @F
mov ebx, [edi+output] mov ebx, [edi+output]
test ebx, ebx add ebx, new_app_base
jz .fail
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
ret ret
@@: ;@@:
cmp eax, DEV_GET_INFO ; cmp eax, DEV_GET_INFO
jne @F ; jne @F
mov ebx, [edi+output] ; mov ebx, [edi+output]
stdcall get_dev_info, ebx ; stdcall get_dev_info, ebx
ret ; ret
@@: @@:
.fail: .fail:
xor eax, eax or eax, -1
ret ret
endp endp
@ -438,24 +408,6 @@ restore output
restore out_size restore out_size
align 4
proc remap_irq ;for Intel chipsets ONLY !!!
mov eax, VALID_IRQ
bt eax, IRQ_LINE
jnc .exit
mov edx, 0x4D0
in ax,dx
bts ax, IRQ_LINE
out dx, aX
stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
mov [ctrl.int_line], IRQ_LINE
.exit:
ret
endp
align 4 align 4
proc ac97_irq proc ac97_irq
@ -464,37 +416,6 @@ proc ac97_irq
; call SysMsgBoardStr ; call SysMsgBoardStr
; end if ; end if
mov edx, PCM_OUT_CR_REG
mov al, 0x14
call [ctrl.ctrl_write8]
mov ax, 0x1c
mov edx, PCM_OUT_SR_REG
call [ctrl.ctrl_write16]
mov edx, PCM_OUT_CIV_REG
call [ctrl.ctrl_read8]
and eax, 0x1F
cmp eax, [civ_val]
je .skip
mov [civ_val], eax
dec eax
and eax, 0x1F
mov [ctrl.lvi_reg], eax
mov edx, PCM_OUT_LVI_REG
call [ctrl.ctrl_write8]
mov edx, PCM_OUT_CR_REG
mov ax, 0x1D
call [ctrl.ctrl_write8]
mov eax, [civ_val]
add eax, 2
and eax, 31
mov ebx, dword [buff_list+eax*4]
cmp [ctrl.user_callback], 0 cmp [ctrl.user_callback], 0
je @f je @f
@ -505,7 +426,7 @@ proc ac97_irq
.skip: .skip:
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x1D mov ax, 0x11 ;0x1D
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
ret ret
endp endp
@ -522,7 +443,8 @@ proc create_primary_buff
cld cld
rep stosd rep stosd
stdcall GetPgAddr, [ctrl.buffer] mov eax, [ctrl.buffer]
call GetPgAddr
mov ebx, 0xC0002000 mov ebx, 0xC0002000
mov ecx, 4 mov ecx, 4
@ -573,10 +495,11 @@ proc create_primary_buff
add edi, 4 add edi, 4
loop @B loop @B
mov ecx, pcmout_bdl mov eax, pcmout_bdl
stdcall GetPgAddr, ecx mov ebx, eax
and ecx, 0xFFF call GetPgAddr ;eax
add eax, ecx and ebx, 0xFFF
add eax, ebx
mov edx, PCM_OUT_BDL mov edx, PCM_OUT_BDL
call [ctrl.ctrl_write32] call [ctrl.ctrl_write32]
@ -585,7 +508,6 @@ proc create_primary_buff
mov [ctrl.lvi_reg], eax mov [ctrl.lvi_reg], eax
mov edx, PCM_OUT_LVI_REG mov edx, PCM_OUT_LVI_REG
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
ret ret
endp endp
@ -602,7 +524,7 @@ proc detect_controller
inc eax inc eax
call PciApi call PciApi
cmp eax, -1 cmp eax, -1
je .no_pci je .err
mov [last_bus], eax mov [last_bus], eax
@ -626,7 +548,8 @@ proc detect_controller
add edi, 12 add edi, 12
jmp @B jmp @B
.next: inc [devfn] .next:
inc [devfn]
cmp [devfn], 256 cmp [devfn], 256
jb .next_dev jb .next_dev
mov eax, [bus] mov eax, [bus]
@ -654,15 +577,6 @@ proc detect_controller
mov esi, [edi+8] mov esi, [edi+8]
mov [ctrl.ctrl_setup], esi mov [ctrl.ctrl_setup], esi
cmp ebx, VID_INTEL
jne @F
mov [ctrl.vendor_ids], msg_Intel
ret
@@:
cmp ebx, VID_NVIDIA
jne @F
mov [ctrl.vendor_ids], msg_NVidia
@@:
cmp ebx, 0x1274 cmp ebx, 0x1274
jne @F jne @F
mov [ctrl.vendor_ids], msgEnsoniq mov [ctrl.vendor_ids], msgEnsoniq
@ -670,56 +584,17 @@ proc detect_controller
@@: @@:
mov [ctrl.vendor_ids], 0 ;something wrong ? mov [ctrl.vendor_ids], 0 ;something wrong ?
ret ret
.no_pci:
mov esi, msgPCI
call SysMsgBoardStr
.err: .err:
xor eax, eax xor eax, eax
ret ret
endp endp
align 4
proc get_LPC_bus ;for Intel chipsets ONLY !!!
locals
last_bus dd ?
bus dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call [PciApi]
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
stdcall PciRead32, [bus], dword 0xF8, dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
cmp eax, 0x24D08086
je .found
.next:
mov eax, [bus]
inc eax
cmp eax, [last_bus]
mov [bus], eax
jna .next_bus
.err:
xor eax, eax
dec eax
ret
.found:
mov eax, [bus]
ret
endp
align 4 align 4
proc init_controller proc init_controller
mov esi, msgPCIcmd
call SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
mov ebx, eax mov ebx, eax
and eax, 0xFFFF and eax, 0xFFFF
@ -727,27 +602,28 @@ proc init_controller
shr ebx, 16 shr ebx, 16
mov [ctrl.pci_stat], ebx mov [ctrl.pci_stat], ebx
call dword2str
call SysMsgBoardStr
mov esi, msgIObase
call SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
and eax,0xFFFE and eax,0xFFFE
mov [ctrl.codec_io_base], eax mov [ctrl.codec_io_base], eax
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 call dword2str
and eax, 0xFFC0 call SysMsgBoardStr
mov [ctrl.ctrl_io_base], eax
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 mov esi, msgIntline
mov [ctrl.codec_mem_base], eax call SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
mov [ctrl.ctrl_mem_base], eax
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
and eax, 0xFF and eax, 0xFF
mov [ctrl.int_line], eax mov [ctrl.int_line], eax
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41 call dword2str
and eax, 0xFF call SysMsgBoardStr
mov [ctrl.cfg_reg], eax
call [ctrl.ctrl_setup] call [ctrl.ctrl_setup]
xor eax, eax xor eax, eax
@ -773,28 +649,6 @@ endp
PG_SW equ 0x003 PG_SW equ 0x003
PG_NOCACHE equ 0x018 PG_NOCACHE equ 0x018
align 4
proc set_ICH4
stdcall AllocKernelSpace, dword 0x2000
mov edi, eax
stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
mov [ctrl.codec_mem_base], edi
add edi, 0x1000
stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
mov [ctrl.ctrl_mem_base], edi
mov [ctrl.codec_read16], codec_mem_r16 ;virtual
mov [ctrl.codec_write16], codec_mem_w16 ;virtual
mov [ctrl.ctrl_read8 ], ctrl_mem_r8 ;virtual
mov [ctrl.ctrl_read16], ctrl_mem_r16 ;virtual
mov [ctrl.ctrl_read32], ctrl_mem_r32 ;virtual
mov [ctrl.ctrl_write8 ], ctrl_mem_w8 ;virtual
mov [ctrl.ctrl_write16], ctrl_mem_w16 ;virtual
mov [ctrl.ctrl_write32], ctrl_mem_w32 ;virtual
ret
endp
align 4 align 4
proc reset_controller proc reset_controller
@ -818,7 +672,6 @@ proc reset_controller
mov edx, MC_IN_CR_REG mov edx, MC_IN_CR_REG
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
ret ret
endp endp
@ -828,6 +681,26 @@ proc init_codec
counter dd ? counter dd ?
endl endl
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]
call dword2str
call SysMsgBoardStr
test eax, CTRL_ST_CREADY
jnz .ready
call reset_codec call reset_codec
and eax, eax and eax, eax
jz .err jz .err
@ -992,8 +865,7 @@ proc cold_reset
endp endp
align 4 align 4
proc play play:
mov eax, 16 mov eax, 16
mov [ctrl.lvi_reg], eax mov [ctrl.lvi_reg], eax
mov edx, PCM_OUT_LVI_REG mov edx, PCM_OUT_LVI_REG
@ -1002,22 +874,20 @@ proc play
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x1D mov ax, 0x1D
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
xor eax, eax
ret ret
endp
align 4 align 4
proc stop stop:
mov edx, PCM_OUT_CR_REG mov edx, PCM_OUT_CR_REG
mov ax, 0x14 mov ax, 0x0
call [ctrl.ctrl_write8]
mov eax, 16
mov [ctrl.lvi_reg], eax
mov edx, PCM_OUT_LVI_REG
call [ctrl.ctrl_write8] call [ctrl.ctrl_write8]
mov ax, 0x1c
mov edx, PCM_OUT_SR_REG
call [ctrl.ctrl_write16]
xor eax, eax
ret ret
endp
align 4 align 4
proc get_dev_info stdcall, p_info:dword proc get_dev_info stdcall, p_info:dword
@ -1051,7 +921,6 @@ proc get_dev_info stdcall, p_info:dword
mov ebx, [ctrl.pci_cmd] mov ebx, [ctrl.pci_cmd]
mov [CTRL_INFO.pci_cmd], ebx mov [CTRL_INFO.pci_cmd], ebx
ret ret
endp endp
@ -1127,8 +996,6 @@ proc codec_check_ready
xor eax, wax xor eax, wax
inc eax inc eax
ret ret
align 4
.not_ready: .not_ready:
xor eax, eax xor eax, eax
ret ret
@ -1176,7 +1043,7 @@ proc StallExec
rdtsc rdtsc
sub eax, ebx sub eax, ebx
sbb edx, ecx sbb edx, ecx
jb @B js @B
pop eax pop eax
pop ebx pop ebx
@ -1245,109 +1112,40 @@ proc ctrl_io_w32
ret ret
endp endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MEMORY MAPPED IO (os depended)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4 align 4
proc codec_mem_r16 dword2str:
add edx, [ctrl.codec_mem_base] mov esi, hex_buff
mov ax, word [edx] mov ecx, -8
@@:
rol eax, 4
mov ebx, eax
and ebx, 0x0F
mov bl, [ebx+hexletters]
mov [8+esi+ecx], bl
inc ecx
jnz @B
ret ret
endp
align 4 hexletters db '0123456789ABCDEF'
proc codec_mem_w16 hex_buff db 8 dup(0),13,10,0
add edx, [ctrl.codec_mem_base]
mov word [edx], ax
ret
endp
align 4
proc ctrl_mem_r8
add edx, [ctrl.ctrl_mem_base]
mov al, [edx]
ret
endp
align 4
proc ctrl_mem_r16
add edx, [ctrl.ctrl_mem_base]
mov ax, [edx]
ret
endp
align 4
proc ctrl_mem_r32
add edx, [ctrl.ctrl_mem_base]
mov eax, [edx]
ret
endp
align 4
proc ctrl_mem_w8
add edx, [ctrl.ctrl_mem_base]
mov [edx], al
ret
endp
align 4
proc ctrl_mem_w16
add edx, [ctrl.ctrl_mem_base]
mov [edx], ax
ret
endp
align 4
proc ctrl_mem_w32
add edx, [ctrl.ctrl_mem_base]
mov [edx], eax
ret
endp
include "codec.inc" include "codec.inc"
align 4 align 4
devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH devices dd (0x5000 shl 16)+0x1274,msgEnsoniq,set_ICH
dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH dd (0x5880 shl 16)+0x1274,msgVibra128,set_ICH
dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
dd (CTRL_NFORCE shl 16)+VID_NVIDIA,msg_NForce, set_ICH
dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
dd (0x5000 shl 16)+0x1274,msgEnsoniq,set_ICH
dd 0 ;terminator dd 0 ;terminator
msg_ICH db 'Intel ICH', 13,10, 0 version dd 0x00040000
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_NForce db 'NForce', 13,10, 0
msg_NForce2 db 'NForce 2', 13,10, 0
msg_NForce3 db 'NForce 3', 13,10, 0
msg_NVidia db 'NVidea', 0
msgEnsoniq db 'Ensonic 1371',0 msgEnsoniq db 'Ensonic 1371',0
msgVibra128 db 'Sound Blaster AudioPCI Vibra 128',0
szKernel db 'KERNEL', 0
sz_sound_srv db 'SOUND',0 sz_sound_srv db 'SOUND',0
msgInit db 'detect hardware...',13,10,0 msgDetect db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgFail db 'device not found',13,10,0 msgFail db 'device not found',13,10,0
msgAttchIRQ db 'IRQ line not supported', 13,10, 0 msgAttchIRQ db 'IRQ line not supported', 13,10, 0
msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0
@ -1366,6 +1164,11 @@ msgWRFail db 'warm reset failed',13,10,0
msgCRFail db 'cold reset failed',13,10,0 msgCRFail db 'cold reset failed',13,10,0
msgCFail db 'codec not ready',13,10,0 msgCFail db 'codec not ready',13,10,0
msgResetOk db 'reset complete',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
msgIObase db 'IO base ',0
msgIntline db 'Interrupt line ',0
section '.data' data readable writable align 16 section '.data' data readable writable align 16