* sound drivers converted to PE

* sound driver selector: revert r5071 and fix the problem properly
* sis: integrate changes from drivers/audio/sisnbook, add to autobuild
* intelac97: fix clicks during play on VBox
* intel_hda: fix problems at shutdown

git-svn-id: svn://kolibrios.org@5077 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2014-09-01 11:21:04 +00:00
parent 4afcb5706b
commit 11bd59473f
18 changed files with 466 additions and 2689 deletions

View File

@ -127,11 +127,6 @@ FASM_PROGRAMS:=\
develop/info/html.syn:DEVELOP/INFO/HTML.SYN:$(PROGS)/other/t_edit/info/html_syn.asm \
develop/info/ini_files.syn:DEVELOP/INFO/INI_FILES.SYN:$(PROGS)/other/t_edit/info/ini_files_syn.asm \
develop/info/win_const.syn:DEVELOP/INFO/WIN_CONST.SYN:$(PROGS)/other/t_edit/info/win_const_syn.asm \
drivers/emu10k1x.obj:DRIVERS/EMU10K1X.OBJ:$(KERNEL)/drivers/emu10k1x.asm \
drivers/fm801.obj:DRIVERS/FM801.OBJ:$(KERNEL)/drivers/fm801.asm \
drivers/infinity.obj:DRIVERS/INFINITY.OBJ:$(KERNEL)/drivers/infinity.asm \
drivers/intelac97.obj:DRIVERS/INTELAC97.OBJ:$(KERNEL)/drivers/intelac97.asm \
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
File|Managers/opendial:File|Managers/OPENDIAL:$(PROGS)/fs/opendial/opendial.asm \
@ -230,6 +225,12 @@ FASM_PROGRAMS_PESTRIP:=\
drivers/intel_hda.sys:DRIVERS/intel_hda.sys:$(REPOSITORY)/drivers/audio/intel_hda/intel_hda.asm \
drivers/sb16.sys:DRIVERS/SB16.SYS:$(REPOSITORY)/drivers/audio/sb16/sb16.asm \
drivers/sound.sys:DRIVERS/SOUND.SYS:$(REPOSITORY)/drivers/audio/sound.asm \
drivers/infinity.sys:DRIVERS/INFINITY.SYS:$(REPOSITORY)/drivers/audio/infinity/infinity.asm \
drivers/intelac97.sys:DRIVERS/INTELAC97.SYS:$(REPOSITORY)/drivers/audio/intelac97.asm \
drivers/emu10k1x.sys:DRIVERS/EMU10K1X.SYS:$(REPOSITORY)/drivers/audio/emu10k1x.asm \
drivers/fm801.sys:DRIVERS/FM801.SYS:$(REPOSITORY)/drivers/audio/fm801.asm \
drivers/vt823x.sys:DRIVERS/VT823X.SYS:$(REPOSITORY)/drivers/audio/vt823x.asm \
drivers/sis.sys:DRIVERS/SIS.SYS:$(REPOSITORY)/drivers/audio/sis.asm \
# end of list
# The list of all FASM programs with one main FASM file for CD image.
# Format of an item is exactly the same as in the previous list.

View File

@ -36,7 +36,7 @@ proc detect_codec
mov eax, [edi+4]
mov [codec.ac_vendor_ids], eax
mov esi, eax
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall detect_chip, [edi+8]
ret
@ -48,10 +48,10 @@ proc detect_codec
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [codec.chip_id]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
ret
endp
@ -72,7 +72,7 @@ proc detect_chip stdcall, chip_tab:dword
mov eax, [edi+4]
mov [codec.chip_ids], eax
mov esi, eax
call SysMsgBoardStr
invoke SysMsgBoardStr
ret
.next:
add edi, 8
@ -80,10 +80,10 @@ proc detect_chip stdcall, chip_tab:dword
.unknown:
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [codec.chip_id]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
ret
endp

View File

