diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-10-17 10:39:09 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-10-17 17:39:32 -0400 |
commit | e16fb6d1408bca0c0b36d490688eba3dc924b1fd (patch) | |
tree | 2499ce9b20eec4bac8d6a119559c8f403582d03b /sound/pci | |
parent | 84db9150b64ccad9c40e42a9967f1cf9592ebc8f (diff) |
ALSA: hda/realtek - Clean up codec renames
Use a static table for detecting the codec renames.
Also clean up the error paths in each patch_*() function.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 289 |
1 files changed, 139 insertions, 150 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cc861c1d69ec..ab6b9fa203d0 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -2480,6 +2480,49 @@ static int alc_codec_rename(struct hda_codec *codec, const char *name) | |||
2480 | } | 2480 | } |
2481 | 2481 | ||
2482 | /* | 2482 | /* |
2483 | * Rename codecs appropriately from COEF value | ||
2484 | */ | ||
2485 | struct alc_codec_rename_table { | ||
2486 | unsigned int vendor_id; | ||
2487 | unsigned short coef_mask; | ||
2488 | unsigned short coef_bits; | ||
2489 | const char *name; | ||
2490 | }; | ||
2491 | |||
2492 | static struct alc_codec_rename_table rename_tbl[] = { | ||
2493 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, | ||
2494 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, | ||
2495 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, | ||
2496 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, | ||
2497 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, | ||
2498 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, | ||
2499 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, | ||
2500 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, | ||
2501 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, | ||
2502 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, | ||
2503 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, | ||
2504 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, | ||
2505 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, | ||
2506 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, | ||
2507 | { } /* terminator */ | ||
2508 | }; | ||
2509 | |||
2510 | static int alc_codec_rename_from_preset(struct hda_codec *codec) | ||
2511 | { | ||
2512 | const struct alc_codec_rename_table *p; | ||
2513 | unsigned short coef; | ||
2514 | |||
2515 | for (p = rename_tbl; p->vendor_id; p++) { | ||
2516 | if (p->vendor_id != codec->vendor_id) | ||
2517 | continue; | ||
2518 | coef = alc_read_coef_idx(codec, 0); | ||
2519 | if ((coef & p->coef_mask) == p->coef_bits) | ||
2520 | return alc_codec_rename(codec, p->name); | ||
2521 | } | ||
2522 | return 0; | ||
2523 | } | ||
2524 | |||
2525 | /* | ||
2483 | * Automatic parse of I/O pins from the BIOS configuration | 2526 | * Automatic parse of I/O pins from the BIOS configuration |
2484 | */ | 2527 | */ |
2485 | 2528 | ||
@@ -3853,10 +3896,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
3853 | if (board_config == ALC_MODEL_AUTO) { | 3896 | if (board_config == ALC_MODEL_AUTO) { |
3854 | /* automatic parse from the BIOS config */ | 3897 | /* automatic parse from the BIOS config */ |
3855 | err = alc880_parse_auto_config(codec); | 3898 | err = alc880_parse_auto_config(codec); |
3856 | if (err < 0) { | 3899 | if (err < 0) |
3857 | alc_free(codec); | 3900 | goto error; |
3858 | return err; | ||
3859 | } | ||
3860 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS | 3901 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
3861 | else if (!err) { | 3902 | else if (!err) { |
3862 | printk(KERN_INFO | 3903 | printk(KERN_INFO |
@@ -3881,10 +3922,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
3881 | 3922 | ||
3882 | if (!spec->no_analog) { | 3923 | if (!spec->no_analog) { |
3883 | err = snd_hda_attach_beep_device(codec, 0x1); | 3924 | err = snd_hda_attach_beep_device(codec, 0x1); |
3884 | if (err < 0) { | 3925 | if (err < 0) |
3885 | alc_free(codec); | 3926 | goto error; |
3886 | return err; | ||
3887 | } | ||
3888 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 3927 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
3889 | } | 3928 | } |
3890 | 3929 | ||
@@ -3899,6 +3938,10 @@ static int patch_alc880(struct hda_codec *codec) | |||
3899 | #endif | 3938 | #endif |
3900 | 3939 | ||
3901 | return 0; | 3940 | return 0; |
3941 | |||
3942 | error: | ||
3943 | alc_free(codec); | ||
3944 | return err; | ||
3902 | } | 3945 | } |
3903 | 3946 | ||
3904 | 3947 | ||
@@ -3980,10 +4023,8 @@ static int patch_alc260(struct hda_codec *codec) | |||
3980 | if (board_config == ALC_MODEL_AUTO) { | 4023 | if (board_config == ALC_MODEL_AUTO) { |
3981 | /* automatic parse from the BIOS config */ | 4024 | /* automatic parse from the BIOS config */ |
3982 | err = alc260_parse_auto_config(codec); | 4025 | err = alc260_parse_auto_config(codec); |
3983 | if (err < 0) { | 4026 | if (err < 0) |
3984 | alc_free(codec); | 4027 | goto error; |
3985 | return err; | ||
3986 | } | ||
3987 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS | 4028 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
3988 | else if (!err) { | 4029 | else if (!err) { |
3989 | printk(KERN_INFO | 4030 | printk(KERN_INFO |
@@ -4008,10 +4049,8 @@ static int patch_alc260(struct hda_codec *codec) | |||
4008 | 4049 | ||
4009 | if (!spec->no_analog) { | 4050 | if (!spec->no_analog) { |
4010 | err = snd_hda_attach_beep_device(codec, 0x1); | 4051 | err = snd_hda_attach_beep_device(codec, 0x1); |
4011 | if (err < 0) { | 4052 | if (err < 0) |
4012 | alc_free(codec); | 4053 | goto error; |
4013 | return err; | ||
4014 | } | ||
4015 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); | 4054 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
4016 | } | 4055 | } |
4017 | 4056 | ||
@@ -4029,6 +4068,10 @@ static int patch_alc260(struct hda_codec *codec) | |||
4029 | #endif | 4068 | #endif |
4030 | 4069 | ||
4031 | return 0; | 4070 | return 0; |
4071 | |||
4072 | error: | ||
4073 | alc_free(codec); | ||
4074 | return err; | ||
4032 | } | 4075 | } |
4033 | 4076 | ||
4034 | 4077 | ||
@@ -4136,6 +4179,10 @@ static int patch_alc882(struct hda_codec *codec) | |||
4136 | break; | 4179 | break; |
4137 | } | 4180 | } |
4138 | 4181 | ||
4182 | err = alc_codec_rename_from_preset(codec); | ||
4183 | if (err < 0) | ||
4184 | goto error; | ||
4185 | |||
4139 | board_config = alc_board_config(codec, ALC882_MODEL_LAST, | 4186 | board_config = alc_board_config(codec, ALC882_MODEL_LAST, |
4140 | alc882_models, alc882_cfg_tbl); | 4187 | alc882_models, alc882_cfg_tbl); |
4141 | 4188 | ||
@@ -4159,10 +4206,8 @@ static int patch_alc882(struct hda_codec *codec) | |||
4159 | if (board_config == ALC_MODEL_AUTO) { | 4206 | if (board_config == ALC_MODEL_AUTO) { |
4160 | /* automatic parse from the BIOS config */ | 4207 | /* automatic parse from the BIOS config */ |
4161 | err = alc882_parse_auto_config(codec); | 4208 | err = alc882_parse_auto_config(codec); |
4162 | if (err < 0) { | 4209 | if (err < 0) |
4163 | alc_free(codec); | 4210 | goto error; |
4164 | return err; | ||
4165 | } | ||
4166 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS | 4211 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
4167 | else if (!err) { | 4212 | else if (!err) { |
4168 | printk(KERN_INFO | 4213 | printk(KERN_INFO |
@@ -4187,10 +4232,8 @@ static int patch_alc882(struct hda_codec *codec) | |||
4187 | 4232 | ||
4188 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 4233 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
4189 | err = snd_hda_attach_beep_device(codec, 0x1); | 4234 | err = snd_hda_attach_beep_device(codec, 0x1); |
4190 | if (err < 0) { | 4235 | if (err < 0) |
4191 | alc_free(codec); | 4236 | goto error; |
4192 | return err; | ||
4193 | } | ||
4194 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 4237 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
4195 | } | 4238 | } |
4196 | 4239 | ||
@@ -4209,6 +4252,10 @@ static int patch_alc882(struct hda_codec *codec) | |||
4209 | #endif | 4252 | #endif |
4210 | 4253 | ||
4211 | return 0; | 4254 | return 0; |
4255 | |||
4256 | error: | ||
4257 | alc_free(codec); | ||
4258 | return err; | ||
4212 | } | 4259 | } |
4213 | 4260 | ||
4214 | 4261 | ||
@@ -4313,10 +4360,8 @@ static int patch_alc262(struct hda_codec *codec) | |||
4313 | if (board_config == ALC_MODEL_AUTO) { | 4360 | if (board_config == ALC_MODEL_AUTO) { |
4314 | /* automatic parse from the BIOS config */ | 4361 | /* automatic parse from the BIOS config */ |
4315 | err = alc262_parse_auto_config(codec); | 4362 | err = alc262_parse_auto_config(codec); |
4316 | if (err < 0) { | 4363 | if (err < 0) |
4317 | alc_free(codec); | 4364 | goto error; |
4318 | return err; | ||
4319 | } | ||
4320 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS | 4365 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
4321 | else if (!err) { | 4366 | else if (!err) { |
4322 | printk(KERN_INFO | 4367 | printk(KERN_INFO |
@@ -4341,10 +4386,8 @@ static int patch_alc262(struct hda_codec *codec) | |||
4341 | 4386 | ||
4342 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 4387 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
4343 | err = snd_hda_attach_beep_device(codec, 0x1); | 4388 | err = snd_hda_attach_beep_device(codec, 0x1); |
4344 | if (err < 0) { | 4389 | if (err < 0) |
4345 | alc_free(codec); | 4390 | goto error; |
4346 | return err; | ||
4347 | } | ||
4348 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 4391 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
4349 | } | 4392 | } |
4350 | 4393 | ||
@@ -4364,6 +4407,10 @@ static int patch_alc262(struct hda_codec *codec) | |||
4364 | #endif | 4407 | #endif |
4365 | 4408 | ||
4366 | return 0; | 4409 | return 0; |
4410 | |||
4411 | error: | ||
4412 | alc_free(codec); | ||
4413 | return err; | ||
4367 | } | 4414 | } |
4368 | 4415 | ||
4369 | /* | 4416 | /* |
@@ -4427,10 +4474,8 @@ static int patch_alc268(struct hda_codec *codec) | |||
4427 | 4474 | ||
4428 | /* automatic parse from the BIOS config */ | 4475 | /* automatic parse from the BIOS config */ |
4429 | err = alc268_parse_auto_config(codec); | 4476 | err = alc268_parse_auto_config(codec); |
4430 | if (err < 0) { | 4477 | if (err < 0) |
4431 | alc_free(codec); | 4478 | goto error; |
4432 | return err; | ||
4433 | } | ||
4434 | 4479 | ||
4435 | has_beep = 0; | 4480 | has_beep = 0; |
4436 | for (i = 0; i < spec->num_mixers; i++) { | 4481 | for (i = 0; i < spec->num_mixers; i++) { |
@@ -4442,10 +4487,8 @@ static int patch_alc268(struct hda_codec *codec) | |||
4442 | 4487 | ||
4443 | if (has_beep) { | 4488 | if (has_beep) { |
4444 | err = snd_hda_attach_beep_device(codec, 0x1); | 4489 | err = snd_hda_attach_beep_device(codec, 0x1); |
4445 | if (err < 0) { | 4490 | if (err < 0) |
4446 | alc_free(codec); | 4491 | goto error; |
4447 | return err; | ||
4448 | } | ||
4449 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) | 4492 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
4450 | /* override the amp caps for beep generator */ | 4493 | /* override the amp caps for beep generator */ |
4451 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | 4494 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
@@ -4473,6 +4516,10 @@ static int patch_alc268(struct hda_codec *codec) | |||
4473 | alc_init_jacks(codec); | 4516 | alc_init_jacks(codec); |
4474 | 4517 | ||
4475 | return 0; | 4518 | return 0; |
4519 | |||
4520 | error: | ||
4521 | alc_free(codec); | ||
4522 | return err; | ||
4476 | } | 4523 | } |
4477 | 4524 | ||
4478 | /* | 4525 | /* |
@@ -4962,41 +5009,28 @@ static int patch_alc269(struct hda_codec *codec) | |||
4962 | 5009 | ||
4963 | alc_auto_parse_customize_define(codec); | 5010 | alc_auto_parse_customize_define(codec); |
4964 | 5011 | ||
5012 | err = alc_codec_rename_from_preset(codec); | ||
5013 | if (err < 0) | ||
5014 | goto error; | ||
5015 | |||
4965 | if (codec->vendor_id == 0x10ec0269) { | 5016 | if (codec->vendor_id == 0x10ec0269) { |
4966 | unsigned int coef; | 5017 | unsigned int coef; |
4967 | spec->codec_variant = ALC269_TYPE_ALC269VA; | 5018 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
4968 | coef = alc_read_coef_idx(codec, 0); | 5019 | coef = alc_read_coef_idx(codec, 0); |
4969 | if ((coef & 0x00f0) == 0x0010) { | 5020 | if ((coef & 0x00f0) == 0x0010) { |
4970 | if (codec->bus->pci->subsystem_vendor == 0x1025 && | 5021 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
4971 | spec->cdefine.platform_type == 1) { | 5022 | spec->cdefine.platform_type == 1) |
4972 | err = alc_codec_rename(codec, "ALC271X"); | 5023 | err = alc_codec_rename(codec, "ALC271X"); |
4973 | } else if ((coef & 0xf000) == 0x2000) { | ||
4974 | err = alc_codec_rename(codec, "ALC259"); | ||
4975 | } else if ((coef & 0xf000) == 0x3000) { | ||
4976 | err = alc_codec_rename(codec, "ALC258"); | ||
4977 | } else if ((coef & 0xfff0) == 0x3010) { | ||
4978 | err = alc_codec_rename(codec, "ALC277"); | ||
4979 | } else { | ||
4980 | err = alc_codec_rename(codec, "ALC269VB"); | ||
4981 | } | ||
4982 | spec->codec_variant = ALC269_TYPE_ALC269VB; | 5024 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
4983 | } else if ((coef & 0x00f0) == 0x0020) { | 5025 | } else if ((coef & 0x00f0) == 0x0020) { |
4984 | if (coef == 0xa023) | 5026 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
4985 | err = alc_codec_rename(codec, "ALC259"); | 5027 | codec->bus->pci->subsystem_device == 0x21f3) |
4986 | else if (coef == 0x6023) | ||
4987 | err = alc_codec_rename(codec, "ALC281X"); | ||
4988 | else if (codec->bus->pci->subsystem_vendor == 0x17aa && | ||
4989 | codec->bus->pci->subsystem_device == 0x21f3) | ||
4990 | err = alc_codec_rename(codec, "ALC3202"); | 5028 | err = alc_codec_rename(codec, "ALC3202"); |
4991 | else | ||
4992 | err = alc_codec_rename(codec, "ALC269VC"); | ||
4993 | spec->codec_variant = ALC269_TYPE_ALC269VC; | 5029 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
4994 | } else | 5030 | } else |
4995 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 5031 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
4996 | if (err < 0) { | 5032 | if (err < 0) |
4997 | alc_free(codec); | 5033 | goto error; |
4998 | return err; | ||
4999 | } | ||
5000 | alc269_fill_coef(codec); | 5034 | alc269_fill_coef(codec); |
5001 | } | 5035 | } |
5002 | 5036 | ||
@@ -5006,10 +5040,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
5006 | 5040 | ||
5007 | /* automatic parse from the BIOS config */ | 5041 | /* automatic parse from the BIOS config */ |
5008 | err = alc269_parse_auto_config(codec); | 5042 | err = alc269_parse_auto_config(codec); |
5009 | if (err < 0) { | 5043 | if (err < 0) |
5010 | alc_free(codec); | 5044 | goto error; |
5011 | return err; | ||
5012 | } | ||
5013 | 5045 | ||
5014 | if (!spec->no_analog && !spec->adc_nids) { | 5046 | if (!spec->no_analog && !spec->adc_nids) { |
5015 | alc_auto_fill_adc_caps(codec); | 5047 | alc_auto_fill_adc_caps(codec); |
@@ -5022,10 +5054,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
5022 | 5054 | ||
5023 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 5055 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
5024 | err = snd_hda_attach_beep_device(codec, 0x1); | 5056 | err = snd_hda_attach_beep_device(codec, 0x1); |
5025 | if (err < 0) { | 5057 | if (err < 0) |
5026 | alc_free(codec); | 5058 | goto error; |
5027 | return err; | ||
5028 | } | ||
5029 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 5059 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
5030 | } | 5060 | } |
5031 | 5061 | ||
@@ -5049,6 +5079,10 @@ static int patch_alc269(struct hda_codec *codec) | |||
5049 | #endif | 5079 | #endif |
5050 | 5080 | ||
5051 | return 0; | 5081 | return 0; |
5082 | |||
5083 | error: | ||
5084 | alc_free(codec); | ||
5085 | return err; | ||
5052 | } | 5086 | } |
5053 | 5087 | ||
5054 | /* | 5088 | /* |
@@ -5114,10 +5148,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
5114 | 5148 | ||
5115 | /* automatic parse from the BIOS config */ | 5149 | /* automatic parse from the BIOS config */ |
5116 | err = alc861_parse_auto_config(codec); | 5150 | err = alc861_parse_auto_config(codec); |
5117 | if (err < 0) { | 5151 | if (err < 0) |
5118 | alc_free(codec); | 5152 | goto error; |
5119 | return err; | ||
5120 | } | ||
5121 | 5153 | ||
5122 | if (!spec->no_analog && !spec->adc_nids) { | 5154 | if (!spec->no_analog && !spec->adc_nids) { |
5123 | alc_auto_fill_adc_caps(codec); | 5155 | alc_auto_fill_adc_caps(codec); |
@@ -5130,10 +5162,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
5130 | 5162 | ||
5131 | if (!spec->no_analog) { | 5163 | if (!spec->no_analog) { |
5132 | err = snd_hda_attach_beep_device(codec, 0x23); | 5164 | err = snd_hda_attach_beep_device(codec, 0x23); |
5133 | if (err < 0) { | 5165 | if (err < 0) |
5134 | alc_free(codec); | 5166 | goto error; |
5135 | return err; | ||
5136 | } | ||
5137 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); | 5167 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
5138 | } | 5168 | } |
5139 | 5169 | ||
@@ -5150,6 +5180,10 @@ static int patch_alc861(struct hda_codec *codec) | |||
5150 | #endif | 5180 | #endif |
5151 | 5181 | ||
5152 | return 0; | 5182 | return 0; |
5183 | |||
5184 | error: | ||
5185 | alc_free(codec); | ||
5186 | return err; | ||
5153 | } | 5187 | } |
5154 | 5188 | ||
5155 | /* | 5189 | /* |
@@ -5235,10 +5269,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
5235 | 5269 | ||
5236 | /* automatic parse from the BIOS config */ | 5270 | /* automatic parse from the BIOS config */ |
5237 | err = alc861vd_parse_auto_config(codec); | 5271 | err = alc861vd_parse_auto_config(codec); |
5238 | if (err < 0) { | 5272 | if (err < 0) |
5239 | alc_free(codec); | 5273 | goto error; |
5240 | return err; | ||
5241 | } | ||
5242 | 5274 | ||
5243 | if (codec->vendor_id == 0x10ec0660) { | 5275 | if (codec->vendor_id == 0x10ec0660) { |
5244 | /* always turn on EAPD */ | 5276 | /* always turn on EAPD */ |
@@ -5256,10 +5288,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
5256 | 5288 | ||
5257 | if (!spec->no_analog) { | 5289 | if (!spec->no_analog) { |
5258 | err = snd_hda_attach_beep_device(codec, 0x23); | 5290 | err = snd_hda_attach_beep_device(codec, 0x23); |
5259 | if (err < 0) { | 5291 | if (err < 0) |
5260 | alc_free(codec); | 5292 | goto error; |
5261 | return err; | ||
5262 | } | ||
5263 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 5293 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
5264 | } | 5294 | } |
5265 | 5295 | ||
@@ -5277,6 +5307,10 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
5277 | #endif | 5307 | #endif |
5278 | 5308 | ||
5279 | return 0; | 5309 | return 0; |
5310 | |||
5311 | error: | ||
5312 | alc_free(codec); | ||
5313 | return err; | ||
5280 | } | 5314 | } |
5281 | 5315 | ||
5282 | /* | 5316 | /* |
@@ -5598,18 +5632,16 @@ static int patch_alc662(struct hda_codec *codec) | |||
5598 | 5632 | ||
5599 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 5633 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
5600 | 5634 | ||
5635 | err = alc_codec_rename_from_preset(codec); | ||
5636 | if (err < 0) | ||
5637 | goto error; | ||
5638 | |||
5601 | coef = alc_read_coef_idx(codec, 0); | 5639 | coef = alc_read_coef_idx(codec, 0); |
5602 | if (coef == 0x8020 || coef == 0x8011) | 5640 | if (coef & (1 << 14) && |
5603 | err = alc_codec_rename(codec, "ALC661"); | 5641 | codec->bus->pci->subsystem_vendor == 0x1025 && |
5604 | else if (coef & (1 << 14) && | 5642 | spec->cdefine.platform_type == 1) { |
5605 | codec->bus->pci->subsystem_vendor == 0x1025 && | 5643 | if (alc_codec_rename(codec, "ALC272X") < 0) |
5606 | spec->cdefine.platform_type == 1) | 5644 | goto error; |
5607 | err = alc_codec_rename(codec, "ALC272X"); | ||
5608 | else if (coef == 0x4011) | ||
5609 | err = alc_codec_rename(codec, "ALC656"); | ||
5610 | if (err < 0) { | ||
5611 | alc_free(codec); | ||
5612 | return err; | ||
5613 | } | 5645 | } |
5614 | 5646 | ||
5615 | alc_pick_fixup(codec, alc662_fixup_models, | 5647 | alc_pick_fixup(codec, alc662_fixup_models, |
@@ -5617,10 +5649,8 @@ static int patch_alc662(struct hda_codec *codec) | |||
5617 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 5649 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
5618 | /* automatic parse from the BIOS config */ | 5650 | /* automatic parse from the BIOS config */ |
5619 | err = alc662_parse_auto_config(codec); | 5651 | err = alc662_parse_auto_config(codec); |
5620 | if (err < 0) { | 5652 | if (err < 0) |
5621 | alc_free(codec); | 5653 | goto error; |
5622 | return err; | ||
5623 | } | ||
5624 | 5654 | ||
5625 | if (!spec->no_analog && !spec->adc_nids) { | 5655 | if (!spec->no_analog && !spec->adc_nids) { |
5626 | alc_auto_fill_adc_caps(codec); | 5656 | alc_auto_fill_adc_caps(codec); |
@@ -5633,10 +5663,8 @@ static int patch_alc662(struct hda_codec *codec) | |||
5633 | 5663 | ||
5634 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 5664 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
5635 | err = snd_hda_attach_beep_device(codec, 0x1); | 5665 | err = snd_hda_attach_beep_device(codec, 0x1); |
5636 | if (err < 0) { | 5666 | if (err < 0) |
5637 | alc_free(codec); | 5667 | goto error; |
5638 | return err; | ||
5639 | } | ||
5640 | switch (codec->vendor_id) { | 5668 | switch (codec->vendor_id) { |
5641 | case 0x10ec0662: | 5669 | case 0x10ec0662: |
5642 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 5670 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
@@ -5667,49 +5695,10 @@ static int patch_alc662(struct hda_codec *codec) | |||
5667 | #endif | 5695 | #endif |
5668 | 5696 | ||
5669 | return 0; | 5697 | return 0; |
5670 | } | ||
5671 | |||
5672 | static int patch_alc888(struct hda_codec *codec) | ||
5673 | { | ||
5674 | int coef; | ||
5675 | |||
5676 | coef = alc_read_coef_idx(codec, 0); | ||
5677 | /* For ALC887-VD ALC888S-VD */ | ||
5678 | if ((coef & 0x00f0) == 0x0030) { | ||
5679 | kfree(codec->chip_name); | ||
5680 | if (codec->vendor_id == 0x10ec0887) | ||
5681 | err = alc_codec_rename(codec, "ALC887-VD"); | ||
5682 | else | ||
5683 | err = alc_codec_rename(codec, "ALC888-VD"); | ||
5684 | if (err < 0) { | ||
5685 | alc_free(codec); | ||
5686 | return -ENOMEM; | ||
5687 | } | ||
5688 | return patch_alc662(codec); | ||
5689 | } | ||
5690 | 5698 | ||
5691 | /* For ALC888S-VC */ | 5699 | error: |
5692 | if (codec->vendor_id == 0x10ec0888) { | 5700 | alc_free(codec); |
5693 | if ((coef & 0xf0f0) == 0x3020) { | 5701 | return err; |
5694 | err = alc_codec_rename(codec, "ALC886"); | ||
5695 | if (err < 0) { | ||
5696 | alc_free(codec); | ||
5697 | return -ENOMEM; | ||
5698 | } | ||
5699 | } | ||
5700 | } | ||
5701 | return patch_alc882(codec); | ||
5702 | } | ||
5703 | |||
5704 | static int patch_alc899(struct hda_codec *codec) | ||
5705 | { | ||
5706 | if ((alc_read_coef_idx(codec, 0) & 0x2000) != 0x2000) { | ||
5707 | if (alc_codec_rename(codec, "ALC898") < 0) { | ||
5708 | alc_free(codec); | ||
5709 | return -ENOMEM; | ||
5710 | } | ||
5711 | } | ||
5712 | return patch_alc882(codec); | ||
5713 | } | 5702 | } |
5714 | 5703 | ||
5715 | /* | 5704 | /* |
@@ -5789,13 +5778,13 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
5789 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", | 5778 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
5790 | .patch = patch_alc882 }, | 5779 | .patch = patch_alc882 }, |
5791 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, | 5780 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
5792 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 }, | 5781 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
5793 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", | 5782 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
5794 | .patch = patch_alc882 }, | 5783 | .patch = patch_alc882 }, |
5795 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 }, | 5784 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
5796 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, | 5785 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
5797 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, | 5786 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
5798 | { .id = 0x10ec0899, .name = "ALC899", .patch = patch_alc899 }, | 5787 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
5799 | {} /* terminator */ | 5788 | {} /* terminator */ |
5800 | }; | 5789 | }; |
5801 | 5790 | ||