intel hda from Asper 0.18b

git-svn-id: svn://kolibrios.org@3083 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-12-07 02:56:49 +00:00
parent e1614186fc
commit 7a6b2a11ad
6 changed files with 6201 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,648 @@
; Universal Interface for Intel High Definition Audio Codec
; nodes
AC_NODE_ROOT equ 0x00
; function group types
AC_GRP_AUDIO_FUNCTION equ 0x01
AC_GRP_MODEM_FUNCTION equ 0x02
; widget types
AC_WID_AUD_OUT equ 0x0 ; Audio Out
AC_WID_AUD_IN equ 0x1 ; Audio In
AC_WID_AUD_MIX equ 0x2 ; Audio Mixer
AC_WID_AUD_SEL equ 0x3 ; Audio Selector
AC_WID_PIN equ 0x4 ; Pin Complex
AC_WID_POWER equ 0x5 ; Power
AC_WID_VOL_KNB equ 0x6 ; Volume Knob
AC_WID_BEEP equ 0x7 ; Beep Generator
AC_WID_VENDOR equ 0x0F ; Vendor specific
; GET verbs
AC_VERB_GET_STREAM_FORMAT equ 0x0A00
AC_VERB_GET_AMP_GAIN_MUTE equ 0x0B00
AC_VERB_GET_PROC_COEF equ 0x0C00
AC_VERB_GET_COEF_INDEX equ 0x0D00
AC_VERB_PARAMETERS equ 0x0F00
AC_VERB_GET_CONNECT_SEL equ 0x0F01
AC_VERB_GET_CONNECT_LIST equ 0x0F02
AC_VERB_GET_PROC_STATE equ 0x0F03
AC_VERB_GET_SDI_SELECT equ 0x0F04
AC_VERB_GET_POWER_STATE equ 0x0F05
AC_VERB_GET_CONV equ 0x0F06
AC_VERB_GET_PIN_WIDGET_CONTROL equ 0x0F07
AC_VERB_GET_UNSOLICITED_RESPONSE equ 0x0F08
AC_VERB_GET_PIN_SENSE equ 0x0F09
AC_VERB_GET_BEEP_CONTROL equ 0x0F0A
AC_VERB_GET_EAPD_BTLENABLE equ 0x0F0C
AC_VERB_GET_DIGI_CONVERT_1 equ 0x0F0D
AC_VERB_GET_DIGI_CONVERT_2 equ 0x0F0E ; unused
AC_VERB_GET_VOLUME_KNOB_CONTROL equ 0x0F0F
; f10-f1a: GPIO
AC_VERB_GET_GPIO_DATA equ 0x0F15
AC_VERB_GET_GPIO_MASK equ 0x0F16
AC_VERB_GET_GPIO_DIRECTION equ 0x0F17
AC_VERB_GET_GPIO_WAKE_MASK equ 0x0F18
AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK equ 0x0F19
AC_VERB_GET_GPIO_STICKY_MASK equ 0x0F1A
AC_VERB_GET_CONFIG_DEFAULT equ 0x0F1C
; f20: AFG/MFG
AC_VERB_GET_SUBSYSTEM_ID equ 0x0F20
AC_VERB_GET_CVT_CHAN_COUNT equ 0x0F2D
AC_VERB_GET_HDMI_DIP_SIZE equ 0x0F2E
AC_VERB_GET_HDMI_ELDD equ 0x0F2F
AC_VERB_GET_HDMI_DIP_INDEX equ 0x0F30
AC_VERB_GET_HDMI_DIP_DATA equ 0x0F31
AC_VERB_GET_HDMI_DIP_XMIT equ 0x0F32
AC_VERB_GET_HDMI_CP_CTRL equ 0x0F33
AC_VERB_GET_HDMI_CHAN_SLOT equ 0x0F34
; SET verbs
AC_VERB_SET_STREAM_FORMAT equ 0x200
AC_VERB_SET_AMP_GAIN_MUTE equ 0x300
AC_VERB_SET_PROC_COEF equ 0x400
AC_VERB_SET_COEF_INDEX equ 0x500
AC_VERB_SET_CONNECT_SEL equ 0x701
AC_VERB_SET_PROC_STATE equ 0x703
AC_VERB_SET_SDI_SELECT equ 0x704
AC_VERB_SET_POWER_STATE equ 0x705
AC_VERB_SET_CHANNEL_STREAMID equ 0x706
AC_VERB_SET_PIN_WIDGET_CONTROL equ 0x707
AC_VERB_SET_UNSOLICITED_ENABLE equ 0x708
AC_VERB_SET_PIN_SENSE equ 0x709
AC_VERB_SET_BEEP_CONTROL equ 0x70A
AC_VERB_SET_EAPD_BTLENABLE equ 0x70C
AC_VERB_SET_DIGI_CONVERT_1 equ 0x70D
AC_VERB_SET_DIGI_CONVERT_2 equ 0x70E
AC_VERB_SET_VOLUME_KNOB_CONTROL equ 0x70F
AC_VERB_SET_GPIO_DATA equ 0x715
AC_VERB_SET_GPIO_MASK equ 0x716
AC_VERB_SET_GPIO_DIRECTION equ 0x717
AC_VERB_SET_GPIO_WAKE_MASK equ 0x718
AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK equ 0x719
AC_VERB_SET_GPIO_STICKY_MASK equ 0x71A
AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 equ 0x71C
AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 equ 0x71D
AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 equ 0x71E
AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 equ 0x71F
AC_VERB_SET_EAPD equ 0x788
AC_VERB_SET_CODEC_RESET equ 0x7FF
AC_VERB_SET_CVT_CHAN_COUNT equ 0x72D
AC_VERB_SET_HDMI_DIP_INDEX equ 0x730
AC_VERB_SET_HDMI_DIP_DATA equ 0x731
AC_VERB_SET_HDMI_DIP_XMIT equ 0x732
AC_VERB_SET_HDMI_CP_CTRL equ 0x733
AC_VERB_SET_HDMI_CHAN_SLOT equ 0x734
; Parameter IDs
AC_PAR_VENDOR_ID equ 0x00
AC_PAR_SUBSYSTEM_ID equ 0x01
AC_PAR_REV_ID equ 0x02
AC_PAR_NODE_COUNT equ 0x04
AC_PAR_FUNCTION_TYPE equ 0x05
AC_PAR_AUDIO_FG_CAP equ 0x08
AC_PAR_AUDIO_WIDGET_CAP equ 0x09
AC_PAR_PCM equ 0x0A
AC_PAR_STREAM equ 0x0B
AC_PAR_PIN_CAP equ 0x0C
AC_PAR_AMP_IN_CAP equ 0x0D
AC_PAR_CONNLIST_LEN equ 0x0E
AC_PAR_POWER_STATE equ 0x0F
AC_PAR_PROC_CAP equ 0x10
AC_PAR_GPIO_CAP equ 0x11
AC_PAR_AMP_OUT_CAP equ 0x12
AC_PAR_VOL_KNB_CAP equ 0x13
AC_PAR_HDMI_LPCM_CAP equ 0x20
; AC_VERB_PARAMETERS results (32bit)
; Function Group Type
AC_FGT_TYPE equ (0xFF shl 0)
AC_FGT_TYPE_SHIFT equ 0
AC_FGT_UNSOL_CAP equ (1 shl 8)
; Audio Function Group Capabilities
AC_AFG_OUT_DELAY equ (0xF shl 0)
AC_AFG_IN_DELAY equ (0xF shl 8)
AC_AFG_BEEP_GEN equ (1 shl 16)
; Audio Widget Capabilities
AC_WCAP_STEREO equ (1 shl 0) ; stereo I/O
AC_WCAP_IN_AMP equ (1 shl 1) ; AMP-in present
AC_WCAP_OUT_AMP equ (1 shl 2) ; AMP-out present
AC_WCAP_AMP_OVRD equ (1 shl 3) ; AMP-parameter override
AC_WCAP_FORMAT_OVRD equ (1 shl 4) ; format override
AC_WCAP_STRIPE equ (1 shl 5) ; stripe
AC_WCAP_PROC_WID equ (1 shl 6) ; Proc Widget
AC_WCAP_UNSOL_CAP equ (1 shl 7) ; Unsol capable
AC_WCAP_CONN_LIST equ (1 shl 8) ; connection list
AC_WCAP_DIGITAL equ (1 shl 9) ; digital I/O
AC_WCAP_POWER equ (1 shl 10) ; power control
AC_WCAP_LR_SWAP equ (1 shl 11) ; L/R swap
AC_WCAP_CP_CAPS equ (1 shl 12) ; content protection
AC_WCAP_CHAN_CNT_EXT equ (7 shl 13) ; channel count ext
AC_WCAP_DELAY equ (0xF shl 16)
AC_WCAP_DELAY_SHIFT equ 16
AC_WCAP_TYPE equ (0xF shl 20)
AC_WCAP_TYPE_SHIFT equ 20
; supported PCM rates and bits
AC_SUPPCM_RATES equ (0xFFF shl 0)
AC_SUPPCM_BITS_8 equ (1 shl 16)
AC_SUPPCM_BITS_16 equ (1 shl 17)
AC_SUPPCM_BITS_20 equ (1 shl 18)
AC_SUPPCM_BITS_24 equ (1 shl 19)
AC_SUPPCM_BITS_32 equ (1 shl 20)
; supported PCM stream format
AC_SUPFMT_PCM equ (1 shl 0)
AC_SUPFMT_FLOAT32 equ (1 shl 1)
AC_SUPFMT_AC3 equ (1 shl 2)
; GP I/O count
AC_GPIO_IO_COUNT equ (0xFF shl 0)
AC_GPIO_O_COUNT equ (0xFF shl 8)
AC_GPIO_O_COUNT_SHIFT equ 8
AC_GPIO_I_COUNT equ (0xFF shl 16)
AC_GPIO_I_COUNT_SHIFT equ 16
AC_GPIO_UNSOLICITED equ (1 shl 30)
AC_GPIO_WAKE equ (1 shl 31)
; Converter stream, channel
AC_CONV_CHANNEL equ (0xF shl 0)
AC_CONV_STREAM equ (0xF shl 4)
AC_CONV_STREAM_SHIFT equ 4
; Input converter SDI select
AC_SDI_SELECT equ (0xF shl 0)
; Unsolicited response control
AC_UNSOL_TAG equ (0x3F shl 0)
AC_UNSOL_ENABLED equ (1 shl 7)
AC_USRSP_EN equ AC_UNSOL_ENABLED
; Unsolicited responses
AC_UNSOL_RES_TAG equ (0x3F shl 26)
AC_UNSOL_RES_TAG_SHIFT equ 26
AC_UNSOL_RES_SUBTAG equ (0x1F shl 21)
AC_UNSOL_RES_SUBTAG_SHIFT equ 21
AC_UNSOL_RES_ELDV equ (1 shl 1) ; ELD Data valid (for HDMI)
AC_UNSOL_RES_PD equ (1 shl 0) ; pinsense detect
AC_UNSOL_RES_CP_STATE equ (1 shl 1) ; content protection
AC_UNSOL_RES_CP_READY equ (1 shl 0) ; content protection
; Pin widget capabilies
AC_PINCAP_IMP_SENSE equ (1 shl 0) ; impedance sense capable
AC_PINCAP_TRIG_REQ equ (1 shl 1) ; trigger required
AC_PINCAP_PRES_DETECT equ (1 shl 2) ; presence detect capable
AC_PINCAP_HP_DRV equ (1 shl 3) ; headphone drive capable
AC_PINCAP_OUT equ (1 shl 4) ; output capable
AC_PINCAP_IN equ (1 shl 5) ; input capable
AC_PINCAP_BALANCE equ (1 shl 6) ; balanced I/O capable
; Note: This LR_SWAP pincap is defined in the Realtek ALC883 specification,
; but is marked reserved in the Intel HDA specification.
AC_PINCAP_LR_SWAP equ (1 shl 7) ; L/R swap
; Note: The same bit as LR_SWAP is newly defined as HDMI capability
; in HD-audio specification
AC_PINCAP_HDMI equ (1 shl 7) ; HDMI pin
AC_PINCAP_DP equ (1 shl 24) ; DisplayPort pin, can
; coexist with AC_PINCAP_HDMI
AC_PINCAP_VREF equ (0x37 shl 8)
AC_PINCAP_VREF_SHIFT equ 8
AC_PINCAP_EAPD equ (1 shl 16) ; EAPD capable
AC_PINCAP_HBR equ (1 shl 27) ; High Bit Rate
; Vref status (used in pin cap)
AC_PINCAP_VREF_HIZ equ (1 shl 0) ; Hi-Z
AC_PINCAP_VREF_50 equ (1 shl 1) ; 50%
AC_PINCAP_VREF_GRD equ (1 shl 2) ; ground
AC_PINCAP_VREF_80 equ (1 shl 4) ; 80%
AC_PINCAP_VREF_100 equ (1 shl 5) ; 100%
; Amplifier capabilities
AC_AMPCAP_OFFSET equ (0x7F shl 0) ; 0dB offset
AC_AMPCAP_OFFSET_SHIFT equ 0
AC_AMPCAP_NUM_STEPS equ (0x7F shl 8) ; number of steps
AC_AMPCAP_NUM_STEPS_SHIFT equ 8
AC_AMPCAP_STEP_SIZE equ (0x7F shl 16) ; step size 0-32dB
; in 0.25dB
AC_AMPCAP_STEP_SIZE_SHIFT equ 16
AC_AMPCAP_MUTE equ (1 shl 31) ; mute capable
AC_AMPCAP_MUTE_SHIFT equ 31
; Connection list
AC_CLIST_LENGTH equ (0x7F shl 0)
AC_CLIST_LONG equ (1 shl 7)
; Supported power status
AC_PWRST_D0SUP equ (1 shl 0)
AC_PWRST_D1SUP equ (1 shl 1)
AC_PWRST_D2SUP equ (1 shl 2)
AC_PWRST_D3SUP equ (1 shl 3)
AC_PWRST_D3COLDSUP equ (1 shl 4)
AC_PWRST_S3D3COLDSUP equ (1 shl 29)
AC_PWRST_CLKSTOP equ (1 shl 30)
AC_PWRST_EPSS equ (1 shl 31)
; Power state values
AC_PWRST_SETTING equ (0xF shl 0)
AC_PWRST_ACTUAL equ (0xF shl 4)
AC_PWRST_ACTUAL_SHIFT equ 4
AC_PWRST_D0 equ 0x00
AC_PWRST_D1 equ 0x01
AC_PWRST_D2 equ 0x02
AC_PWRST_D3 equ 0x03
; Processing capabilies
AC_PCAP_BENIGN equ (1 shl 0)
AC_PCAP_NUM_COEF equ (0xFF shl 8)
AC_PCAP_NUM_COEF_SHIFT equ 8
; Volume knobs capabilities
AC_KNBCAP_NUM_STEPS equ (0x7F shl 0)
AC_KNBCAP_DELTA equ (1 shl 7)
; HDMI LPCM capabilities
AC_LPCMCAP_48K_CP_CHNS equ (0x0F shl 0) ; max channels w/ CP-on
AC_LPCMCAP_48K_NO_CHNS equ (0x0F shl 4) ; max channels w/o CP-on
AC_LPCMCAP_48K_20BIT equ (1 shl 8) ; 20b bitrate supported
AC_LPCMCAP_48K_24BIT equ (1 shl 9) ; 24b bitrate supported
AC_LPCMCAP_96K_CP_CHNS equ (0x0F shl 10) ; max channels w/ CP-on
AC_LPCMCAP_96K_NO_CHNS equ (0x0F shl 14) ; max channels w/o CP-on
AC_LPCMCAP_96K_20BIT equ (1 shl 18) ; 20b bitrate supported
AC_LPCMCAP_96K_24BIT equ (1 shl 19) ; 24b bitrate supported
AC_LPCMCAP_192K_CP_CHNS equ (0x0F shl 20) ; max channels w/ CP-on
AC_LPCMCAP_192K_NO_CHNS equ (0x0F shl 24) ; max channels w/o CP-on
AC_LPCMCAP_192K_20BIT equ (1 shl 28) ; 20b bitrate supported
AC_LPCMCAP_192K_24BIT equ (1 shl 29) ; 24b bitrate supported
AC_LPCMCAP_44K equ (1 shl 30) ; 44.1kHz support
AC_LPCMCAP_44K_MS equ (1 shl 31) ; 44.1kHz-multiplies support
; Control Parameters
; Amp gain/mute
AC_AMP_MUTE equ (1 shl 7)
AC_AMP_GAIN equ (0x7F)
AC_AMP_GET_INDEX equ (0xF shl 0)
AC_AMP_GET_LEFT equ (1 shl 13)
AC_AMP_GET_RIGHT equ (0 shl 13)
AC_AMP_GET_OUTPUT equ (1 shl 15)
AC_AMP_GET_INPUT equ (0 shl 15)
AC_AMP_SET_INDEX equ (0xF shl 8)
AC_AMP_SET_INDEX_SHIFT equ 8
AC_AMP_SET_RIGHT equ (1 shl 12)
AC_AMP_SET_LEFT equ (1 shl 13)
AC_AMP_SET_INPUT equ (1 shl 14)
AC_AMP_SET_OUTPUT equ (1 shl 15)
; DIGITAL1 bits
AC_DIG1_ENABLE equ (1 shl 0)
AC_DIG1_V equ (1 shl 1)
AC_DIG1_VCFG equ (1 shl 2)
AC_DIG1_EMPHASIS equ (1 shl 3)
AC_DIG1_COPYRIGHT equ (1 shl 4)
AC_DIG1_NONAUDIO equ (1 shl 5)
AC_DIG1_PROFESSIONAL equ (1 shl 6)
AC_DIG1_LEVEL equ (1 shl 7)
; DIGITAL2 bits
AC_DIG2_CC equ (0x7F shl 0)
; Pin widget control - 8bit
AC_PINCTL_VREFEN equ (0x7 shl 0)
AC_PINCTL_VREF_HIZ equ 0 ; Hi-Z
AC_PINCTL_VREF_50 equ 1 ; 50%
AC_PINCTL_VREF_GRD equ 2 ; ground
AC_PINCTL_VREF_80 equ 4 ; 80%
AC_PINCTL_VREF_100 equ 5 ; 100%
AC_PINCTL_IN_EN equ (1 shl 5)
AC_PINCTL_OUT_EN equ (1 shl 6)
AC_PINCTL_HP_EN equ (1 shl 7)
; Pin sense - 32bit
AC_PINSENSE_IMPEDANCE_MASK equ (0x7FFFFFFF)
AC_PINSENSE_PRESENCE equ (1 shl 31)
AC_PINSENSE_ELDV equ (1 shl 30) ; ELD valid (HDMI)
; EAPD/BTL enable - 32bit
AC_EAPDBTL_BALANCED equ (1 shl 0)
AC_EAPDBTL_EAPD equ (1 shl 1)
AC_EAPDBTL_LR_SWAP equ (1 shl 2)
; HDMI ELD data
AC_ELDD_ELD_VALID equ (1 shl 31)
AC_ELDD_ELD_DATA equ 0xFF
; HDMI DIP size
AC_DIPSIZE_ELD_BUF equ (1 shl 3) ; ELD buf size of packet size
AC_DIPSIZE_PACK_IDX equ (0x07 shl 0) ; packet index
; HDMI DIP index
AC_DIPIDX_PACK_IDX equ (0x07 shl 5) ; packet idnex
AC_DIPIDX_BYTE_IDX equ (0x1F shl 0) ; byte index
; HDMI DIP xmit (transmit) control
AC_DIPXMIT_MASK equ (0x3 shl 6)
AC_DIPXMIT_DISABLE equ (0x0 shl 6) ; disable xmit
AC_DIPXMIT_ONCE equ (0x2 shl 6) ; xmit once then disable
AC_DIPXMIT_BEST equ (0x3 shl 6) ; best effort
; HDMI content protection (CP) control
AC_CPCTRL_CES equ (1 shl 9) ; current encryption state
AC_CPCTRL_READY equ (1 shl 8) ; ready bit
AC_CPCTRL_SUBTAG equ (0x1F shl 3) ; subtag for unsol-resp
AC_CPCTRL_STATE equ (3 shl 0) ; current CP request state
; Converter channel <-> HDMI slot mapping
AC_CVTMAP_HDMI_SLOT equ (0xF shl 0) ; HDMI slot number
AC_CVTMAP_CHAN equ (0xF shl 4) ; converter channel number
; configuration default - 32bit
AC_DEFCFG_SEQUENCE equ (0xF shl 0)
AC_DEFCFG_DEF_ASSOC equ (0xF shl 4)
AC_DEFCFG_ASSOC_SHIFT equ 4
AC_DEFCFG_MISC equ (0xF shl 8)
AC_DEFCFG_MISC_SHIFT equ 8
AC_DEFCFG_MISC_NO_PRESENCE equ (1 shl 0)
AC_DEFCFG_COLOR equ (0xF shl 12)
AC_DEFCFG_COLOR_SHIFT equ 12
AC_DEFCFG_CONN_TYPE equ (0xF shl 16)
AC_DEFCFG_CONN_TYPE_SHIFT equ 16
AC_DEFCFG_DEVICE equ (0xF shl 20)
AC_DEFCFG_DEVICE_SHIFT equ 20
AC_DEFCFG_LOCATION equ (0x3F shl 24)
AC_DEFCFG_LOCATION_SHIFT equ 24
AC_DEFCFG_PORT_CONN equ (0x3 shl 30)
AC_DEFCFG_PORT_CONN_SHIFT equ 30
; device device types (0x0-0xf)
AC_JACK_LINE_OUT equ 0x0
AC_JACK_SPEAKER equ 0x1
AC_JACK_HP_OUT equ 0x2
AC_JACK_CD equ 0x3
AC_JACK_SPDIF_OUT equ 0x4
AC_JACK_DIG_OTHER_OUT equ 0x5
AC_JACK_MODEM_LINE_SIDE equ 0x6
AC_JACK_MODEM_HAND_SIDE equ 0x7
AC_JACK_LINE_IN equ 0x8
AC_JACK_AUX equ 0x9
AC_JACK_MIC_IN equ 0xA
AC_JACK_TELEPHONY equ 0xB
AC_JACK_SPDIF_IN equ 0xC
AC_JACK_DIG_OTHER_IN equ 0xD
AC_JACK_OTHER equ 0xF
; jack connection types (0x0-0xf)
AC_JACK_CONN_UNKNOWN equ 0x0
AC_JACK_CONN_1_8 equ 0x1
AC_JACK_CONN_1_4 equ 0x2
AC_JACK_CONN_ATAPI equ 0x3
AC_JACK_CONN_RCA equ 0x4
AC_JACK_CONN_OPTICAL equ 0x5
AC_JACK_CONN_OTHER_DIGITAL equ 0x6
AC_JACK_CONN_OTHER_ANALOG equ 0x7
AC_JACK_CONN_DIN equ 0x8
AC_JACK_CONN_XLR equ 0x9
AC_JACK_CONN_RJ11 equ 0xA
AC_JACK_CONN_COMB equ 0xB
AC_JACK_CONN_OTHER equ 0xF
; jack colors (0x0-0xf)
AC_JACK_COLOR_UNKNOWN equ 0x0
AC_JACK_COLOR_BLACK equ 0x1
AC_JACK_COLOR_GREY equ 0x2
AC_JACK_COLOR_BLUE equ 0x3
AC_JACK_COLOR_GREEN equ 0x4
AC_JACK_COLOR_RED equ 0x5
AC_JACK_COLOR_ORANGE equ 0x6
AC_JACK_COLOR_YELLOW equ 0x7
AC_JACK_COLOR_PURPLE equ 0x8
AC_JACK_COLOR_PINK equ 0x9
AC_JACK_COLOR_WHITE equ 0xE
AC_JACK_COLOR_OTHER equ 0xF
; Jack location (0x0-0x3f)
; common case
AC_JACK_LOC_NONE equ 0
AC_JACK_LOC_REAR equ 1
AC_JACK_LOC_FRONT equ 2
AC_JACK_LOC_LEFT equ 3
AC_JACK_LOC_RIGHT equ 4
AC_JACK_LOC_TOP equ 5
AC_JACK_LOC_BOTTOM equ 6
; bits 4-5
AC_JACK_LOC_EXTERNAL equ 0x00
AC_JACK_LOC_INTERNAL equ 0x10
AC_JACK_LOC_SEPARATE equ 0x20
AC_JACK_LOC_OTHER equ 0x30
; external on primary chasis
AC_JACK_LOC_REAR_PANEL equ 0x07
AC_JACK_LOC_DRIVE_BAY equ 0x08
; internal
AC_JACK_LOC_RISER equ 0x17
AC_JACK_LOC_HDMI equ 0x18
AC_JACK_LOC_ATAPI equ 0x19
; others
AC_JACK_LOC_MOBILE_IN equ 0x37
AC_JACK_LOC_MOBILE_OUT equ 0x38
; Port connectivity (0-3)
AC_JACK_PORT_COMPLEX equ 0
AC_JACK_PORT_NONE equ 1
AC_JACK_PORT_FIXED equ 2
AC_JACK_PORT_BOTH equ 3
; max. connections to a widget
HDA_MAX_CONNECTIONS equ 32
; max. codec address
HDA_MAX_CODEC_ADDRESS equ 0x0f
; max number of PCM devics per card
HDA_MAX_PCMS equ 10
; Structures
; direction
HDA_INPUT equ 0x0
HDA_OUTPUT equ 0x1
struc HDA_VERB
{
.nid dw ?
.verb dd ?
.param dd ?
}
virtual at 0
HDA_VERB HDA_VERB
end virtual
; the struct for codec->pin_configs
struc HDA_PINCFG
{
.nid dw ?
.reserved dw ? ;Asper + for align purposes
.cfg dd ?
.sizeof:
}
virtual at 0
HDA_PINCFG HDA_PINCFG
end virtual
;Asper [ this part is from "hda_local.h"
;(...)
; amp value bits
HDA_AMP_MUTE equ 0x80
HDA_AMP_UNMUTE equ 0x00
HDA_AMP_VOLMASK equ 0x7F
;(...)
; unsolicited event handler
HDA_UNSOL_QUEUE_SIZE equ 64
;struc HDA_BUS_UNSOLICITED
;{
; ; ring buffer
; .queue:
; times HDA_UNSOL_QUEUE_SIZE*2 dd ?
; .rp dd ?
; .wp dd ?
;
; ; workqueue
; .work dd ?;struct work_struct work;
; .bus dd ? ;struct hda_bus ;bus
;};
; Helper for automatic ping configuration
AUTO_PIN_MIC equ 0
AUTO_PIN_FRONT_MIC equ 1
AUTO_PIN_LINE equ 2
AUTO_PIN_FRONT_LINE equ 3
AUTO_PIN_CD equ 4
AUTO_PIN_AUX equ 5
AUTO_PIN_LAST equ 6
AUTO_PIN_LINE_OUT equ 0
AUTO_PIN_SPEAKER_OUT equ 1
AUTO_PIN_HP_OUT equ 2
;extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
AUTO_CFG_MAX_OUTS equ 5
;struc AUTO_PIN_CFG
;{
; .line_outs dd ?
; ; sorted in the order of FrontSurrCLFESide
; .line_out_pins times AUTO_CFG_MAX_OUTS dw ?
; .speaker_outs dd ?
; .speaker_pins times AUTO_CFG_MAX_OUTS dw ?
; .hp_outs dd ?
; .line_out_type dd ? ; AUTO_PIN_XXX_OUT
; .hp_pins times AUTO_CFG_MAX_OUTS dw ?
; .input_pins times AUTO_PIN_LAST dw ?
; .dig_outs dd ?
; .dig_out_pins times 2 dd ?
; .dig_in_pin dw ?
; .mono_out_pin dw ?
; .dig_out_type times 2 dd ? ; HDA_PCM_TYPE_XXX
; .dig_in_type dd ? ; HDA_PCM_TYPE_XXX
;}
;#define get_defcfg_connect(cfg) \
; ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
;#define get_defcfg_association(cfg) \
; ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
;#define get_defcfg_location(cfg) \
; ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
;#define get_defcfg_sequence(cfg) \
; (cfg & AC_DEFCFG_SEQUENCE)
;#define get_defcfg_device(cfg) \
; ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
; amp values
;AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
;AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
AMP_OUT_MUTE equ 0xb080
AMP_OUT_UNMUTE equ 0xb000
AMP_OUT_ZERO equ 0xb000
; pinctl values
PIN_IN equ (AC_PINCTL_IN_EN)
PIN_VREFHIZ equ (AC_PINCTL_IN_EN or AC_PINCTL_VREF_HIZ)
PIN_VREF50 equ (AC_PINCTL_IN_EN or AC_PINCTL_VREF_50)
PIN_VREFGRD equ (AC_PINCTL_IN_EN or AC_PINCTL_VREF_GRD)
PIN_VREF80 equ (AC_PINCTL_IN_EN or AC_PINCTL_VREF_80)
PIN_VREF100 equ (AC_PINCTL_IN_EN or AC_PINCTL_VREF_100)
PIN_OUT equ (AC_PINCTL_OUT_EN)
PIN_HP equ (AC_PINCTL_OUT_EN or AC_PINCTL_HP_EN)
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
movzx ebx, [codec.start_nid]
movzx ecx, [codec.num_nodes]
mov edx, [nid]
cmp edx, ebx
jl .out
add ecx, ebx
cmp edx, ecx
jge .out
sub edx, ebx
shl edx, 2
add edx, [codec.wcaps]
mov eax, [edx]
.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
shr eax, AC_WCAP_TYPE_SHIFT
ret
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
shl eax, 1
or eax, 1
inc eax
ret
endp
;Asper ]

