All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Felix Homann <linuxaudio@showlabor.de>
Cc: alsa-devel@alsa-project.org, patch@alsa-project.org, mark@pogo.org.uk
Subject: Re: [PATCH 6/7] M-Audio Fast Track Ultra: Add effect program switch
Date: Mon, 23 Apr 2012 17:08:19 +0200	[thread overview]
Message-ID: <s5hhawa5vvg.wl%tiwai@suse.de> (raw)
In-Reply-To: <1335191857-6725-7-git-send-email-linuxaudio@showlabor.de>

At Mon, 23 Apr 2012 16:37:36 +0200,
Felix Homann wrote:
> 
> 
> Signed-off-by: Felix Homann <linuxaudio@showlabor.de>

Put some more texts here.  Otherwise one can't know what you've done.
For example, you can explain more about what effect is added and how.
Or any current restriction or whatever.


> diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
> index 3adef3e..f751137 100644
> --- a/sound/usb/mixer_quirks.c
> +++ b/sound/usb/mixer_quirks.c
> @@ -574,6 +574,187 @@ static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
>  }
>  
>  /* M-Audio FastTrack Ultra quirks */
> +/* FTU Effect switch */
> +struct snd_ftu_eff_switch_priv_val {
> +	struct usb_mixer_interface *mixer;
> +	int cached_value;
> +	int is_cached;
> +};
> +
> +static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
> +					struct snd_ctl_elem_info *uinfo)
> +{
> +	static char *texts[8] = {"Room 1",
> +				 "Room 2",
> +				 "Room 3",
> +				 "Hall 1",
> +				 "Hall 2",
> +				 "Plate",
> +				 "Delay",
> +				 "Echo"
> +	};
> +
> +	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
> +	uinfo->count = 1;
> +	uinfo->value.enumerated.items = 8;
> +	if (uinfo->value.enumerated.item > 7)
> +		uinfo->value.enumerated.item = 7;
> +	strcpy(uinfo->value.enumerated.name,
> +		texts[uinfo->value.enumerated.item]);
> +
> +	return 0;
> +}
> +
> +static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
> +					struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_usb_audio *chip;
> +	struct usb_mixer_interface *mixer;
> +	struct snd_ftu_eff_switch_priv_val *pval;
> +	int err;
> +	unsigned char value[2];
> +
> +	pval = (struct snd_ftu_eff_switch_priv_val *)
> +		kctl->private_value;
> +
> +	if (pval->is_cached) {
> +		ucontrol->value.enumerated.item[0] = pval->cached_value;
> +		return 0;
> +	}
> +
> +	mixer = (struct usb_mixer_interface *) pval->mixer;
> +	if (snd_BUG_ON(!mixer))
> +		return -EINVAL;
> +
> +	chip = (struct snd_usb_audio *) mixer->chip;
> +	if (snd_BUG_ON(!chip))
> +		return -EINVAL;
> +
> +	const int id = 6;
> +	const int validx = 1;
> +	const int val_type = USB_MIXER_S16;
> +
> +	value[0] = 0x00;
> +	value[1] = 0x00;
> +
> +	const int val_len = 2;
> +
> +	err = snd_usb_ctl_msg(chip->dev,
> +			usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
> +			USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
> +			validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
> +			value, val_len);
> +	if (err < 0)
> +		return -1;

Return err as is.

