Fix silent play bug

git-svn-id: svn://kolibrios.org@3496 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Asper 2013-05-09 17:25:42 +00:00
parent a1dd9086b0
commit f7a17ff6c5
2 changed files with 223 additions and 168 deletions

View File

@ -74,7 +74,7 @@ proc codec_exec_verb stdcall, cmd:dword;, res:dword <- returned in eax
@@: @@:
; call snd_hda_power_down ;call snd_hda_power_down
cmp edx, -1 cmp edx, -1
jne .l1 jne .l1
@ -154,13 +154,24 @@ proc snd_hda_sequence_write stdcall, seq:dword
push eax ebx ecx esi push eax ebx ecx esi
mov esi, [seq] mov esi, [seq]
@@: @@:
mov ecx, [esi + hda_verb.nid] ;mov ecx, [esi + hda_verb.nid]
mov ebx, [esi + hda_verb.verb] ;mov ebx, [esi + hda_verb.verb]
mov eax, [esi + hda_verb.param] ;mov eax, [esi + hda_verb.param]
;stdcall snd_hda_codec_write, ecx, 0, ebx, eax
;add esi, hda_verb.sizeof
;test ecx, ecx
;jnz @b
;______________________________________
cmp dword [esi], 0
je .out
movzx ecx, word [esi] ; NID
movzx ebx, word [esi+2] ; verb
and bx, 0x0FFF
movzx eax, word [esi + 4] ; sizeof(param) = 4 bytes
stdcall snd_hda_codec_write, ecx, 0, ebx, eax stdcall snd_hda_codec_write, ecx, 0, ebx, eax
add esi, hda_verb.sizeof add esi, 6
test ecx, ecx jmp @b
jnz @b .out:
pop esi ecx ebx eax pop esi ecx ebx eax
ret ret
endp endp
@ -547,7 +558,7 @@ proc snd_hda_codec_init ; We use just one codec (the first found)
@@: @@:
; 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
pop ebx pop ebx
ret ret
@ -567,14 +578,7 @@ proc snd_hda_codec_configure
@@: @@:
; call the default parser ; call the default parser
stdcall snd_hda_parse_generic_codec ;entry point to generic tree parser!!! stdcall snd_hda_parse_generic_codec ;entry point to generic tree parser!!!
;Asper+:patch for HP Elitebook 8730w [
; push eax ebx
; mov ebx, [codec.afg]
; stdcall snd_hda_codec_write, ebx, 0, AC_VERB_SET_GPIO_MASK, 0x02
; stdcall snd_hda_codec_write, ebx, 0, AC_VERB_SET_GPIO_DIRECTION, 0x02
; stdcall snd_hda_codec_write, ebx, 0, AC_VERB_SET_GPIO_DATA, 0x02 ; first muted
; pop ebx eax
;Asper+ ]
test eax, eax test eax, eax
jz @f jz @f
if DEBUG if DEBUG

View File

