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

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

ALSA: hda - Give standard "Bass Speaker" mixer for 2.1 speakers



When two built-in speakers are found on the machine, we can suppose
it's rather a 2.1 speaker system with a bass output instead of
front/surround channels.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 17a4adbe
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ struct cs_spec {


	unsigned int hp_detect:1;
	unsigned int hp_detect:1;
	unsigned int mic_detect:1;
	unsigned int mic_detect:1;
	unsigned int speaker_2_1:1;
	/* CS421x */
	/* CS421x */
	unsigned int spdif_detect:1;
	unsigned int spdif_detect:1;
	unsigned int sense_b:1;
	unsigned int sense_b:1;
@@ -443,6 +444,9 @@ static int parse_output(struct hda_codec *codec)
	spec->multiout.dac_nids = spec->dac_nid;
	spec->multiout.dac_nids = spec->dac_nid;
	spec->multiout.max_channels = i * 2;
	spec->multiout.max_channels = i * 2;


	if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && i == 2)
		spec->speaker_2_1 = 1; /* assume 2.1 speakers */

	/* add HP and speakers */
	/* add HP and speakers */
	extra_nids = 0;
	extra_nids = 0;
	for (i = 0; i < cfg->hp_outs; i++) {
	for (i = 0; i < cfg->hp_outs; i++) {
@@ -632,7 +636,9 @@ static int add_output(struct hda_codec *codec, hda_nid_t dac, int idx,
		index = idx;
		index = idx;
		break;
		break;
	case AUTO_PIN_SPEAKER_OUT:
	case AUTO_PIN_SPEAKER_OUT:
		if (num_ctls > 1)
		if (spec->speaker_2_1)
			name = idx ? "Bass Speaker" : "Speaker";
		else if (num_ctls > 1)
			name = speakers[idx];
			name = speakers[idx];
		else
		else
			name = "Speaker";
			name = "Speaker";
+25 −3
Original line number Original line Diff line number Diff line
@@ -472,7 +472,7 @@ static const struct snd_kcontrol_new cxt_beep_mixer[] = {
#endif
#endif


static const char * const slave_pfxs[] = {
static const char * const slave_pfxs[] = {
	"Headphone", "Speaker", "Front", "Surround", "CLFE",
	"Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE",
	NULL
	NULL
};
};


@@ -4116,11 +4116,26 @@ static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac,
	return 0;
	return 0;
}
}


static bool is_2_1_speaker(struct conexant_spec *spec)
{
	int i, type, num_spk = 0;

	for (i = 0; i < spec->dac_info_filled; i++) {
		type = spec->dac_info[i].type;
		if (type == AUTO_PIN_LINE_OUT)
			type = spec->autocfg.line_out_type;
		if (type == AUTO_PIN_SPEAKER_OUT)
			num_spk++;
	}
	return (num_spk == 2 && spec->autocfg.line_out_type != AUTO_PIN_LINE_OUT);
}

static int cx_auto_build_output_controls(struct hda_codec *codec)
static int cx_auto_build_output_controls(struct hda_codec *codec)
{
{
	struct conexant_spec *spec = codec->spec;
	struct conexant_spec *spec = codec->spec;
	int i, err;
	int i, err;
	int num_line = 0, num_hp = 0, num_spk = 0;
	int num_line = 0, num_hp = 0, num_spk = 0;
	bool speaker_2_1;
	static const char * const texts[3] = { "Front", "Surround", "CLFE" };
	static const char * const texts[3] = { "Front", "Surround", "CLFE" };


	if (spec->dac_info_filled == 1)
	if (spec->dac_info_filled == 1)
@@ -4128,6 +4143,8 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
					 spec->dac_info[0].pin,
					 spec->dac_info[0].pin,
					 "Master", 0);
					 "Master", 0);


	speaker_2_1 = is_2_1_speaker(spec);

	for (i = 0; i < spec->dac_info_filled; i++) {
	for (i = 0; i < spec->dac_info_filled; i++) {
		const char *label;
		const char *label;
		int idx, type;
		int idx, type;
@@ -4146,8 +4163,13 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
			idx = num_hp++;
			idx = num_hp++;
			break;
			break;
		case AUTO_PIN_SPEAKER_OUT:
		case AUTO_PIN_SPEAKER_OUT:
			if (speaker_2_1) {
				label = num_spk++ ? "Bass Speaker" : "Speaker";
				idx = 0;
			} else {
				label = "Speaker";
				label = "Speaker";
				idx = num_spk++;
				idx = num_spk++;
			}
			break;
			break;
		}
		}
		err = try_add_pb_volume(codec, dac,
		err = try_add_pb_volume(codec, dac,
+4 −4
Original line number Original line Diff line number Diff line
@@ -1081,7 +1081,7 @@ static struct snd_kcontrol_new stac_smux_mixer = {


static const char * const slave_pfxs[] = {
static const char * const slave_pfxs[] = {
	"Front", "Surround", "Center", "LFE", "Side",
	"Front", "Surround", "Center", "LFE", "Side",
	"Headphone", "Speaker", "IEC958", "PCM",
	"Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
	NULL
	NULL
};
};


@@ -3269,9 +3269,9 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
				idx = i;
				idx = i;
				break;
				break;
			case AUTO_PIN_SPEAKER_OUT:
			case AUTO_PIN_SPEAKER_OUT:
				if (num_outs <= 1) {
				if (num_outs <= 2) {
					name = "Speaker";
					name = i ? "Bass Speaker" : "Speaker";
					idx = i;
					idx = 0;
					break;
					break;
				}
				}
				/* Fall through in case of multi speaker outs */
				/* Fall through in case of multi speaker outs */
+3 −3
Original line number Original line Diff line number Diff line
@@ -1454,7 +1454,7 @@ static const struct hda_pcm_stream via_pcm_digital_capture = {
 */
 */
static const char * const via_slave_pfxs[] = {
static const char * const via_slave_pfxs[] = {
	"Front", "Surround", "Center", "LFE", "Side",
	"Front", "Surround", "Center", "LFE", "Side",
	"Headphone", "Speaker",
	"Headphone", "Speaker", "Bass Speaker",
	NULL,
	NULL,
};
};


@@ -1969,8 +1969,8 @@ static int via_auto_create_multi_out_ctls(struct hda_codec *codec)
		} else {
		} else {
			const char *pfx = chname[i];
			const char *pfx = chname[i];
			if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
			if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
			    cfg->line_outs == 1)
			    cfg->line_outs <= 2)
				pfx = "Speaker";
				pfx = i ? "Bass Speaker" : "Speaker";
			err = create_ch_ctls(codec, pfx, 3, true, path);
			err = create_ch_ctls(codec, pfx, 3, true, path);
			if (err < 0)
			if (err < 0)
				return err;
				return err;