Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62f949bf authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Get rid of action field from struct hda_jack_tbl



The action value assigned to each hda_jack_tbl entry is mostly
superfluous.  The actually used values are either the widget NID or a
value specific to the callback.

The former case can be simply replaced by a reference to widget NID
itself.  The only place doing the latter is STAC/IDT codec driver for
the powermap handling.  But, the code doesn't need to check the action
field at all -- the function jack_update_power() is called either with
a specific pin or with NULL.  So the check of jack->action can be
removed completely there, too.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 998052b7
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -4180,7 +4180,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
		if (!is_jack_detectable(codec, nid))
			continue;
		codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid);
		snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT,
		snd_hda_jack_detect_enable_callback(codec, nid,
						    call_hp_automute);
		spec->detect_hp = 1;
	}
@@ -4193,7 +4193,6 @@ static int check_auto_mute_availability(struct hda_codec *codec)
					continue;
				codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid);
				snd_hda_jack_detect_enable_callback(codec, nid,
								    HDA_GEN_FRONT_EVENT,
								    call_line_automute);
				spec->detect_lo = 1;
			}
@@ -4235,7 +4234,6 @@ static bool auto_mic_check_imux(struct hda_codec *codec)
	for (i = 1; i < spec->am_num_entries; i++)
		snd_hda_jack_detect_enable_callback(codec,
						    spec->am_entry[i].pin,
						    HDA_GEN_MIC_EVENT,
						    call_mic_autoswitch);
	return true;
}
+0 −6
Original line number Diff line number Diff line
@@ -12,12 +12,6 @@
#ifndef __SOUND_HDA_GENERIC_H
#define __SOUND_HDA_GENERIC_H

/* unsol event tags */
enum {
	HDA_GEN_HP_EVENT = 1, HDA_GEN_FRONT_EVENT, HDA_GEN_MIC_EVENT,
	HDA_GEN_LAST_EVENT = HDA_GEN_MIC_EVENT
};

/* table entry for multi-io paths */
struct hda_multi_io {
	hda_nid_t pin;		/* multi-io widget pin NID */
+3 −7
Original line number Diff line number Diff line
@@ -217,7 +217,6 @@ EXPORT_SYMBOL_GPL(snd_hda_jack_detect_state);
 * snd_hda_jack_detect_enable - enable the jack-detection
 */
int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
					unsigned char action,
					hda_jack_callback cb)
{
	struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid);
@@ -226,8 +225,6 @@ int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
	if (jack->jack_detect)
		return 0; /* already registered */
	jack->jack_detect = 1;
	if (action)
		jack->action = action;
	if (cb)
		jack->callback = cb;
	if (codec->jackpoll_interval > 0)
@@ -238,10 +235,9 @@ int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
}
EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable_callback);

int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
			       unsigned char action)
int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid)
{
	return snd_hda_jack_detect_enable_callback(codec, nid, action, NULL);
	return snd_hda_jack_detect_enable_callback(codec, nid, NULL);
}
EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable);

@@ -431,7 +427,7 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
		return err;

	if (!phantom_jack)
		return snd_hda_jack_detect_enable(codec, nid, 0);
		return snd_hda_jack_detect_enable(codec, nid);
	return 0;
}

+1 −21
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ typedef void (*hda_jack_callback) (struct hda_codec *, struct hda_jack_tbl *);

struct hda_jack_tbl {
	hda_nid_t nid;
	unsigned char action;		/* event action (0 = none) */
	unsigned char tag;		/* unsol event tag */
	unsigned int private_data;	/* arbitrary data */
	hda_jack_callback callback;
@@ -47,29 +46,10 @@ struct hda_jack_tbl *
snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid);
void snd_hda_jack_tbl_clear(struct hda_codec *codec);

/**
 * snd_hda_jack_get_action - get jack-tbl entry for the tag
 *
 * Call this from the unsol event handler to get the assigned action for the
 * event.  This will mark the dirty flag for the later reporting, too.
 */
static inline unsigned char
snd_hda_jack_get_action(struct hda_codec *codec, unsigned int tag)
{
	struct hda_jack_tbl *jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
	if (jack) {
		jack->jack_dirty = 1;
		return jack->action;
	}
	return 0;
}

void snd_hda_jack_set_dirty_all(struct hda_codec *codec);

int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
			       unsigned char action);
int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid);
int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
					unsigned char action,
					hda_jack_callback cb);

int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
+9 −7
Original line number Diff line number Diff line
@@ -4116,8 +4116,8 @@ static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc)

static void ca0132_init_unsol(struct hda_codec *codec)
{
	snd_hda_jack_detect_enable(codec, UNSOL_TAG_HP, UNSOL_TAG_HP);
	snd_hda_jack_detect_enable(codec, UNSOL_TAG_AMIC1, UNSOL_TAG_AMIC1);
	snd_hda_jack_detect_enable(codec, UNSOL_TAG_HP);
	snd_hda_jack_detect_enable(codec, UNSOL_TAG_AMIC1);
}

static void refresh_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir)
@@ -4406,16 +4406,18 @@ static void ca0132_process_dsp_response(struct hda_codec *codec)
static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res)
{
	struct ca0132_spec *spec = codec->spec;
	unsigned int tag = (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f;

	if (((res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f) == UNSOL_TAG_DSP) {
	if (tag == UNSOL_TAG_DSP) {
		ca0132_process_dsp_response(codec);
	} else {
		res = snd_hda_jack_get_action(codec,
				(res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f);
		struct hda_jack_tbl *jack;

		codec_dbg(codec, "snd_hda_jack_get_action: 0x%x\n", res);

		switch (res) {
		jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
		if (!jack)
			return;
		switch (jack->nid) {
		case UNSOL_TAG_HP:
			/* Delay enabling the HP amp, to let the mic-detection
			 * state machine run.
Loading