View File

@ -0,0 +1,89 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 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,\
SysMsgBoardChar,\
GetCurrentTask,\
LoadFile,\
SendEvent,\
SetMouseData,\
Sleep,\
GetTimerTicks,\
\
strncat,\
strncpy,\
strncmp,\
strnlen,\
strchr,\
strrchr,\
\
LFBAddress

View File

@ -0,0 +1,268 @@
; 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

@ -0,0 +1,936 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Universal Interface for Intel High Definition Audio Codec ;
; ;
; Generic widget tree parser ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; widget node for parsing
struc HDA_GNODE
{
.nid dw ? ;NID of this widget
.nconns dw ? ;number of input connections
.conn_list dd ?
.slist dw ? ;temporary list
dw ?
.wid_caps dd ? ;widget capabilities
.type db ? ;widget type
.pin_ctl db ? ;pin controls
.checked db ? ;the flag indicates that the node is already parsed
.pin_caps dd ? ;pin widget capabilities
.def_cfg dd ? ;default configuration
.amp_out_caps dd ? ;AMP out capabilities
.amp_in_caps dd ? ;AMP in capabilities
.next dd ? ; struct list_head list
.sizeof:
}
virtual at 0
HDA_GNODE HDA_GNODE
end virtual
struc HDA_GSPEC
{
.dac_node dd ? ;DAC node
dd ?
.out_pin_node dd ? ;Output pin (Line-Out) node
dd ?
.def_amp_in_caps dd ?
.def_amp_out_caps dd ?
; .pcm_rec dd ? ;PCM information
.nid_list dd 0 ;list of widgets
}
struc VOLUME_CTL
{
.out_amp_node dd 0 ;Asper+ : To get/set volume
.num_steps db ? ; num_steps=NumSteps+1
.step_size db ? ; step_size=StepSize+1
.maxDb dd ? ; Max volume in Db. maxDb=(num_steps*step_size/4*100)
}
; retrieve the default device type from the default config value
proc defcfg_type stdcall, node:dword
push edx
mov edx, [node]
mov eax, [edx + HDA_GNODE.def_cfg]
and eax, AC_DEFCFG_DEVICE
shr eax, AC_DEFCFG_DEVICE_SHIFT
pop edx
ret
endp
proc defcfg_location stdcall, node:dword
push edx
mov edx, [node]
mov eax, [edx + HDA_GNODE.def_cfg]
and eax, AC_DEFCFG_LOCATION
shr eax, AC_DEFCFG_LOCATION_SHIFT
pop edx
ret
endp
proc defcfg_port_conn stdcall, node:dword
push edx
mov edx, [node]
mov eax, [edx + HDA_GNODE.def_cfg]
and eax, AC_DEFCFG_PORT_CONN
shr eax, AC_DEFCFG_PORT_CONN_SHIFT
pop edx
ret
endp
proc defcfg_color stdcall, node:dword
push edx
mov edx, [node]
mov eax, [edx + HDA_GNODE.def_cfg]
and eax, AC_DEFCFG_COLOR
shr eax, AC_DEFCFG_COLOR_SHIFT
pop edx
ret
endp
; destructor
proc snd_hda_generic_free
push eax ebx edx edi
; free all widgets
mov ebx, [spec.nid_list] ; ebx = 1st node address
test ebx, ebx
jz .out
mov edx, [ebx + HDA_GNODE.next] ;edx = 2nd node address
.next:
test edx, edx
jz .free_head
mov eax, [edx + HDA_GNODE.conn_list]
lea edi, [edx + HDA_GNODE.slist]
cmp eax, edi
je @f
pusha
call Kfree ;free conn_list
popa
@@:
mov eax, edx
mov edx, [edx + HDA_GNODE.next]
pusha
call Kfree ;free node
popa
jmp .next
.free_head:
mov eax, [spec.nid_list]
pusha
call Kfree ;free the very 1st node in the list
popa
mov [spec.nid_list], 0
.out:
pop edi edx ebx eax
ret
endp
; add a new widget node and read its attributes
proc add_new_node stdcall, nid:dword
push ebx ecx edx edi esi
mov eax, HDA_GNODE.sizeof
call Kmalloc
test eax, eax
jz .err_out ; Not enough memory
mov edx, eax
;Asper+ [
mov edi, edx
xor eax, eax
mov ecx, HDA_GNODE.sizeof
rep stosb
;Asper+ ]
mov eax, [nid]
mov word [edx + HDA_GNODE.nid], ax
stdcall get_wcaps, eax
mov [edx + HDA_GNODE.wid_caps], eax
mov ebx, eax
stdcall get_wcaps_type, eax
mov byte [edx + HDA_GNODE.type], al
mov eax, HDA_MAX_CONNECTIONS*2 ;HDA_MAX_CONNECTIONS * sizeof(word)
push ebx ecx edx
call Kmalloc ;malloc temporary conn_list
pop edx ecx ebx
mov edi, eax
test ebx, AC_WCAP_CONN_LIST
jz .no_conn_list
stdcall snd_hda_get_connections, [nid], edi, HDA_MAX_CONNECTIONS
mov ecx, eax
cmp ecx, 0
jge @f
mov eax, edx
pusha
call Kfree ;free node
popa
mov eax, ecx
jmp .out
.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
pop edi edx ecx ebx
shr ecx, 1
test eax, eax
jnz @f
mov eax, edi
pusha
call Kfree ;free temporary conn_list
popa
jmp .err_out
@@:
mov [edx + HDA_GNODE.conn_list], eax
.set_conn_list:
mov [edx + HDA_GNODE.nconns], cx
push edi
mov esi, edi
mov edi, eax
rep movsw
pop edi
mov al, byte [edx + HDA_GNODE.type]
test al, AC_WID_PIN
jz @f
;Asper+ [
cmp al, AC_WID_VENDOR
je @f
;Asper+ ]
stdcall read_pin_cap, [nid]
mov [edx + HDA_GNODE.pin_caps], eax
stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0
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
jz .no_out_amp
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:
;;Asper+: Beeper [
; pusha
; mov bl, byte [edx + HDA_GNODE.type]
; cmp bl, AC_WID_BEEP
; jne .not_beeper
;
; mov ebx, [nid]
; mov [codec.beeper_nid], bx
;
; test eax, eax
; jz .no_beeper_amp
; ;set beep amplifier here
; stdcall unmute_output, edx
; .no_beeper_amp:
; ;try to beep here
; stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_BEEP_CONTROL, 0 ;eax
; if DEBUG
; push eax esi
; mov esi, msgBeeperNid
; call SysMsgBoardStr
; push eax
; mov eax, [nid]
; stdcall fdword2str, 2
; call SysMsgBoardStr
;
; mov esi, msgBeeperValue
; call SysMsgBoardStr
; pop eax
; stdcall fdword2str, 2
; call SysMsgBoardStr
;
; mov esi, msgBeepNow
; call SysMsgBoardStr
; pop esi eax
; end if
; mov ecx, 256*1
; .next_tone:
; dec ecx
; movzx ebx, [esi + HDA_GNODE.nid]
; stdcall snd_hda_codec_write, [nid], 0, AC_VERB_SET_BEEP_CONTROL, ecx
; ;mov eax, 0x8000
; ;stdcall StallExec
; test ecx, ecx
; jnz .next_tone
; .end_beep:
; stdcall snd_hda_codec_read, [nid], 0, AC_VERB_GET_BEEP_CONTROL, 0 ;eax
; if DEBUG
; ;push eax esi
; mov esi, msgBeeperValue
; call SysMsgBoardStr
; stdcall fdword2str, 2
; call SysMsgBoardStr
; ;pop esi eax
; end if
; .not_beeper:
; popa
;;Asper+: Beeper ]
xor eax, eax
test ebx, AC_WCAP_IN_AMP
jz .no_in_amp
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:
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:
cmp [esi + HDA_GNODE.type], AC_WID_PIN
jne @f
cmp [edx + HDA_GNODE.type], AC_WID_PIN
je .pin
mov edi, [spec.nid_list]
cmp [edi + HDA_GNODE.type], AC_WID_PIN
jne .not_pin
mov [edx + HDA_GNODE.next], edi
.head: ;CleverMouse+
mov [spec.nid_list], edx
pop edi
jmp .out
.pin:
movzx edi, byte [esi + HDA_GNODE.def_cfg]
cmp edi, ebx
jle @f
.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:
mov [esi + HDA_GNODE.next], edx
pop edi
;Asper+ ]
.out:
mov eax, edi
pusha
call Kfree ;free temporary conn_list
popa
xor eax, eax
pop esi edi edx ecx ebx
ret
.err_out:
mov eax, edx
pusha
call Kfree ;free node
popa
xor eax, eax
dec eax
pop esi edi edx ecx ebx
ret
endp
; build the AFG subtree
proc build_afg_tree
push ebx ecx edx
mov ebx, [codec.afg]
snd_hda_param_read ebx, AC_PAR_AMP_OUT_CAP
mov [spec.def_amp_out_caps], eax
snd_hda_param_read ebx, AC_PAR_AMP_IN_CAP
mov [spec.def_amp_in_caps], eax
stdcall snd_hda_get_sub_nodes, ebx
mov ecx, eax
and ecx, 0xFFFF ;ecx = nodes number
mov edx, eax
shr edx, 16 ;eax = address of the first nid
test edx, edx
jz @f
cmp ecx, 0
jge .nid_ok
@@:
if FDEBUG
push esi
mov esi, emsgInvalidAFGSubtree
call SysMsgBoardStr
pop esi
end if
xor eax, eax
dec eax
jmp .out
.nid_ok:
; parse all nodes belonging to the AFG
.next_node:
test ecx, ecx
jz .build_done
stdcall add_new_node, edx
test eax, eax
jnz .out
inc edx
dec ecx
jmp .next_node
.build_done:
xor eax, eax
.out:
pop edx ecx ebx
ret
endp
; look for the node record for the given NID
proc hda_get_node stdcall, nid:dword
push ebx edx esi
movzx ebx, word [nid]
mov esi, [spec.nid_list]
test esi, esi
jz .out
.next_node:
mov edx, [esi + HDA_GNODE.next]
test edx, edx ;Asper+
jz .not_found ;Asper+
mov ax, word [esi + HDA_GNODE.nid]
cmp ax, bx
je .out
mov esi, edx
jmp .next_node
.not_found: ;Asper+
xor esi, esi
.out:
mov eax, esi
pop esi edx ebx
ret
endp
;Asper+[
proc set_eapd stdcall, node:dword ;nid:dword, on:dword
push eax ebx esi
mov esi, [node]
cmp [esi + HDA_GNODE.type], AC_WID_PIN
jne .out
; eapd capable?
test [esi + HDA_GNODE.pin_caps], AC_PINCAP_EAPD
jz .out
;stdcall snd_hda_codec_read, ebx, 0, AC_VERB_GET_EAPD_BTLENABLE, AC_EAPDBTL_EAPD
;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
push eax esi
mov esi, msgEnableEAPD
call SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 3
call SysMsgBoardStr
pop esi eax
end if
.out:
pop esi ebx eax
ret
endp
;Asper+]
; 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
push esi
mov esi, msgUnmuteOut
call SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
pop esi
end if
stdcall set_eapd, esi ;Asper+: set EAPD if exist
mov ebx, eax
mov eax, [esi + HDA_GNODE.amp_out_caps]
mov ecx, eax
and eax, AC_AMPCAP_NUM_STEPS
shr eax, AC_AMPCAP_NUM_STEPS_SHIFT
stdcall snd_hda_codec_amp_stereo, ebx, HDA_OUTPUT, 0, 0xFF, eax
and ecx, AC_AMPCAP_STEP_SIZE
shr ecx, AC_AMPCAP_STEP_SIZE_SHIFT
test al, al
jz .out
if DEBUG
push eax esi
mov esi, msgAmpVal
call SysMsgBoardStr
stdcall fdword2str, 1
call SysMsgBoardStr
mov esi, strSemicolon
call SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 3
call SysMsgBoardStr
pop esi eax
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
mov [volume.maxDb], eax
.out:
xor eax, eax
pop esi edx ecx ebx
ret
endp
; unmute (and set max vol) the input amplifier
proc unmute_input stdcall, node:dword, index:dword
push ecx edx esi
test [esi + HDA_GNODE.wid_caps], AC_WCAP_IN_AMP
jz .out
and [index], 0xF ;Asper+ : Ranger
mov esi, [node]
movzx eax, word [esi + HDA_GNODE.nid]
if DEBUG
push eax esi
mov esi, msgUnmuteIn
call SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
mov esi, msgIdx
call SysMsgBoardStr
mov eax, [index]
stdcall fdword2str, 3
call SysMsgBoardStr
pop esi eax
end if
mov edx, [esi + HDA_GNODE.amp_in_caps]
mov ecx, edx
and edx, AC_AMPCAP_NUM_STEPS
shr edx, AC_AMPCAP_NUM_STEPS_SHIFT
stdcall snd_hda_codec_amp_stereo, eax, HDA_INPUT, [index], 0xFF, edx
.out:
xor eax, eax
pop esi edx ecx
ret
endp
; select the input connection of the given node.
proc select_input_connection stdcall, node:dword, index:dword
push ebx esi
mov esi, [node]
movzx eax, word [esi + HDA_GNODE.nid]
mov ebx, [index]
if DEBUG
mov esi, msgConnect
call SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
mov esi, msgIdx
call SysMsgBoardStr
push eax
mov eax, ebx
stdcall fdword2str, 3
call SysMsgBoardStr
pop eax
end if
stdcall snd_hda_codec_write, eax, 0, AC_VERB_SET_CONNECT_SEL, ebx
pop esi ebx
ret
endp
; clear checked flag of each node in the node list
proc clear_check_flags
push eax esi
mov esi, [spec.nid_list]
test esi, esi
jz .out
.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:
pop esi eax
ret
endp
;
; parse the output path recursively until reach to an audio output widget
;
; returns 0 if not found, 1 if found, or a negative error code.
;
proc parse_output_path stdcall, node:dword, dac_idx:dword
push ebx ecx edx esi
mov esi, [node]
mov al, byte [esi + HDA_GNODE.checked]
test al, al
jnz .ret_zero
mov byte [esi + HDA_GNODE.checked], 1
mov al, byte [esi + HDA_GNODE.type]
cmp al, AC_WID_AUD_OUT
jne .not_wid_aud_out
movzx eax, word [esi + HDA_GNODE.nid]
mov ebx, [esi + HDA_GNODE.wid_caps]
test ebx, AC_WCAP_DIGITAL
jz @f
if DEBUG
push esi
mov esi, msgSkipDigitalOutNode
call SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
pop esi
end if
jmp .ret_zero
@@:
if DEBUG
push eax esi
mov esi, msgAudOutFound
call SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
pop esi eax
end if
push eax
stdcall unmute_output, esi ;Asper+
pop eax
mov ecx, [dac_idx]
shl ecx, 2
push eax
mov eax, [spec.dac_node+ecx]
test eax, eax
pop eax
jz @f
; already DAC node is assigned, just unmute & connect
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:
movzx ebx, [esi + HDA_GNODE.nconns]
xor ecx, ecx
mov edx, [esi + HDA_GNODE.conn_list]
test ebx, ebx
jz .ret_zero
.next_node:
stdcall hda_get_node, [edx]
test eax, eax
jz .continue
stdcall parse_output_path, eax, [dac_idx]
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:
add edx, 2
inc ecx
cmp ecx, ebx
jl .next_node
.ret_zero:
xor eax, eax
pop esi edx ecx ebx
ret
.ret_one:
xor eax, eax
inc eax
.ret: ;Asper+
pop esi edx ecx ebx
ret
endp
; Look for the output PIN widget with the given jack type
; and parse the output path to that PIN.
;
; Returns the PIN node when the path to DAC is established.
proc parse_output_jack stdcall, jack_type:dword
push edx esi
mov esi, [spec.nid_list]
test esi, esi
jz .ret_zero
.next_pin:
cmp [esi + HDA_GNODE.type], AC_WID_PIN
jne .continue
; output capable?
mov eax, [esi + HDA_GNODE.pin_caps]
test eax, AC_PINCAP_OUT
jz .continue
stdcall defcfg_port_conn, esi
cmp eax, AC_JACK_PORT_NONE
je .continue ;unconnected
mov edx, [jack_type]
cmp edx, 0
jl @f
stdcall defcfg_type, esi
cmp edx, eax
jne .continue
test [esi + HDA_GNODE.wid_caps], AC_WCAP_DIGITAL
jnz .continue ; skip SPDIF
@@:
; output as default?
if DEBUG
pusha
; push esi
; mov esi, msgPin_Nid
; call SysMsgBoardStr
; pop esi
movzx eax, [esi + HDA_GNODE.nid]
movzx ebx, [esi + HDA_GNODE.pin_ctl]
mov ecx, [esi + HDA_GNODE.pin_caps]
mov edx, [esi + HDA_GNODE.def_cfg]
mov edi, [esi + HDA_GNODE.amp_out_caps]
mov esi, msgPin_Nid
call SysMsgBoardStr
stdcall fdword2str, 3
call SysMsgBoardStr
mov esi, msgPin_Ctl
call SysMsgBoardStr
mov eax, ebx
stdcall fdword2str, 2
call SysMsgBoardStr
mov esi, msgPin_Caps
call SysMsgBoardStr
mov eax, ecx
stdcall fdword2str, 2
call SysMsgBoardStr
mov esi, msgDef_Cfg
call SysMsgBoardStr
mov eax, edx
stdcall fdword2str, 2
call SysMsgBoardStr
mov esi, msgAmp_Out_Caps
call SysMsgBoardStr
mov eax, edi
stdcall fdword2str, 2
call SysMsgBoardStr
popa
end if
; test [esi + HDA_GNODE.pin_ctl], AC_PINCTL_OUT_EN
; jz .continue
stdcall clear_check_flags
stdcall parse_output_path, esi, 0
test eax, eax
jnz @f
mov edx, [spec.out_pin_node]
test edx, edx
jz @f
stdcall clear_check_flags
stdcall parse_output_path, esi, 1
@@:
cmp eax, 0
jle .l1
; unmute the PIN output
stdcall unmute_output, esi
; set PIN-Out enable
xor edx, edx
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:
mov edx, [esi + HDA_GNODE.next]
test edx, edx
jz .ret_zero
mov esi, edx
jmp .next_pin
.ret_zero:
xor eax, eax
.out:
pop esi edx
ret
endp
; parse outputs
proc parse_output
push edx
; Look for the output PIN widget
;
; first, look for the line-out pin
stdcall parse_output_jack, AC_JACK_LINE_OUT
test eax, eax
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:
; look for the HP-out pin
stdcall parse_output_jack, AC_JACK_HP_OUT
test eax, eax
jz .l2
mov edx, [spec.out_pin_node]
test edx, edx
jnz @f
mov [spec.out_pin_node], eax
jmp .l2
@@:
mov [spec.out_pin_node+4], eax
.l2:
mov edx, [spec.out_pin_node]
test edx, edx
jnz @f
; no line-out or HP pins found,
; then choose for the first output pin
stdcall parse_output_jack, -1
mov [spec.out_pin_node], eax
test eax, eax
jnz @f
if DEBUG
push esi
mov esi, emsgNoProperOutputPathFound
call SysMsgBoardStr
pop esi
end if
@@:
pop edx
xor eax, eax
ret
endp
;(...) Skip functions for the input (capture is not supported).
; the generic parser
proc snd_hda_parse_generic_codec
mov eax, [codec.afg]
test eax, eax
jz .out
stdcall build_afg_tree
cmp eax, 0
jl .error
stdcall parse_output
xor eax, eax
.out:
ret
.error:
stdcall snd_hda_generic_free
ret
endp
; some data
spec HDA_GSPEC
volume VOLUME_CTL

File diff suppressed because it is too large Load Diff