GNU Linux-libre 4.14.290-gnu1
[releases.git] / sound / pci / hda / local.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  */
4
5 #ifndef __HDAC_LOCAL_H
6 #define __HDAC_LOCAL_H
7
8 int hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm);
9
10 #define get_wcaps(codec, nid) \
11         hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP)
12 /* get the widget type from widget capability bits */
13 static inline int get_wcaps_type(unsigned int wcaps)
14 {
15         if (!wcaps)
16                 return -1; /* invalid type */
17         return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
18 }
19
20 #define get_pin_caps(codec, nid) \
21         hdac_read_parm(codec, nid, AC_PAR_PIN_CAP)
22
23 static inline
24 unsigned int get_pin_cfg(struct hdac_device *codec, hda_nid_t nid)
25 {
26         unsigned int val;
27
28         if (snd_hdac_read(codec, nid, AC_VERB_GET_CONFIG_DEFAULT, 0, &val))
29                 return -1;
30         return val;
31 }
32
33 #define get_amp_caps(codec, nid, dir) \
34         hdac_read_parm(codec, nid, (dir) == HDA_OUTPUT ? \
35                        AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP)
36
37 #define get_power_caps(codec, nid) \
38         hdac_read_parm(codec, nid, AC_PAR_POWER_STATE)
39
40 #endif /* __HDAC_LOCAL_H */