> +
> +	ucontrol->value.enumerated.item[0] = value[0];
> +	pval->cached_value = value[0];
> +	pval->is_cached = 1;
> +
> +	return 0;
> +}
> +
> +static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
> +					struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_usb_audio *chip;
> +	struct snd_ftu_eff_switch_priv_val *pval;
> +
> +	struct usb_mixer_interface *mixer;
> +	int changed, cur_val, err, new_val;
> +	unsigned char value[2];
> +
> +	changed = 0;
> +	const int id = 6;
> +	const int validx = 1;
> +	const int val_type = USB_MIXER_S16;
> +	const int val_len = 2;
> +
> +	pval = (struct snd_ftu_eff_switch_priv_val *)
> +		kctl->private_value;
> +	cur_val = pval->cached_value;
> +	new_val = ucontrol->value.enumerated.item[0];
> +
> +	mixer = (struct usb_mixer_interface *) pval->mixer;
> +	if (snd_BUG_ON(!mixer))
> +		return -EINVAL;
> +
> +	chip = (struct snd_usb_audio *) mixer->chip;
> +	if (snd_BUG_ON(!chip))
> +		return -EINVAL;
> +
> +	if (!pval->is_cached) {
> +		/* Read current value */
> +		err = snd_usb_ctl_msg(chip->dev,
> +				usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
> +				USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
> +				validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
> +				value, val_len);
> +		if (err < 0)
> +			return -1;

Ditto.

> +
> +		cur_val = value[0];
> +		pval->cached_value = cur_val;
> +		pval->is_cached = 1;
> +	}
> +	/* update value if needed */
> +	if (cur_val != new_val) {
> +		value[0] = new_val;
> +		value[1] = 0;
> +		err = snd_usb_ctl_msg(chip->dev,
> +				usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
> +				USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
> +				validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
> +				value, val_len);
> +		if (err < 0)
> +			return -1;

Ditto.

> +
> +		pval->cached_value = new_val;
> +		pval->is_cached = 1;
> +		changed = 1;
> +	}
> +
> +	return changed;
> +}
> +
> +static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer)
> +{
> +	static struct snd_kcontrol_new template = {
> +		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +		.name = "Effect Program Switch",
> +		.index = 0,
> +		.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
> +		.info = snd_ftu_eff_switch_info,
> +		.get = snd_ftu_eff_switch_get,
> +		.put = snd_ftu_eff_switch_put
> +	};
> +

Avoid the unnecessary blank line.

> +	int err;
> +	struct snd_kcontrol *kctl;
> +	struct snd_ftu_eff_switch_priv_val *pval;
> +
> +	pval = kzalloc(sizeof(*pval), GFP_KERNEL);
> +	if (!pval)
> +		return -ENOMEM;
> +
> +	pval->cached_value = 0;
> +	pval->is_cached = 0;
> +	pval->mixer = mixer;
> +
> +	template.private_value = (unsigned long) pval;
> +	kctl = snd_ctl_new1(&template, mixer->chip);
> +	if (!kctl) {
> +		kfree(pval);
> +		return -ENOMEM;
> +	}
> +
> +	err = snd_ctl_add(mixer->chip->card, kctl);
> +	if (err < 0)
> +		return err;
> +
> +	return 0;
> +}
> +
>  
>  /* Create volume controls for FTU devices*/
>  static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
> @@ -622,6 +803,10 @@ static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
>  	if (err < 0)
>  		return err;
>  
> +	err = snd_ftu_create_effect_switch(mixer);
> +	if (err < 0)
> +		return err;
> +
>  	return 0;
>  }
>  
> -- 
> 1.7.5.4
> 

  reply	other threads:[~2012-04-23 15:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 14:37 [PATCH 0/7] Alsa: snd-usb: Improve M-Audio Fast Track Ultra mixer - v2 Felix Homann
2012-04-23 14:37 ` [PATCH 1/7] Unify M-Audio Fast Track Ultra and Ebox-44 mixer quirks Felix Homann
2012-04-23 15:06   ` Takashi Iwai
2012-04-23 16:00     ` Felix Homann
2012-04-23 16:01       ` Takashi Iwai
2012-04-23 18:43     ` Mark Hills
2012-04-24  6:22       ` Takashi Iwai
2012-04-23 14:37 ` [PATCH 2/7] Rename and export mixer_vol_tlv Felix Homann
2012-04-23 14:37 ` [PATCH 3/7] Add TLV to M-Audio Fast Track Ultra controls Felix Homann
2012-04-23 14:37 ` [PATCH 4/7] Rename Fast Track Ultra mixer quirk functions Felix Homann
2012-04-23 14:37 ` [PATCH 5/7] Update comment for M-Audio FTU quirk Felix Homann
2012-04-23 14:37 ` [PATCH 6/7] M-Audio Fast Track Ultra: Add effect program switch Felix Homann
2012-04-23 15:08   ` Takashi Iwai [this message]
2012-04-23 14:37 ` [PATCH 7/7] M-Audio Fast Track Ultra: Add effect controls Felix Homann
2012-04-23 15:11   ` Takashi Iwai
2012-04-23 16:07     ` Felix Homann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hhawa5vvg.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=linuxaudio@showlabor.de \
    --cc=mark@pogo.org.uk \
    --cc=patch@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.