openvortex-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openvortex-dev] au88x0 PCM Volume control


From: Raymond
Subject: [Openvortex-dev] au88x0 PCM Volume control
Date: Tue, 06 Sep 2005 16:00:15 +0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.7.8) Gecko/20050603 Fedora/1.7.8-1.1.1.legacy

The proposed PCM Volume controls of the playback device 0 of au88x0 driver allow any ALSA application using the PCM Volume control (.iface=SNDRV_CTL_ELEM_IFACE_PCM) associated to the sudevice to change the volume (-48dB to 6dB) when the audio passing through the hardware mixer of au88x0.


Mono
                            0dB
DMA -> FIFO -> SRC -> MIXIN ---> MIXOUT -> Equalizer -> Front Left
                        |   0dB
                        +------> MIXOUT -> Equalizer -> Front Right
                        |   6dB
                        +------> MIXOUT --------------> Rear Left
                        |   6dB
                        +------> MIXOUT --------------> Rear Right

Stereo

                            0dB
DMA -> FIFO -> SRC -> MIXIN ---> MIXOUT -> Equalizer -> Front Left
            |           |   6dB
            |           +------> MIXOUT --------------> Rear Left
            |               0dB
            +> SRC -> MIXIN ---> MIXOUT -> Equalizer -> Front Right
                        |   6dB
                        +------> MIXOUT --------------> Rear Right

Surround40

                            0dB
DMA -> FIFO -> SRC -> MIXIN ---> MIXOUT -> Equalizer -> Front Left
            |               0dB
            +> SRC -> MIXIN ---> MIXOUT -> Equalizer -> Front Right
            |               6dB
            +> SRC -> MIXIN ---> MIXOUT --------------> Rear Left
            |               6dB
            +> SRC -> MIXIN ---> MIXOUT --------------> Rear Right


Description of the patch (beta)
- add PCM Volume control by using the hardware mixer of au88x0


TEST AT YOUR OWN RISK !!!

The audio will be distorted when total gain exceed the limit of 18-bits
DAC in AC97 codec.


Any comment/suggestion or programs to test the feature are welcome.


Hi,


On Mon, 2005-08-29 at 10:28 +0800, Raymond wrote:

> Distortion occur when the combined gain of audio data, hardware
> mixer ,  equalizer and 3D effect > 6dB ( limit by the 18-bits DAC i
> n AC97 codec)


The maximum gain possible for a entire audio pipe should obvisouly not
exceeded.


Why the hardware mixer in the current ALSA driver is set to zero gain in vortex_adb_allocroute() when capturing audio from 18-bits ADC to 16-bits audio ? ( In theory, it should be -6dB )


                                              AC97
16bits Audio                 0dB        18bits   Analog
DMA <- FIFO <- SRC <- MIXOUT <- MIXIN <- ADC  <- MIXER <---- MIC
                                       |           |
DMA <- FIFO <- SRC <- MIXOUT <- MIXIN <+           +---------LINE IN
                                                   |
                                                   +---------VIDEO
                                                   |
                                                   +---------CD
                                                   |
                                                   +---------AUX
                                                   |
                                                   +---------PHONE
                                                   |
                                                   +---------MIX



> In the ALSA au88x0 driver, the hardware mixer provide default gain
> of  6dB ( 16-bits auido data to 18-bits DAC in AC97 codec ) for the
> left/right channels of au8820 and the rear channels of au8810/au8830
> (to  SDAC of quad codec),
 >
> For the front channels of au8810/au8830, zero gain in hardware mixer
> and  this 6dB gain is most likely controlled by the equalizer or 3D
> effect.
>

I would suggest using the correct signed or unsigned type instead of
doing explicit type conversions.



static void
vortex_mix_setinputvolumebyte(vortex_t * vortex, unsigned char mix,
                              int mixin, unsigned char vol)
{
        int temp;

        hwwrite(vortex->mmio,
                VORTEX_MIX_INVOL_A + (((mix << 5) + mixin) << 2), vol);
        if (1) {                /* this_10, initialized to 1. */
                temp =
                    hwread(vortex->mmio,
                           VORTEX_MIX_INVOL_B + (((mix << 5) + mixin) << 2));
                if ((temp != 0x80) || (vol == 0x80))
                        return;
        }
        hwwrite(vortex->mmio,
                VORTEX_MIX_INVOL_B + (((mix << 5) + mixin) << 2), vol);
}


static int snd_vortex_adb_pcm_change_vol(vortex_t *vortex,int mixin,int
mix,int volume)
{
        if ( volume >= 128 )
                vortex_mix_setinputvolumebyte(vortex, mix, mixin, volume-128);
  // GAIN
        else
                if ( volume < 64 )
                        vortex_mix_setinputvolumebyte(vortex, mix, mixin, 
0x80);        // MUTE
                else
                        vortex_mix_setinputvolumebyte(vortex, mix, mixin, 
volume+128);  // ATTEN
        return 0;
}












reply via email to

[Prev in Thread] Current Thread [Next in Thread]