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

Commit b5786e85 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Keep char arrays in input_mux items



Keep char array in the input_mux item itself instead of pointing to
an external string.  This is a preliminary work for improving the
input-mux name based on the pin role.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6cb3b707
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -4662,17 +4662,8 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
};
EXPORT_SYMBOL_HDA(auto_pin_cfg_labels);

static const char *input_labels[AUTO_PIN_LAST][4] = {
	{ "Mic", "Mic 2", "Mic 3", "Mic 4" },
	{ "Front Mic", "Front Mic 2", "Front Mic 3", "Front Mic 4" },
	{ "Line", "Line 2", "Line 3", "Line 4" },
	{ "Front Line", "Front Line 2", "Front Line 3", "Front Line 4" },
	{ "CD", "CD 2", "CD 3", "CD 4" },
	{ "Aux", "Aux 2", "Aux 3", "Aux 4" },
};

const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
					int input)
void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
				 int input, char *str)
{
	int type = cfg->inputs[input].type;
	int idx;
@@ -4681,7 +4672,10 @@ const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
		if (type != cfg->inputs[input].type)
			break;
	}
	return input_labels[type][idx];
	if (idx > 0)
		sprintf(str, "%s %d", auto_pin_cfg_labels[type], idx);
	else
		strcpy(str, auto_pin_cfg_labels[type]);
}
EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label);

+1 −1
Original line number Diff line number Diff line
@@ -566,7 +566,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec,
	}
	label = spec->cap_labels[spec->input_mux.num_items];
	strcpy(label, type);
	spec->input_mux.items[spec->input_mux.num_items].label = label;
	strcpy(spec->input_mux.items[spec->input_mux.num_items].label, label);

	/* unmute the PIN external input */
	unmute_input(codec, node, 0); /* index = 0? */
+3 −3
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
 */
#define HDA_MAX_NUM_INPUTS	16
struct hda_input_mux_item {
	const char *label;
	char label[32];
	unsigned int index;
};
struct hda_input_mux {
@@ -391,8 +391,8 @@ struct auto_pin_cfg_item {
};

struct auto_pin_cfg;
const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
					int input);
void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg,
				 int input, char *label);

struct auto_pin_cfg {
	int line_outs;
+3 −3
Original line number Diff line number Diff line
@@ -2926,13 +2926,13 @@ static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
				       type <= AUTO_PIN_FRONT_MIC);
		if (err < 0)
			return err;
		imux->items[imux->num_items].label =
			snd_hda_get_input_pin_label(cfg, i);
		snd_hda_get_input_pin_label(cfg, i,
			imux->items[imux->num_items].label);
		imux->items[imux->num_items].index =
			ad1988_pin_to_adc_idx(cfg->inputs[i].pin);
		imux->num_items++;
	}
	imux->items[imux->num_items].label = "Mix";
	strcpy(imux->items[imux->num_items].label, "Mix");
	imux->items[imux->num_items].index = 9;
	imux->num_items++;

+5 −5
Original line number Diff line number Diff line
@@ -4974,8 +4974,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
		if (idx < 0 && cap2)
			idx = get_connection_index(codec, cap2, pin);
		if (idx >= 0) {
			imux->items[imux->num_items].label =
				snd_hda_get_input_pin_label(cfg, i);
			snd_hda_get_input_pin_label(cfg, i,
				imux->items[imux->num_items].label);
			imux->items[imux->num_items].index = idx;
			imux->num_items++;
		}
@@ -10626,9 +10626,9 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
			break;
		nid = cfg->inputs[i].pin;
		if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
			char label[32];
			snprintf(label, sizeof(label), "%s Boost",
				 snd_hda_get_input_pin_label(cfg, i));
			char pinname[32], label[32];
			snd_hda_get_input_pin_label(cfg, i, pinname);
			snprintf(label, sizeof(label), "%s Boost", pinname);
			err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
				  HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
			if (err < 0)
Loading