aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-11-12 05:52:13 -0500
committerTakashi Iwai <tiwai@suse.de>2015-11-12 05:52:13 -0500
commit909cadc6c8c7e52149fb4687453277d6cabe8c80 (patch)
tree110036e24c89e80360dd3d0b74824846ef72b5f9
parente2656412f2a7343ecfd13eb74bac0a6e6e9c5aad (diff)
ALSA: hda - Simplify phantom jack handling for HDMI/DP
The HDMI codec parser may create a phantom jack, but the helper function snd_hda_jack_add_kctl() treats always as a normal jack. This is superfluous as the jack query is executed at each time the jack sync is performed. Since the HDMI codec parser is the only caller of this function, it's easier to change back this directly calling the original __snd_hda_jack_add_kctl() with phantom_jack parameter. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_jack.c18
-rw-r--r--sound/pci/hda/hda_jack.h2
-rw-r--r--sound/pci/hda/patch_hdmi.c7
3 files changed, 8 insertions, 19 deletions
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
index 366efbf87d41..c945e257d368 100644
--- a/sound/pci/hda/hda_jack.c
+++ b/sound/pci/hda/hda_jack.c
@@ -383,7 +383,7 @@ static void hda_free_jack_priv(struct snd_jack *jack)
383 * This assigns a jack-detection kctl to the given pin. The kcontrol 383 * This assigns a jack-detection kctl to the given pin. The kcontrol
384 * will have the given name and index. 384 * will have the given name and index.
385 */ 385 */
386static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, 386int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
387 const char *name, bool phantom_jack) 387 const char *name, bool phantom_jack)
388{ 388{
389 struct hda_jack_tbl *jack; 389 struct hda_jack_tbl *jack;
@@ -410,20 +410,6 @@ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
410 410
411 return 0; 411 return 0;
412} 412}
413
414/**
415 * snd_hda_jack_add_kctl - Add a jack kctl for the given pin
416 * @codec: the HDA codec
417 * @nid: pin NID
418 * @name: the name string for the jack ctl
419 *
420 * This is a simple helper calling __snd_hda_jack_add_kctl().
421 */
422int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
423 const char *name)
424{
425 return __snd_hda_jack_add_kctl(codec, nid, name, false);
426}
427EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl); 413EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl);
428 414
429static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, 415static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
@@ -451,7 +437,7 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
451 if (phantom_jack) 437 if (phantom_jack)
452 /* Example final name: "Internal Mic Phantom Jack" */ 438 /* Example final name: "Internal Mic Phantom Jack" */
453 strncat(name, " Phantom", sizeof(name) - strlen(name) - 1); 439 strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
454 err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack); 440 err = snd_hda_jack_add_kctl(codec, nid, name, phantom_jack);
455 if (err < 0) 441 if (err < 0)
456 return err; 442 return err;
457 443
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
index 387d30984dfe..858708a044f5 100644
--- a/sound/pci/hda/hda_jack.h
+++ b/sound/pci/hda/hda_jack.h
@@ -82,7 +82,7 @@ static inline bool snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
82bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid); 82bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
83 83
84int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, 84int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
85 const char *name); 85 const char *name, bool phantom_jack);
86int snd_hda_jack_add_kctls(struct hda_codec *codec, 86int snd_hda_jack_add_kctls(struct hda_codec *codec,
87 const struct auto_pin_cfg *cfg); 87 const struct auto_pin_cfg *cfg);
88 88
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 309274bd1858..60cd9e700909 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -2097,14 +2097,17 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
2097 struct hdmi_spec *spec = codec->spec; 2097 struct hdmi_spec *spec = codec->spec;
2098 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); 2098 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
2099 int pcmdev = get_pcm_rec(spec, pin_idx)->device; 2099 int pcmdev = get_pcm_rec(spec, pin_idx)->device;
2100 bool phantom_jack;
2100 2101
2101 if (pcmdev > 0) 2102 if (pcmdev > 0)
2102 sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev); 2103 sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
2103 if (!is_jack_detectable(codec, per_pin->pin_nid)) 2104 phantom_jack = !is_jack_detectable(codec, per_pin->pin_nid);
2105 if (phantom_jack)
2104 strncat(hdmi_str, " Phantom", 2106 strncat(hdmi_str, " Phantom",
2105 sizeof(hdmi_str) - strlen(hdmi_str) - 1); 2107 sizeof(hdmi_str) - strlen(hdmi_str) - 1);
2106 2108
2107 return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str); 2109 return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str,
2110 phantom_jack);
2108} 2111}
2109 2112
2110static int generic_hdmi_build_controls(struct hda_codec *codec) 2113static int generic_hdmi_build_controls(struct hda_codec *codec)