Commit a22d543a authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Introduce get_wcaps_type() macro

Add a helper macro to retrieve the widget type from wiget cap bits.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent a3daf689
...@@ -748,8 +748,7 @@ static int read_pin_defaults(struct hda_codec *codec) ...@@ -748,8 +748,7 @@ static int read_pin_defaults(struct hda_codec *codec)
for (i = 0; i < codec->num_nodes; i++, nid++) { for (i = 0; i < codec->num_nodes; i++, nid++) {
struct hda_pincfg *pin; struct hda_pincfg *pin;
unsigned int wcaps = get_wcaps(codec, nid); unsigned int wcaps = get_wcaps(codec, nid);
unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> unsigned int wid_type = get_wcaps_type(wcaps);
AC_WCAP_TYPE_SHIFT;
if (wid_type != AC_WID_PIN) if (wid_type != AC_WID_PIN)
continue; continue;
pin = snd_array_new(&codec->init_pins); pin = snd_array_new(&codec->init_pins);
...@@ -2386,8 +2385,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, ...@@ -2386,8 +2385,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
for (i = 0; i < codec->num_nodes; i++, nid++) { for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int wcaps = get_wcaps(codec, nid); unsigned int wcaps = get_wcaps(codec, nid);
if (wcaps & AC_WCAP_POWER) { if (wcaps & AC_WCAP_POWER) {
unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> unsigned int wid_type = get_wcaps_type(wcaps);
AC_WCAP_TYPE_SHIFT;
if (power_state == AC_PWRST_D3 && if (power_state == AC_PWRST_D3 &&
wid_type == AC_WID_PIN) { wid_type == AC_WID_PIN) {
unsigned int pincap; unsigned int pincap;
...@@ -3678,8 +3676,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, ...@@ -3678,8 +3676,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
end_nid = codec->start_nid + codec->num_nodes; end_nid = codec->start_nid + codec->num_nodes;
for (nid = codec->start_nid; nid < end_nid; nid++) { for (nid = codec->start_nid; nid < end_nid; nid++) {
unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_caps = get_wcaps(codec, nid);
unsigned int wid_type = unsigned int wid_type = get_wcaps_type(wid_caps);
(wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
unsigned int def_conf; unsigned int def_conf;
short assoc, loc; short assoc, loc;
......
...@@ -122,7 +122,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid ...@@ -122,7 +122,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
return -ENOMEM; return -ENOMEM;
node->nid = nid; node->nid = nid;
node->wid_caps = get_wcaps(codec, nid); node->wid_caps = get_wcaps(codec, nid);
node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; node->type = get_wcaps_type(node->wid_caps);
if (node->wid_caps & AC_WCAP_CONN_LIST) { if (node->wid_caps & AC_WCAP_CONN_LIST) {
nconns = snd_hda_get_connections(codec, nid, conn_list, nconns = snd_hda_get_connections(codec, nid, conn_list,
HDA_MAX_CONNECTIONS); HDA_MAX_CONNECTIONS);
......
...@@ -407,6 +407,9 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) ...@@ -407,6 +407,9 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
return codec->wcaps[nid - codec->start_nid]; return codec->wcaps[nid - codec->start_nid];
} }
/* get the widget type from widget capability bits */
#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
unsigned int caps); unsigned int caps);
......
...@@ -508,8 +508,7 @@ static void print_codec_info(struct snd_info_entry *entry, ...@@ -508,8 +508,7 @@ static void print_codec_info(struct snd_info_entry *entry,
unsigned int wid_caps = unsigned int wid_caps =
snd_hda_param_read(codec, nid, snd_hda_param_read(codec, nid,
AC_PAR_AUDIO_WIDGET_CAP); AC_PAR_AUDIO_WIDGET_CAP);
unsigned int wid_type = unsigned int wid_type = get_wcaps_type(wid_caps);
(wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
hda_nid_t conn[HDA_MAX_CONNECTIONS]; hda_nid_t conn[HDA_MAX_CONNECTIONS];
int conn_len = 0; int conn_len = 0;
......
...@@ -459,8 +459,7 @@ static void parse_input(struct hda_codec *codec) ...@@ -459,8 +459,7 @@ static void parse_input(struct hda_codec *codec)
nid = codec->start_nid; nid = codec->start_nid;
for (i = 0; i < codec->num_nodes; i++, nid++) { for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int wcaps = get_wcaps(codec, nid); unsigned int wcaps = get_wcaps(codec, nid);
unsigned int type = (wcaps & AC_WCAP_TYPE) >> unsigned int type = get_wcaps_type(wcaps);
AC_WCAP_TYPE_SHIFT;
if (type != AC_WID_AUD_IN) if (type != AC_WID_AUD_IN)
continue; continue;
if (snd_hda_get_connections(codec, nid, &pin, 1) != 1) if (snd_hda_get_connections(codec, nid, &pin, 1) != 1)
......
...@@ -415,7 +415,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, ...@@ -415,7 +415,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
imux = &spec->input_mux[mux_idx]; imux = &spec->input_mux[mux_idx];
type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; type = get_wcaps_type(get_wcaps(codec, nid));
if (type == AC_WID_AUD_MIX) { if (type == AC_WID_AUD_MIX) {
/* Matrix-mixer style (e.g. ALC882) */ /* Matrix-mixer style (e.g. ALC882) */
unsigned int *cur_val = &spec->cur_mux[adc_idx]; unsigned int *cur_val = &spec->cur_mux[adc_idx];
...@@ -4623,7 +4623,7 @@ static int patch_alc880(struct hda_codec *codec) ...@@ -4623,7 +4623,7 @@ static int patch_alc880(struct hda_codec *codec)
/* check whether NID 0x07 is valid */ /* check whether NID 0x07 is valid */
unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
/* get type */ /* get type */
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wcap = get_wcaps_type(wcap);
if (wcap != AC_WID_AUD_IN) { if (wcap != AC_WID_AUD_IN) {
spec->adc_nids = alc880_adc_nids_alt; spec->adc_nids = alc880_adc_nids_alt;
spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
...@@ -6266,7 +6266,7 @@ static int patch_alc260(struct hda_codec *codec) ...@@ -6266,7 +6266,7 @@ static int patch_alc260(struct hda_codec *codec)
if (!spec->adc_nids && spec->input_mux) { if (!spec->adc_nids && spec->input_mux) {
/* check whether NID 0x04 is valid */ /* check whether NID 0x04 is valid */
unsigned int wcap = get_wcaps(codec, 0x04); unsigned int wcap = get_wcaps(codec, 0x04);
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wcap = get_wcaps_type(wcap);
/* get type */ /* get type */
if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
spec->adc_nids = alc260_adc_nids_alt; spec->adc_nids = alc260_adc_nids_alt;
...@@ -9460,7 +9460,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec) ...@@ -9460,7 +9460,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
spec->init_verbs[0] = alc883_auto_init_verbs; spec->init_verbs[0] = alc883_auto_init_verbs;
/* if ADC 0x07 is available, initialize it, too */ /* if ADC 0x07 is available, initialize it, too */
wcap = get_wcaps(codec, 0x07); wcap = get_wcaps(codec, 0x07);
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wcap = get_wcaps_type(wcap);
if (wcap == AC_WID_AUD_IN) if (wcap == AC_WID_AUD_IN)
add_verb(spec, alc882_adc1_init_verbs); add_verb(spec, alc882_adc1_init_verbs);
...@@ -9577,7 +9577,7 @@ static int patch_alc882(struct hda_codec *codec) ...@@ -9577,7 +9577,7 @@ static int patch_alc882(struct hda_codec *codec)
hda_nid_t nid = alc882_adc_nids[i]; hda_nid_t nid = alc882_adc_nids[i];
unsigned int wcap = get_wcaps(codec, nid); unsigned int wcap = get_wcaps(codec, nid);
/* get type */ /* get type */
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wcap = get_wcaps_type(wcap);
if (wcap != AC_WID_AUD_IN) if (wcap != AC_WID_AUD_IN)
continue; continue;
spec->private_adc_nids[spec->num_adc_nids] = nid; spec->private_adc_nids[spec->num_adc_nids] = nid;
...@@ -11460,7 +11460,7 @@ static int patch_alc262(struct hda_codec *codec) ...@@ -11460,7 +11460,7 @@ static int patch_alc262(struct hda_codec *codec)
unsigned int wcap = get_wcaps(codec, 0x07); unsigned int wcap = get_wcaps(codec, 0x07);
/* get type */ /* get type */
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wcap = get_wcaps_type(wcap);
if (wcap != AC_WID_AUD_IN) { if (wcap != AC_WID_AUD_IN) {
spec->adc_nids = alc262_adc_nids_alt; spec->adc_nids = alc262_adc_nids_alt;
spec->num_adc_nids = spec->num_adc_nids =
...@@ -12536,7 +12536,7 @@ static int patch_alc268(struct hda_codec *codec) ...@@ -12536,7 +12536,7 @@ static int patch_alc268(struct hda_codec *codec)
int i; int i;
/* get type */ /* get type */
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wcap = get_wcaps_type(wcap);
if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
spec->adc_nids = alc268_adc_nids_alt; spec->adc_nids = alc268_adc_nids_alt;
spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
...@@ -13991,8 +13991,7 @@ static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin) ...@@ -13991,8 +13991,7 @@ static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
return 0; return 0;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
unsigned int type; unsigned int type;
type = (get_wcaps(codec, srcs[i]) & AC_WCAP_TYPE) type = get_wcaps_type(get_wcaps(codec, srcs[i]));
>> AC_WCAP_TYPE_SHIFT;
if (type != AC_WID_AUD_OUT) if (type != AC_WID_AUD_OUT)
continue; continue;
for (j = 0; j < spec->multiout.num_dacs; j++) for (j = 0; j < spec->multiout.num_dacs; j++)
......
...@@ -3058,7 +3058,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) ...@@ -3058,7 +3058,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
HDA_MAX_CONNECTIONS); HDA_MAX_CONNECTIONS);
for (j = 0; j < conn_len; j++) { for (j = 0; j < conn_len; j++) {
wcaps = get_wcaps(codec, conn[j]); wcaps = get_wcaps(codec, conn[j]);
wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; wtype = get_wcaps_type(wcaps);
/* we check only analog outputs */ /* we check only analog outputs */
if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
continue; continue;
...@@ -3746,8 +3746,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out ...@@ -3746,8 +3746,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
conn_list, 1) > 0) { conn_list, 1) > 0) {
int wcaps = get_wcaps(codec, conn_list[0]); int wcaps = get_wcaps(codec, conn_list[0]);
int wid_type = (wcaps & AC_WCAP_TYPE) int wid_type = get_wcaps_type(wcaps);
>> AC_WCAP_TYPE_SHIFT;
/* LR swap check, some stac925x have a mux that /* LR swap check, some stac925x have a mux that
* changes the DACs output path instead of the * changes the DACs output path instead of the
* mono-mux path. * mono-mux path.
...@@ -4753,8 +4752,7 @@ static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) ...@@ -4753,8 +4752,7 @@ static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
nid = codec->start_nid; nid = codec->start_nid;
for (i = 0; i < codec->num_nodes; i++, nid++) { for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int wcaps = get_wcaps(codec, nid); unsigned int wcaps = get_wcaps(codec, nid);
unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> unsigned int wid_type = get_wcaps_type(wcaps);
AC_WCAP_TYPE_SHIFT;
if (wid_type == AC_WID_PIN) if (wid_type == AC_WID_PIN)
snd_hda_codec_read(codec, nid, 0, snd_hda_codec_read(codec, nid, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL, 0); AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
......
...@@ -1339,8 +1339,7 @@ static int get_mux_nids(struct hda_codec *codec) ...@@ -1339,8 +1339,7 @@ static int get_mux_nids(struct hda_codec *codec)
for (i = 0; i < spec->num_adc_nids; i++) { for (i = 0; i < spec->num_adc_nids; i++) {
nid = spec->adc_nids[i]; nid = spec->adc_nids[i];
while (nid) { while (nid) {
type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) type = get_wcaps_type(get_wcaps(codec, nid));
>> AC_WCAP_TYPE_SHIFT;
if (type == AC_WID_PIN) if (type == AC_WID_PIN)
break; break;
n = snd_hda_get_connections(codec, nid, conn, n = snd_hda_get_connections(codec, nid, conn,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment