                          VIA AC'97 codec
                     sound problem solver pack
                            for OS/2

                     (c) 2001 by Vit Timchsihin
                           tivv@ukr.net

                           version 0.9


1. Preface

    Not long ago I've decided to upgrade my PC. The motherboard I've selected
contained VIA 686B with integrated AC'97 audio. I even heard that there are
drivers for this audio card.
    But after I came home and tried to use the sound I've faced some problems...
Now I can listen any WAV/MP3 file I wish (now I have CD player plying using
digital transfer).
    Some time later I've realized that I am not alone and so this package
was created to help many others that faced same problems.

2. Introduction

    Any AC'97 sound solution has two parts:
    a)Driver-dependant interface chip (VIA 686 in our case) that creates
      interface between user program (or driver) and codec
    b)Driver-independant codec chip. It is also important because this
      codec defines what features you will have, what sound quality you
      will hear and so on.

    VIA 686 provides two (almost, see below) independant interfaces to the
    sound codec:
    a)AC'97 version (this is what VIA drivers working with)
    b)Sound Blaster Pro emulation (that is second way, standard
      Sound Blaster pro (OPL3) drivers can work with this.

    Both cases have it's own problems, that are described in the two sections
below. But if you will overcome problem in both ways, you will have ability
to get TWO independant virtual sound card.

Note: This sound solution does NOT include MIDI, so you will need software
      midi (like TIMIDITY). Fortunatelly this is not a problem.

3. Tools

    This package has next tools available:
    a)viadt.exe (TRAP remover, see below)
    b)dumpreg - dumps AC'97 codec registers
    c)setreg - sets AC'97 codec register, can be used
      to set mixer settings (volume).

    Last two need IOPL32.DLL (URL #3 in url.txt).

4. VIA (AC'97) driver problems:

    a)Playing sound files causes TRAP D

    Technical cause:
        When creating VIA drivers from DDK MAD16 samples
        they have used too small buffers and so while playing
        they are going out of buffer.

    Patch:
        viaudd.sys
        0000B367: 20 F0
        0000B3BB: 20 F0
        0000B3EA: 20 F0
        0000B408: 20 F0
        0000B461: 25 F0
        0000B47E: 25 F0

        This will enlarge buffers from 0x2000 (0x2500) to 0xF000
        bytes. You can set other values to comsume less memory

    b)All sound files are played faster then needed

    This is codec functionality problems: not all codecs has
    variable sound rate feature, and if codec lacks the feature
    it will play all files if they are 48000 Khz

    Nothing can be done with this, the only thing is that you can
    check this to be sure:
    1)Run dumpreg.
    2)Look for 0x28 register
    3)Check bit 0. It will indicate if your codec support
    variable rate for playing.
    3)Check bit 3. It will indicate if your codec support
    variable rate for recording.

    If you are not lucky (like me <g>), you must use second (Sound Blaster Pro)
solution. But you can still leave VIA drivers to play(or record!) 48000Khz
audio. In case of recording, you will get full duplex solution.

5. Sound Blaster emulation problems

    a)TRAP 2

    Technical cause:
        This is feature <g>.
        The trap is created by hardware when SB driver tries to access
        midi. This enables creation of solution that will react to the trap
        and emulate SB FM MIDI. Fortunatelly this is disableable.

    Solution:
        Add CALL=D:\PATH\viadt.exe to your config.sys. This program will
        disable TRAP 2 generation for all VIA sound solutions found.

    b)Problems playing 44100Khz audio.

    Technical cause:
        SB Pro OS/2 drivers simpy does not allow this rate.

    Solution:
        Next patch must be applied to file taken from WSEB (Aurora)
        distribution. SBP2D2.SYS is 46508 bytes of size.
        a)Raize up some checks:
        SBP2D2.SYS
        00004861: 22 80
        00004862: 56 BB
        0000486E: 22 80
        0000486F: 56 BB
        000049DC: 22 80
        000049DD: 56 BB

        b)Add 16bit 44100 mode to list of supported
        Note 1: It is interesting that 8bit 44100 is already in the table,
                no matter driver does not support anything higher then 22050
        Note 2: This patch will replace MIDI entry (since MIDI is not supported)
        SBP2D2.SYS
        000002B5: 02 00
        000002B8: 00 0A
        000002BD: 02 40
        000002C0: 03 08
        000002C4: 00 44
        000002C5: 00 AC
        000002C8: 00 02
        000002CA: 00 08

    c)Nothing can be heard from Solution.

    Technical cause:
        Yet two solutions are independant, something still must init
        AC'97 codec.

    Solution:
        a) This can be done by viaudd driver (simply leave it
        in the config.sys, even without referencing in MMOS2).
        b) viaudd setup gives to high rate for PC speaker as for me,
        That's why I can recommend using setreg.exe to set needed volumes
        (See below).

6. Using setreg as mixer control program to set volumes.

    a)Use regs2.txt to select needed register.
    b)Call setreg <register> <value>.
    In most volume cases value must be 4 bytes hex value (i.e. ABCD),
    first two digits for one channel (left/right), last two for other.
    Setting highest bit (8000) will mute.
    Please note that lower settings gives HIGHER volume.

    My favorite settings (that are lines form startup.cmd):
    D:\path\setreg.exe 2 505
    D:\path\setreg.exe a a0a
    D:\path\setreg.exe 1c 0
    D:\path\setreg.exe 12 808
    D:\path\setreg.exe 18 a0a

    Note 1: To get other register values see first two urls from url.txt
    Note 2: setreg traps for me if called from config.sys (it seems that
            IOPL32 does not work), that's why I call it from startup.cmd

7. Disclaimer

    This pack is freeware

    YOU ARE USING THIS IT AT YOUR OWN RISK!!! In no event I take any
responsibillity   for  damages,  problems,  custodies,  etc. resulting
from  use, inability  to  use, misuse,  possession  or non-possession of
this library directly or indirectly.

	THE SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

    Permission is granted to redistribute this package free of charge,
provided it is distributed in the full archive with unmodified
contents and no profit beyond the price of the media on which it
is distributed is made. Exception to the last rule: the library
may be included on freeware/shareware collections on CD-ROM, as
well as on magazine cover CD-ROMs.

8. Trademarks

    IBM and OS/2 are registered trademarks of International Business
Machines, Inc.

    All other trademarks, registered trade marks, service marks and other
registered marks are the property of their respective owners.
