intel_hda: Convert to PE. Apply source format rules. Some changes to get/set master volume. Enable unsolicited events.

git-svn-id: svn://kolibrios.org@5048 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Asper 2014-08-21 00:30:45 +00:00
parent d3545f769e
commit 2dab47a972
7 changed files with 3476 additions and 3771 deletions

View File

@ -131,7 +131,6 @@ FASM_PROGRAMS:=\
drivers/emu10k1x.obj:DRIVERS/EMU10K1X.OBJ:$(KERNEL)/drivers/emu10k1x.asm \ drivers/emu10k1x.obj:DRIVERS/EMU10K1X.OBJ:$(KERNEL)/drivers/emu10k1x.asm \
drivers/fm801.obj:DRIVERS/FM801.OBJ:$(KERNEL)/drivers/fm801.asm \ drivers/fm801.obj:DRIVERS/FM801.OBJ:$(KERNEL)/drivers/fm801.asm \
drivers/infinity.obj:DRIVERS/INFINITY.OBJ:$(KERNEL)/drivers/infinity.asm \ drivers/infinity.obj:DRIVERS/INFINITY.OBJ:$(KERNEL)/drivers/infinity.asm \
drivers/intel_hda.obj:DRIVERS/intel_hda.obj:$(REPOSITORY)/drivers/audio/intel_hda/intel_hda.asm \
drivers/sb16.obj:DRIVERS/SB16.OBJ:$(KERNEL)/drivers/sb16/sb16.asm \ drivers/sb16.obj:DRIVERS/SB16.OBJ:$(KERNEL)/drivers/sb16/sb16.asm \
drivers/sound.obj:DRIVERS/SOUND.OBJ:$(KERNEL)/drivers/sound.asm \ drivers/sound.obj:DRIVERS/SOUND.OBJ:$(KERNEL)/drivers/sound.asm \
drivers/intelac97.obj:DRIVERS/INTELAC97.OBJ:$(KERNEL)/drivers/intelac97.asm \ drivers/intelac97.obj:DRIVERS/INTELAC97.OBJ:$(KERNEL)/drivers/intelac97.asm \
@ -230,6 +229,7 @@ FASM_PROGRAMS_PESTRIP:=\
drivers/rdc.sys:DRIVERS/RDC.SYS:$(REPOSITORY)/drivers/video/rdc.asm \ drivers/rdc.sys:DRIVERS/RDC.SYS:$(REPOSITORY)/drivers/video/rdc.asm \
drivers/ps2mouse.sys:DRIVERS/PS2MOUSE.SYS:$(REPOSITORY)/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm \ drivers/ps2mouse.sys:DRIVERS/PS2MOUSE.SYS:$(REPOSITORY)/drivers/mouse/ps2mouse4d/trunk/ps2mouse.asm \
drivers/tmpdisk.sys:DRIVERS/TMPDISK.SYS:$(REPOSITORY)/drivers/disk/tmpdisk.asm \ drivers/tmpdisk.sys:DRIVERS/TMPDISK.SYS:$(REPOSITORY)/drivers/disk/tmpdisk.asm \
drivers/intel_hda.sys:DRIVERS/intel_hda.sys:$(REPOSITORY)/drivers/audio/intel_hda/intel_hda.asm \
# end of list # end of list
# The list of all FASM programs with one main FASM file for CD image. # 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. # Format of an item is exactly the same as in the previous list.

View File

@ -40,13 +40,13 @@ proc codec_exec_verb stdcall, cmd:dword;, res:dword <- returned in eax
mov eax, -1 mov eax, -1
ret ret
@@: @@:
if FDEBUG ;YAHOO if FDEBUG
push eax esi push eax esi
mov esi, msgVerbQuery mov esi, msgVerbQuery
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ebx mov eax, ebx
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -64,16 +64,15 @@ proc codec_exec_verb stdcall, cmd:dword;, res:dword <- returned in eax
jz .end_debug jz .end_debug
push eax esi push eax esi
mov esi, msgVerbAnswer mov esi, msgVerbAnswer
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, edx mov eax, edx
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
.end_debug: .end_debug:
end if end if
@@: @@:
;call snd_hda_power_down ;call snd_hda_power_down
cmp edx, -1 cmp edx, -1
jne .l1 jne .l1
@ -88,7 +87,7 @@ proc codec_exec_verb stdcall, cmd:dword;, res:dword <- returned in eax
if DEBUG if DEBUG
push esi push esi
mov esi, emsgBusResetFatalComm mov esi, emsgBusResetFatalComm
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
call azx_bus_reset call azx_bus_reset
@ -199,7 +198,6 @@ proc snd_hda_get_sub_nodes stdcall, nid:dword;, start_id:dword <- returned in
inc eax inc eax
@@: @@:
and eax, 0x7FFF7FFF and eax, 0x7FFF7FFF
ret ret
endp endp
@ -246,10 +244,10 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
jnz .conn_list_ok jnz .conn_list_ok
if DEBUG if DEBUG
mov esi, emsgConnListNotAvailable mov esi, emsgConnListNotAvailable
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [nid] mov eax, [nid]
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
xor eax, eax xor eax, eax
dec eax dec eax
@ -333,22 +331,22 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, emsgInvConnList mov esi, emsgInvConnList
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [nid] mov eax, [nid]
stdcall fdword2str, 1 stdcall fdword2str, 1
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, strSemicolon mov esi, strSemicolon
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ecx mov eax, ecx
stdcall fdword2str, 0 stdcall fdword2str, 0
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, strSemicolon mov esi, strSemicolon
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [parm] mov eax, [parm]
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
xor eax, eax xor eax, eax
@ -372,18 +370,18 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
push eax esi push eax esi
push esi push esi
mov esi, emsgInvDepRangeVal mov esi, emsgInvDepRangeVal
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
push eax push eax
mov eax, esi mov eax, esi
stdcall fdword2str, 0 stdcall fdword2str, 0
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, strSemicolon mov esi, strSemicolon
call SysMsgBoardStr invoke SysMsgBoardStr
pop eax pop eax
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
jmp .continue jmp .continue
@ -398,7 +396,7 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
if DEBUG if DEBUG
push esi push esi
mov esi, emsgTooManyConns mov esi, emsgTooManyConns
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
pop ecx pop ecx
@ -426,7 +424,7 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
if DEBUG if DEBUG
push esi push esi
mov esi, emsgTooManyConns mov esi, emsgTooManyConns
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
jmp .err_out jmp .err_out
@ -511,12 +509,11 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
mov eax, [codec.afg] mov eax, [codec.afg]
test eax, eax test eax, eax
jnz @f jnz @f
;Asper+: try to use another codec if possible [ ;Asper+: try to use another codec if possible [
if DEBUG if DEBUG
push esi push esi
mov esi, msgNoAFGFound mov esi, msgNoAFGFound
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
push ecx push ecx
@ -534,7 +531,7 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
if DEBUG if DEBUG
push esi push esi
mov esi, emsgNoAFGorMFGFound mov esi, emsgNoAFGorMFGFound
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
.skip_codec: .skip_codec:
@ -551,7 +548,7 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
if DEBUG if DEBUG
push esi push esi
mov esi, emsgNoMem mov esi, emsgNoMem
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
pop ebx pop ebx
@ -571,9 +568,7 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
test eax, eax test eax, eax
jnz @f jnz @f
stdcall snd_hda_codec_read, ebx, 0, AC_VERB_GET_SUBSYSTEM_ID, 0 stdcall snd_hda_codec_read, ebx, 0, AC_VERB_GET_SUBSYSTEM_ID, 0
@@: @@:
; power up all before initialization ; power up all before initialization
stdcall snd_hda_set_power_state, ebx, AC_PWRST_D0 stdcall snd_hda_set_power_state, ebx, AC_PWRST_D0
@ -602,7 +597,7 @@ proc snd_hda_codec_configure
if DEBUG if DEBUG
push esi push esi
mov esi, emsgNoParserAvailable mov esi, emsgNoParserAvailable
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
@@: @@:
@ -630,7 +625,7 @@ proc get_codec_name
mov eax, [edi+4] mov eax, [edi+4]
mov [codec.ac_vendor_ids], eax mov [codec.ac_vendor_ids], eax
mov esi, eax mov esi, eax
call SysMsgBoardStr invoke SysMsgBoardStr
.get_chip_name: .get_chip_name:
stdcall detect_chip, [edi+8] stdcall detect_chip, [edi+8]
pop esi edi ebx eax pop esi edi ebx eax
@ -643,10 +638,10 @@ proc get_codec_name
mov [codec.chip_ids], chip_unknown mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown mov esi, chip_unknown
call SysMsgBoardStr invoke SysMsgBoardStr
movzx eax, [codec.chip_id] movzx eax, [codec.chip_id]
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi edi ebx eax pop esi edi ebx eax
ret ret
endp endp
@ -654,7 +649,6 @@ endp
align 4 align 4
proc detect_chip stdcall, chip_tab:dword proc detect_chip stdcall, chip_tab:dword
push eax ebx edi esi push eax ebx edi esi
mov ax, [codec.chip_id] mov ax, [codec.chip_id]
@ -669,7 +663,7 @@ proc detect_chip stdcall, chip_tab:dword
mov eax, [edi+4] mov eax, [edi+4]
mov [codec.chip_ids], eax mov [codec.chip_ids], eax
mov esi, eax mov esi, eax
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi edi ebx eax pop esi edi ebx eax
ret ret
.next: .next:
@ -678,10 +672,10 @@ proc detect_chip stdcall, chip_tab:dword
.unknown: .unknown:
mov [codec.chip_ids], chip_unknown mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown mov esi, chip_unknown
call SysMsgBoardStr invoke SysMsgBoardStr
movzx eax, [codec.chip_id] movzx eax, [codec.chip_id]
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi edi ebx eax pop esi edi ebx eax
ret ret
endp endp
@ -697,19 +691,19 @@ proc setup_fg_nodes
shr ebx, 16 shr ebx, 16
and ebx, 0x7FFF ; nid and ebx, 0x7FFF ; nid
if DEBUG ;YAHOO if DEBUG
push eax esi push eax esi
mov esi, msgSETUP_FG_NODES mov esi, msgSETUP_FG_NODES
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ebx mov eax, ebx
stdcall fdword2str, 1 stdcall fdword2str, 1
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, strSemicolon mov esi, strSemicolon
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ecx mov eax, ecx
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -719,12 +713,12 @@ end if
snd_hda_param_read ebx, AC_PAR_FUNCTION_TYPE snd_hda_param_read ebx, AC_PAR_FUNCTION_TYPE
and eax, 0xFF and eax, 0xFF
if DEBUG ;YAHOO if DEBUG
push eax esi push eax esi
mov esi, msgFG_TYPE mov esi, msgFG_TYPE
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -766,33 +760,33 @@ proc read_widget_caps stdcall, fg_node:dword
and ebx, 0x7FFF ; nid and ebx, 0x7FFF ; nid
mov [codec.start_nid], bx mov [codec.start_nid], bx
if DEBUG ;YAHOO if DEBUG
push eax esi push eax esi
mov esi, msgSETUP_FG_NODES mov esi, msgSETUP_FG_NODES
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ebx mov eax, ebx
stdcall fdword2str, 1 stdcall fdword2str, 1
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, strSemicolon mov esi, strSemicolon
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ecx mov eax, ecx
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
if FDEBUG ;YAHOO if FDEBUG
push esi push esi
mov esi, msgWCaps mov esi, msgWCaps
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
mov eax, ecx mov eax, ecx
shl eax, 2 shl eax, 2
push ebx ecx push ebx ecx
call Kmalloc invoke Kmalloc
pop ecx ebx pop ecx ebx
test eax, eax test eax, eax
jz .err_out jz .err_out
@ -828,7 +822,7 @@ proc read_pin_defaults
mov eax, HDA_PINCFG.sizeof mov eax, HDA_PINCFG.sizeof
mul cl mul cl
push ebx ecx push ebx ecx
call Kmalloc invoke Kmalloc
pop ecx ebx pop ecx ebx
test eax, eax test eax, eax
jz .err_out jz .err_out
@ -840,7 +834,7 @@ proc read_pin_defaults
if FDEBUG if FDEBUG
push eax esi push eax esi
mov esi, msgPinCfgs mov esi, msgPinCfgs
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -958,27 +952,27 @@ proc hda_codec_setup_stream stdcall, nid:dword, stream_tag:dword, channel_id:dwo
if DEBUG if DEBUG
push esi push esi
mov esi, msgHDACodecSetupStream mov esi, msgHDACodecSetupStream
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgStream mov esi, msgStream
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [stream_tag] mov eax, [stream_tag]
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgChannel mov esi, msgChannel
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [channel_id] mov eax, [channel_id]
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgFormat mov esi, msgFormat
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [format] mov eax, [format]
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
mov eax, [stream_tag] mov eax, [stream_tag]
@ -1006,9 +1000,9 @@ proc snd_hda_codec_cleanup_stream stdcall, nid:dword
if DEBUG if DEBUG
push esi push esi
mov esi, msgHDACodecCleanupStream mov esi, msgHDACodecCleanupStream
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_CHANNEL_STREAMID, 0 stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_CHANNEL_STREAMID, 0
@ -1133,6 +1127,51 @@ proc snd_hda_codec_amp_stereo stdcall, nid:dword, direction:dword, idx:dword, ma
ret ret
endp endp
; execute pin sense measurement
proc snd_hda_read_pin_sense stdcall, nid:dword, trigger_sense:dword
mov eax, [trigger_sense]
test eax, eax
jz .no_trigger_sense
stdcall read_pin_cap, [nid]
test eax, AC_PINCAP_TRIG_REQ ;need trigger?
jz .no_trigger_sense
stdcall snd_hda_codec_read, [nid], 0, AC_VERB_SET_PIN_SENSE, 0
.no_trigger_sense:
stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_PIN_SENSE, 0
ret
endp
proc is_jack_detectable stdcall, nid:dword
stdcall read_pin_cap, [nid]
test eax, AC_PINCAP_PRES_DETECT
jz .no
stdcall get_wcaps, [nid]
test eax, AC_WCAP_UNSOL_CAP
jz .no
.yes:
xor eax, eax
inc eax
ret
.no:
xor eax, eax
ret
endp
proc snd_hda_enable_pin_sense stdcall nid:dword, jacktag:dword
push eax
stdcall is_jack_detectable, [nid]
test eax, eax
jz @f
mov eax, [jacktag]
or eax, AC_USRSP_EN
stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_UNSOLICITED_ENABLE, eax
@@:
pop eax
ret
endp
;; set power state of the codec ;; set power state of the codec
proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
@ -1151,7 +1190,6 @@ proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
mov dx, [codec.vendor_id] mov dx, [codec.vendor_id]
cmp dx, 0x14F1 cmp dx, 0x14F1
jne @f jne @f
mov eax, 10000 mov eax, 10000
call StallExec call StallExec
@ -1285,7 +1323,6 @@ chips_VIA dd 0xE721, chip_VT1708B_1
dd 0xFF dd 0xFF
chips_IDT dd 0xFF chips_IDT dd 0xFF
chips_LSI dd 0x1039, chip_LSI1039 chips_LSI dd 0x1039, chip_LSI1039
dd 0x1040, chip_LSI1040 dd 0x1040, chip_LSI1040
dd 0x3026, chip_LSI3026 dd 0x3026, chip_LSI3026
@ -1362,3 +1399,4 @@ chip_LSI1039 db '1039 (Agere Systems HDA Modem)',13,10,0
chip_LSI1040 db '1040 (Agere Systems HDA Modem)',13,10,0 chip_LSI1040 db '1040 (Agere Systems HDA Modem)',13,10,0
chip_LSI3026 db '3026 (Agere Systems HDA Modem)',13,10,0 chip_LSI3026 db '3026 (Agere Systems HDA Modem)',13,10,0
chip_LSI3055 db '3055 (Agere Systems HDA Modem)',13,10,0 chip_LSI3055 db '3055 (Agere Systems HDA Modem)',13,10,0

View File

@ -598,7 +598,6 @@ PIN_HP_AMP equ (AC_PINCTL_HP_EN)
; get widget capabilities ; get widget capabilities
;static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
proc get_wcaps stdcall, nid:dword proc get_wcaps stdcall, nid:dword
push ebx ecx edx push ebx ecx edx
xor eax, eax xor eax, eax
@ -623,7 +622,6 @@ proc get_wcaps stdcall, nid:dword
endp endp
; get the widget type from widget capability bits ; get the widget type from widget capability bits
;#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
proc get_wcaps_type stdcall, wcaps:dword proc get_wcaps_type stdcall, wcaps:dword
mov eax, [wcaps] mov eax, [wcaps]
and eax, AC_WCAP_TYPE and eax, AC_WCAP_TYPE
@ -633,8 +631,6 @@ endp
;static inline unsigned int get_wcaps_channels(u32 wcaps) ;static inline unsigned int get_wcaps_channels(u32 wcaps)
proc get_wcaps_channels stdcall, wcaps:dword proc get_wcaps_channels stdcall, wcaps:dword
; chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
; chans = ((chans << 1) | 1) + 1;
mov eax, [wcaps] mov eax, [wcaps]
and eax, AC_WCAP_CHAN_CNT_EXT and eax, AC_WCAP_CHAN_CNT_EXT
shr eax, 13 shr eax, 13
@ -644,5 +640,4 @@ proc get_wcaps_channels stdcall, wcaps:dword
ret ret
endp endp
;Asper ] ;Asper ]

View File

