Skip to contentSkip to conversation

au88x0 PCM Volume control

DISCUSSION Raymond 1 participant 1 message Sep 6, 2005 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Raymond

author
#1 lore raw

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
Quoted 5 lines

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

Quoted 22 lines

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.

Quoted 12 lines

Hi,

Quoted 3 lines · Raymond

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
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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),

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

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;
}

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf