2 * HD-audio regmap helpers
5 #ifndef __SOUND_HDA_REGMAP_H
6 #define __SOUND_HDA_REGMAP_H
8 #include <linux/regmap.h>
9 #include <sound/core.h>
10 #include <sound/hdaudio.h>
12 int snd_hdac_regmap_init(struct hdac_device
*codec
);
13 void snd_hdac_regmap_exit(struct hdac_device
*codec
);
14 int snd_hdac_regmap_add_vendor_verb(struct hdac_device
*codec
,
16 int snd_hdac_regmap_read_raw(struct hdac_device
*codec
, unsigned int reg
,
18 int snd_hdac_regmap_write_raw(struct hdac_device
*codec
, unsigned int reg
,
20 int snd_hdac_regmap_update_raw(struct hdac_device
*codec
, unsigned int reg
,
21 unsigned int mask
, unsigned int val
);
24 * snd_hdac_regmap_encode_verb - encode the verb to a pseudo register
28 * Returns an encoded pseudo register.
30 #define snd_hdac_regmap_encode_verb(nid, verb) \
31 (((verb) << 8) | 0x80000 | ((unsigned int)(nid) << 20))
34 * snd_hdac_regmap_encode_amp - encode the AMP verb to a pseudo register
36 * @ch: channel (left = 0, right = 1)
37 * @dir: direction (#HDA_INPUT, #HDA_OUTPUT)
38 * @idx: input index value
40 * Returns an encoded pseudo register.
42 #define snd_hdac_regmap_encode_amp(nid, ch, dir, idx) \
43 (snd_hdac_regmap_encode_verb(nid, AC_VERB_GET_AMP_GAIN_MUTE) | \
44 ((ch) ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT) | \
45 ((dir) == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT) | \
49 * snd_hdac_regmap_write - Write a verb with caching
52 * @val: value to write
54 * For writing an amp value, use snd_hda_regmap_amp_update().
57 snd_hdac_regmap_write(struct hdac_device
*codec
, hda_nid_t nid
,
58 unsigned int verb
, unsigned int val
)
60 unsigned int cmd
= snd_hdac_regmap_encode_verb(nid
, verb
);
62 return snd_hdac_regmap_write_raw(codec
, cmd
, val
);
66 * snd_hda_regmap_update - Update a verb value with caching
68 * @verb: verb to update
69 * @mask: bit mask to update
70 * @val: value to update
72 * For updating an amp value, use snd_hda_regmap_amp_update().
75 snd_hdac_regmap_update(struct hdac_device
*codec
, hda_nid_t nid
,
76 unsigned int verb
, unsigned int mask
,
79 unsigned int cmd
= snd_hdac_regmap_encode_verb(nid
, verb
);
81 return snd_hdac_regmap_update_raw(codec
, cmd
, mask
, val
);
85 * snd_hda_regmap_read - Read a verb with caching
88 * @val: pointer to store the value
90 * For reading an amp value, use snd_hda_regmap_get_amp().
93 snd_hdac_regmap_read(struct hdac_device
*codec
, hda_nid_t nid
,
94 unsigned int verb
, unsigned int *val
)
96 unsigned int cmd
= snd_hdac_regmap_encode_verb(nid
, verb
);
98 return snd_hdac_regmap_read_raw(codec
, cmd
, val
);
102 * snd_hdac_regmap_get_amp - Read AMP value
103 * @codec: HD-audio codec
104 * @nid: NID to read the AMP value
105 * @ch: channel (left=0 or right=1)
106 * @direction: #HDA_INPUT or #HDA_OUTPUT
107 * @index: the index value (only for input direction)
108 * @val: the pointer to store the value
110 * Read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit.
111 * Returns the value or a negative error.
114 snd_hdac_regmap_get_amp(struct hdac_device
*codec
, hda_nid_t nid
,
115 int ch
, int dir
, int idx
)
117 unsigned int cmd
= snd_hdac_regmap_encode_amp(nid
, ch
, dir
, idx
);
120 err
= snd_hdac_regmap_read_raw(codec
, cmd
, &val
);
121 return err
< 0 ? err
: val
;
125 * snd_hdac_regmap_update_amp - update the AMP value
126 * @codec: HD-audio codec
127 * @nid: NID to read the AMP value
128 * @ch: channel (left=0 or right=1)
129 * @direction: #HDA_INPUT or #HDA_OUTPUT
130 * @idx: the index value (only for input direction)
131 * @mask: bit mask to set
132 * @val: the bits value to set
134 * Update the AMP value with a bit mask.
135 * Returns 0 if the value is unchanged, 1 if changed, or a negative error.
138 snd_hdac_regmap_update_amp(struct hdac_device
*codec
, hda_nid_t nid
,
139 int ch
, int dir
, int idx
, int mask
, int val
)
141 unsigned int cmd
= snd_hdac_regmap_encode_amp(nid
, ch
, dir
, idx
);
143 return snd_hdac_regmap_update_raw(codec
, cmd
, mask
, val
);
146 #endif /* __SOUND_HDA_REGMAP_H */
This page took 0.039467 seconds and 5 git commands to generate.