@ -1,17 +1,15 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
format PE DLL native 0.05
entry START
DEBUG equ 1
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices
@ -315,35 +313,23 @@ struc CTRL_INFO
.codec_id dd ?
}
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
EVENT_NOTIFY equ 0x00000200
public START
public service_proc
public version
section '.flat' code readable writable executable
include '../struct.inc'
include '../macros.inc'
include '../proc32.inc'
include '../peimport.inc'
section '.flat' code readable align 16
proc START stdcall, state:dword
proc START c uses ebx esi edi, state:dword, cmdline:dword
cmp [state], 1
jne .stop
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call detect_controller
@ -352,9 +338,9 @@ proc START stdcall, state:dword
if DEBUG
mov esi, [ctrl.vendor_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, [ctrl.ctrl_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call init_controller
@ -368,10 +354,10 @@ proc START stdcall, state:dword
call setup_codec
mov esi, msgPrimBuff
call SysMsgBoardStr
invoke SysMsgBoardStr
call create_primary_buff
mov esi, msgDone
call SysMsgBoardStr
invoke SysMsgBoardStr
if IRQ_REMAP
pushf
@ -399,7 +385,7 @@ proc START stdcall, state:dword
mov [ctrl.int_line], IRQ_LINE
popf
mov esi, msgRemap
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, VALID_IRQ
@ -412,21 +398,21 @@ proc START stdcall, state:dword
bt eax, ebx
jnc .fail_msg
stdcall AttachIntHandler, ebx, ac97_irq, dword 0
invoke AttachIntHandler, ebx, ac97_irq, dword 0
stdcall create
.reg:
stdcall RegService, sz_sound_srv, service_proc
invoke RegService, sz_sound_srv, service_proc
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
ret
.fail_msg:
call SysMsgBoardStr
invoke SysMsgBoardStr
xor eax, eax
ret
.stop:
@ -462,7 +448,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgPlay
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call play
ret
@ -471,7 +457,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgStop
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call stop
ret
@ -543,7 +529,7 @@ endp
align 4
proc create_primary_buff
stdcall KernelAlloc, 0x10000
invoke KernelAlloc, 0x10000
mov [ctrl.buffer], eax
mov edi, eax
@ -553,7 +539,7 @@ proc create_primary_buff
rep stosd
mov eax, [ctrl.buffer]
call GetPgAddr
invoke GetPgAddr
mov edi, pcmout_bdl
stosd
@ -565,7 +551,7 @@ proc create_primary_buff
stosd ;1.]
mov eax, [ctrl.buffer]
call GetPgAddr
invoke GetPgAddr
stdcall ptr_write, PLAYBACK_POINTER, 0, 0
stdcall ptr_write, PLAYBACK_UNKNOWN1, 0, 0
@ -574,7 +560,7 @@ proc create_primary_buff
mov eax, pcmout_bdl
mov ebx, eax
call GetPgAddr
invoke GetPgAddr
and ebx, 0xFFF
add eax, ebx
@ -601,7 +587,7 @@ proc detect_controller
xor eax, eax
mov [bus], eax
inc eax
call PciApi
invoke PciApi
cmp eax, -1
je .err
@ -610,7 +596,7 @@ proc detect_controller
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
invoke PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
@ -670,13 +656,13 @@ endp
align 4
proc init_controller
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x2C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x2C
mov esi, msgPciSubsys
call SysMsgBoardStr
invoke SysMsgBoardStr
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
mov ebx, eax
and eax, 0xFFFF
mov [ctrl.pci_cmd], eax
@ -684,27 +670,27 @@ proc init_controller
mov [ctrl.pci_stat], ebx
mov esi, msgPciCmd
call SysMsgBoardStr
invoke SysMsgBoardStr
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPciStat
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [ctrl.pci_stat]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgCtrlIsaIo
call SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
invoke SysMsgBoardStr
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFC0
mov [ctrl.ctrl_io_base], eax
.default:
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
and eax, 0xFF
@@:
mov [ctrl.int_line], eax
@ -753,7 +739,7 @@ proc reset_codec
if DEBUG
mov esi, msgCold
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, 100000 ; wait 100 ms ;400000 ; wait 400 ms
@ -775,7 +761,7 @@ proc reset_codec
if DEBUG
mov esi, msgCRFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.fail:
@ -851,11 +837,11 @@ endp
align 4
proc create stdcall
stdcall PciRead16, [ctrl.bus], [ctrl.devfn], dword 4
invoke PciRead16, [ctrl.bus], [ctrl.devfn], 4
test eax, 4 ; test master bit
jnz @f
or eax, 4
stdcall PciWrite16, [ctrl.bus], [ctrl.devfn], dword 4, eax ; set master bit
invoke PciWrite16, [ctrl.bus], [ctrl.devfn], 4, eax ; set master bit
@@:
xor eax, eax
@ -1117,8 +1103,6 @@ devices dd (CTRL_CT0200 shl 16)+VID_Creative,msg_CT_EMU10K1X,set_Creative
dd 0 ;terminator
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_CT_EMU10K1X db 'SB Live! Dell OEM', 13,10, 0
msg_Creative db 'Creative ', 0
@ -1157,8 +1141,11 @@ msgCtrlIsaIo db 'controller io base ',0
;msgMixMMIo db 'codec mmio base ',0
;msgIrqMap db 'AC97 irq map as ',0
section '.data' data readable writable align 16
align 4
data fixups
end data
align 8
pcmout_bdl rq 32
buff_list rd 32

View File

@ -1,18 +1,16 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
format PE DLL native 0.05
entry START
DEBUG equ 1
DEBUG_IRQ equ 0
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices
@ -276,28 +274,15 @@ struc CTRL_INFO
.codec_id dd ?
}
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
EVENT_NOTIFY equ 0x00000200
public START
public service_proc
public version
section '.flat' code readable writable executable
include '../struct.inc'
include '../macros.inc'
include '../proc32.inc'
include '../peimport.inc'
section '.flat' code readable align 16
proc START stdcall, state:dword
proc START c uses ebx esi edi, state:dword, cmdline:dword
cmp [state], 1
jne .stop
@ -305,9 +290,9 @@ proc START stdcall, state:dword
if DEBUG
mov eax, START
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgInit
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call detect_controller
@ -316,9 +301,9 @@ proc START stdcall, state:dword
if DEBUG
mov esi, [ctrl.vendor_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, [ctrl.ctrl_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
@ -334,11 +319,11 @@ proc START stdcall, state:dword
call setup_codec
mov esi, msgPrimBuff
call SysMsgBoardStr
invoke SysMsgBoardStr
call create_primary_buff
mov esi, msgDone
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, VALID_IRQ
mov ebx, [ctrl.int_line]
@ -350,20 +335,20 @@ proc START stdcall, state:dword
bt eax, ebx
jnc .fail_msg
stdcall AttachIntHandler, ebx, ac97_irq, dword 0
invoke AttachIntHandler, ebx, ac97_irq, dword 0
.reg:
stdcall RegService, sz_sound_srv, service_proc
invoke RegService, sz_sound_srv, service_proc
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
ret
.fail_msg:
call SysMsgBoardStr
invoke SysMsgBoardStr
xor eax, eax
ret
.stop:
@ -400,7 +385,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgPlay
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call play
ret
@ -409,7 +394,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgStop
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call stop
ret
@ -485,7 +470,7 @@ proc ac97_irq
if DEBUG_IRQ
mov esi, msgIRQ
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov edx, FM_INTSTATUS
@ -508,7 +493,7 @@ endp
align 4
proc create_primary_buff
stdcall KernelAlloc, 0x10000
invoke KernelAlloc, 0x10000
mov [ctrl.buffer], eax
mov edi, eax
@ -518,7 +503,7 @@ proc create_primary_buff
rep stosd
mov eax, [ctrl.buffer]
call GetPgAddr
invoke GetPgAddr
mov [buffer_pgaddr], eax
ret
@ -535,7 +520,7 @@ proc detect_controller
xor eax, eax
mov [bus], eax
inc eax
call PciApi
invoke PciApi
cmp eax, -1
je .err
@ -544,14 +529,14 @@ proc detect_controller
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
invoke PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
push eax
stdcall PciRead32, [bus], [devfn], dword 0x09
invoke PciRead32, [bus], [devfn], dword 0x09
and eax, 0xffffff
cmp eax, 0x060100 ;pci-isa
jne .no_bridge
@ -612,7 +597,7 @@ endp
align 4
proc init_controller
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 4
mov ebx, eax
and eax, 0xFFFF
mov [ctrl.pci_cmd], eax
@ -620,36 +605,36 @@ proc init_controller
mov [ctrl.pci_stat], ebx
mov esi, msgPciCmd
call SysMsgBoardStr
invoke SysMsgBoardStr
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPciStat
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [ctrl.pci_stat]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgCtrlIsaIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFFE
mov [ctrl.ctrl_io_base], eax
mov esi, msgIrqNum
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x3C
and eax, 0xFF
mov [ctrl.int_line], eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
call [ctrl.ctrl_setup]
xor eax, eax
@ -676,7 +661,7 @@ align 4
proc reset_controller
mov esi, msgInitCtrl
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, FM_CARD_CTL
call [ctrl.ctrl_read8]
@ -719,7 +704,7 @@ align 4
proc init_codec
mov esi, msgInitCodec
call SysMsgBoardStr
invoke SysMsgBoardStr
mov al, FM_CODEC_CMD_READ
mov edx, FM_CODEC_CMD
@ -1024,8 +1009,6 @@ align 4
devices dd (CTRL_FM801 shl 16)+VID_FM801, msg_FM801, set_FM
dd 0
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_FM801 db 'FM801 AC97 controller',13,10, 0
msg_FM db 'Forte Media',13,10, 0
@ -1053,7 +1036,9 @@ msgCtrlIsaIo db 'controller io base ',0
msgIrqNum db 'IRQ default ',0
;msgIrqMap db 'AC97 irq map as ',0
section '.data' data readable writable align 16
align 4
data fixups
end data
codec CODEC
ctrl AC_CNTRL

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2006-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2006-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -8,16 +8,12 @@
; Serge 2006-2008
; email: infinity_sound@mail.ru
format MS COFF
format PE DLL native 0.05
entry START
DEBUG equ 1
include 'proc32.inc'
include 'main.inc'
include 'imports.inc'
CURRENT_API equ 0x0101 ;1.01
COMPATIBLE_API equ 0x0100 ;1.00
@ -38,10 +34,6 @@ OS_BASE equ 0x80000000
CAPS_SSE2 equ 26
PG_SW equ 0x003
public START
public service_proc
public version
RT_INP_EMPTY equ 0xFF000001
RT_OUT_EMPTY equ 0xFF000002
RT_INP_FULL equ 0xFF000003
@ -57,32 +49,26 @@ DEV_STOP equ 2
DEV_CALLBACK equ 3
DEV_GET_POS equ 9
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
section '.flat' code readable executable
include '../../struct.inc'
include '../../macros.inc'
include '../../proc32.inc'
include 'main.inc'
include '../../peimport.inc'
virtual at 0
IOCTL IOCTL
end virtual
section '.flat' code readable align 16
proc START stdcall, state:dword
proc START c uses ebx esi edi, state:dword, cmdline:dword
cmp [state], 1
jne .exit
stdcall GetService, szSound
invoke GetService, szSound
test eax, eax
jz .fail
mov [hSound], eax
stdcall KernelAlloc, 16*512
invoke KernelAlloc, 16*512
test eax, eax
jz .out_of_mem
mov [mix_buff], eax
@ -133,12 +119,12 @@ end if
end if
stdcall set_handler, [hSound], new_mix
mov [eng_state], SND_STOP
stdcall RegService, szInfinity, service_proc
invoke RegService, szInfinity, service_proc
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.exit:
xor eax, eax
@ -147,21 +133,12 @@ end if
.out_of_mem:
if DEBUG
mov esi, msgMem
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
align 4
srv_calls dd service_proc.srv_getversion ; 0
@ -189,7 +166,7 @@ srv_calls_end:
proc service_proc stdcall, ioctl:dword
mov edi, [ioctl]
mov eax, [edi+io_code]
mov eax, [edi+IOCTL.io_code]
cmp eax, (srv_calls_end-srv_calls)/4
ja .fail
@ -200,7 +177,7 @@ proc service_proc stdcall, ioctl:dword
; cmp [edi+inp_size], 4
; jb .fali
mov ebx, [edi+input]
mov ebx, [edi+IOCTL.input]
mov edx, [ebx]
cmp [edx+STREAM.magic], 'WAVE'
@ -219,8 +196,8 @@ proc service_proc stdcall, ioctl:dword
align 4
.srv_getversion:
mov eax, [edi+output]
cmp [edi+out_size], 4
mov eax, [edi+IOCTL.output]
cmp [edi+IOCTL.out_size], 4
jne .fail
mov eax, [eax]
mov [eax], dword API_VERSION
@ -229,10 +206,10 @@ align 4
align 4
.snd_create_buff:
mov ebx, [edi+input]
mov ebx, [edi+IOCTL.input]
stdcall CreateBuffer, [ebx], [ebx+4]
mov edi, [ioctl]
mov ecx, [edi+output]
mov ecx, [edi+IOCTL.output]
mov ecx, [ecx]
mov [ecx], ebx
ret
@ -251,7 +228,7 @@ align 4
align 4
.snd_getformat:
movzx eax, word [edx+STREAM.format]
mov ecx, [edi+output]
mov ecx, [edi+IOCTL.output]
mov ecx, [ecx]
mov [ecx], eax
xor eax, eax
@ -271,7 +248,7 @@ align 4
.snd_getpos:
stdcall GetBufferPos, edx
mov edi, [ioctl]
mov ecx, [edi+output]
mov ecx, [edi+IOCTL.output]
mov ecx, [ecx]
mov [ecx], ebx
ret
@ -305,7 +282,7 @@ align 4
align 4
.snd_getvolume:
mov eax, [edi+output]
mov eax, [edi+IOCTL.output]
mov ecx, [eax]
mov eax, [eax+4]
stdcall GetBufferVol, edx, ecx, eax
@ -318,7 +295,7 @@ align 4
align 4
.snd_getpan:
mov eax, [edx+STREAM.pan]
mov ebx, [edi+output]
mov ebx, [edi+IOCTL.output]
mov ebx, [ebx]
mov [ebx], eax
xor eax, eax
@ -327,7 +304,7 @@ align 4
align 4
.snd_getbuffsize:
mov eax, [edx+STREAM.in_size]
mov ecx, [edi+output]
mov ecx, [edi+IOCTL.output]
mov ecx, [ecx]
mov [ecx], eax
xor eax, eax
@ -339,13 +316,13 @@ align 4
jz .fail
mov ebx, [edx+STREAM.in_free]
mov ecx, [edi+output]
mov ecx, [edi+IOCTL.output]
mov [ecx], ebx
xor eax, eax
ret
align 4
.snd_settimebase:
cmp [edi+inp_size], 12
cmp [edi+IOCTL.inp_size], 12
jne .fail
mov eax, [ebx+4]
@ -364,7 +341,7 @@ align 4
align 4
.snd_gettimestamp:
cmp [edi+out_size], 8
cmp [edi+IOCTL.out_size], 8
jne .fail
pushfd
@ -393,7 +370,7 @@ align 4
push dword [hSound] ;.handle
mov eax, esp
stdcall ServiceHandler, eax
invoke ServiceHandler, eax
add esp, 6*4
pop edi
@ -407,7 +384,7 @@ align 4
mov dword [esp], 0 ; clear offset
@@:
mov edi, [edi+output]
mov edi, [edi+IOCTL.output]
emms
fild qword [edx+STREAM.time_stamp]
@ -461,11 +438,11 @@ proc CreateBuffer stdcall, format:dword, size:dword
jnz .fail
.test_ok:
call GetPid
invoke GetPid
mov ebx, eax
mov eax, STREAM.sizeof
call CreateObject
invoke CreateObject
test eax, eax
jz .fail
mov [str], eax
@ -516,7 +493,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
shr ebx, 12
mov [ring_pages], ebx
stdcall CreateRingBuffer, eax, PG_SW
invoke CreateRingBuffer, eax, PG_SW
mov edi, [str]
mov ecx, [ring_size]
@ -536,7 +513,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
mov ecx, [size]
add ecx, 128 ;resampler required
mov [eax+STREAM.in_size], ecx
stdcall KernelAlloc, ecx
invoke KernelAlloc, ecx
mov edi, [str]
mov [edi+STREAM.in_base], eax
@ -550,7 +527,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
mov [edi+STREAM.in_top], eax
.out_buff:
stdcall AllocKernelSpace, dword 128*1024
invoke AllocKernelSpace, dword 128*1024
mov edi, [str]
xor ebx, ebx
@ -569,19 +546,19 @@ proc CreateBuffer stdcall, format:dword, size:dword
mov dword [edi+STREAM.time_stamp+4], ebx
mov dword [edi+STREAM.last_ts], ebx
stdcall AllocPages, dword 64/4
invoke AllocPages, dword 64/4
mov edi, [str]
mov ebx, [edi+STREAM.out_base]
mov ecx, 16
or eax, PG_SW
push eax
push ebx
call CommitPages ;eax, ebx, ecx
invoke CommitPages ;eax, ebx, ecx
mov ecx, 16
pop ebx
pop eax
add ebx, 64*1024
call CommitPages ;double mapped
invoke CommitPages ;double mapped
mov edi, [str]
mov ecx, [edi+STREAM.in_top]
@ -599,7 +576,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
xor esi, esi
mov ecx, MANUAL_DESTROY
call CreateEvent
invoke CreateEvent
mov ebx, [str]
mov [ebx+STREAM.notify_event], eax
@ -647,12 +624,12 @@ DestroyBuffer:
mov [ecx+STREAM.str_fd], ebx
popf
stdcall KernelFree, [eax+STREAM.in_base]
invoke KernelFree, [eax+STREAM.in_base]
mov eax, [.handle]
stdcall KernelFree, [eax+STREAM.out_base]
invoke KernelFree, [eax+STREAM.out_base]
pop eax ;restore stack
call DestroyObject ;eax= stream
invoke DestroyObject ;eax= stream
xor eax, eax
ret
.fail:
@ -833,7 +810,7 @@ proc wave_out stdcall, str:dword,src:dword,size:dword
jne @F
lea eax, [fpu_state+15]
and eax, -16
call FpuSave
invoke FpuSave
mov [state_saved], 1
@@:
stdcall refill, edx
@ -853,7 +830,7 @@ proc wave_out stdcall, str:dword,src:dword,size:dword
mov edx, [str]
mov eax, [edx+STREAM.notify_event]
mov ebx, [edx+STREAM.notify_id]
call WaitEvent ;eax ebx
invoke WaitEvent ;eax ebx
jmp .main_loop
.done:
cmp [state_saved], 1
@ -861,7 +838,7 @@ proc wave_out stdcall, str:dword,src:dword,size:dword
lea eax, [fpu_state+15]
and eax, -16
call FpuRestore
invoke FpuRestore
@@:
xor eax, eax
ret
@ -1156,7 +1133,7 @@ proc play_buffer stdcall, str:dword, flags:dword
.wait:
mov eax, [edx+STREAM.notify_event]
mov ebx, [edx+STREAM.notify_id]
call WaitEvent ;eax ebx
invoke WaitEvent ;eax ebx
mov edx, [str]
cmp [edx+STREAM.flags], SND_STOP
@ -1182,7 +1159,7 @@ proc stop_buffer stdcall, str:dword
mov eax, [edx+STREAM.notify_event]
mov ebx, [edx+STREAM.notify_id]
call ClearEvent ;eax ebx
invoke ClearEvent ;eax ebx
xor eax, eax
ret
@ -1315,7 +1292,7 @@ proc set_handler stdcall, hsrv:dword, handler_proc:dword
mov [out_size], 0
lea eax, [handler]
stdcall ServiceHandler, eax
invoke ServiceHandler, eax
ret
endp
@ -1342,7 +1319,7 @@ proc dev_play stdcall, hsrv:dword
mov [out_size], ebx
lea eax, [handle]
stdcall ServiceHandler, eax
invoke ServiceHandler, eax
ret
endp
@ -1441,7 +1418,6 @@ vol_min dd 0x0000D8F0,0x0000D8F0
pan_max dd 0x00002710,0x00002710
;stream_map dd 0xFFFF ; 16
version dd (5 shl 16) or SOUND_VERSION
szInfinity db 'INFINITY',0
szSound db 'SOUND',0
@ -1457,7 +1433,11 @@ msgWaveout db 'Play waveout', 13,10,0
msgSetVolume db 'Set volume',13,10,0
end if
section '.data' data readable writable align 16
align 4
data fixups
end data
section '.data' data readable writable
play_list rd 16
mix_input rd 16

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2006-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2006-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -27,7 +27,7 @@ proc new_mix stdcall, output:dword
lea eax, [fpu_state+16]
and eax, -16 ;must be 16b aligned
call FpuSave
invoke FpuSave
call update_streams
.mix:
@ -66,7 +66,7 @@ end if
.exit:
lea eax, [fpu_state+16]
and eax, -16
call FpuRestore
invoke FpuRestore
ret
.done:
mov ecx, [main_count]
@ -196,7 +196,7 @@ proc refill stdcall, str:dword
mov ebx, [ebx+STREAM.notify_id]
mov edx, EVENT_WATCHED
xor esi, esi
call RaiseEvent ;eax, ebx, edx, esi
invoke RaiseEvent ;eax, ebx, edx, esi
.exit:
ret
endp
@ -267,7 +267,7 @@ proc refill_ring stdcall, str:dword
mov ebx, [ebx+STREAM.notify_id]
xor edx, edx
call RaiseEvent ;eax, ebx, edx, esi
invoke RaiseEvent ;eax, ebx, edx, esi
.exit:
ret
endp

View File

@ -500,10 +500,9 @@ include '../../peimport.inc'
include 'CODEC_H.INC'
entry START
section '.flat' readable writable executable
;proc START stdcall, state:dword
proc START c, state:dword, cmdline:dword
;proc START c, reason:dword, cmdline:dword
proc START
push ebx esi ; save used registers to be stdcall
virtual at esp
rd 2 ; saved registers
@ -512,8 +511,8 @@ virtual at esp
.cmdline dd ? ; normally NULL
end virtual
; 1. Check the reason for the call, do nothing unless initializing.
;cmp [.reason], DRV_ENTRY
;jne .stop
cmp [.reason], DRV_ENTRY
jne .stop
if DEBUG
mov esi, msgTV

View File

@ -1,17 +1,17 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
format PE DLL native 0.05
entry START
include '../struct.inc'
DEBUG equ 1
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
DEBUG_IRQ equ 0
@ -274,35 +274,21 @@ struc CTRL_INFO
.codec_id dd ?
}
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
EVENT_NOTIFY equ 0x00000200
public START
public service_proc
public version
section '.flat' code readable executable
include '../macros.inc'
include '../proc32.inc'
include '../peimport.inc'
section '.flat' code readable align 16
proc START stdcall, state:dword
proc START c uses ebx esi edi, state:dword, cmdline:dword
cmp [state], 1
jne .stop
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call detect_controller
@ -311,9 +297,9 @@ proc START stdcall, state:dword
if DEBUG
mov esi, [ctrl.vendor_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, [ctrl.ctrl_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
@ -329,10 +315,10 @@ proc START stdcall, state:dword
call setup_codec
mov esi, msgPrimBuff
call SysMsgBoardStr
invoke SysMsgBoardStr
call create_primary_buff
mov esi, msgDone
call SysMsgBoardStr
invoke SysMsgBoardStr
if IRQ_REMAP
pushf
@ -360,23 +346,23 @@ proc START stdcall, state:dword
mov [ctrl.int_line], IRQ_LINE
popf
mov esi, msgRemap
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov ebx, [ctrl.int_line]
stdcall AttachIntHandler, ebx, ac97_irq, dword 0
invoke AttachIntHandler, ebx, ac97_irq, 0
.reg:
stdcall RegService, sz_sound_srv, service_proc
invoke RegService, sz_sound_srv, service_proc
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
ret
.fail_msg:
call SysMsgBoardStr
invoke SysMsgBoardStr
xor eax, eax
ret
.stop:
@ -413,7 +399,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgPlay
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call play
ret
@ -422,7 +408,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgStop
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call stop
ret
@ -484,7 +470,7 @@ proc ac97_irq
if DEBUG_IRQ
mov esi, msgIRQ
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov edx, CTRL_STAT
@ -508,9 +494,9 @@ proc ac97_irq
.do_intr:
push eax
mov edx, PCM_OUT_CR_REG
mov al, 0x10; 0x10
call [ctrl.ctrl_write8]
; mov edx, PCM_OUT_CR_REG
; mov al, 0x10; 0x10
; call [ctrl.ctrl_write8]
mov ax, 0x1c
mov edx, PCM_OUT_SR_REG
@ -531,19 +517,16 @@ proc ac97_irq
mov edx, PCM_OUT_LVI_REG
call [ctrl.ctrl_write8]
mov edx, PCM_OUT_CR_REG
mov ax, 0x11 ;0x1D
call [ctrl.ctrl_write8]
mov eax, [civ_val]
add eax, 1
and eax, 31
mov ebx, dword [buff_list+eax*4]
; mov edx, PCM_OUT_CR_REG
; mov ax, 0x11 ;0x1D
; call [ctrl.ctrl_write8]
cmp [ctrl.user_callback], 0
je .done
stdcall [ctrl.user_callback], ebx
mov eax, [ctrl.lvi_reg]
stdcall [ctrl.user_callback], [buff_list+eax*4]
.done:
pop eax
and eax, 0x40
@ -552,16 +535,16 @@ proc ac97_irq
or eax, 1
ret
.skip:
mov edx, PCM_OUT_CR_REG
mov ax, 0x11 ;0x1D
call [ctrl.ctrl_write8]
; mov edx, PCM_OUT_CR_REG
; mov ax, 0x11 ;0x1D
; call [ctrl.ctrl_write8]
jmp .done
endp
align 4
proc create_primary_buff
stdcall KernelAlloc, 0x10000
invoke KernelAlloc, 0x10000
mov [ctrl.buffer], eax
mov edi, eax
@ -571,7 +554,7 @@ proc create_primary_buff
rep stosd
mov eax, [ctrl.buffer]
call GetPgAddr
invoke GetPgAddr
mov ebx, 0xC0002000
mov ecx, 4
@ -624,7 +607,7 @@ proc create_primary_buff
mov eax, pcmout_bdl
mov ebx, eax
call GetPgAddr ;eax
invoke GetPgAddr ;eax
and ebx, 0xFFF
add eax, ebx
@ -640,59 +623,36 @@ endp
align 4
proc detect_controller
locals
last_bus dd ?
bus dd ?
devfn dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
push ebx edi
invoke GetPCIList
mov ebx, eax
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov eax, [eax+PCIDEV.fd]
cmp eax, ebx
jz .not_found
mov edx, [eax+PCIDEV.vendor_device_id]
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
cmp dword [edi], 0
jz .next_dev
cmp edx, [edi]
jz .found
add edi, 12
jmp @B
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
.not_found:
xor eax, eax
pop edi ebx
ret
.found:
mov ebx, [bus]
movzx ebx, [eax+PCIDEV.bus]
mov [ctrl.bus], ebx
mov ecx, [devfn]
movzx ecx, [eax+PCIDEV.devfn]
mov [ctrl.devfn], ecx
mov edx, eax
mov eax, edx
and edx, 0xFFFF
mov [ctrl.vendor], edx
shr eax, 16
@ -700,29 +660,32 @@ proc detect_controller
mov ebx, [edi+4]
mov [ctrl.ctrl_ids], ebx
mov esi, [edi+8]
mov [ctrl.ctrl_setup], esi
mov eax, [edi+8]
mov [ctrl.ctrl_setup], eax
cmp edx, VID_INTEL
jne @F
mov [ctrl.vendor_ids], msg_Intel
pop edi ebx
ret
@@:
cmp edx, VID_NVIDIA
jne @F
mov [ctrl.vendor_ids], msg_NVidia
pop edi ebx
ret
@@:
.err:
xor eax, eax
mov [ctrl.vendor_ids], eax ;something wrong ?
pop edi ebx
ret
endp
align 4
proc init_controller
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 4
mov ebx, eax
and eax, 0xFFFF
mov [ctrl.pci_cmd], eax
@ -730,55 +693,55 @@ proc init_controller
mov [ctrl.pci_stat], ebx
mov esi, msgPciCmd
call SysMsgBoardStr
invoke SysMsgBoardStr
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPciStat
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [ctrl.pci_stat]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgMixIsaIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFFE
mov [ctrl.codec_io_base], eax
mov esi, msgCtrlIsaIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x14
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFC0
mov [ctrl.ctrl_io_base], eax
mov esi, msgMixMMIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x18
mov [ctrl.codec_mem_base], eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgCtrlMMIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x1C
mov [ctrl.ctrl_mem_base], eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
if 0
@ -787,11 +750,11 @@ if 0
jne .default
mov esi, msgIrqMap
call SysMsgBoardStr
stdcall PciRead8, 0, 0xF8, 0x61
invoke SysMsgBoardStr
invoke PciRead8, 0, 0xF8, 0x61
and eax, 0xFF
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
btr eax, 7 ;when bit 7 set remap disabled
jnc @F
xor eax, eax
@ -799,12 +762,12 @@ if 0
end if
.default:
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x3C
and eax, 0xFF
@@:
mov [ctrl.int_line], eax
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
invoke PciRead8, [ctrl.bus], [ctrl.devfn], 0x41
and eax, 0xFF
mov [ctrl.cfg_reg], eax
@ -837,10 +800,10 @@ PG_NOCACHE equ 0x018
align 4
proc set_ICH4
stdcall MapIoMem, [ctrl.codec_mem_base], 0x1000, PG_SW+PG_NOCACHE
invoke MapIoMem, [ctrl.codec_mem_base], 0x1000, PG_SW+PG_NOCACHE
mov [ctrl.codec_mem_base], eax
stdcall MapIoMem, [ctrl.ctrl_mem_base], 0x1000, PG_SW+PG_NOCACHE
invoke MapIoMem, [ctrl.ctrl_mem_base], 0x1000, PG_SW+PG_NOCACHE
mov [ctrl.ctrl_mem_base], eax
mov [ctrl.codec_read16], codec_mem_r16 ;virtual
@ -888,21 +851,21 @@ proc init_codec
endl
mov esi, msgControl
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, CTRL_STAT
call [ctrl.ctrl_read32]
push eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
cmp eax, 0xFFFFFFFF
je .err
@ -968,14 +931,14 @@ proc reset_codec
if DEBUG
mov esi, msgCFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax ; timeout error
ret
.ok:
if DEBUG
mov esi, msgResetOk
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
@ -995,7 +958,7 @@ proc warm_reset
if DEBUG
mov esi, msgWarm
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov [counter], 10 ; total 10*100 ms = 1s
@ -1013,7 +976,7 @@ proc warm_reset
if DEBUG
mov esi, msgWRFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.fail:
stc
@ -1035,7 +998,7 @@ proc cold_reset
if DEBUG
mov esi, msgCold
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, 400000 ; wait 400 ms
@ -1057,7 +1020,7 @@ proc cold_reset
if DEBUG
mov esi, msgCRFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.fail:
@ -1065,21 +1028,21 @@ proc cold_reset
ret
.ok:
mov esi, msgControl
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, CTRL_STAT
call [ctrl.ctrl_read32]
push eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
test eax, CTRL_ST_CREADY
@ -1438,8 +1401,6 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
dd 0 ;terminator
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_ICH db '802801AA (ICH)', 13,10, 0
msg_ICH0 db '802801AB (ICH0)', 13,10, 0
msg_ICH2 db '802801BA (ICH2)', 13,10, 0
@ -1495,7 +1456,11 @@ msgCtrlMMIo db 'controller mmio base ',0
msgMixMMIo db 'codec mmio base ',0
msgIrqMap db 'AC97 irq map as ',0
section '.data' data readable writable align 16
align 4
data fixups
end data
section '.data' data readable writable
pcmout_bdl rq 32
buff_list rd 32

View File

@ -1,18 +1,15 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
format PE DLL native 0.05
entry START
DEBUG equ 1
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
DEBUG_IRQ equ 0
@ -30,7 +27,7 @@ if USE_COM_IRQ
ATTCH_IRQ equ 0000111010111000b
end if
CPU_FREQ equ 2600d
CPU_FREQ equ 2000d
BIT0 EQU 0x00000001
BIT1 EQU 0x00000002
@ -251,35 +248,23 @@ struc CTRL_INFO
.codec_id dd ?
}
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
EVENT_NOTIFY equ 0x00000200
public START
public service_proc
public version
section '.flat' code readable writable executable
include '../struct.inc'
include '../macros.inc'
include '../proc32.inc'
include '../peimport.inc'
section '.flat' code readable align 16
proc START stdcall, state:dword
proc START c uses ebx esi edi, state:dword, cmdline:dword
cmp [state], 1
jne .stop
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call detect_controller
@ -288,9 +273,9 @@ proc START stdcall, state:dword
if DEBUG
mov esi, [ctrl.vendor_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, [ctrl.ctrl_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
@ -306,10 +291,10 @@ proc START stdcall, state:dword
call setup_codec
mov esi, msgPrimBuff
call SysMsgBoardStr
invoke SysMsgBoardStr
call create_primary_buff
mov esi, msgDone
call SysMsgBoardStr
invoke SysMsgBoardStr
if IRQ_REMAP
pushf
@ -322,13 +307,13 @@ proc START stdcall, state:dword
test ebx, ebx
jz .skip
bts ax, bx ;mask old line
.skip
.skip:
bts ax, IRQ_LINE ;mask new ine
out 0x21, al
mov al, ah
out 0xA1, al
;remap IRQ
stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
invoke PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
mov dx, 0x4d0 ;8259 ELCR1
in al, dx
@ -337,7 +322,7 @@ proc START stdcall, state:dword
mov [ctrl.int_line], IRQ_LINE
popf
mov esi, msgRemap
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, VALID_IRQ
@ -350,19 +335,19 @@ proc START stdcall, state:dword
bt eax, ebx
jnc .fail_msg
stdcall AttachIntHandler, ebx, ac97_irq, dword 0
invoke AttachIntHandler, ebx, ac97_irq, 0
.reg:
stdcall RegService, sz_sound_srv, service_proc
invoke RegService, sz_sound_srv, service_proc
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
ret
.fail_msg:
call SysMsgBoardStr
invoke SysMsgBoardStr
xor eax, eax
ret
.stop:
@ -399,7 +384,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgPlay
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call play
ret
@ -408,7 +393,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgStop
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call stop
ret
@ -455,7 +440,7 @@ proc ac97_irq
if DEBUG_IRQ
mov esi, msgIRQ
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov edx, PCM_OUT_CR_REG
@ -507,7 +492,7 @@ endp
align 4
proc create_primary_buff
stdcall KernelAlloc, 0x10000
invoke KernelAlloc, 0x10000
mov [ctrl.buffer], eax
mov edi, eax
@ -517,7 +502,7 @@ proc create_primary_buff
rep stosd
mov eax, [ctrl.buffer]
call GetPgAddr
invoke GetPgAddr
mov ebx, 0xC0004000
mov ecx, 4
@ -570,7 +555,7 @@ proc create_primary_buff
mov eax, pcmout_bdl
mov ebx, eax
call GetPgAddr ;eax
invoke GetPgAddr ;eax
and ebx, 0xFFF
add eax, ebx
@ -593,143 +578,132 @@ endp
align 4
proc detect_controller
locals
last_bus dd ?
bus dd ?
devfn dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
push ebx
invoke GetPCIList
mov ebx, eax
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
mov eax, [eax+PCIDEV.fd]
cmp eax, ebx
je .found
add edi, 12
jmp @B
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
je .err
cmp [eax+PCIDEV.class], 0x060100 ;pci-isa
jne .no_bridge
movzx edx, [eax+PCIDEV.bus]
mov [brg_bus], edx
movzx edx, [eax+PCIDEV.devfn]
mov [brg_devfn], edx
.no_bridge:
mov edx, [eax+PCIDEV.vendor_device_id]
mov esi, devices
@@:
cmp dword [esi], 0
jz .next_dev
cmp dword [esi], edx
jz .found
add esi, 12
jmp @b
.err:
xor eax, eax
pop ebx
ret
.found:
mov ebx, [bus]
movzx ebx, [eax+PCIDEV.bus]
mov [ctrl.bus], ebx
mov ecx, [devfn]
movzx ecx, [eax+PCIDEV.devfn]
mov [ctrl.devfn], ecx
mov edx, eax
mov eax, edx
and edx, 0xFFFF
mov [ctrl.vendor], edx
shr eax, 16
mov [ctrl.dev_id], eax
mov ebx, [edi+4]
mov ebx, [esi+4]
mov [ctrl.ctrl_ids], ebx
mov [ctrl.vendor_ids], msg_SIS
mov esi, [edi+8]
mov [ctrl.ctrl_setup], esi
ret
.err:
xor eax, eax
mov eax, [esi+8]
mov [ctrl.ctrl_setup], eax
pop ebx
ret
endp
align 4
proc init_controller
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 4
mov ebx, eax
and eax, 0xFFFF
or al, 5
invoke PciWrite16, [ctrl.bus], [ctrl.devfn], 4, eax
movzx eax, bx
mov [ctrl.pci_cmd], eax
shr ebx, 16
mov [ctrl.pci_stat], ebx
mov esi, msgPciCmd
call SysMsgBoardStr
invoke SysMsgBoardStr
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPciStat
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [ctrl.pci_stat]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgMixIsaIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFFE
mov [ctrl.codec_io_base], eax
mov esi, msgCtrlIsaIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x14
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFC0
mov [ctrl.ctrl_io_base], eax
mov esi, msgMixMMIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x18
mov [ctrl.codec_mem_base], eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgCtrlMMIo
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x1C
mov [ctrl.ctrl_mem_base], eax
call dword2str
call SysMsgBoardStr
.default:
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
and eax, 0xFF
invoke SysMsgBoardStr
invoke PciRead32, [ctrl.bus], [ctrl.devfn], 0x3C
cmp al, 0xFF
jnz @f
movzx eax, ah
add eax, 0x40
invoke PciWrite8, [brg_bus], [brg_devfn], eax, 5
invoke PciWrite8, [ctrl.bus], [ctrl.devfn], 0x3C, 5
mov al, 5
@@:
and eax, 0xFF
mov [ctrl.int_line], eax
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
invoke PciRead8, [ctrl.bus], [ctrl.devfn], 0x41
and eax, 0xFF
mov [ctrl.cfg_reg], eax
@ -786,27 +760,27 @@ proc init_codec
endl
mov esi, msgControl
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, CTRL_STAT
call [ctrl.ctrl_read32]
push eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
cmp eax, 0xFFFFFFFF
je .err
test eax, CTRL_ST_CREADY
jnz .done ;;;;;.ready
jnz .ready
call reset_codec
test eax, eax
@ -866,7 +840,7 @@ proc reset_codec
if DEBUG
mov esi, msgCFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax ; timeout error
ret
@ -888,7 +862,7 @@ proc warm_reset
if DEBUG
mov esi, msgWarm
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov [counter], 10 ; total 10*100 ms = 1s
@ -906,7 +880,7 @@ proc warm_reset
if DEBUG
mov esi, msgWRFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.fail:
stc
@ -928,7 +902,7 @@ proc cold_reset
if DEBUG
mov esi, msgCold
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, 400000 ; wait 400 ms
@ -950,7 +924,7 @@ proc cold_reset
if DEBUG
mov esi, msgCRFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.fail:
@ -958,21 +932,21 @@ proc cold_reset
ret
.ok:
mov esi, msgControl
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, GLOB_CTRL
call [ctrl.ctrl_read32]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
invoke SysMsgBoardStr
mov edx, CTRL_STAT
call [ctrl.ctrl_read32]
push eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
test eax, CTRL_ST_CREADY
@ -1089,12 +1063,6 @@ endp
align 4
proc codec_write stdcall, ac_reg:dword
push eax
call check_semafore
and eax, eax
jz .err
pop eax
mov esi, [ac_reg]
mov edx, esi
call [ctrl.codec_write16]
@ -1102,9 +1070,6 @@ proc codec_write stdcall, ac_reg:dword
shr esi, 1
bts [codec.shadow_flag], esi
ret
.err:
pop eax
ret
endp
align 4
@ -1124,7 +1089,7 @@ proc codec_check_ready
endp
align 4
proc check_semafore
proc check_semaphore
local counter:DWORD
mov [counter], 100
@ -1180,15 +1145,27 @@ endp
align 4
proc codec_io_r16
push eax edx
call check_semaphore
test eax, eax
pop edx eax
jz .err
add edx, [ctrl.codec_io_base]
in ax, dx
.err:
ret
endp
align 4
proc codec_io_w16
push eax edx
call check_semaphore
test eax, eax
pop edx eax
jz .err
add edx, [ctrl.codec_io_base]
out dx, ax
.err:
ret
endp
@ -1257,8 +1234,6 @@ align 4
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
dd 0
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_AC db '7012 AC97 controller',13,10, 0
msg_SIS db 'Silicon Integrated Systems',13,10, 0
@ -1295,8 +1270,11 @@ msgCtrlMMIo db 'controller mmio base ',0
msgMixMMIo db 'codec mmio base ',0
msgIrqMap db 'AC97 irq map as ',0
section '.data' data readable writable align 16
align 4
data fixups
end data
align 8
pcmout_bdl rq 32
buff_list rd 32
@ -1305,3 +1283,6 @@ ctrl AC_CNTRL
lpc_bus rd 1
civ_val rd 1
brg_bus dd ?
brg_devfn dd ?

View File

@ -1,289 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AD_LOSEL equ BIT5
AD_HPSEL equ BIT10
align 4
proc detect_codec
locals
codec_id dd ?
endl
stdcall codec_read, dword 0x7C
shl eax, 16
mov [codec_id], eax
stdcall codec_read, dword 0x7E
or eax, [codec_id]
mov [codec.chip_id], eax
and eax, 0xFFFFFF00
mov edi, codecs
@@:
mov ebx, [edi]
test ebx, ebx
jz .unknown
cmp eax, ebx
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
jmp @B
.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
align 4
proc detect_chip stdcall, chip_tab:dword
mov eax, [codec.chip_id]
and eax, 0xFF
mov edi, [chip_tab]
@@:
mov ebx, [edi]
cmp ebx, 0xFF
je .unknown
cmp eax,ebx
jne .next
mov eax, [edi+4]
mov [codec.chip_ids], eax
mov esi, eax
call SysMsgBoardStr
ret
.next:
add edi, 8
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
align 4
proc setup_codec
xor eax, eax
stdcall codec_write, dword CODEC_AUX_VOL
mov eax, 0x0B0B
stdcall codec_write, dword CODEC_MASTER_VOL_REG
mov ax, 0x08
stdcall codec_write, dword 0x0C
mov ax, 0x0808
stdcall codec_write, dword CODEC_PCM_OUT_REG
mov ax, 0x0808
stdcall codec_write, dword 0x10
mov ax, 0x0808
stdcall codec_write, dword 0x12
mov ax, 0x0808
stdcall codec_write, dword 0x16
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
stdcall set_sample_rate, dword 48000
.init_error:
xor eax, eax ; exit with error
ret
endp
; param
; eax= volume -10000 - 0 for both channels
align 4
set_master_vol:
cmp eax, 0
jl @F
xor eax, eax
jmp .set
@@:
cmp eax, -9450
jg .set
mov eax, -9450 ;clamp into 6 bits
.set:
cdq
mov ebx, -150
idiv ebx
mov ah, al
stdcall codec_write, dword CODEC_MASTER_VOL_REG
xor eax, eax
ret
align 4
proc get_master_vol stdcall, pvol:dword
stdcall codec_read, dword CODEC_MASTER_VOL_REG
and eax, 0x3F
imul eax, -150
mov ebx, [pvol]
mov [ebx], eax
xor eax, eax
ret
endp
align 4
proc set_sample_rate stdcall, rate:dword
mov eax, [rate]
stdcall codec_write, dword CODEC_PCM_FRONT_DACRATE_REG
ret
endp
patch_AD:
stdcall codec_read, 0x76
or ax, BIT5+BIT10
stdcall codec_write, 0x76
ret
align 16
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
ac_Cirrus db 'Cirrus Logic',13,10,0
chip_unknown db 'unknown codec id ', 0
CHIP_ANALOG equ 0x41445300
CHIP_REALTEK equ 0x414C4700
CHIP_CMEDIA equ 0x434D4900
CHIP_CIRRUS equ 0x43525900
align 16
codecs dd CHIP_ANALOG, ac_Analog, chips_Analog
dd CHIP_CMEDIA, ac_CMedia, chips_CMedia
dd CHIP_REALTEK,ac_Realtek, chips_Realtek
dd CHIP_CIRRUS, ac_Cirrus, chips_Cirrus
dd 0
align 16
chips_Analog dd 0x03, chip_AD1819
dd 0x40, chip_AD1881
dd 0x48, chip_AD1881A
dd 0x60, chip_AD1884
dd 0x61, chip_AD1886
dd 0x62, chip_AD1887
dd 0x63, chip_AD1886A
dd 0x70, chip_AD1980
dd 0x75, chip_AD1985
dd 0xFF
chips_Realtek:
dd 0x10, chip_ALC201a
dd 0x20, chip_ALC650
dd 0x21, chip_ALC650D
dd 0x22, chip_ALC650E
dd 0x23, chip_ALC650F
dd 0x60, chip_ALC655
dd 0x80, chip_ALC658
dd 0x81, chip_ALC658D
dd 0x90, chip_ALC850
dd 0xFF
chips_CMedia dd 0x41, chip_CM9738
dd 0x61, chip_CM9739
dd 0x69, chip_CM9780
dd 0x78, chip_CM9761
dd 0x82, chip_CM9761
dd 0x83, chip_CM9761
dd 0xFF
chips_Cirrus dd 0x00, chip_CS4297
dd 0x10, chip_CS4297A
dd 0x20, chip_CS4298
dd 0x28, chip_CS4294
dd 0x30, chip_CS4299
dd 0x34, chip_CS4299D
dd 0x48, chip_CS4201
dd 0x58, chip_CS4205
dd 0x60, chip_CS4291
dd 0x70, chip_CS4202
dd 0xFF
align 16
;Analog Devices
chip_AD1819 db 'AD1819 ',0dh,0ah,00h
chip_AD1881 db 'AD1881 ',0dh,0ah,00h
chip_AD1881A db 'AD1881A',0dh,0ah,00h
chip_AD1884 db 'AD1885 ',0dh,0ah,00h
chip_AD1885 db 'AD1885 ',0dh,0ah,00h
chip_AD1886 db 'AD1886 ',0dh,0ah,00h
chip_AD1886A db 'AD1886A',0dh,0ah,00h
chip_AD1887 db 'AD1887 ',0dh,0ah,00h
chip_AD1980 db 'AD1980 ',0dh,0ah,00h
chip_AD1985 db 'AD1985 ',0dh,0ah,00h
;Realtek
chip_ALC201a db 'ALC201a',0dh,0ah,00h
chip_ALC650 db 'ALC650 ',0dh,0ah,00h
chip_ALC650D db 'ALC650D',0dh,0ah,00h
chip_ALC650E db 'ALC650E',0dh,0ah,00h
chip_ALC650F db 'ALC650F',0dh,0ah,00h
chip_ALC655 db 'ALC655 ',0dh,0ah,00h
chip_ALC658 db 'ALC658 ',0dh,0ah,00h
chip_ALC658D db 'ALC658D',0dh,0ah,00h
chip_ALC850 db 'ALC850 ',0dh,0ah,00h
;CMedia
chip_CM9738 db 'CMI9738', 0dh,0ah,0
chip_CM9739 db 'CMI9739', 0dh,0ah,0
chip_CM9780 db 'CMI9780', 0dh,0ah,0
chip_CM9761 db 'CMI9761', 0dh,0ah,0
;Cirrus
chip_CS4297 db 'CS4297',13,10,0
chip_CS4297A db 'CS4297A',13,10,0
chip_CS4298 db 'CS4298',13,10,0
chip_CS4294 db 'CS4294',13,10,0
chip_CS4299 db 'CS4299',13,10,0
chip_CS4299D db 'CS4299D',13,10,0
chip_CS4201 db 'CS4201',13,10,0
chip_CS4205 db 'CS4205',13,10,0
chip_CS4291 db 'CS4291',13,10,0
chip_CS4202 db 'CS4202',13,10,0

View File

@ -1,14 +0,0 @@
Немного переделал драйвер звука для чипа SIS
-добавил подключение PCI устройства к контроллеру прерывания
(БИОС неназначил номер прерывания) назначается IRQ 5
-изменил чтение регистра кодека (считывание и запись производится через 'семафор')
в остальном оставил все как есть :)
SIS.obj - просто бинарник
sis.asm - исходник
codec.inc - (добавил номер определения своего кодека)
G@K

File diff suppressed because it is too large Load Diff

View File

@ -11,10 +11,10 @@ entry START
DEBUG = 1
section '.flat' code readable writable executable
include '../proc32.inc'
include '../struct.inc'
include '../macros.inc'
include '../peimport.inc'
VID_INTEL = 0x8086
VID_NVIDIA = 0x10DE
@ -160,20 +160,27 @@ struct SRV
ends
proc START c, state:dword, cmdline:dword
proc START c uses ebx esi edi, state:dword, cmdline:dword
mov eax, [srv_entry]
cmp [state], 1
jne .fail
jne .stop
if DEBUG
mov esi, msgInit
invoke SysMsgBoardStr
end if
test eax, eax
jnz .done
call detect_controller
ret
.fail:
.stop:
test eax, eax
jz .done
leave
jmp eax
.done:
xor eax, eax
ret
endp
@ -229,10 +236,6 @@ endl
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
if DEBUG
mov esi, msgNotFound
invoke SysMsgBoardStr
end if
xor eax, eax
ret
.found:
@ -402,13 +405,10 @@ emu10k1x db 'EMU10K1X', 0
intelhda db 'INTEL_HDA', 0
msgInit db 'Detecting hardware...',13,10,0
msgNotFound db 'No compatible soundcard found!',13,10,0
msgFail db 'Failed',13,10,0
msgFail db 'No compatible soundcard found!',13,10,0
msgLoading db 'Loading ',0
msgNewline db 13,10,0
align 4
data fixups
end data
include '../peimport.inc'

View File

@ -5,13 +5,11 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
format PE DLL native 0.05
entry START
DEBUG equ 1
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices
@ -311,35 +309,22 @@ struc CTRL_INFO
.codec_id dd ?
}
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
EVENT_NOTIFY equ 0x00000200
public START
public service_proc
public version
section '.flat' code readable writable executable
include '../struct.inc'
include '../macros.inc'
include '../proc32.inc'
include '../peimport.inc'
section '.flat' code readable align 16
proc START stdcall, state:dword
proc START c, state:dword, cmdline:dword
cmp [state], 1
jne .stop
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call detect_controller
@ -348,9 +333,9 @@ proc START stdcall, state:dword
if DEBUG
mov esi, [ctrl.vendor_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, [ctrl.ctrl_ids]
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call init_controller
@ -364,10 +349,10 @@ proc START stdcall, state:dword
call setup_codec
mov esi, msgPrimBuff
call SysMsgBoardStr
invoke SysMsgBoardStr
call create_primary_buff
mov esi, msgDone
call SysMsgBoardStr
invoke SysMsgBoardStr
if IRQ_REMAP
pushf
@ -386,7 +371,7 @@ proc START stdcall, state:dword
mov al, ah
out 0xA1, al
stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE ;remap IRQ
invoke PciWrite8, 0, 0xF8, 0x61, IRQ_LINE ;remap IRQ
mov dx, 0x4d0 ;8259 ELCR1
in al, dx
@ -395,7 +380,7 @@ proc START stdcall, state:dword
mov [ctrl.int_line], IRQ_LINE
popf
mov esi, msgRemap
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, VALID_IRQ
@ -408,19 +393,19 @@ proc START stdcall, state:dword
bt eax, ebx
jnc .fail_msg
stdcall AttachIntHandler, ebx, ac97_irq_VIA, dword 0
invoke AttachIntHandler, ebx, ac97_irq_VIA, 0
.reg:
stdcall RegService, sz_sound_srv, service_proc
invoke RegService, sz_sound_srv, service_proc
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
ret
.fail_msg:
call SysMsgBoardStr
invoke SysMsgBoardStr
xor eax, eax
ret
.stop:
@ -456,7 +441,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgPlay
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call play
ret
@ -465,7 +450,7 @@ proc service_proc stdcall, ioctl:dword
jne @F
if DEBUG
mov esi, msgStop
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
call stop
ret
@ -552,7 +537,7 @@ endp
align 4
proc create_primary_buff
stdcall KernelAlloc, 0x10000
invoke KernelAlloc, 0x10000
mov [ctrl.buffer], eax
mov edi, eax
@ -562,7 +547,7 @@ proc create_primary_buff
rep stosd
mov eax, [ctrl.buffer]
call GetPgAddr
invoke GetPgAddr
mov edi, pcmout_bdl
stosd
mov eax, 0x80004000
@ -590,7 +575,7 @@ proc create_primary_buff
mov eax, pcmout_bdl
mov ebx, eax
call GetPgAddr
invoke GetPgAddr
and ebx, 0xFFF
add eax, ebx
@ -669,7 +654,7 @@ proc detect_controller
xor eax, eax
mov [bus], eax
inc eax
call PciApi
invoke PciApi
cmp eax, -1
je .err
@ -678,7 +663,7 @@ proc detect_controller
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
invoke PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
@ -738,7 +723,7 @@ endp
align 4
proc init_controller
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
mov ebx, eax
and eax, 0xFFFF
mov [ctrl.pci_cmd], eax
@ -746,27 +731,27 @@ proc init_controller
mov [ctrl.pci_stat], ebx
mov esi, msgPciCmd
call SysMsgBoardStr
invoke SysMsgBoardStr
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPciStat
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [ctrl.pci_stat]
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgCtrlIsaIo
call SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
invoke SysMsgBoardStr
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
and eax, 0xFFC0
mov [ctrl.ctrl_io_base], eax
.default:
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
and eax, 0xFF
@@:
mov [ctrl.int_line], eax
@ -813,19 +798,19 @@ proc init_codec
endl
mov esi, msgControl
call SysMsgBoardStr
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
invoke SysMsgBoardStr
invoke PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
and eax, 0xFF
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
invoke SysMsgBoardStr
invoke PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
and eax, 0xFF
push eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
test eax, VIA_ACLINK_C00_READY
@ -854,7 +839,7 @@ endp
align 4
proc reset_codec
stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \
invoke PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \
VIA_ACLINK_CTRL_ENABLE or VIA_ACLINK_CTRL_RESET or VIA_ACLINK_CTRL_SYNC
mov eax, 100000 ; wait 100 ms
call StallExec
@ -864,14 +849,14 @@ proc reset_codec
if DEBUG
mov esi, msgCFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax ; timeout error
ret
.ok:
if DEBUG
mov esi, msgResetOk
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
xor eax, eax
inc eax
@ -885,11 +870,11 @@ proc cold_reset
counter dd ?
endl
stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0
invoke PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0
if DEBUG
mov esi, msgCold
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, 100000 ; wait 100 ms ;400000 ; wait 400 ms
@ -897,11 +882,11 @@ proc cold_reset
;; ACLink on, deassert ACLink reset, VSR, SGD data out
;; note - FM data out has trouble with non VRA codecs !!
stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT
invoke PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT
mov [counter], 16 ; total 20*100 ms = 2s
.wait:
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
invoke PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
test eax, VIA_ACLINK_C00_READY
jnz .ok
@ -913,7 +898,7 @@ proc cold_reset
if DEBUG
mov esi, msgCRFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
.fail:
@ -921,18 +906,18 @@ proc cold_reset
ret
.ok:
mov esi, msgControl
call SysMsgBoardStr
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
invoke SysMsgBoardStr
invoke PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStatus
call SysMsgBoardStr
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
invoke SysMsgBoardStr
invoke PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT
and eax, 0xFF
push eax
call dword2str
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
test eax, VIA_ACLINK_C00_READY ;CTRL_ST_CREADY
@ -1087,7 +1072,7 @@ proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax
.err:
if DEBUG
mov esi, msgCInvalid
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
mov eax, -1 ; invalid codec error
ret
@ -1120,7 +1105,7 @@ proc codec_write stdcall, ac_reg:dword
.err:
if DEBUG
mov esi, msgCFail
call SysMsgBoardStr
invoke SysMsgBoardStr
end if
;mov eax, -1 ; codec not ready error
ret
@ -1244,8 +1229,6 @@ devices dd (CTRL_VT82C686 shl 16)+VID_VIA,msg_VT82C686,set_VIA
dd 0 ;terminator
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_VT82C686 db 'VT82C686', 13,10, 0
msg_VT8233 db 'VT8233', 13,10, 0
msg_VIA db 'VIA' , 13,10, 0
@ -1284,9 +1267,11 @@ msgCtrlIsaIo db 'controller io base ',0
;msgMixMMIo db 'codec mmio base ',0
;msgIrqMap db 'AC97 irq map as ',0
align 4
data fixups
end data
section '.data' data readable writable align 16
align 8
pcmout_bdl rq 32
buff_list rd 32

View File

@ -1,438 +0,0 @@
; Stub of videodriver for RDC Semiconductor Co. M2010/M2012 videocards (controller names: R3306/R3308).
; It is used in SoC produced by DMP Electronics Inc.:
; Vortex86MX (contains RDC M2010 graphics card, appears in eBox-3300MX)
; Vortex86MX+ (contains RDC M2012 graphics card, appears in eBox-3310MX)
; Link to manufacturers websites -
; RDC Semiconductor Co.: http://www.rdc.com.tw
; DM&P Electronics Inc.: http://www.dmp.com.tw and http://www.compactpc.com.tw
; Code stolen from vidintel.asm driver (c) by CleverMouse and adapted for RDC.
; When the start procedure gets control,
; it tries to detect preferred resolution,
; sets the detected resolution assuming 32-bpp VESA mode and exits
; (without registering a service).
; Detection can be overloaded with compile-time settings
; use_predefined_mode/predefined_width/predefined_height.
; set predefined resolution here
use_predefined_mode = 0;1
predefined_width = 0;1366
predefined_height = 0;768
; standard driver stuff
format MS COFF
DEBUG = 1
include 'proc32.inc'
include 'imports.inc'
public START
public version
section '.flat' code readable align 16
; the start procedure (see the description above)
START:
; 1. Detect device. Abort if not found.
push esi
call DetectDevice
test esi, esi
jz .return0
;{START}yogev_ezra: temporary exit after detection
pusha
mov esi, exitmsg
call SysMsgBoardStr
popa
jmp .return0
;{END}yogev_ezra: temporary exit after detection
; 2. Detect optimal mode unless the mode is given explicitly. Abort if failed.
if use_predefined_mode = 0
call DetectMode
end if
cmp [width], 0
jz .return0_cleanup
; 3. Set the detected mode.
call SetMode
; 4. Cleanup and return.
.return0_cleanup:
stdcall FreeKernelSpace, esi
.return0:
pop esi
xor eax, eax
ret 4
; check that there is RDC videocard
; if so, map MMIO registers and set internal variables
; esi points to MMIO block; NULL means no device
DetectDevice:
; 1. Sanity check: check that we are dealing with RDC videocard.
; Integrated video device for RDC is always at PCI:0:13:0 (bus:dev:fn=0:0d:0)
xor esi, esi ; initialize return value to NULL
; 1a. Get PCI VendorID and DeviceID.
push esi ; in: reg=0 (register) -> register 00 means return DeviceID (bits 16-31) + VendorID (bits 0-15)
push 68h ; in: devfn=13:0 | device:5bit (0Dh = 1101) + func:3bit (0 = 000) -> total:1byte (1101000b = 68h)
push esi ; in: bus=0
call PciRead32
; 1b. loword(eax) = ax = VendorID, hiword(eax) = DeviceID.
; Test whether we have RDC Semiconductor Co. chipset.
cmp ax, 17F3h ;VendorID 0x17F3, 'RDC Semiconductor Co.'
jnz .return
; 1c. Say hi including DeviceID.
shr eax, 10h ; now, ax = HIWORD(eax) = PCI DeviceID
push edi
pusha
mov edi, pciid_text ; edi='0000'
call WriteWord
mov esi, hellomsg
call SysMsgBoardStr
popa
; 1d. Test whether we know this DeviceID.
; If this is the case, remember the position of the device in line of RDC cards;
; this knowledge will be useful later.
; Tested on devices with id: 17F3:2010, 17F3:2012.
mov ecx, pciids_num
mov edi, pciids
repnz scasw
pop edi
jnz .return_unknown_pciid
sub ecx, pciids_num - 1
neg ecx
mov [deviceType], ecx
; 1e. Continue saying hi with positive intonation.
pusha
mov esi, knownmsg
call SysMsgBoardStr
popa
; 2. Prepare MMIO region to control the card.
; 2a. Read MMIO physical address from PCI config space.
; According to RDC M2010/M2012 registers manual, their memory-mapped I/O space is located at Base address #1
push 14h ; in: reg=14h (register) -> register 14h means Base address #1 (BAR1) in PCI configuration space
push 68h ; in: devfn=13:0 | device:5bit (0Dh = 1101) + func:3bit (0 = 000) -> total:1byte (1101000b = 68h)
push esi ; in: bus=0
call PciRead32
; 2b. Mask out PCI region type, lower 4 bits.
and al, not 0xF
; 2c. Create virtual mapping of the physical memory.
push 1Bh
push 100000h
push eax
call MapIoMem
; 3. Return.
xchg esi, eax
.return:
ret
; 1f. If we do not know DeviceID, continue saying hi with negative intonation.
.return_unknown_pciid:
pusha
mov esi, unknownmsg
call SysMsgBoardStr
popa
ret
; Convert word in ax to hexadecimal text in edi, advance edi.
WriteWord:
; 1. Convert high byte.
push eax
mov al, ah
call WriteByte
pop eax
; 2. Convert low byte.
; Fall through to WriteByte; ret from WriteByte is ret from WriteWord too.
; Convert byte in al to hexadecimal text in edi, advance edi.
WriteByte:
; 1. Convert high nibble.
push eax
shr al, 4
call WriteNibble
pop eax
; 2. Convert low nibble.
and al, 0xF
; Fall through to WriteNibble; ret from WriteNibble is ret from WriteByte too.
; Convert nibble in al to hexadecimal text in edi, advance edi.
WriteNibble:
; Obvious, isn't it?
cmp al, 10
sbb al, 69h
das
stosb ; This instruction uses EDI implicitly
ret
if use_predefined_mode = 0
; detect resolution of the flat panel
DetectMode:
push esi edi
; 1. Get the location of block of GMBUS* registers.
; Starting with Ironlake, GMBUS* registers were moved.
add esi, 5100h
cmp [deviceType], pciids_num ;ironlake_start
jb @f
add esi, 0xC0000
@@:
; 2. Initialize GMBUS engine.
mov edi, edid
mov ecx, 0x10000
@@:
test byte [esi+8+1], 80h
loopnz @b
jnz .fail
mov dword [esi], 3
test byte [esi+8+1], 4
jz .noreset
call ResetGMBus
jnz .fail
.noreset:
; 3. Send read command.
and dword [esi+20h], 0
mov dword [esi+4], 4E8000A1h
; 4. Wait for data, writing to the buffer as data arrive.
.getdata:
mov ecx, 0x10000
@@:
test byte [esi+8+1], 8
loopz @b
test byte [esi+8+1], 4
jz .dataok
call ResetGMBus
jmp .fail
.dataok:
mov eax, [esi+0Ch]
stosd
cmp edi, edid+80h
jb .getdata
; 5. Wait for bus idle.
mov ecx, 0x10000
@@:
test byte [esi+8+1], 2
loopnz @b
; 6. We got EDID; dump it if DEBUG.
if DEBUG
pusha
xor ecx, ecx
mov esi, edid
mov edi, edid_text
.dumploop:
lodsb
call WriteByte
mov al, ' '
stosb
inc cl
test cl, 15
jnz @f
mov byte [edi-1], 13
mov al, 10
stosb
@@:
test cl, cl
jns .dumploop
mov esi, edidmsg
call SysMsgBoardStr
popa
end if
; 7. Test whether EDID is good.
; 7a. Signature: 00 FF FF FF FF FF FF 00.
mov esi, edid
cmp dword [esi], 0xFFFFFF00
jnz .fail
cmp dword [esi+4], 0x00FFFFFF
jnz .fail
; 7b. Checksum must be zero.
xor edx, edx
mov ecx, 80h
@@:
lodsb
add dl, al
loop @b
jnz .fail
; 8. Get width and height from EDID.
xor eax, eax
mov ah, [esi-80h+3Ah]
shr ah, 4
mov al, [esi-80h+38h]
mov [width], eax
mov ah, [esi-80h+3Dh]
shr ah, 4
mov al, [esi-80h+3Bh]
mov [height], eax
; 9. Return.
.fail:
pop edi esi
ret
; reset bus, clear all errors
ResetGMBus:
; look into the PRM
mov dword [esi+4], 80000000h
mov dword [esi+4], 0
mov ecx, 0x10000
@@:
test byte [esi+8+1], 2
loopnz @b
ret
end if
; set resolution [width]*[height]
SetMode:
; 1. Program the registers of videocard.
; look into the PRM
cli
; or byte [esi+7000Ah], 0Ch ; PIPEACONF: disable Display+Cursor Planes
; or byte [esi+7100Ah], 0Ch ; PIPEBCONF: disable Display+Cursor Planes
xor eax, eax
xor edx, edx
cmp [deviceType], pciids_num ;i965_start
jb @f
mov dl, 9Ch - 84h
@@:
; or byte [esi+71403h], 80h ; VGACNTRL: VGA Display Disable
and byte [esi+70080h], not 27h ; CURACNTR: disable cursor A
mov dword [esi+70084h], eax ; CURABASE: force write to CURA* regs
and byte [esi+700C0h], not 27h ; CURBCNTR: disable cursor B
mov dword [esi+700C4h], eax ; CURBBASE: force write to CURB* regs
and byte [esi+70183h], not 80h ; DSPACNTR: disable Primary A Plane
mov dword [esi+edx+70184h], eax ; DSPALINOFF/DSPASURF: force write to DSPA* regs
and byte [esi+71183h], not 80h ; DSPBCNTR: disable Primary B Plane
mov dword [esi+edx+71184h], eax ; DSPBLINOFF/DSPBSURF: force write to DSPB* regs
if 1
cmp [deviceType], pciids_num ;ironlake_start
jae .disable_pipes
mov edx, 10000h
or byte [esi+70024h], 2 ; PIPEASTAT: clear VBLANK status
or byte [esi+71024h], 2 ; PIPEBSTAT: clear VBLANK status
.wait_vblank_preironlake1:
mov ecx, 1000h
loop $
test byte [esi+7000Bh], 80h ; PIPEACONF: pipe A active?
jz @f
test byte [esi+70024h], 2 ; PIPEASTAT: got VBLANK?
jz .wait_vblank_preironlake2
@@:
test byte [esi+7100Bh], 80h ; PIPEBCONF: pipe B active?
jz .disable_pipes
test byte [esi+71024h], 2 ; PIPEBSTAT: got VBLANK?
jnz .disable_pipes
.wait_vblank_preironlake2:
dec edx
jnz .wait_vblank_preironlake1
jmp .not_disabled
.disable_pipes:
end if
and byte [esi+7000Bh], not 80h ; PIPEACONF: disable pipe
and byte [esi+7100Bh], not 80h ; PIPEBCONF: disable pipe
cmp [deviceType], pciids_num ;gen4_start
jb .wait_watching_scanline
; g45 and later: use special flag from PIPE*CONF
mov edx, 10000h
@@:
mov ecx, 1000h
loop $
test byte [esi+7000Bh], 40h ; PIPEACONF: wait until pipe disabled
jz @f
dec edx
jnz @b
jmp .not_disabled
@@:
test byte [esi+7100Bh], 40h ; PIPEBCONF: wait until pipe disabled
jz .disabled
mov ecx, 1000h
loop $
dec edx
jnz @b
jmp .not_disabled
; pineview and before: wait while scanline still changes
.wait_watching_scanline:
mov edx, 1000h
.dis1:
push dword [esi+71000h]
push dword [esi+70000h]
mov ecx, 10000h
loop $
pop eax
xor eax, [esi+70000h]
and eax, 1FFFh
pop eax
jnz .notdis1
xor eax, [esi+71000h]
and eax, 1FFFh
jz .disabled
.notdis1:
dec edx
jnz .dis1
.not_disabled:
sti
jmp .return
.disabled:
lea eax, [esi+61183h]
cmp [deviceType], pciids_num ;ironlake_start
jb @f
add eax, 0xE0000 - 0x60000
@@:
lea edx, [esi+60000h]
test byte [eax], 40h
jz @f
add edx, 1000h
@@:
mov eax, [width]
dec eax
shl eax, 16
mov ax, word [height]
dec eax
mov dword [edx+1Ch], eax ; PIPEASRC: set source image size
ror eax, 16
mov dword [edx+10190h], eax ; for old cards
mov ecx, [width]
add ecx, 15
and ecx, not 15
shl ecx, 2
mov dword [edx+10188h], ecx ; DSPASTRIDE: set scanline length
mov dword [edx+10184h], 0 ; DSPALINOFF: force write to DSPA* registers
and byte [esi+61233h], not 80h ; PFIT_CONTROL: disable panel fitting
or byte [edx+1000Bh], 80h ; PIPEACONF: enable pipe
; and byte [edx+1000Ah], not 0Ch ; PIPEACONF: enable Display+Cursor Planes
or byte [edx+10183h], 80h ; DSPACNTR: enable Display Plane A
sti
; 2. Notify the kernel that resolution has changed.
call GetDisplay
mov edx, [width]
mov dword [eax+8], edx
mov edx, [height]
mov dword [eax+0Ch], edx
mov [eax+18h], ecx
mov eax, [width]
dec eax
dec edx
call SetScreen
.return:
ret
align 4
hellomsg db 'RDC videocard detected, PciId=17F3:' ;VendorID 0x17F3, 'RDC Semiconductor Co.'
pciid_text db '0000'
db ', which is ', 0
knownmsg db 'known',13,10,0
unknownmsg db 'unknown',13,10,0
exitmsg db 'Card detected successfully, exiting driver...',13,10,0
if DEBUG
edidmsg db 'EDID successfully read:',13,10
edid_text rb 8*(16*3+1)
db 0
end if
version:
dd 0x50005
width dd predefined_width
height dd predefined_height
pciids:
dw 0x2010 ; M2010 - appears in eBox-3300MX (Vortex86MX SoC)
dw 0x2012 ; M2012 - appears in eBox-3310MX (Vortex86MX+ SoC)
pciids_num = ($ - pciids) / 2
align 4
deviceType dd ?
edid rb 0x80