aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-05-07 12:03:15 -0400
committerTakashi Iwai <tiwai@suse.de>2012-05-08 10:38:14 -0400
commit3de9517356389abc2e6c0d32f5ae1ceb218f6b7d (patch)
tree035bbda34e3db5680c0f30ac492b3c40ee0fa1fd /sound/pci/hda
parentffd344444f9f8f4843d24084ef3da0d09140edb8 (diff)
ALSA: hda/realtek - Call a common helper for alc_spec initialization
Just a clean up by calling the same helper function. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/patch_realtek.c136
1 files changed, 61 insertions, 75 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 6dd1b74e9f68..ae9732ce8670 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4405,6 +4405,25 @@ static int alc_parse_auto_config(struct hda_codec *codec,
4405 return 1; 4405 return 1;
4406} 4406}
4407 4407
4408/* common preparation job for alc_spec */
4409static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
4410{
4411 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4412 int err;
4413
4414 if (!spec)
4415 return -ENOMEM;
4416 codec->spec = spec;
4417 spec->mixer_nid = mixer_nid;
4418
4419 err = alc_codec_rename_from_preset(codec);
4420 if (err < 0) {
4421 kfree(spec);
4422 return err;
4423 }
4424 return 0;
4425}
4426
4408static int alc880_parse_auto_config(struct hda_codec *codec) 4427static int alc880_parse_auto_config(struct hda_codec *codec)
4409{ 4428{
4410 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 4429 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
@@ -4786,13 +4805,11 @@ static int patch_alc880(struct hda_codec *codec)
4786 struct alc_spec *spec; 4805 struct alc_spec *spec;
4787 int err; 4806 int err;
4788 4807
4789 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4808 err = alc_alloc_spec(codec, 0x0b);
4790 if (spec == NULL) 4809 if (err < 0)
4791 return -ENOMEM; 4810 return err;
4792
4793 codec->spec = spec;
4794 4811
4795 spec->mixer_nid = 0x0b; 4812 spec = codec->spec;
4796 spec->need_dac_fix = 1; 4813 spec->need_dac_fix = 1;
4797 4814
4798 alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, 4815 alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
@@ -4979,13 +4996,11 @@ static int patch_alc260(struct hda_codec *codec)
4979 struct alc_spec *spec; 4996 struct alc_spec *spec;
4980 int err; 4997 int err;
4981 4998
4982 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4999 err = alc_alloc_spec(codec, 0x07);
4983 if (spec == NULL) 5000 if (err < 0)
4984 return -ENOMEM; 5001 return err;
4985
4986 codec->spec = spec;
4987 5002
4988 spec->mixer_nid = 0x07; 5003 spec = codec->spec;
4989 5004
4990 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); 5005 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
4991 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 5006 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
@@ -5452,13 +5467,11 @@ static int patch_alc882(struct hda_codec *codec)
5452 struct alc_spec *spec; 5467 struct alc_spec *spec;
5453 int err; 5468 int err;
5454 5469
5455 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5470 err = alc_alloc_spec(codec, 0x0b);
5456 if (spec == NULL) 5471 if (err < 0)
5457 return -ENOMEM; 5472 return err;
5458
5459 codec->spec = spec;
5460 5473
5461 spec->mixer_nid = 0x0b; 5474 spec = codec->spec;
5462 5475
5463 switch (codec->vendor_id) { 5476 switch (codec->vendor_id) {
5464 case 0x10ec0882: 5477 case 0x10ec0882:
@@ -5470,10 +5483,6 @@ static int patch_alc882(struct hda_codec *codec)
5470 break; 5483 break;
5471 } 5484 }
5472 5485
5473 err = alc_codec_rename_from_preset(codec);
5474 if (err < 0)
5475 goto error;
5476
5477 alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, 5486 alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
5478 alc882_fixups); 5487 alc882_fixups);
5479 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 5488 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
@@ -5597,13 +5606,11 @@ static int patch_alc262(struct hda_codec *codec)
5597 struct alc_spec *spec; 5606 struct alc_spec *spec;
5598 int err; 5607 int err;
5599 5608
5600 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5609 err = alc_alloc_spec(codec, 0x0b);
5601 if (spec == NULL) 5610 if (err < 0)
5602 return -ENOMEM; 5611 return err;
5603
5604 codec->spec = spec;
5605 5612
5606 spec->mixer_nid = 0x0b; 5613 spec = codec->spec;
5607 5614
5608#if 0 5615#if 0
5609 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is 5616 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
@@ -5699,13 +5706,12 @@ static int patch_alc268(struct hda_codec *codec)
5699 struct alc_spec *spec; 5706 struct alc_spec *spec;
5700 int i, has_beep, err; 5707 int i, has_beep, err;
5701 5708
5702 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5703 if (spec == NULL)
5704 return -ENOMEM;
5705
5706 codec->spec = spec;
5707
5708 /* ALC268 has no aa-loopback mixer */ 5709 /* ALC268 has no aa-loopback mixer */
5710 err = alc_alloc_spec(codec, 0);
5711 if (err < 0)
5712 return err;
5713
5714 spec = codec->spec;
5709 5715
5710 /* automatic parse from the BIOS config */ 5716 /* automatic parse from the BIOS config */
5711 err = alc268_parse_auto_config(codec); 5717 err = alc268_parse_auto_config(codec);
@@ -6216,19 +6222,13 @@ static void alc269_fill_coef(struct hda_codec *codec)
6216static int patch_alc269(struct hda_codec *codec) 6222static int patch_alc269(struct hda_codec *codec)
6217{ 6223{
6218 struct alc_spec *spec; 6224 struct alc_spec *spec;
6219 int err = 0; 6225 int err;
6220
6221 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6222 if (spec == NULL)
6223 return -ENOMEM;
6224
6225 codec->spec = spec;
6226
6227 spec->mixer_nid = 0x0b;
6228 6226
6229 err = alc_codec_rename_from_preset(codec); 6227 err = alc_alloc_spec(codec, 0x0b);
6230 if (err < 0) 6228 if (err < 0)
6231 goto error; 6229 return err;
6230
6231 spec = codec->spec;
6232 6232
6233 if (codec->vendor_id == 0x10ec0269) { 6233 if (codec->vendor_id == 0x10ec0269) {
6234 spec->codec_variant = ALC269_TYPE_ALC269VA; 6234 spec->codec_variant = ALC269_TYPE_ALC269VA;
@@ -6374,13 +6374,11 @@ static int patch_alc861(struct hda_codec *codec)
6374 struct alc_spec *spec; 6374 struct alc_spec *spec;
6375 int err; 6375 int err;
6376 6376
6377 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6377 err = alc_alloc_spec(codec, 0x15);
6378 if (spec == NULL) 6378 if (err < 0)
6379 return -ENOMEM; 6379 return err;
6380
6381 codec->spec = spec;
6382 6380
6383 spec->mixer_nid = 0x15; 6381 spec = codec->spec;
6384 6382
6385 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); 6383 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
6386 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 6384 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
@@ -6477,13 +6475,11 @@ static int patch_alc861vd(struct hda_codec *codec)
6477 struct alc_spec *spec; 6475 struct alc_spec *spec;
6478 int err; 6476 int err;
6479 6477
6480 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6478 err = alc_alloc_spec(codec, 0x0b);
6481 if (spec == NULL) 6479 if (err < 0)
6482 return -ENOMEM; 6480 return err;
6483
6484 codec->spec = spec;
6485 6481
6486 spec->mixer_nid = 0x0b; 6482 spec = codec->spec;
6487 6483
6488 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); 6484 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
6489 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 6485 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
@@ -6822,25 +6818,19 @@ static const struct alc_model_fixup alc662_fixup_models[] = {
6822static int patch_alc662(struct hda_codec *codec) 6818static int patch_alc662(struct hda_codec *codec)
6823{ 6819{
6824 struct alc_spec *spec; 6820 struct alc_spec *spec;
6825 int err = 0; 6821 int err;
6826
6827 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6828 if (!spec)
6829 return -ENOMEM;
6830 6822
6831 codec->spec = spec; 6823 err = alc_alloc_spec(codec, 0x0b);
6824 if (err < 0)
6825 return err;
6832 6826
6833 spec->mixer_nid = 0x0b; 6827 spec = codec->spec;
6834 6828
6835 /* handle multiple HPs as is */ 6829 /* handle multiple HPs as is */
6836 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; 6830 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6837 6831
6838 alc_fix_pll_init(codec, 0x20, 0x04, 15); 6832 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6839 6833
6840 err = alc_codec_rename_from_preset(codec);
6841 if (err < 0)
6842 goto error;
6843
6844 if ((alc_get_coef0(codec) & (1 << 14)) && 6834 if ((alc_get_coef0(codec) & (1 << 14)) &&
6845 codec->bus->pci->subsystem_vendor == 0x1025 && 6835 codec->bus->pci->subsystem_vendor == 0x1025 &&
6846 spec->cdefine.platform_type == 1) { 6836 spec->cdefine.platform_type == 1) {
@@ -6903,16 +6893,12 @@ static int alc680_parse_auto_config(struct hda_codec *codec)
6903 */ 6893 */
6904static int patch_alc680(struct hda_codec *codec) 6894static int patch_alc680(struct hda_codec *codec)
6905{ 6895{
6906 struct alc_spec *spec;
6907 int err; 6896 int err;
6908 6897
6909 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6910 if (spec == NULL)
6911 return -ENOMEM;
6912
6913 codec->spec = spec;
6914
6915 /* ALC680 has no aa-loopback mixer */ 6898 /* ALC680 has no aa-loopback mixer */
6899 err = alc_alloc_spec(codec, 0);
6900 if (err < 0)
6901 return err;
6916 6902
6917 /* automatic parse from the BIOS config */ 6903 /* automatic parse from the BIOS config */
6918 err = alc680_parse_auto_config(codec); 6904 err = alc680_parse_auto_config(codec);