1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4 ;; Distributed under terms of the GNU General Public License ;;
6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 format PE DLL native
0.05
13 API_VERSION
equ 0x01000100
21 VALID_IRQ
equ 1101111111111110b
32 CTRL_VT82C686
equ 0x3058
33 CTRL_VT8233_5
equ 0x3059
36 CODEC_MASTER_VOL_REG
equ 0x02
37 CODEC_AUX_VOL
equ 0x04 ;
38 CODEC_PCM_OUT_REG
equ 0x18 ; PCM output volume
39 CODEC_EXT_AUDIO_REG
equ 0x28 ; extended audio
40 CODEC_EXT_AUDIO_CTRL_REG
equ 0x2a ; extended audio control
41 CODEC_PCM_FRONT_DACRATE_REG
equ 0x2c ; PCM out sample rate
42 CODEC_PCM_SURND_DACRATE_REG
equ 0x2e ; surround sound sample rate
43 CODEC_PCM_LFE_DACRATE_REG
equ 0x30 ; LFE sample rate
46 ;VIA host controller registers set
48 VIA_REG_OFFSET_STATUS
equ 0x00 ;; byte - channel status
49 VIA_REG_STAT_ACTIVE
equ 0x80 ;; RO
50 VIA_REG_STAT_PAUSED
equ 0x40 ;; RO
51 VIA_REG_STAT_TRIGGER_QUEUED
equ 0x08 ;; RO
52 VIA_REG_STAT_STOPPED
equ 0x04 ;; RWC
53 VIA_REG_STAT_EOL
equ 0x02 ;; RWC
54 VIA_REG_STAT_FLAG
equ 0x01 ;; RWC
55 VIA_REG_OFFSET_CONTROL
equ 0x01 ;; byte - channel control
56 VIA_REG_CTRL_START
equ 0x80 ;; WO
57 VIA_REG_CTRL_TERMINATE
equ 0x40 ;; WO
58 VIA_REG_CTRL_AUTOSTART
equ 0x20
59 VIA_REG_CTRL_PAUSE
equ 0x08 ;; RW
60 VIA_REG_CTRL_INT_STOP
equ 0x04
61 VIA_REG_CTRL_INT_EOL
equ 0x02
62 VIA_REG_CTRL_INT_FLAG
equ 0x01
63 VIA_REG_CTRL_RESET
equ 0x01 ;; RW - probably reset? undocumented
64 VIA_REG_CTRL_INT
equ (VIA_REG_CTRL_INT_FLAG
or \
65 VIA_REG_CTRL_INT_EOL
or \
66 VIA_REG_CTRL_AUTOSTART
)
67 VIA_REG_OFFSET_TYPE
equ 0x02 ;; byte - channel type (686 only)
68 VIA_REG_TYPE_AUTOSTART
equ 0x80 ;; RW - autostart at EOL
69 VIA_REG_TYPE_16BIT
equ 0x20 ;; RW
70 VIA_REG_TYPE_STEREO
equ 0x10 ;; RW
71 VIA_REG_TYPE_INT_LLINE
equ 0x00
72 VIA_REG_TYPE_INT_LSAMPLE
equ 0x04
73 VIA_REG_TYPE_INT_LESSONE
equ 0x08
74 VIA_REG_TYPE_INT_MASK
equ 0x0c
75 VIA_REG_TYPE_INT_EOL
equ 0x02
76 VIA_REG_TYPE_INT_FLAG
equ 0x01
77 VIA_REG_OFFSET_TABLE_PTR
equ 0x04 ;; dword - channel table pointer
78 VIA_REG_OFFSET_CURR_PTR
equ 0x04 ;; dword - channel current pointer
79 VIA_REG_OFFSET_STOP_IDX
equ 0x08 ;; dword - stop index, channel type, sample rate
80 VIA8233_REG_TYPE_16BIT
equ 0x00200000 ;; RW
81 VIA8233_REG_TYPE_STEREO
equ 0x00100000 ;; RW
82 VIA_REG_OFFSET_CURR_COUNT
equ 0x0c ;; dword - channel current count (24 bit)
83 VIA_REG_OFFSET_CURR_INDEX
equ 0x0f ;; byte - channel current index (for via8233 only)
86 VIADEV_PLAYBACK
equ 0x00
87 VIADEV_CAPTURE
equ 0x10
91 VIA_REG_AC97
equ 0x80 ; dword
92 VIA_REG_AC97_CODEC_ID_MASK
equ 0xC0000000 ;(3<<30)
93 VIA_REG_AC97_CODEC_ID_SHIFT
equ 30
94 VIA_REG_AC97_CODEC_ID_PRIMARY
equ 0x00
95 VIA_REG_AC97_CODEC_ID_SECONDARY
equ 0x01
96 VIA_REG_AC97_SECONDARY_VALID
equ 0x08000000 ;(1<<27)
97 VIA_REG_AC97_PRIMARY_VALID
equ 0x02000000 ;(1<<25)
98 VIA_REG_AC97_BUSY
equ 0x01000000 ;(1<<24)
99 VIA_REG_AC97_READ
equ 0x00800000 ;(1<<23)
100 VIA_REG_AC97_CMD_SHIFT
equ 16
101 VIA_REG_AC97_CMD_MASK
equ 0x7E
102 VIA_REG_AC97_DATA_SHIFT
equ 0
103 VIA_REG_AC97_DATA_MASK
equ 0xFFFF
105 VIA_REG_SGD_SHADOW
equ 0x84 ; dword
107 ;; via8233-specific registers ;;
108 VIA_REG_OFS_PLAYBACK_VOLUME_L
equ 0x02 ;; byte
109 VIA_REG_OFS_PLAYBACK_VOLUME_R
equ 0x03 ;; byte
110 VIA_REG_OFS_MULTPLAY_FORMAT
equ 0x02 ;; byte - format and channels
111 VIA_REG_MULTPLAY_FMT_8BIT
equ 0x00
112 VIA_REG_MULTPLAY_FMT_16BIT
equ 0x80
113 VIA_REG_MULTPLAY_FMT_CH_MASK
equ 0x70 ;; # channels << 4 (valid = 1,2,4,6)
114 VIA_REG_OFS_CAPTURE_FIFO
equ 0x02 ;; byte - bit 6 = fifo enable
115 VIA_REG_CAPTURE_FIFO_ENABLE
equ 0x40
117 VIA_DXS_MAX_VOLUME
equ 31 ;; max. volume (attenuation) of reg 0x32/33
119 VIA_TBL_BIT_FLAG
equ 0x40000000
120 VIA_TBL_BIT_EOL
equ 0x80000000
123 VIA_ACLINK_STAT
equ 0x40
125 VIA_ACLINK_C00_READY
equ 0x01 ; primary codec ready
126 VIA_ACLINK_CTRL
equ 0x41
127 VIA_ACLINK_CTRL_ENABLE
equ 0x80 ; 0: disable, 1: enable
128 VIA_ACLINK_CTRL_RESET
equ 0x40 ; 0: assert, 1: de-assert
129 VIA_ACLINK_CTRL_SYNC
equ 0x20 ; 0: release SYNC, 1: force SYNC hi
130 VIA_ACLINK_CTRL_SDO
equ 0x10 ; 0: release SDO, 1: force SDO hi
131 VIA_ACLINK_CTRL_VRA
equ 0x08 ; 0: disable VRA, 1: enable VRA
132 VIA_ACLINK_CTRL_PCM
equ 0x04 ; 0: disable PCM, 1: enable PCM
133 VIA_ACLINK_CTRL_FM
equ 0x02 ; via686 only
134 VIA_ACLINK_CTRL_SB
equ 0x01 ; via686 only
135 VIA_ACLINK_CTRL_INIT
equ (VIA_ACLINK_CTRL_ENABLE
or \
136 VIA_ACLINK_CTRL_RESET
or \
137 VIA_ACLINK_CTRL_PCM
or \
139 VIA_FUNC_ENABLE
equ 0x42
140 VIA_FUNC_MIDI_PNP
equ 0x80 ; FIXME: it's 0x40 in the datasheet!
141 VIA_FUNC_MIDI_IRQMASK
equ 0x40 ; FIXME: not documented!
142 VIA_FUNC_RX2C_WRITE
equ 0x20
143 VIA_FUNC_SB_FIFO_EMPTY
equ 0x10
144 VIA_FUNC_ENABLE_GAME
equ 0x08
145 VIA_FUNC_ENABLE_FM
equ 0x04
146 VIA_FUNC_ENABLE_MIDI
equ 0x02
147 VIA_FUNC_ENABLE_SB
equ 0x01
148 VIA_PNP_CONTROL
equ 0x43
149 VIA_FM_NMI_CTRL
equ 0x48
150 VIA8233_VOLCHG_CTRL
equ 0x48
151 VIA8233_SPDIF_CTRL
equ 0x49
152 VIA8233_SPDIF_DX3
equ 0x08
153 VIA8233_SPDIF_SLOT_MASK
equ 0x03
154 VIA8233_SPDIF_SLOT_1011
equ 0x00
155 VIA8233_SPDIF_SLOT_34
equ 0x01
156 VIA8233_SPDIF_SLOT_78
equ 0x02
157 VIA8233_SPDIF_SLOT_69
equ 0x03
167 DEV_SET_MASTERVOL
equ 6
168 DEV_GET_MASTERVOL
equ 7
172 struc AC_CNTRL
;AC controller base class
189 .vendor_ids dd ? ;vendor id string
190 .ctrl_ids dd ? ;hub id string
212 struc CODEC
;Audio Chip base class
218 .ac_vendor_ids dd ? ;ac vendor id string
219 .chip_ids dd ? ;chip model string
224 .regs dw ? ; codec registers
225 .reg_master_vol dw ? ;0x02
226 .reg_aux_out_vol dw ? ;0x04
227 .reg_mone_vol dw ? ;0x06
228 .reg_master_tone dw ? ;0x08
229 .reg_beep_vol dw ? ;0x0A
230 .reg_phone_vol dw ? ;0x0C
231 .reg_mic_vol dw ? ;0x0E
232 .reg_line_in_vol dw ? ;0x10
233 .reg_cd_vol dw ? ;0x12
234 .reg_video_vol dw ? ;0x14
235 .reg_aux_in_vol dw ? ;0x16
236 .reg_pcm_out_vol dw ? ;0x18
237 .reg_rec_select dw ? ;0x1A
238 .reg_rec_gain dw ? ;0x1C
239 .reg_rec_gain_mic dw ? ;0x1E
241 .reg_3d_ctrl dw ? ;0X22
243 .reg_powerdown dw ? ;0x26
244 .reg_ext_audio dw ? ;0x28
245 .reg_ext_st dw ? ;0x2a
246 .reg_pcm_front_rate dw ? ;0x2c
247 .reg_pcm_surr_rate dw ? ;0x2e
248 .reg_lfe_rate dw ? ;0x30
249 .reg_pcm_in_rate dw ? ;0x32
251 .reg_cent_lfe_vol dw ? ;0x36
252 .reg_surr_vol dw ? ;0x38
253 .reg_spdif_ctrl dw ? ;0x3A
272 .reg_page_0 dw ? ;0x60
273 .reg_page_1 dw ? ;0x62
274 .reg_page_2 dw ? ;0x64
275 .reg_page_3 dw ? ;0x66
276 .reg_page_4 dw ? ;0x68
277 .reg_page_5 dw ? ;0x6A
278 .reg_page_6 dw ? ;0x6C
279 .reg_page_7 dw ? ;0x6E
286 .reg_vendor_id_1 dw ? ;0x7C
287 .reg_vendor_id_2 dw ? ;0x7E
306 EVENT_NOTIFY
equ 0x00000200
308 section '.flat' code readable writable executable
309 include '../struct.inc'
310 include '../macros.inc'
311 include '../proc32.inc'
312 include '../peimport.inc'
314 proc START c
, state:dword, cmdline:dword
321 invoke SysMsgBoardStr
324 call detect_controller
329 mov esi, [ctrl.vendor_ids
]
330 invoke SysMsgBoardStr
331 mov esi, [ctrl.ctrl_ids
]
332 invoke SysMsgBoardStr
346 invoke SysMsgBoardStr
347 call create_primary_buff
349 invoke SysMsgBoardStr
355 mov ebx, [ctrl.int_line
]
361 bts ax, bx ;mask old line
363 bts ax, IRQ_LINE
;mask new ine
368 invoke PciWrite8
, 0, 0xF8, 0x61, IRQ_LINE
;remap IRQ
370 mov dx, 0x4d0 ;8259 ELCR1
373 out dx, al ;set level-triggered mode
374 mov [ctrl.int_line
], IRQ_LINE
377 invoke SysMsgBoardStr
381 mov ebx, [ctrl.int_line
]
386 invoke AttachIntHandler
, ebx, ac97_irq_VIA
, 0
388 invoke RegService
, sz_sound_srv
, service_proc
393 invoke SysMsgBoardStr
398 invoke SysMsgBoardStr
407 handle
equ IOCTL.handle
408 io_code
equ IOCTL.io_code
409 input
equ IOCTL.input
410 inp_size
equ IOCTL.inp_size
411 output
equ IOCTL.output
412 out_size
equ IOCTL.out_size
415 proc service_proc stdcall
, ioctl:dword
418 mov eax, [edi+io_code
]
420 cmp eax, SRV_GETVERSION
422 mov eax, [edi+output
]
423 cmp [edi+out_size
], 4
426 mov [eax], dword API_VERSION
434 invoke SysMsgBoardStr
443 invoke SysMsgBoardStr
448 cmp eax, DEV_CALLBACK
451 stdcall set_callback
, [ebx]
454 cmp eax, DEV_SET_MASTERVOL
458 call set_master_vol
;eax= vol
461 cmp eax, DEV_GET_MASTERVOL
463 mov ebx, [edi+output
]
464 stdcall get_master_vol
, ebx
467 cmp eax, DEV_GET_INFO
469 mov ebx, [edi+output
]
470 stdcall get_dev_info
, ebx
476 mov edx, VIADEV_PLAYBACK
+ VIA_REG_OFFSET_CURR_COUNT
477 call [ctrl.ctrl_read32
]
482 mov edx, [edi+output
]
506 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_STATUS
507 call [ctrl.ctrl_read8
]
508 test al, VIA_REG_STAT_ACTIVE
511 and al, VIA_REG_STAT_EOL
or VIA_REG_STAT_FLAG
or VIA_REG_STAT_STOPPED
512 mov byte [status
], al
514 mov ebx, dword [buff_list
]
515 cmp [ctrl.user_callback
], 0
517 stdcall
[ctrl.user_callback
], ebx
519 mov al, byte [status
] ;; ack ;;
520 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_STATUS
521 call [ctrl.ctrl_write8
]
528 proc create_primary_buff
530 invoke KernelAlloc
, 0x10000
531 mov [ctrl.buffer
], eax
539 mov eax, [ctrl.buffer
]
547 mov eax, [ctrl.buffer
]
563 stdcall channel_reset
, VIADEV_PLAYBACK
564 stdcall codec_check_ready
572 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_TABLE_PTR
573 call [ctrl.ctrl_write32
]
575 stdcall codec_check_ready
577 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFS_PLAYBACK_VOLUME_L
579 call [ctrl.ctrl_write8
]
581 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFS_PLAYBACK_VOLUME_R
583 call [ctrl.ctrl_write8
]
585 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_STOP_IDX
586 mov eax, VIA8233_REG_TYPE_16BIT
or VIA8233_REG_TYPE_STEREO
or 0xfffff or 0xff000000
587 mov [ctrl.lvi_reg
], 16 ;0xF;eax
588 call [ctrl.ctrl_write32
]
590 stdcall codec_check_ready
595 proc channel_reset
channel:dword
596 mov esi, dword [channel
]
598 add edx, VIA_REG_OFFSET_CONTROL
599 mov eax, VIA_REG_CTRL_PAUSE
or VIA_REG_CTRL_TERMINATE
or VIA_REG_CTRL_RESET
600 call [ctrl.ctrl_write8
]
603 add edx, VIA_REG_OFFSET_CONTROL
604 call [ctrl.ctrl_read8
]
606 mov eax, 50000 ; wait 50 ms
610 add edx, VIA_REG_OFFSET_CONTROL
612 call [ctrl.ctrl_write8
]
616 add edx, VIA_REG_OFFSET_STATUS
618 call [ctrl.ctrl_write8
]
620 ;outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */
621 ; mov edx, esi ;; for via686
622 ; add edx, VIA_REG_OFFSET_TYPE
624 ; call [ctrl.ctrl_write8]
626 ;; outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR));
628 ;add edx, VIA_REG_OFFSET_CURR_PTR
630 ;call [ctrl.ctrl_write8]
637 proc detect_controller
656 invoke PciRead32
, [bus
], [devfn
], dword 0
688 mov [ctrl.devfn
], ecx
692 mov [ctrl.vendor
], edx
694 mov [ctrl.dev_id
], eax
697 mov [ctrl.ctrl_ids
], ebx
699 mov [ctrl.ctrl_setup
], esi
703 mov [ctrl.vendor_ids
], msg_VIA
709 mov [ctrl.vendor_ids
], eax ;something wrong ?
716 invoke PciRead32
, [ctrl.bus
], [ctrl.devfn
], dword 4
719 mov [ctrl.pci_cmd
], eax
721 mov [ctrl.pci_stat
], ebx
724 invoke SysMsgBoardStr
726 invoke SysMsgBoardStr
729 invoke SysMsgBoardStr
730 mov eax, [ctrl.pci_stat
]
732 invoke SysMsgBoardStr
734 mov esi, msgCtrlIsaIo
735 invoke SysMsgBoardStr
736 invoke PciRead32
, [ctrl.bus
], [ctrl.devfn
], dword 0x10
738 invoke SysMsgBoardStr
741 mov [ctrl.ctrl_io_base
], eax
744 invoke PciRead32
, [ctrl.bus
], [ctrl.devfn
], dword 0x3C
747 mov [ctrl.int_line
], eax
749 ;stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE ;0x42
750 ;mov byte [old_legacy], al
752 ;stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_PNP_CONTROL ;0x43
753 ;mov byte [old_legacy_cfg], al
755 ;mov al, VIA_FUNC_ENABLE_SB or VIA_FUNC_ENABLE_FM
757 ;and al, byte [old_legacy]
759 ;stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE, eax ;0x42
760 ;mov byte [old_legacy], al
762 call [ctrl.ctrl_setup
]
770 mov [ctrl.codec_read16
], codec_io_r16
;virtual
771 mov [ctrl.codec_write16
], codec_io_w16
;virtual
773 mov [ctrl.ctrl_read8
], ctrl_io_r8
;virtual
774 mov [ctrl.ctrl_read16
], ctrl_io_r16
;virtual
775 mov [ctrl.ctrl_read32
], ctrl_io_r32
;virtual
777 mov [ctrl.ctrl_write8
], ctrl_io_w8
;virtual
778 mov [ctrl.ctrl_write16
], ctrl_io_w16
;virtual
779 mov [ctrl.ctrl_write32
], ctrl_io_w32
;virtual
791 invoke SysMsgBoardStr
792 invoke PciRead8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_CTRL
795 invoke SysMsgBoardStr
798 invoke SysMsgBoardStr
799 invoke PciRead8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_STAT
803 invoke SysMsgBoardStr
806 test eax, VIA_ACLINK_C00_READY
814 xor edx, edx ; ac_reg_0
815 call [ctrl.codec_write16
]
819 xor eax, eax ; timeout error
832 invoke PciWrite8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_CTRL
, \
833 VIA_ACLINK_CTRL_ENABLE
or VIA_ACLINK_CTRL_RESET
or VIA_ACLINK_CTRL_SYNC
834 mov eax, 100000 ; wait 100 ms
842 invoke SysMsgBoardStr
844 xor eax, eax ; timeout error
849 invoke SysMsgBoardStr
863 invoke PciWrite8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_CTRL
, dword 0
867 invoke SysMsgBoardStr
870 mov eax, 100000 ; wait 100 ms ;400000 ; wait 400 ms
873 ;; ACLink on, deassert ACLink reset, VSR, SGD data out
874 ;; note - FM data out has trouble with non VRA codecs !!
875 invoke PciWrite8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_CTRL
, dword VIA_ACLINK_CTRL_INIT
877 mov [counter
], 16 ; total 20*100 ms = 2s
879 invoke PciRead8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_STAT
880 test eax, VIA_ACLINK_C00_READY
883 mov eax, 100000 ; wait 100 ms
891 invoke SysMsgBoardStr
899 invoke SysMsgBoardStr
900 invoke PciRead8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_CTRL
902 invoke SysMsgBoardStr
905 invoke SysMsgBoardStr
906 invoke PciRead8
, [ctrl.bus
], [ctrl.devfn
], dword VIA_ACLINK_STAT
910 invoke SysMsgBoardStr
913 test eax, VIA_ACLINK_C00_READY
;CTRL_ST_CREADY
921 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_STOP_IDX
922 mov eax, VIA8233_REG_TYPE_16BIT
or VIA8233_REG_TYPE_STEREO
or 0xfffff or 0xff000000
923 mov [ctrl.lvi_reg
], 16
924 call [ctrl.ctrl_write32
]
926 mov eax, VIA_REG_CTRL_INT
927 or eax, VIA_REG_CTRL_START
928 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_CONTROL
929 call [ctrl.ctrl_write8
]
936 mov eax, VIA_REG_CTRL_INT
937 or eax, VIA_REG_CTRL_TERMINATE
938 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_CONTROL
939 call [ctrl.ctrl_write8
]
941 stdcall channel_reset
, VIADEV_PLAYBACK
946 proc get_dev_info stdcall
, p_info:dword
952 mov eax, [ctrl.int_line
]
953 mov ecx, [ctrl.ctrl_io_base
]
954 mov [CTRL_INFO.irq
], eax
955 mov [CTRL_INFO.ctrl_io_base
], ecx
958 ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR
959 ;call [ctrl.ctrl_read32]
960 mov [CTRL_INFO.codec_io_base
], eax
961 ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX
962 ;call [ctrl.ctrl_read32]
963 mov [CTRL_INFO.codec_mem_base
], eax
964 ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CURR_COUNT
965 ;call [ctrl.ctrl_read32]
966 mov [CTRL_INFO.ctrl_mem_base
], eax
968 mov eax, [codec.chip_id
]
969 mov [CTRL_INFO.codec_id
], eax
971 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_CONTROL
972 call [ctrl.ctrl_read8
]
974 mov [CTRL_INFO.glob_cntrl
], eax
976 mov edx, VIADEV_PLAYBACK
+VIA_REG_OFFSET_STATUS
977 call [ctrl.ctrl_read8
]
979 mov [CTRL_INFO.glob_sta
], eax
981 mov ebx, [ctrl.pci_cmd
]
982 mov [CTRL_INFO.pci_cmd
], ebx
987 proc set_callback stdcall
, handler:dword
989 mov [ctrl.user_callback
], eax
995 proc codec_check_ready stdcall
1000 mov [counter
], 1000 ; total 1000*1 ms = 1s
1002 call [ctrl.codec_read16
]
1003 test eax, VIA_REG_AC97_BUSY
1006 mov eax, 1000 ; wait 1 ms
1021 proc codec_valid stdcall
1022 stdcall codec_check_ready
1027 proc codec_read stdcall
, ac_reg:dword ; reg = edx, reval = eax
1032 ;Use only primary codec.
1035 shl eax, VIA_REG_AC97_CMD_SHIFT
1036 or eax, VIA_REG_AC97_PRIMARY_VALID
or VIA_REG_AC97_READ
1038 mov [counter
], 3 ; total 3*20 ms = 60ms
1041 call [ctrl.codec_write16
]
1043 mov eax, 20000 ; wait 20 ms
1056 mov eax, 25000 ; wait 25 ms
1059 call [ctrl.codec_read16
] ;change edx !!!
1064 mov esi, msgCInvalid
1065 invoke SysMsgBoardStr
1067 mov eax, -1 ; invalid codec error
1072 proc codec_write stdcall
, ac_reg:dword
1073 ;Use only primary codec.
1076 shl edx, VIA_REG_AC97_CMD_SHIFT
1078 shl eax, VIA_REG_AC97_DATA_SHIFT
1081 mov eax, VIA_REG_AC97_CODEC_ID_PRIMARY
;not VIA_REG_AC97_CODEC_ID_PRIMARY
1082 shl eax, VIA_REG_AC97_CODEC_ID_SHIFT
1087 call [ctrl.codec_write16
]
1088 mov [codec.regs
+esi], ax
1090 stdcall codec_check_ready
1098 invoke SysMsgBoardStr
1100 ;mov eax, -1 ; codec not ready error
1131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1132 ; CONTROLLER IO functions
1133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1136 proc codec_io_r16
;r32
1137 mov edx, [ctrl.ctrl_io_base
]
1138 add edx, VIA_REG_AC97
1144 proc codec_io_w16
;w32
1145 mov edx, [ctrl.ctrl_io_base
]
1146 add edx, VIA_REG_AC97
1153 add edx, [ctrl.ctrl_io_base
]
1160 add edx, [ctrl.ctrl_io_base
]
1167 add edx, [ctrl.ctrl_io_base
]
1174 add edx, [ctrl.ctrl_io_base
]
1181 add edx, [ctrl.ctrl_io_base
]
1188 add edx, [ctrl.ctrl_io_base
]
1203 mov bl, [ebx+hexletters
]
1210 hexletters
db '0123456789ABCDEF'
1211 hex_buff
db 8 dup
(0),13,10,0
1217 devices
dd (CTRL_VT82C686
shl 16)+VID_VIA
,msg_VT82C686
,set_VIA
1218 dd (CTRL_VT8233_5
shl 16)+VID_VIA
,msg_VT8233
,set_VIA
1222 msg_VT82C686
db 'VT82C686', 13,10, 0
1223 msg_VT8233
db 'VT8233', 13,10, 0
1224 msg_VIA
db 'VIA' , 13,10, 0
1226 szKernel
db 'KERNEL', 0
1227 sz_sound_srv
db 'SOUND',0
1229 msgInit
db 'detect hardware...',13,10,0
1230 msgFail
db 'device not found',13,10,0
1231 msgInvIRQ
db 'IRQ line not assigned or invalid', 13,10, 0
1232 msgPlay
db 'start play', 13,10,0
1233 msgStop
db 'stop play', 13,10,0
1234 ;msgIRQ db 'AC97 IRQ', 13,10,0
1235 ;msgInitCtrl db 'init controller',13,10,0
1236 ;msgInitCodec db 'init codec',13,10,0
1237 msgPrimBuff
db 'create primary buffer ...',0
1238 msgDone
db 'done',13,10,0
1239 msgRemap
db 'Remap IRQ',13,10,0
1240 ;msgReg db 'set service handler',13,10,0
1241 ;msgOk db 'service installed',13,10,0
1242 msgCold
db 'cold reset',13,10,0
1243 ;msgWarm db 'warm reset',13,10,0
1244 ;msgWRFail db 'warm reset failed',13,10,0
1245 msgCRFail
db 'cold reset failed',13,10,0
1246 msgCFail
db 'codec not ready',13,10,0
1247 msgCInvalid
db 'codec is not valid',13,10,0 ;Asper
1248 msgResetOk
db 'reset complete',13,10,0
1249 msgStatus
db 'global status ',0
1250 msgControl
db 'global control ',0
1251 msgPciCmd
db 'PCI command ',0
1252 msgPciStat
db 'PCI status ',0
1253 msgCtrlIsaIo
db 'controller io base ',0
1254 ;msgMixIsaIo db 'codec io base ',0
1255 ;msgCtrlMMIo db 'controller mmio base ',0
1256 ;msgMixMMIo db 'codec mmio base ',0
1257 ;msgIrqMap db 'AC97 irq map as ',0