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>
This commit is contained in:
parent
e2656412f2
commit
909cadc6c8
|
@ -383,7 +383,7 @@ static void hda_free_jack_priv(struct snd_jack *jack)
|
||||||
* This assigns a jack-detection kctl to the given pin. The kcontrol
|
* This assigns a jack-detection kctl to the given pin. The kcontrol
|
||||||
* will have the given name and index.
|
* will have the given name and index.
|
||||||
*/
|
*/
|
||||||
static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||||
const char *name, bool phantom_jack)
|
const char *name, bool phantom_jack)
|
||||||
{
|
{
|
||||||
struct hda_jack_tbl *jack;
|
struct hda_jack_tbl *jack;
|
||||||
|
@ -410,20 +410,6 @@ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* snd_hda_jack_add_kctl - Add a jack kctl for the given pin
|
|
||||||
* @codec: the HDA codec
|
|
||||||
* @nid: pin NID
|
|
||||||
* @name: the name string for the jack ctl
|
|
||||||
*
|
|
||||||
* This is a simple helper calling __snd_hda_jack_add_kctl().
|
|
||||||
*/
|
|
||||||
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
|
||||||
const char *name)
|
|
||||||
{
|
|
||||||
return __snd_hda_jack_add_kctl(codec, nid, name, false);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl);
|
EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl);
|
||||||
|
|
||||||
static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
|
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,
|
||||||
if (phantom_jack)
|
if (phantom_jack)
|
||||||
/* Example final name: "Internal Mic Phantom Jack" */
|
/* Example final name: "Internal Mic Phantom Jack" */
|
||||||
strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
|
strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
|
||||||
err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack);
|
err = snd_hda_jack_add_kctl(codec, nid, name, phantom_jack);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ static inline bool snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
|
||||||
bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
|
bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
|
||||||
|
|
||||||
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||||
const char *name);
|
const char *name, bool phantom_jack);
|
||||||
int snd_hda_jack_add_kctls(struct hda_codec *codec,
|
int snd_hda_jack_add_kctls(struct hda_codec *codec,
|
||||||
const struct auto_pin_cfg *cfg);
|
const struct auto_pin_cfg *cfg);
|
||||||
|
|
||||||
|
|
|
@ -2097,14 +2097,17 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
|
||||||
struct hdmi_spec *spec = codec->spec;
|
struct hdmi_spec *spec = codec->spec;
|
||||||
struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
|
struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
|
||||||
int pcmdev = get_pcm_rec(spec, pin_idx)->device;
|
int pcmdev = get_pcm_rec(spec, pin_idx)->device;
|
||||||
|
bool phantom_jack;
|
||||||
|
|
||||||
if (pcmdev > 0)
|
if (pcmdev > 0)
|
||||||
sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
|
sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
|
||||||
if (!is_jack_detectable(codec, per_pin->pin_nid))
|
phantom_jack = !is_jack_detectable(codec, per_pin->pin_nid);
|
||||||
|
if (phantom_jack)
|
||||||
strncat(hdmi_str, " Phantom",
|
strncat(hdmi_str, " Phantom",
|
||||||
sizeof(hdmi_str) - strlen(hdmi_str) - 1);
|
sizeof(hdmi_str) - strlen(hdmi_str) - 1);
|
||||||
|
|
||||||
return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str);
|
return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str,
|
||||||
|
phantom_jack);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int generic_hdmi_build_controls(struct hda_codec *codec)
|
static int generic_hdmi_build_controls(struct hda_codec *codec)
|
||||||
|
|
Loading…
Reference in a new issue