[alsa-devel] PATCH - via82xx vt1618 7.1 Audio Support

Takashi Iwai tiwai at suse.de
Mon Aug 25 08:47:02 CEST 2008


At Fri, 22 Aug 2008 16:26:59 -0700,
John L. Utz III wrote:
> 
> Makes Audio > 2.0 work on the VIA vt1618 7.1 Channel AC97 Codec
> 
> Patched against ALSA-GIT Fri Aug 22 16:24:52 PDT 2008
> 
> Authored-by:   John L. Utz III john.utz at dmx.com

It's taken from "From:" tag.  If you need a different address for the
patch, put "From:" tag with that address before the patch
description.

> Signed-off-by: John L. Utz III john.utz at dmx.com

Put the address with <> please.

> +/* VIA VT1618 8 CHANNEL AC97 CODEC */
> +
> +/* config aux in jack - not found on 3 jack motherboards or soundcards */
> +
> +static int snd_ac97_vt1618_aux_info(struct snd_kcontrol *kcontrol,
> +				    struct snd_ctl_elem_info *uinfo)
> +{
> +	static const  char  *acTxtAux[] = {"Aux In", "Back Surr Out"};

As mentioned earlier, the Hungarian notation should be avoided (unless
it must be so).  In this case, use a plain variable name like
"text_aux".

> +static int snd_ac97_vt1618_UAJ_info(struct snd_kcontrol *kcontrol,
> +				    struct snd_ctl_elem_info *uinfo)
> +{
> +	/* cribbed from ac97_surround_jack_mode_info() ordering in these lists
> +	 * reflects vt1618 docs for Vendor Defined Register 0x60 */
> +
> +	static const char *acTxtUAJ0[] =
> +		{ "Speaker Out", "DAC Unmixed Out", "Line In", "Mic In"};
> +
> +	static const char *acTxtUAJ1[] =
> +		{ "Surround Out", "DAC Unmixed Out", "Line In", "Mic In"};
> +
> +	static const char *acTxtUAJ2[] =
> +		{ "Center LFE Out", "DAC Unmixed Out", "Line In", "Mic In"};
> +
> +	const char **ppacTxt = acTxtUAJ0;
> +
> +	if (0x000C == kcontrol->private_value)
> +		ppacTxt = acTxtUAJ1;
> +
> +	if (0x0030 == kcontrol->private_value)
> +		ppacTxt = acTxtUAJ2;

Maybe it's cleaner to define the code like the following:

struct vt1618_uaj_item {
	unsigned short reg;
	unsigned short shift;
	const char *items[4];
};

static struct vt1618_uaj *vt1618_uaj[3] = {
	{
		/* speaker jack */
		.reg = 0x03,
		.shift = 0,
		.items = {
			"Speaker Out", "DAC Unmixed Out", "Line In", "Mic In"
		},
	},
	{
		/* line jack */
		.reg = 0x0c,
		.shift = 2,
		.items = {
			"Surround Out", "DAC Unmixed Out", "Line In", "Mic In"
		},
	},
	{
		/* mic jack */
		.reg = 0x30,
		.shift = 4,
		.items = {
			"Center LFE Out", "DAC Unmixed Out", "Line In",
			"Mic In"
		},
	},
};

And pass the array index to private_value field.
Then you can avoid if's in each callback.

> +static const struct snd_kcontrol_new snd_ac97_controls_vt1618[] = {
> +	AC97_SINGLE("Exchange Center/LFE", 0x5a,  8, 1,     0),
> +	AC97_SINGLE("DC Offset",           0x5a, 10, 1,     0),
> +	AC97_SINGLE("Soft Mute",           0x5c,  0, 1,     1),
> +	AC97_SINGLE("Headphone Amp",       0x5c,  5, 1,     1),
> +	AC97_DOUBLE("Back Surr Volume",    0x5e,  8, 0, 31, 1),
> +	AC97_SINGLE("Back Surr Switch",    0x5e, 15, 1,     1),
> +	{
> +		.iface         = SNDRV_CTL_ELEM_IFACE_MIXER,
> +		.name          = "Aux Jack",

Better to be "Aux Jack Mode" or such.


Could you fix these issues and repost?

thanks,

Takashi


More information about the Alsa-devel mailing list