This source file includes following definitions.
- snd_hdac_regmap_write
- snd_hdac_regmap_update
- snd_hdac_regmap_read
- snd_hdac_regmap_get_amp
- snd_hdac_regmap_update_amp
- snd_hdac_regmap_get_amp_stereo
- snd_hdac_regmap_update_amp_stereo
- snd_hdac_regmap_sync_node
1
2
3
4
5
6 #ifndef __SOUND_HDA_REGMAP_H
7 #define __SOUND_HDA_REGMAP_H
8
9 #include <linux/regmap.h>
10 #include <sound/core.h>
11 #include <sound/hdaudio.h>
12
13 #define AC_AMP_FAKE_MUTE 0x10
14
15 int snd_hdac_regmap_init(struct hdac_device *codec);
16 void snd_hdac_regmap_exit(struct hdac_device *codec);
17 int snd_hdac_regmap_add_vendor_verb(struct hdac_device *codec,
18 unsigned int verb);
19 int snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg,
20 unsigned int *val);
21 int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec,
22 unsigned int reg, unsigned int *val);
23 int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg,
24 unsigned int val);
25 int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg,
26 unsigned int mask, unsigned int val);
27 int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg,
28 unsigned int mask, unsigned int val);
29 void snd_hdac_regmap_sync(struct hdac_device *codec);
30
31
32
33
34
35
36
37
38 #define snd_hdac_regmap_encode_verb(nid, verb) \
39 (((verb) << 8) | 0x80000 | ((unsigned int)(nid) << 20))
40
41
42
43
44
45
46
47
48
49
50 #define snd_hdac_regmap_encode_amp(nid, ch, dir, idx) \
51 (snd_hdac_regmap_encode_verb(nid, AC_VERB_GET_AMP_GAIN_MUTE) | \
52 ((ch) ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT) | \
53 ((dir) == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT) | \
54 (idx))
55
56
57
58
59
60
61
62
63
64 #define snd_hdac_regmap_encode_amp_stereo(nid, dir, idx) \
65 (snd_hdac_regmap_encode_verb(nid, AC_VERB_GET_AMP_GAIN_MUTE) | \
66 AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT | \
67 ((dir) == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT) | \
68 (idx))
69
70
71
72
73
74
75
76
77
78 static inline int
79 snd_hdac_regmap_write(struct hdac_device *codec, hda_nid_t nid,
80 unsigned int verb, unsigned int val)
81 {
82 unsigned int cmd = snd_hdac_regmap_encode_verb(nid, verb);
83
84 return snd_hdac_regmap_write_raw(codec, cmd, val);
85 }
86
87
88
89
90
91
92
93
94
95
96 static inline int
97 snd_hdac_regmap_update(struct hdac_device *codec, hda_nid_t nid,
98 unsigned int verb, unsigned int mask,
99 unsigned int val)
100 {
101 unsigned int cmd = snd_hdac_regmap_encode_verb(nid, verb);
102
103 return snd_hdac_regmap_update_raw(codec, cmd, mask, val);
104 }
105
106
107
108
109
110
111
112
113
114 static inline int
115 snd_hdac_regmap_read(struct hdac_device *codec, hda_nid_t nid,
116 unsigned int verb, unsigned int *val)
117 {
118 unsigned int cmd = snd_hdac_regmap_encode_verb(nid, verb);
119
120 return snd_hdac_regmap_read_raw(codec, cmd, val);
121 }
122
123
124
125
126
127
128
129
130
131
132
133
134
135 static inline int
136 snd_hdac_regmap_get_amp(struct hdac_device *codec, hda_nid_t nid,
137 int ch, int dir, int idx)
138 {
139 unsigned int cmd = snd_hdac_regmap_encode_amp(nid, ch, dir, idx);
140 int err, val;
141
142 err = snd_hdac_regmap_read_raw(codec, cmd, &val);
143 return err < 0 ? err : val;
144 }
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 static inline int
160 snd_hdac_regmap_update_amp(struct hdac_device *codec, hda_nid_t nid,
161 int ch, int dir, int idx, int mask, int val)
162 {
163 unsigned int cmd = snd_hdac_regmap_encode_amp(nid, ch, dir, idx);
164
165 return snd_hdac_regmap_update_raw(codec, cmd, mask, val);
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179
180 static inline int
181 snd_hdac_regmap_get_amp_stereo(struct hdac_device *codec, hda_nid_t nid,
182 int dir, int idx)
183 {
184 unsigned int cmd = snd_hdac_regmap_encode_amp_stereo(nid, dir, idx);
185 int err, val;
186
187 err = snd_hdac_regmap_read_raw(codec, cmd, &val);
188 return err < 0 ? err : val;
189 }
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204 static inline int
205 snd_hdac_regmap_update_amp_stereo(struct hdac_device *codec, hda_nid_t nid,
206 int dir, int idx, int mask, int val)
207 {
208 unsigned int cmd = snd_hdac_regmap_encode_amp_stereo(nid, dir, idx);
209
210 return snd_hdac_regmap_update_raw(codec, cmd, mask, val);
211 }
212
213
214
215
216
217
218 static inline void
219 snd_hdac_regmap_sync_node(struct hdac_device *codec, hda_nid_t nid)
220 {
221 regcache_mark_dirty(codec->regmap);
222 regcache_sync_region(codec->regmap, nid << 20, ((nid + 1) << 20) - 1);
223 }
224
225 #endif