@ -1,89 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro kernel_export [name]{
forward
if used name
if DEBUG
display 'uses: ',`name,#13,#10
end if
extrn name
end if
}
; all exported kernel functions and data
kernel_export \
RegService,\
GetService,\
ServiceHandler,\
AttachIntHandler,\
GetIntHandler,\
FpuSave,\
FpuRestore,\
ReservePortArea,\
Boot_Log,\
\
PciApi,\
PciRead32,\
PciRead16,\
PciRead8,\
PciWrite8,\
PciWrite16,\
PciWrite32,\
\
AllocPage,\
AllocPages,\
FreePage,\
MapPage,\
MapSpace,\
MapIoMem,\
GetPgAddr,\
CommitPages,\
ReleasePages,\
\
AllocKernelSpace,\
FreeKernelSpace,\
KernelAlloc,\
KernelFree,\
UserAlloc,\
UserFree,\
Kmalloc,\
Kfree,\
CreateRingBuffer,\
\
GetPid,\
CreateObject,\
DestroyObject,\
CreateEvent,\
RaiseEvent,\
WaitEvent,\
DestroyEvent,\
ClearEvent,\
\
LoadCursor,\
SelectHwCursor,\
SetHwCursor,\
HwCursorRestore,\
HwCursorCreate,\
\
SysMsgBoardStr,\
SysMsgBoard,\
GetCurrentTask,\
LoadFile,\
SendEvent,\
SetMouseData,\
Sleep,\
GetTimerTicks,\
\
strncat,\
strncpy,\
strncmp,\
strnlen,\
strchr,\
strrchr,\
\
LFBAddress

View File

@ -1,268 +0,0 @@
; Macroinstructions for defining and calling procedures
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call proc }
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call [proc] }
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call proc
if size@ccall
add esp,size@ccall
end if }
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call [proc]
if size@ccall
add esp,size@ccall
end if }
macro proc [args] ; define procedure
{ common
match name params, args>
\{ define@proc name,<params \} }
prologue@proc equ prologuedef
macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes
push ebp
mov ebp,esp
if localbytes
sub esp,localbytes
end if
end if
irps reg, reglist \{ push reg \} }
epilogue@proc equ epiloguedef
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
{ irps reg, reglist \{ reverse pop reg \}
if parmbytes | localbytes
leave
end if
if flag and 10000b
retn
else
retn parmbytes
end if }
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name
name:
match =stdcall args, statement \{ params equ args
flag = 11b \}
match =stdcall, statement \{ params equ
flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement
flag = 0 \}
virtual at ebp+8
match =uses reglist=,args, params \{ regs equ reglist
params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist
params equ \}
match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (ebp+8)
end virtual
name # % = parmbytes/4
all@vars equ
current = 0
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
macro locals
\{ virtual at ebp-localbytes+current
macro label . \\{ deflocal@proc .,:, \\}
struc db [val] \\{ \common deflocal@proc .,db,val \\}
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
macro endl
\{ purge label
restruc db,dw,dp,dd,dt,dq
restruc rb,rw,rp,rd,rt,rq
restruc byte,word,dword,pword,tword,qword
current = $-(ebp-localbytes)
end virtual \}
macro ret operand
\{ match any, operand \\{ retn operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
end if \} }
macro defargs@proc [arg]
{ common
if ~ arg eq
forward
local ..arg,current@arg
match argname:type, arg
\{ current@arg equ argname
label ..arg type
argname equ ..arg
if dqword eq type
dd ?,?,?,?
else if tbyte eq type
dd ?,?,?
else if qword eq type | pword eq type
dd ?,?
else
dd ?
end if \}
match =current@arg,current@arg
\{ current@arg equ arg
arg equ ..arg
..arg dd ? \}
common
args@proc equ current@arg
forward
restore current@arg
common
end if }
macro deflocal@proc name,def,[val]
{ common
match vars, all@vars \{ all@vars equ all@vars, \}
all@vars equ all@vars name
forward
local ..var,..tmp
..var def val
match =?, val \{ ..tmp equ \}
match any =dup (=?), val \{ ..tmp equ \}
match tmp : value, ..tmp : val
\{ tmp: end virtual
initlocal@proc ..var,def value
virtual at tmp\}
common
match first rest, ..var, \{ name equ first \} }
macro initlocal@proc name,def
{ virtual at name
def
size@initlocal = $ - name
end virtual
position@initlocal = 0
while size@initlocal > position@initlocal
virtual at name
def
if size@initlocal - position@initlocal < 2
current@initlocal = 1
load byte@initlocal byte from name+position@initlocal
else if size@initlocal - position@initlocal < 4
current@initlocal = 2
load word@initlocal word from name+position@initlocal
else
current@initlocal = 4
load dword@initlocal dword from name+position@initlocal
end if
end virtual
if current@initlocal = 1
mov byte [name+position@initlocal],byte@initlocal
else if current@initlocal = 2
mov word [name+position@initlocal],word@initlocal
else
mov dword [name+position@initlocal],dword@initlocal
end if
position@initlocal = position@initlocal + current@initlocal
end while }
macro endp
{ purge ret,locals,endl
finish@proc
purge finish@proc
restore regs@proc
match all,args@proc \{ restore all \}
restore args@proc
match all,all@vars \{ restore all \} }
macro local [var]
{ common
locals
forward done@local equ
match varname[count]:vartype, var
\{ match =BYTE, vartype \\{ varname rb count
restore done@local \\}
match =WORD, vartype \\{ varname rw count
restore done@local \\}
match =DWORD, vartype \\{ varname rd count
restore done@local \\}
match =PWORD, vartype \\{ varname rp count
restore done@local \\}
match =QWORD, vartype \\{ varname rq count
restore done@local \\}
match =TBYTE, vartype \\{ varname rt count
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
rq count+count
restore done@local \\}
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
match :varname:vartype, done@local:var
\{ match =BYTE, vartype \\{ varname db ?
restore done@local \\}
match =WORD, vartype \\{ varname dw ?
restore done@local \\}
match =DWORD, vartype \\{ varname dd ?
restore done@local \\}
match =PWORD, vartype \\{ varname dp ?
restore done@local \\}
match =QWORD, vartype \\{ varname dq ?
restore done@local \\}
match =TBYTE, vartype \\{ varname dt ?
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
dq ?,?
restore done@local \\}
match , done@local \\{ varname vartype
restore done@local \\} \}
match ,done@local
\{ var
restore done@local \}
common
endl }

View File

@ -52,7 +52,6 @@ struc VOLUME_CTL
} }
; retrieve the default device type from the default config value ; retrieve the default device type from the default config value
proc defcfg_type stdcall, node:dword proc defcfg_type stdcall, node:dword
push edx push edx
mov edx, [node] mov edx, [node]
@ -93,7 +92,6 @@ proc defcfg_color stdcall, node:dword
ret ret
endp endp
; destructor ; destructor
proc snd_hda_generic_free proc snd_hda_generic_free
push eax ebx edx edi push eax ebx edx edi
@ -112,19 +110,19 @@ proc snd_hda_generic_free
cmp eax, edi cmp eax, edi
je @f je @f
pusha pusha
call Kfree ;free conn_list invoke Kfree ;free conn_list
popa popa
@@: @@:
mov eax, edx mov eax, edx
mov edx, [edx + HDA_GNODE.next] mov edx, [edx + HDA_GNODE.next]
pusha pusha
call Kfree ;free node invoke Kfree ;free node
popa popa
jmp .next jmp .next
.free_head: .free_head:
mov eax, [spec.nid_list] mov eax, [spec.nid_list]
pusha pusha
call Kfree ;free the very 1st node in the list invoke Kfree ;free the very 1st node in the list
popa popa
mov [spec.nid_list], 0 mov [spec.nid_list], 0
.out: .out:
@ -138,7 +136,7 @@ proc add_new_node stdcall, nid:dword
push ebx ecx edx edi esi push ebx ecx edx edi esi
mov eax, HDA_GNODE.sizeof mov eax, HDA_GNODE.sizeof
call Kmalloc invoke Kmalloc
test eax, eax test eax, eax
jz .err_out ; Not enough memory jz .err_out ; Not enough memory
@ -160,7 +158,7 @@ proc add_new_node stdcall, nid:dword
mov eax, HDA_MAX_CONNECTIONS*2 ;HDA_MAX_CONNECTIONS * sizeof(word) mov eax, HDA_MAX_CONNECTIONS*2 ;HDA_MAX_CONNECTIONS * sizeof(word)
push ebx ecx edx push ebx ecx edx
call Kmalloc ;malloc temporary conn_list invoke Kmalloc ;malloc temporary conn_list
pop edx ecx ebx pop edx ecx ebx
mov edi, eax mov edi, eax
@ -174,7 +172,7 @@ proc add_new_node stdcall, nid:dword
mov eax, edx mov eax, edx
pusha pusha
call Kfree ;free node invoke Kfree ;free node
popa popa
mov eax, ecx mov eax, ecx
jmp .out jmp .out
@ -192,7 +190,7 @@ proc add_new_node stdcall, nid:dword
mov eax, ecx mov eax, ecx
shl ecx, 1 shl ecx, 1
push ebx ecx edx edi push ebx ecx edx edi
call Kmalloc ;malloc conn_list invoke Kmalloc ;malloc conn_list
pop edi edx ecx ebx pop edi edx ecx ebx
shr ecx, 1 shr ecx, 1
test eax, eax test eax, eax
@ -200,7 +198,7 @@ proc add_new_node stdcall, nid:dword
mov eax, edi mov eax, edi
pusha pusha
call Kfree ;free temporary conn_list invoke Kfree ;free temporary conn_list
popa popa
jmp .err_out jmp .err_out
@@: @@:
@ -264,20 +262,20 @@ proc add_new_node stdcall, nid:dword
;if DEBUG ;if DEBUG
; push eax esi ; push eax esi
; mov esi, msgBeeperNid ; mov esi, msgBeeperNid
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; push eax ; push eax
; mov eax, [nid] ; mov eax, [nid]
; stdcall fdword2str, 2 ; stdcall fdword2str, 2
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; ;
; mov esi, msgBeeperValue ; mov esi, msgBeeperValue
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; pop eax ; pop eax
; stdcall fdword2str, 2 ; stdcall fdword2str, 2
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; ;
; mov esi, msgBeepNow ; mov esi, msgBeepNow
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; pop esi eax ; pop esi eax
;end if ;end if
; mov ecx, 256*1 ; mov ecx, 256*1
@ -294,9 +292,9 @@ proc add_new_node stdcall, nid:dword
;if DEBUG ;if DEBUG
; ;push eax esi ; ;push eax esi
; mov esi, msgBeeperValue ; mov esi, msgBeeperValue
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; stdcall fdword2str, 2 ; stdcall fdword2str, 2
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; ;pop esi eax ; ;pop esi eax
;end if ;end if
;.not_beeper: ;.not_beeper:
@ -367,7 +365,7 @@ proc add_new_node stdcall, nid:dword
.out: .out:
mov eax, edi mov eax, edi
pusha pusha
call Kfree ;free temporary conn_list invoke Kfree ;free temporary conn_list
popa popa
xor eax, eax xor eax, eax
pop esi edi edx ecx ebx pop esi edi edx ecx ebx
@ -376,7 +374,7 @@ proc add_new_node stdcall, nid:dword
.err_out: .err_out:
mov eax, edx mov eax, edx
pusha pusha
call Kfree ;free node invoke Kfree ;free node
popa popa
xor eax, eax xor eax, eax
dec eax dec eax
@ -411,7 +409,7 @@ proc build_afg_tree
if FDEBUG if FDEBUG
push esi push esi
mov esi, emsgInvalidAFGSubtree mov esi, emsgInvalidAFGSubtree
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
xor eax, eax xor eax, eax
@ -437,6 +435,33 @@ proc build_afg_tree
ret ret
endp endp
;Asper+[
proc print_afg_tree_nodes
push eax esi edi
mov esi, msgNodeSeq
invoke SysMsgBoardStr
mov edi, [spec.nid_list]
test edi, edi
jz .out
.next_node:
movzx eax, word [edi + HDA_GNODE.nid]
mov esi, msgNID
invoke SysMsgBoardStr
stdcall fdword2str, 3
invoke SysMsgBoardStr
mov eax, [edi + HDA_GNODE.next]
test eax, eax
jz .out
mov edi, eax
jmp .next_node
.out:
pop edi esi eax
ret
endp
;Asper+]
; look for the node record for the given NID ; look for the node record for the given NID
proc hda_get_node stdcall, nid:dword proc hda_get_node stdcall, nid:dword
@ -480,10 +505,10 @@ proc set_eapd stdcall, node:dword ;nid:dword, on:dword
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, msgEnableEAPD mov esi, msgEnableEAPD
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ebx mov eax, ebx
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
.out: .out:
@ -494,7 +519,6 @@ endp
; unmute (and set max vol) the output amplifier ; unmute (and set max vol) the output amplifier
proc unmute_output stdcall, node:dword proc unmute_output stdcall, node:dword
push ebx ecx edx esi push ebx ecx edx esi
mov esi, [node] mov esi, [node]
test [esi + HDA_GNODE.wid_caps], AC_WCAP_OUT_AMP test [esi + HDA_GNODE.wid_caps], AC_WCAP_OUT_AMP
@ -503,9 +527,9 @@ proc unmute_output stdcall, node:dword
if DEBUG if DEBUG
push esi push esi
mov esi, msgUnmuteOut mov esi, msgUnmuteOut
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
@ -528,27 +552,23 @@ proc unmute_output stdcall, node:dword
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, msgAmpVal mov esi, msgAmpVal
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 1 stdcall fdword2str, 1
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, strSemicolon mov esi, strSemicolon
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ecx mov eax, ecx
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
mov [volume.out_amp_node], esi mov [volume.out_amp_node], esi
inc al
mov [volume.num_steps], al mov [volume.num_steps], al
inc cl
mov [volume.step_size], cl mov [volume.step_size], cl
mul cl mul cl
shr eax, 2 imul eax, (100/4)
imul eax, 100
mov [volume.maxDb], eax mov [volume.maxDb], eax
.out: .out:
xor eax, eax xor eax, eax
pop esi edx ecx ebx pop esi edx ecx ebx
@ -566,14 +586,14 @@ proc unmute_input stdcall, node:dword, index:dword
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, msgUnmuteIn mov esi, msgUnmuteIn
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgIdx mov esi, msgIdx
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [index] mov eax, [index]
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -599,16 +619,16 @@ proc select_input_connection stdcall, node:dword, index:dword
mov ebx, [index] mov ebx, [index]
if DEBUG if DEBUG
mov esi, msgConnect mov esi, msgConnect
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgIdx mov esi, msgIdx
call SysMsgBoardStr invoke SysMsgBoardStr
push eax push eax
mov eax, ebx mov eax, ebx
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop eax pop eax
end if end if
stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_CONNECT_SEL, ebx stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_CONNECT_SEL, ebx
@ -630,7 +650,6 @@ proc clear_check_flags
jz .out jz .out
mov esi, eax mov esi, eax
jmp .next_node jmp .next_node
.out: .out:
pop esi eax pop esi eax
ret ret
@ -661,9 +680,9 @@ proc parse_output_path stdcall, node:dword, dac_idx:dword
if DEBUG if DEBUG
push esi push esi
mov esi, msgSkipDigitalOutNode mov esi, msgSkipDigitalOutNode
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
jmp .ret_zero jmp .ret_zero
@ -671,9 +690,9 @@ proc parse_output_path stdcall, node:dword, dac_idx:dword
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, msgAudOutFound mov esi, msgAudOutFound
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -768,12 +787,16 @@ proc parse_output_jack stdcall, jack_type:dword
test [esi + HDA_GNODE.wid_caps], AC_WCAP_DIGITAL test [esi + HDA_GNODE.wid_caps], AC_WCAP_DIGITAL
jnz .continue ; skip SPDIF jnz .continue ; skip SPDIF
@@: @@:
; output as default? push eax
movzx eax, [esi + HDA_GNODE.nid]
stdcall snd_hda_enable_pin_sense, eax, eax ;Asper+: enable unsolicited events for the output pin
pop eax
if DEBUG if DEBUG
pusha pusha
; push esi ; push esi
; mov esi, msgPin_Nid ; mov esi, msgPin_Nid
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; pop esi ; pop esi
movzx eax, [esi + HDA_GNODE.nid] movzx eax, [esi + HDA_GNODE.nid]
movzx ebx, [esi + HDA_GNODE.pin_ctl] movzx ebx, [esi + HDA_GNODE.pin_ctl]
@ -781,38 +804,42 @@ if DEBUG
mov edx, [esi + HDA_GNODE.def_cfg] mov edx, [esi + HDA_GNODE.def_cfg]
mov edi, [esi + HDA_GNODE.amp_out_caps] mov edi, [esi + HDA_GNODE.amp_out_caps]
mov esi, msgPin_Nid mov esi, msgPin_Nid
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgPin_Ctl mov esi, msgPin_Ctl
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ebx mov eax, ebx
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgPin_Caps mov esi, msgPin_Caps
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ecx mov eax, ecx
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgDef_Cfg mov esi, msgDef_Cfg
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, edx mov eax, edx
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgAmp_Out_Caps mov esi, msgAmp_Out_Caps
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, edi mov eax, edi
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
popa popa
end if end if
; output as default?
; test [esi + HDA_GNODE.pin_ctl], AC_PINCTL_OUT_EN ; test [esi + HDA_GNODE.pin_ctl], AC_PINCTL_OUT_EN
; jz .continue ; jz .continue
.use_dac0:
cmp [spec.dac_node], 0
jne .use_dac1
stdcall clear_check_flags stdcall clear_check_flags
stdcall parse_output_path, esi, 0 stdcall parse_output_path, esi, 0
@ -821,6 +848,7 @@ end if
mov edx, [spec.out_pin_node] mov edx, [spec.out_pin_node]
test edx, edx test edx, edx
jz @f jz @f
.use_dac1:
stdcall clear_check_flags stdcall clear_check_flags
stdcall parse_output_path, esi, 1 stdcall parse_output_path, esi, 1
@@: @@:
@ -899,7 +927,7 @@ proc parse_output
if DEBUG if DEBUG
push esi push esi
mov esi, emsgNoProperOutputPathFound mov esi, emsgNoProperOutputPathFound
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
@@: @@:
@ -921,6 +949,10 @@ proc snd_hda_parse_generic_codec
cmp eax, 0 cmp eax, 0
jl .error jl .error
if FDEBUG
stdcall print_afg_tree_nodes ;Asper+
end if
stdcall parse_output stdcall parse_output
xor eax, eax xor eax, eax
.out: .out:

View File

@ -5,32 +5,29 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF format PE DLL native 0.05
section '.flat' code readable writable executable
DEBUG equ 1 DEBUG equ 1
FDEBUG equ 0 FDEBUG equ 0
DEBUG_IRQ equ 0 DEBUG_IRQ equ 0
USE_SINGLE_MODE equ 0 ; 1 = Single mode; 0 = Normal mode. USE_SINGLE_MODE equ 0 ; 1 = Single mode; 0 = Normal mode.
USE_UNSOL_EV equ 1 ; 1 = Use unsolicited events; 0 = Do not use unsolicited events.
TEST_VERSION_NUMBER equ '018e' TEST_VERSION_NUMBER equ '019'
;Asper+ [ ;Asper+ [
SDO_TAG equ 1 ;Asper: Output stream tag id (any number except 0) SDO_TAG equ 1 ;Output stream tag id (any number except 0)
SDO_IDX equ 4 ;Asper: Output stream index SDO_IDX equ 4 ;Output stream index
;According to "Intel® I/O Controller Hub 6 (ICH6) High Definition Audio / AC 97 Programmers Reference Manual (PRM) May 2005 Document" ;According to "Intel® I/O Controller Hub 6 (ICH6) High Definition Audio / AC 97 Programmers Reference Manual (PRM) May 2005 Document"
;and "Intel® I/O Controller Hub 6 (ICH6) Family Datasheet" SDO0=4, ;and "Intel® I/O Controller Hub 6 (ICH6) Family Datasheet" SDO0=4,
;but according to "High Definition Audio Specification Revision 1.0a June 17, 2010" SDO0 depends on the number of SDIs. ;but according to "High Definition Audio Specification Revision 1.0a June 17, 2010" SDO0 depends on the number of SDIs.
SDO_INT equ 1 shl SDO_IDX ;Asper: Output stream interrupt (must be power of 2) SDO_INT equ 1 shl SDO_IDX ;Output stream interrupt (must be power of 2)
SDO_OFS equ 0x80+(SDO_IDX*0x20) ;Asper: Output stream offset SDO_OFS equ 0x80+(SDO_IDX*0x20) ;Output stream offset
;Asper+ ] ;Asper+ ]
include 'PROC32.INC'
include 'IMPORTS.INC'
include 'CODEC_H.INC'
CURRENT_API equ 0x0100 ;1.00 CURRENT_API equ 0x0100 ;1.00
COMPATIBLE_API equ 0x0101 ;1.01 COMPATIBLE_API equ 0x0101 ;1.01
API_VERSION equ (COMPATIBLE_API shl 16) or CURRENT_API API_VERSION equ (COMPATIBLE_API shl 16) or CURRENT_API
@ -344,7 +341,8 @@ DEV_EXEC_CODEC_CMD equ 100
;Asper: Non standard system service. For the tests only! ] ;Asper: Non standard system service. For the tests only! ]
struc AC_CNTRL ;AC controller base class struc AC_CNTRL ;AC controller base class
{ .bus dd ? {
.bus dd ?
.devfn dd ? .devfn dd ?
.vendor dw ? .vendor dw ?
@ -377,7 +375,6 @@ struc AC_CNTRL ;AC controller base class
.ctrl_write16 dd ? .ctrl_write16 dd ?
.ctrl_write32 dd ? .ctrl_write32 dd ?
;Asper+ [
.codec_mask dd ? .codec_mask dd ?
.rb dd ? .rb dd ?
.rirb_rp dw 0 .rirb_rp dw 0
@ -394,12 +391,10 @@ struc AC_CNTRL ;AC controller base class
.start_wallclk dd ? ; start + minimum wallclk .start_wallclk dd ? ; start + minimum wallclk
.period_wallclk dd ? ; wallclk for period .period_wallclk dd ? ; wallclk for period
.position_fix db ? .position_fix db ?
;Asper+ ]
} }
struc CODEC ;Audio Chip base class struc CODEC ;Audio Chip base class
{ {
;Asper+ [
.addr dd ? ; codec slot index (codec address) .addr dd ? ; codec slot index (codec address)
.afg dd ? ; AFG node id .afg dd ? ; AFG node id
.mfg dd ? ; MFG node id .mfg dd ? ; MFG node id
@ -419,14 +414,14 @@ struc CODEC ;Audio Chip base class
.num_pins dd ? ;Asper + : word is enough, but for align... .num_pins dd ? ;Asper + : word is enough, but for align...
.beeper_nid dw ? .beeper_nid dw ?
.pad dw ? .pad dw ?
;Asper+ ]
.ac_vendor_ids dd ? ;ac vendor id string .ac_vendor_ids dd ? ;ac vendor id string
.chip_ids dd ? ;chip model string .chip_ids dd ? ;chip model string
} }
struc CTRL_INFO struc CTRL_INFO
{ .pci_cmd dd ? {
.pci_cmd dd ?
.irq dd ? .irq dd ?
.glob_cntrl dd ? .glob_cntrl dd ?
.glob_sta dd ? .glob_sta dd ?
@ -438,7 +433,8 @@ struc CTRL_INFO
} }
struc IOCTL struc IOCTL
{ .handle dd ? {
.handle dd ?
.io_code dd ? .io_code dd ?
.input dd ? .input dd ?
.inp_size dd ? .inp_size dd ?
@ -446,10 +442,6 @@ struc IOCTL
.out_size dd ? .out_size dd ?
} }
virtual at 0
IOCTL IOCTL
end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
; Macroses by CleverMouse ; Macroses by CleverMouse
@ -498,23 +490,37 @@ lock xchg [eax], ebx
pop ebx eax pop ebx eax
} }
public START data fixups
public service_proc end data
public version
section '.flat' code readable align 16 include '../../struct.inc'
include '../../macros.inc'
include '../../proc32.inc'
include '../../peimport.inc'
include 'CODEC_H.INC'
proc START stdcall, state:dword entry START
section '.flat' readable writable executable
cmp [state], 1 ;proc START stdcall, state:dword
jne .stop proc START c, state:dword, cmdline:dword
push ebx esi ; save used registers to be stdcall
virtual at esp
rd 2 ; saved registers
dd ? ; return address
.reason dd ? ; DRV_ENTRY or DRV_EXIT
.cmdline dd ? ; normally NULL
end virtual
; 1. Check the reason for the call, do nothing unless initializing.
;cmp [.reason], DRV_ENTRY
;jne .stop
if DEBUG if DEBUG
mov esi, msgTV mov esi, msgTV
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgInit mov esi, msgInit
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
call detect_controller call detect_controller
@ -522,16 +528,15 @@ proc START stdcall, state:dword
jz .fail jz .fail
mov esi,[ctrl.vendor_ids] mov esi,[ctrl.vendor_ids]
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, [ctrl.ctrl_ids] mov esi, [ctrl.ctrl_ids]
call SysMsgBoardStr invoke SysMsgBoardStr
call init_controller call init_controller
test eax, eax test eax, eax
jz .fail jz .fail
;Asper This part is from "azx_create" proc. [ ;Asper This part is from "azx_create" proc. [
;(...)
mov [ctrl.position_fix], POS_FIX_LPIB mov [ctrl.position_fix], POS_FIX_LPIB
cmp [driver_type], AZX_DRIVER_VIA cmp [driver_type], AZX_DRIVER_VIA
je .set_via_patch je .set_via_patch
@ -554,10 +559,10 @@ proc START stdcall, state:dword
;Asper ] ;Asper ]
mov esi, msgPrimBuff mov esi, msgPrimBuff
call SysMsgBoardStr invoke SysMsgBoardStr
call create_primary_buff call create_primary_buff
mov esi, msgDone mov esi, msgDone
call SysMsgBoardStr invoke SysMsgBoardStr
if IRQ_REMAP if IRQ_REMAP
pushf pushf
@ -571,12 +576,12 @@ proc START stdcall, state:dword
jz .skip jz .skip
bts ax, bx ;mask old line bts ax, bx ;mask old line
.skip .skip
bts ax, IRQ_LINE ;mask new ine bts ax, IRQ_LINE ;mask new line
out 0x21, al out 0x21, al
mov al, ah mov al, ah
out 0xA1, al out 0xA1, al
;remap IRQ ;remap IRQ
stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE invoke PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
mov dx, 0x4d0 ;8259 ELCR1 mov dx, 0x4d0 ;8259 ELCR1
in al, dx in al, dx
@ -585,11 +590,11 @@ proc START stdcall, state:dword
mov [ctrl.int_line], IRQ_LINE mov [ctrl.int_line], IRQ_LINE
popf popf
mov esi, msgRemap mov esi, msgRemap
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
mov ebx, [ctrl.int_line] mov ebx, [ctrl.int_line]
stdcall AttachIntHandler, ebx, hda_irq, dword 0 invoke AttachIntHandler, ebx, hda_irq, dword 0
;Asper This part is from "azx_probe" proc. [ ;Asper This part is from "azx_probe" proc. [
call azx_codec_create call azx_codec_create
@ -604,25 +609,25 @@ proc START stdcall, state:dword
; create PCM streams ; create PCM streams
;Asper+ [ ;Asper+ [
mov eax, [spec.dac_node] mov eax, [spec.dac_node]
if DEBUG if DEBUG ;-
push eax esi push eax esi
mov esi, msgVal mov esi, msgVal
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
test eax, eax test eax, eax
jz .fail jz .fail
mov ebx, [spec.dac_node+4] mov ebx, [spec.dac_node+4]
if DEBUG if DEBUG ;-
push eax esi push eax esi
mov esi, msgVal mov esi, msgVal
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [spec.dac_node+4] mov eax, [spec.dac_node+4]
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
@ -637,24 +642,26 @@ proc START stdcall, state:dword
if USE_SINGLE_MODE if USE_SINGLE_MODE
mov esi, msgSingleMode mov esi, msgSingleMode
call SysMsgBoardStr invoke SysMsgBoardStr
else else
mov esi, msgNormalMode mov esi, msgNormalMode
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
.reg: .reg:
stdcall RegService, sz_sound_srv, service_proc invoke RegService, sz_sound_srv, service_proc
pop esi ebx
ret ret
.fail: .fail:
mov esi, msgFail mov esi, msgFail
.fail_msg: .fail_msg:
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi ebx
xor eax, eax xor eax, eax
ret ret
.stop: .stop:
call stop call stop
pop esi ebx
xor eax, eax xor eax, eax
ret ret
endp endp
@ -686,7 +693,7 @@ proc service_proc stdcall, ioctl:dword
jne @F jne @F
if DEBUG if DEBUG
mov esi, msgPlay mov esi, msgPlay
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
call play call play
xor eax, eax xor eax, eax
@ -696,7 +703,7 @@ proc service_proc stdcall, ioctl:dword
jne @F jne @F
if DEBUG if DEBUG
mov esi, msgStop mov esi, msgStop
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
call stop call stop
xor eax, eax xor eax, eax
@ -744,7 +751,7 @@ proc service_proc stdcall, ioctl:dword
; jne @f ; jne @f
;if DEBUG ;if DEBUG
; mov esi, msgSetChannelVolume ; mov esi, msgSetChannelVolume
; call SysMsgBoardStr ; invoke SysMsgBoardStr
;end if ;end if
; mov ebx, [edi+input] ; mov ebx, [edi+input]
; mov cl, byte [ebx] ; cl=channel ; mov cl, byte [ebx] ; cl=channel
@ -752,18 +759,17 @@ proc service_proc stdcall, ioctl:dword
;if DEBUG ;if DEBUG
; push eax esi ; push eax esi
; mov esi, msgYAHOO1 ; mov esi, msgYAHOO1
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; stdcall fdword2str, 1 ; stdcall fdword2str, 1
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; mov esi, strSemicolon ; mov esi, strSemicolon
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; movzx eax, cl ; movzx eax, cl
; stdcall fdword2str, 3 ; stdcall fdword2str, 3
; call SysMsgBoardStr ; invoke SysMsgBoardStr
; pop esi eax ; pop esi eax
;end if ;end if
; ; ; call set_channel_volume
; call set_channel_volume
; xor eax, eax ; xor eax, eax
; ret ; ret
;@@: ;@@:
@ -790,7 +796,6 @@ proc service_proc stdcall, ioctl:dword
@@: @@:
;Asper: Non standard system service. For the tests only! ] ;Asper: Non standard system service. For the tests only! ]
.fail: .fail:
or eax, -1 or eax, -1
ret ret
@ -810,10 +815,10 @@ proc hda_irq ;+
if DEBUG_IRQ if DEBUG_IRQ
push eax esi push eax esi
;mov esi, msgIRQ ;mov esi, msgIRQ
;call SysMsgBoardStr ;invoke SysMsgBoardStr
call GetTimerTicks call GetTimerTicks
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
mov edx, ICH6_REG_INTSTS mov edx, ICH6_REG_INTSTS
@ -848,9 +853,7 @@ proc hda_irq ;+
cmp [ctrl.user_callback], 0 cmp [ctrl.user_callback], 0
je @f je @f
stdcall [ctrl.user_callback], ebx stdcall [ctrl.user_callback], ebx
@@: @@:
; clear rirb int ; clear rirb int
mov edx, ICH6_REG_RIRBSTS mov edx, ICH6_REG_RIRBSTS
call azx_readb call azx_readb
@ -865,7 +868,6 @@ proc hda_irq ;+
mov eax, 80 ; wait 80 us mov eax, 80 ; wait 80 us
call StallExec call StallExec
@@: @@:
call azx_update_rirb call azx_update_rirb
.l2: .l2:
mov al, RIRB_INT_MASK mov al, RIRB_INT_MASK
@ -894,10 +896,10 @@ endp
align 4 align 4
proc create_primary_buff proc create_primary_buff
stdcall KernelAlloc, 4096 invoke KernelAlloc, 4096
mov [ctrl.posbuf], eax mov [ctrl.posbuf], eax
stdcall KernelAlloc, 0x10000 ;0x8000 invoke KernelAlloc, 0x10000 ;0x8000
mov [ctrl.buffer], eax mov [ctrl.buffer], eax
mov edi, eax mov edi, eax
@ -906,8 +908,7 @@ proc create_primary_buff
cld cld
rep stosd rep stosd
invoke KernelAlloc, 4096
stdcall KernelAlloc, 4096
mov [pcmout_bdl], eax mov [pcmout_bdl], eax
mov edi, eax mov edi, eax
@ -916,7 +917,6 @@ proc create_primary_buff
cld cld
rep stosd rep stosd
; reset BDL address ; reset BDL address
xor eax, eax xor eax, eax
mov edx, ICH6_REG_SD_BDLPL + SDO_OFS mov edx, ICH6_REG_SD_BDLPL + SDO_OFS
@ -928,11 +928,10 @@ proc create_primary_buff
; program the initial BDL entries ; program the initial BDL entries
mov eax, [ctrl.buffer] mov eax, [ctrl.buffer]
mov ebx, eax mov ebx, eax
call GetPgAddr invoke GetPgAddr
and ebx, 0xFFF and ebx, 0xFFF
add eax, ebx add eax, ebx
mov ebx, 0x4000 ;buffer size mov ebx, 0x4000 ;buffer size
mov ecx, 8 ;number of periods mov ecx, 8 ;number of periods
mov edi, [pcmout_bdl] ;pcmout_bdl mov edi, [pcmout_bdl] ;pcmout_bdl
@ -948,7 +947,6 @@ proc create_primary_buff
; program the IOC to enable interrupt when buffer completes ; program the IOC to enable interrupt when buffer completes
mov dword [edi+12], 0x01 mov dword [edi+12], 0x01
add eax, ebx add eax, ebx
add edi, 16 add edi, 16
dec ecx dec ecx
@ -958,7 +956,6 @@ proc create_primary_buff
dec ecx dec ecx
jnz .next_period jnz .next_period
mov edi, buff_list mov edi, buff_list
mov eax, [ctrl.buffer] mov eax, [ctrl.buffer]
mov ecx, 4 ;2 mov ecx, 4 ;2
@ -991,11 +988,10 @@ proc detect_controller
bus dd ? bus dd ?
devfn dd ? devfn dd ?
endl endl
xor eax, eax xor eax, eax
mov [bus], eax mov [bus], eax
inc eax inc eax
call PciApi invoke PciApi
cmp eax, -1 cmp eax, -1
je .err je .err
@ -1004,7 +1000,7 @@ proc detect_controller
.next_bus: .next_bus:
and [devfn], 0 and [devfn], 0
.next_dev: .next_dev:
stdcall PciRead32, [bus], [devfn], dword 0 invoke PciRead32, [bus], [devfn], dword 0
test eax, eax test eax, eax
jz .next jz .next
cmp eax, -1 cmp eax, -1
@ -1019,7 +1015,7 @@ proc detect_controller
cmp eax, ebx cmp eax, ebx
je .found je .found
add edi, 12 add edi, 12
jmp @B jmp @b
.next: .next:
inc [devfn] inc [devfn]
cmp [devfn], 256 cmp [devfn], 256
@ -1048,17 +1044,17 @@ proc detect_controller
mov [ctrl.ctrl_ids], ebx mov [ctrl.ctrl_ids], ebx
cmp edx, VID_INTEL cmp edx, VID_INTEL
jne @F jne @f
mov [ctrl.vendor_ids], msg_Intel mov [ctrl.vendor_ids], msg_Intel
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_NVIDIA cmp edx, VID_NVIDIA
jne @F jne @f
mov [ctrl.vendor_ids], msg_NVidia mov [ctrl.vendor_ids], msg_NVidia
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_ATI cmp edx, VID_ATI
jne @F jne @f
cmp eax, 0x4383 cmp eax, 0x4383
jg .ati_hdmi jg .ati_hdmi
mov [ctrl.vendor_ids], msg_ATI mov [ctrl.vendor_ids], msg_ATI
@ -1068,42 +1064,42 @@ proc detect_controller
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_AMD cmp edx, VID_AMD
jne @F jne @f
mov [ctrl.vendor_ids], msg_AMD mov [ctrl.vendor_ids], msg_AMD
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_VIA cmp edx, VID_VIA
jne @F jne @f
mov [ctrl.vendor_ids], msg_VIA mov [ctrl.vendor_ids], msg_VIA
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_SIS cmp edx, VID_SIS
jne @F jne @f
mov [ctrl.vendor_ids], msg_SIS mov [ctrl.vendor_ids], msg_SIS
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_ULI cmp edx, VID_ULI
jne @F jne @f
mov [ctrl.vendor_ids], msg_ULI mov [ctrl.vendor_ids], msg_ULI
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_TERA cmp edx, VID_TERA
jne @F jne @f
mov [ctrl.vendor_ids], msg_TERA mov [ctrl.vendor_ids], msg_TERA
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_CREATIVE cmp edx, VID_CREATIVE
jne @F jne @f
mov [ctrl.vendor_ids], msg_CREATIVE mov [ctrl.vendor_ids], msg_CREATIVE
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_RDC cmp edx, VID_RDC
jne @F jne @f
mov [ctrl.vendor_ids], msg_RDC mov [ctrl.vendor_ids], msg_RDC
jmp .ok jmp .ok
@@: @@:
cmp edx, VID_VMWARE cmp edx, VID_VMWARE
jne @F jne @f
mov [ctrl.vendor_ids], msg_VMWARE mov [ctrl.vendor_ids], msg_VMWARE
jmp .ok jmp .ok
@@: @@:
@ -1121,14 +1117,13 @@ endp
align 4 align 4
proc init_controller proc init_controller
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
test eax, 0x4 ; Test Master bit test eax, 0x4 ; Test Master bit
jnz @f jnz @f
or eax, 0x4 ; Set Master bit or eax, 0x4 ; Set Master bit
stdcall PciWrite32, [ctrl.bus], [ctrl.devfn], dword 4, eax invoke PciWrite32, [ctrl.bus], [ctrl.devfn], dword 4, eax
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
@@: @@:
mov ebx, eax mov ebx, eax
and eax, 0xFFFF and eax, 0xFFFF
mov [ctrl.pci_cmd], eax mov [ctrl.pci_cmd], eax
@ -1136,34 +1131,34 @@ proc init_controller
mov [ctrl.pci_stat], ebx mov [ctrl.pci_stat], ebx
mov esi, msgPciCmd mov esi, msgPciCmd
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgPciStat mov esi, msgPciStat
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, [ctrl.pci_stat] mov eax, [ctrl.pci_stat]
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgHDALowMMIo mov esi, msgHDALowMMIo
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
and eax, 0xFFFFC000 and eax, 0xFFFFC000
mov [ctrl.ctrl_mem_base], eax mov [ctrl.ctrl_mem_base], eax
mov esi, msgHDAUpMMIo mov esi, msgHDAUpMMIo
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
;-mov [ctrl.hda_upper_mem_base], eax ;-mov [ctrl.hda_upper_mem_base], eax
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
.default: .default:
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C invoke PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
and eax, 0xFF and eax, 0xFF
@@: @@:
mov [ctrl.int_line], eax mov [ctrl.int_line], eax
@ -1176,11 +1171,10 @@ proc init_controller
call azx_readw call azx_readw
if DEBUG if DEBUG
mov esi, msgGCap mov esi, msgGCap
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
; allocate CORB/RIRB ; allocate CORB/RIRB
call azx_alloc_cmd_io call azx_alloc_cmd_io
@ -1198,14 +1192,12 @@ endp
PG_SW equ 0x003 PG_SW equ 0x003
PG_NOCACHE equ 0x018 PG_NOCACHE equ 0x018
align 4 align 4
proc set_HDA proc set_HDA
invoke MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE
stdcall MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE
mov [ctrl.ctrl_mem_base], eax mov [ctrl.ctrl_mem_base], eax
ret ret
endp endp
@ -1291,13 +1283,13 @@ proc reset_controller
; Accept unsolicited responses ; Accept unsolicited responses
if USE_SINGLE_MODE if USE_SINGLE_MODE
else else if USE_UNSOL_EV
;UNSUPPORTED YET! [ ;UNSUPPORTED YET! [
; mov edx, ICH6_REG_GCTL mov edx, ICH6_REG_GCTL
; call azx_readl call azx_readl
; or eax, ICH6_GCTL_UNSOL or eax, ICH6_GCTL_UNSOL
; mov edx, ICH6_REG_GCTL mov edx, ICH6_REG_GCTL
; call azx_writel call azx_writel
;UNSUPPORTED YET! ] ;UNSUPPORTED YET! ]
end if end if
@ -1312,9 +1304,9 @@ proc reset_controller
if DEBUG if DEBUG
mov esi, msgCodecMask mov esi, msgCodecMask
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
@@: @@:
@ -1325,7 +1317,7 @@ proc reset_controller
.fail: .fail:
if DEBUG if DEBUG
mov esi, msgHDARFail mov esi, msgHDARFail
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
stc stc
ret ret
@ -1390,7 +1382,7 @@ stop:
ret ret
;align 4 ;align 4
;proc get_dev_info stdcall, p_info:dword ;proc get_dev_info stdcall, p_info:dword ;deprecated
;virtual at esi ;virtual at esi
; CTRL_INFO CTRL_INFO ; CTRL_INFO CTRL_INFO
;end virtual ;end virtual
@ -1438,7 +1430,7 @@ endp
proc azx_alloc_cmd_io proc azx_alloc_cmd_io
push eax ecx edx push eax ecx edx
; single page (at least 4096 bytes) must suffice for both ringbuffers ; single page (at least 4096 bytes) must suffice for both ringbuffers
stdcall KernelAlloc, 4096 invoke KernelAlloc, 4096
mov [ctrl.rb], eax mov [ctrl.rb], eax
mov edi, eax mov edi, eax
@ -1457,7 +1449,7 @@ proc azx_init_cmd_io
; CORB set up ; CORB set up
mov eax, [ctrl.rb] mov eax, [ctrl.rb]
mov ebx, eax mov ebx, eax
call GetPgAddr invoke GetPgAddr
and ebx, 0xFFF and ebx, 0xFFF
add eax, ebx add eax, ebx
push eax ; save corb address push eax ; save corb address
@ -1615,7 +1607,7 @@ proc azx_update_rirb
if DEBUG if DEBUG
push esi push esi
mov esi, msgSpuriousResponce mov esi, msgSpuriousResponce
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
jmp .l1 jmp .l1
@ -1676,9 +1668,9 @@ proc azx_rirb_get_response
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, msgGetResponceTimeout mov esi, msgGetResponceTimeout
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgPollingCodecOnce mov esi, msgPollingCodecOnce
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
mov [do_poll], 1 mov [do_poll], 1
@ -1689,9 +1681,9 @@ proc azx_rirb_get_response
if DEBUG if DEBUG
push eax esi push eax esi
mov esi, msgGetResponceTimeout mov esi, msgGetResponceTimeout
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgSwitchToPollMode mov esi, msgSwitchToPollMode
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
mov [ctrl.polling_mode], 1 mov [ctrl.polling_mode], 1
@ -1706,7 +1698,6 @@ proc azx_rirb_get_response
jmp .out jmp .out
@@: @@:
; a fatal communication error; need either to reset or to fallback ; a fatal communication error; need either to reset or to fallback
; to the single_cmd mode ; to the single_cmd mode
mov [ctrl.rirb_error], 1 mov [ctrl.rirb_error], 1
@ -1780,11 +1771,11 @@ proc azx_single_wait_for_response
mov edx, ICH6_REG_IRS mov edx, ICH6_REG_IRS
call azx_readw call azx_readw
mov esi, msgGetResponceTimeout mov esi, msgGetResponceTimeout
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgIRS mov esi, msgIRS
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
pop esi edx ecx pop esi edx ecx
@ -1836,14 +1827,14 @@ proc azx_single_send_cmd stdcall, val:dword
mov edx, ICH6_REG_IRS mov edx, ICH6_REG_IRS
call azx_readw call azx_readw
mov esi, msgSendCmdTimeout mov esi, msgSendCmdTimeout
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgVal mov esi, msgVal
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, dword [val] mov eax, dword [val]
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
pop esi edx ecx pop esi edx ecx
@ -2041,7 +2032,7 @@ proc azx_init_chip
; program the position buffer ; program the position buffer
mov eax, dword [ctrl.posbuf] mov eax, dword [ctrl.posbuf]
mov ebx, eax mov ebx, eax
call GetPgAddr invoke GetPgAddr
and ebx, 0xFFF and ebx, 0xFFF
add eax, ebx add eax, ebx
mov edx, ICH6_REG_DPLBASE mov edx, ICH6_REG_DPLBASE
@ -2060,7 +2051,7 @@ endp
; update bits in a PCI register byte ; update bits in a PCI register byte
proc update_pci_byte stdcall, reg:dword, mask:dword, val:dword proc update_pci_byte stdcall, reg:dword, mask:dword, val:dword
push ax bx push ax bx
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], [reg] invoke PciRead8, [ctrl.bus], [ctrl.devfn], [reg]
mov bl, byte [mask] mov bl, byte [mask]
mov bh, bl mov bh, bl
xor bl, -1 xor bl, -1
@ -2068,7 +2059,7 @@ proc update_pci_byte stdcall, reg:dword, mask:dword, val:dword
shr bx, 8 shr bx, 8
and bl, byte [val] and bl, byte [val]
or al, bl or al, bl
stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], [reg], eax invoke PciWrite8, [ctrl.bus], [ctrl.devfn], [reg], eax
pop bx ax pop bx ax
ret ret
endp endp
@ -2102,7 +2093,7 @@ proc azx_init_pci
cmp eax, AZX_DRIVER_PCH cmp eax, AZX_DRIVER_PCH
jne @f jne @f
.l1: .l1:
stdcall PciRead16, [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC invoke PciRead16, [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
test ax, INTEL_SCH_HDA_DEVC_NOSNOOP test ax, INTEL_SCH_HDA_DEVC_NOSNOOP
jz @f jz @f
push ebx push ebx
@ -2110,19 +2101,19 @@ proc azx_init_pci
xor ebx, -1 xor ebx, -1
and eax, ebx and eax, ebx
pop ebx pop ebx
stdcall PciWrite16, [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC, eax invoke PciWrite16, [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC, eax
stdcall PciRead16, [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC invoke PciRead16, [ctrl.bus], [ctrl.devfn], dword INTEL_SCH_HDA_DEVC
if DEBUG if DEBUG
push esi push esi
mov esi, msgHDASnoopDisabled mov esi, msgHDASnoopDisabled
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msg_OK mov esi, msg_OK
test ax, INTEL_SCH_HDA_DEVC_NOSNOOP test ax, INTEL_SCH_HDA_DEVC_NOSNOOP
jz .snoop_ok jz .snoop_ok
mov esi, msg_Fail mov esi, msg_Fail
.snoop_ok: .snoop_ok:
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
@@: @@:
@ -2223,7 +2214,7 @@ proc azx_setup_controller
; lower BDL address ; lower BDL address
mov eax, [pcmout_bdl] mov eax, [pcmout_bdl]
mov ebx, eax mov ebx, eax
call GetPgAddr invoke GetPgAddr
and ebx, 0xFFF and ebx, 0xFFF
add eax, ebx add eax, ebx
mov edx, ICH6_REG_SD_BDLPL + SDO_OFS mov edx, ICH6_REG_SD_BDLPL + SDO_OFS
@ -2242,14 +2233,13 @@ proc azx_setup_controller
jnz @f jnz @f
mov eax, dword [ctrl.posbuf] mov eax, dword [ctrl.posbuf]
mov ebx, eax mov ebx, eax
call GetPgAddr invoke GetPgAddr
and ebx, 0xFFF and ebx, 0xFFF
add eax, ebx add eax, ebx
or eax, ICH6_DPLBASE_ENABLE or eax, ICH6_DPLBASE_ENABLE
mov edx, ICH6_REG_DPLBASE mov edx, ICH6_REG_DPLBASE
call azx_writel call azx_writel
@@: @@:
; set the interrupt enable bits in the descriptor control register ; set the interrupt enable bits in the descriptor control register
mov edx, ICH6_REG_SD_CTL + SDO_OFS mov edx, ICH6_REG_SD_CTL + SDO_OFS
call azx_readl call azx_readl
@ -2281,11 +2271,11 @@ proc probe_codec, addr:dword
if DEBUG if DEBUG
push esi push esi
mov esi, msgCodecOK mov esi, msgCodecOK
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgCAd mov esi, msgCAd
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 3 stdcall fdword2str, 3
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
xor eax, eax xor eax, eax
@ -2319,7 +2309,7 @@ proc azx_codec_create
; Some BIOSen give you wrong codec addresses that don't exist ; Some BIOSen give you wrong codec addresses that don't exist
if DEBUG if DEBUG
mov esi, msgCodecError mov esi, msgCodecError
call SysMsgBoardStr invoke SysMsgBoardStr
end if end if
mov ebx, edx mov ebx, edx
xor ebx, -1 xor ebx, -1
@ -2395,15 +2385,16 @@ proc azx_stop_chip
; disable interrupts ; disable interrupts
call azx_int_disable call azx_int_disable
call azx_int_clear call azx_int_clear
; disable CORB/RIRB ; disable CORB/RIRB
call azx_free_cmd_io call azx_free_cmd_io
; disable position buffer ; disable position buffer
xor eax, eax xor eax, eax
mov edx, ICH6_REG_DPLBASE mov edx, ICH6_REG_DPLBASE
call azx_writel call azx_writel
mov edx, ICH6_REG_DPUBASE mov edx, ICH6_REG_DPUBASE
call azx_writel call azx_writel
pop edx eax pop edx eax
ret ret
endp endp
@ -2436,18 +2427,18 @@ set_channel_volume:
push eax ebx ecx edx push eax ebx ecx edx
mov ebx, [volume.maxDb] mov ebx, [volume.maxDb]
neg eax neg eax
if 0;DEBUG ;YAHOO if DEBUG ;-
push eax esi push eax esi
mov esi, msgNewVolume mov esi, msgNewVolume
call SysMsgBoardStr invoke SysMsgBoardStr
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
mov esi, msgMaxVolume mov esi, msgMinVolume
call SysMsgBoardStr invoke SysMsgBoardStr
mov eax, ebx mov eax, ebx
stdcall fdword2str, 2 stdcall fdword2str, 2
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi eax pop esi eax
end if end if
test ebx, ebx test ebx, ebx
@ -2459,16 +2450,20 @@ set_channel_volume:
jmp .set jmp .set
@@: @@:
cmp eax, ebx cmp eax, ebx
jl .set jng .set
mov eax, ebx mov eax, ebx
.set: .set:
sub ebx, eax
mov eax, ebx
;cdq ;cdq
xor edx, edx xor edx, edx
shl eax, 2 push eax
mov ebx, 100 movzx eax, [volume.step_size]
div bx imul eax, (100/4)
mov bl, [volume.step_size] mov ebx, eax
div bl pop eax
xor edx, edx
idiv ebx
mov edx, [volume.out_amp_node] mov edx, [volume.out_amp_node]
test edx, edx test edx, edx
@ -2486,10 +2481,10 @@ set_channel_volume:
pop edx ecx ebx eax pop edx ecx ebx eax
ret ret
.err_out: .err_out:
if 0;DEBUG ;YAHOO if DEBUG ;-
push esi push esi
mov esi, emsgNoVolCtrl mov esi, emsgNoVolCtrl
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if end if
jmp .out jmp .out
@ -2508,13 +2503,10 @@ get_channel_volume:
jz .out jz .out
movzx ebx, [edx+HDA_GNODE.nid] movzx ebx, [edx+HDA_GNODE.nid]
stdcall get_volume_mute, ebx, ecx, HDA_OUTPUT, 0 stdcall get_volume_mute, ebx, ecx, HDA_OUTPUT, 0
and eax, 0x7F ;get gain
mov cl, [volume.step_size] mov cl, [volume.step_size]
mul cl mul cl
imul eax, (-100/4)
mov cx, 100
mul cx
shr eax, 2 ; *0.25
neg eax
.out: .out:
pop edx ecx ebx pop edx ecx ebx
ret ret
@ -2616,8 +2608,13 @@ proc snd_hda_queue_unsol_event stdcall, par1:dword, par2:dword
if DEBUG if DEBUG
push esi push esi
mov esi, msgUnsolEvent mov esi, msgUnsolEvent
call SysMsgBoardStr invoke SysMsgBoardStr
pop esi pop esi
end if
if USE_UNSOL_EV = 0
;Test. Do not make queue, process immediately!
;stdcall here snd_hda_read_pin_sense stdcall, nid:dword, trigger_sense:dword
;and then mute/unmute pin based on the results
end if end if
ret ret
endp endp
@ -2945,7 +2942,7 @@ end if
if DEBUG if DEBUG
msgYAHOO2 db 'YAHOO2: ',0 msgYAHOO2 db 'YAHOO2: ',0
msgMaxVolume db 'MaxVolume: ',0 msgMinVolume db 'MinVolume: ',0
msgNewVolume db 'NewVolume: ',0 msgNewVolume db 'NewVolume: ',0
msgVerbQuery db 'Q: ',0 msgVerbQuery db 'Q: ',0
@ -2960,13 +2957,13 @@ if DEBUG
msgBeeperNid db 'Beeper found: NID=',0 msgBeeperNid db 'Beeper found: NID=',0
msgBeeperValue db 'Beeper initial value: ',0 msgBeeperValue db 'Beeper initial value: ',0
msgBeepNow db 'Beep!',13,10,0 msgBeepNow db 'Beep!',13,10,0
msgNodeSeq db 'Sequence of codec nodes:',13,10,0
msgNID db 'NID: 0x',0
end if end if
;] Asper ;] Asper
section '.data' data readable writable align 16
aspinlock dd SPINLOCK_FREE aspinlock dd SPINLOCK_FREE
codec CODEC codec CODEC