ALSA: hda - Add alc_codec_rename() helper

Added alc_codec_rename() helper for renaming codec->chip_name.
Added Acer-specific codec naming for ALC269/662.

[Clean-up and refactoring by tiwai]

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Kailang Yang 2010-03-19 11:33:06 +01:00 committed by Takashi Iwai
parent da00c24493
commit c027ddcd01

View file

@ -3848,6 +3848,18 @@ static struct hda_codec_ops alc_patch_ops = {
.reboot_notify = alc_shutup, .reboot_notify = alc_shutup,
}; };
/* replace the codec chip_name with the given string */
static int alc_codec_rename(struct hda_codec *codec, const char *name)
{
kfree(codec->chip_name);
codec->chip_name = kstrdup(name, GFP_KERNEL);
if (!codec->chip_name) {
alc_free(codec);
return -ENOMEM;
}
return 0;
}
/* /*
* Test configuration for debugging * Test configuration for debugging
* *
@ -14169,17 +14181,15 @@ static int patch_alc269(struct hda_codec *codec)
alc_auto_parse_customize_define(codec); alc_auto_parse_customize_define(codec);
alc_fix_pll_init(codec, 0x20, 0x04, 15);
if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
kfree(codec->chip_name); if (codec->bus->pci->subsystem_vendor == 0x1025 &&
codec->chip_name = kstrdup("ALC259", GFP_KERNEL); spec->cdefine.platform_type == 1)
if (!codec->chip_name) { alc_codec_rename(codec, "ALC271X");
alc_free(codec); else
return -ENOMEM; alc_codec_rename(codec, "ALC259");
}
is_alc269vb = 1; is_alc269vb = 1;
} } else
alc_fix_pll_init(codec, 0x20, 0x04, 15);
board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
alc269_models, alc269_models,
@ -18394,14 +18404,12 @@ static int patch_alc662(struct hda_codec *codec)
alc_fix_pll_init(codec, 0x20, 0x04, 15); alc_fix_pll_init(codec, 0x20, 0x04, 15);
if (alc_read_coef_idx(codec, 0)==0x8020){ if (alc_read_coef_idx(codec, 0) == 0x8020)
kfree(codec->chip_name); alc_codec_rename(codec, "ALC661");
codec->chip_name = kstrdup("ALC661", GFP_KERNEL); else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
if (!codec->chip_name) { codec->bus->pci->subsystem_vendor == 0x1025 &&
alc_free(codec); spec->cdefine.platform_type == 1)
return -ENOMEM; alc_codec_rename(codec, "ALC272X");
}
}
board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
alc662_models, alc662_models,