Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: libin.yang@linux.intel.com
Cc: libin.yang@intel.com, mengdong.lin@intel.com,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH 3/4] ALSA: hda - hdmi jack created based on pcm
Date: Thu, 07 Jan 2016 15:13:53 +0100	[thread overview]
Message-ID: <s5hk2nlfpem.wl-tiwai@suse.de> (raw)
In-Reply-To: <1451524942-17288-4-git-send-email-libin.yang@linux.intel.com>

On Thu, 31 Dec 2015 02:22:21 +0100,
libin.yang@linux.intel.com wrote:
> 
> From: Libin Yang <libin.yang@linux.intel.com>
> 
> Jack is created based on pcm.
> 
> For dyn_pcm_assign:
>  Driver will not use hda_jack. It will operate snd_jack directly.

This is nothing new, it's already so for Intel codecs (via audio
component).

>  snd_jack pointer will be stored in spec->pcm.jack.

.... instead of the current spec->acomp_jack.


> When pcm is
>  assigned to pin, jack will be assigned to pin automatically.
> 
> For !dyn_pcm_assign:
>  Driver will continue using hda_jack for less impact on the old cases.
>  Pcm is statically assigned to pin. So is jack. spec->pcm.jack will
>  save the snd_jack pointer created in hda_jack.
> 
> Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
(snip)

> -static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
> +static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx)
>  {
>  	char hdmi_str[32] = "HDMI/DP";
>  	struct hdmi_spec *spec = codec->spec;
> -	struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
> -	int pcmdev = get_pcm_rec(spec, pin_idx).pcm->device;
> +	struct hdmi_spec_per_pin *per_pin;
> +	struct hda_jack_tbl *jack;
> +	int pcmdev = get_pcm_rec(spec, pcm_idx).pcm->device;
>  	bool phantom_jack;
> +	int ret;
>  
>  	if (pcmdev > 0)
>  		sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
> -	if (codec_has_acomp(codec))
> -		return add_acomp_jack_kctl(codec, per_pin, hdmi_str);
> -	phantom_jack = !is_jack_detectable(codec, per_pin->pin_nid);
> -	if (phantom_jack)
> -		strncat(hdmi_str, " Phantom",
> -			sizeof(hdmi_str) - strlen(hdmi_str) - 1);
>  
> -	return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str,
> -				     phantom_jack);
> +	/* for !dyn_pcm_assign, we still use hda_jack for compatibility */
> +	if (!spec->dyn_pcm_assign) {

Actually, the code changes become smaller with the following:

	if (spec->dyn_pcm_assign)
		return add_hdmi_jack_kctl(codec, spec, pcm_idx, hdmi_str);

Then the rest is almost same as the original code, and you'd need to
give a few more comments and assignment of pcm_rec[].jack in
addition.


> @@ -2626,18 +2659,23 @@ static void hdmi_array_free(struct hdmi_spec *spec)
>  static void generic_hdmi_free(struct hda_codec *codec)
>  {
>  	struct hdmi_spec *spec = codec->spec;
> -	int pin_idx;
> +	int pin_idx, pcm_idx;
>  
>  	if (codec_has_acomp(codec))
>  		snd_hdac_i915_register_notifier(NULL);
>  
>  	for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
>  		struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
> -
>  		cancel_delayed_work_sync(&per_pin->work);
>  		eld_proc_free(per_pin);
> -		if (per_pin->acomp_jack)
> -			snd_device_free(codec->card, per_pin->acomp_jack);
> +	}
> +
> +	for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) {
> +		if (spec->dyn_pcm_assign)
> +			snd_device_free(codec->card,
> +					spec->pcm_rec[pcm_idx].jack);
> +		else
> +			spec->pcm_rec[pcm_idx].jack = NULL;

Check whether spec->pcm_rec[pcm_idx].jack is NULL beforehand.


Takashi

  reply	other threads:[~2016-01-07 14:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-31  1:22 [PATCH 0/4] ALSA: hda - hdmi jack support for dynamic pcm assignment libin.yang
2015-12-31  1:22 ` [PATCH 1/4] ALSA: Add documentation about HD-audio DP MST libin.yang
2015-12-31  1:22 ` [PATCH 2/4] ALSA: hda - add hdmi_pcm to manage hdmi pcm related features libin.yang
2016-01-07 13:59   ` Takashi Iwai
2016-01-08  2:48     ` Yang, Libin
2015-12-31  1:22 ` [PATCH 3/4] ALSA: hda - hdmi jack created based on pcm libin.yang
2016-01-07 14:13   ` Takashi Iwai [this message]
2016-01-08  3:15     ` Yang, Libin
2016-01-08  7:43       ` Takashi Iwai
2016-01-08  7:52         ` Yang, Libin
2016-01-08  7:54           ` Takashi Iwai
2016-01-08  7:57             ` Yang, Libin
2015-12-31  1:22 ` [PATCH 4/4] ALSA: hda - hdmi monitor hotplug support for dynamic pcm assignment libin.yang
2016-01-07 14:18   ` Takashi Iwai
2016-01-08  5:25     ` Yang, Libin
2016-01-08  7:45       ` Takashi Iwai
2016-01-08  7:53         ` Yang, Libin
2016-01-06  9:18 ` [PATCH 0/4] ALSA: hda - hdmi jack " Takashi Iwai
2016-01-07  1:41   ` Yang, Libin
2016-01-07 10:31     ` Takashi Iwai
2016-01-08  2:47       ` Yang, Libin

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=s5hk2nlfpem.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=libin.yang@intel.com \
    --cc=libin.yang@linux.intel.com \
    --cc=mengdong.lin@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox