| /* |
| * Universal Interface for Intel High Definition Audio Codec |
| * |
| * HD audio interface patch for ALC 260/880/882 codecs |
| * |
| * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| * PeiSen Hou <pshou@realtek.com.tw> |
| * Takashi Iwai <tiwai@suse.de> |
| * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
| * |
| * 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. |
| * |
| * This driver is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with this program; if not, write to the Free Software |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| */ |
| |
| #include <sound/driver.h> |
| #include <linux/init.h> |
| #include <linux/delay.h> |
| #include <linux/slab.h> |
| #include <linux/pci.h> |
| #include <sound/core.h> |
| #include "hda_codec.h" |
| #include "hda_local.h" |
| |
| #define ALC880_FRONT_EVENT 0x01 |
| #define ALC880_DCVOL_EVENT 0x02 |
| #define ALC880_HP_EVENT 0x04 |
| #define ALC880_MIC_EVENT 0x08 |
| |
| /* ALC880 board config type */ |
| enum { |
| ALC880_3ST, |
| ALC880_3ST_DIG, |
| ALC880_5ST, |
| ALC880_5ST_DIG, |
| ALC880_W810, |
| ALC880_Z71V, |
| ALC880_6ST, |
| ALC880_6ST_DIG, |
| ALC880_F1734, |
| ALC880_ASUS, |
| ALC880_ASUS_DIG, |
| ALC880_ASUS_W1V, |
| ALC880_ASUS_DIG2, |
| ALC880_FUJITSU, |
| ALC880_UNIWILL_DIG, |
| ALC880_UNIWILL, |
| ALC880_UNIWILL_P53, |
| ALC880_CLEVO, |
| ALC880_TCL_S700, |
| ALC880_LG, |
| ALC880_LG_LW, |
| #ifdef CONFIG_SND_DEBUG |
| ALC880_TEST, |
| #endif |
| ALC880_AUTO, |
| ALC880_MODEL_LAST /* last tag */ |
| }; |
| |
| /* ALC260 models */ |
| enum { |
| ALC260_BASIC, |
| ALC260_HP, |
| ALC260_HP_3013, |
| ALC260_FUJITSU_S702X, |
| ALC260_ACER, |
| ALC260_WILL, |
| ALC260_REPLACER_672V, |
| #ifdef CONFIG_SND_DEBUG |
| ALC260_TEST, |
| #endif |
| ALC260_AUTO, |
| ALC260_MODEL_LAST /* last tag */ |
| }; |
| |
| /* ALC262 models */ |
| enum { |
| ALC262_BASIC, |
| ALC262_HIPPO, |
| ALC262_HIPPO_1, |
| ALC262_FUJITSU, |
| ALC262_HP_BPC, |
| ALC262_HP_BPC_D7000_WL, |
| ALC262_HP_BPC_D7000_WF, |
| ALC262_BENQ_ED8, |
| ALC262_SONY_ASSAMD, |
| ALC262_BENQ_T31, |
| ALC262_AUTO, |
| ALC262_MODEL_LAST /* last tag */ |
| }; |
| |
| /* ALC268 models */ |
| enum { |
| ALC268_3ST, |
| ALC268_TOSHIBA, |
| ALC268_ACER, |
| ALC268_AUTO, |
| ALC268_MODEL_LAST /* last tag */ |
| }; |
| |
| /* ALC861 models */ |
| enum { |
| ALC861_3ST, |
| ALC660_3ST, |
| ALC861_3ST_DIG, |
| ALC861_6ST_DIG, |
| ALC861_UNIWILL_M31, |
| ALC861_TOSHIBA, |
| ALC861_ASUS, |
| ALC861_ASUS_LAPTOP, |
| ALC861_AUTO, |
| ALC861_MODEL_LAST, |
| }; |
| |
| /* ALC861-VD models */ |
| enum { |
| ALC660VD_3ST, |
| ALC660VD_3ST_DIG, |
| ALC861VD_3ST, |
| ALC861VD_3ST_DIG, |
| ALC861VD_6ST_DIG, |
| ALC861VD_LENOVO, |
| ALC861VD_DALLAS, |
| ALC861VD_HP, |
| ALC861VD_AUTO, |
| ALC861VD_MODEL_LAST, |
| }; |
| |
| /* ALC662 models */ |
| enum { |
| ALC662_3ST_2ch_DIG, |
| ALC662_3ST_6ch_DIG, |
| ALC662_3ST_6ch, |
| ALC662_5ST_DIG, |
| ALC662_LENOVO_101E, |
| ALC662_ASUS_EEEPC_P701, |
| ALC662_AUTO, |
| ALC662_MODEL_LAST, |
| }; |
| |
| /* ALC882 models */ |
| enum { |
| ALC882_3ST_DIG, |
| ALC882_6ST_DIG, |
| ALC882_ARIMA, |
| ALC882_W2JC, |
| ALC882_TARGA, |
| ALC882_ASUS_A7J, |
| ALC882_ASUS_A7M, |
| ALC885_MACPRO, |
| ALC885_MBP3, |
| ALC885_IMAC24, |
| ALC882_AUTO, |
| ALC882_MODEL_LAST, |
| }; |
| |
| /* ALC883 models */ |
| enum { |
| ALC883_3ST_2ch_DIG, |
| ALC883_3ST_6ch_DIG, |
| ALC883_3ST_6ch, |
| ALC883_6ST_DIG, |
| ALC883_TARGA_DIG, |
| ALC883_TARGA_2ch_DIG, |
| ALC883_ACER, |
| ALC883_ACER_ASPIRE, |
| ALC883_MEDION, |
| ALC883_MEDION_MD2, |
| ALC883_LAPTOP_EAPD, |
| ALC883_LENOVO_101E_2ch, |
| ALC883_LENOVO_NB0763, |
| ALC888_LENOVO_MS7195_DIG, |
| ALC883_HAIER_W66, |
| ALC888_6ST_HP, |
| ALC888_3ST_HP, |
| ALC883_AUTO, |
| ALC883_MODEL_LAST, |
| }; |
| |
| /* for GPIO Poll */ |
| #define GPIO_MASK 0x03 |
| |
| struct alc_spec { |
| /* codec parameterization */ |
| struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
| unsigned int num_mixers; |
| |
| const struct hda_verb *init_verbs[5]; /* initialization verbs |
| * don't forget NULL |
| * termination! |
| */ |
| unsigned int num_init_verbs; |
| |
| char *stream_name_analog; /* analog PCM stream */ |
| struct hda_pcm_stream *stream_analog_playback; |
| struct hda_pcm_stream *stream_analog_capture; |
| |
| char *stream_name_digital; /* digital PCM stream */ |
| struct hda_pcm_stream *stream_digital_playback; |
| struct hda_pcm_stream *stream_digital_capture; |
| |
| /* playback */ |
| struct hda_multi_out multiout; /* playback set-up |
| * max_channels, dacs must be set |
| * dig_out_nid and hp_nid are optional |
| */ |
| |
| /* capture */ |
| unsigned int num_adc_nids; |
| hda_nid_t *adc_nids; |
| hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| |
| /* capture source */ |
| unsigned int num_mux_defs; |
| const struct hda_input_mux *input_mux; |
| unsigned int cur_mux[3]; |
| |
| /* channel model */ |
| const struct hda_channel_mode *channel_mode; |
| int num_channel_mode; |
| int need_dac_fix; |
| |
| /* PCM information */ |
| struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
| |
| /* dynamic controls, init_verbs and input_mux */ |
| struct auto_pin_cfg autocfg; |
| unsigned int num_kctl_alloc, num_kctl_used; |
| struct snd_kcontrol_new *kctl_alloc; |
| struct hda_input_mux private_imux; |
| hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
| |
| /* hooks */ |
| void (*init_hook)(struct hda_codec *codec); |
| void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
| |
| /* for pin sensing */ |
| unsigned int sense_updated: 1; |
| unsigned int jack_present: 1; |
| |
| #ifdef CONFIG_SND_HDA_POWER_SAVE |
| struct hda_loopback_check loopback; |
| #endif |
| }; |
| |
| /* |
| * configuration template - to be copied to the spec instance |
| */ |
| struct alc_config_preset { |
| struct snd_kcontrol_new *mixers[5]; /* should be identical size |
| * with spec |
| */ |
| const struct hda_verb *init_verbs[5]; |
| unsigned int num_dacs; |
| hda_nid_t *dac_nids; |
| hda_nid_t dig_out_nid; /* optional */ |
| hda_nid_t hp_nid; /* optional */ |
| unsigned int num_adc_nids; |
| hda_nid_t *adc_nids; |
| hda_nid_t dig_in_nid; |
| unsigned int num_channel_mode; |
| const struct hda_channel_mode *channel_mode; |
| int need_dac_fix; |
| unsigned int num_mux_defs; |
| const struct hda_input_mux *input_mux; |
| void (*unsol_event)(struct hda_codec *, unsigned int); |
| void (*init_hook)(struct hda_codec *); |
| #ifdef CONFIG_SND_HDA_POWER_SAVE |
| struct hda_amp_list *loopbacks; |
| #endif |
| }; |
| |
| |
| /* |
| * input MUX handling |
| */ |
| static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_info *uinfo) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| struct alc_spec *spec = codec->spec; |
| unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| if (mux_idx >= spec->num_mux_defs) |
| mux_idx = 0; |
| return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
| } |
| |
| static int alc_mux_enum_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; |
| unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| |
| ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| return 0; |
| } |
| |
| static int alc_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; |
| unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, |
| spec->adc_nids[adc_idx], |
| &spec->cur_mux[adc_idx]); |
| } |
| |
| |
| /* |
| * channel mode setting |
| */ |
| static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_info *uinfo) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| spec->num_channel_mode); |
| } |
| |
| static int alc_ch_mode_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; |
| return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| spec->num_channel_mode, |
| spec->multiout.max_channels); |
| } |
| |
| static int alc_ch_mode_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 err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| spec->num_channel_mode, |
| &spec->multiout.max_channels); |
| if (err >= 0 && spec->need_dac_fix) |
| spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
| return err; |
| } |
| |
| /* |
| * Control the mode of pin widget settings via the mixer. "pc" is used |
| * instead of "%" to avoid consequences of accidently treating the % as |
| * being part of a format specifier. Maximum allowed length of a value is |
| * 63 characters plus NULL terminator. |
| * |
| * Note: some retasking pin complexes seem to ignore requests for input |
| * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these |
| * are requested. Therefore order this list so that this behaviour will not |
| * cause problems when mixer clients move through the enum sequentially. |
| * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
| * March 2006. |
| */ |
| static char *alc_pin_mode_names[] = { |
| "Mic 50pc bias", "Mic 80pc bias", |
| "Line in", "Line out", "Headphone out", |
| }; |
| static unsigned char alc_pin_mode_values[] = { |
| PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
| }; |
| /* The control can present all 5 options, or it can limit the options based |
| * in the pin being assumed to be exclusively an input or an output pin. In |
| * addition, "input" pins may or may not process the mic bias option |
| * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to |
| * accept requests for bias as of chip versions up to March 2006) and/or |
| * wiring in the computer. |
| */ |
| #define ALC_PIN_DIR_IN 0x00 |
| #define ALC_PIN_DIR_OUT 0x01 |
| #define ALC_PIN_DIR_INOUT 0x02 |
| #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 |
| #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 |
| |
| /* Info about the pin modes supported by the different pin direction modes. |
| * For each direction the minimum and maximum values are given. |
| */ |
| static signed char alc_pin_mode_dir_info[5][2] = { |
| { 0, 2 }, /* ALC_PIN_DIR_IN */ |
| { 3, 4 }, /* ALC_PIN_DIR_OUT */ |
| { 0, 4 }, /* ALC_PIN_DIR_INOUT */ |
| { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
| { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ |
| }; |
| #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) |
| #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) |
| #define alc_pin_mode_n_items(_dir) \ |
| (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) |
| |
| static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_info *uinfo) |
| { |
| unsigned int item_num = uinfo->value.enumerated.item; |
| unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| |
| uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| uinfo->count = 1; |
| uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
| |
| if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) |
| item_num = alc_pin_mode_min(dir); |
| strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); |
| return 0; |
| } |
| |
| static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| unsigned int i; |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = kcontrol->private_value & 0xffff; |
| unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| long *valp = ucontrol->value.integer.value; |
| unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 0x00); |
| |
| /* Find enumerated value for current pinctl setting */ |
| i = alc_pin_mode_min(dir); |
| while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
| i++; |
| *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
| return 0; |
| } |
| |
| static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| signed int change; |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = kcontrol->private_value & 0xffff; |
| unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| long val = *ucontrol->value.integer.value; |
| unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 0x00); |
| |
| if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
| val = alc_pin_mode_min(dir); |
| |
| change = pinctl != alc_pin_mode_values[val]; |
| if (change) { |
| /* Set pin mode to that requested */ |
| snd_hda_codec_write_cache(codec, nid, 0, |
| AC_VERB_SET_PIN_WIDGET_CONTROL, |
| alc_pin_mode_values[val]); |
| |
| /* Also enable the retasking pin's input/output as required |
| * for the requested pin mode. Enum values of 2 or less are |
| * input modes. |
| * |
| * Dynamically switching the input/output buffers probably |
| * reduces noise slightly (particularly on input) so we'll |
| * do it. However, having both input and output buffers |
| * enabled simultaneously doesn't seem to be problematic if |
| * this turns out to be necessary in the future. |
| */ |
| if (val <= 2) { |
| snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, HDA_AMP_MUTE); |
| snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
| HDA_AMP_MUTE, 0); |
| } else { |
| snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
| HDA_AMP_MUTE, HDA_AMP_MUTE); |
| snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, 0); |
| } |
| } |
| return change; |
| } |
| |
| #define ALC_PIN_MODE(xname, nid, dir) \ |
| { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| .info = alc_pin_mode_info, \ |
| .get = alc_pin_mode_get, \ |
| .put = alc_pin_mode_put, \ |
| .private_value = nid | (dir<<16) } |
| |
| /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
| * together using a mask with more than one bit set. This control is |
| * currently used only by the ALC260 test model. At this stage they are not |
| * needed for any "production" models. |
| */ |
| #ifdef CONFIG_SND_DEBUG |
| #define alc_gpio_data_info snd_ctl_boolean_mono_info |
| |
| static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = kcontrol->private_value & 0xffff; |
| unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| long *valp = ucontrol->value.integer.value; |
| unsigned int val = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_GPIO_DATA, 0x00); |
| |
| *valp = (val & mask) != 0; |
| return 0; |
| } |
| static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| signed int change; |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = kcontrol->private_value & 0xffff; |
| unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| long val = *ucontrol->value.integer.value; |
| unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_GPIO_DATA, |
| 0x00); |
| |
| /* Set/unset the masked GPIO bit(s) as needed */ |
| change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
| if (val == 0) |
| gpio_data &= ~mask; |
| else |
| gpio_data |= mask; |
| snd_hda_codec_write_cache(codec, nid, 0, |
| AC_VERB_SET_GPIO_DATA, gpio_data); |
| |
| return change; |
| } |
| #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ |
| { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| .info = alc_gpio_data_info, \ |
| .get = alc_gpio_data_get, \ |
| .put = alc_gpio_data_put, \ |
| .private_value = nid | (mask<<16) } |
| #endif /* CONFIG_SND_DEBUG */ |
| |
| /* A switch control to allow the enabling of the digital IO pins on the |
| * ALC260. This is incredibly simplistic; the intention of this control is |
| * to provide something in the test model allowing digital outputs to be |
| * identified if present. If models are found which can utilise these |
| * outputs a more complete mixer control can be devised for those models if |
| * necessary. |
| */ |
| #ifdef CONFIG_SND_DEBUG |
| #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
| |
| static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = kcontrol->private_value & 0xffff; |
| unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| long *valp = ucontrol->value.integer.value; |
| unsigned int val = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_DIGI_CONVERT, 0x00); |
| |
| *valp = (val & mask) != 0; |
| return 0; |
| } |
| static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| signed int change; |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = kcontrol->private_value & 0xffff; |
| unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| long val = *ucontrol->value.integer.value; |
| unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_DIGI_CONVERT, |
| 0x00); |
| |
| /* Set/unset the masked control bit(s) as needed */ |
| change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
| if (val==0) |
| ctrl_data &= ~mask; |
| else |
| ctrl_data |= mask; |
| snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
| ctrl_data); |
| |
| return change; |
| } |
| #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ |
| { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| .info = alc_spdif_ctrl_info, \ |
| .get = alc_spdif_ctrl_get, \ |
| .put = alc_spdif_ctrl_put, \ |
| .private_value = nid | (mask<<16) } |
| #endif /* CONFIG_SND_DEBUG */ |
| |
| /* |
| * set up from the preset table |
| */ |
| static void setup_preset(struct alc_spec *spec, |
| const struct alc_config_preset *preset) |
| { |
| int i; |
| |
| for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) |
| spec->mixers[spec->num_mixers++] = preset->mixers[i]; |
| for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
| i++) |
| spec->init_verbs[spec->num_init_verbs++] = |
| preset->init_verbs[i]; |
| |
| spec->channel_mode = preset->channel_mode; |
| spec->num_channel_mode = preset->num_channel_mode; |
| spec->need_dac_fix = preset->need_dac_fix; |
| |
| spec->multiout.max_channels = spec->channel_mode[0].channels; |
| |
| spec->multiout.num_dacs = preset->num_dacs; |
| spec->multiout.dac_nids = preset->dac_nids; |
| spec->multiout.dig_out_nid = preset->dig_out_nid; |
| spec->multiout.hp_nid = preset->hp_nid; |
| |
| spec->num_mux_defs = preset->num_mux_defs; |
| if (!spec->num_mux_defs) |
| spec->num_mux_defs = 1; |
| spec->input_mux = preset->input_mux; |
| |
| spec->num_adc_nids = preset->num_adc_nids; |
| spec->adc_nids = preset->adc_nids; |
| spec->dig_in_nid = preset->dig_in_nid; |
| |
| spec->unsol_event = preset->unsol_event; |
| spec->init_hook = preset->init_hook; |
| #ifdef CONFIG_SND_HDA_POWER_SAVE |
| spec->loopback.amplist = preset->loopbacks; |
| #endif |
| } |
| |
| /* Enable GPIO mask and set output */ |
| static struct hda_verb alc_gpio1_init_verbs[] = { |
| {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| { } |
| }; |
| |
| static struct hda_verb alc_gpio2_init_verbs[] = { |
| {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| { } |
| }; |
| |
| static struct hda_verb alc_gpio3_init_verbs[] = { |
| {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| { } |
| }; |
| |
| static void alc_sku_automute(struct hda_codec *codec) |
| { |
| struct alc_spec *spec = codec->spec; |
| unsigned int mute; |
| unsigned int present; |
| unsigned int hp_nid = spec->autocfg.hp_pins[0]; |
| unsigned int sp_nid = spec->autocfg.speaker_pins[0]; |
| |
| /* need to execute and sync at first */ |
| snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); |
| present = snd_hda_codec_read(codec, hp_nid, 0, |
| AC_VERB_GET_PIN_SENSE, 0); |
| spec->jack_present = (present & 0x80000000) != 0; |
| if (spec->jack_present) { |
| /* mute internal speaker */ |
| snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, HDA_AMP_MUTE); |
| } else { |
| /* unmute internal speaker if necessary */ |
| mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0); |
| snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, mute); |
| } |
| } |
| |
| /* unsolicited event for HP jack sensing */ |
| static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
| { |
| if (codec->vendor_id == 0x10ec0880) |
| res >>= 28; |
| else |
| res >>= 26; |
| if (res != ALC880_HP_EVENT) |
| return; |
| |
| alc_sku_automute(codec); |
| } |
| |
| /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| * 31 ~ 16 : Manufacture ID |
| * 15 ~ 8 : SKU ID |
| * 7 ~ 0 : Assembly ID |
| * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| */ |
| static void alc_subsystem_id(struct hda_codec *codec, |
| unsigned int porta, unsigned int porte, |
| unsigned int portd) |
| { |
| unsigned int ass, tmp, i; |
| unsigned nid; |
| struct alc_spec *spec = codec->spec; |
| |
| ass = codec->subsystem_id & 0xffff; |
| if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| goto do_sku; |
| |
| /* |
| * 31~30 : port conetcivity |
| * 29~21 : reserve |
| * 20 : PCBEEP input |
| * 19~16 : Check sum (15:1) |
| * 15~1 : Custom |
| * 0 : override |
| */ |
| nid = 0x1d; |
| if (codec->vendor_id == 0x10ec0260) |
| nid = 0x17; |
| ass = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_CONFIG_DEFAULT, 0); |
| if (!(ass & 1) && !(ass & 0x100000)) |
| return; |
| if ((ass >> 30) != 1) /* no physical connection */ |
| return; |
| |
| /* check sum */ |
| tmp = 0; |
| for (i = 1; i < 16; i++) { |
| if ((ass >> i) && 1) |
| tmp++; |
| } |
| if (((ass >> 16) & 0xf) != tmp) |
| return; |
| do_sku: |
| /* |
| * 0 : override |
| * 1 : Swap Jack |
| * 2 : 0 --> Desktop, 1 --> Laptop |
| * 3~5 : External Amplifier control |
| * 7~6 : Reserved |
| */ |
| tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| switch (tmp) { |
| case 1: |
| snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| break; |
| case 3: |
| snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| break; |
| case 7: |
| snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| break; |
| case 5: /* set EAPD output high */ |
| switch (codec->vendor_id) { |
| case 0x10ec0260: |
| snd_hda_codec_write(codec, 0x0f, 0, |
| AC_VERB_SET_EAPD_BTLENABLE, 2); |
| snd_hda_codec_write(codec, 0x10, 0, |
| AC_VERB_SET_EAPD_BTLENABLE, 2); |
| break; |
| case 0x10ec0262: |
| case 0x10ec0267: |
| case 0x10ec0268: |
| case 0x10ec0269: |
| case 0x10ec0862: |
| case 0x10ec0662: |
| snd_hda_codec_write(codec, 0x14, 0, |
| AC_VERB_SET_EAPD_BTLENABLE, 2); |
| snd_hda_codec_write(codec, 0x15, 0, |
| AC_VERB_SET_EAPD_BTLENABLE, 2); |
| break; |
| } |
| switch (codec->vendor_id) { |
| case 0x10ec0260: |
| snd_hda_codec_write(codec, 0x1a, 0, |
| AC_VERB_SET_COEF_INDEX, 7); |
| tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| AC_VERB_GET_PROC_COEF, 0); |
| snd_hda_codec_write(codec, 0x1a, 0, |
| AC_VERB_SET_COEF_INDEX, 7); |
| snd_hda_codec_write(codec, 0x1a, 0, |
| AC_VERB_SET_PROC_COEF, |
| tmp | 0x2010); |
| break; |
| case 0x10ec0262: |
| case 0x10ec0880: |
| case 0x10ec0882: |
| case 0x10ec0883: |
| case 0x10ec0885: |
| case 0x10ec0888: |
| snd_hda_codec_write(codec, 0x20, 0, |
| AC_VERB_SET_COEF_INDEX, 7); |
| tmp = snd_hda_codec_read(codec, 0x20, 0, |
| AC_VERB_GET_PROC_COEF, 0); |
| snd_hda_codec_write(codec, 0x20, 0, |
| AC_VERB_SET_COEF_INDEX, 7); |
| snd_hda_codec_write(codec, 0x20, 0, |
| AC_VERB_SET_PROC_COEF, |
| tmp | 0x2010); |
| break; |
| case 0x10ec0267: |
| case 0x10ec0268: |
| snd_hda_codec_write(codec, 0x20, 0, |
| AC_VERB_SET_COEF_INDEX, 7); |
| tmp = snd_hda_codec_read(codec, 0x20, 0, |
| AC_VERB_GET_PROC_COEF, 0); |
| snd_hda_codec_write(codec, 0x20, 0, |
| AC_VERB_SET_COEF_INDEX, 7); |
| snd_hda_codec_write(codec, 0x20, 0, |
| AC_VERB_SET_PROC_COEF, |
| tmp | 0x3000); |
| break; |
| } |
| default: |
| break; |
| } |
| |
| /* is laptop and enable the function "Mute internal speaker |
| * when the external headphone out jack is plugged" |
| */ |
| if (!(ass & 0x4) || !(ass & 0x8000)) |
| return; |
| /* |
| * 10~8 : Jack location |
| * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| * 14~13: Resvered |
| * 15 : 1 --> enable the function "Mute internal speaker |
| * when the external headphone out jack is plugged" |
| */ |
| if (!spec->autocfg.speaker_pins[0]) { |
| if (spec->multiout.dac_nids[0]) |
| spec->autocfg.speaker_pins[0] = |
| spec->multiout.dac_nids[0]; |
| else |
| return; |
| } |
| |
| if (!spec->autocfg.hp_pins[0]) { |
| tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| if (tmp == 0) |
| spec->autocfg.hp_pins[0] = porta; |
| else if (tmp == 1) |
| spec->autocfg.hp_pins[0] = porte; |
| else if (tmp == 2) |
| spec->autocfg.hp_pins[0] = portd; |
| else |
| return; |
| } |
| |
| snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, |
| AC_VERB_SET_UNSOLICITED_ENABLE, |
| AC_USRSP_EN | ALC880_HP_EVENT); |
| spec->unsol_event = alc_sku_unsol_event; |
| spec->init_hook = alc_sku_automute; |
| } |
| |
| /* |
| * Fix-up pin default configurations |
| */ |
| |
| struct alc_pincfg { |
| hda_nid_t nid; |
| u32 val; |
| }; |
| |
| static void alc_fix_pincfg(struct hda_codec *codec, |
| const struct snd_pci_quirk *quirk, |
| const struct alc_pincfg **pinfix) |
| { |
| const struct alc_pincfg *cfg; |
| |
| quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| if (!quirk) |
| return; |
| |
| cfg = pinfix[quirk->value]; |
| for (; cfg->nid; cfg++) { |
| int i; |
| u32 val = cfg->val; |
| for (i = 0; i < 4; i++) { |
| snd_hda_codec_write(codec, cfg->nid, 0, |
| AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, |
| val & 0xff); |
| val >>= 8; |
| } |
| } |
| } |
| |
| /* |
| * ALC880 3-stack model |
| * |
| * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) |
| * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
| * F-Mic = 0x1b, HP = 0x19 |
| */ |
| |
| static hda_nid_t alc880_dac_nids[4] = { |
| /* front, rear, clfe, rear_surr */ |
| 0x02, 0x05, 0x04, 0x03 |
| }; |
| |
| static hda_nid_t alc880_adc_nids[3] = { |
| /* ADC0-2 */ |
| 0x07, 0x08, 0x09, |
| }; |
| |
| /* The datasheet says the node 0x07 is connected from inputs, |
| * but it shows zero connection in the real implementation on some devices. |
| * Note: this is a 915GAV bug, fixed on 915GLV |
| */ |
| static hda_nid_t alc880_adc_nids_alt[2] = { |
| /* ADC1-2 */ |
| 0x08, 0x09, |
| }; |
| |
| #define ALC880_DIGOUT_NID 0x06 |
| #define ALC880_DIGIN_NID 0x0a |
| |
| static struct hda_input_mux alc880_capture_source = { |
| .num_items = 4, |
| .items = { |
| { "Mic", 0x0 }, |
| { "Front Mic", 0x3 }, |
| { "Line", 0x2 }, |
| { "CD", 0x4 }, |
| }, |
| }; |
| |
| /* channel source setting (2/6 channel selection for 3-stack) */ |
| /* 2ch mode */ |
| static struct hda_verb alc880_threestack_ch2_init[] = { |
| /* set line-in to input, mute it */ |
| { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| /* set mic-in to input vref 80%, mute it */ |
| { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| { } /* end */ |
| }; |
| |
| /* 6ch mode */ |
| static struct hda_verb alc880_threestack_ch6_init[] = { |
| /* set line-in to output, unmute it */ |
| { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| /* set mic-in to output, unmute it */ |
| { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| { } /* end */ |
| }; |
| |
| static struct hda_channel_mode alc880_threestack_modes[2] = { |
| { 2, alc880_threestack_ch2_init }, |
| { 6, alc880_threestack_ch6_init }, |
| }; |
| |
| static struct snd_kcontrol_new alc880_three_stack_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("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("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
| { |
| .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 */ |
| }; |
| |
| /* capture mixer elements */ |
| static struct snd_kcontrol_new alc880_capture_mixer[] = { |
| HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| { |
| .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| /* The multiple "Capture Source" controls confuse alsamixer |
| * So call somewhat different.. |
| * FIXME: the controls appear in the "playback" view! |
| */ |
| /* .name = "Capture Source", */ |
| .name = "Input Source", |
| .count = 3, |
| .info = alc_mux_enum_info, |
| .get = alc_mux_enum_get, |
| .put = alc_mux_enum_put, |
| }, |
| { } /* end */ |
| }; |
| |
| /* capture mixer elements (in case NID 0x07 not available) */ |
| static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
| HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| { |
| .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| /* The multiple "Capture Source" controls confuse alsamixer |
| * So call somewhat different.. |
| * FIXME: the controls appear in the "playback" view! |
| */ |
| /* .name = "Capture Source", */ |
| .name = "Input Source", |
| .count = 2, |
| .info = alc_mux_enum_info, |
| .get = alc_mux_enum_get, |
| .put = alc_mux_enum_put, |
| }, |
| { } /* end */ |
| }; |
| |
| |
| |
| /* |
| * ALC880 5-stack model |
| * |
| * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
| * Side = 0x02 (0xd) |
| * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
| * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 |
| */ |
| |
| /* additional mixers to alc880_three_stack_mixer */ |
| static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
| HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| /* channel source setting (6/8 channel selection for 5-stack) */ |
| /* 6ch mode */ |
| static struct hda_verb alc880_fivestack_ch6_init[] = { |
| /* set line-in to input, mute it */ |
| { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| { } /* end */ |
| }; |
| |
| /* 8ch mode */ |
| static struct hda_verb alc880_fivestack_ch8_init[] = { |
| /* set line-in to output, unmute it */ |
| { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| { } /* end */ |
| }; |
| |
| static struct hda_channel_mode alc880_fivestack_modes[2] = { |
| { 6, alc880_fivestack_ch6_init }, |
| { 8, alc880_fivestack_ch8_init }, |
| }; |
| |
| |
| /* |
| * ALC880 6-stack model |
| * |
| * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
| * Side = 0x05 (0x0f) |
| * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
| * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b |
| */ |
| |
| static hda_nid_t alc880_6st_dac_nids[4] = { |
| /* front, rear, clfe, rear_surr */ |
| 0x02, 0x03, 0x04, 0x05 |
| }; |
| |
| static struct hda_input_mux alc880_6stack_capture_source = { |
| .num_items = 4, |
| .items = { |
| { "Mic", 0x0 }, |
| { "Front Mic", 0x1 }, |
| { "Line", 0x2 }, |
| { "CD", 0x4 }, |
| }, |
| }; |
| |
| /* fixed 8-channels */ |
| static struct hda_channel_mode alc880_sixstack_modes[1] = { |
| { 8, NULL }, |
| }; |
| |
| static struct snd_kcontrol_new alc880_six_stack_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", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 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("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
| 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("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, 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 */ |
| }; |
| |
| |
| /* |
| * ALC880 W810 model |
| * |
| * W810 has rear IO for: |
| * Front (DAC 02) |
| * Surround (DAC 03) |
| * Center/LFE (DAC 04) |
| * Digital out (06) |
| * |
| * The system also has a pair of internal speakers, and a headphone jack. |
| * These are both connected to Line2 on the codec, hence to DAC 02. |
| * |
| * There is a variable resistor to control the speaker or headphone |
| * volume. This is a hardware-only device without a software API. |
| * |
| * Plugging headphones in will disable the internal speakers. This is |
| * implemented in hardware, not via the driver using jack sense. In |
| * a similar fashion, plugging into the rear socket marked "front" will |
| * disable both the speakers and headphones. |
| * |
| * For input, there's a microphone jack, and an "audio in" jack. |
| * These may not do anything useful with this driver yet, because I |
| * haven't setup any initialization verbs for these yet... |
| */ |
| |
| static hda_nid_t alc880_w810_dac_nids[3] = { |
| /* front, rear/surround, clfe */ |
| 0x02, 0x03, 0x04 |
| }; |
| |
| /* fixed 6 channels */ |
| static struct hda_channel_mode alc880_w810_modes[1] = { |
| { 6, NULL } |
| }; |
| |
| /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ |
| static struct snd_kcontrol_new alc880_w810_base_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", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 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_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| { } /* end */ |
| }; |
| |
| |
| /* |
| * Z710V model |
| * |
| * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) |
| * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
| * Line = 0x1a |
| */ |
| |
| static hda_nid_t alc880_z71v_dac_nids[1] = { |
| 0x02 |
| }; |
| #define ALC880_Z71V_HP_DAC 0x03 |
| |
| /* fixed 2 channels */ |
| static struct hda_channel_mode alc880_2_jack_modes[1] = { |
| { 2, NULL } |
| }; |
| |
| static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
| HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| |
| /* FIXME! */ |
| /* |
| * ALC880 F1734 model |
| * |
| * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) |
| * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 |
| */ |
| |
| static hda_nid_t alc880_f1734_dac_nids[1] = { |
| 0x03 |
| }; |
| #define ALC880_F1734_HP_DAC 0x02 |
| |
| static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
| HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| |
| /* FIXME! */ |
| /* |
| * ALC880 ASUS model |
| * |
| * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| * Mic = 0x18, Line = 0x1a |
| */ |
| |
| #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ |
| #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ |
| |
| static struct snd_kcontrol_new alc880_asus_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", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 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("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), |
| { |
| .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 */ |
| }; |
| |
| /* FIXME! */ |
| /* |
| * ALC880 ASUS W1V model |
| * |
| * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| * Mic = 0x18, Line = 0x1a, Line2 = 0x1b |
| */ |
| |
| /* additional mixers to alc880_asus_mixer */ |
| static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
| HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
| HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| /* additional mixers to alc880_asus_mixer */ |
| static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
| HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| /* TCL S700 */ |
| static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { |
| HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| HDA_CODEC_MUTE("Headphone 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("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), |
| HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| { |
| .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| /* The multiple "Capture Source" controls confuse alsamixer |
| * So call somewhat different.. |
| * FIXME: the controls appear in the "playback" view! |
| */ |
| /* .name = "Capture Source", */ |
| .name = "Input Source", |
| .count = 1, |
| .info = alc_mux_enum_info, |
| .get = alc_mux_enum_get, |
| .put = alc_mux_enum_put, |
| }, |
| { } /* end */ |
| }; |
| |
| /* Uniwill */ |
| static struct snd_kcontrol_new alc880_uniwill_mixer[] = { |
| HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 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("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("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, 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 struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
| HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
| HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| { } /* end */ |
| }; |
| |
| /* |
| * build control elements |
| */ |
| static int alc_build_controls(struct hda_codec *codec) |
| { |
| struct alc_spec *spec = codec->spec; |
| int err; |
| int i; |
| |
| for (i = 0; i < spec->num_mixers; i++) { |
| err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| if (err < 0) |
| return err; |
| } |
| |
| if (spec->multiout.dig_out_nid) { |
| err = snd_hda_create_spdif_out_ctls(codec, |
| spec->multiout.dig_out_nid); |
| if (err < 0) |
| return err; |
| } |
| if (spec->dig_in_nid) { |
| err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| if (err < 0) |
| return err; |
| } |
| return 0; |
| } |
| |
| |
| /* |
| * initialize the codec volumes, etc |
| */ |
| |
| /* |
| * generic initialization of ADC, input mixers and output mixers |
| */ |
| static struct hda_verb alc880_volume_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)}, |
| |
| /* Unmute 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)}, |
| {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| |
| /* |
| * Set up output mixers (0x0c - 0x0f) |
| */ |
| /* 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}, |
| {0x0f, 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_MUTE(0)}, |
| {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| |
| { } |
| }; |
| |
| /* |
| * 3-stack pin configuration: |
| * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b |
| */ |
| static struct hda_verb alc880_pin_3stack_init_verbs[] = { |
| /* |
| * preset connection lists of input pins |
| * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| */ |
| {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
| {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ |
| |
| /* |
| * Set pin mode and muting |
| */ |
| /* set front pin widgets 0x14 for output */ |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {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_UNMUTE}, |
| /* Line In pin widget for input */ |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| /* CD pin widget for input */ |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| { } |
| }; |
| |
| /* |
| * 5-stack pin configuration: |
| * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, |
| * line-in/side = 0x1a, f-mic = 0x1b |
| */ |
| static struct hda_verb alc880_pin_5stack_init_verbs[] = { |
| /* |
| * preset connection lists of input pins |
| * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| */ |
| {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ |
| |
| /* |
| * Set pin mode and muting |
| */ |
| /* set pin widgets 0x14-0x17 for output */ |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| /* unmute pins for output (no gain on this amp) */ |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x17, 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_UNMUTE}, |
| /* Line In pin widget for input */ |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| /* CD pin widget for input */ |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| { } |
| }; |
| |
| /* |
| * W810 pin configuration: |
| * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b |
| */ |
| static struct hda_verb alc880_pin_w810_init_verbs[] = { |
| /* hphone/speaker input selector: front DAC */ |
| {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| |
| { } |
| }; |
| |
| /* |
| * Z71V pin configuration: |
| * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) |
| */ |
| static struct hda_verb alc880_pin_z71v_init_verbs[] = { |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| { } |
| }; |
| |
| /* |
| * 6-stack pin configuration: |
| * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
| * f-mic = 0x19, line = 0x1a, HP = 0x1b |
| */ |
| static struct hda_verb alc880_pin_6stack_init_verbs[] = { |
| {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| { } |
| }; |
| |
| /* |
| * Uniwill pin configuration: |
| * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, |
| * line = 0x1a |
| */ |
| static struct hda_verb alc880_uniwill_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}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ |
| /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
| {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
| |
| { } |
| }; |
| |
| /* |
| * Uniwill P53 |
| * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, |
| */ |
| static struct hda_verb alc880_uniwill_p53_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}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| |
| {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
| {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, |
| |
| { } |
| }; |
| |
| static struct hda_verb alc880_beep_init_verbs[] = { |
| { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, |
| { } |
| }; |
| |
| /* toggle speaker-output according to the hp-jack state */ |
| static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
| { |
| unsigned int present; |
| unsigned char bits; |
| |
| present = snd_hda_codec_read(codec, 0x14, 0, |
| AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| bits = present ? HDA_AMP_MUTE : 0; |
| snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, bits); |
| snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, bits); |
| } |
| |
| /* auto-toggle front mic */ |
| static void alc880_uniwill_mic_automute(struct hda_codec *codec) |
| { |
| unsigned int present; |
| unsigned char bits; |
| |
| present = snd_hda_codec_read(codec, 0x18, 0, |
| AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| bits = present ? HDA_AMP_MUTE : 0; |
| snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
| } |
| |
| static void alc880_uniwill_automute(struct hda_codec *codec) |
| { |
| alc880_uniwill_hp_automute(codec); |
| alc880_uniwill_mic_automute(codec); |
| } |
| |
| static void alc880_uniwill_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! |
| */ |
| switch (res >> 28) { |
| case ALC880_HP_EVENT: |
| alc880_uniwill_hp_automute(codec); |
| break; |
| case ALC880_MIC_EVENT: |
| alc880_uniwill_mic_automute(codec); |
| break; |
| } |
| } |
| |
| static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) |
| { |
| unsigned int present; |
| unsigned char bits; |
| |
| present = snd_hda_codec_read(codec, 0x14, 0, |
| AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| bits = present ? HDA_AMP_MUTE : 0; |
| snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits); |
| } |
| |
| static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) |
| { |
| unsigned int present; |
| |
| present = snd_hda_codec_read(codec, 0x21, 0, |
| AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| present &= HDA_AMP_VOLMASK; |
| snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, |
| HDA_AMP_VOLMASK, present); |
| snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, |
| HDA_AMP_VOLMASK, present); |
| } |
| |
| static void alc880_uniwill_p53_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) == ALC880_HP_EVENT) |
| alc880_uniwill_p53_hp_automute(codec); |
| if ((res >> 28) == ALC880_DCVOL_EVENT) |
| alc880_uniwill_p53_dcvol_automute(codec); |
| } |
| |
| /* FIXME! */ |
| /* |
| * F1734 pin configuration: |
| * HP = 0x14, speaker-out = 0x15, mic = 0x18 |
| */ |
| static struct hda_verb alc880_pin_f1734_init_verbs[] = { |
| {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| { } |
| }; |
| |
| /* FIXME! */ |
| /* |
| * ASUS pin configuration: |
| * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a |
| */ |
| static struct hda_verb alc880_pin_asus_init_verbs[] = { |
| {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| |
| { } |
| }; |
| |
| /* Enable GPIO mask and set output */ |
| #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
| #define alc880_gpio2_init_verbs alc_gpio2_init_verbs |
| |
| /* Clevo m520g init */ |
| static struct hda_verb alc880_pin_clevo_init_verbs[] = { |
| /* headphone output */ |
| {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| /* line-out */ |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* Line-in */ |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* CD */ |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* Mic1 (rear panel) */ |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* Mic2 (front panel) */ |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* headphone */ |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* change to EAPD mode */ |
| {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| |
| { } |
| }; |
| |
| static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
| /* change to EAPD mode */ |
| {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| |
| /* Headphone output */ |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| /* Front output*/ |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| |
| /* Line In pin widget for input */ |
| {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| /* CD pin widget for input */ |
| {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| |
| /* change to EAPD mode */ |
| {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, |
| |
| { } |
| }; |
| |
| /* |
| * LG m1 express dual |
| * |
| * Pin assignment: |
| * Rear Line-In/Out (blue): 0x14 |
| * Build-in Mic-In: 0x15 |
| * Speaker-out: 0x17 |
| * HP-Out (green): 0x1b |
| * Mic-In/Out (red): 0x19 |
| * SPDIF-Out: 0x1e |
| */ |
| |
| /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ |
| static hda_nid_t alc880_lg_dac_nids[3] = { |
| 0x05, 0x02, 0x03 |
| }; |
| |
| /* seems analog CD is not working */ |
| static struct hda_input_mux alc880_lg_capture_source = { |
| .num_items = 3, |
| .items = { |
| { "Mic", 0x1 }, |
| { "Line", 0x5 }, |
| { "Internal Mic", 0x6 }, |
| }, |
| }; |
| |
| /* 2,4,6 channel modes */ |
| static struct hda_verb alc880_lg_ch2_init[] = { |
| /* set line-in and mic-in to input */ |
| { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| { } |
| }; |
| |
| static struct hda_verb alc880_lg_ch4_init[] = { |
| /* set line-in to out and mic-in to input */ |
| { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| { } |
| }; |
| |
| static struct hda_verb alc880_lg_ch6_init[] = { |
| /* set line-in and mic-in to output */ |
| { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| { } |
| }; |
| |
| static struct hda_channel_mode alc880_lg_ch_modes[3] = { |
| { 2, alc880_lg_ch2_init }, |
| { 4, alc880_lg_ch4_init }, |
| { 6, alc880_lg_ch6_init }, |
| }; |
| |
| static struct snd_kcontrol_new alc880_lg_mixer[] = { |
| /* FIXME: it's not really "master" but front channels */ |
| HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), |
| HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), |
| HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), |
| HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), |
| HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), |
| HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, 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 struct hda_verb alc880_lg_init_verbs[] = { |
| /* set capture source to mic-in */ |
| {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| /* mute all amp mixer inputs */ |
| {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, |
| {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| /* line-in to input */ |
| {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* built-in mic */ |
| {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* speaker-out */ |
| {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* mic-in to input */ |
| {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* HP-out */ |
| {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| /* jack sense */ |
| {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, |
| { } |
| }; |
| |
| /* toggle speaker-output according to the hp-jack state */ |
| static void alc880_lg_automute(struct hda_codec *codec) |
| { |
| unsigned int present; |
| unsigned char bits; |
| |
| present = snd_hda_codec_read(codec, 0x1b, 0, |
| AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| bits = present ? HDA_AMP_MUTE : 0; |
| snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, bits); |
| } |
| |
| static void alc880_lg_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) == 0x01) |
| alc880_lg_automute(codec); |
| } |
| |
| /* |
| * 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 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 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 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 | 0x1}, |
| { } |
| }; |
| |
| /* toggle speaker-output according to the hp-jack state */ |
| static void alc880_lg_lw_automute(struct hda_codec *codec) |
| { |
| unsigned int present; |
| unsigned char bits; |
| |
| present = snd_hda_codec_read(codec, 0x1b, 0, |
| AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| bits = present ? HDA_AMP_MUTE : 0; |
| snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, bits); |
| } |
| |
| static void alc880_lg_lw_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) == 0x01) |
| alc880_lg_lw_automute(codec); |
| } |
| |
| #ifdef CONFIG_SND_HDA_POWER_SAVE |
| static struct hda_amp_list alc880_loopbacks[] = { |
| { 0x0b, HDA_INPUT, 0 }, |
| { 0x0b, HDA_INPUT, 1 }, |
| { 0x0b, HDA_INPUT, 2 }, |
| { 0x0b, HDA_INPUT, 3 }, |
| { 0x0b, HDA_INPUT, 4 }, |
| { } /* end */ |
| }; |
| |
| static struct hda_amp_list alc880_lg_loopbacks[] = { |
| { 0x0b, HDA_INPUT, 1 }, |
| { 0x0b, HDA_INPUT, 6 }, |
| { 0x0b, HDA_INPUT, 7 }, |
| { } /* end */ |
| }; |
| #endif |
| |
| /* |
| * Common callbacks |
| */ |
| |
| static int alc_init(struct hda_codec *codec) |
| { |
| struct alc_spec *spec = codec->spec; |
| unsigned int i; |
| |
| for (i = 0; i < spec->num_init_verbs; i++) |
| snd_hda_sequence_write(codec, spec->init_verbs[i]); |
| |
| if (spec->init_hook) |
| spec->init_hook(codec); |
| |
| return 0; |
| } |
| |
| static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| { |
| struct alc_spec *spec = codec->spec; |
| |
| if (spec->unsol_event) |
| spec->unsol_event(codec, res); |
| } |
| |
| #ifdef CONFIG_SND_HDA_POWER_SAVE |
| static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| } |
| #endif |
| |
| /* |
| * Analog playback callbacks |
| */ |
| static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| } |
| |
| static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| unsigned int stream_tag, |
| unsigned int format, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| stream_tag, format, substream); |
| } |
| |
| static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| } |
| |
| /* |
| * Digital out |
| */ |
| static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| } |
| |
| static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| unsigned int stream_tag, |
| unsigned int format, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| stream_tag, format, substream); |
| } |
| |
| static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| } |
| |
| /* |
| * Analog capture |
| */ |
| static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| unsigned int stream_tag, |
| unsigned int format, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| |
| snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| stream_tag, 0, format); |
| return 0; |
| } |
| |
| static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| struct hda_codec *codec, |
| struct snd_pcm_substream *substream) |
| { |
| struct alc_spec *spec = codec->spec; |
| |
| snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 0, 0, 0); |
| return 0; |
| } |
| |
| |
| /* |
| */ |
| static struct hda_pcm_stream alc880_pcm_analog_playback = { |
| .substreams = 1, |
| .channels_min = 2, |
| .channels_max = 8, |
| /* NID is set in alc_build_pcms */ |
| .ops = { |
| .open = alc880_playback_pcm_open, |
| .prepare = alc880_playback_pcm_prepare, |
| .cleanup = alc880_playback_pcm_cleanup |
| }, |
| }; |
| |
| static struct hda_pcm_stream alc880_pcm_analog_capture = { |
| .substreams = 2, |
| .channels_min = 2, |
| .channels_max = 2, |
| /* NID is set in alc_build_pcms */ |
| .ops = { |
| .prepare = alc880_capture_pcm_prepare, |
| .cleanup = alc880_capture_pcm_cleanup |
| }, |
| }; |
| |
| static struct hda_pcm_stream alc880_pcm_digital_playback = { |
| .substreams = 1, |
| .channels_min = 2, |
| .channels_max = 2, |
| /* NID is set in alc_build_pcms */ |
| .ops = { |
| .open = alc880_dig_playback_pcm_open, |
| .close = alc880_dig_playback_pcm_close, |
| .prepare = alc880_dig_playback_pcm_prepare |
| }, |
| }; |
| |
| static struct hda_pcm_stream alc880_pcm_digital_capture = { |
| .substreams = 1, |
| .channels_min = 2, |
| .channels_max = 2, |
| /* NID is set in alc_build_pcms */ |
| }; |
| |
| /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
| static struct hda_pcm_stream alc_pcm_null_playback = { |
| .substreams = 0, |
| .channels_min = 0, |
| .channels_max = 0, |
| }; |
| |
| static int alc_build_pcms(struct hda_codec *codec) |
| { |
| struct alc_spec *spec = codec->spec; |
| struct hda_pcm *info = spec->pcm_rec; |
| int i; |
| |
| codec->num_pcms = 1; |
| codec->pcm_info = info; |
| |
| info->name = spec->stream_name_analog; |
| if (spec->stream_analog_playback) { |
| snd_assert(spec->multiout.dac_nids, return -EINVAL); |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| } |
| if (spec->stream_analog_capture) { |
| snd_assert(spec->adc_nids, return -EINVAL); |
| info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
| info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| } |
| |
| if (spec->channel_mode) { |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| for (i = 0; i < spec->num_channel_mode; i++) { |
| if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| } |
| } |
| } |
| |
| /* SPDIF for stream index #1 */ |
| if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| codec->num_pcms = 2; |
| info = spec->pcm_rec + 1; |
| info->name = spec->stream_name_digital; |
| if (spec->multiout.dig_out_nid && |
| spec->stream_digital_playback) { |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| } |
| if (spec->dig_in_nid && |
| spec->stream_digital_capture) { |
| info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
| info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| } |
| } |
| |
| /* If the use of more than one ADC is requested for the current |
| * model, configure a second analog capture-only PCM. |
| */ |
| /* Additional Analaog capture for index #2 */ |
| if (spec->num_adc_nids > 1 && spec->stream_analog_capture && |
| spec->adc_nids) { |
| codec->num_pcms = 3; |
| info = spec->pcm_rec + 2; |
| info->name = spec->stream_name_analog; |
| /* No playback stream for second PCM */ |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; |
| info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| if (spec->stream_analog_capture) { |
| info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
| info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; |
| } |
| } |
| |
| return 0; |
| } |
| |
| static void alc_free(struct hda_codec *codec) |
| { |
| struct alc_spec *spec = codec->spec; |
| unsigned int i; |
| |
| if (!spec) |
| return; |
| |
| if (spec->kctl_alloc) { |
| for (i = 0; i < spec->num_kctl_used; i++) |
| kfree(spec->kctl_alloc[i].name); |
| kfree(spec->kctl_alloc); |
| } |
| kfree(spec); |
| } |
| |
| /* |
| */ |
| static struct hda_codec_ops alc_patch_ops = { |
| .build_controls = alc_build_controls, |
| .build_pcms = alc_build_pcms, |
| .init = alc_init, |
| .free = alc_free, |
| .unsol_event = alc_unsol_event, |
| #ifdef CONFIG_SND_HDA_POWER_SAVE |
| .check_power_status = alc_check_power_status, |
| #endif |
| }; |
| |
| |
| /* |
| * Test configuration for debugging |
| * |
| * Almost all inputs/outputs are enabled. I/O pins can be configured via |
| * enum controls. |
| */ |
| #ifdef CONFIG_SND_DEBUG |
| static hda_nid_t alc880_test_dac_nids[4] = { |
| 0x02, 0x03, 0x04, 0x05 |
| }; |
| |
| static struct hda_input_mux alc880_test_capture_source = { |
| .num_items = 7, |
| .items = { |
| { "In-1", 0x0 }, |
| { "In-2", 0x1 }, |
| { "In-3", 0x2 }, |
| { "In-4", 0x3 }, |
| { "CD", 0x4 }, |
| { "Front", 0x5 }, |
| { "Surround", 0x6 }, |
| }, |
| }; |
| |
| static struct hda_channel_mode alc880_test_modes[4] = { |
| { 2, NULL }, |
| { 4, NULL }, |
| { 6, NULL }, |
| { 8, NULL }, |
| }; |
| |
| static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_info *uinfo) |
| { |
| static char *texts[] = { |
| "N/A", "Line Out", "HP Out", |
| "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" |
| }; |
| uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| uinfo->count = 1; |
| uinfo->value.enumerated.items = 8; |
| if (uinfo->value.enumerated.item >= 8) |
| uinfo->value.enumerated.item = 7; |
| strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| return 0; |
| } |
| |
| static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| unsigned int pin_ctl, item = 0; |
| |
| pin_ctl = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| if (pin_ctl & AC_PINCTL_OUT_EN) { |
| if (pin_ctl & AC_PINCTL_HP_EN) |
| item = 2; |
| else |
| item = 1; |
| } else if (pin_ctl & AC_PINCTL_IN_EN) { |
| switch (pin_ctl & AC_PINCTL_VREFEN) { |
| case AC_PINCTL_VREF_HIZ: item = 3; break; |
| case AC_PINCTL_VREF_50: item = 4; break; |
| case AC_PINCTL_VREF_GRD: item = 5; break; |
| case AC_PINCTL_VREF_80: item = 6; break; |
| case AC_PINCTL_VREF_100: item = 7; break; |
| } |
| } |
| ucontrol->value.enumerated.item[0] = item; |
| return 0; |
| } |
| |
| static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| static unsigned int ctls[] = { |
| 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, |
| AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, |
| AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, |
| AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, |
| AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, |
| AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, |
| }; |
| unsigned int old_ctl, new_ctl; |
| |
| old_ctl = snd_hda_codec_read(codec, nid, 0, |
| AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| new_ctl = ctls[ucontrol->value.enumerated.item[0]]; |
| if (old_ctl != new_ctl) { |
| int val; |
| snd_hda_codec_write_cache(codec, nid, 0, |
| AC_VERB_SET_PIN_WIDGET_CONTROL, |
| new_ctl); |
| val = ucontrol->value.enumerated.item[0] >= 3 ? |
| HDA_AMP_MUTE : 0; |
| snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| HDA_AMP_MUTE, val); |
| return 1; |
| } |
| return 0; |
| } |
| |
| static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_info *uinfo) |
| { |
| static char *texts[] = { |
| "Front", "Surround", "CLFE", "Side" |
| }; |
| uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| uinfo->count = 1; |
| uinfo->value.enumerated.items = 4; |
| if (uinfo->value.enumerated.item >= 4) |
| uinfo->value.enumerated.item = 3; |
| strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| return 0; |
| } |
| |
| static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| unsigned int sel; |
| |
| sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| ucontrol->value.enumerated.item[0] = sel & 3; |
| return 0; |
| } |
| |
| static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
| struct snd_ctl_elem_value *ucontrol) |
| { |
| struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| unsigned int sel; |
| |
| sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; |
| if (ucontrol->value.enumerated.item[0] != sel) { |
| sel = ucontrol->value.enumerated.item[0] & 3; |
| snd_hda_codec_write_cache(codec, nid, 0, |
| AC_VERB_SET_CONNECT_SEL, sel); |
| return 1; |
| } |
| return 0; |
| } |
| |
| #define PIN_CTL_TEST(xname,nid) { \ |
| .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| .name = xname, \ |
| .info = alc_test_pin_ctl_info, \ |
| .get = alc_test_pin_ctl_get, \ |
| .put = alc_test_pin_ctl_put, \ |
| .private_value = nid \ |
| } |
| |
| #define PIN_SRC_TEST(xname,nid) { \ |
| .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| .name = xname, \ |
| .info = alc_test_pin_src_info, \ |
| .get = alc_test_pin_src_get, \ |
| .put = alc_test_pin_src_put, \ |
| .private_value = nid \ |
| } |
| |
| static struct snd_kcontrol_new alc880_test_mixer[] = { |
| HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
| HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
| HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
| HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), |
| HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
| PIN_CTL_TEST("Front Pin Mode", 0x14), |
| PIN_CTL_TEST("Surround Pin Mode", 0x15), |
| PIN_CTL_TEST("CLFE Pin Mode", 0x16), |
| PIN_CTL_TEST("Side Pin Mode", 0x17), |
| PIN_CTL_TEST("In-1 Pin Mode", 0x18), |
| PIN_CTL_TEST("In-2 Pin Mode", 0x19), |
| PIN_CTL_TEST("In-3 Pin Mode", 0x1a), |
| PIN_CTL_TEST("In-4 Pin Mode", 0x1b), |
| PIN_SRC_TEST("In-1 Pin Source", 0x18), |
| PIN_SRC_TEST("In-2 Pin Source", 0x19), |
| PIN_SRC_TEST("In-3 Pin Source", 0x1a), |
| PIN_SRC_TEST("In-4 Pin Source", 0x1b), |
| HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), |
| HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), |
| HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), |
| HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, 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 */ |
| }; |
|