ALSA: hda/realtek - Optimize alc888_coef_init()
Just a refactoring using the existing helper functions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Родитель
e52faba0f3
Коммит
f2a227cd38
|
@ -128,6 +128,43 @@ struct alc_spec {
|
|||
unsigned int coef0;
|
||||
};
|
||||
|
||||
/*
|
||||
* COEF access helper functions
|
||||
*/
|
||||
|
||||
static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned int coef_idx)
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
|
||||
val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
|
||||
return val;
|
||||
}
|
||||
|
||||
#define alc_read_coef_idx(codec, coef_idx) \
|
||||
alc_read_coefex_idx(codec, 0x20, coef_idx)
|
||||
|
||||
static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned int coef_idx, unsigned int coef_val)
|
||||
{
|
||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
|
||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
|
||||
}
|
||||
|
||||
#define alc_write_coef_idx(codec, coef_idx, coef_val) \
|
||||
alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
|
||||
|
||||
/* a special bypass for COEF 0; read the cached value at the second time */
|
||||
static unsigned int alc_get_coef0(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
|
||||
if (!spec->coef0)
|
||||
spec->coef0 = alc_read_coef_idx(codec, 0);
|
||||
return spec->coef0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Append the given mixer and verb elements for the later use
|
||||
* The mixer array is referred in build_controls(), and init_verbs are
|
||||
|
@ -231,19 +268,12 @@ static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
|
|||
/* additional initialization for ALC888 variants */
|
||||
static void alc888_coef_init(struct hda_codec *codec)
|
||||
{
|
||||
unsigned int tmp;
|
||||
|
||||
snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
|
||||
tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
|
||||
snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
|
||||
if ((tmp & 0xf0) == 0x20)
|
||||
if (alc_get_coef0(codec) == 0x20)
|
||||
/* alc888S-VC */
|
||||
snd_hda_codec_read(codec, 0x20, 0,
|
||||
AC_VERB_SET_PROC_COEF, 0x830);
|
||||
alc_write_coef_idx(codec, 7, 0x830);
|
||||
else
|
||||
/* alc888-VB */
|
||||
snd_hda_codec_read(codec, 0x20, 0,
|
||||
AC_VERB_SET_PROC_COEF, 0x3030);
|
||||
alc_write_coef_idx(codec, 7, 0x3030);
|
||||
}
|
||||
|
||||
/* additional initialization for ALC889 variants */
|
||||
|
@ -586,47 +616,6 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* COEF access helper functions
|
||||
*/
|
||||
|
||||
static int alc_read_coefex_idx(struct hda_codec *codec,
|
||||
hda_nid_t nid,
|
||||
unsigned int coef_idx)
|
||||
{
|
||||
unsigned int val;
|
||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX,
|
||||
coef_idx);
|
||||
val = snd_hda_codec_read(codec, nid, 0,
|
||||
AC_VERB_GET_PROC_COEF, 0);
|
||||
return val;
|
||||
}
|
||||
|
||||
#define alc_read_coef_idx(codec, coef_idx) \
|
||||
alc_read_coefex_idx(codec, 0x20, coef_idx)
|
||||
|
||||
static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
|
||||
unsigned int coef_idx,
|
||||
unsigned int coef_val)
|
||||
{
|
||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX,
|
||||
coef_idx);
|
||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF,
|
||||
coef_val);
|
||||
}
|
||||
|
||||
#define alc_write_coef_idx(codec, coef_idx, coef_val) \
|
||||
alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
|
||||
|
||||
/* a special bypass for COEF 0; read the cached value at the second time */
|
||||
static unsigned int alc_get_coef0(struct hda_codec *codec)
|
||||
{
|
||||
struct alc_spec *spec = codec->spec;
|
||||
if (!spec->coef0)
|
||||
spec->coef0 = alc_read_coef_idx(codec, 0);
|
||||
return spec->coef0;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче