All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Raymond Yau <superquad.vortex2@gmail.com>
Cc: ALSA Development Mailing List <alsa-devel@alsa-project.org>
Subject: Re: [PATCH] HDA - add "Independent HP" switch for ad1988
Date: Wed, 21 Sep 2011 10:45:07 +0200	[thread overview]
Message-ID: <s5h1uvaz3l8.wl%tiwai@suse.de> (raw)
In-Reply-To: <CAN8cciYWVwcCnrGjgn3Vrvoxd+j6GrKXNRzoqDMAExKMo5_+_Q@mail.gmail.com>

At Sun, 18 Sep 2011 07:18:28 +0800,
Raymond Yau wrote:
> 
> Add "Independent HP" switch for ad1988
> 
> - add playback device 2 "AD1988 HP" for 7.1+2 multi streaming playback
> - add "Independent HP" switch to enable/disable the feature
>   switch is inactive and write protect when device 0 or device 2 is opened
> - remove 6stack-dig-fp model

Any rationale to remove this model?
I'm fine with the removal, but need to know the reason.

Also, regarding the patch:

> @@ -302,6 +304,71 @@ static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
>  }
>  #endif
>  
> +static void activate_ctl(struct hda_codec *codec, const char *name, int active)
> +{
> +	struct snd_kcontrol *ctl = snd_hda_find_mixer_ctl(codec, name);
> +	if (ctl) {
> +		ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +		ctl->vd[0].access |= active ? 0:SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +                ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_WRITE;

Please use tabs.

> +		ctl->vd[0].access |= active ? SNDRV_CTL_ELEM_ACCESS_WRITE:0;       
> +		snd_ctl_notify(codec->bus->card,
> +			       SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
> +	}
> +}
> +
> + static void set_stream_active(struct hda_codec *codec, bool active)
> +{
> +	struct ad198x_spec *spec = codec->spec;
> +	if (active)
> +		spec->num_active_streams++;
> +	else
> +		spec->num_active_streams--;
> +	activate_ctl(codec, "Independent HP", spec->num_active_streams == 0);
> +	printk(KERN_INFO "set stream active : active stream  %d \n", spec->num_active_streams);

Avoid debug prints in the final code.
If any, use snd_printdd() or such.

> +}
+
+static int ad1988_independent_hp_info(struct snd_kcontrol *kcontrol,
+				   struct snd_ctl_elem_info *uinfo)
+{
+	static const char * const texts[] = { "OFF", "ON", NULL};
+	int index;
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+	uinfo->count = 1;
+	uinfo->value.enumerated.items = 2;
+	index = uinfo->value.enumerated.item;
+	if (index >= 2)
+		index = 1;
+	strcpy(uinfo->value.enumerated.name, texts[index]);
+	return 0;
+}
+
+static int ad1988_independent_hp_get(struct snd_kcontrol *kcontrol,
+				  struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct ad198x_spec *spec = codec->spec;
+	ucontrol->value.enumerated.item[0] = spec->independent_hp;
+	return 0;
+}
+
+static int ad1988_independent_hp_put(struct snd_kcontrol *kcontrol,
+				  struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct ad198x_spec *spec = codec->spec;
+	unsigned int select = ucontrol->value.enumerated.item[0];
+	if (spec->independent_hp != select) {
+	        spec->independent_hp = select;
+		if (spec->independent_hp)
+			spec->multiout.hp_nid = 0; 
+		else
+			spec->multiout.hp_nid = spec->alt_dac_nid[0];
+		return 1;
+	}
+	return 0;
+}

Changing spec->multiout.hp_nid dynamically here is racy.  If the value
is changed during the PCM stream is opened, the HP-setup might be kept
inconsistent at close.


thanks,

Takashi

  reply	other threads:[~2011-09-21  8:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-17 23:18 [PATCH] HDA - add "Independent HP" switch for ad1988 Raymond Yau
2011-09-21  8:45 ` Takashi Iwai [this message]
2011-09-22  2:32   ` Raymond Yau
2011-09-22 10:44     ` Takashi Iwai

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=s5h1uvaz3l8.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=superquad.vortex2@gmail.com \
    /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.