Skip to content

Commit

Permalink
Add experimental support for the SiS7012 AC'97 Sound Controller, see …
Browse files Browse the repository at this point in the history
…GitHub issue #2
  • Loading branch information
volkertb committed Oct 10, 2020
1 parent 3c0198e commit 3bbe006
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
9 changes: 7 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ sep 02 2002

(With some small modifications/additions made by Volkert de Buisonjé)

Uses AC'97 audio on supported Intel chipsets
(ICH/ICH0/ICH2/ICH3/ICH4/ICH5/ESB/ICH6/ICH7 southbridge, or 440MX chipset)
Uses AC'97 audio on supported chipsets:

* Intel: ICH/ICH0/ICH2/ICH3/ICH4/ICH5/ESB/ICH6/ICH7 southbridge, or 440MX chipset
* SiS7012

No drivers required. (there aren't any for DOS anyway!)


Expand Down Expand Up @@ -39,6 +42,8 @@ implement proper .wav header parsing. You get what you pay for.]
(first generation) ICH has been successfully tested in both QEMU+KVM and
VirtualBox VMs, but has yet to be tested on actual hardware. Other ICHes (up to
ICH7) should be compatible with the the ICH2 but these haven't been tested yet.
Also the SiS7012 AC'97 Sound Controller should now be supported, but this too
is as of yet untested.
If you have tested with any of these chipsets, please share your findings!

3) ONLY supports 16bit samples, stereo format .wav files. Multiple sample
Expand Down
27 changes: 27 additions & 0 deletions codec.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
.CODE

extern NAMBAR:word
extern NABMBAR:WORD
extern DETECTED_PCI_DEV:DWORD
extern delay1_4ms:NEAR

include codec.inc
include ich2ac97.inc


; enable codec, unmute stuff, set output rate to 44.1
Expand All @@ -45,6 +48,15 @@ codecConfig proc public
; Skip volume adjustment if not requested
cmp bh,"Y"
jnz skip_volume_adjustment

; If the detected device is a SiS7012, apply device-specific unmute quirk:
mov eax,dword ptr[DETECTED_PCI_DEV]
cmp eax,(SIS_7012_DID shl 16) + SIS_VID
jne noSis7012QuirksNeeded
call unmuteSis7012

noSis7012QuirksNeeded:

;
;
; This stuff sets the volume to MAXIMUM.
Expand Down Expand Up @@ -78,6 +90,21 @@ skip_volume_adjustment:
ret
codecConfig endp

; Unmute quirk specifically for the SiS7012
unmuteSis7012 proc public
push ax
push dx

mov dx, ds:[NABMBAR]
add dx, CUSTOM_SIS_7012_REG
in ax, dx
or ax, 00000001b
out dx, ax

pop dx
pop ax
ret
unmuteSis7012 endp



Expand Down
9 changes: 7 additions & 2 deletions ich2ac97.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
; * ICH7 is the last generation to support AC'97 Audio (ICH8 and onwards support Intel HD Audio only)
; * The 440MX is not in the ICH family, but does support AC'97 Audio (mobile chipset with integrated north/southbridge)
;
INTEL_VID equ 8086h ; Intel's PCI vendor ID
INTEL_VID equ 8086h ; vendor ID: Intel
ICH_DID equ 2415h ; device ID: 82801AA AC'97 Audio Controller (ICH)
ICH0_DID equ 2425h ; device ID: 82801AB AC'97 Audio Controller (ICH0)
ICH2_DID equ 2445h ; device ID: 82801BA/BAM AC'97 Audio Controller (ICH2)
Expand All @@ -32,7 +32,10 @@ ESB_DID equ 25a6h ; device ID: 6300ESB AC'97 Audio Control
ICH6_DID equ 266eh ; device ID: 82801FB/FBM/FR/FW/FRW AC'97 Audio Controller (ICH6)
ICH7_DID equ 27deh ; device ID: 82801GB/GBM/GR/GH/GHM AC'97 Audio Controller (ICH7)
I440MX_DID equ 7195h ; device ID: 82440MX AC'97 Audio Controller (440MX)
; TODO: add any non-Intel AC'97 audio devices that are compatible as well

; Other (non-Intel) vendors that are (mostly) compatible with ICHx AC'97 audio
SIS_VID equ 1039h ; vendor ID: Silicon Integrated Systems (SiS)
SIS_7012_DID equ 7012h ; device ID: SiS7012 AC'97 Sound Controller