@ -13,7 +13,7 @@ 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.
TEST_VERSION_NUMBER equ '018b' TEST_VERSION_NUMBER equ '018d'
;Asper+ [ ;Asper+ [
SDO_TAG equ 1 ;Asper: Output stream tag id (any number except 0) SDO_TAG equ 1 ;Asper: Output stream tag id (any number except 0)
@ -452,6 +452,52 @@ end virtual
EVENT_NOTIFY equ 0x00000200 EVENT_NOTIFY equ 0x00000200
; Macroses by CleverMouse
; The following macro assume that we are on uniprocessor machine.
; Serious work is needed for multiprocessor machines.
macro spin_lock_irqsave spinlock
{
pushf
cli
}
macro spin_unlock_irqrestore spinlock
{
popf
}
macro spin_lock_irq spinlock
{
cli
}
macro spin_unlock_irq spinlock
{
sti
}
SPINLOCK_BUSY = 1
SPINLOCK_FREE = 0
macro spin_lock
{
push eax ebx
mov eax, aspinlock
mov ebx, SPINLOCK_BUSY
@@:
lock xchg [eax], ebx
cmp ebx, SPINLOCK_FREE
jnz @b
pop ebx eax
}
macro spin_unlock
{
push eax ebx
mov eax, aspinlock
mov eax, aspinlock
mov ebx, SPINLOCK_FREE
lock xchg [eax], ebx
pop ebx eax
}
public START public START
public service_proc public service_proc
public version public version
@ -602,12 +648,7 @@ proc START stdcall, state:dword
stdcall RegService, sz_sound_srv, service_proc stdcall RegService, sz_sound_srv, service_proc
ret ret
.fail: .fail:
if DEBUG
mov esi, msgFail mov esi, msgFail
call SysMsgBoardStr
end if
xor eax, eax
ret
.fail_msg: .fail_msg:
call SysMsgBoardStr call SysMsgBoardStr
xor eax, eax xor eax, eax
@ -647,8 +688,8 @@ proc service_proc stdcall, ioctl:dword
mov esi, msgPlay mov esi, msgPlay
call SysMsgBoardStr call SysMsgBoardStr
end if end if
call play call play
xor eax, eax xor eax, eax
ret ret
@@: @@:
cmp eax, DEV_STOP cmp eax, DEV_STOP
@ -657,50 +698,50 @@ proc service_proc stdcall, ioctl:dword
mov esi, msgStop mov esi, msgStop
call SysMsgBoardStr call SysMsgBoardStr
end if end if
call stop call stop
xor eax, eax xor eax, eax
ret ret
@@: @@:
cmp eax, DEV_CALLBACK cmp eax, DEV_CALLBACK
jne @F jne @f
mov ebx, [edi+input] mov ebx, [edi+input]
stdcall set_callback, [ebx] stdcall set_callback, [ebx]
xor eax, eax xor eax, eax
ret ret
@@: @@:
cmp eax, DEV_SET_MASTERVOL cmp eax, DEV_SET_MASTERVOL
jne @F jne @f
mov eax, [edi+input] mov eax, [edi+input]
mov eax, [eax] mov eax, [eax]
call set_master_vol call set_master_vol
xor eax, eax xor eax, eax
ret ret
@@: @@:
cmp eax, DEV_GET_MASTERVOL cmp eax, DEV_GET_MASTERVOL
jne @F jne @f
mov ebx, [edi+output] mov ebx, [edi+output]
stdcall get_master_vol, ebx stdcall get_master_vol, ebx
xor eax, eax xor eax, eax
ret ret
;@@: ;@@:
; cmp eax, DEV_GET_INFO ; cmp eax, DEV_GET_INFO
; jne @F ; jne @f
; mov ebx, [edi+output] ; mov ebx, [edi+output]
; stdcall get_dev_info, ebx ; stdcall get_dev_info, ebx
; xor eax, eax ; xor eax, eax
; ret ; ret
@@: @@:
cmp eax, DEV_GET_POS cmp eax, DEV_GET_POS
jne @F jne @f
stdcall azx_get_position stdcall azx_get_position
shr eax, 2 shr eax, 2
mov ebx, [edi+output] mov ebx, [edi+output]
mov [ebx], eax mov [ebx], eax
xor eax, eax xor eax, eax
ret ret
@@: @@:
; cmp eax, DEV_SET_CHANNEL_VOLUME ; cmp eax, DEV_SET_CHANNEL_VOLUME
; jne @F ; jne @f
; if DEBUG ; if DEBUG
; mov esi, msgSetChannelVolume ; mov esi, msgSetChannelVolume
; call SysMsgBoardStr ; call SysMsgBoardStr
@ -709,30 +750,30 @@ proc service_proc stdcall, ioctl:dword
; mov cl, byte [ebx] ; cl=channel ; mov cl, byte [ebx] ; cl=channel
; mov eax, dword [ebx+1] ; eax=volume in Db ; mov eax, dword [ebx+1] ; eax=volume in Db
; if DEBUG ; if DEBUG
; push eax esi ; push eax esi
; mov esi, msgYAHOO1 ; mov esi, msgYAHOO1
; call SysMsgBoardStr ; call SysMsgBoardStr
; stdcall fdword2str, 1 ; stdcall fdword2str, 1
; call SysMsgBoardStr ; call SysMsgBoardStr
; mov esi, strSemicolon ; mov esi, strSemicolon
; call SysMsgBoardStr ; call SysMsgBoardStr
; movzx eax, cl ; movzx eax, cl
; stdcall fdword2str, 3 ; stdcall fdword2str, 3
; call SysMsgBoardStr ; call 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
;@@: ;@@:
; cmp eax, DEV_GET_CHANNEL_VOLUME ; cmp eax, DEV_GET_CHANNEL_VOLUME
; jne @F ; jne @f
; mov cl, byte [edi+input] ; cl=channel ; mov cl, byte [edi+input] ; cl=channel
; call get_channel_volume ; call get_channel_volume
; mov ebx, [edi+output] ; mov ebx, [edi+output]
; mov [ebx], eax ; mov [ebx], eax
; xor eax, eax ; xor eax, eax
; ret ; ret
;@@: ;@@:
@ -765,6 +806,7 @@ restore out_size
align 4 align 4
proc hda_irq ;+ proc hda_irq ;+
spin_lock
if DEBUG_IRQ if DEBUG_IRQ
push eax esi push eax esi
;mov esi, msgIRQ ;mov esi, msgIRQ
@ -778,6 +820,7 @@ proc hda_irq ;+
call azx_readl call azx_readl
test eax, eax test eax, eax
jnz @f jnz @f
spin_unlock
ret ret
@@: @@:
mov ebx, eax ; status mov ebx, eax ; status
@ -843,6 +886,7 @@ proc hda_irq ;+
@@: @@:
;end if ;end if
or eax, 1 or eax, 1
spin_unlock
ret ret
endp endp
@ -935,7 +979,7 @@ proc create_primary_buff
; wallclk has 24Mhz clock source ; wallclk has 24Mhz clock source
mov [ctrl.period_wallclk], ((0x4000 * 24000) / 48000) * 1000 mov [ctrl.period_wallclk], ((0x4000 * 24000) / 48000) * 1000
;-call azx_stream_reset call azx_stream_reset
call azx_setup_controller call azx_setup_controller
ret ret
endp endp
@ -1290,16 +1334,19 @@ endp
align 4 align 4
play: play:
spin_lock
mov edx, ICH6_REG_WALLCLK mov edx, ICH6_REG_WALLCLK
call azx_readl call azx_readl
mov [ctrl.start_wallclk], eax mov [ctrl.start_wallclk], eax
call azx_stream_start call azx_stream_start
xor eax, eax xor eax, eax
spin_unlock
ret ret
align 4 align 4
stop: stop:
spin_lock
;* call azx_stream_stop ;Asper: Hangs system ;* call azx_stream_stop ;Asper: Hangs system
;R push ebx ecx edx ;R push ebx ecx edx
;R ; stop DMA ;R ; stop DMA
@ -1339,6 +1386,7 @@ stop:
;Asper ] ;Asper ]
xor eax, eax xor eax, eax
spin_unlock
ret ret
;align 4 ;align 4
@ -1404,6 +1452,7 @@ proc azx_alloc_cmd_io
endp endp
proc azx_init_cmd_io proc azx_init_cmd_io
spin_lock_irq
pusha pusha
; CORB set up ; CORB set up
mov eax, [ctrl.rb] mov eax, [ctrl.rb]
@ -1471,10 +1520,12 @@ proc azx_init_cmd_io
call azx_writeb call azx_writeb
popa popa
spin_unlock_irq
ret ret
endp endp
proc azx_free_cmd_io proc azx_free_cmd_io
spin_lock_irq
push eax edx push eax edx
; disable ringbuffer DMAs ; disable ringbuffer DMAs
xor al, al xor al, al
@ -1483,12 +1534,14 @@ proc azx_free_cmd_io
mov edx, ICH6_REG_CORBCTL mov edx, ICH6_REG_CORBCTL
call azx_writeb call azx_writeb
pop edx eax pop edx eax
spin_unlock_irq
ret ret
endp endp
; send a command ; send a command
proc azx_corb_send_cmd stdcall, val:dword proc azx_corb_send_cmd stdcall, val:dword
spin_lock_irq
push edx edi push edx edi
xor eax, eax xor eax, eax
; add command to corb ; add command to corb
@ -1509,6 +1562,7 @@ proc azx_corb_send_cmd stdcall, val:dword
pop edi edx pop edi edx
xor eax, eax ;Asper+ xor eax, eax ;Asper+
spin_unlock_irq
ret ret
endp endp
@ -1589,7 +1643,9 @@ proc azx_rirb_get_response
test ah, ah test ah, ah
jz @f jz @f
.poll: .poll:
spin_lock_irq
call azx_update_rirb call azx_update_rirb
spin_unlock_irq
@@: @@:
mov eax, [ctrl.rirb_cmd] mov eax, [ctrl.rirb_cmd]
test eax, eax test eax, eax
@ -2457,56 +2513,50 @@ get_channel_volume:
shr eax, 2 ; *0.25 shr eax, 2 ; *0.25
neg eax neg eax
.out: .out:
pop edx ecx ebx pop edx ecx ebx
ret ret
; in: ecx = delay ; in: ecx = delay
udelay: udelay:
push eax ecx edx push eax ecx edx
test ecx, ecx test ecx, ecx
jnz @f jnz @f
inc ecx inc ecx
@@: @@:
mov eax, ecx mov eax, ecx
mov cx, 500 mov cx, 500
mul cl mul cl
mov ecx, edx mov ecx, edx
shl ecx, 16 shl ecx, 16
or ecx, eax or ecx, eax
@@: @@:
xor eax, eax xor eax, eax
cpuid cpuid
dec ecx dec ecx
jz @b jz @b
pop edx ecx eax pop edx ecx eax
ret ret
align 4 align 4
proc StallExec proc StallExec
push ecx push ecx edx ebx eax
push edx
push ebx
push eax
mov ecx, CPU_FREQ mov ecx, CPU_FREQ
mul ecx mul ecx
mov ebx, eax ;low mov ebx, eax ;low
mov ecx, edx ;high mov ecx, edx ;high
rdtsc rdtsc
add ebx, eax add ebx, eax
adc ecx,edx adc ecx,edx
@@: @@:
rdtsc rdtsc
sub eax, ebx sub eax, ebx
sbb edx, ecx sbb edx, ecx
js @B js @B
pop eax pop eax ebx edx ecx
pop ebx ret
pop edx
pop ecx
ret
endp endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -2515,44 +2565,44 @@ endp
align 4 align 4
proc azx_readb proc azx_readb
add edx, [ctrl.ctrl_mem_base] add edx, [ctrl.ctrl_mem_base]
mov al, [edx] mov al, [edx]
ret ret
endp endp
align 4 align 4
proc azx_readw proc azx_readw
add edx, [ctrl.ctrl_mem_base] add edx, [ctrl.ctrl_mem_base]
mov ax, [edx] mov ax, [edx]
ret ret
endp endp
align 4 align 4
proc azx_readl proc azx_readl
add edx, [ctrl.ctrl_mem_base] add edx, [ctrl.ctrl_mem_base]
mov eax, [edx] mov eax, [edx]
ret ret
endp endp
align 4 align 4
proc azx_writeb proc azx_writeb
add edx, [ctrl.ctrl_mem_base] add edx, [ctrl.ctrl_mem_base]
mov [edx], al mov [edx], al
ret ret
endp endp
align 4 align 4
proc azx_writew proc azx_writew
add edx, [ctrl.ctrl_mem_base] add edx, [ctrl.ctrl_mem_base]
mov [edx], ax mov [edx], ax
ret ret
endp endp
align 4 align 4
proc azx_writel proc azx_writel
add edx, [ctrl.ctrl_mem_base] add edx, [ctrl.ctrl_mem_base]
mov [edx], eax mov [edx], eax
ret ret
endp endp
;_______ ;_______
@ -2561,56 +2611,56 @@ endp
;Asper remember to add this functions: ;Asper remember to add this functions:
proc snd_hda_queue_unsol_event stdcall, par1:dword, par2:dword 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 call SysMsgBoardStr
pop esi pop esi
end if end if
ret ret
endp endp
;... ;...
align 4 align 4
proc fdword2str stdcall, flags:dword ; bit 0 - skipLeadZeroes; bit 1 - newLine; other bits undefined proc fdword2str stdcall, flags:dword ; bit 0 - skipLeadZeroes; bit 1 - newLine; other bits undefined
push eax ebx ecx push eax ebx ecx
mov esi, hex_buff mov esi, hex_buff
mov ecx, -8 mov ecx, -8
push eax push eax
@@: @@:
rol eax, 4 rol eax, 4
mov ebx, eax mov ebx, eax
and ebx, 0x0F and ebx, 0x0F
mov bl, [ebx+hexletters] mov bl, [ebx+hexletters]
mov [8+esi+ecx], bl mov [8+esi+ecx], bl
inc ecx inc ecx
jnz @B jnz @b
pop eax pop eax
mov dword [esi+8], 0 mov dword [esi+8], 0
test [flags], 0x2 ; new line ? test [flags], 0x2 ; new line ?
jz .no_newline jz .no_newline
mov dword [esi+8], 0x00000A0D mov dword [esi+8], 0x00000A0D
.no_newline: .no_newline:
push eax push eax
test [flags], 0x1 ; skip zero bits ? test [flags], 0x1 ; skip zero bits ?
jz .no_skipz jz .no_skipz
mov ecx, 8 mov ecx, 8
@@: @@:
test eax, 0xF0000000 test eax, 0xF0000000
jnz .skipz_done jnz .skipz_done
rol eax, 4 rol eax, 4
inc esi inc esi
dec ecx dec ecx
jnz @b jnz @b
dec esi dec esi
.skipz_done: .skipz_done:
.no_skipz: .no_skipz:
pop eax pop eax
pop ecx ebx eax pop ecx ebx eax
ret ret
endp endp
hexletters db '0123456789ABCDEF' hexletters db '0123456789ABCDEF'
@ -2913,6 +2963,7 @@ end if
section '.data' data readable writable align 16 section '.data' data readable writable align 16
aspinlock dd SPINLOCK_FREE
codec CODEC codec CODEC
ctrl AC_CNTRL ctrl AC_CNTRL