Skip to content

Commit 909cadc

Browse files
committed
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>
1 parent e265641 commit 909cadc

3 files changed

Lines changed: 8 additions & 19 deletions

File tree

sound/pci/hda/hda_jack.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void hda_free_jack_priv(struct snd_jack *jack)
383383
* This assigns a jack-detection kctl to the given pin. The kcontrol
384384
* will have the given name and index.
385385
*/
386-
static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
386+
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
387387
const char *name, bool phantom_jack)
388388
{
389389
struct hda_jack_tbl *jack;
@@ -410,20 +410,6 @@ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
410410

411411
return 0;
412412
}
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-
*/
422-
int 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-
}
427413
EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl);
428414

429415
static 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,
451437
if (phantom_jack)
452438
/* Example final name: "Internal Mic Phantom Jack" */
453439
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);
455441
if (err < 0)
456442
return err;
457443

sound/pci/hda/hda_jack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static inline bool snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
8282
bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
8383

8484
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
85-
const char *name);
85+
const char *name, bool phantom_jack);
8686
int snd_hda_jack_add_kctls(struct hda_codec *codec,
8787
const struct auto_pin_cfg *cfg);
8888

sound/pci/hda/patch_hdmi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,14 +2097,17 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
20972097
struct hdmi_spec *spec = codec->spec;
20982098
struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
20992099
int pcmdev = get_pcm_rec(spec, pin_idx)->device;
2100+
bool phantom_jack;
21002101

21012102
if (pcmdev > 0)
21022103
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)
21042106
strncat(hdmi_str, " Phantom",
21052107
sizeof(hdmi_str) - strlen(hdmi_str) - 1);
21062108

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);
21082111
}
21092112

21102113
static int generic_hdmi_build_controls(struct hda_codec *codec)

0 commit comments

Comments
 (0)