NAMBAR_REG equ 10h ; native audio mixer BAR
NAM_SIZE equ 256 ; 256 bytes required.
Expand All @@ -55,6 +58,8 @@ PI_BDBAR_REG equ 0 ; PCM in buffer descriptor BAR
PO_BDBAR_REG equ 10h ; PCM out buffer descriptor BAR
MC_BDBAR_REG equ 20h ; MIC in buffer descriptor BAR

CUSTOM_SIS_7012_REG equ 0x4c ; SiS7012-specific register, required for unmuting output

; each buffer descriptor BAR holds a pointer which has entries to the buffer
; contents of the .WAV file we're going to play. Each entry is 8 bytes long
; (more on that later) and can contain 32 entries total, so each BAR is
Expand Down
28 changes: 22 additions & 6 deletions player.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
INCLUDE constant.inc
INCLUDE ich2ac97.inc

extern setFree:NEAR
extern setFree:NEAR
extern pciBusDetect:NEAR
extern pciFindDevice:NEAR
extern pciRegRead32:NEAR
extern pciRegRead16:NEAR
extern pciRegRead8:NEAR
extern pciRegWrite8:NEAR
extern codecConfig:NEAR
extern memAlloc:NEAR
extern memAlloc:NEAR
extern processCmdline:NEAR
extern openFile:NEAR
extern closeFile:NEAR
Expand Down Expand Up @@ -164,6 +164,12 @@ pci_bios_detected:
call pciFindDevice
jnc @f

; Check for a SiS7012 AC'97 Sound Controller
lea dx, sis7012DetectedMsg
mov eax, (SIS_7012_DID shl 16) + SIS_VID
call pciFindDevice
jnc @f

; couldn't find any supported audio device!

push cs
Expand All @@ -176,14 +182,16 @@ pci_bios_detected:
noDevMsg db "Error: Unable to find any supported AC'97 audio device!",CR,LF,"$"

@@:
; Store the detected device and vendor ID (should still be in eax)
mov dword ptr[DETECTED_PCI_DEV],eax

; Report whatever device has been detected at this point
; (dx should now be pointing to the message corresponding to the detected device)
; Report whatever device has been detected at this point
; (dx should now be pointing to the message corresponding to the detected device)
call printData

; get PCI subsystem info
mov al, PCI_SUBSYS_REG
call pciRegRead32
mov al, PCI_SUBSYS_REG
call pciRegRead32

; Print PCI subsystem info in EAX
push eax ; push PCI address
Expand Down Expand Up @@ -299,13 +307,16 @@ public BDL_BUFFER ; 256 byte buffer for descriptor list
public WAV_BUFFER1,WAV_BUFFER2 ; 64k buffers for wav file storage
public NAMBAR ; PCI BAR for mixer registers
public NABMBAR ; PCI BAR for bus master registers
public DETECTED_PCI_DEV ; The detected PCI device, device+vendor ID

BDL_BUFFER dw 0 ; segment of our 256byte BDL buffer
WAV_BUFFER1 dw 0 ; segment of our WAV storage
WAV_BUFFER2 dw 0 ; segment of 2nd wav buffer
NAMBAR dw 0 ; BAR for mixer
NABMBAR dw 0 ; BAR for bus master regs

DETECTED_PCI_DEV dd 0 ; The detected PCI device, device+vendor ID

ichDetectedMsg db "Intel 82801AA AC'97 Audio Controller (ICH) detected.",CR,LF,
"PCI Vendor ID : 8086h",CR,LF,
"PCI Device ID : 2415h",CR,LF,"$"
Expand Down Expand Up @@ -353,6 +364,11 @@ immx440DetectedMsg db "82440MX AC'97 Audio Controller (MX440) detected.",CR,LF,
"PCI Vendor ID : 8086h",CR,LF,
"PCI Device ID : 7195h",CR,LF,"$"

sis7012DetectedMsg db "SiS7012 AC'97 Sound Controller detected.",CR,LF,
"(Untested model, let me know on GitHub whether it works or not!)",CR,LF,
"PCI Vendor ID : 1039h",CR,LF,
"PCI Device ID : 7012h",CR,LF,"$"

subsystemIdMsg db "Device Subsystem ID : $"
subsystemVendorIdMsg db "Device Subsystem Vendor ID: $"

Expand Down

0 comments on commit 3bbe006

Please sign in to comment.