diff options
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 124 |
1 files changed, 10 insertions, 114 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 8f1bd80e6027..2a94c58b2104 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -4193,119 +4193,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
4193 | /* | 4193 | /* |
4194 | * ALC262 support | 4194 | * ALC262 support |
4195 | */ | 4195 | */ |
4196 | |||
4197 | /* We use two mixers depending on the output pin; 0x16 is a mono output | ||
4198 | * and thus it's bound with a different mixer. | ||
4199 | * This function returns which mixer amp should be used. | ||
4200 | */ | ||
4201 | static int alc262_check_volbit(hda_nid_t nid) | ||
4202 | { | ||
4203 | if (!nid) | ||
4204 | return 0; | ||
4205 | else if (nid == 0x16) | ||
4206 | return 2; | ||
4207 | else | ||
4208 | return 1; | ||
4209 | } | ||
4210 | |||
4211 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
4212 | const char *pfx, int *vbits, int idx) | ||
4213 | { | ||
4214 | unsigned long val; | ||
4215 | int vbit; | ||
4216 | |||
4217 | vbit = alc262_check_volbit(nid); | ||
4218 | if (!vbit) | ||
4219 | return 0; | ||
4220 | if (*vbits & vbit) /* a volume control for this mixer already there */ | ||
4221 | return 0; | ||
4222 | *vbits |= vbit; | ||
4223 | if (vbit == 2) | ||
4224 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | ||
4225 | else | ||
4226 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | ||
4227 | return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val); | ||
4228 | } | ||
4229 | |||
4230 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
4231 | const char *pfx, int idx) | ||
4232 | { | ||
4233 | unsigned long val; | ||
4234 | |||
4235 | if (!nid) | ||
4236 | return 0; | ||
4237 | if (nid == 0x16) | ||
4238 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | ||
4239 | else | ||
4240 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | ||
4241 | return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val); | ||
4242 | } | ||
4243 | |||
4244 | /* add playback controls from the parsed DAC table */ | ||
4245 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, | ||
4246 | const struct auto_pin_cfg *cfg) | ||
4247 | { | ||
4248 | const char *pfx; | ||
4249 | int vbits; | ||
4250 | int i, index, err; | ||
4251 | |||
4252 | spec->multiout.num_dacs = 1; /* only use one dac */ | ||
4253 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
4254 | spec->private_dac_nids[0] = 2; | ||
4255 | |||
4256 | for (i = 0; i < 2; i++) { | ||
4257 | pfx = alc_get_line_out_pfx(spec, i, true, &index); | ||
4258 | if (!pfx) | ||
4259 | pfx = "PCM"; | ||
4260 | err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, | ||
4261 | index); | ||
4262 | if (err < 0) | ||
4263 | return err; | ||
4264 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { | ||
4265 | err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i], | ||
4266 | "Speaker", i); | ||
4267 | if (err < 0) | ||
4268 | return err; | ||
4269 | } | ||
4270 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { | ||
4271 | err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i], | ||
4272 | "Headphone", i); | ||
4273 | if (err < 0) | ||
4274 | return err; | ||
4275 | } | ||
4276 | } | ||
4277 | |||
4278 | vbits = alc262_check_volbit(cfg->line_out_pins[0]) | | ||
4279 | alc262_check_volbit(cfg->speaker_pins[0]) | | ||
4280 | alc262_check_volbit(cfg->hp_pins[0]); | ||
4281 | vbits = 0; | ||
4282 | for (i = 0; i < 2; i++) { | ||
4283 | pfx = alc_get_line_out_pfx(spec, i, true, &index); | ||
4284 | if (!pfx) | ||
4285 | pfx = "PCM"; | ||
4286 | err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx, | ||
4287 | &vbits, i); | ||
4288 | if (err < 0) | ||
4289 | return err; | ||
4290 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { | ||
4291 | err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i], | ||
4292 | "Speaker", &vbits, i); | ||
4293 | if (err < 0) | ||
4294 | return err; | ||
4295 | } | ||
4296 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { | ||
4297 | err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i], | ||
4298 | "Headphone", &vbits, i); | ||
4299 | if (err < 0) | ||
4300 | return err; | ||
4301 | } | ||
4302 | } | ||
4303 | return 0; | ||
4304 | } | ||
4305 | |||
4306 | /* | ||
4307 | * BIOS auto configuration | ||
4308 | */ | ||
4309 | static int alc262_parse_auto_config(struct hda_codec *codec) | 4196 | static int alc262_parse_auto_config(struct hda_codec *codec) |
4310 | { | 4197 | { |
4311 | struct alc_spec *spec = codec->spec; | 4198 | struct alc_spec *spec = codec->spec; |
@@ -4324,7 +4211,16 @@ static int alc262_parse_auto_config(struct hda_codec *codec) | |||
4324 | } | 4211 | } |
4325 | return 0; /* can't find valid BIOS pin config */ | 4212 | return 0; /* can't find valid BIOS pin config */ |
4326 | } | 4213 | } |
4327 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); | 4214 | err = alc_auto_fill_dac_nids(codec); |
4215 | if (err < 0) | ||
4216 | return err; | ||
4217 | err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg); | ||
4218 | if (err < 0) | ||
4219 | return err; | ||
4220 | err = alc_auto_create_hp_out(codec); | ||
4221 | if (err < 0) | ||
4222 | return err; | ||
4223 | err = alc_auto_create_speaker_out(codec); | ||
4328 | if (err < 0) | 4224 | if (err < 0) |
4329 | return err; | 4225 | return err; |
4330 | err = alc_auto_create_input_ctls(codec); | 4226 | err = alc_auto_create_input_ctls(codec); |