[alsa-devel] [PATCH v2 3/5] snd-usb-6fire: add individual volume control for analog channels

Takashi Iwai tiwai at suse.de
Wed Feb 22 14:37:42 CET 2012


At Wed, 22 Feb 2012 14:07:14 +0100,
Torsten Schenk wrote:
> 
> -static void usb6fire_control_master_vol_update(struct control_runtime *rt)
> +static void usb6fire_control_output_vol_update(struct control_runtime *rt)
>  {
>  	struct comm_runtime *comm_rt = rt->chip->comm;
> -	if (comm_rt) {
> -		/* set volume */
> -		comm_rt->write8(comm_rt, 0x12, 0x0f, 180 - rt->master_vol);
> -		 /* unmute */
> -		comm_rt->write8(comm_rt, 0x12, 0x0e, 0x00);
> -	}
> +	int i;
> +
> +	if (comm_rt)
> +		for (i = 0; i < 6; i++)
> +			comm_rt->write8(comm_rt, 0x12, 0x0f + i,
> +				180 - rt->output_vol[i]);
>  }

Would be better to update only the affected channel, but it's just
a minor thing.  Not need to change at this time.

> -static struct __devinitdata snd_kcontrol_new elements[] = {
> +static struct __devinitdata snd_kcontrol_new vol_elements[] = {
>  	{
>  		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> -		.name = "Master Playback Volume",
> -		.index = 0,
> +		.name = "Analog Playback Volume",
> +		.index = 1,

The index should start also from zero.


> @@ -310,6 +365,39 @@
>  	{}
>  };
>  
> +static int usb6fire_control_add_virtual(
> +	struct control_runtime *rt,
> +	struct snd_card *card,
> +	char *name,
> +	struct snd_kcontrol_new *elems)
> +{
> +	int ret;
> +	int i;
> +	struct snd_kcontrol *vmaster = snd_ctl_make_virtual_master(name, NULL);

Pass tlv_output here.



thanks,

Takashi


More information about the Alsa-devel mailing list