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

Commit 4cc9b9d6 authored by Kailang Yang's avatar Kailang Yang Committed by Takashi Iwai
Browse files

ALSA: hda/realtek - Support headset mode for ALC225



Support headset mode for ALC225 platforms.

Signed-off-by: default avatarKailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent cfc5a845
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -3662,6 +3662,16 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
		WRITE_COEF(0xb7, 0x802b),
		{}
	};
	static struct coef_fw coef0225[] = {
		UPDATE_COEF(0x4a, 1<<8, 0),
		UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
		UPDATE_COEF(0x63, 3<<14, 3<<14),
		UPDATE_COEF(0x4a, 3<<4, 2<<4),
		UPDATE_COEF(0x4a, 3<<10, 3<<10),
		UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
		UPDATE_COEF(0x4a, 3<<10, 0),
		{}
	};

	switch (codec->core.vendor_id) {
	case 0x10ec0255:
@@ -3686,6 +3696,9 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
	case 0x10ec0668:
		alc_process_coef_fw(codec, coef0668);
		break;
	case 0x10ec0225:
		alc_process_coef_fw(codec, coef0225);
		break;
	}
	codec_dbg(codec, "Headset jack set to unplugged mode.\n");
}
@@ -3731,6 +3744,13 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
		UPDATE_COEF(0xc3, 0, 1<<12),
		{}
	};
	static struct coef_fw coef0225[] = {
		UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
		UPDATE_COEF(0x4a, 3<<4, 2<<4),
		UPDATE_COEF(0x63, 3<<14, 0),
		{}
	};


	switch (codec->core.vendor_id) {
	case 0x10ec0255:
@@ -3776,6 +3796,12 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
		alc_process_coef_fw(codec, coef0688);
		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
		break;
	case 0x10ec0225:
		alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
		snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
		alc_process_coef_fw(codec, coef0225);
		snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
		break;
	}
	codec_dbg(codec, "Headset jack set to mic-in mode.\n");
}
@@ -3888,6 +3914,13 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
		WRITE_COEF(0xc3, 0x0000),
		{}
	};
	static struct coef_fw coef0225[] = {
		UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
		UPDATE_COEF(0x49, 1<<8, 1<<8),
		UPDATE_COEF(0x4a, 7<<6, 7<<6),
		UPDATE_COEF(0x4a, 3<<4, 3<<4),
		{}
	};

	switch (codec->core.vendor_id) {
	case 0x10ec0255:
@@ -3916,6 +3949,9 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
	case 0x10ec0668:
		alc_process_coef_fw(codec, coef0688);
		break;
	case 0x10ec0225:
		alc_process_coef_fw(codec, coef0225);
		break;
	}
	codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
}
@@ -3959,6 +3995,13 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
		WRITE_COEF(0xc3, 0x0000),
		{}
	};
	static struct coef_fw coef0225[] = {
		UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
		UPDATE_COEF(0x49, 1<<8, 1<<8),
		UPDATE_COEF(0x4a, 7<<6, 7<<6),
		UPDATE_COEF(0x4a, 3<<4, 3<<4),
		{}
	};

	switch (codec->core.vendor_id) {
	case 0x10ec0255:
@@ -3987,6 +4030,9 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
	case 0x10ec0668:
		alc_process_coef_fw(codec, coef0688);
		break;
	case 0x10ec0225:
		alc_process_coef_fw(codec, coef0225);
		break;
	}
	codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
}
@@ -4018,6 +4064,11 @@ static void alc_determine_headset_type(struct hda_codec *codec)
		WRITE_COEF(0xc3, 0x0c00),
		{}
	};
	static struct coef_fw coef0225[] = {
		UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
		UPDATE_COEF(0x49, 1<<8, 1<<8),
		{}
	};

	switch (codec->core.vendor_id) {
	case 0x10ec0255:
@@ -4062,6 +4113,12 @@ static void alc_determine_headset_type(struct hda_codec *codec)
		val = alc_read_coef_idx(codec, 0xbe);
		is_ctia = (val & 0x1c02) == 0x1c02;
		break;
	case 0x10ec0225:
		alc_process_coef_fw(codec, coef0225);
		msleep(800);
		val = alc_read_coef_idx(codec, 0x46);
		is_ctia = (val & 0x00f0) == 0x00f0;
		break;
	}

	codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",