Merge branch 'topic/hda' into for-linus
This commit is contained in:
commit
9e4ce164ee
25 changed files with 1625 additions and 4723 deletions
|
@ -42,19 +42,7 @@ ALC260
|
|||
|
||||
ALC262
|
||||
======
|
||||
fujitsu Fujitsu Laptop
|
||||
benq Benq ED8
|
||||
benq-t31 Benq T31
|
||||
hippo Hippo (ATI) with jack detection, Sony UX-90s
|
||||
hippo_1 Hippo (Benq) with jack detection
|
||||
toshiba-s06 Toshiba S06
|
||||
toshiba-rx1 Toshiba RX1
|
||||
tyan Tyan Thunder n6650W (S2915-E)
|
||||
ultra Samsung Q1 Ultra Vista model
|
||||
lenovo-3000 Lenovo 3000 y410
|
||||
nec NEC Versa S9100
|
||||
basic fixed pin assignment w/o SPDIF
|
||||
auto auto-config reading BIOS (default)
|
||||
N/A
|
||||
|
||||
ALC267/268
|
||||
==========
|
||||
|
@ -350,7 +338,6 @@ STAC92HD83*
|
|||
mic-ref Reference board with power management for ports
|
||||
dell-s14 Dell laptop
|
||||
dell-vostro-3500 Dell Vostro 3500 laptop
|
||||
hp HP laptops with (inverted) mute-LED
|
||||
hp-dv7-4000 HP dv-7 4000
|
||||
auto BIOS setup (default)
|
||||
|
||||
|
|
|
@ -227,4 +227,12 @@ snd_ctl_add_slave_uncached(struct snd_kcontrol *master,
|
|||
return _snd_ctl_add_slave(master, slave, SND_CTL_SLAVE_NEED_UPDATE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper functions for jack-detection controls
|
||||
*/
|
||||
struct snd_kcontrol *
|
||||
snd_kctl_jack_new(const char *name, int idx, void *private_data);
|
||||
void snd_kctl_jack_report(struct snd_card *card,
|
||||
struct snd_kcontrol *kctl, bool status);
|
||||
|
||||
#endif /* __SOUND_CONTROL_H */
|
||||
|
|
|
@ -217,6 +217,9 @@ config SND_PCM_XRUN_DEBUG
|
|||
config SND_VMASTER
|
||||
bool
|
||||
|
||||
config SND_KCTL_JACK
|
||||
bool
|
||||
|
||||
config SND_DMA_SGBUF
|
||||
def_bool y
|
||||
depends on X86
|
||||
|
|
|
@ -7,6 +7,7 @@ snd-y := sound.o init.o memory.o info.o control.o misc.o device.o
|
|||
snd-$(CONFIG_ISA_DMA_API) += isadma.o
|
||||
snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o
|
||||
snd-$(CONFIG_SND_VMASTER) += vmaster.o
|
||||
snd-$(CONFIG_SND_KCTL_JACK) += ctljack.o
|
||||
snd-$(CONFIG_SND_JACK) += jack.o
|
||||
|
||||
snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \
|
||||
|
|
56
sound/core/ctljack.c
Normal file
56
sound/core/ctljack.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Helper functions for jack-detection kcontrols
|
||||
*
|
||||
* Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/export.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/control.h>
|
||||
|
||||
#define jack_detect_kctl_info snd_ctl_boolean_mono_info
|
||||
|
||||
static int jack_detect_kctl_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
ucontrol->value.integer.value[0] = kcontrol->private_value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_kcontrol_new jack_detect_kctl = {
|
||||
/* name is filled later */
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_CARD,
|
||||
.access = SNDRV_CTL_ELEM_ACCESS_READ,
|
||||
.info = jack_detect_kctl_info,
|
||||
.get = jack_detect_kctl_get,
|
||||
};
|
||||
|
||||
struct snd_kcontrol *
|
||||
snd_kctl_jack_new(const char *name, int idx, void *private_data)
|
||||
{
|
||||
struct snd_kcontrol *kctl;
|
||||
kctl = snd_ctl_new1(&jack_detect_kctl, private_data);
|
||||
if (!kctl)
|
||||
return NULL;
|
||||
snprintf(kctl->id.name, sizeof(kctl->id.name), "%s Jack", name);
|
||||
kctl->id.index = idx;
|
||||
kctl->private_value = 0;
|
||||
return kctl;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_kctl_jack_new);
|
||||
|
||||
void snd_kctl_jack_report(struct snd_card *card,
|
||||
struct snd_kcontrol *kctl, bool status)
|
||||
{
|
||||
if (kctl->private_value == status)
|
||||
return;
|
||||
kctl->private_value = status;
|
||||
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_kctl_jack_report);
|
|
@ -2,6 +2,7 @@ menuconfig SND_HDA_INTEL
|
|||
tristate "Intel HD Audio"
|
||||
select SND_PCM
|
||||
select SND_VMASTER
|
||||
select SND_KCTL_JACK
|
||||
help
|
||||
Say Y here to include support for Intel "High Definition
|
||||
Audio" (Azalia) and its compatible devices.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
snd-hda-intel-objs := hda_intel.o
|
||||
|
||||
snd-hda-codec-y := hda_codec.o
|
||||
snd-hda-codec-y := hda_codec.o hda_jack.o
|
||||
snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
|
||||
snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
|
||||
snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
|
||||
|
|
|
@ -1,875 +0,0 @@
|
|||
/*
|
||||
* ALC262 quirk models
|
||||
* included by patch_realtek.c
|
||||
*/
|
||||
|
||||
/* ALC262 models */
|
||||
enum {
|
||||
ALC262_AUTO,
|
||||
ALC262_BASIC,
|
||||
ALC262_HIPPO,
|
||||
ALC262_HIPPO_1,
|
||||
ALC262_FUJITSU,
|
||||
ALC262_BENQ_ED8,
|
||||
ALC262_BENQ_T31,
|
||||
ALC262_ULTRA,
|
||||
ALC262_LENOVO_3000,
|
||||
ALC262_NEC,
|
||||
ALC262_TOSHIBA_S06,
|
||||
ALC262_TOSHIBA_RX1,
|
||||
ALC262_TYAN,
|
||||
ALC262_MODEL_LAST /* last tag */
|
||||
};
|
||||
|
||||
#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
|
||||
#define ALC262_DIGIN_NID ALC880_DIGIN_NID
|
||||
|
||||
#define alc262_dac_nids alc260_dac_nids
|
||||
#define alc262_adc_nids alc882_adc_nids
|
||||
#define alc262_adc_nids_alt alc882_adc_nids_alt
|
||||
#define alc262_capsrc_nids alc882_capsrc_nids
|
||||
#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
|
||||
|
||||
#define alc262_modes alc260_modes
|
||||
#define alc262_capture_source alc882_capture_source
|
||||
|
||||
static const hda_nid_t alc262_dmic_adc_nids[1] = {
|
||||
/* ADC0 */
|
||||
0x09
|
||||
};
|
||||
|
||||
static const hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
|
||||
|
||||
static const struct snd_kcontrol_new alc262_base_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
/* bind hp and internal speaker mute (with plug check) as master switch */
|
||||
|
||||
static int alc262_hippo_master_sw_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
||||
struct alc_spec *spec = codec->spec;
|
||||
*ucontrol->value.integer.value = !spec->master_mute;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
||||
struct alc_spec *spec = codec->spec;
|
||||
int val = !*ucontrol->value.integer.value;
|
||||
|
||||
if (val == spec->master_mute)
|
||||
return 0;
|
||||
spec->master_mute = val;
|
||||
update_outputs(codec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define ALC262_HIPPO_MASTER_SWITCH \
|
||||
{ \
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
|
||||
.name = "Master Playback Switch", \
|
||||
.info = snd_ctl_boolean_mono_info, \
|
||||
.get = alc262_hippo_master_sw_get, \
|
||||
.put = alc262_hippo_master_sw_put, \
|
||||
}, \
|
||||
{ \
|
||||
.iface = NID_MAPPING, \
|
||||
.name = "Master Playback Switch", \
|
||||
.subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
|
||||
(SUBDEV_SPEAKER(0) << 16), \
|
||||
}
|
||||
|
||||
#define alc262_hp_master_sw_get alc262_hippo_master_sw_get
|
||||
#define alc262_hp_master_sw_put alc262_hippo_master_sw_put
|
||||
|
||||
static const struct snd_kcontrol_new alc262_hippo_mixer[] = {
|
||||
ALC262_HIPPO_MASTER_SWITCH,
|
||||
HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new alc262_hippo1_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
ALC262_HIPPO_MASTER_SWITCH,
|
||||
HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
/* mute/unmute internal speaker according to the hp jack and mute state */
|
||||
static void alc262_hippo_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x15;
|
||||
spec->autocfg.speaker_pins[0] = 0x14;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
static void alc262_hippo1_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x1b;
|
||||
spec->autocfg.speaker_pins[0] = 0x14;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
|
||||
static const struct snd_kcontrol_new alc262_sony_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
ALC262_HIPPO_MASTER_SWITCH,
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
ALC262_HIPPO_MASTER_SWITCH,
|
||||
HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new alc262_tyan_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_tyan_verbs[] = {
|
||||
/* Headphone automute */
|
||||
{0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
|
||||
/* P11 AUX_IN, white 4-pin connector */
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
|
||||
{0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
|
||||
{0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
|
||||
{0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
|
||||
|
||||
{}
|
||||
};
|
||||
|
||||
/* unsolicited event for HP jack sensing */
|
||||
static void alc262_tyan_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x1b;
|
||||
spec->autocfg.speaker_pins[0] = 0x15;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
|
||||
#define alc262_capture_mixer alc882_capture_mixer
|
||||
#define alc262_capture_alt_mixer alc882_capture_alt_mixer
|
||||
|
||||
/*
|
||||
* generic initialization of ADC, input mixers and output mixers
|
||||
*/
|
||||
static const struct hda_verb alc262_init_verbs[] = {
|
||||
/*
|
||||
* Unmute ADC0-2 and set the default input to mic-in
|
||||
*/
|
||||
{0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
|
||||
/* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
|
||||
* mixer widget
|
||||
* Note: PASD motherboards uses the Line In 2 as the input for
|
||||
* front panel mic (mic 2)
|
||||
*/
|
||||
/* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
|
||||
|
||||
/*
|
||||
* Set up output mixers (0x0c - 0x0e)
|
||||
*/
|
||||
/* set vol=0 to output mixers */
|
||||
{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
|
||||
{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
|
||||
{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
|
||||
/* set up input amps for analog loopback */
|
||||
/* Amp Indices: DAC = 0, mixer = 1 */
|
||||
{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
|
||||
{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
|
||||
{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
|
||||
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
|
||||
{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
|
||||
{0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
|
||||
{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
|
||||
{0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
|
||||
{0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
|
||||
|
||||
{0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
|
||||
{0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
|
||||
{0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
|
||||
{0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
|
||||
{0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
|
||||
|
||||
{0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
|
||||
|
||||
/* FIXME: use matrix-type input source selection */
|
||||
/* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
|
||||
/* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
|
||||
/* Input mixer2 */
|
||||
{0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
|
||||
{0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
|
||||
{0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
|
||||
{0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
|
||||
/* Input mixer3 */
|
||||
{0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
|
||||
{0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
|
||||
{0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
|
||||
{0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
|
||||
|
||||
{ }
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_eapd_verbs[] = {
|
||||
{0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
|
||||
{0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
|
||||
{ }
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_hippo1_unsol_verbs[] = {
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
|
||||
{0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
|
||||
|
||||
{0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_sony_unsol_verbs[] = {
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
|
||||
|
||||
{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_toshiba_s06_verbs[] = {
|
||||
{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
|
||||
{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
|
||||
{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
|
||||
{0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
|
||||
{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{}
|
||||
};
|
||||
|
||||
static void alc262_toshiba_s06_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x15;
|
||||
spec->autocfg.speaker_pins[0] = 0x14;
|
||||
spec->ext_mic_pin = 0x18;
|
||||
spec->int_mic_pin = 0x12;
|
||||
spec->auto_mic = 1;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_PIN);
|
||||
}
|
||||
|
||||
/*
|
||||
* nec model
|
||||
* 0x15 = headphone
|
||||
* 0x16 = internal speaker
|
||||
* 0x18 = external mic
|
||||
*/
|
||||
|
||||
static const struct snd_kcontrol_new alc262_nec_mixer[] = {
|
||||
HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
|
||||
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
|
||||
HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_nec_verbs[] = {
|
||||
/* Unmute Speaker */
|
||||
{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
|
||||
/* Headphone */
|
||||
{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
|
||||
|
||||
/* External mic to headphone */
|
||||
{0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
|
||||
/* External mic to speaker */
|
||||
{0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
|
||||
{}
|
||||
};
|
||||
|
||||
/*
|
||||
* fujitsu model
|
||||
* 0x14 = headphone/spdif-out, 0x15 = internal speaker,
|
||||
* 0x1b = port replicator headphone out
|
||||
*/
|
||||
|
||||
static const struct hda_verb alc262_fujitsu_unsol_verbs[] = {
|
||||
{0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
|
||||
{0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_lenovo_3000_init_verbs[] = {
|
||||
/* Front Mic pin: input vref at 50% */
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
|
||||
{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct hda_input_mux alc262_fujitsu_capture_source = {
|
||||
.num_items = 3,
|
||||
.items = {
|
||||
{ "Mic", 0x0 },
|
||||
{ "Internal Mic", 0x1 },
|
||||
{ "CD", 0x4 },
|
||||
},
|
||||
};
|
||||
|
||||
static void alc262_fujitsu_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x14;
|
||||
spec->autocfg.hp_pins[1] = 0x1b;
|
||||
spec->autocfg.speaker_pins[0] = 0x15;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
/* bind volumes of both NID 0x0c and 0x0d */
|
||||
static const struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
|
||||
.ops = &snd_hda_bind_vol,
|
||||
.values = {
|
||||
HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
|
||||
HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
|
||||
0
|
||||
},
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
|
||||
HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
|
||||
{
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
||||
.name = "Master Playback Switch",
|
||||
.subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
|
||||
.info = snd_ctl_boolean_mono_info,
|
||||
.get = alc262_hp_master_sw_get,
|
||||
.put = alc262_hp_master_sw_put,
|
||||
},
|
||||
{
|
||||
.iface = NID_MAPPING,
|
||||
.name = "Master Playback Switch",
|
||||
.private_value = 0x1b,
|
||||
},
|
||||
HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static void alc262_lenovo_3000_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x1b;
|
||||
spec->autocfg.speaker_pins[0] = 0x14;
|
||||
spec->autocfg.speaker_pins[1] = 0x16;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
|
||||
HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
|
||||
{
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
||||
.name = "Master Playback Switch",
|
||||
.subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
|
||||
.info = snd_ctl_boolean_mono_info,
|
||||
.get = alc262_hp_master_sw_get,
|
||||
.put = alc262_hp_master_sw_put,
|
||||
},
|
||||
HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
|
||||
HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
|
||||
ALC262_HIPPO_MASTER_SWITCH,
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
/* additional init verbs for Benq laptops */
|
||||
static const struct hda_verb alc262_EAPD_verbs[] = {
|
||||
{0x20, AC_VERB_SET_COEF_INDEX, 0x07},
|
||||
{0x20, AC_VERB_SET_PROC_COEF, 0x3070},
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
|
||||
|
||||
{0x20, AC_VERB_SET_COEF_INDEX, 0x07},
|
||||
{0x20, AC_VERB_SET_PROC_COEF, 0x3050},
|
||||
{}
|
||||
};
|
||||
|
||||
/* Samsung Q1 Ultra Vista model setup */
|
||||
static const struct snd_kcontrol_new alc262_ultra_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_ultra_verbs[] = {
|
||||
/* output mixer */
|
||||
{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
|
||||
{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
|
||||
{0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
|
||||
/* speaker */
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
|
||||
{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
|
||||
{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
/* HP */
|
||||
{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
|
||||
{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
/* internal mic */
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
|
||||
/* ADC, choose mic */
|
||||
{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
|
||||
{0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
|
||||
{}
|
||||
};
|
||||
|
||||
/* mute/unmute internal speaker according to the hp jack and mute state */
|
||||
static void alc262_ultra_automute(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
unsigned int mute;
|
||||
|
||||
mute = 0;
|
||||
/* auto-mute only when HP is used as HP */
|
||||
if (!spec->cur_mux[0]) {
|
||||
spec->hp_jack_present = snd_hda_jack_detect(codec, 0x15);
|
||||
if (spec->hp_jack_present)
|
||||
mute = HDA_AMP_MUTE;
|
||||
}
|
||||
/* mute/unmute internal speaker */
|
||||
snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
|
||||
HDA_AMP_MUTE, mute);
|
||||
/* mute/unmute HP */
|
||||
snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
|
||||
HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
|
||||
}
|
||||
|
||||
/* unsolicited event for HP jack sensing */
|
||||
static void alc262_ultra_unsol_event(struct hda_codec *codec,
|
||||
unsigned int res)
|
||||
{
|
||||
if ((res >> 26) != ALC_HP_EVENT)
|
||||
return;
|
||||
alc262_ultra_automute(codec);
|
||||
}
|
||||
|
||||
static const struct hda_input_mux alc262_ultra_capture_source = {
|
||||
.num_items = 2,
|
||||
.items = {
|
||||
{ "Mic", 0x1 },
|
||||
{ "Headphone", 0x7 },
|
||||
},
|
||||
};
|
||||
|
||||
static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
||||
struct alc_spec *spec = codec->spec;
|
||||
int ret;
|
||||
|
||||
ret = alc_mux_enum_put(kcontrol, ucontrol);
|
||||
if (!ret)
|
||||
return 0;
|
||||
/* reprogram the HP pin as mic or HP according to the input source */
|
||||
snd_hda_codec_write_cache(codec, 0x15, 0,
|
||||
AC_VERB_SET_PIN_WIDGET_CONTROL,
|
||||
spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
|
||||
alc262_ultra_automute(codec); /* mute/unmute HP */
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
|
||||
{
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
||||
.name = "Capture Source",
|
||||
.info = alc_mux_enum_info,
|
||||
.get = alc_mux_enum_get,
|
||||
.put = alc262_ultra_mux_enum_put,
|
||||
},
|
||||
{
|
||||
.iface = NID_MAPPING,
|
||||
.name = "Capture Source",
|
||||
.private_value = 0x15,
|
||||
},
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
|
||||
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
|
||||
{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
|
||||
{0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
|
||||
|
||||
{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
|
||||
{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
|
||||
{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
|
||||
|
||||
{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
|
||||
{0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
|
||||
{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{}
|
||||
};
|
||||
|
||||
/*
|
||||
* configuration and preset
|
||||
*/
|
||||
static const char * const alc262_models[ALC262_MODEL_LAST] = {
|
||||
[ALC262_BASIC] = "basic",
|
||||
[ALC262_HIPPO] = "hippo",
|
||||
[ALC262_HIPPO_1] = "hippo_1",
|
||||
[ALC262_FUJITSU] = "fujitsu",
|
||||
[ALC262_BENQ_ED8] = "benq",
|
||||
[ALC262_BENQ_T31] = "benq-t31",
|
||||
[ALC262_TOSHIBA_S06] = "toshiba-s06",
|
||||
[ALC262_TOSHIBA_RX1] = "toshiba-rx1",
|
||||
[ALC262_ULTRA] = "ultra",
|
||||
[ALC262_LENOVO_3000] = "lenovo-3000",
|
||||
[ALC262_NEC] = "nec",
|
||||
[ALC262_TYAN] = "tyan",
|
||||
[ALC262_AUTO] = "auto",
|
||||
};
|
||||
|
||||
static const struct snd_pci_quirk alc262_cfg_tbl[] = {
|
||||
SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
|
||||
SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
|
||||
SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
|
||||
ALC262_TOSHIBA_RX1),
|
||||
SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
|
||||
SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
|
||||
SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
|
||||
SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
|
||||
SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
|
||||
ALC262_ULTRA),
|
||||
SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
|
||||
SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
|
||||
SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
|
||||
SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
|
||||
SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct alc_config_preset alc262_presets[] = {
|
||||
[ALC262_BASIC] = {
|
||||
.mixers = { alc262_base_mixer },
|
||||
.init_verbs = { alc262_init_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
},
|
||||
[ALC262_HIPPO] = {
|
||||
.mixers = { alc262_hippo_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.dig_out_nid = ALC262_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_hippo_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_HIPPO_1] = {
|
||||
.mixers = { alc262_hippo1_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x02,
|
||||
.dig_out_nid = ALC262_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_hippo1_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_FUJITSU] = {
|
||||
.mixers = { alc262_fujitsu_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
|
||||
alc262_fujitsu_unsol_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.dig_out_nid = ALC262_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_fujitsu_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_fujitsu_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_BENQ_ED8] = {
|
||||
.mixers = { alc262_base_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
},
|
||||
[ALC262_BENQ_T31] = {
|
||||
.mixers = { alc262_benq_t31_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
|
||||
alc_hp15_unsol_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_hippo_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_ULTRA] = {
|
||||
.mixers = { alc262_ultra_mixer },
|
||||
.cap_mixer = alc262_ultra_capture_mixer,
|
||||
.init_verbs = { alc262_ultra_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_ultra_capture_source,
|
||||
.adc_nids = alc262_adc_nids, /* ADC0 */
|
||||
.capsrc_nids = alc262_capsrc_nids,
|
||||
.num_adc_nids = 1, /* single ADC */
|
||||
.unsol_event = alc262_ultra_unsol_event,
|
||||
.init_hook = alc262_ultra_automute,
|
||||
},
|
||||
[ALC262_LENOVO_3000] = {
|
||||
.mixers = { alc262_lenovo_3000_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
|
||||
alc262_lenovo_3000_unsol_verbs,
|
||||
alc262_lenovo_3000_init_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.dig_out_nid = ALC262_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_fujitsu_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_lenovo_3000_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_NEC] = {
|
||||
.mixers = { alc262_nec_mixer },
|
||||
.init_verbs = { alc262_nec_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
},
|
||||
[ALC262_TOSHIBA_S06] = {
|
||||
.mixers = { alc262_toshiba_s06_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
|
||||
alc262_eapd_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.capsrc_nids = alc262_dmic_capsrc_nids,
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.adc_nids = alc262_dmic_adc_nids, /* ADC0 */
|
||||
.num_adc_nids = 1, /* single ADC */
|
||||
.dig_out_nid = ALC262_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_toshiba_s06_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_TOSHIBA_RX1] = {
|
||||
.mixers = { alc262_toshiba_rx1_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x03,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_hippo_setup,
|
||||
.init_hook = alc_inithook,
|
||||
},
|
||||
[ALC262_TYAN] = {
|
||||
.mixers = { alc262_tyan_mixer },
|
||||
.init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
|
||||
.num_dacs = ARRAY_SIZE(alc262_dac_nids),
|
||||
.dac_nids = alc262_dac_nids,
|
||||
.hp_nid = 0x02,
|
||||
.dig_out_nid = ALC262_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc262_modes),
|
||||
.channel_mode = alc262_modes,
|
||||
.input_mux = &alc262_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc262_tyan_setup,
|
||||
.init_hook = alc_hp_automute,
|
||||
},
|
||||
};
|
||||
|
|
@ -26,8 +26,6 @@ enum {
|
|||
ALC880_CLEVO,
|
||||
ALC880_TCL_S700,
|
||||
ALC880_LG,
|
||||
ALC880_LG_LW,
|
||||
ALC880_MEDION_RIM,
|
||||
#ifdef CONFIG_SND_DEBUG
|
||||
ALC880_TEST,
|
||||
#endif
|
||||
|
@ -1052,163 +1050,6 @@ static void alc880_lg_setup(struct hda_codec *codec)
|
|||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
/*
|
||||
* LG LW20
|
||||
*
|
||||
* Pin assignment:
|
||||
* Speaker-out: 0x14
|
||||
* Mic-In: 0x18
|
||||
* Built-in Mic-In: 0x19
|
||||
* Line-In: 0x1b
|
||||
* HP-Out: 0x1a
|
||||
* SPDIF-Out: 0x1e
|
||||
*/
|
||||
|
||||
static const struct hda_input_mux alc880_lg_lw_capture_source = {
|
||||
.num_items = 3,
|
||||
.items = {
|
||||
{ "Mic", 0x0 },
|
||||
{ "Internal Mic", 0x1 },
|
||||
{ "Line In", 0x2 },
|
||||
},
|
||||
};
|
||||
|
||||
#define alc880_lg_lw_modes alc880_threestack_modes
|
||||
|
||||
static const struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
|
||||
HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
|
||||
HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
|
||||
HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
|
||||
HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
|
||||
{
|
||||
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
||||
.name = "Channel Mode",
|
||||
.info = alc_ch_mode_info,
|
||||
.get = alc_ch_mode_get,
|
||||
.put = alc_ch_mode_put,
|
||||
},
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_verb alc880_lg_lw_init_verbs[] = {
|
||||
{0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
|
||||
{0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
|
||||
{0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
|
||||
|
||||
/* set capture source to mic-in */
|
||||
{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
|
||||
{0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
|
||||
/* speaker-out */
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
/* HP-out */
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
/* mic-in to input */
|
||||
{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
|
||||
{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
/* built-in mic */
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
|
||||
{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
/* jack sense */
|
||||
{0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{ }
|
||||
};
|
||||
|
||||
/* toggle speaker-output according to the hp-jack state */
|
||||
static void alc880_lg_lw_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x1b;
|
||||
spec->autocfg.speaker_pins[0] = 0x14;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
|
||||
HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
|
||||
HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
|
||||
HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
|
||||
HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
|
||||
{ } /* end */
|
||||
};
|
||||
|
||||
static const struct hda_input_mux alc880_medion_rim_capture_source = {
|
||||
.num_items = 2,
|
||||
.items = {
|
||||
{ "Mic", 0x0 },
|
||||
{ "Internal Mic", 0x1 },
|
||||
},
|
||||
};
|
||||
|
||||
static const struct hda_verb alc880_medion_rim_init_verbs[] = {
|
||||
{0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
|
||||
|
||||
{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
|
||||
/* Mic1 (rear panel) pin widget for input and vref at 80% */
|
||||
{0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
|
||||
{0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
|
||||
/* Mic2 (as headphone out) for HP output */
|
||||
{0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
|
||||
{0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
|
||||
/* Internal Speaker */
|
||||
{0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
|
||||
{0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
|
||||
|
||||
{0x20, AC_VERB_SET_COEF_INDEX, 0x07},
|
||||
{0x20, AC_VERB_SET_PROC_COEF, 0x3060},
|
||||
|
||||
{0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
|
||||
{ }
|
||||
};
|
||||
|
||||
/* toggle speaker-output according to the hp-jack state */
|
||||
static void alc880_medion_rim_automute(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
alc_hp_automute(codec);
|
||||
/* toggle EAPD */
|
||||
if (spec->hp_jack_present)
|
||||
snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
|
||||
else
|
||||
snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
|
||||
}
|
||||
|
||||
static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
|
||||
unsigned int res)
|
||||
{
|
||||
/* Looks like the unsol event is incompatible with the standard
|
||||
* definition. 4bit tag is placed at 28 bit!
|
||||
*/
|
||||
if ((res >> 28) == ALC_HP_EVENT)
|
||||
alc880_medion_rim_automute(codec);
|
||||
}
|
||||
|
||||
static void alc880_medion_rim_setup(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
spec->autocfg.hp_pins[0] = 0x14;
|
||||
spec->autocfg.speaker_pins[0] = 0x1b;
|
||||
alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
static const struct hda_amp_list alc880_lg_loopbacks[] = {
|
||||
{ 0x0b, HDA_INPUT, 1 },
|
||||
|
@ -1505,8 +1346,6 @@ static const char * const alc880_models[ALC880_MODEL_LAST] = {
|
|||
[ALC880_FUJITSU] = "fujitsu",
|
||||
[ALC880_F1734] = "F1734",
|
||||
[ALC880_LG] = "lg",
|
||||
[ALC880_LG_LW] = "lg-lw",
|
||||
[ALC880_MEDION_RIM] = "medion",
|
||||
#ifdef CONFIG_SND_DEBUG
|
||||
[ALC880_TEST] = "test",
|
||||
#endif
|
||||
|
@ -1557,18 +1396,15 @@ static const struct snd_pci_quirk alc880_cfg_tbl[] = {
|
|||
SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
|
||||
SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
|
||||
SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
|
||||
SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
|
||||
SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
|
||||
SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
|
||||
SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
|
||||
SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
|
||||
SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
|
||||
SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
|
||||
SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
|
||||
SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
|
||||
SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
|
||||
SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
|
||||
SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
|
||||
SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
|
||||
SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
|
||||
SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
|
||||
|
@ -1848,35 +1684,6 @@ static const struct alc_config_preset alc880_presets[] = {
|
|||
.loopbacks = alc880_lg_loopbacks,
|
||||
#endif
|
||||
},
|
||||
[ALC880_LG_LW] = {
|
||||
.mixers = { alc880_lg_lw_mixer },
|
||||
.init_verbs = { alc880_volume_init_verbs,
|
||||
alc880_lg_lw_init_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc880_dac_nids),
|
||||
.dac_nids = alc880_dac_nids,
|
||||
.dig_out_nid = ALC880_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
|
||||
.channel_mode = alc880_lg_lw_modes,
|
||||
.input_mux = &alc880_lg_lw_capture_source,
|
||||
.unsol_event = alc_sku_unsol_event,
|
||||
.setup = alc880_lg_lw_setup,
|
||||
.init_hook = alc_hp_automute,
|
||||
},
|
||||
[ALC880_MEDION_RIM] = {
|
||||
.mixers = { alc880_medion_rim_mixer },
|
||||
.init_verbs = { alc880_volume_init_verbs,
|
||||
alc880_medion_rim_init_verbs,
|
||||
alc_gpio2_init_verbs },
|
||||
.num_dacs = ARRAY_SIZE(alc880_dac_nids),
|
||||
.dac_nids = alc880_dac_nids,
|
||||
.dig_out_nid = ALC880_DIGOUT_NID,
|
||||
.num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
|
||||
.channel_mode = alc880_2_jack_modes,
|
||||
.input_mux = &alc880_medion_rim_capture_source,
|
||||
.unsol_event = alc880_medion_rim_unsol_event,
|
||||
.setup = alc880_medion_rim_setup,
|
||||
.init_hook = alc880_medion_rim_automute,
|
||||
},
|
||||
#ifdef CONFIG_SND_DEBUG
|
||||
[ALC880_TEST] = {
|
||||
.mixers = { alc880_test_mixer },
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,6 +33,7 @@
|
|||
#include <sound/jack.h>
|
||||
#include "hda_local.h"
|
||||
#include "hda_beep.h"
|
||||
#include "hda_jack.h"
|
||||
#include <sound/hda_hwdep.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
|
@ -1723,43 +1724,6 @@ int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
|
|||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_override_pin_caps);
|
||||
|
||||
/**
|
||||
* snd_hda_pin_sense - execute pin sense measurement
|
||||
* @codec: the CODEC to sense
|
||||
* @nid: the pin NID to sense
|
||||
*
|
||||
* Execute necessary pin sense measurement and return its Presence Detect,
|
||||
* Impedance, ELD Valid etc. status bits.
|
||||
*/
|
||||
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
u32 pincap;
|
||||
|
||||
if (!codec->no_trigger_sense) {
|
||||
pincap = snd_hda_query_pin_caps(codec, nid);
|
||||
if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
|
||||
snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_SET_PIN_SENSE, 0);
|
||||
}
|
||||
return snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0);
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_pin_sense);
|
||||
|
||||
/**
|
||||
* snd_hda_jack_detect - query pin Presence Detect status
|
||||
* @codec: the CODEC to sense
|
||||
* @nid: the pin NID to sense
|
||||
*
|
||||
* Query and return the pin's Presence Detect status.
|
||||
*/
|
||||
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
u32 sense = snd_hda_pin_sense(codec, nid);
|
||||
return !!(sense & AC_PINSENSE_PRESENCE);
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
|
||||
|
||||
/*
|
||||
* read the current volume to info
|
||||
* if the cache exists, read the cache value.
|
||||
|
@ -2308,6 +2272,7 @@ int snd_hda_codec_reset(struct hda_codec *codec)
|
|||
}
|
||||
if (codec->patch_ops.free)
|
||||
codec->patch_ops.free(codec);
|
||||
snd_hda_jack_tbl_clear(codec);
|
||||
codec->proc_widget_hook = NULL;
|
||||
codec->spec = NULL;
|
||||
free_hda_cache(&codec->amp_cache);
|
||||
|
@ -3364,6 +3329,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
|
|||
restore_pincfgs(codec); /* restore all current pin configs */
|
||||
restore_shutup_pins(codec);
|
||||
hda_exec_init_verbs(codec);
|
||||
snd_hda_jack_set_dirty_all(codec);
|
||||
if (codec->patch_ops.resume)
|
||||
codec->patch_ops.resume(codec);
|
||||
else {
|
||||
|
@ -3850,6 +3816,12 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
|
|||
if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))
|
||||
return audio_idx[type][i];
|
||||
|
||||
/* non-fixed slots starting from 10 */
|
||||
for (i = 10; i < 32; i++) {
|
||||
if (!test_and_set_bit(i, bus->pcm_dev_bits))
|
||||
return i;
|
||||
}
|
||||
|
||||
snd_printk(KERN_WARNING "Too many %s devices\n",
|
||||
snd_hda_pcm_type_name[type]);
|
||||
return -EAGAIN;
|
||||
|
@ -5004,8 +4976,8 @@ EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr);
|
|||
* "Rear", "Internal".
|
||||
*/
|
||||
|
||||
const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
|
||||
int check_location)
|
||||
static const char *hda_get_input_pin_label(struct hda_codec *codec,
|
||||
hda_nid_t pin, bool check_location)
|
||||
{
|
||||
unsigned int def_conf;
|
||||
static const char * const mic_names[] = {
|
||||
|
@ -5044,7 +5016,6 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
|
|||
return "Misc";
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(hda_get_input_pin_label);
|
||||
|
||||
/* Check whether the location prefix needs to be added to the label.
|
||||
* If all mic-jacks are in the same location (e.g. rear panel), we don't
|
||||
|
@ -5101,6 +5072,149 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
|
|||
}
|
||||
EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
|
||||
|
||||
/* return the position of NID in the list, or -1 if not found */
|
||||
static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nums; i++)
|
||||
if (list[i] == nid)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get a unique suffix or an index number */
|
||||
static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
|
||||
int num_pins, int *indexp)
|
||||
{
|
||||
static const char * const channel_sfx[] = {
|
||||
" Front", " Surround", " CLFE", " Side"
|
||||
};
|
||||
int i;
|
||||
|
||||
i = find_idx_in_nid_list(nid, pins, num_pins);
|
||||
if (i < 0)
|
||||
return NULL;
|
||||
if (num_pins == 1)
|
||||
return "";
|
||||
if (num_pins > ARRAY_SIZE(channel_sfx)) {
|
||||
if (indexp)
|
||||
*indexp = i;
|
||||
return "";
|
||||
}
|
||||
return channel_sfx[i];
|
||||
}
|
||||
|
||||
static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
|
||||
const struct auto_pin_cfg *cfg,
|
||||
const char *name, char *label, int maxlen,
|
||||
int *indexp)
|
||||
{
|
||||
unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
|
||||
int attr = snd_hda_get_input_pin_attr(def_conf);
|
||||
const char *pfx = "", *sfx = "";
|
||||
|
||||
/* handle as a speaker if it's a fixed line-out */
|
||||
if (!strcmp(name, "Line-Out") && attr == INPUT_PIN_ATTR_INT)
|
||||
name = "Speaker";
|
||||
/* check the location */
|
||||
switch (attr) {
|
||||
case INPUT_PIN_ATTR_DOCK:
|
||||
pfx = "Dock ";
|
||||
break;
|
||||
case INPUT_PIN_ATTR_FRONT:
|
||||
pfx = "Front ";
|
||||
break;
|
||||
}
|
||||
if (cfg) {
|
||||
/* try to give a unique suffix if needed */
|
||||
sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs,
|
||||
indexp);
|
||||
if (!sfx)
|
||||
sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs,
|
||||
indexp);
|
||||
if (!sfx) {
|
||||
/* don't add channel suffix for Headphone controls */
|
||||
int idx = find_idx_in_nid_list(nid, cfg->hp_pins,
|
||||
cfg->hp_outs);
|
||||
if (idx >= 0)
|
||||
*indexp = idx;
|
||||
sfx = "";
|
||||
}
|
||||
}
|
||||
snprintf(label, maxlen, "%s%s%s", pfx, name, sfx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_hda_get_pin_label - Get a label for the given I/O pin
|
||||
*
|
||||
* Get a label for the given pin. This function works for both input and
|
||||
* output pins. When @cfg is given as non-NULL, the function tries to get
|
||||
* an optimized label using hda_get_autocfg_input_label().
|
||||
*
|
||||
* This function tries to give a unique label string for the pin as much as
|
||||
* possible. For example, when the multiple line-outs are present, it adds
|
||||
* the channel suffix like "Front", "Surround", etc (only when @cfg is given).
|
||||
* If no unique name with a suffix is available and @indexp is non-NULL, the
|
||||
* index number is stored in the pointer.
|
||||
*/
|
||||
int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
|
||||
const struct auto_pin_cfg *cfg,
|
||||
char *label, int maxlen, int *indexp)
|
||||
{
|
||||
unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
|
||||
const char *name = NULL;
|
||||
int i;
|
||||
|
||||
if (indexp)
|
||||
*indexp = 0;
|
||||
if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
|
||||
return 0;
|
||||
|
||||
switch (get_defcfg_device(def_conf)) {
|
||||
case AC_JACK_LINE_OUT:
|
||||
return fill_audio_out_name(codec, nid, cfg, "Line-Out",
|
||||
label, maxlen, indexp);
|
||||
case AC_JACK_SPEAKER:
|
||||
return fill_audio_out_name(codec, nid, cfg, "Speaker",
|
||||
label, maxlen, indexp);
|
||||
case AC_JACK_HP_OUT:
|
||||
return fill_audio_out_name(codec, nid, cfg, "Headphone",
|
||||
label, maxlen, indexp);
|
||||
case AC_JACK_SPDIF_OUT:
|
||||
case AC_JACK_DIG_OTHER_OUT:
|
||||
if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
|
||||
name = "HDMI";
|
||||
else
|
||||
name = "SPDIF";
|
||||
if (cfg && indexp) {
|
||||
i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
|
||||
cfg->dig_outs);
|
||||
if (i >= 0)
|
||||
*indexp = i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (cfg) {
|
||||
for (i = 0; i < cfg->num_inputs; i++) {
|
||||
if (cfg->inputs[i].pin != nid)
|
||||
continue;
|
||||
name = hda_get_autocfg_input_label(codec, cfg, i);
|
||||
if (name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!name)
|
||||
name = hda_get_input_pin_label(codec, nid, true);
|
||||
break;
|
||||
}
|
||||
if (!name)
|
||||
return 0;
|
||||
strlcpy(label, name, maxlen);
|
||||
return 1;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_get_pin_label);
|
||||
|
||||
/**
|
||||
* snd_hda_add_imux_item - Add an item to input_mux
|
||||
*
|
||||
|
@ -5252,113 +5366,5 @@ void snd_print_pcm_bits(int pcm, char *buf, int buflen)
|
|||
}
|
||||
EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
|
||||
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
/*
|
||||
* Input-jack notification support
|
||||
*/
|
||||
struct hda_jack_item {
|
||||
hda_nid_t nid;
|
||||
int type;
|
||||
struct snd_jack *jack;
|
||||
};
|
||||
|
||||
static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid,
|
||||
int type)
|
||||
{
|
||||
switch (type) {
|
||||
case SND_JACK_HEADPHONE:
|
||||
return "Headphone";
|
||||
case SND_JACK_MICROPHONE:
|
||||
return "Mic";
|
||||
case SND_JACK_LINEOUT:
|
||||
return "Line-out";
|
||||
case SND_JACK_LINEIN:
|
||||
return "Line-in";
|
||||
case SND_JACK_HEADSET:
|
||||
return "Headset";
|
||||
case SND_JACK_VIDEOOUT:
|
||||
return "HDMI/DP";
|
||||
default:
|
||||
return "Misc";
|
||||
}
|
||||
}
|
||||
|
||||
static void hda_free_jack_priv(struct snd_jack *jack)
|
||||
{
|
||||
struct hda_jack_item *jacks = jack->private_data;
|
||||
jacks->nid = 0;
|
||||
jacks->jack = NULL;
|
||||
}
|
||||
|
||||
int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
|
||||
const char *name)
|
||||
{
|
||||
struct hda_jack_item *jack;
|
||||
int err;
|
||||
|
||||
snd_array_init(&codec->jacks, sizeof(*jack), 32);
|
||||
jack = snd_array_new(&codec->jacks);
|
||||
if (!jack)
|
||||
return -ENOMEM;
|
||||
|
||||
jack->nid = nid;
|
||||
jack->type = type;
|
||||
if (!name)
|
||||
name = get_jack_default_name(codec, nid, type);
|
||||
err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
|
||||
if (err < 0) {
|
||||
jack->nid = 0;
|
||||
return err;
|
||||
}
|
||||
jack->jack->private_data = jack;
|
||||
jack->jack->private_free = hda_free_jack_priv;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_input_jack_add);
|
||||
|
||||
void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
struct hda_jack_item *jacks = codec->jacks.list;
|
||||
int i;
|
||||
|
||||
if (!jacks)
|
||||
return;
|
||||
|
||||
for (i = 0; i < codec->jacks.used; i++, jacks++) {
|
||||
unsigned int pin_ctl;
|
||||
unsigned int present;
|
||||
int type;
|
||||
|
||||
if (jacks->nid != nid)
|
||||
continue;
|
||||
present = snd_hda_jack_detect(codec, nid);
|
||||
type = jacks->type;
|
||||
if (type == (SND_JACK_HEADPHONE | SND_JACK_LINEOUT)) {
|
||||
pin_ctl = snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
|
||||
type = (pin_ctl & AC_PINCTL_HP_EN) ?
|
||||
SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
|
||||
}
|
||||
snd_jack_report(jacks->jack, present ? type : 0);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_input_jack_report);
|
||||
|
||||
/* free jack instances manually when clearing/reconfiguring */
|
||||
void snd_hda_input_jack_free(struct hda_codec *codec)
|
||||
{
|
||||
if (!codec->bus->shutdown && codec->jacks.list) {
|
||||
struct hda_jack_item *jacks = codec->jacks.list;
|
||||
int i;
|
||||
for (i = 0; i < codec->jacks.used; i++, jacks++) {
|
||||
if (jacks->jack)
|
||||
snd_device_free(codec->bus->card, jacks->jack);
|
||||
}
|
||||
}
|
||||
snd_array_free(&codec->jacks);
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_input_jack_free);
|
||||
#endif /* CONFIG_SND_HDA_INPUT_JACK */
|
||||
|
||||
MODULE_DESCRIPTION("HDA codec core");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -547,9 +547,6 @@ enum {
|
|||
/* max. codec address */
|
||||
#define HDA_MAX_CODEC_ADDRESS 0x0f
|
||||
|
||||
/* max number of PCM devics per card */
|
||||
#define HDA_MAX_PCMS 10
|
||||
|
||||
/*
|
||||
* generic arrays
|
||||
*/
|
||||
|
@ -869,6 +866,9 @@ struct hda_codec {
|
|||
void (*proc_widget_hook)(struct snd_info_buffer *buffer,
|
||||
struct hda_codec *codec, hda_nid_t nid);
|
||||
|
||||
/* jack detection */
|
||||
struct snd_array jacktbl;
|
||||
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
/* jack detection */
|
||||
struct snd_array jacks;
|
||||
|
|
|
@ -407,6 +407,14 @@ struct azx_rb {
|
|||
u32 res[AZX_MAX_CODECS]; /* last read value */
|
||||
};
|
||||
|
||||
struct azx_pcm {
|
||||
struct azx *chip;
|
||||
struct snd_pcm *pcm;
|
||||
struct hda_codec *codec;
|
||||
struct hda_pcm_stream *hinfo[2];
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
struct azx {
|
||||
struct snd_card *card;
|
||||
struct pci_dev *pci;
|
||||
|
@ -434,7 +442,7 @@ struct azx {
|
|||
struct azx_dev *azx_dev;
|
||||
|
||||
/* PCM */
|
||||
struct snd_pcm *pcm[HDA_MAX_PCMS];
|
||||
struct list_head pcm_list; /* azx_pcm list */
|
||||
|
||||
/* HD codec */
|
||||
unsigned short codec_mask;
|
||||
|
@ -479,6 +487,7 @@ enum {
|
|||
AZX_DRIVER_SCH,
|
||||
AZX_DRIVER_ATI,
|
||||
AZX_DRIVER_ATIHDMI,
|
||||
AZX_DRIVER_ATIHDMI_NS,
|
||||
AZX_DRIVER_VIA,
|
||||
AZX_DRIVER_SIS,
|
||||
AZX_DRIVER_ULI,
|
||||
|
@ -525,6 +534,7 @@ static char *driver_short_names[] __devinitdata = {
|
|||
[AZX_DRIVER_SCH] = "HDA Intel MID",
|
||||
[AZX_DRIVER_ATI] = "HDA ATI SB",
|
||||
[AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
|
||||
[AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
|
||||
[AZX_DRIVER_VIA] = "HDA VIA VT82xx",
|
||||
[AZX_DRIVER_SIS] = "HDA SIS966",
|
||||
[AZX_DRIVER_ULI] = "HDA ULI M5461",
|
||||
|
@ -1143,16 +1153,6 @@ static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
|
|||
|
||||
static void azx_init_pci(struct azx *chip)
|
||||
{
|
||||
/* force to non-snoop mode for a new VIA controller when BIOS is set */
|
||||
if (chip->snoop && chip->driver_type == AZX_DRIVER_VIA) {
|
||||
u8 snoop;
|
||||
pci_read_config_byte(chip->pci, 0x42, &snoop);
|
||||
if (!(snoop & 0x80) && chip->pci->revision == 0x30) {
|
||||
chip->snoop = 0;
|
||||
snd_printdd(SFX "Force to non-snoop mode\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
|
||||
* TCSEL == Traffic Class Select Register, which sets PCI express QOS
|
||||
* Ensuring these bits are 0 clears playback static on some HD Audio
|
||||
|
@ -1486,10 +1486,9 @@ static void azx_bus_reset(struct hda_bus *bus)
|
|||
azx_init_chip(chip, 1);
|
||||
#ifdef CONFIG_PM
|
||||
if (chip->initialized) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < HDA_MAX_PCMS; i++)
|
||||
snd_pcm_suspend_all(chip->pcm[i]);
|
||||
struct azx_pcm *p;
|
||||
list_for_each_entry(p, &chip->pcm_list, list)
|
||||
snd_pcm_suspend_all(p->pcm);
|
||||
snd_hda_suspend(chip->bus);
|
||||
snd_hda_resume(chip->bus);
|
||||
}
|
||||
|
@ -1667,12 +1666,6 @@ static struct snd_pcm_hardware azx_pcm_hw = {
|
|||
.fifo_size = 0,
|
||||
};
|
||||
|
||||
struct azx_pcm {
|
||||
struct azx *chip;
|
||||
struct hda_codec *codec;
|
||||
struct hda_pcm_stream *hinfo[2];
|
||||
};
|
||||
|
||||
static int azx_pcm_open(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
||||
|
@ -2197,7 +2190,7 @@ static void azx_pcm_free(struct snd_pcm *pcm)
|
|||
{
|
||||
struct azx_pcm *apcm = pcm->private_data;
|
||||
if (apcm) {
|
||||
apcm->chip->pcm[pcm->device] = NULL;
|
||||
list_del(&apcm->list);
|
||||
kfree(apcm);
|
||||
}
|
||||
}
|
||||
|
@ -2215,14 +2208,11 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
|
|||
unsigned int size;
|
||||
int s, err;
|
||||
|
||||
if (pcm_dev >= HDA_MAX_PCMS) {
|
||||
snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n",
|
||||
pcm_dev);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (chip->pcm[pcm_dev]) {
|
||||
snd_printk(KERN_ERR SFX "PCM %d already exists\n", pcm_dev);
|
||||
return -EBUSY;
|
||||
list_for_each_entry(apcm, &chip->pcm_list, list) {
|
||||
if (apcm->pcm->device == pcm_dev) {
|
||||
snd_printk(KERN_ERR SFX "PCM %d already exists\n", pcm_dev);
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
|
||||
cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
|
||||
|
@ -2235,12 +2225,13 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
|
|||
if (apcm == NULL)
|
||||
return -ENOMEM;
|
||||
apcm->chip = chip;
|
||||
apcm->pcm = pcm;
|
||||
apcm->codec = codec;
|
||||
pcm->private_data = apcm;
|
||||
pcm->private_free = azx_pcm_free;
|
||||
if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
|
||||
pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
|
||||
chip->pcm[pcm_dev] = pcm;
|
||||
list_add_tail(&apcm->list, &chip->pcm_list);
|
||||
cpcm->pcm = pcm;
|
||||
for (s = 0; s < 2; s++) {
|
||||
apcm->hinfo[s] = &cpcm->stream[s];
|
||||
|
@ -2370,12 +2361,12 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
|
|||
{
|
||||
struct snd_card *card = pci_get_drvdata(pci);
|
||||
struct azx *chip = card->private_data;
|
||||
int i;
|
||||
struct azx_pcm *p;
|
||||
|
||||
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
|
||||
azx_clear_irq_pending(chip);
|
||||
for (i = 0; i < HDA_MAX_PCMS; i++)
|
||||
snd_pcm_suspend_all(chip->pcm[i]);
|
||||
list_for_each_entry(p, &chip->pcm_list, list)
|
||||
snd_pcm_suspend_all(p->pcm);
|
||||
if (chip->initialized)
|
||||
snd_hda_suspend(chip->bus);
|
||||
azx_stop_chip(chip);
|
||||
|
@ -2502,7 +2493,6 @@ static int azx_dev_free(struct snd_device *device)
|
|||
static struct snd_pci_quirk position_fix_list[] __devinitdata = {
|
||||
SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB),
|
||||
SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB),
|
||||
SND_PCI_QUIRK(0x1028, 0x02c6, "Dell Inspiron 1010", POS_FIX_LPIB),
|
||||
SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB),
|
||||
SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
|
||||
SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB),
|
||||
|
@ -2633,6 +2623,35 @@ static void __devinit check_msi(struct azx *chip)
|
|||
}
|
||||
}
|
||||
|
||||
/* check the snoop mode availability */
|
||||
static void __devinit azx_check_snoop_available(struct azx *chip)
|
||||
{
|
||||
bool snoop = chip->snoop;
|
||||
|
||||
switch (chip->driver_type) {
|
||||
case AZX_DRIVER_VIA:
|
||||
/* force to non-snoop mode for a new VIA controller
|
||||
* when BIOS is set
|
||||
*/
|
||||
if (snoop) {
|
||||
u8 val;
|
||||
pci_read_config_byte(chip->pci, 0x42, &val);
|
||||
if (!(val & 0x80) && chip->pci->revision == 0x30)
|
||||
snoop = false;
|
||||
}
|
||||
break;
|
||||
case AZX_DRIVER_ATIHDMI_NS:
|
||||
/* new ATI HDMI requires non-snoop */
|
||||
snoop = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (snoop != chip->snoop) {
|
||||
snd_printk(KERN_INFO SFX "Force to %s mode\n",
|
||||
snoop ? "snoop" : "non-snoop");
|
||||
chip->snoop = snoop;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* constructor
|
||||
|
@ -2671,6 +2690,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
|
|||
check_msi(chip);
|
||||
chip->dev_index = dev;
|
||||
INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work);
|
||||
INIT_LIST_HEAD(&chip->pcm_list);
|
||||
|
||||
chip->position_fix[0] = chip->position_fix[1] =
|
||||
check_position_fix(chip, position_fix[dev]);
|
||||
|
@ -2678,6 +2698,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
|
|||
|
||||
chip->single_cmd = single_cmd;
|
||||
chip->snoop = hda_snoop;
|
||||
azx_check_snoop_available(chip);
|
||||
|
||||
if (bdl_pos_adj[dev] < 0) {
|
||||
switch (chip->driver_type) {
|
||||
|
@ -2776,6 +2797,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
|
|||
chip->capture_streams = ULI_NUM_CAPTURE;
|
||||
break;
|
||||
case AZX_DRIVER_ATIHDMI:
|
||||
case AZX_DRIVER_ATIHDMI_NS:
|
||||
chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
|
||||
chip->capture_streams = ATIHDMI_NUM_CAPTURE;
|
||||
break;
|
||||
|
@ -2970,7 +2992,11 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
|
|||
/* SCH */
|
||||
{ PCI_DEVICE(0x8086, 0x811b),
|
||||
.driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
|
||||
AZX_DCAPS_BUFSIZE},
|
||||
AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_LPIB }, /* Poulsbo */
|
||||
{ PCI_DEVICE(0x8086, 0x080a),
|
||||
.driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
|
||||
AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_LPIB }, /* Oaktrail */
|
||||
/* ICH */
|
||||
{ PCI_DEVICE(0x8086, 0x2668),
|
||||
.driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
|
||||
AZX_DCAPS_BUFSIZE }, /* ICH6 */
|
||||
|
@ -3037,6 +3063,14 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
|
|||
.driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
|
||||
{ PCI_DEVICE(0x1002, 0xaa48),
|
||||
.driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
|
||||
{ PCI_DEVICE(0x1002, 0x9902),
|
||||
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
|
||||
{ PCI_DEVICE(0x1002, 0xaaa0),
|
||||
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
|
||||
{ PCI_DEVICE(0x1002, 0xaaa8),
|
||||
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
|
||||
{ PCI_DEVICE(0x1002, 0xaab0),
|
||||
.driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
|
||||
/* VIA VT8251/VT8237A */
|
||||
{ PCI_DEVICE(0x1106, 0x3288),
|
||||
.driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA },
|
||||
|
|
353
sound/pci/hda/hda_jack.c
Normal file
353
sound/pci/hda/hda_jack.c
Normal file
|
@ -0,0 +1,353 @@
|
|||
/*
|
||||
* Jack-detection handling for HD-audio
|
||||
*
|
||||
* Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
|
||||
*
|
||||
* This driver is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/export.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/control.h>
|
||||
#include <sound/jack.h>
|
||||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_jack.h"
|
||||
|
||||
/* execute pin sense measurement */
|
||||
static u32 read_pin_sense(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
u32 pincap;
|
||||
|
||||
if (!codec->no_trigger_sense) {
|
||||
pincap = snd_hda_query_pin_caps(codec, nid);
|
||||
if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
|
||||
snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_SET_PIN_SENSE, 0);
|
||||
}
|
||||
return snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_GET_PIN_SENSE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_hda_jack_tbl_get - query the jack-table entry for the given NID
|
||||
*/
|
||||
struct hda_jack_tbl *
|
||||
snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
struct hda_jack_tbl *jack = codec->jacktbl.list;
|
||||
int i;
|
||||
|
||||
if (!nid || !jack)
|
||||
return NULL;
|
||||
for (i = 0; i < codec->jacktbl.used; i++, jack++)
|
||||
if (jack->nid == nid)
|
||||
return jack;
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_get);
|
||||
|
||||
/**
|
||||
* snd_hda_jack_tbl_get_from_tag - query the jack-table entry for the given tag
|
||||
*/
|
||||
struct hda_jack_tbl *
|
||||
snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag)
|
||||
{
|
||||
struct hda_jack_tbl *jack = codec->jacktbl.list;
|
||||
int i;
|
||||
|
||||
if (!tag || !jack)
|
||||
return NULL;
|
||||
for (i = 0; i < codec->jacktbl.used; i++, jack++)
|
||||
if (jack->tag == tag)
|
||||
return jack;
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_get_from_tag);
|
||||
|
||||
/**
|
||||
* snd_hda_jack_tbl_new - create a jack-table entry for the given NID
|
||||
*/
|
||||
struct hda_jack_tbl *
|
||||
snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
|
||||
if (jack)
|
||||
return jack;
|
||||
snd_array_init(&codec->jacktbl, sizeof(*jack), 16);
|
||||
jack = snd_array_new(&codec->jacktbl);
|
||||
if (!jack)
|
||||
return NULL;
|
||||
jack->nid = nid;
|
||||
jack->jack_dirty = 1;
|
||||
jack->tag = codec->jacktbl.used;
|
||||
return jack;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_new);
|
||||
|
||||
void snd_hda_jack_tbl_clear(struct hda_codec *codec)
|
||||
{
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
/* free jack instances manually when clearing/reconfiguring */
|
||||
if (!codec->bus->shutdown && codec->jacktbl.list) {
|
||||
struct hda_jack_tbl *jack = codec->jacktbl.list;
|
||||
int i;
|
||||
for (i = 0; i < codec->jacktbl.used; i++, jack++) {
|
||||
if (jack->jack)
|
||||
snd_device_free(codec->bus->card, jack->jack);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
snd_array_free(&codec->jacktbl);
|
||||
}
|
||||
|
||||
/* update the cached value and notification flag if needed */
|
||||
static void jack_detect_update(struct hda_codec *codec,
|
||||
struct hda_jack_tbl *jack)
|
||||
{
|
||||
if (jack->jack_dirty || !jack->jack_detect) {
|
||||
jack->pin_sense = read_pin_sense(codec, jack->nid);
|
||||
jack->jack_dirty = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_hda_set_dirty_all - Mark all the cached as dirty
|
||||
*
|
||||
* This function sets the dirty flag to all entries of jack table.
|
||||
* It's called from the resume path in hda_codec.c.
|
||||
*/
|
||||
void snd_hda_jack_set_dirty_all(struct hda_codec *codec)
|
||||
{
|
||||
struct hda_jack_tbl *jack = codec->jacktbl.list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < codec->jacktbl.used; i++, jack++)
|
||||
if (jack->nid)
|
||||
jack->jack_dirty = 1;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_set_dirty_all);
|
||||
|
||||
/**
|
||||
* snd_hda_pin_sense - execute pin sense measurement
|
||||
* @codec: the CODEC to sense
|
||||
* @nid: the pin NID to sense
|
||||
*
|
||||
* Execute necessary pin sense measurement and return its Presence Detect,
|
||||
* Impedance, ELD Valid etc. status bits.
|
||||
*/
|
||||
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
|
||||
if (jack) {
|
||||
jack_detect_update(codec, jack);
|
||||
return jack->pin_sense;
|
||||
}
|
||||
return read_pin_sense(codec, nid);
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_pin_sense);
|
||||
|
||||
#define get_jack_plug_state(sense) !!(sense & AC_PINSENSE_PRESENCE)
|
||||
|
||||
/**
|
||||
* snd_hda_jack_detect - query pin Presence Detect status
|
||||
* @codec: the CODEC to sense
|
||||
* @nid: the pin NID to sense
|
||||
*
|
||||
* Query and return the pin's Presence Detect status.
|
||||
*/
|
||||
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
u32 sense = snd_hda_pin_sense(codec, nid);
|
||||
return get_jack_plug_state(sense);
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
|
||||
|
||||
/**
|
||||
* snd_hda_jack_detect_enable - enable the jack-detection
|
||||
*/
|
||||
int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned char action)
|
||||
{
|
||||
struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid);
|
||||
if (!jack)
|
||||
return -ENOMEM;
|
||||
if (jack->jack_detect)
|
||||
return 0; /* already registered */
|
||||
jack->jack_detect = 1;
|
||||
if (action)
|
||||
jack->action = action;
|
||||
return snd_hda_codec_write_cache(codec, nid, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | jack->tag);
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);
|
||||
|
||||
/**
|
||||
* snd_hda_jack_report_sync - sync the states of all jacks and report if changed
|
||||
*/
|
||||
void snd_hda_jack_report_sync(struct hda_codec *codec)
|
||||
{
|
||||
struct hda_jack_tbl *jack = codec->jacktbl.list;
|
||||
int i, state;
|
||||
|
||||
for (i = 0; i < codec->jacktbl.used; i++, jack++)
|
||||
if (jack->nid) {
|
||||
jack_detect_update(codec, jack);
|
||||
if (!jack->kctl)
|
||||
continue;
|
||||
state = get_jack_plug_state(jack->pin_sense);
|
||||
snd_kctl_jack_report(codec->bus->card, jack->kctl, state);
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
if (jack->jack)
|
||||
snd_jack_report(jack->jack,
|
||||
state ? jack->type : 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_report_sync);
|
||||
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
/* guess the jack type from the pin-config */
|
||||
static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
|
||||
switch (get_defcfg_device(def_conf)) {
|
||||
case AC_JACK_LINE_OUT:
|
||||
case AC_JACK_SPEAKER:
|
||||
return SND_JACK_LINEOUT;
|
||||
case AC_JACK_HP_OUT:
|
||||
return SND_JACK_HEADPHONE;
|
||||
case AC_JACK_SPDIF_OUT:
|
||||
case AC_JACK_DIG_OTHER_OUT:
|
||||
return SND_JACK_AVOUT;
|
||||
case AC_JACK_MIC_IN:
|
||||
return SND_JACK_MICROPHONE;
|
||||
default:
|
||||
return SND_JACK_LINEIN;
|
||||
}
|
||||
}
|
||||
|
||||
static void hda_free_jack_priv(struct snd_jack *jack)
|
||||
{
|
||||
struct hda_jack_tbl *jacks = jack->private_data;
|
||||
jacks->nid = 0;
|
||||
jacks->jack = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* snd_hda_jack_add_kctl - Add a kctl for the given pin
|
||||
*
|
||||
* This assigns a jack-detection kctl to the given pin. The kcontrol
|
||||
* will have the given name and index.
|
||||
*/
|
||||
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||
const char *name, int idx)
|
||||
{
|
||||
struct hda_jack_tbl *jack;
|
||||
struct snd_kcontrol *kctl;
|
||||
int err, state;
|
||||
|
||||
jack = snd_hda_jack_tbl_new(codec, nid);
|
||||
if (!jack)
|
||||
return 0;
|
||||
if (jack->kctl)
|
||||
return 0; /* already created */
|
||||
kctl = snd_kctl_jack_new(name, idx, codec);
|
||||
if (!kctl)
|
||||
return -ENOMEM;
|
||||
err = snd_hda_ctl_add(codec, nid, kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
jack->kctl = kctl;
|
||||
state = snd_hda_jack_detect(codec, nid);
|
||||
snd_kctl_jack_report(codec->bus->card, kctl, state);
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
jack->type = get_input_jack_type(codec, nid);
|
||||
err = snd_jack_new(codec->bus->card, name, jack->type, &jack->jack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
jack->jack->private_data = jack;
|
||||
jack->jack->private_free = hda_free_jack_priv;
|
||||
snd_jack_report(jack->jack, state ? jack->type : 0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl);
|
||||
|
||||
static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||
const struct auto_pin_cfg *cfg)
|
||||
{
|
||||
unsigned int def_conf, conn;
|
||||
char name[44];
|
||||
int idx, err;
|
||||
|
||||
if (!nid)
|
||||
return 0;
|
||||
if (!is_jack_detectable(codec, nid))
|
||||
return 0;
|
||||
def_conf = snd_hda_codec_get_pincfg(codec, nid);
|
||||
conn = get_defcfg_connect(def_conf);
|
||||
if (conn != AC_JACK_PORT_COMPLEX)
|
||||
return 0;
|
||||
|
||||
snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx);
|
||||
err = snd_hda_jack_add_kctl(codec, nid, name, idx);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return snd_hda_jack_detect_enable(codec, nid, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_hda_jack_add_kctls - Add kctls for all pins included in the given pincfg
|
||||
*/
|
||||
int snd_hda_jack_add_kctls(struct hda_codec *codec,
|
||||
const struct auto_pin_cfg *cfg)
|
||||
{
|
||||
const hda_nid_t *p;
|
||||
int i, err;
|
||||
|
||||
for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) {
|
||||
err = add_jack_kctl(codec, *p, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) {
|
||||
if (*p == *cfg->line_out_pins) /* might be duplicated */
|
||||
break;
|
||||
err = add_jack_kctl(codec, *p, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) {
|
||||
if (*p == *cfg->line_out_pins) /* might be duplicated */
|
||||
break;
|
||||
err = add_jack_kctl(codec, *p, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
for (i = 0; i < cfg->num_inputs; i++) {
|
||||
err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) {
|
||||
err = add_jack_kctl(codec, *p, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
err = add_jack_kctl(codec, cfg->dig_in_pin, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = add_jack_kctl(codec, cfg->mono_out_pin, cfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls);
|
86
sound/pci/hda/hda_jack.h
Normal file
86
sound/pci/hda/hda_jack.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Jack-detection handling for HD-audio
|
||||
*
|
||||
* Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
|
||||
*
|
||||
* This driver is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef __SOUND_HDA_JACK_H
|
||||
#define __SOUND_HDA_JACK_H
|
||||
|
||||
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 */
|
||||
/* jack-detection stuff */
|
||||
unsigned int pin_sense; /* cached pin-sense value */
|
||||
unsigned int jack_detect:1; /* capable of jack-detection? */
|
||||
unsigned int jack_dirty:1; /* needs to update? */
|
||||
struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
int type;
|
||||
struct snd_jack *jack;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct hda_jack_tbl *
|
||||
snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid);
|
||||
struct hda_jack_tbl *
|
||||
snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag);
|
||||
|
||||
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);
|
||||
|
||||
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
|
||||
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
|
||||
|
||||
static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT))
|
||||
return false;
|
||||
if (!codec->ignore_misc_bit &&
|
||||
(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
|
||||
AC_DEFCFG_MISC_NO_PRESENCE))
|
||||
return false;
|
||||
if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
|
||||
const char *name, int idx);
|
||||
int snd_hda_jack_add_kctls(struct hda_codec *codec,
|
||||
const struct auto_pin_cfg *cfg);
|
||||
|
||||
void snd_hda_jack_report_sync(struct hda_codec *codec);
|
||||
|
||||
|
||||
#endif /* __SOUND_HDA_JACK_H */
|
|
@ -394,11 +394,12 @@ struct auto_pin_cfg_item {
|
|||
};
|
||||
|
||||
struct auto_pin_cfg;
|
||||
const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
|
||||
int check_location);
|
||||
const char *hda_get_autocfg_input_label(struct hda_codec *codec,
|
||||
const struct auto_pin_cfg *cfg,
|
||||
int input);
|
||||
int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
|
||||
const struct auto_pin_cfg *cfg,
|
||||
char *label, int maxlen, int *indexp);
|
||||
int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
|
||||
int index, int *type_index_ret);
|
||||
|
||||
|
@ -487,7 +488,12 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
|
|||
}
|
||||
|
||||
/* get the widget type from widget capability bits */
|
||||
#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
|
||||
static inline int get_wcaps_type(unsigned int wcaps)
|
||||
{
|
||||
if (!wcaps)
|
||||
return -1; /* invalid type */
|
||||
return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
|
||||
}
|
||||
|
||||
static inline unsigned int get_wcaps_channels(u32 wcaps)
|
||||
{
|
||||
|
@ -505,21 +511,6 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
|
|||
u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
|
||||
int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned int caps);
|
||||
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
|
||||
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
|
||||
|
||||
static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT))
|
||||
return false;
|
||||
if (!codec->ignore_misc_bit &&
|
||||
(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
|
||||
AC_DEFCFG_MISC_NO_PRESENCE))
|
||||
return false;
|
||||
if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* flags for hda_nid_item */
|
||||
#define HDA_NID_ITEM_AMP (1<<0)
|
||||
|
@ -688,28 +679,4 @@ static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
|
|||
#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
|
||||
void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
|
||||
|
||||
/*
|
||||
* Input-jack notification support
|
||||
*/
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
|
||||
const char *name);
|
||||
void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid);
|
||||
void snd_hda_input_jack_free(struct hda_codec *codec);
|
||||
#else /* CONFIG_SND_HDA_INPUT_JACK */
|
||||
static inline int snd_hda_input_jack_add(struct hda_codec *codec,
|
||||
hda_nid_t nid, int type,
|
||||
const char *name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void snd_hda_input_jack_report(struct hda_codec *codec,
|
||||
hda_nid_t nid)
|
||||
{
|
||||
}
|
||||
static inline void snd_hda_input_jack_free(struct hda_codec *codec)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_SND_HDA_INPUT_JACK */
|
||||
|
||||
#endif /* __SOUND_HDA_LOCAL_H */
|
||||
|
|
|
@ -54,6 +54,8 @@ static const char *get_wid_type_name(unsigned int wid_value)
|
|||
[AC_WID_BEEP] = "Beep Generator Widget",
|
||||
[AC_WID_VENDOR] = "Vendor Defined Widget",
|
||||
};
|
||||
if (wid_value == -1)
|
||||
return "UNKNOWN Widget";
|
||||
wid_value &= 0xf;
|
||||
if (names[wid_value])
|
||||
return names[wid_value];
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_beep.h"
|
||||
#include "hda_jack.h"
|
||||
|
||||
struct ad198x_spec {
|
||||
const struct snd_kcontrol_new *mixers[6];
|
||||
|
|
|
@ -41,7 +41,7 @@ struct ca0110_spec {
|
|||
hda_nid_t dig_out;
|
||||
hda_nid_t dig_in;
|
||||
unsigned int num_inputs;
|
||||
const char *input_labels[AUTO_PIN_LAST];
|
||||
char input_labels[AUTO_PIN_LAST][32];
|
||||
struct hda_pcm pcm_rec[2]; /* PCM information */
|
||||
};
|
||||
|
||||
|
@ -476,7 +476,9 @@ static void parse_input(struct hda_codec *codec)
|
|||
if (j >= cfg->num_inputs)
|
||||
continue;
|
||||
spec->input_pins[n] = pin;
|
||||
spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1);
|
||||
snd_hda_get_pin_label(codec, pin, cfg,
|
||||
spec->input_labels[n],
|
||||
sizeof(spec->input_labels[n]), NULL);
|
||||
spec->adcs[n] = nid;
|
||||
n++;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <sound/core.h>
|
||||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_jack.h"
|
||||
#include <sound/tlv.h>
|
||||
|
||||
/*
|
||||
|
@ -78,6 +79,7 @@ enum {
|
|||
CS420X_MBP53,
|
||||
CS420X_MBP55,
|
||||
CS420X_IMAC27,
|
||||
CS420X_IMAC27_122,
|
||||
CS420X_APPLE,
|
||||
CS420X_AUTO,
|
||||
CS420X_MODELS
|
||||
|
@ -137,7 +139,7 @@ enum {
|
|||
*/
|
||||
#define CS4210_DAC_NID 0x02
|
||||
#define CS4210_ADC_NID 0x03
|
||||
#define CS421X_VENDOR_NID 0x0B
|
||||
#define CS4210_VENDOR_NID 0x0B
|
||||
#define CS421X_DMIC_PIN_NID 0x09 /* Port E */
|
||||
#define CS421X_SPDIF_PIN_NID 0x0A /* Port H */
|
||||
|
||||
|
@ -148,6 +150,10 @@ enum {
|
|||
|
||||
#define SPDIF_EVENT 0x04
|
||||
|
||||
/* Cirrus Logic CS4213 is like CS4210 but does not have SPDIF input/output */
|
||||
#define CS4213_VENDOR_NID 0x09
|
||||
|
||||
|
||||
static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
|
||||
{
|
||||
struct cs_spec *spec = codec->spec;
|
||||
|
@ -721,8 +727,9 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol,
|
|||
if (uinfo->value.enumerated.item >= spec->num_inputs)
|
||||
uinfo->value.enumerated.item = spec->num_inputs - 1;
|
||||
idx = spec->input_idx[uinfo->value.enumerated.item];
|
||||
strcpy(uinfo->value.enumerated.name,
|
||||
hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1));
|
||||
snd_hda_get_pin_label(codec, cfg->inputs[idx].pin, cfg,
|
||||
uinfo->value.enumerated.name,
|
||||
sizeof(uinfo->value.enumerated.name), NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -920,16 +927,14 @@ static void cs_automute(struct hda_codec *codec)
|
|||
|
||||
/* mute speakers if spdif or hp jack is plugged in */
|
||||
for (i = 0; i < cfg->speaker_outs; i++) {
|
||||
int pin_ctl = hp_present ? 0 : PIN_OUT;
|
||||
/* detect on spdif is specific to CS4210 */
|
||||
if (spdif_present && (spec->vendor_nid == CS4210_VENDOR_NID))
|
||||
pin_ctl = 0;
|
||||
|
||||
nid = cfg->speaker_pins[i];
|
||||
snd_hda_codec_write(codec, nid, 0,
|
||||
AC_VERB_SET_PIN_WIDGET_CONTROL,
|
||||
hp_present ? 0 : PIN_OUT);
|
||||
/* detect on spdif is specific to CS421x */
|
||||
if (spec->vendor_nid == CS421X_VENDOR_NID) {
|
||||
snd_hda_codec_write(codec, nid, 0,
|
||||
AC_VERB_SET_PIN_WIDGET_CONTROL,
|
||||
spdif_present ? 0 : PIN_OUT);
|
||||
}
|
||||
AC_VERB_SET_PIN_WIDGET_CONTROL, pin_ctl);
|
||||
}
|
||||
if (spec->gpio_eapd_hp) {
|
||||
unsigned int gpio = hp_present ?
|
||||
|
@ -938,8 +943,8 @@ static void cs_automute(struct hda_codec *codec)
|
|||
AC_VERB_SET_GPIO_DATA, gpio);
|
||||
}
|
||||
|
||||
/* specific to CS421x */
|
||||
if (spec->vendor_nid == CS421X_VENDOR_NID) {
|
||||
/* specific to CS4210 */
|
||||
if (spec->vendor_nid == CS4210_VENDOR_NID) {
|
||||
/* mute HPs if spdif jack (SENSE_B) is present */
|
||||
for (i = 0; i < cfg->hp_outs; i++) {
|
||||
nid = cfg->hp_pins[i];
|
||||
|
@ -976,7 +981,12 @@ static void cs_automic(struct hda_codec *codec)
|
|||
present = snd_hda_jack_detect(codec, nid);
|
||||
|
||||
/* specific to CS421x, single ADC */
|
||||
if (spec->vendor_nid == CS421X_VENDOR_NID) {
|
||||
if (spec->vendor_nid == CS420X_VENDOR_NID) {
|
||||
if (present)
|
||||
change_cur_input(codec, spec->automic_idx, 0);
|
||||
else
|
||||
change_cur_input(codec, !spec->automic_idx, 0);
|
||||
} else {
|
||||
if (present) {
|
||||
spec->last_input = spec->cur_input;
|
||||
spec->cur_input = spec->automic_idx;
|
||||
|
@ -984,11 +994,6 @@ static void cs_automic(struct hda_codec *codec)
|
|||
spec->cur_input = spec->last_input;
|
||||
}
|
||||
cs_update_input_select(codec);
|
||||
} else {
|
||||
if (present)
|
||||
change_cur_input(codec, spec->automic_idx, 0);
|
||||
else
|
||||
change_cur_input(codec, !spec->automic_idx, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1027,9 +1032,7 @@ static void init_output(struct hda_codec *codec)
|
|||
if (!cfg->speaker_outs)
|
||||
continue;
|
||||
if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
|
||||
snd_hda_codec_write(codec, nid, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | HP_EVENT);
|
||||
snd_hda_jack_detect_enable(codec, nid, HP_EVENT);
|
||||
spec->hp_detect = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1070,19 +1073,10 @@ static void init_input(struct hda_codec *codec)
|
|||
AC_VERB_SET_AMP_GAIN_MUTE,
|
||||
AMP_IN_MUTE(spec->adc_idx[i]));
|
||||
if (spec->mic_detect && spec->automic_idx == i)
|
||||
snd_hda_codec_write(codec, pin, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | MIC_EVENT);
|
||||
snd_hda_jack_detect_enable(codec, pin, MIC_EVENT);
|
||||
}
|
||||
/* specific to CS421x */
|
||||
if (spec->vendor_nid == CS421X_VENDOR_NID) {
|
||||
if (spec->mic_detect)
|
||||
cs_automic(codec);
|
||||
else {
|
||||
spec->cur_adc = spec->adc_nid[spec->cur_input];
|
||||
cs_update_input_select(codec);
|
||||
}
|
||||
} else {
|
||||
/* CS420x has multiple ADC, CS421x has single ADC */
|
||||
if (spec->vendor_nid == CS420X_VENDOR_NID) {
|
||||
change_cur_input(codec, spec->cur_input, 1);
|
||||
if (spec->mic_detect)
|
||||
cs_automic(codec);
|
||||
|
@ -1096,6 +1090,13 @@ static void init_input(struct hda_codec *codec)
|
|||
* selected in IDX_SPDIF_CTL.
|
||||
*/
|
||||
cs_vendor_coef_set(codec, IDX_ADC_CFG, coef);
|
||||
} else {
|
||||
if (spec->mic_detect)
|
||||
cs_automic(codec);
|
||||
else {
|
||||
spec->cur_adc = spec->adc_nid[spec->cur_input];
|
||||
cs_update_input_select(codec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1200,11 +1201,14 @@ static int cs_init(struct hda_codec *codec)
|
|||
init_output(codec);
|
||||
init_input(codec);
|
||||
init_digital(codec);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cs_build_controls(struct hda_codec *codec)
|
||||
{
|
||||
struct cs_spec *spec = codec->spec;
|
||||
int err;
|
||||
|
||||
err = build_output(codec);
|
||||
|
@ -1219,7 +1223,15 @@ static int cs_build_controls(struct hda_codec *codec)
|
|||
err = build_digital_input(codec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return cs_init(codec);
|
||||
err = cs_init(codec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cs_free(struct hda_codec *codec)
|
||||
|
@ -1232,7 +1244,7 @@ static void cs_free(struct hda_codec *codec)
|
|||
|
||||
static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
|
||||
{
|
||||
switch ((res >> 26) & 0x7f) {
|
||||
switch (snd_hda_jack_get_action(codec, res >> 26)) {
|
||||
case HP_EVENT:
|
||||
cs_automute(codec);
|
||||
break;
|
||||
|
@ -1240,6 +1252,7 @@ static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
cs_automic(codec);
|
||||
break;
|
||||
}
|
||||
snd_hda_jack_report_sync(codec);
|
||||
}
|
||||
|
||||
static const struct hda_codec_ops cs_patch_ops = {
|
||||
|
@ -1278,6 +1291,7 @@ static const char * const cs420x_models[CS420X_MODELS] = {
|
|||
[CS420X_MBP53] = "mbp53",
|
||||
[CS420X_MBP55] = "mbp55",
|
||||
[CS420X_IMAC27] = "imac27",
|
||||
[CS420X_IMAC27_122] = "imac27_122",
|
||||
[CS420X_APPLE] = "apple",
|
||||
[CS420X_AUTO] = "auto",
|
||||
};
|
||||
|
@ -1294,6 +1308,7 @@ static const struct snd_pci_quirk cs420x_cfg_tbl[] = {
|
|||
};
|
||||
|
||||
static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = {
|
||||
SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
|
||||
SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
|
||||
{} /* terminator */
|
||||
};
|
||||
|
@ -1393,6 +1408,12 @@ static int patch_cs420x(struct hda_codec *codec)
|
|||
spec->gpio_mask = spec->gpio_dir =
|
||||
spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
|
||||
break;
|
||||
case CS420X_IMAC27_122:
|
||||
spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */
|
||||
spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
|
||||
spec->gpio_mask = spec->gpio_dir =
|
||||
spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
|
||||
break;
|
||||
}
|
||||
|
||||
err = cs_parse_auto_config(codec);
|
||||
|
@ -1557,7 +1578,7 @@ static const struct snd_kcontrol_new cs421x_speaker_bost_ctl = {
|
|||
.tlv = { .p = cs421x_speaker_boost_db_scale },
|
||||
};
|
||||
|
||||
static void cs421x_pinmux_init(struct hda_codec *codec)
|
||||
static void cs4210_pinmux_init(struct hda_codec *codec)
|
||||
{
|
||||
struct cs_spec *spec = codec->spec;
|
||||
unsigned int def_conf, coef;
|
||||
|
@ -1602,10 +1623,7 @@ static void init_cs421x_digital(struct hda_codec *codec)
|
|||
if (!cfg->speaker_outs)
|
||||
continue;
|
||||
if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
|
||||
|
||||
snd_hda_codec_write(codec, nid, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | SPDIF_EVENT);
|
||||
snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT);
|
||||
spec->spdif_detect = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1615,10 +1633,11 @@ static int cs421x_init(struct hda_codec *codec)
|
|||
{
|
||||
struct cs_spec *spec = codec->spec;
|
||||
|
||||
snd_hda_sequence_write(codec, cs421x_coef_init_verbs);
|
||||
snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes);
|
||||
|
||||
cs421x_pinmux_init(codec);
|
||||
if (spec->vendor_nid == CS4210_VENDOR_NID) {
|
||||
snd_hda_sequence_write(codec, cs421x_coef_init_verbs);
|
||||
snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes);
|
||||
cs4210_pinmux_init(codec);
|
||||
}
|
||||
|
||||
if (spec->gpio_mask) {
|
||||
snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
|
||||
|
@ -1632,6 +1651,7 @@ static int cs421x_init(struct hda_codec *codec)
|
|||
init_output(codec);
|
||||
init_input(codec);
|
||||
init_cs421x_digital(codec);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1771,32 +1791,21 @@ static int build_cs421x_output(struct hda_codec *codec)
|
|||
struct auto_pin_cfg *cfg = &spec->autocfg;
|
||||
struct snd_kcontrol *kctl;
|
||||
int err;
|
||||
char *name = "HP/Speakers";
|
||||
char *name = "Master";
|
||||
|
||||
fix_volume_caps(codec, dac);
|
||||
if (!spec->vmaster_sw) {
|
||||
err = add_vmaster(codec, dac);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
err = add_mute(codec, name, 0,
|
||||
HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_ctl_add_slave(spec->vmaster_sw, kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
err = add_volume(codec, name, 0,
|
||||
HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_ctl_add_slave(spec->vmaster_vol, kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (cfg->speaker_outs) {
|
||||
if (cfg->speaker_outs && (spec->vendor_nid == CS4210_VENDOR_NID)) {
|
||||
err = snd_hda_ctl_add(codec, 0,
|
||||
snd_ctl_new1(&cs421x_speaker_bost_ctl, codec));
|
||||
if (err < 0)
|
||||
|
@ -1807,6 +1816,7 @@ static int build_cs421x_output(struct hda_codec *codec)
|
|||
|
||||
static int cs421x_build_controls(struct hda_codec *codec)
|
||||
{
|
||||
struct cs_spec *spec = codec->spec;
|
||||
int err;
|
||||
|
||||
err = build_cs421x_output(codec);
|
||||
|
@ -1818,12 +1828,20 @@ static int cs421x_build_controls(struct hda_codec *codec)
|
|||
err = build_digital_output(codec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return cs421x_init(codec);
|
||||
err = cs421x_init(codec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res)
|
||||
{
|
||||
switch ((res >> 26) & 0x3f) {
|
||||
switch (snd_hda_jack_get_action(codec, res >> 26)) {
|
||||
case HP_EVENT:
|
||||
case SPDIF_EVENT:
|
||||
cs_automute(codec);
|
||||
|
@ -1833,6 +1851,7 @@ static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
cs_automic(codec);
|
||||
break;
|
||||
}
|
||||
snd_hda_jack_report_sync(codec);
|
||||
}
|
||||
|
||||
static int parse_cs421x_input(struct hda_codec *codec)
|
||||
|
@ -1883,6 +1902,7 @@ static int cs421x_parse_auto_config(struct hda_codec *codec)
|
|||
*/
|
||||
static int cs421x_suspend(struct hda_codec *codec, pm_message_t state)
|
||||
{
|
||||
struct cs_spec *spec = codec->spec;
|
||||
unsigned int coef;
|
||||
|
||||
snd_hda_shutup_pins(codec);
|
||||
|
@ -1892,15 +1912,17 @@ static int cs421x_suspend(struct hda_codec *codec, pm_message_t state)
|
|||
snd_hda_codec_write(codec, CS4210_ADC_NID, 0,
|
||||
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
|
||||
|
||||
coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
|
||||
coef |= 0x0004; /* PDREF */
|
||||
cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
|
||||
if (spec->vendor_nid == CS4210_VENDOR_NID) {
|
||||
coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
|
||||
coef |= 0x0004; /* PDREF */
|
||||
cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct hda_codec_ops cs4210_patch_ops = {
|
||||
static struct hda_codec_ops cs421x_patch_ops = {
|
||||
.build_controls = cs421x_build_controls,
|
||||
.build_pcms = cs_build_pcms,
|
||||
.init = cs421x_init,
|
||||
|
@ -1911,7 +1933,7 @@ static struct hda_codec_ops cs4210_patch_ops = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static int patch_cs421x(struct hda_codec *codec)
|
||||
static int patch_cs4210(struct hda_codec *codec)
|
||||
{
|
||||
struct cs_spec *spec;
|
||||
int err;
|
||||
|
@ -1921,7 +1943,7 @@ static int patch_cs421x(struct hda_codec *codec)
|
|||
return -ENOMEM;
|
||||
codec->spec = spec;
|
||||
|
||||
spec->vendor_nid = CS421X_VENDOR_NID;
|
||||
spec->vendor_nid = CS4210_VENDOR_NID;
|
||||
|
||||
spec->board_config =
|
||||
snd_hda_check_board_config(codec, CS421X_MODELS,
|
||||
|
@ -1949,13 +1971,13 @@ static int patch_cs421x(struct hda_codec *codec)
|
|||
is auto-parsed. If GPIO or SENSE_B is forced, DMIC input
|
||||
is disabled.
|
||||
*/
|
||||
cs421x_pinmux_init(codec);
|
||||
cs4210_pinmux_init(codec);
|
||||
|
||||
err = cs421x_parse_auto_config(codec);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
|
||||
codec->patch_ops = cs4210_patch_ops;
|
||||
codec->patch_ops = cs421x_patch_ops;
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -1965,6 +1987,31 @@ static int patch_cs421x(struct hda_codec *codec)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int patch_cs4213(struct hda_codec *codec)
|
||||
{
|
||||
struct cs_spec *spec;
|
||||
int err;
|
||||
|
||||
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
|
||||
if (!spec)
|
||||
return -ENOMEM;
|
||||
codec->spec = spec;
|
||||
|
||||
spec->vendor_nid = CS4213_VENDOR_NID;
|
||||
|
||||
err = cs421x_parse_auto_config(codec);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
|
||||
codec->patch_ops = cs421x_patch_ops;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
kfree(codec->spec);
|
||||
codec->spec = NULL;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* patch entries
|
||||
|
@ -1972,13 +2019,15 @@ static int patch_cs421x(struct hda_codec *codec)
|
|||
static const struct hda_codec_preset snd_hda_preset_cirrus[] = {
|
||||
{ .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x },
|
||||
{ .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x },
|
||||
{ .id = 0x10134210, .name = "CS4210", .patch = patch_cs421x },
|
||||
{ .id = 0x10134210, .name = "CS4210", .patch = patch_cs4210 },
|
||||
{ .id = 0x10134213, .name = "CS4213", .patch = patch_cs4213 },
|
||||
{} /* terminator */
|
||||
};
|
||||
|
||||
MODULE_ALIAS("snd-hda-codec-id:10134206");
|
||||
MODULE_ALIAS("snd-hda-codec-id:10134207");
|
||||
MODULE_ALIAS("snd-hda-codec-id:10134210");
|
||||
MODULE_ALIAS("snd-hda-codec-id:10134213");
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_beep.h"
|
||||
#include "hda_jack.h"
|
||||
|
||||
#define CXT_PIN_DIR_IN 0x00
|
||||
#define CXT_PIN_DIR_OUT 0x01
|
||||
|
@ -415,40 +416,6 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
|
|||
&spec->cur_mux[adc_idx]);
|
||||
}
|
||||
|
||||
static int conexant_init_jacks(struct hda_codec *codec)
|
||||
{
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
struct conexant_spec *spec = codec->spec;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < spec->num_init_verbs; i++) {
|
||||
const struct hda_verb *hv;
|
||||
|
||||
hv = spec->init_verbs[i];
|
||||
while (hv->nid) {
|
||||
int err = 0;
|
||||
switch (hv->param ^ AC_USRSP_EN) {
|
||||
case CONEXANT_HP_EVENT:
|
||||
err = snd_hda_input_jack_add(codec, hv->nid,
|
||||
SND_JACK_HEADPHONE, NULL);
|
||||
snd_hda_input_jack_report(codec, hv->nid);
|
||||
break;
|
||||
case CXT5051_PORTC_EVENT:
|
||||
case CONEXANT_MIC_EVENT:
|
||||
err = snd_hda_input_jack_add(codec, hv->nid,
|
||||
SND_JACK_MICROPHONE, NULL);
|
||||
snd_hda_input_jack_report(codec, hv->nid);
|
||||
break;
|
||||
}
|
||||
if (err < 0)
|
||||
return err;
|
||||
++hv;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_SND_HDA_INPUT_JACK */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg,
|
||||
unsigned int power_state)
|
||||
{
|
||||
|
@ -474,7 +441,6 @@ static int conexant_init(struct hda_codec *codec)
|
|||
|
||||
static void conexant_free(struct hda_codec *codec)
|
||||
{
|
||||
snd_hda_input_jack_free(codec);
|
||||
snd_hda_detach_beep_device(codec);
|
||||
kfree(codec->spec);
|
||||
}
|
||||
|
@ -1120,8 +1086,6 @@ static const char * const cxt5045_models[CXT5045_MODELS] = {
|
|||
|
||||
static const struct snd_pci_quirk cxt5045_cfg_tbl[] = {
|
||||
SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
|
||||
SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
|
||||
CXT5045_LAPTOP_HPSENSE),
|
||||
SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
|
||||
SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
|
||||
SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
|
||||
|
@ -1750,7 +1714,6 @@ static void cxt5051_hp_automute(struct hda_codec *codec)
|
|||
static void cxt5051_hp_unsol_event(struct hda_codec *codec,
|
||||
unsigned int res)
|
||||
{
|
||||
int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
|
||||
switch (res >> 26) {
|
||||
case CONEXANT_HP_EVENT:
|
||||
cxt5051_hp_automute(codec);
|
||||
|
@ -1762,7 +1725,6 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec,
|
|||
cxt5051_portc_automic(codec);
|
||||
break;
|
||||
}
|
||||
snd_hda_input_jack_report(codec, nid);
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new cxt5051_playback_mixers[] = {
|
||||
|
@ -1901,8 +1863,6 @@ static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid,
|
|||
snd_hda_codec_write(codec, nid, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | event);
|
||||
snd_hda_input_jack_add(codec, nid, SND_JACK_MICROPHONE, NULL);
|
||||
snd_hda_input_jack_report(codec, nid);
|
||||
}
|
||||
|
||||
static const struct hda_verb cxt5051_ideapad_init_verbs[] = {
|
||||
|
@ -1918,7 +1878,6 @@ static int cxt5051_init(struct hda_codec *codec)
|
|||
struct conexant_spec *spec = codec->spec;
|
||||
|
||||
conexant_init(codec);
|
||||
conexant_init_jacks(codec);
|
||||
|
||||
if (spec->auto_mic & AUTO_MIC_PORTB)
|
||||
cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT);
|
||||
|
@ -3450,7 +3409,6 @@ static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
|
|||
hda_nid_t nid = pins[i];
|
||||
if (!nid || !is_jack_detectable(codec, nid))
|
||||
break;
|
||||
snd_hda_input_jack_report(codec, nid);
|
||||
present |= snd_hda_jack_detect(codec, nid);
|
||||
}
|
||||
return present;
|
||||
|
@ -3755,8 +3713,7 @@ static void cx_auto_automic(struct hda_codec *codec)
|
|||
|
||||
static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res)
|
||||
{
|
||||
int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
|
||||
switch (res >> 26) {
|
||||
switch (snd_hda_jack_get_action(codec, res >> 26)) {
|
||||
case CONEXANT_HP_EVENT:
|
||||
cx_auto_hp_automute(codec);
|
||||
break;
|
||||
|
@ -3765,9 +3722,9 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
break;
|
||||
case CONEXANT_MIC_EVENT:
|
||||
cx_auto_automic(codec);
|
||||
snd_hda_input_jack_report(codec, nid);
|
||||
break;
|
||||
}
|
||||
snd_hda_jack_report_sync(codec);
|
||||
}
|
||||
|
||||
/* check whether the pin config is suitable for auto-mic switching;
|
||||
|
@ -3979,13 +3936,11 @@ static void mute_outputs(struct hda_codec *codec, int num_nids,
|
|||
}
|
||||
|
||||
static void enable_unsol_pins(struct hda_codec *codec, int num_pins,
|
||||
hda_nid_t *pins, unsigned int tag)
|
||||
hda_nid_t *pins, unsigned int action)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_pins; i++)
|
||||
snd_hda_codec_write(codec, pins[i], 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | tag);
|
||||
snd_hda_jack_detect_enable(codec, pins[i], action);
|
||||
}
|
||||
|
||||
static void cx_auto_init_output(struct hda_codec *codec)
|
||||
|
@ -4060,16 +4015,14 @@ static void cx_auto_init_input(struct hda_codec *codec)
|
|||
|
||||
if (spec->auto_mic) {
|
||||
if (spec->auto_mic_ext >= 0) {
|
||||
snd_hda_codec_write(codec,
|
||||
cfg->inputs[spec->auto_mic_ext].pin, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | CONEXANT_MIC_EVENT);
|
||||
snd_hda_jack_detect_enable(codec,
|
||||
cfg->inputs[spec->auto_mic_ext].pin,
|
||||
CONEXANT_MIC_EVENT);
|
||||
}
|
||||
if (spec->auto_mic_dock >= 0) {
|
||||
snd_hda_codec_write(codec,
|
||||
cfg->inputs[spec->auto_mic_dock].pin, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | CONEXANT_MIC_EVENT);
|
||||
snd_hda_jack_detect_enable(codec,
|
||||
cfg->inputs[spec->auto_mic_dock].pin,
|
||||
CONEXANT_MIC_EVENT);
|
||||
}
|
||||
cx_auto_automic(codec);
|
||||
} else {
|
||||
|
@ -4097,6 +4050,7 @@ static int cx_auto_init(struct hda_codec *codec)
|
|||
cx_auto_init_output(codec);
|
||||
cx_auto_init_input(codec);
|
||||
cx_auto_init_digital(codec);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4326,6 +4280,7 @@ static int cx_auto_build_input_controls(struct hda_codec *codec)
|
|||
|
||||
static int cx_auto_build_controls(struct hda_codec *codec)
|
||||
{
|
||||
struct conexant_spec *spec = codec->spec;
|
||||
int err;
|
||||
|
||||
err = cx_auto_build_output_controls(codec);
|
||||
|
@ -4334,7 +4289,13 @@ static int cx_auto_build_controls(struct hda_codec *codec)
|
|||
err = cx_auto_build_input_controls(codec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return conexant_build_controls(codec);
|
||||
err = conexant_build_controls(codec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cx_auto_search_adcs(struct hda_codec *codec)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <sound/jack.h>
|
||||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_jack.h"
|
||||
|
||||
static bool static_hdmi_pcm;
|
||||
module_param(static_hdmi_pcm, bool, 0644);
|
||||
|
@ -48,8 +49,8 @@ MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
|
|||
*
|
||||
* The HDA correspondence of pipes/ports are converter/pin nodes.
|
||||
*/
|
||||
#define MAX_HDMI_CVTS 4
|
||||
#define MAX_HDMI_PINS 4
|
||||
#define MAX_HDMI_CVTS 8
|
||||
#define MAX_HDMI_PINS 8
|
||||
|
||||
struct hdmi_spec_per_cvt {
|
||||
hda_nid_t cvt_nid;
|
||||
|
@ -754,10 +755,18 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
|
|||
static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
|
||||
{
|
||||
struct hdmi_spec *spec = codec->spec;
|
||||
int pin_nid = res >> AC_UNSOL_RES_TAG_SHIFT;
|
||||
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
|
||||
int pin_nid;
|
||||
int pd = !!(res & AC_UNSOL_RES_PD);
|
||||
int eldv = !!(res & AC_UNSOL_RES_ELDV);
|
||||
int pin_idx;
|
||||
struct hda_jack_tbl *jack;
|
||||
|
||||
jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
|
||||
if (!jack)
|
||||
return;
|
||||
pin_nid = jack->nid;
|
||||
jack->jack_dirty = 1;
|
||||
|
||||
printk(KERN_INFO
|
||||
"HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
|
||||
|
@ -768,6 +777,7 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
|
|||
return;
|
||||
|
||||
hdmi_present_sense(&spec->pins[pin_idx], 1);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
}
|
||||
|
||||
static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
|
||||
|
@ -795,11 +805,10 @@ static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
|
|||
|
||||
static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
|
||||
{
|
||||
struct hdmi_spec *spec = codec->spec;
|
||||
int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
|
||||
int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
|
||||
|
||||
if (pin_nid_to_pin_index(spec, tag) < 0) {
|
||||
if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) {
|
||||
snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
|
||||
return;
|
||||
}
|
||||
|
@ -996,8 +1005,6 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
|
|||
msecs_to_jiffies(300));
|
||||
}
|
||||
}
|
||||
|
||||
snd_hda_input_jack_report(codec, pin_nid);
|
||||
}
|
||||
|
||||
static void hdmi_repoll_eld(struct work_struct *work)
|
||||
|
@ -1126,12 +1133,12 @@ static int hdmi_parse_codec(struct hda_codec *codec)
|
|||
|
||||
/*
|
||||
*/
|
||||
static char *generic_hdmi_pcm_names[MAX_HDMI_PINS] = {
|
||||
"HDMI 0",
|
||||
"HDMI 1",
|
||||
"HDMI 2",
|
||||
"HDMI 3",
|
||||
};
|
||||
static char *get_hdmi_pcm_name(int idx)
|
||||
{
|
||||
static char names[MAX_HDMI_PINS][8];
|
||||
sprintf(&names[idx][0], "HDMI %d", idx);
|
||||
return &names[idx][0];
|
||||
}
|
||||
|
||||
/*
|
||||
* HDMI callbacks
|
||||
|
@ -1209,7 +1216,7 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
|
|||
struct hda_pcm_stream *pstr;
|
||||
|
||||
info = &spec->pcm_rec[pin_idx];
|
||||
info->name = generic_hdmi_pcm_names[pin_idx];
|
||||
info->name = get_hdmi_pcm_name(pin_idx);
|
||||
info->pcm_type = HDA_PCM_TYPE_HDMI;
|
||||
|
||||
pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
|
||||
|
@ -1226,21 +1233,15 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
|
|||
|
||||
static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
|
||||
{
|
||||
int err;
|
||||
char hdmi_str[32];
|
||||
char hdmi_str[32] = "HDMI/DP";
|
||||
struct hdmi_spec *spec = codec->spec;
|
||||
struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
|
||||
int pcmdev = spec->pcm_rec[pin_idx].device;
|
||||
|
||||
snprintf(hdmi_str, sizeof(hdmi_str), "HDMI/DP,pcm=%d", pcmdev);
|
||||
if (pcmdev > 0)
|
||||
sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
|
||||
|
||||
err = snd_hda_input_jack_add(codec, per_pin->pin_nid,
|
||||
SND_JACK_VIDEOOUT, pcmdev > 0 ? hdmi_str : NULL);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
hdmi_present_sense(per_pin, 0);
|
||||
return 0;
|
||||
return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, 0);
|
||||
}
|
||||
|
||||
static int generic_hdmi_build_controls(struct hda_codec *codec)
|
||||
|
@ -1270,6 +1271,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
|
|||
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
hdmi_present_sense(per_pin, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1286,14 +1289,13 @@ static int generic_hdmi_init(struct hda_codec *codec)
|
|||
struct hdmi_eld *eld = &per_pin->sink_eld;
|
||||
|
||||
hdmi_init_pin(codec, pin_nid);
|
||||
snd_hda_codec_write(codec, pin_nid, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | pin_nid);
|
||||
snd_hda_jack_detect_enable(codec, pin_nid, pin_nid);
|
||||
|
||||
per_pin->codec = codec;
|
||||
INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld);
|
||||
snd_hda_eld_proc_new(codec, eld, pin_idx);
|
||||
}
|
||||
snd_hda_jack_report_sync(codec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1309,7 +1311,6 @@ static void generic_hdmi_free(struct hda_codec *codec)
|
|||
cancel_delayed_work(&per_pin->work);
|
||||
snd_hda_eld_proc_free(codec, eld);
|
||||
}
|
||||
snd_hda_input_jack_free(codec);
|
||||
|
||||
flush_workqueue(codec->bus->workq);
|
||||
kfree(spec);
|
||||
|
@ -1364,7 +1365,7 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
|
|||
chans = get_wcaps(codec, spec->cvts[i].cvt_nid);
|
||||
chans = get_wcaps_channels(chans);
|
||||
|
||||
info->name = generic_hdmi_pcm_names[i];
|
||||
info->name = get_hdmi_pcm_name(i);
|
||||
info->pcm_type = HDA_PCM_TYPE_HDMI;
|
||||
pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
|
||||
snd_BUG_ON(!spec->pcm_playback);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -37,6 +37,7 @@
|
|||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_beep.h"
|
||||
#include "hda_jack.h"
|
||||
|
||||
enum {
|
||||
STAC_VREF_EVENT = 1,
|
||||
|
@ -96,7 +97,6 @@ enum {
|
|||
STAC_92HD83XXX_PWR_REF,
|
||||
STAC_DELL_S14,
|
||||
STAC_DELL_VOSTRO_3500,
|
||||
STAC_92HD83XXX_HP,
|
||||
STAC_92HD83XXX_HP_cNB11_INTQUAD,
|
||||
STAC_HP_DV7_4000,
|
||||
STAC_92HD83XXX_MODELS
|
||||
|
@ -176,13 +176,6 @@ enum {
|
|||
STAC_9872_MODELS
|
||||
};
|
||||
|
||||
struct sigmatel_event {
|
||||
hda_nid_t nid;
|
||||
unsigned char type;
|
||||
unsigned char tag;
|
||||
int data;
|
||||
};
|
||||
|
||||
struct sigmatel_mic_route {
|
||||
hda_nid_t pin;
|
||||
signed char mux_idx;
|
||||
|
@ -215,6 +208,7 @@ struct sigmatel_spec {
|
|||
unsigned int gpio_mute;
|
||||
unsigned int gpio_led;
|
||||
unsigned int gpio_led_polarity;
|
||||
unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
|
||||
unsigned int vref_led;
|
||||
|
||||
/* stream */
|
||||
|
@ -230,9 +224,6 @@ struct sigmatel_spec {
|
|||
const hda_nid_t *pwr_nids;
|
||||
const hda_nid_t *dac_list;
|
||||
|
||||
/* events */
|
||||
struct snd_array events;
|
||||
|
||||
/* playback */
|
||||
struct hda_input_mux *mono_mux;
|
||||
unsigned int cur_mmux;
|
||||
|
@ -1093,13 +1084,10 @@ static const char * const slave_sws[] = {
|
|||
};
|
||||
|
||||
static void stac92xx_free_kctls(struct hda_codec *codec);
|
||||
static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
|
||||
|
||||
static int stac92xx_build_controls(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
struct auto_pin_cfg *cfg = &spec->autocfg;
|
||||
hda_nid_t nid;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
|
@ -1185,31 +1173,9 @@ static int stac92xx_build_controls(struct hda_codec *codec)
|
|||
|
||||
stac92xx_free_kctls(codec); /* no longer needed */
|
||||
|
||||
/* create jack input elements */
|
||||
if (spec->hp_detect) {
|
||||
for (i = 0; i < cfg->hp_outs; i++) {
|
||||
int type = SND_JACK_HEADPHONE;
|
||||
nid = cfg->hp_pins[i];
|
||||
/* jack detection */
|
||||
if (cfg->hp_outs == i)
|
||||
type |= SND_JACK_LINEOUT;
|
||||
err = stac92xx_add_jack(codec, nid, type);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < cfg->line_outs; i++) {
|
||||
err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
|
||||
SND_JACK_LINEOUT);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
for (i = 0; i < cfg->num_inputs; i++) {
|
||||
nid = cfg->inputs[i].pin;
|
||||
err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1691,7 +1657,6 @@ static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
|
|||
[STAC_92HD83XXX_PWR_REF] = "mic-ref",
|
||||
[STAC_DELL_S14] = "dell-s14",
|
||||
[STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
|
||||
[STAC_92HD83XXX_HP] = "hp",
|
||||
[STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
|
||||
[STAC_HP_DV7_4000] = "hp-dv7-4000",
|
||||
};
|
||||
|
@ -1706,8 +1671,6 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
|
|||
"unknown Dell", STAC_DELL_S14),
|
||||
SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
|
||||
"Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
|
||||
SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
|
||||
"HP", STAC_92HD83XXX_HP),
|
||||
SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
|
||||
"HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
|
||||
SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
|
||||
|
@ -2874,7 +2837,8 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
|
|||
}
|
||||
|
||||
if (control) {
|
||||
strcpy(name, hda_get_input_pin_label(codec, nid, 1));
|
||||
snd_hda_get_pin_label(codec, nid, &spec->autocfg,
|
||||
name, sizeof(name), NULL);
|
||||
return stac92xx_add_control(codec->spec, control,
|
||||
strcat(name, " Jack Mode"), nid);
|
||||
}
|
||||
|
@ -3552,7 +3516,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
|
|||
for (i = 0; i < spec->num_dmics; i++) {
|
||||
hda_nid_t nid;
|
||||
int index, type_idx;
|
||||
const char *label;
|
||||
char label[32];
|
||||
|
||||
nid = spec->dmic_nids[i];
|
||||
if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
|
||||
|
@ -3565,7 +3529,8 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
|
|||
if (index < 0)
|
||||
continue;
|
||||
|
||||
label = hda_get_input_pin_label(codec, nid, 1);
|
||||
snd_hda_get_pin_label(codec, nid, &spec->autocfg,
|
||||
label, sizeof(label), NULL);
|
||||
snd_hda_add_imux_item(dimux, label, index, &type_idx);
|
||||
if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
|
||||
snd_hda_add_imux_item(imux, label, index, &type_idx);
|
||||
|
@ -4163,65 +4128,18 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
|
|||
AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
|
||||
}
|
||||
|
||||
static int stac92xx_add_jack(struct hda_codec *codec,
|
||||
hda_nid_t nid, int type)
|
||||
{
|
||||
#ifdef CONFIG_SND_HDA_INPUT_JACK
|
||||
int def_conf = snd_hda_codec_get_pincfg(codec, nid);
|
||||
int connectivity = get_defcfg_connect(def_conf);
|
||||
|
||||
if (connectivity && connectivity != AC_JACK_PORT_FIXED)
|
||||
return 0;
|
||||
|
||||
return snd_hda_input_jack_add(codec, nid, type, NULL);
|
||||
#else
|
||||
return 0;
|
||||
#endif /* CONFIG_SND_HDA_INPUT_JACK */
|
||||
}
|
||||
|
||||
static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
|
||||
static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned char type, int data)
|
||||
{
|
||||
struct sigmatel_event *event;
|
||||
struct hda_jack_tbl *event;
|
||||
|
||||
snd_array_init(&spec->events, sizeof(*event), 32);
|
||||
event = snd_array_new(&spec->events);
|
||||
event = snd_hda_jack_tbl_new(codec, nid);
|
||||
if (!event)
|
||||
return -ENOMEM;
|
||||
event->nid = nid;
|
||||
event->type = type;
|
||||
event->tag = spec->events.used;
|
||||
event->data = data;
|
||||
event->action = type;
|
||||
event->private_data = data;
|
||||
|
||||
return event->tag;
|
||||
}
|
||||
|
||||
static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
|
||||
hda_nid_t nid)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
struct sigmatel_event *event = spec->events.list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < spec->events.used; i++, event++) {
|
||||
if (event->nid == nid)
|
||||
return event;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
|
||||
unsigned char tag)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
struct sigmatel_event *event = spec->events.list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < spec->events.used; i++, event++) {
|
||||
if (event->tag == tag)
|
||||
return event;
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check if given nid is a valid pin and no other events are assigned
|
||||
|
@ -4231,24 +4149,17 @@ static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
|
|||
static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned int type)
|
||||
{
|
||||
struct sigmatel_event *event;
|
||||
int tag;
|
||||
struct hda_jack_tbl *event;
|
||||
|
||||
if (!is_jack_detectable(codec, nid))
|
||||
return 0;
|
||||
event = stac_get_event(codec, nid);
|
||||
if (event) {
|
||||
if (event->type != type)
|
||||
return 0;
|
||||
tag = event->tag;
|
||||
} else {
|
||||
tag = stac_add_event(codec->spec, nid, type, 0);
|
||||
if (tag < 0)
|
||||
return 0;
|
||||
}
|
||||
snd_hda_codec_write_cache(codec, nid, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | tag);
|
||||
event = snd_hda_jack_tbl_new(codec, nid);
|
||||
if (!event)
|
||||
return -ENOMEM;
|
||||
if (event->action && event->action != type)
|
||||
return 0;
|
||||
event->action = type;
|
||||
snd_hda_jack_detect_enable(codec, nid, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -4318,15 +4229,34 @@ static void stac_store_hints(struct hda_codec *codec)
|
|||
spec->eapd_switch = val;
|
||||
get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
|
||||
if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
|
||||
if (spec->gpio_led <= 8) {
|
||||
spec->gpio_mask |= spec->gpio_led;
|
||||
spec->gpio_dir |= spec->gpio_led;
|
||||
if (spec->gpio_led_polarity)
|
||||
spec->gpio_data |= spec->gpio_led;
|
||||
}
|
||||
spec->gpio_mask |= spec->gpio_led;
|
||||
spec->gpio_dir |= spec->gpio_led;
|
||||
if (spec->gpio_led_polarity)
|
||||
spec->gpio_data |= spec->gpio_led;
|
||||
}
|
||||
}
|
||||
|
||||
static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
|
||||
const hda_nid_t *pins)
|
||||
{
|
||||
while (num_pins--)
|
||||
stac_issue_unsol_event(codec, *pins++);
|
||||
}
|
||||
|
||||
/* fake event to set up pins */
|
||||
static void stac_fake_hp_events(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
||||
if (spec->autocfg.hp_outs)
|
||||
stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
|
||||
spec->autocfg.hp_pins);
|
||||
if (spec->autocfg.line_outs &&
|
||||
spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
|
||||
stac_issue_unsol_events(codec, spec->autocfg.line_outs,
|
||||
spec->autocfg.line_out_pins);
|
||||
}
|
||||
|
||||
static int stac92xx_init(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
@ -4377,10 +4307,7 @@ static int stac92xx_init(struct hda_codec *codec)
|
|||
stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
|
||||
AC_PINCTL_OUT_EN);
|
||||
/* fake event to set up pins */
|
||||
if (cfg->hp_pins[0])
|
||||
stac_issue_unsol_event(codec, cfg->hp_pins[0]);
|
||||
else if (cfg->line_out_pins[0])
|
||||
stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
|
||||
stac_fake_hp_events(codec);
|
||||
} else {
|
||||
stac92xx_auto_init_multi_out(codec);
|
||||
stac92xx_auto_init_hp_out(codec);
|
||||
|
@ -4443,7 +4370,7 @@ static int stac92xx_init(struct hda_codec *codec)
|
|||
/* power on when no jack detection is available */
|
||||
/* or when the VREF is used for controlling LED */
|
||||
if (!spec->hp_detect ||
|
||||
(spec->gpio_led > 8 && spec->gpio_led == nid)) {
|
||||
spec->vref_mute_led_nid == nid) {
|
||||
stac_toggle_power_map(codec, nid, 1);
|
||||
continue;
|
||||
}
|
||||
|
@ -4478,6 +4405,8 @@ static int stac92xx_init(struct hda_codec *codec)
|
|||
stac_toggle_power_map(codec, nid, 0);
|
||||
}
|
||||
|
||||
snd_hda_jack_report_sync(codec);
|
||||
|
||||
/* sync mute LED */
|
||||
if (spec->gpio_led)
|
||||
hda_call_check_power_status(codec, 0x01);
|
||||
|
@ -4534,8 +4463,6 @@ static void stac92xx_free(struct hda_codec *codec)
|
|||
return;
|
||||
|
||||
stac92xx_shutup(codec);
|
||||
snd_hda_input_jack_free(codec);
|
||||
snd_array_free(&spec->events);
|
||||
|
||||
kfree(spec);
|
||||
snd_hda_detach_beep_device(codec);
|
||||
|
@ -4799,26 +4726,13 @@ static void stac92xx_mic_detect(struct hda_codec *codec)
|
|||
mic->mux_idx);
|
||||
}
|
||||
|
||||
static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
struct sigmatel_event *event = stac_get_event(codec, nid);
|
||||
if (!event)
|
||||
return;
|
||||
codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
|
||||
}
|
||||
|
||||
static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
|
||||
static void handle_unsol_event(struct hda_codec *codec,
|
||||
struct hda_jack_tbl *event)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
struct sigmatel_event *event;
|
||||
int tag, data;
|
||||
int data;
|
||||
|
||||
tag = (res >> 26) & 0x7f;
|
||||
event = stac_get_event_from_tag(codec, tag);
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
switch (event->type) {
|
||||
switch (event->action) {
|
||||
case STAC_HP_EVENT:
|
||||
case STAC_LO_EVENT:
|
||||
stac92xx_hp_detect(codec);
|
||||
|
@ -4828,7 +4742,7 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
break;
|
||||
}
|
||||
|
||||
switch (event->type) {
|
||||
switch (event->action) {
|
||||
case STAC_HP_EVENT:
|
||||
case STAC_LO_EVENT:
|
||||
case STAC_MIC_EVENT:
|
||||
|
@ -4836,7 +4750,6 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
case STAC_PWR_EVENT:
|
||||
if (spec->num_pwrs > 0)
|
||||
stac92xx_pin_sense(codec, event->nid);
|
||||
snd_hda_input_jack_report(codec, event->nid);
|
||||
|
||||
switch (codec->subsystem_id) {
|
||||
case 0x103c308f:
|
||||
|
@ -4861,11 +4774,33 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
AC_VERB_GET_GPIO_DATA, 0);
|
||||
/* toggle VREF state based on GPIOx status */
|
||||
snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
|
||||
!!(data & (1 << event->data)));
|
||||
!!(data & (1 << event->private_data)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
|
||||
{
|
||||
struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
|
||||
if (!event)
|
||||
return;
|
||||
handle_unsol_event(codec, event);
|
||||
}
|
||||
|
||||
static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
|
||||
{
|
||||
struct hda_jack_tbl *event;
|
||||
int tag;
|
||||
|
||||
tag = (res >> 26) & 0x7f;
|
||||
event = snd_hda_jack_tbl_get_from_tag(codec, tag);
|
||||
if (!event)
|
||||
return;
|
||||
event->jack_dirty = 1;
|
||||
handle_unsol_event(codec, event);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
}
|
||||
|
||||
static int hp_blike_system(u32 subsystem_id);
|
||||
|
||||
static void set_hp_led_gpio(struct hda_codec *codec)
|
||||
|
@ -4904,7 +4839,7 @@ static void set_hp_led_gpio(struct hda_codec *codec)
|
|||
* Need more information on whether it is true across the entire series.
|
||||
* -- kunal
|
||||
*/
|
||||
static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
|
||||
static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
const struct dmi_device *dev = NULL;
|
||||
|
@ -4915,8 +4850,14 @@ static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
|
|||
if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
|
||||
&spec->gpio_led_polarity,
|
||||
&spec->gpio_led) == 2) {
|
||||
if (spec->gpio_led < 4)
|
||||
unsigned int max_gpio;
|
||||
max_gpio = snd_hda_param_read(codec, codec->afg,
|
||||
AC_PAR_GPIO_CAP);
|
||||
max_gpio &= AC_GPIO_IO_COUNT;
|
||||
if (spec->gpio_led < max_gpio)
|
||||
spec->gpio_led = 1 << spec->gpio_led;
|
||||
else
|
||||
spec->vref_mute_led_nid = spec->gpio_led;
|
||||
return 1;
|
||||
}
|
||||
if (sscanf(dev->name, "HP_Mute_LED_%d",
|
||||
|
@ -4924,13 +4865,21 @@ static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
|
|||
set_hp_led_gpio(codec);
|
||||
return 1;
|
||||
}
|
||||
/* BIOS bug: unfilled OEM string */
|
||||
if (strstr(dev->name, "HP_Mute_LED_P_G")) {
|
||||
set_hp_led_gpio(codec);
|
||||
spec->gpio_led_polarity = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fallback case - if we don't find the DMI strings,
|
||||
* we statically set the GPIO - if not a B-series system.
|
||||
* we statically set the GPIO - if not a B-series system
|
||||
* and default polarity is provided
|
||||
*/
|
||||
if (!hp_blike_system(codec->subsystem_id)) {
|
||||
if (!hp_blike_system(codec->subsystem_id) &&
|
||||
(default_polarity == 0 || default_polarity == 1)) {
|
||||
set_hp_led_gpio(codec);
|
||||
spec->gpio_led_polarity = default_polarity;
|
||||
return 1;
|
||||
|
@ -5017,19 +4966,11 @@ static void stac927x_proc_hook(struct snd_info_buffer *buffer,
|
|||
#ifdef CONFIG_PM
|
||||
static int stac92xx_resume(struct hda_codec *codec)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
||||
stac92xx_init(codec);
|
||||
snd_hda_codec_resume_amp(codec);
|
||||
snd_hda_codec_resume_cache(codec);
|
||||
/* fake event to set up pins again to override cached values */
|
||||
if (spec->hp_detect) {
|
||||
if (spec->autocfg.hp_pins[0])
|
||||
stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
|
||||
else if (spec->autocfg.line_out_pins[0])
|
||||
stac_issue_unsol_event(codec,
|
||||
spec->autocfg.line_out_pins[0]);
|
||||
}
|
||||
stac_fake_hp_events(codec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5045,15 +4986,12 @@ static int stac92xx_pre_resume(struct hda_codec *codec)
|
|||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
||||
/* sync mute LED */
|
||||
if (spec->gpio_led) {
|
||||
if (spec->gpio_led <= 8) {
|
||||
stac_gpio_set(codec, spec->gpio_mask,
|
||||
spec->gpio_dir, spec->gpio_data);
|
||||
} else {
|
||||
stac_vrefout_set(codec,
|
||||
spec->gpio_led, spec->vref_led);
|
||||
}
|
||||
}
|
||||
if (spec->vref_mute_led_nid)
|
||||
stac_vrefout_set(codec, spec->vref_mute_led_nid,
|
||||
spec->vref_led);
|
||||
else if (spec->gpio_led)
|
||||
stac_gpio_set(codec, spec->gpio_mask,
|
||||
spec->gpio_dir, spec->gpio_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5064,7 +5002,7 @@ static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
|
|||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
||||
if (power_state == AC_PWRST_D3) {
|
||||
if (spec->gpio_led > 8) {
|
||||
if (spec->vref_mute_led_nid) {
|
||||
/* with vref-out pin used for mute led control
|
||||
* codec AFG is prevented from D3 state
|
||||
*/
|
||||
|
@ -5117,7 +5055,7 @@ static int stac92xx_update_led_status(struct hda_codec *codec)
|
|||
}
|
||||
}
|
||||
/*polarity defines *not* muted state level*/
|
||||
if (spec->gpio_led <= 8) {
|
||||
if (!spec->vref_mute_led_nid) {
|
||||
if (muted)
|
||||
spec->gpio_data &= ~spec->gpio_led; /* orange */
|
||||
else
|
||||
|
@ -5135,7 +5073,8 @@ static int stac92xx_update_led_status(struct hda_codec *codec)
|
|||
muted_lvl = spec->gpio_led_polarity ?
|
||||
AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ;
|
||||
spec->vref_led = muted ? muted_lvl : notmtd_lvl;
|
||||
stac_vrefout_set(codec, spec->gpio_led, spec->vref_led);
|
||||
stac_vrefout_set(codec, spec->vref_mute_led_nid,
|
||||
spec->vref_led);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -5642,14 +5581,14 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
|
|||
|
||||
codec->patch_ops = stac92xx_patch_ops;
|
||||
|
||||
if (find_mute_led_gpio(codec, 0))
|
||||
if (find_mute_led_cfg(codec, -1/*no default cfg*/))
|
||||
snd_printd("mute LED gpio %d polarity %d\n",
|
||||
spec->gpio_led,
|
||||
spec->gpio_led_polarity);
|
||||
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
if (spec->gpio_led) {
|
||||
if (spec->gpio_led <= 8) {
|
||||
if (!spec->vref_mute_led_nid) {
|
||||
spec->gpio_mask |= spec->gpio_led;
|
||||
spec->gpio_dir |= spec->gpio_led;
|
||||
spec->gpio_data |= spec->gpio_led;
|
||||
|
@ -5830,15 +5769,13 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
|
|||
switch (spec->board_config) {
|
||||
case STAC_HP_M4:
|
||||
/* Enable VREF power saving on GPIO1 detect */
|
||||
err = stac_add_event(spec, codec->afg,
|
||||
err = stac_add_event(codec, codec->afg,
|
||||
STAC_VREF_EVENT, 0x02);
|
||||
if (err < 0)
|
||||
return err;
|
||||
snd_hda_codec_write_cache(codec, codec->afg, 0,
|
||||
AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
|
||||
snd_hda_codec_write_cache(codec, codec->afg, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | err);
|
||||
snd_hda_jack_detect_enable(codec, codec->afg, 0);
|
||||
spec->gpio_mask |= 0x02;
|
||||
break;
|
||||
}
|
||||
|
@ -5955,14 +5892,14 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
|
|||
}
|
||||
}
|
||||
|
||||
if (find_mute_led_gpio(codec, 1))
|
||||
if (find_mute_led_cfg(codec, 1))
|
||||
snd_printd("mute LED gpio %d polarity %d\n",
|
||||
spec->gpio_led,
|
||||
spec->gpio_led_polarity);
|
||||
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
if (spec->gpio_led) {
|
||||
if (spec->gpio_led <= 8) {
|
||||
if (!spec->vref_mute_led_nid) {
|
||||
spec->gpio_mask |= spec->gpio_led;
|
||||
spec->gpio_dir |= spec->gpio_led;
|
||||
spec->gpio_data |= spec->gpio_led;
|
||||
|
@ -6309,14 +6246,12 @@ static int patch_stac9205(struct hda_codec *codec)
|
|||
snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
|
||||
|
||||
/* Enable unsol response for GPIO4/Dock HP connection */
|
||||
err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
|
||||
err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
|
||||
if (err < 0)
|
||||
return err;
|
||||
snd_hda_codec_write_cache(codec, codec->afg, 0,
|
||||
AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
|
||||
snd_hda_codec_write_cache(codec, codec->afg, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | err);
|
||||
snd_hda_jack_detect_enable(codec, codec->afg, 0);
|
||||
|
||||
spec->gpio_dir = 0x0b;
|
||||
spec->eapd_mask = 0x01;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <sound/asoundef.h>
|
||||
#include "hda_codec.h"
|
||||
#include "hda_local.h"
|
||||
#include "hda_jack.h"
|
||||
|
||||
/* Pin Widget NID */
|
||||
#define VT1708_HP_PIN_NID 0x20
|
||||
|
@ -1503,6 +1504,11 @@ static int via_build_controls(struct hda_codec *codec)
|
|||
analog_low_current_mode(codec);
|
||||
|
||||
via_free_kctls(codec); /* no longer needed */
|
||||
|
||||
err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1714,6 +1720,7 @@ static void via_unsol_event(struct hda_codec *codec,
|
|||
unsigned int res)
|
||||
{
|
||||
res >>= 26;
|
||||
res = snd_hda_jack_get_action(codec, res);
|
||||
|
||||
if (res & VIA_JACK_EVENT)
|
||||
set_widgets_power_state(codec);
|
||||
|
@ -1724,6 +1731,7 @@ static void via_unsol_event(struct hda_codec *codec,
|
|||
via_hp_automute(codec);
|
||||
else if (res == VIA_GPIO_EVENT)
|
||||
via_gpio_control(codec);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
|
@ -2200,7 +2208,10 @@ static int via_auto_create_loopback_switch(struct hda_codec *codec)
|
|||
{
|
||||
struct via_spec *spec = codec->spec;
|
||||
|
||||
if (!spec->aa_mix_nid || !spec->out_mix_path.depth)
|
||||
if (!spec->aa_mix_nid)
|
||||
return 0; /* no loopback switching available */
|
||||
if (!(spec->out_mix_path.depth || spec->hp_mix_path.depth ||
|
||||
spec->speaker_path.depth))
|
||||
return 0; /* no loopback switching available */
|
||||
if (!via_clone_control(spec, &via_aamix_ctl_enum))
|
||||
return -ENOMEM;
|
||||
|
@ -2736,9 +2747,8 @@ static void via_auto_init_unsol_event(struct hda_codec *codec)
|
|||
int i;
|
||||
|
||||
if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0]))
|
||||
snd_hda_codec_write(codec, cfg->hp_pins[0], 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT);
|
||||
snd_hda_jack_detect_enable(codec, cfg->hp_pins[0],
|
||||
VIA_HP_EVENT | VIA_JACK_EVENT);
|
||||
|
||||
if (cfg->speaker_pins[0])
|
||||
ev = VIA_LINE_EVENT;
|
||||
|
@ -2747,16 +2757,14 @@ static void via_auto_init_unsol_event(struct hda_codec *codec)
|
|||
for (i = 0; i < cfg->line_outs; i++) {
|
||||
if (cfg->line_out_pins[i] &&
|
||||
is_jack_detectable(codec, cfg->line_out_pins[i]))
|
||||
snd_hda_codec_write(codec, cfg->line_out_pins[i], 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | ev | VIA_JACK_EVENT);
|
||||
snd_hda_jack_detect_enable(codec, cfg->line_out_pins[i],
|
||||
ev | VIA_JACK_EVENT);
|
||||
}
|
||||
|
||||
for (i = 0; i < cfg->num_inputs; i++) {
|
||||
if (is_jack_detectable(codec, cfg->inputs[i].pin))
|
||||
snd_hda_codec_write(codec, cfg->inputs[i].pin, 0,
|
||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||
AC_USRSP_EN | VIA_JACK_EVENT);
|
||||
snd_hda_jack_detect_enable(codec, cfg->inputs[i].pin,
|
||||
VIA_JACK_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2779,6 +2787,7 @@ static int via_init(struct hda_codec *codec)
|
|||
|
||||
via_hp_automute(codec);
|
||||
vt1708_update_hp_work(spec);
|
||||
snd_hda_jack_report_sync(codec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2789,6 +2798,7 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
|
|||
vt1708_hp_work.work);
|
||||
if (spec->codec_type != VT1708)
|
||||
return;
|
||||
snd_hda_jack_set_dirty_all(spec->codec);
|
||||
/* if jack state toggled */
|
||||
if (spec->vt1708_hp_present
|
||||
!= snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) {
|
||||
|
|
Loading…
Reference in a new issue