?? patch_realtek.c
字號:
/* * 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 0x03struct 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);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -