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/fm801.obj:DRIVERS/FM801.OBJ:$(KERNEL)/drivers/fm801.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/sound.obj:DRIVERS/SOUND.OBJ:$(KERNEL)/drivers/sound.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/ps2mouse.sys:DRIVERS/PS2MOUSE.SYS:$(REPOSITORY)/drivers/mouse/ps2mouse4d/trunk/ps2mouse.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
# 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

@ -24,7 +24,7 @@ proc make_codec_cmd stdcall, nid:dword, direct:dword, verb:dword, parm:dword
or eax, ebx
pop ebx
ret
.err:
.err:
pop ebx
mov eax, -1
ret
@ -39,41 +39,40 @@ proc codec_exec_verb stdcall, cmd:dword;, res:dword <- returned in eax
pop edx ebx
mov eax, -1
ret
@@:
if FDEBUG ;YAHOO
@@:
if FDEBUG
push eax esi
mov esi, msgVerbQuery
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
end if
mov edx, -1
.again:
; call snd_hda_power_up
.again:
;call snd_hda_power_up
stdcall azx_send_cmd, ebx
mov ebx, eax
test ebx, ebx
jnz @f
call azx_get_response
mov edx, eax
if FDEBUG
if FDEBUG
test edx, edx
jz .end_debug
push eax esi
mov esi, msgVerbAnswer
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, edx
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
.end_debug:
end if
@@:
.end_debug:
end if
@@:
;call snd_hda_power_down
cmp edx, -1
jne .l1
@ -85,20 +84,20 @@ proc codec_exec_verb stdcall, cmd:dword;, res:dword <- returned in eax
mov eax, [ctrl.response_reset]
jz @f
if DEBUG
if DEBUG
push esi
mov esi, emsgBusResetFatalComm
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
call azx_bus_reset
@@:
.l1:
@@:
.l1:
;; clear reset-flag when the communication gets recovered
test ebx, ebx
jnz @f
mov [ctrl.response_reset], 0
@@:
@@:
mov eax, edx
pop edx ebx
@ -153,7 +152,7 @@ endp
proc snd_hda_sequence_write stdcall, seq:dword
push eax ebx ecx esi
mov esi, [seq]
@@:
@@:
;mov ecx, [esi + hda_verb.nid]
;mov ebx, [esi + hda_verb.verb]
;mov eax, [esi + hda_verb.param]
@ -171,7 +170,7 @@ proc snd_hda_sequence_write stdcall, seq:dword
stdcall snd_hda_codec_write, ecx, 0, ebx, eax
add esi, 6
jmp @b
.out:
.out:
pop esi ecx ebx eax
ret
endp
@ -197,9 +196,8 @@ proc snd_hda_get_sub_nodes stdcall, nid:dword;, start_id:dword <- returned in
cmp eax, -1
jne @f
inc eax
@@:
@@:
and eax, 0x7FFF7FFF
ret
endp
@ -216,7 +214,7 @@ endp
;; Returns the number of connections, or a negative error code.
;;
proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dword ;Asper: Complete translation!
locals
locals
parm dd ?
conn_len dd ?
conns dd 0
@ -225,7 +223,7 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
mask dd 0x7F
wcaps dd ?
prev_nid dw 1 ;Asper: Hmm.. Probably ALSA bug that it isn't initialized. I suppose to init it with 1.
endl
endl
push ebx ecx edx edi esi
mov edi, [conn_list]
@ -244,17 +242,17 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
je .conn_list_ok
test ebx, AC_WCAP_CONN_LIST
jnz .conn_list_ok
if DEBUG
if DEBUG
mov esi, emsgConnListNotAvailable
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [nid]
stdcall fdword2str, 3
call SysMsgBoardStr
end if
invoke SysMsgBoardStr
end if
xor eax, eax
dec eax
jmp .out
.conn_list_ok:
.conn_list_ok:
snd_hda_param_read [nid], AC_PAR_CONNLIST_LEN
mov [parm], eax
@ -265,7 +263,7 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
mov [shift], 16
mov [num_elements], 2
mov [mask], 0x7FFF ;Asper+
@@:
@@:
and eax, AC_CLIST_LENGTH
test eax, eax
jz .out ; no connection
@ -283,7 +281,7 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
xor eax, eax
dec eax
jmp .out
@@:
@@:
mov eax, [parm]
and eax, [mask]
@ -291,19 +289,19 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
xor eax, eax
inc eax
jmp .out
.multi_conns:
.multi_conns:
; multi connection
xor ecx, ecx
mov edx, [num_elements]
.next_conn:
.next_conn:
mov eax, ecx
.mod:
.mod:
cmp eax, edx
jl .mod_counted
sub eax, edx
jmp .mod
.mod_counted:
.mod_counted:
test eax, eax
jnz .l1
@ -314,7 +312,7 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
jne .l1
cmp [ctrl.rirb_error], 0
jne .err_out
.l1:
.l1:
mov eax, 1
push ecx
@ -330,30 +328,30 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
test eax, eax
jnz @f
if DEBUG
if DEBUG
push eax esi
mov esi, emsgInvConnList
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [nid]
stdcall fdword2str, 1
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 0
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [parm]
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
end if
xor eax, eax
jmp .out
@@:
@@:
push ecx
mov cl, [shift]
shr [parm], cl
@ -367,43 +365,43 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
jz .l2
cmp esi, eax
jl @f
.l2:
if DEBUG
.l2:
if DEBUG
push eax esi
push esi
mov esi, emsgInvDepRangeVal
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
push eax
mov eax, esi
stdcall fdword2str, 0
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
end if
jmp .continue
@@:
@@:
push ecx
mov ecx, esi
inc ecx
mov ebx, [conns]
.next_conn2:
.next_conn2:
cmp ebx, [max_conns]
jl @f
if DEBUG
if DEBUG
push esi
mov esi, emsgTooManyConns
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
pop ecx
jmp .err_out
@@:
@@:
shl ebx, 1
push edi
add edi, ebx
@ -418,19 +416,19 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
mov [conns], ebx
pop ecx
jmp .end_range_test
.range_zero:
.range_zero:
mov ebx, [conns]
cmp ebx, [max_conns]
jl @f
if DEBUG
if DEBUG
push esi
mov esi, emsgTooManyConns
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
jmp .err_out
@@:
@@:
shl ebx, 1
push edi
add edi, ebx
@ -439,18 +437,18 @@ proc snd_hda_get_connections stdcall, nid:dword, conn_list:dword, max_conns:dwo
shr ebx, 1
inc ebx
mov [conns], ebx
.end_range_test:
.end_range_test:
mov [prev_nid], ax
.continue:
.continue:
inc ecx
cmp ecx, [conn_len]
jl .next_conn
mov eax, [conns]
.out:
.out:
pop esi edi edx ecx ebx
ret
.err_out:
.err_out:
pop esi edi edx ecx ebx
mov eax, -1
ret
@ -495,7 +493,7 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
cmp eax, -1
jne @f
snd_hda_param_read AC_NODE_ROOT, AC_PAR_VENDOR_ID
@@:
@@:
mov [codec.chip_id], ax
shr eax, 16
mov [codec.vendor_id], ax
@ -511,14 +509,13 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
mov eax, [codec.afg]
test eax, eax
jnz @f
;Asper+: try to use another codec if possible [
if DEBUG
if DEBUG
push esi
mov esi, msgNoAFGFound
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
push ecx
inc eax
mov ecx, [codec.addr]
@ -531,16 +528,16 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
mov eax, [codec.mfg]
test eax, eax
jnz @f
if DEBUG
if DEBUG
push esi
mov esi, emsgNoAFGorMFGFound
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
.skip_codec:
end if
.skip_codec:
mov eax, -1
ret
@@:
@@:
mov ebx, eax
push ebx
@ -548,16 +545,16 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
cmp eax, 0
jge @f
if DEBUG
if DEBUG
push esi
mov esi, emsgNoMem
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
pop ebx
mov eax, -1
ret
@@:
@@:
call read_pin_defaults
@ -566,14 +563,12 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
pop ebx
mov eax, -1
ret
@@:
@@:
mov eax, [codec.subsystem_id]
test eax, eax
jnz @f
stdcall snd_hda_codec_read, ebx, 0, AC_VERB_GET_SUBSYSTEM_ID, 0
@@:
@@:
; power up all before initialization
stdcall snd_hda_set_power_state, ebx, AC_PWRST_D0
@ -593,20 +588,20 @@ endp
;;
proc snd_hda_codec_configure
call get_codec_name
@@:
@@:
; call the default parser
stdcall snd_hda_parse_generic_codec ;entry point to generic tree parser!!!
test eax, eax
jz @f
if DEBUG
if DEBUG
push esi
mov esi, emsgNoParserAvailable
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
@@:
.out:
end if
@@:
.out:
ret
endp
@ -620,7 +615,7 @@ proc get_codec_name
mov ax, [codec.vendor_id]
mov edi, hda_vendor_ids
@@:
@@:
mov ebx, [edi]
test ebx, ebx
jz .unknown
@ -630,23 +625,23 @@ proc get_codec_name
mov eax, [edi+4]
mov [codec.ac_vendor_ids], eax
mov esi, eax
call SysMsgBoardStr
.get_chip_name:
invoke SysMsgBoardStr
.get_chip_name:
stdcall detect_chip, [edi+8]
pop esi edi ebx eax
ret
.next:
.next:
add edi, 12
jmp @b
.unknown:
.unknown:
mov [codec.ac_vendor_ids], ac_unknown
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
invoke SysMsgBoardStr
movzx eax, [codec.chip_id]
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi edi ebx eax
ret
endp
@ -654,7 +649,6 @@ endp
align 4
proc detect_chip stdcall, chip_tab:dword
push eax ebx edi esi
mov ax, [codec.chip_id]
@ -669,7 +663,7 @@ proc detect_chip stdcall, chip_tab:dword
mov eax, [edi+4]
mov [codec.chip_ids], eax
mov esi, eax
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi edi ebx eax
ret
.next:
@ -678,10 +672,10 @@ proc detect_chip stdcall, chip_tab:dword
.unknown:
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
invoke SysMsgBoardStr
movzx eax, [codec.chip_id]
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi edi ebx eax
ret
endp
@ -697,34 +691,34 @@ proc setup_fg_nodes
shr ebx, 16
and ebx, 0x7FFF ; nid
if DEBUG ;YAHOO
if DEBUG
push eax esi
mov esi, msgSETUP_FG_NODES
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 1
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
.next:
.next:
test ecx, ecx
jz .l1
snd_hda_param_read ebx, AC_PAR_FUNCTION_TYPE
and eax, 0xFF
if DEBUG ;YAHOO
if DEBUG
push eax esi
mov esi, msgFG_TYPE
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
@ -734,19 +728,19 @@ end if
mov [codec.afg], ebx
mov [codec.function_id], eax
jmp .continue
@@:
@@:
cmp eax, AC_GRP_MODEM_FUNCTION
jne @f
mov [codec.mfg], ebx
mov [codec.function_id], eax
jmp .continue
@@:
.continue:
@@:
.continue:
inc ebx
dec ecx
jnz .next
.l1:
.l1:
pop ecx ebx eax
ret
endp
@ -766,40 +760,40 @@ proc read_widget_caps stdcall, fg_node:dword
and ebx, 0x7FFF ; nid
mov [codec.start_nid], bx
if DEBUG ;YAHOO
if DEBUG
push eax esi
mov esi, msgSETUP_FG_NODES
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 1
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
if FDEBUG ;YAHOO
if FDEBUG
push esi
mov esi, msgWCaps
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
mov eax, ecx
shl eax, 2
push ebx ecx
call Kmalloc
invoke Kmalloc
pop ecx ebx
test eax, eax
jz .err_out
mov [codec.wcaps], eax
mov edi, eax
.next_node:
.next_node:
snd_hda_param_read ebx, AC_PAR_AUDIO_WIDGET_CAP
stosd
@ -809,7 +803,7 @@ end if
pop edi edx ecx ebx
xor eax, eax
ret
.err_out:
.err_out:
pop edi edx ecx ebx
xor eax, eax
dec eax
@ -828,7 +822,7 @@ proc read_pin_defaults
mov eax, HDA_PINCFG.sizeof
mul cl
push ebx ecx
call Kmalloc
invoke Kmalloc
pop ecx ebx
test eax, eax
jz .err_out
@ -840,12 +834,12 @@ proc read_pin_defaults
if FDEBUG
push eax esi
mov esi, msgPinCfgs
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
.next_node:
.next_node:
stdcall get_wcaps, ebx
and eax, AC_WCAP_TYPE
shr eax, AC_WCAP_TYPE_SHIFT
@ -859,7 +853,7 @@ end if
add edi, HDA_PINCFG.sizeof
inc [codec.num_pins]
.continue:
.continue:
inc ebx
dec ecx
jnz .next_node
@ -867,7 +861,7 @@ end if
pop edi edx ecx ebx
xor eax, eax
ret
.err_out:
.err_out:
pop edi edx ecx ebx
xor eax, eax
dec eax
@ -882,17 +876,17 @@ proc look_up_pincfg stdcall, array:dword, nid:dword
mov ecx, [codec.num_pins]
mov eax, [array]
mov ebx, [nid]
.next_pin:
.next_pin:
mov dx, [eax + HDA_PINCFG.nid]
cmp dx, bx
je .out
.continue:
.continue:
add eax, HDA_PINCFG.sizeof
dec ecx
jnz .next_pin
xor eax, eax
.out:
.out:
pop edx ecx ebx
ret
endp
@ -904,14 +898,14 @@ proc set_pincfg stdcall, nid:dword, cfg:dword
xor ebx, ebx
mov edx, AC_VERB_SET_CONFIG_DEFAULT_BYTES_0
mov ecx, 4
@@:
@@:
mov bl, al
stdcall snd_hda_codec_write, [nid], 0, edx, ebx
shr eax, 8
inc edx
dec ecx
jnz @b
.l1:
.l1:
pop edx ecx ebx eax
ret
endp
@ -933,7 +927,7 @@ proc snd_hda_codec_get_pincfg stdcall, nid:dword
jz @f
mov edi, eax
mov eax, [edi + HDA_PINCFG.cfg]
@@:
@@:
pop edi
ret
endp
@ -954,33 +948,33 @@ proc hda_codec_setup_stream stdcall, nid:dword, stream_tag:dword, channel_id:dwo
jnz @f
pop eax
ret
@@:
if DEBUG
@@:
if DEBUG
push esi
mov esi, msgHDACodecSetupStream
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgStream
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [stream_tag]
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgChannel
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [channel_id]
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgFormat
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [format]
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
mov eax, [stream_tag]
shl eax, 4
or eax, [channel_id]
@ -1002,21 +996,21 @@ proc snd_hda_codec_cleanup_stream stdcall, nid:dword
jz @f
pop eax
ret
@@:
if DEBUG
@@:
if DEBUG
push esi
mov esi, msgHDACodecCleanupStream
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_CHANNEL_STREAMID, 0
if 0 ; keep the format
if 0 ; keep the format
mov eax, 1000000 ; wait 100 ms
call StallExec
stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_STREAM_FORMAT, 0
end if
end if
pop eax
ret
endp
@ -1036,15 +1030,15 @@ proc get_volume_mute stdcall, nid:dword, ch:dword, direction:dword, index:dword
test eax, eax
jz @f
mov ebx, AC_AMP_GET_RIGHT
@@:
@@:
mov eax, [direction]
cmp eax, HDA_OUTPUT
jne @f
or ebx, AC_AMP_GET_OUTPUT
jmp .l1
@@:
@@:
or ebx, AC_AMP_GET_INPUT
.l1:
.l1:
or ebx, [index]
stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_AMP_GAIN_MUTE, ebx
and eax, 0xFF
@ -1061,15 +1055,15 @@ proc put_volume_mute stdcall, nid:dword, ch:dword, direction:dword, index:dword,
test eax, eax
jz @f
mov ebx, AC_AMP_SET_RIGHT
@@:
@@:
mov eax, [direction]
cmp eax, HDA_OUTPUT
jne @f
or ebx, AC_AMP_SET_OUTPUT
jmp .l1
@@:
@@:
or ebx, AC_AMP_SET_INPUT
.l1:
.l1:
mov eax, [index]
shl eax, AC_AMP_SET_INDEX_SHIFT
or ebx, eax
@ -1133,6 +1127,51 @@ proc snd_hda_codec_amp_stereo stdcall, nid:dword, direction:dword, idx:dword, ma
ret
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
proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
@ -1143,7 +1182,7 @@ proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
jne @f
mov eax, 100000
call StallExec
@@:
@@:
stdcall snd_hda_codec_read, [fg], 0, AC_VERB_SET_POWER_STATE, ebx
;partial workaround for "azx_get_response timeout"
cmp ebx, AC_PWRST_D0
@ -1151,14 +1190,13 @@ proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
mov dx, [codec.vendor_id]
cmp dx, 0x14F1
jne @f
mov eax, 10000
call StallExec
@@:
@@:
movzx ecx, [codec.num_nodes]
movzx edx, [codec.start_nid]
.next_nid:
.next_nid:
stdcall get_wcaps, edx
test eax, AC_WCAP_POWER
jz .skip_nid
@ -1178,10 +1216,10 @@ proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
and eax, 0x02
test eax, eax
jnz .skip_nid
.l2:
.l1:
.l2:
.l1:
stdcall snd_hda_codec_write, edx, 0, AC_VERB_SET_POWER_STATE, ebx
.skip_nid:
.skip_nid:
inc edx
dec ecx
jnz .next_nid
@ -1190,7 +1228,7 @@ proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
jne .out
;wait until codec reaches to D0
mov ecx, 500
.wait_D0:
.wait_D0:
stdcall snd_hda_codec_read, [fg], 0, AC_VERB_GET_POWER_STATE, 0
cmp eax, ebx
je .out
@ -1198,7 +1236,7 @@ proc snd_hda_set_power_state stdcall, fg:dword, power_state:dword
call StallExec
dec ecx
jnz .wait_D0
.out:
.out:
pop edx ecx ebx eax
ret
endp
@ -1285,7 +1323,6 @@ chips_VIA dd 0xE721, chip_VT1708B_1
dd 0xFF
chips_IDT dd 0xFF
chips_LSI dd 0x1039, chip_LSI1039
dd 0x1040, chip_LSI1040
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_LSI3026 db '3026 (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
;static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
proc get_wcaps stdcall, nid:dword
push ebx ecx edx
xor eax, eax
@ -617,13 +616,12 @@ proc get_wcaps stdcall, nid:dword
shl edx, 2
add edx, [codec.wcaps]
mov eax, [edx]
.out:
.out:
pop edx ecx ebx
ret
endp
; 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
mov eax, [wcaps]
and eax, AC_WCAP_TYPE
@ -633,8 +631,6 @@ endp
;static inline unsigned int get_wcaps_channels(u32 wcaps)
proc get_wcaps_channels stdcall, wcaps:dword
; chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
; chans = ((chans << 1) | 1) + 1;
mov eax, [wcaps]
and eax, AC_WCAP_CHAN_CNT_EXT
shr eax, 13
@ -644,5 +640,4 @@ proc get_wcaps_channels stdcall, wcaps:dword
ret
endp
;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
proc defcfg_type stdcall, node:dword
push edx
mov edx, [node]
@ -93,7 +92,6 @@ proc defcfg_color stdcall, node:dword
ret
endp
; destructor
proc snd_hda_generic_free
push eax ebx edx edi
@ -103,7 +101,7 @@ proc snd_hda_generic_free
jz .out
mov edx, [ebx + HDA_GNODE.next] ;edx = 2nd node address
.next:
.next:
test edx, edx
jz .free_head
@ -112,22 +110,22 @@ proc snd_hda_generic_free
cmp eax, edi
je @f
pusha
call Kfree ;free conn_list
invoke Kfree ;free conn_list
popa
@@:
@@:
mov eax, edx
mov edx, [edx + HDA_GNODE.next]
pusha
call Kfree ;free node
invoke Kfree ;free node
popa
jmp .next
.free_head:
.free_head:
mov eax, [spec.nid_list]
pusha
call Kfree ;free the very 1st node in the list
invoke Kfree ;free the very 1st node in the list
popa
mov [spec.nid_list], 0
.out:
.out:
pop edi edx ebx eax
ret
endp
@ -138,7 +136,7 @@ proc add_new_node stdcall, nid:dword
push ebx ecx edx edi esi
mov eax, HDA_GNODE.sizeof
call Kmalloc
invoke Kmalloc
test eax, eax
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)
push ebx ecx edx
call Kmalloc ;malloc temporary conn_list
invoke Kmalloc ;malloc temporary conn_list
pop edx ecx ebx
mov edi, eax
@ -174,25 +172,25 @@ proc add_new_node stdcall, nid:dword
mov eax, edx
pusha
call Kfree ;free node
invoke Kfree ;free node
popa
mov eax, ecx
jmp .out
.no_conn_list:
.no_conn_list:
xor ecx, ecx
@@:
@@:
cmp ecx, 2 ;nconns <= ARRAY_SIZE(node->slist) ?
jg @f
lea eax, [edx + HDA_GNODE.slist]
mov [edx + HDA_GNODE.conn_list], eax
jmp .set_conn_list
@@:
@@:
mov eax, ecx
shl ecx, 1
push ebx ecx edx edi
call Kmalloc ;malloc conn_list
invoke Kmalloc ;malloc conn_list
pop edi edx ecx ebx
shr ecx, 1
test eax, eax
@ -200,12 +198,12 @@ proc add_new_node stdcall, nid:dword
mov eax, edi
pusha
call Kfree ;free temporary conn_list
invoke Kfree ;free temporary conn_list
popa
jmp .err_out
@@:
@@:
mov [edx + HDA_GNODE.conn_list], eax
.set_conn_list:
.set_conn_list:
mov [edx + HDA_GNODE.nconns], cx
push edi
mov esi, edi
@ -229,7 +227,7 @@ proc add_new_node stdcall, nid:dword
mov byte [edx + HDA_GNODE.pin_ctl], al
stdcall snd_hda_codec_get_pincfg, [nid]
mov [edx + HDA_GNODE.def_cfg], eax
@@:
@@:
xor eax, eax
test ebx, AC_WCAP_OUT_AMP
@ -237,13 +235,13 @@ proc add_new_node stdcall, nid:dword
test ebx, AC_WCAP_AMP_OVRD
jz @f
snd_hda_param_read [nid], AC_PAR_AMP_OUT_CAP
@@:
@@:
test eax, eax
jnz @f
mov eax, [spec.def_amp_out_caps]
@@:
@@:
mov [edx + HDA_GNODE.amp_out_caps], eax
.no_out_amp:
.no_out_amp:
;;Asper+: Beeper [
; pusha
@ -258,30 +256,30 @@ proc add_new_node stdcall, nid:dword
; jz .no_beeper_amp
; ;set beep amplifier here
; stdcall unmute_output, edx
; .no_beeper_amp:
;.no_beeper_amp:
; ;try to beep here
; stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_BEEP_CONTROL, 0 ;eax
; if DEBUG
;if DEBUG
; push eax esi
; mov esi, msgBeeperNid
; call SysMsgBoardStr
; invoke SysMsgBoardStr
; push eax
; mov eax, [nid]
; stdcall fdword2str, 2
; call SysMsgBoardStr
; invoke SysMsgBoardStr
;
; mov esi, msgBeeperValue
; call SysMsgBoardStr
; invoke SysMsgBoardStr
; pop eax
; stdcall fdword2str, 2
; call SysMsgBoardStr
; invoke SysMsgBoardStr
;
; mov esi, msgBeepNow
; call SysMsgBoardStr
; invoke SysMsgBoardStr
; pop esi eax
; end if
;end if
; mov ecx, 256*1
; .next_tone:
;.next_tone:
; dec ecx
; movzx ebx, [esi + HDA_GNODE.nid]
; stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_BEEP_CONTROL, ecx
@ -289,17 +287,17 @@ proc add_new_node stdcall, nid:dword
; ;stdcall StallExec
; test ecx, ecx
; jnz .next_tone
; .end_beep:
;.end_beep:
; stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_BEEP_CONTROL, 0 ;eax
; if DEBUG
;if DEBUG
; ;push eax esi
; mov esi, msgBeeperValue
; call SysMsgBoardStr
; invoke SysMsgBoardStr
; stdcall fdword2str, 2
; call SysMsgBoardStr
; invoke SysMsgBoardStr
; ;pop esi eax
; end if
; .not_beeper:
;end if
;.not_beeper:
; popa
;;Asper+: Beeper ]
@ -309,26 +307,26 @@ proc add_new_node stdcall, nid:dword
test ebx, AC_WCAP_AMP_OVRD
jz @f
snd_hda_param_read [nid], AC_PAR_AMP_IN_CAP
@@:
@@:
test eax, eax
jnz @f
mov eax, [spec.def_amp_in_caps]
@@:
@@:
mov [edx + HDA_GNODE.amp_in_caps], eax
.no_in_amp:
.no_in_amp:
mov esi, [spec.nid_list]
test esi, esi
jnz @f
mov [spec.nid_list], edx
jmp .out
@@:
@@:
;Asper+: Sort pins by DA:Sequence during tree building [
mov ecx, esi
movzx ebx, byte [edx + HDA_GNODE.def_cfg]
push edi
.next_node:
.next_node:
cmp [esi + HDA_GNODE.type], AC_WID_PIN
jne @f
cmp [edx + HDA_GNODE.type], AC_WID_PIN
@ -338,45 +336,45 @@ proc add_new_node stdcall, nid:dword
cmp [edi + HDA_GNODE.type], AC_WID_PIN
jne .not_pin
mov [edx + HDA_GNODE.next], edi
.head: ;CleverMouse+
.head: ;CleverMouse+
mov [spec.nid_list], edx
pop edi
jmp .out
.pin:
.pin:
movzx edi, byte [esi + HDA_GNODE.def_cfg]
cmp edi, ebx
jle @f
.not_pin:
.not_pin:
mov [edx + HDA_GNODE.next], esi
cmp esi, [spec.nid_list] ;CleverMouse+
jz .head ;CleverMouse+
mov esi, ecx
jmp .insert
@@:
@@:
mov eax, [esi + HDA_GNODE.next]
test eax, eax
jz .insert
mov ecx, esi
mov esi, eax
jmp .next_node
.insert:
.insert:
mov [esi + HDA_GNODE.next], edx
pop edi
;Asper+ ]
.out:
.out:
mov eax, edi
pusha
call Kfree ;free temporary conn_list
invoke Kfree ;free temporary conn_list
popa
xor eax, eax
pop esi edi edx ecx ebx
ret
.err_out:
.err_out:
mov eax, edx
pusha
call Kfree ;free node
invoke Kfree ;free node
popa
xor eax, eax
dec eax
@ -407,20 +405,20 @@ proc build_afg_tree
jz @f
cmp ecx, 0
jge .nid_ok
@@:
if FDEBUG
@@:
if FDEBUG
push esi
mov esi, emsgInvalidAFGSubtree
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
xor eax, eax
dec eax
jmp .out
.nid_ok:
.nid_ok:
; parse all nodes belonging to the AFG
.next_node:
.next_node:
test ecx, ecx
jz .build_done
@ -430,13 +428,40 @@ proc build_afg_tree
inc edx
dec ecx
jmp .next_node
.build_done:
.build_done:
xor eax, eax
.out:
.out:
pop edx ecx ebx
ret
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
proc hda_get_node stdcall, nid:dword
@ -446,7 +471,7 @@ proc hda_get_node stdcall, nid:dword
test esi, esi
jz .out
.next_node:
.next_node:
mov edx, [esi + HDA_GNODE.next]
test edx, edx ;Asper+
jz .not_found ;Asper+
@ -456,9 +481,9 @@ proc hda_get_node stdcall, nid:dword
mov esi, edx
jmp .next_node
.not_found: ;Asper+
.not_found: ;Asper+
xor esi, esi
.out:
.out:
mov eax, esi
pop esi edx ebx
ret
@ -477,16 +502,16 @@ proc set_eapd stdcall, node:dword ;nid:dword, on:dword
;or eax, AC_EAPDBTL_EAPD
movzx ebx, [esi + HDA_GNODE.nid]
stdcall snd_hda_codec_write, ebx, 0, AC_VERB_SET_EAPD_BTLENABLE, AC_EAPDBTL_EAPD ;eax
if DEBUG
if DEBUG
push eax esi
mov esi, msgEnableEAPD
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
.out:
.out:
pop esi ebx eax
ret
endp
@ -494,20 +519,19 @@ endp
; unmute (and set max vol) the output amplifier
proc unmute_output stdcall, node:dword
push ebx ecx edx esi
mov esi, [node]
test [esi + HDA_GNODE.wid_caps], AC_WCAP_OUT_AMP
jz .out
movzx eax, word [esi + HDA_GNODE.nid]
if DEBUG
if DEBUG
push esi
mov esi, msgUnmuteOut
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
stdcall set_eapd, esi ;Asper+: set EAPD if exist
@ -525,31 +549,27 @@ proc unmute_output stdcall, node:dword
test al, al
jz .out
if DEBUG
if DEBUG
push eax esi
mov esi, msgAmpVal
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 1
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
end if
mov [volume.out_amp_node], esi
inc al
mov [volume.num_steps], al
inc cl
mov [volume.step_size], cl
mul cl
shr eax, 2
imul eax, 100
imul eax, (100/4)
mov [volume.maxDb], eax
.out:
.out:
xor eax, eax
pop esi edx ecx ebx
ret
@ -563,19 +583,19 @@ proc unmute_input stdcall, node:dword, index:dword
and [index], 0xF ;Asper+ : Ranger
mov esi, [node]
movzx eax, word [esi + HDA_GNODE.nid]
if DEBUG
if DEBUG
push eax esi
mov esi, msgUnmuteIn
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgIdx
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, [index]
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
end if
mov edx, [esi + HDA_GNODE.amp_in_caps]
mov ecx, edx
@ -584,7 +604,7 @@ proc unmute_input stdcall, node:dword, index:dword
shr edx, AC_AMPCAP_NUM_STEPS_SHIFT
stdcall snd_hda_codec_amp_stereo, eax, HDA_INPUT, [index], 0xFF, edx
.out:
.out:
xor eax, eax
pop esi edx ecx
ret
@ -597,20 +617,20 @@ proc select_input_connection stdcall, node:dword, index:dword
mov esi, [node]
movzx eax, word [esi + HDA_GNODE.nid]
mov ebx, [index]
if DEBUG
if DEBUG
mov esi, msgConnect
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgIdx
call SysMsgBoardStr
invoke SysMsgBoardStr
push eax
mov eax, ebx
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop eax
end if
end if
stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_CONNECT_SEL, ebx
pop esi ebx
ret
@ -623,15 +643,14 @@ proc clear_check_flags
mov esi, [spec.nid_list]
test esi, esi
jz .out
.next_node:
.next_node:
mov byte [esi + HDA_GNODE.checked], 0
mov eax, [esi + HDA_GNODE.next]
test eax, eax
jz .out
mov esi, eax
jmp .next_node
.out:
.out:
pop esi eax
ret
endp
@ -658,24 +677,24 @@ proc parse_output_path stdcall, node:dword, dac_idx:dword
mov ebx, [esi + HDA_GNODE.wid_caps]
test ebx, AC_WCAP_DIGITAL
jz @f
if DEBUG
if DEBUG
push esi
mov esi, msgSkipDigitalOutNode
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
end if
jmp .ret_zero
@@:
if DEBUG
@@:
if DEBUG
push eax esi
mov esi, msgAudOutFound
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi eax
end if
end if
push eax
stdcall unmute_output, esi ;Asper+
@ -691,18 +710,18 @@ proc parse_output_path stdcall, node:dword, dac_idx:dword
cmp eax, [node]
je .ret_one
jmp .ret_zero
@@:
@@:
mov ecx, [dac_idx]
shl ecx, 2
mov [spec.dac_node+ecx], eax
jmp .ret_one ;found
.not_wid_aud_out:
.not_wid_aud_out:
movzx ebx, [esi + HDA_GNODE.nconns]
xor ecx, ecx
mov edx, [esi + HDA_GNODE.conn_list]
test ebx, ebx
jz .ret_zero
.next_node:
.next_node:
stdcall hda_get_node, [edx]
test eax, eax
jz .continue
@ -712,24 +731,24 @@ proc parse_output_path stdcall, node:dword, dac_idx:dword
cmp [esi + HDA_GNODE.nconns], 1
jle @f
stdcall select_input_connection, esi, ecx
@@:
@@:
;UNSUPPORTED YET! stdcall unmute_input, esi, ecx
stdcall unmute_output, esi
jmp .ret_one
.continue:
.continue:
add edx, 2
inc ecx
cmp ecx, ebx
jl .next_node
.ret_zero:
.ret_zero:
xor eax, eax
pop esi edx ecx ebx
ret
.ret_one:
.ret_one:
xor eax, eax
inc eax
.ret: ;Asper+
.ret: ;Asper+
pop esi edx ecx ebx
ret
endp
@ -744,7 +763,7 @@ proc parse_output_jack stdcall, jack_type:dword
mov esi, [spec.nid_list]
test esi, esi
jz .ret_zero
.next_pin:
.next_pin:
cmp [esi + HDA_GNODE.type], AC_WID_PIN
jne .continue
@ -767,13 +786,17 @@ proc parse_output_jack stdcall, jack_type:dword
test [esi + HDA_GNODE.wid_caps], AC_WCAP_DIGITAL
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
pusha
; push esi
; mov esi, msgPin_Nid
; call SysMsgBoardStr
; invoke SysMsgBoardStr
; pop esi
movzx eax, [esi + HDA_GNODE.nid]
movzx ebx, [esi + HDA_GNODE.pin_ctl]
@ -781,38 +804,42 @@ if DEBUG
mov edx, [esi + HDA_GNODE.def_cfg]
mov edi, [esi + HDA_GNODE.amp_out_caps]
mov esi, msgPin_Nid
call SysMsgBoardStr
invoke SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPin_Ctl
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgPin_Caps
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgDef_Cfg
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, edx
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
mov esi, msgAmp_Out_Caps
call SysMsgBoardStr
invoke SysMsgBoardStr
mov eax, edi
stdcall fdword2str, 2
call SysMsgBoardStr
invoke SysMsgBoardStr
popa
end if
; output as default?
; test [esi + HDA_GNODE.pin_ctl], AC_PINCTL_OUT_EN
; jz .continue
.use_dac0:
cmp [spec.dac_node], 0
jne .use_dac1
stdcall clear_check_flags
stdcall parse_output_path, esi, 0
@ -821,9 +848,10 @@ end if
mov edx, [spec.out_pin_node]
test edx, edx
jz @f
.use_dac1:
stdcall clear_check_flags
stdcall parse_output_path, esi, 1
@@:
@@:
cmp eax, 0
jle .l1
@ -834,22 +862,22 @@ end if
test [esi + HDA_GNODE.pin_caps], AC_PINCAP_HP_DRV
jz @f
mov edx, AC_PINCTL_HP_EN
@@:
@@:
or edx, AC_PINCTL_OUT_EN
movzx eax, [esi + HDA_GNODE.nid]
stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, edx
mov eax, esi
jmp .out
.l1:
.continue:
.l1:
.continue:
mov edx, [esi + HDA_GNODE.next]
test edx, edx
jz .ret_zero
mov esi, edx
jmp .next_pin
.ret_zero:
.ret_zero:
xor eax, eax
.out:
.out:
pop esi edx
ret
endp
@ -866,13 +894,13 @@ proc parse_output
jz @f
mov [spec.out_pin_node], eax ; found, remember the PIN node
jmp .l1
@@:
@@:
; if no line-out is found, try speaker out
stdcall parse_output_jack, AC_JACK_SPEAKER
test eax, eax
jz .l1
mov [spec.out_pin_node], eax ; found, remember the PIN node
.l1:
.l1:
; look for the HP-out pin
stdcall parse_output_jack, AC_JACK_HP_OUT
test eax, eax
@ -883,9 +911,9 @@ proc parse_output
jnz @f
mov [spec.out_pin_node], eax
jmp .l2
@@:
@@:
mov [spec.out_pin_node+4], eax
.l2:
.l2:
mov edx, [spec.out_pin_node]
test edx, edx
jnz @f
@ -896,13 +924,13 @@ proc parse_output
mov [spec.out_pin_node], eax
test eax, eax
jnz @f
if DEBUG
if DEBUG
push esi
mov esi, emsgNoProperOutputPathFound
call SysMsgBoardStr
invoke SysMsgBoardStr
pop esi
end if
@@:
end if
@@:
pop edx
xor eax, eax
ret
@ -921,11 +949,15 @@ proc snd_hda_parse_generic_codec
cmp eax, 0
jl .error
if FDEBUG
stdcall print_afg_tree_nodes ;Asper+
end if
stdcall parse_output
xor eax, eax
.out:
.out:
ret
.error:
.error:
stdcall snd_hda_generic_free
ret
endp

File diff suppressed because it is too large Load Diff