2007-03-26 16:18:08 +04:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
format MS COFF
|
|
|
|
|
|
2008-06-09 16:12:09 +04:00
|
|
|
|
|
|
|
|
|
DEBUG equ 1
|
|
|
|
|
|
2006-10-07 13:47:03 +04:00
|
|
|
|
include 'proc32.inc'
|
2007-01-19 06:58:46 +03:00
|
|
|
|
include 'imports.inc'
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
API_VERSION equ 0x01000100
|
|
|
|
|
DEBUG_IRQ equ 0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices
|
|
|
|
|
IRQ_REMAP equ 0
|
|
|
|
|
IRQ_LINE equ 0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;irq 0,1,2,8,12,13 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
; FEDCBA9876543210
|
2008-03-18 20:19:08 +03:00
|
|
|
|
VALID_IRQ equ 1100111011111000b
|
|
|
|
|
ATTCH_IRQ equ 0000111010100000b
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
|
|
|
|
if USE_COM_IRQ
|
2008-03-18 20:19:08 +03:00
|
|
|
|
ATTCH_IRQ equ 0000111010111000b
|
2007-07-13 20:12:43 +04:00
|
|
|
|
end if
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CPU_FREQ equ 2600d
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
BIT0 EQU 0x00000001
|
|
|
|
|
BIT1 EQU 0x00000002
|
|
|
|
|
BIT2 EQU 0x00000004
|
|
|
|
|
BIT3 EQU 0x00000008
|
|
|
|
|
BIT4 EQU 0x00000010
|
|
|
|
|
BIT5 EQU 0x00000020
|
|
|
|
|
BIT6 EQU 0x00000040
|
|
|
|
|
BIT7 EQU 0x00000080
|
|
|
|
|
BIT8 EQU 0x00000100
|
|
|
|
|
BIT9 EQU 0x00000200
|
|
|
|
|
BIT10 EQU 0x00000400
|
|
|
|
|
BIT11 EQU 0x00000800
|
|
|
|
|
BIT12 EQU 0x00001000
|
|
|
|
|
BIT13 EQU 0x00002000
|
|
|
|
|
BIT14 EQU 0x00004000
|
|
|
|
|
BIT15 EQU 0x00008000
|
|
|
|
|
BIT16 EQU 0x00010000
|
|
|
|
|
BIT17 EQU 0x00020000
|
|
|
|
|
BIT18 EQU 0x00040000
|
|
|
|
|
BIT19 EQU 0x00080000
|
|
|
|
|
BIT20 EQU 0x00100000
|
|
|
|
|
BIT21 EQU 0x00200000
|
|
|
|
|
BIT22 EQU 0x00400000
|
|
|
|
|
BIT23 EQU 0x00800000
|
|
|
|
|
BIT24 EQU 0x00100000
|
|
|
|
|
BIT25 EQU 0x02000000
|
|
|
|
|
BIT26 EQU 0x04000000
|
|
|
|
|
BIT27 EQU 0x08000000
|
|
|
|
|
BIT28 EQU 0x10000000
|
|
|
|
|
BIT29 EQU 0x20000000
|
|
|
|
|
BIT30 EQU 0x40000000
|
|
|
|
|
BIT31 EQU 0x80000000
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
VID_SIS equ 0x1039
|
|
|
|
|
CTRL_SIS equ 0x7012
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
PCM_OUT_BDL equ 0x10 ; PCM out buffer descriptors list
|
|
|
|
|
PCM_OUT_CR_REG equ 0x1b ; PCM out Control Register
|
2006-10-07 13:47:03 +04:00
|
|
|
|
PCM_OUT_LVI_REG equ 0x15 ; PCM last valid index
|
2008-03-18 20:19:08 +03:00
|
|
|
|
PCM_OUT_SR_REG equ 0x18 ; PCM out Status register
|
2006-10-07 13:47:03 +04:00
|
|
|
|
PCM_OUT_PIV_REG equ 0x1a ; PCM out prefetched index
|
2008-03-18 20:19:08 +03:00
|
|
|
|
PCM_OUT_CIV_REG equ 0x14 ; PCM out current index
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
PCM_IN_CR_REG equ 0x0b ; PCM in Control Register
|
|
|
|
|
MC_IN_CR_REG equ 0x2b ; MIC in Control Register
|
2006-10-07 13:47:03 +04:00
|
|
|
|
RR equ BIT1 ; reset registers. Nukes all regs
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CODEC_MASTER_VOL_REG equ 0x02
|
|
|
|
|
CODEC_AUX_VOL equ 0x04 ;
|
|
|
|
|
CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume
|
|
|
|
|
CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio
|
2007-07-13 20:12:43 +04:00
|
|
|
|
CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control
|
|
|
|
|
CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate
|
|
|
|
|
CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate
|
|
|
|
|
CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
GLOB_CTRL equ 0x2C ; Global Control
|
|
|
|
|
CTRL_STAT equ 0x30 ; Global Status
|
|
|
|
|
CTRL_CAS equ 0x34 ; Codec Access Semiphore
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CAS_FLAG equ 0x01 ; Codec Access Semiphore Bit
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CTRL_ST_RCS equ 0x00008000 ; Read Completion Status
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CTRL_CNT_CRIE equ BIT4+BIT5+BIT6 ; Codecs Resume Interrupt Enable
|
2007-02-27 14:47:52 +03:00
|
|
|
|
CTRL_CNT_AC_OFF equ 0x00000008 ; ACLINK Off
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CTRL_CNT_WARM equ 0x00000004 ; AC97 Warm Reset
|
|
|
|
|
CTRL_CNT_COLD equ 0x00000002 ; AC97 Cold Reset
|
|
|
|
|
CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
CODEC_REG_POWERDOWN equ 0x26
|
2008-03-18 20:19:08 +03:00
|
|
|
|
CODEC_REG_ST equ 0x26
|
|
|
|
|
|
|
|
|
|
SRV_GETVERSION equ 0
|
|
|
|
|
DEV_PLAY equ 1
|
|
|
|
|
DEV_STOP equ 2
|
|
|
|
|
DEV_CALLBACK equ 3
|
|
|
|
|
DEV_SET_BUFF equ 4
|
|
|
|
|
DEV_NOTIFY equ 5
|
2006-10-07 13:47:03 +04:00
|
|
|
|
DEV_SET_MASTERVOL equ 6
|
|
|
|
|
DEV_GET_MASTERVOL equ 7
|
2008-03-18 20:19:08 +03:00
|
|
|
|
DEV_GET_INFO equ 8
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
struc AC_CNTRL ;AC controller base class
|
2008-03-18 20:19:08 +03:00
|
|
|
|
{ .bus dd ?
|
|
|
|
|
.devfn dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.vendor dd ?
|
|
|
|
|
.dev_id dd ?
|
|
|
|
|
.pci_cmd dd ?
|
|
|
|
|
.pci_stat dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.codec_io_base dd ?
|
|
|
|
|
.codec_mem_base dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.ctrl_io_base dd ?
|
|
|
|
|
.ctrl_mem_base dd ?
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.cfg_reg dd ?
|
|
|
|
|
.int_line dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.vendor_ids dd ? ;vendor id string
|
|
|
|
|
.ctrl_ids dd ? ;hub id string
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.buffer dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.notify_pos dd ?
|
|
|
|
|
.notify_task dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.lvi_reg dd ?
|
|
|
|
|
.ctrl_setup dd ?
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.user_callback dd ?
|
|
|
|
|
.codec_read16 dd ?
|
|
|
|
|
.codec_write16 dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.ctrl_read8 dd ?
|
|
|
|
|
.ctrl_read16 dd ?
|
|
|
|
|
.ctrl_read32 dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.ctrl_write8 dd ?
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.ctrl_write16 dd ?
|
|
|
|
|
.ctrl_write32 dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struc CODEC ;Audio Chip base class
|
|
|
|
|
{
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.chip_id dd ?
|
|
|
|
|
.flags dd ?
|
|
|
|
|
.status dd ?
|
2006-10-20 18:02:26 +04:00
|
|
|
|
|
|
|
|
|
.ac_vendor_ids dd ? ;ac vendor id string
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.chip_ids dd ? ;chip model string
|
2006-10-20 18:02:26 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.shadow_flag dd ?
|
|
|
|
|
dd ?
|
2006-10-20 18:02:26 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.regs dw ? ; codec registers
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_master_vol dw ? ;0x02
|
|
|
|
|
.reg_aux_out_vol dw ? ;0x04
|
|
|
|
|
.reg_mone_vol dw ? ;0x06
|
|
|
|
|
.reg_master_tone dw ? ;0x08
|
|
|
|
|
.reg_beep_vol dw ? ;0x0A
|
|
|
|
|
.reg_phone_vol dw ? ;0x0C
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.reg_mic_vol dw ? ;0x0E
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_line_in_vol dw ? ;0x10
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.reg_cd_vol dw ? ;0x12
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_video_vol dw ? ;0x14
|
|
|
|
|
.reg_aux_in_vol dw ? ;0x16
|
|
|
|
|
.reg_pcm_out_vol dw ? ;0x18
|
|
|
|
|
.reg_rec_select dw ? ;0x1A
|
|
|
|
|
.reg_rec_gain dw ? ;0x1C
|
|
|
|
|
.reg_rec_gain_mic dw ? ;0x1E
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.reg_gen dw ? ;0x20
|
|
|
|
|
.reg_3d_ctrl dw ? ;0X22
|
|
|
|
|
.reg_page dw ? ;0X24
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_powerdown dw ? ;0x26
|
|
|
|
|
.reg_ext_audio dw ? ;0x28
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.reg_ext_st dw ? ;0x2a
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_pcm_front_rate dw ? ;0x2c
|
|
|
|
|
.reg_pcm_surr_rate dw ? ;0x2e
|
|
|
|
|
.reg_lfe_rate dw ? ;0x30
|
|
|
|
|
.reg_pcm_in_rate dw ? ;0x32
|
2008-03-18 20:19:08 +03:00
|
|
|
|
dw ? ;0x34
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_cent_lfe_vol dw ? ;0x36
|
|
|
|
|
.reg_surr_vol dw ? ;0x38
|
|
|
|
|
.reg_spdif_ctrl dw ? ;0x3A
|
2008-03-18 20:19:08 +03:00
|
|
|
|
dw ? ;0x3C
|
|
|
|
|
dw ? ;0x3E
|
|
|
|
|
dw ? ;0x40
|
|
|
|
|
dw ? ;0x42
|
|
|
|
|
dw ? ;0x44
|
|
|
|
|
dw ? ;0x46
|
|
|
|
|
dw ? ;0x48
|
|
|
|
|
dw ? ;0x4A
|
|
|
|
|
dw ? ;0x4C
|
|
|
|
|
dw ? ;0x4E
|
|
|
|
|
dw ? ;0x50
|
|
|
|
|
dw ? ;0x52
|
|
|
|
|
dw ? ;0x54
|
|
|
|
|
dw ? ;0x56
|
|
|
|
|
dw ? ;0x58
|
|
|
|
|
dw ? ;0x5A
|
|
|
|
|
dw ? ;0x5C
|
|
|
|
|
dw ? ;0x5E
|
|
|
|
|
.reg_page_0 dw ? ;0x60
|
|
|
|
|
.reg_page_1 dw ? ;0x62
|
|
|
|
|
.reg_page_2 dw ? ;0x64
|
|
|
|
|
.reg_page_3 dw ? ;0x66
|
|
|
|
|
.reg_page_4 dw ? ;0x68
|
|
|
|
|
.reg_page_5 dw ? ;0x6A
|
|
|
|
|
.reg_page_6 dw ? ;0x6C
|
|
|
|
|
.reg_page_7 dw ? ;0x6E
|
|
|
|
|
dw ? ;0x70
|
|
|
|
|
dw ? ;0x72
|
|
|
|
|
dw ? ;0x74
|
|
|
|
|
dw ? ;0x76
|
|
|
|
|
dw ? ;0x78
|
|
|
|
|
dw ? ;0x7A
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.reg_vendor_id_1 dw ? ;0x7C
|
|
|
|
|
.reg_vendor_id_2 dw ? ;0x7E
|
|
|
|
|
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.reset dd ? ;virual
|
2006-10-20 18:02:26 +04:00
|
|
|
|
.set_master_vol dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struc CTRL_INFO
|
2008-03-18 20:19:08 +03:00
|
|
|
|
{ .pci_cmd dd ?
|
|
|
|
|
.irq dd ?
|
2007-02-27 14:47:52 +03:00
|
|
|
|
.glob_cntrl dd ?
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.glob_sta dd ?
|
2007-02-27 14:47:52 +03:00
|
|
|
|
.codec_io_base dd ?
|
|
|
|
|
.ctrl_io_base dd ?
|
|
|
|
|
.codec_mem_base dd ?
|
|
|
|
|
.ctrl_mem_base dd ?
|
2008-03-18 20:19:08 +03:00
|
|
|
|
.codec_id dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struc IOCTL
|
2008-03-18 20:19:08 +03:00
|
|
|
|
{ .handle dd ?
|
|
|
|
|
.io_code dd ?
|
|
|
|
|
.input dd ?
|
|
|
|
|
.inp_size dd ?
|
|
|
|
|
.output dd ?
|
|
|
|
|
.out_size dd ?
|
2006-10-07 13:47:03 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual at 0
|
|
|
|
|
IOCTL IOCTL
|
|
|
|
|
end virtual
|
|
|
|
|
|
|
|
|
|
EVENT_NOTIFY equ 0x00000200
|
|
|
|
|
|
|
|
|
|
public START
|
2006-10-20 18:02:26 +04:00
|
|
|
|
public service_proc
|
2006-12-02 11:18:48 +03:00
|
|
|
|
public version
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2006-10-20 18:02:26 +04:00
|
|
|
|
section '.flat' code readable align 16
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2006-11-20 10:06:00 +03:00
|
|
|
|
proc START stdcall, state:dword
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp [state], 1
|
|
|
|
|
jne .stop
|
2006-12-02 11:18:48 +03:00
|
|
|
|
|
2006-10-07 13:47:03 +04:00
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgInit
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call detect_controller
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .fail
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi,[ctrl.vendor_ids]
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
mov esi, [ctrl.ctrl_ids]
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call init_controller
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .fail
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
call init_codec
|
2008-03-18 20:19:08 +03:00
|
|
|
|
test eax, eax
|
|
|
|
|
jz .fail
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call reset_controller
|
|
|
|
|
call setup_codec
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgPrimBuff
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
call create_primary_buff
|
|
|
|
|
mov esi, msgDone
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2007-07-13 20:12:43 +04:00
|
|
|
|
if IRQ_REMAP
|
2008-03-18 20:19:08 +03:00
|
|
|
|
pushf
|
|
|
|
|
cli
|
|
|
|
|
|
|
|
|
|
mov ebx, [ctrl.int_line]
|
|
|
|
|
in al, 0xA1
|
|
|
|
|
mov ah, al
|
|
|
|
|
in al, 0x21
|
|
|
|
|
test ebx, ebx
|
|
|
|
|
jz .skip
|
|
|
|
|
bts ax, bx ;mask old line
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.skip
|
2008-03-18 20:19:08 +03:00
|
|
|
|
bts ax, IRQ_LINE ;mask new ine
|
|
|
|
|
out 0x21, al
|
|
|
|
|
mov al, ah
|
|
|
|
|
out 0xA1, al
|
|
|
|
|
;remap IRQ
|
|
|
|
|
stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
|
|
|
|
|
|
|
|
|
|
mov dx, 0x4d0 ;8259 ELCR1
|
|
|
|
|
in al, dx
|
|
|
|
|
bts ax, IRQ_LINE
|
|
|
|
|
out dx, al ;set level-triggered mode
|
|
|
|
|
mov [ctrl.int_line], IRQ_LINE
|
|
|
|
|
popf
|
|
|
|
|
mov esi, msgRemap
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
end if
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, VALID_IRQ
|
|
|
|
|
mov ebx, [ctrl.int_line]
|
|
|
|
|
mov esi, msgInvIRQ
|
|
|
|
|
bt eax, ebx
|
|
|
|
|
jnc .fail_msg
|
|
|
|
|
mov eax, ATTCH_IRQ
|
|
|
|
|
mov esi, msgAttchIRQ
|
|
|
|
|
bt eax, ebx
|
|
|
|
|
jnc .fail_msg
|
|
|
|
|
|
|
|
|
|
stdcall AttachIntHandler, ebx, ac97_irq, dword 0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.reg:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall RegService, sz_sound_srv, service_proc
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.fail:
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgFail
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.fail_msg:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-11-20 10:06:00 +03:00
|
|
|
|
.stop:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call stop
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-11-20 10:06:00 +03:00
|
|
|
|
endp
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
handle equ IOCTL.handle
|
|
|
|
|
io_code equ IOCTL.io_code
|
|
|
|
|
input equ IOCTL.input
|
|
|
|
|
inp_size equ IOCTL.inp_size
|
|
|
|
|
output equ IOCTL.output
|
|
|
|
|
out_size equ IOCTL.out_size
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc service_proc stdcall, ioctl:dword
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edi, [ioctl]
|
|
|
|
|
mov eax, [edi+io_code]
|
2007-04-18 10:37:14 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp eax, SRV_GETVERSION
|
|
|
|
|
jne @F
|
2007-04-18 10:37:14 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, [edi+output]
|
|
|
|
|
cmp [edi+out_size], 4
|
|
|
|
|
jne .fail
|
2007-04-18 10:37:14 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [eax], dword API_VERSION
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2007-04-18 10:37:14 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp eax, DEV_PLAY
|
|
|
|
|
jne @F
|
2006-10-07 13:47:03 +04:00
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgPlay
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call play
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp eax, DEV_STOP
|
|
|
|
|
jne @F
|
2006-10-07 13:47:03 +04:00
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgStop
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call stop
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp eax, DEV_CALLBACK
|
|
|
|
|
jne @F
|
|
|
|
|
mov ebx, [edi+input]
|
|
|
|
|
stdcall set_callback, [ebx]
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp eax, DEV_SET_MASTERVOL
|
|
|
|
|
jne @F
|
|
|
|
|
mov eax, [edi+input]
|
|
|
|
|
mov eax, [eax]
|
|
|
|
|
call set_master_vol ;eax= vol
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp eax, DEV_GET_MASTERVOL
|
|
|
|
|
jne @F
|
|
|
|
|
mov ebx, [edi+output]
|
|
|
|
|
stdcall get_master_vol, ebx
|
|
|
|
|
ret
|
2007-04-18 10:37:14 +04:00
|
|
|
|
;@@:
|
|
|
|
|
; cmp eax, DEV_GET_INFO
|
|
|
|
|
; jne @F
|
|
|
|
|
; mov ebx, [edi+output]
|
|
|
|
|
; stdcall get_dev_info, ebx
|
|
|
|
|
; ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
|
|
|
|
.fail:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
or eax, -1
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
restore handle
|
|
|
|
|
restore io_code
|
|
|
|
|
restore input
|
|
|
|
|
restore inp_size
|
|
|
|
|
restore output
|
|
|
|
|
restore out_size
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ac97_irq
|
|
|
|
|
|
2007-07-13 20:12:43 +04:00
|
|
|
|
if DEBUG_IRQ
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgIRQ
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
end if
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
mov al, 0x10
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ax, 0x1c
|
|
|
|
|
mov edx, PCM_OUT_SR_REG
|
|
|
|
|
call [ctrl.ctrl_write16]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CIV_REG
|
|
|
|
|
call [ctrl.ctrl_read8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
and eax, 0x1F
|
|
|
|
|
cmp eax, [civ_val]
|
|
|
|
|
je .skip
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [civ_val], eax
|
|
|
|
|
dec eax
|
|
|
|
|
and eax, 0x1F
|
|
|
|
|
mov [ctrl.lvi_reg], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_LVI_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
mov ax, 0x11
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, [civ_val]
|
|
|
|
|
add eax, 1
|
|
|
|
|
and eax, 31
|
|
|
|
|
mov ebx, dword [buff_list+eax*4]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
cmp [ctrl.user_callback], 0
|
|
|
|
|
je @f
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall [ctrl.user_callback], ebx
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
.skip:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
mov ax, 0x11
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc create_primary_buff
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall KernelAlloc, 0x10000
|
|
|
|
|
mov [ctrl.buffer], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edi, eax
|
|
|
|
|
mov ecx, 0x10000/4
|
|
|
|
|
xor eax, eax
|
|
|
|
|
cld
|
|
|
|
|
rep stosd
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, [ctrl.buffer]
|
|
|
|
|
call GetPgAddr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ebx, 0xC0004000
|
|
|
|
|
mov ecx, 4
|
|
|
|
|
mov edi, pcmout_bdl
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi], eax
|
|
|
|
|
mov [edi+4], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+32], eax
|
|
|
|
|
mov [edi+4+32], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+64], eax
|
|
|
|
|
mov [edi+4+64], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+96], eax
|
|
|
|
|
mov [edi+4+96], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+128], eax
|
|
|
|
|
mov [edi+4+128], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+160], eax
|
|
|
|
|
mov [edi+4+160], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+192], eax
|
|
|
|
|
mov [edi+4+192], ebx
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi+224], eax
|
|
|
|
|
mov [edi+4+224], ebx
|
2006-12-02 11:18:48 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add eax, 0x4000
|
|
|
|
|
add edi, 8
|
|
|
|
|
loop @B
|
2006-12-02 11:18:48 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edi, buff_list
|
|
|
|
|
mov eax, [ctrl.buffer]
|
|
|
|
|
mov ecx, 4
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [edi], eax
|
|
|
|
|
mov [edi+16], eax
|
|
|
|
|
mov [edi+32], eax
|
|
|
|
|
mov [edi+48], eax
|
|
|
|
|
mov [edi+64], eax
|
|
|
|
|
mov [edi+80], eax
|
|
|
|
|
mov [edi+96], eax
|
|
|
|
|
mov [edi+112], eax
|
|
|
|
|
|
|
|
|
|
add eax, 0x4000
|
|
|
|
|
add edi, 4
|
|
|
|
|
loop @B
|
|
|
|
|
|
|
|
|
|
mov eax, pcmout_bdl
|
|
|
|
|
mov ebx, eax
|
|
|
|
|
call GetPgAddr ;eax
|
|
|
|
|
and ebx, 0xFFF
|
|
|
|
|
add eax, ebx
|
|
|
|
|
|
|
|
|
|
mov edx, PCM_OUT_BDL
|
|
|
|
|
call [ctrl.ctrl_write32]
|
|
|
|
|
|
|
|
|
|
mov eax, 16
|
|
|
|
|
mov [ctrl.lvi_reg], eax
|
|
|
|
|
mov edx, PCM_OUT_LVI_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
and eax, not 0x000000C0
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_write32]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc detect_controller
|
2008-03-18 20:19:08 +03:00
|
|
|
|
locals
|
|
|
|
|
last_bus dd ?
|
|
|
|
|
bus dd ?
|
|
|
|
|
devfn dd ?
|
|
|
|
|
endl
|
2006-12-02 11:18:48 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov [bus], eax
|
|
|
|
|
inc eax
|
|
|
|
|
call PciApi
|
|
|
|
|
cmp eax, -1
|
|
|
|
|
je .err
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [last_bus], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
.next_bus:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
and [devfn], 0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.next_dev:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [bus], [devfn], dword 0
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .next
|
|
|
|
|
cmp eax, -1
|
|
|
|
|
je .next
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edi, devices
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ebx, [edi]
|
|
|
|
|
test ebx, ebx
|
|
|
|
|
jz .next
|
|
|
|
|
|
|
|
|
|
cmp eax, ebx
|
|
|
|
|
je .found
|
|
|
|
|
add edi, 12
|
|
|
|
|
jmp @B
|
2006-12-02 11:18:48 +03:00
|
|
|
|
.next:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
inc [devfn]
|
|
|
|
|
cmp [devfn], 256
|
|
|
|
|
jb .next_dev
|
|
|
|
|
mov eax, [bus]
|
|
|
|
|
inc eax
|
|
|
|
|
mov [bus], eax
|
|
|
|
|
cmp eax, [last_bus]
|
|
|
|
|
jna .next_bus
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.found:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ebx, [bus]
|
|
|
|
|
mov [ctrl.bus], ebx
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ecx, [devfn]
|
|
|
|
|
mov [ctrl.devfn], ecx
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, eax
|
|
|
|
|
and edx, 0xFFFF
|
|
|
|
|
mov [ctrl.vendor], edx
|
|
|
|
|
shr eax, 16
|
|
|
|
|
mov [ctrl.dev_id], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ebx, [edi+4]
|
|
|
|
|
mov [ctrl.ctrl_ids], ebx
|
|
|
|
|
mov [ctrl.vendor_ids], msg_SIS
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, [edi+8]
|
|
|
|
|
mov [ctrl.ctrl_setup], esi
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.err:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc init_controller
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
|
|
|
|
|
mov ebx, eax
|
|
|
|
|
and eax, 0xFFFF
|
|
|
|
|
mov [ctrl.pci_cmd], eax
|
|
|
|
|
shr ebx, 16
|
|
|
|
|
mov [ctrl.pci_stat], ebx
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgPciCmd
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgPciStat
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
mov eax, [ctrl.pci_stat]
|
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgMixIsaIo
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
and eax,0xFFFE
|
|
|
|
|
mov [ctrl.codec_io_base], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgCtrlIsaIo
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
and eax, 0xFFC0
|
|
|
|
|
mov [ctrl.ctrl_io_base], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgMixMMIo
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
|
|
|
|
|
mov [ctrl.codec_mem_base], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgCtrlMMIo
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
|
|
|
|
|
mov [ctrl.ctrl_mem_base], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.default:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
|
|
|
|
|
and eax, 0xFF
|
2007-07-13 20:12:43 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [ctrl.int_line], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
|
|
|
|
|
and eax, 0xFF
|
|
|
|
|
mov [ctrl.cfg_reg], eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call [ctrl.ctrl_setup]
|
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc set_SIS
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [ctrl.codec_read16], codec_io_r16 ;virtual
|
|
|
|
|
mov [ctrl.codec_write16], codec_io_w16 ;virtual
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual
|
|
|
|
|
mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual
|
|
|
|
|
mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual
|
|
|
|
|
mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual
|
|
|
|
|
mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc reset_controller
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov edx, PCM_IN_CR_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, MC_IN_CR_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, RR
|
|
|
|
|
mov edx, PCM_IN_CR_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, MC_IN_CR_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc init_codec
|
2008-03-18 20:19:08 +03:00
|
|
|
|
locals
|
|
|
|
|
counter dd ?
|
|
|
|
|
endl
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgControl
|
|
|
|
|
call SysMsgBoardStr
|
2006-12-24 10:50:24 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
2006-12-24 10:50:24 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgStatus
|
|
|
|
|
call SysMsgBoardStr
|
2006-12-24 10:50:24 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
push eax
|
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
pop eax
|
|
|
|
|
cmp eax, 0xFFFFFFFF
|
|
|
|
|
je .err
|
2006-12-24 10:50:24 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
test eax, CTRL_ST_CREADY
|
|
|
|
|
jnz .done ;;;;;.ready
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call reset_codec
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .err
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.ready:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor edx, edx ;ac_reg_0
|
|
|
|
|
call [ctrl.codec_write16]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov edx, CODEC_REG_POWERDOWN
|
|
|
|
|
call [ctrl.codec_write16]
|
2006-12-12 00:48:12 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [counter], 200 ; total 200*5 ms = 1s
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.wait:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 5000 ; wait 5 ms
|
|
|
|
|
call StallExec
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CODEC_REG_POWERDOWN
|
|
|
|
|
call [ctrl.codec_read16]
|
|
|
|
|
and eax, 0x0F
|
|
|
|
|
cmp eax, 0x0F
|
|
|
|
|
je .done
|
2006-12-12 00:48:12 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
sub [counter] , 1
|
|
|
|
|
jnz .wait
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.err:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax ; timeout error
|
|
|
|
|
ret
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.done:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 2 ;force set 16-bit 2-channel PCM
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_write32]
|
|
|
|
|
mov eax, 5000 ; wait 5 ms
|
|
|
|
|
call StallExec
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call detect_codec
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc reset_codec
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_read32]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
test eax, 0x02
|
|
|
|
|
jz .cold
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call warm_reset
|
|
|
|
|
jnc .ok
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.cold:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call cold_reset
|
|
|
|
|
jnc .ok
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgCFail
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax ; timeout error
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.ok:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc warm_reset
|
2008-03-18 20:19:08 +03:00
|
|
|
|
locals
|
|
|
|
|
counter dd ?
|
|
|
|
|
endl
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 0x06
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_write32]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgWarm
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [counter], 10 ; total 10*100 ms = 1s
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.wait:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 100000 ; wait 100 ms
|
|
|
|
|
call StallExec
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
test eax, CTRL_ST_CREADY
|
|
|
|
|
jnz .ok
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
dec [counter]
|
|
|
|
|
jnz .wait
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgWRFail
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
2007-07-13 20:12:43 +04:00
|
|
|
|
.fail:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.ok:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc cold_reset
|
2008-03-18 20:19:08 +03:00
|
|
|
|
locals
|
|
|
|
|
counter dd ?
|
|
|
|
|
endl
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 0x02
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_write32]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgCold
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 400000 ; wait 400 ms
|
|
|
|
|
call StallExec
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [counter], 16 ; total 20*100 ms = 2s
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.wait:
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
test eax, CTRL_ST_CREADY
|
|
|
|
|
jnz .ok
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, 100000 ; wait 100 ms
|
|
|
|
|
call StallExec
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
dec [counter]
|
|
|
|
|
jnz .wait
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgCRFail
|
|
|
|
|
call SysMsgBoardStr
|
2006-10-07 13:47:03 +04:00
|
|
|
|
end if
|
2007-07-13 20:12:43 +04:00
|
|
|
|
|
2006-12-12 00:48:12 +03:00
|
|
|
|
.fail:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.ok:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov esi, msgControl
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
|
|
|
|
|
mov esi, msgStatus
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
|
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
push eax
|
|
|
|
|
call dword2str
|
|
|
|
|
call SysMsgBoardStr
|
|
|
|
|
pop eax
|
|
|
|
|
|
|
|
|
|
test eax, CTRL_ST_CREADY
|
|
|
|
|
jz .fail
|
|
|
|
|
clc
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
2007-07-13 20:12:43 +04:00
|
|
|
|
play:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov [civ_val], eax
|
|
|
|
|
mov edx, PCM_OUT_CIV_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
|
|
|
|
|
mov eax, 16
|
|
|
|
|
mov [ctrl.lvi_reg], eax
|
|
|
|
|
mov edx, PCM_OUT_LVI_REG
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
|
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
mov ax, 0x1D
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
align 4
|
2007-07-13 20:12:43 +04:00
|
|
|
|
stop:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, PCM_OUT_CR_REG
|
|
|
|
|
mov ax, 0x0
|
|
|
|
|
call [ctrl.ctrl_write8]
|
|
|
|
|
|
|
|
|
|
mov ax, 0x1c
|
|
|
|
|
mov edx, PCM_OUT_SR_REG
|
|
|
|
|
call [ctrl.ctrl_write16]
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc get_dev_info stdcall, p_info:dword
|
2008-03-18 20:19:08 +03:00
|
|
|
|
virtual at esi
|
|
|
|
|
CTRL_INFO CTRL_INFO
|
|
|
|
|
end virtual
|
|
|
|
|
|
|
|
|
|
mov esi, [p_info]
|
|
|
|
|
mov eax, [ctrl.int_line]
|
|
|
|
|
mov ebx, [ctrl.codec_io_base]
|
|
|
|
|
mov ecx, [ctrl.ctrl_io_base]
|
|
|
|
|
mov edx, [ctrl.codec_mem_base]
|
|
|
|
|
mov edi, [ctrl.ctrl_mem_base]
|
|
|
|
|
|
|
|
|
|
mov [CTRL_INFO.irq], eax
|
|
|
|
|
mov [CTRL_INFO.codec_io_base], ebx
|
|
|
|
|
mov [CTRL_INFO.ctrl_io_base], ecx
|
|
|
|
|
mov [CTRL_INFO.codec_mem_base], edx
|
|
|
|
|
mov [CTRL_INFO.ctrl_mem_base], edi
|
|
|
|
|
|
|
|
|
|
mov eax, [codec.chip_id]
|
|
|
|
|
mov [CTRL_INFO.codec_id], eax
|
|
|
|
|
|
|
|
|
|
mov edx, GLOB_CTRL
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
mov [CTRL_INFO.glob_cntrl], eax
|
|
|
|
|
|
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
mov [CTRL_INFO.glob_sta], eax
|
|
|
|
|
|
|
|
|
|
mov ebx, [ctrl.pci_cmd]
|
|
|
|
|
mov [CTRL_INFO.pci_cmd], ebx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc set_callback stdcall, handler:dword
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov eax, [handler]
|
|
|
|
|
mov [ctrl.user_callback], eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, [ac_reg]
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov ebx, edx
|
|
|
|
|
shr ebx, 1
|
|
|
|
|
bt [codec.shadow_flag], ebx
|
|
|
|
|
jc .use_shadow
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
call [ctrl.codec_read16] ;change edx !!!
|
|
|
|
|
mov ecx, eax
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
test eax, CTRL_ST_RCS
|
|
|
|
|
jz .read_ok
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_STAT
|
|
|
|
|
call [ctrl.ctrl_write32]
|
|
|
|
|
xor eax,eax
|
|
|
|
|
not eax ;timeout
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.read_ok:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, [ac_reg]
|
|
|
|
|
mov [codec.regs+edx], cx
|
|
|
|
|
bts [codec.shadow_flag], ebx
|
|
|
|
|
mov eax, ecx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.use_shadow:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
movzx eax, word [codec.regs+edx]
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc codec_write stdcall, ac_reg:dword
|
2008-03-18 20:19:08 +03:00
|
|
|
|
push eax
|
|
|
|
|
call check_semafore
|
|
|
|
|
and eax, eax
|
|
|
|
|
jz .err
|
|
|
|
|
pop eax
|
|
|
|
|
|
|
|
|
|
mov esi, [ac_reg]
|
|
|
|
|
mov edx, esi
|
|
|
|
|
call [ctrl.codec_write16]
|
|
|
|
|
mov [codec.regs+esi], ax
|
|
|
|
|
shr esi, 1
|
|
|
|
|
bts [codec.shadow_flag], esi
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.err:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
pop eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc codec_check_ready
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_ST
|
|
|
|
|
call [ctrl.ctrl_read32]
|
|
|
|
|
and eax, CTRL_ST_CREADY
|
|
|
|
|
jz .not_ready
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, wax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.not_ready:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc check_semafore
|
2008-03-18 20:19:08 +03:00
|
|
|
|
local counter:DWORD
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov [counter], 100
|
2006-10-07 13:47:03 +04:00
|
|
|
|
.l1:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
mov edx, CTRL_CAS
|
|
|
|
|
call [ctrl.ctrl_read8]
|
|
|
|
|
and eax, CAS_FLAG
|
|
|
|
|
jz .ok
|
|
|
|
|
|
|
|
|
|
mov eax, 1
|
|
|
|
|
call StallExec
|
|
|
|
|
sub [counter], 1
|
|
|
|
|
jnz .l1
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
align 4
|
|
|
|
|
.ok:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
xor eax,eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc StallExec
|
2008-03-18 20:19:08 +03:00
|
|
|
|
push ecx
|
|
|
|
|
push edx
|
|
|
|
|
push ebx
|
|
|
|
|
push eax
|
|
|
|
|
|
|
|
|
|
mov ecx, CPU_FREQ
|
|
|
|
|
mul ecx
|
|
|
|
|
mov ebx, eax ;low
|
|
|
|
|
mov ecx, edx ;high
|
|
|
|
|
rdtsc
|
|
|
|
|
add ebx, eax
|
|
|
|
|
adc ecx, edx
|
2006-10-07 13:47:03 +04:00
|
|
|
|
@@:
|
2008-03-18 20:19:08 +03:00
|
|
|
|
rdtsc
|
|
|
|
|
sub eax, ebx
|
|
|
|
|
sbb edx, ecx
|
|
|
|
|
js @B
|
|
|
|
|
|
|
|
|
|
pop eax
|
|
|
|
|
pop ebx
|
|
|
|
|
pop edx
|
|
|
|
|
pop ecx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; CONTROLLER IO functions
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc codec_io_r16
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.codec_io_base]
|
|
|
|
|
in ax, dx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc codec_io_w16
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.codec_io_base]
|
|
|
|
|
out dx, ax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ctrl_io_r8
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.ctrl_io_base]
|
|
|
|
|
in al, dx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ctrl_io_r16
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.ctrl_io_base]
|
|
|
|
|
in ax, dx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ctrl_io_r32
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.ctrl_io_base]
|
|
|
|
|
in eax, dx
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ctrl_io_w8
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.ctrl_io_base]
|
|
|
|
|
out dx, al
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ctrl_io_w16
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.ctrl_io_base]
|
|
|
|
|
out dx, ax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
proc ctrl_io_w32
|
2008-03-18 20:19:08 +03:00
|
|
|
|
add edx, [ctrl.ctrl_io_base]
|
|
|
|
|
out dx, eax
|
|
|
|
|
ret
|
2006-10-07 13:47:03 +04:00
|
|
|
|
endp
|
|
|
|
|
|
2006-12-24 10:50:24 +03:00
|
|
|
|
align 4
|
|
|
|
|
dword2str:
|
|
|
|
|
mov esi, hex_buff
|
|
|
|
|
mov ecx, -8
|
|
|
|
|
@@:
|
|
|
|
|
rol eax, 4
|
|
|
|
|
mov ebx, eax
|
|
|
|
|
and ebx, 0x0F
|
|
|
|
|
mov bl, [ebx+hexletters]
|
|
|
|
|
mov [8+esi+ecx], bl
|
|
|
|
|
inc ecx
|
|
|
|
|
jnz @B
|
|
|
|
|
ret
|
|
|
|
|
|
2007-07-13 20:12:43 +04:00
|
|
|
|
hexletters db '0123456789ABCDEF'
|
|
|
|
|
hex_buff db 8 dup(0),13,10,0
|
2006-12-24 10:50:24 +03:00
|
|
|
|
|
2006-10-07 13:47:03 +04:00
|
|
|
|
include "codec.inc"
|
|
|
|
|
|
2006-10-20 18:02:26 +04:00
|
|
|
|
align 4
|
2006-10-07 13:47:03 +04:00
|
|
|
|
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
|
2008-03-18 20:19:08 +03:00
|
|
|
|
dd 0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
2007-04-18 10:37:14 +04:00
|
|
|
|
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
2006-12-02 11:18:48 +03:00
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
msg_AC db '7012 AC97 controller',13,10, 0
|
2006-12-02 11:18:48 +03:00
|
|
|
|
msg_SIS db 'Silicon Integrated Systems',13,10, 0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
|
|
|
|
|
sz_sound_srv db 'SOUND',0
|
|
|
|
|
|
|
|
|
|
msgInit db 'detect hardware...',13,10,0
|
|
|
|
|
msgFail db 'device not found',13,10,0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
msgAttchIRQ db 'IRQ line not supported', 13,10, 0
|
|
|
|
|
msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
msgPlay db 'start play', 13,10,0
|
|
|
|
|
msgStop db 'stop play', 13,10,0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
;msgNotify db 'call notify',13,10,0
|
2008-03-18 20:19:08 +03:00
|
|
|
|
msgIRQ db 'AC97 IRQ', 13,10,0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
msgInitCtrl db 'init controller',13,10,0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
;msgInitCodec db 'init codec',13,10,0
|
|
|
|
|
msgPrimBuff db 'create primary buffer ...',0
|
|
|
|
|
msgDone db 'done',13,10,0
|
|
|
|
|
msgRemap db 'Remap IRQ',13,10,0
|
|
|
|
|
;msgReg db 'set service handler',13,10,0
|
2008-03-18 20:19:08 +03:00
|
|
|
|
msgOk db 'service installed',13,10,0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
msgCold db 'cold reset',13,10,0
|
2006-10-07 13:47:03 +04:00
|
|
|
|
msgWarm db 'warm reset',13,10,0
|
|
|
|
|
msgWRFail db 'warm reset failed',13,10,0
|
|
|
|
|
msgCRFail db 'cold reset failed',13,10,0
|
|
|
|
|
msgCFail db 'codec not ready',13,10,0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
msgResetOk db 'reset complete',13,10,0
|
2006-12-24 10:50:24 +03:00
|
|
|
|
msgStatus db 'global status ',0
|
|
|
|
|
msgControl db 'global control ',0
|
2007-07-13 20:12:43 +04:00
|
|
|
|
msgPciCmd db 'PCI command ',0
|
|
|
|
|
msgPciStat db 'PCI status ',0
|
|
|
|
|
msgCtrlIsaIo db 'controller io base ',0
|
|
|
|
|
msgMixIsaIo db 'codec io base ',0
|
|
|
|
|
msgCtrlMMIo db 'controller mmio base ',0
|
|
|
|
|
msgMixMMIo db 'codec mmio base ',0
|
|
|
|
|
msgIrqMap db 'AC97 irq map as ',0
|
2006-10-20 18:02:26 +04:00
|
|
|
|
|
|
|
|
|
section '.data' data readable writable align 16
|
|
|
|
|
|
2008-03-18 20:19:08 +03:00
|
|
|
|
pcmout_bdl rq 32
|
|
|
|
|
buff_list rd 32
|
2006-10-20 18:02:26 +04:00
|
|
|
|
|
|
|
|
|
codec CODEC
|
|
|
|
|
ctrl AC_CNTRL
|
|
|
|
|
|
|
|
|
|
lpc_bus rd 1
|
|
|
|
|
civ_val rd 1
|