⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patch_conexant.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };#define CXT5045_SPDIF_OUT	0x13static struct hda_channel_mode cxt5045_modes[1] = {	{ 2, NULL },};static struct hda_input_mux cxt5045_capture_source = {	.num_items = 2,	.items = {		{ "IntMic", 0x1 },		{ "LineIn", 0x2 },	}};/* turn on/off EAPD (+ mute HP) as a master switch */static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,				    struct snd_ctl_elem_value *ucontrol){	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);	struct conexant_spec *spec = codec->spec;	unsigned int bits;	if (!cxt_eapd_put(kcontrol, ucontrol))		return 0;	/* toggle internal speakers mute depending of presence of	 * the headphone jack	 */	bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;	snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,				 HDA_AMP_MUTE, bits);	bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;	snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,				 HDA_AMP_MUTE, bits);	return 1;}/* bind volumes of both NID 0x10 and 0x11 */static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {	.ops = &snd_hda_bind_vol,	.values = {		HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),		HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),		0	},};/* toggle input of built-in and mic jack appropriately */static void cxt5045_hp_automic(struct hda_codec *codec){	static struct hda_verb mic_jack_on[] = {		{0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},		{0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},		{}	};	static struct hda_verb mic_jack_off[] = {		{0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},		{0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},		{}	};	unsigned int present;	present = snd_hda_codec_read(codec, 0x12, 0,				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;	if (present)		snd_hda_sequence_write(codec, mic_jack_on);	else		snd_hda_sequence_write(codec, mic_jack_off);}/* mute internal speaker if HP is plugged */static void cxt5045_hp_automute(struct hda_codec *codec){	struct conexant_spec *spec = codec->spec;	unsigned int bits;	spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;	bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 	snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,				 HDA_AMP_MUTE, bits);}/* unsolicited event for HP jack sensing */static void cxt5045_hp_unsol_event(struct hda_codec *codec,				   unsigned int res){	res >>= 26;	switch (res) {	case CONEXANT_HP_EVENT:		cxt5045_hp_automute(codec);		break;	case CONEXANT_MIC_EVENT:		cxt5045_hp_automic(codec);		break;	}}static struct snd_kcontrol_new cxt5045_mixers[] = {	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Capture Source",		.info = conexant_mux_enum_info,		.get = conexant_mux_enum_get,		.put = conexant_mux_enum_put	},	HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),	HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),	HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),	HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),	HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),	HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),	HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),	HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),	HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),	HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),	HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Master Playback Switch",		.info = cxt_eapd_info,		.get = cxt_eapd_get,		.put = cxt5045_hp_master_sw_put,		.private_value = 0x10,	},	{}};static struct hda_verb cxt5045_init_verbs[] = {	/* Line in, Mic */	{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },	/* HP, Amp  */	{0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},	{0x10, AC_VERB_SET_CONNECT_SEL, 0x1},	{0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},	{0x11, AC_VERB_SET_CONNECT_SEL, 0x1},	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},	/* Record selector: Int mic */	{0x1a, AC_VERB_SET_CONNECT_SEL,0x1},	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE,	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},	/* SPDIF route: PCM */	{ 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },	/* EAPD */	{0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 	{ } /* end */};static struct hda_verb cxt5045_hp_sense_init_verbs[] = {	/* pin sensing on HP jack */	{0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},	{ } /* end */};static struct hda_verb cxt5045_mic_sense_init_verbs[] = {	/* pin sensing on HP jack */	{0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},	{ } /* end */};#ifdef CONFIG_SND_DEBUG/* Test configuration for debugging, modelled after the ALC260 test * configuration. */static struct hda_input_mux cxt5045_test_capture_source = {	.num_items = 5,	.items = {		{ "MIXER", 0x0 },		{ "MIC1 pin", 0x1 },		{ "LINE1 pin", 0x2 },		{ "HP-OUT pin", 0x3 },		{ "CD pin", 0x4 },        },};static struct snd_kcontrol_new cxt5045_test_mixer[] = {	/* Output controls */	HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),	HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),	HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),	HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),	HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),	HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),		/* Modes for retasking pin widgets */	CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),	CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),	/* EAPD Switch Control */	CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),	/* Loopback mixer controls */	HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),	HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),	HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),	HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),	HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),	HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),	HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),	HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),	HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),	HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Input Source",		.info = conexant_mux_enum_info,		.get = conexant_mux_enum_get,		.put = conexant_mux_enum_put,	},	/* Audio input controls */	HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),	HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),	HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),	HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),	HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),	HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),	HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),	HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),	HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),	HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),	{ } /* end */};static struct hda_verb cxt5045_test_init_verbs[] = {	/* Set connections */	{ 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },	{ 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },	{ 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },	/* Enable retasking pins as output, initially without power amp */	{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},	{0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},	/* Disable digital (SPDIF) pins initially, but users can enable	 * them via a mixer switch.  In the case of SPDIF-out, this initverb	 * payload also sets the generation to 0, output to be in "consumer"	 * PCM format, copyright asserted, no pre-emphasis and no validity	 * control.	 */	{0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},	/* Start with output sum widgets muted and their output gains at min */	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},	/* Unmute retasking pin widget output buffers since the default	 * state appears to be output.  As the pin mode is changed by the	 * user the pin mode control will take care of enabling the pin's	 * input/output buffers as needed.	 */	{0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},	{0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},	/* Mute capture amp left and right */	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},	/* Set ADC connection select to match default mixer setting (mic1	 * pin)	 */	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},	{0x17, AC_VERB_SET_CONNECT_SEL, 0x00},	/* Mute all inputs to mixer widget (even unconnected ones) */	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */	{ }};#endif/* initialize jack-sensing, too */static int cxt5045_init(struct hda_codec *codec){	conexant_init(codec);	cxt5045_hp_automute(codec);	return 0;}enum {	CXT5045_LAPTOP,	 /* Laptops w/ EAPD support */	CXT5045_FUJITSU, /* Laptops w/ EAPD support */ #ifdef CONFIG_SND_DEBUG	CXT5045_TEST,#endif	CXT5045_MODELS};static const char *cxt5045_models[CXT5045_MODELS] = {	[CXT5045_LAPTOP]	= "laptop",	[CXT5045_FUJITSU]	= "fujitsu",#ifdef CONFIG_SND_DEBUG	[CXT5045_TEST]		= "test",#endif};static struct snd_pci_quirk cxt5045_cfg_tbl[] = {	SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),	SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP),	SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),	{}};static int patch_cxt5045(struct hda_codec *codec){	struct conexant_spec *spec;	int board_config;	spec = kzalloc(sizeof(*spec), GFP_KERNEL);	if (!spec)		return -ENOMEM;	mutex_init(&spec->amp_mutex);	codec->spec = spec;	spec->multiout.max_channels = 2;	spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);	spec->multiout.dac_nids = cxt5045_dac_nids;	spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;	spec->num_adc_nids = 1;	spec->adc_nids = cxt5045_adc_nids;	spec->capsrc_nids = cxt5045_capsrc_nids;	spec->input_mux = &cxt5045_capture_source;	spec->num_mixers = 1;	spec->mixers[0] = cxt5045_mixers;	spec->num_init_verbs = 1;	spec->init_verbs[0] = cxt5045_init_verbs;	spec->spdif_route = 0;	spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),	spec->channel_mode = cxt5045_modes,	codec->patch_ops = conexant_patch_ops;	board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,						  cxt5045_models,						  cxt5045_cfg_tbl);	switch (board_config) {	case CXT5045_LAPTOP:		codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;		spec->input_mux = &cxt5045_capture_source;		spec->num_init_verbs = 2;		spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;		spec->mixers[0] = cxt5045_mixers;		codec->patch_ops.init = cxt5045_init;		break;	case CXT5045_FUJITSU:		spec->input_mux = &cxt5045_capture_source;		spec->num_init_verbs = 2;		spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;		spec->mixers[0] = cxt5045_mixers;		codec->patch_ops.init = cxt5045_init;		break;#ifdef CONFIG_SND_DEBUG	case CXT5045_TEST:		spec->input_mux = &cxt5045_test_capture_source;		spec->mixers[0] = cxt5045_test_mixer;		spec->init_verbs[0] = cxt5045_test_init_verbs;#endif		}	return 0;}/* Conexant 5047 specific */#define CXT5047_SPDIF_OUT	0x11static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };static struct hda_channel_mode cxt5047_modes[1] = {	{ 2, NULL },};static struct hda_input_mux cxt5047_capture_source = {	.num_items = 1,	.items = {		{ "Mic", 0x2 },	}};static struct hda_input_mux cxt5047_hp_capture_source = {	.num_items = 1,	.items = {		{ "ExtMic", 0x2 },	}};static struct hda_input_mux cxt5047_toshiba_capture_source = {	.num_items = 2,	.items = {		{ "ExtMic", 0x2 },		{ "Line-In", 0x1 },	}};/* turn on/off EAPD (+ mute HP) as a master switch */static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,				    struct snd_ctl_elem_value *ucontrol){	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);	struct conexant_spec *spec = codec->spec;	unsigned int bits;	if (!cxt_eapd_put(kcontrol, ucontrol))		return 0;	/* toggle internal speakers mute depending of presence of	 * the headphone jack	 */	bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;	snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,				 HDA_AMP_MUTE, bits);	bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;	snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,				 HDA_AMP_MUTE, bits);	return 1;}/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */static struct hda_bind_ctls cxt5047_bind_master_vol = {	.ops = &snd_hda_bind_vol,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -