~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/arizona.h

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.10 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.83 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.153 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.200 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.200 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.76 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * arizona.h - Wolfson Arizona class device shared support
  3  *
  4  * Copyright 2012 Wolfson Microelectronics plc
  5  *
  6  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7  *
  8  * This program is free software; you can redistribute it and/or modify
  9  * it under the terms of the GNU General Public License version 2 as
 10  * published by the Free Software Foundation.
 11  */
 12 
 13 #ifndef _ASOC_ARIZONA_H
 14 #define _ASOC_ARIZONA_H
 15 
 16 #include <linux/completion.h>
 17 #include <linux/notifier.h>
 18 #include <linux/mfd/arizona/core.h>
 19 
 20 #include <sound/soc.h>
 21 
 22 #include "wm_adsp.h"
 23 
 24 #define ARIZONA_CLK_SYSCLK         1
 25 #define ARIZONA_CLK_ASYNCCLK       2
 26 #define ARIZONA_CLK_OPCLK          3
 27 #define ARIZONA_CLK_ASYNC_OPCLK    4
 28 
 29 #define ARIZONA_CLK_SRC_MCLK1    0x0
 30 #define ARIZONA_CLK_SRC_MCLK2    0x1
 31 #define ARIZONA_CLK_SRC_FLL1     0x4
 32 #define ARIZONA_CLK_SRC_FLL2     0x5
 33 #define ARIZONA_CLK_SRC_AIF1BCLK 0x8
 34 #define ARIZONA_CLK_SRC_AIF2BCLK 0x9
 35 #define ARIZONA_CLK_SRC_AIF3BCLK 0xa
 36 
 37 #define ARIZONA_FLL_SRC_NONE      -1
 38 #define ARIZONA_FLL_SRC_MCLK1      0
 39 #define ARIZONA_FLL_SRC_MCLK2      1
 40 #define ARIZONA_FLL_SRC_SLIMCLK    3
 41 #define ARIZONA_FLL_SRC_FLL1       4
 42 #define ARIZONA_FLL_SRC_FLL2       5
 43 #define ARIZONA_FLL_SRC_AIF1BCLK   8
 44 #define ARIZONA_FLL_SRC_AIF2BCLK   9
 45 #define ARIZONA_FLL_SRC_AIF3BCLK  10
 46 #define ARIZONA_FLL_SRC_AIF1LRCLK 12
 47 #define ARIZONA_FLL_SRC_AIF2LRCLK 13
 48 #define ARIZONA_FLL_SRC_AIF3LRCLK 14
 49 
 50 #define ARIZONA_MIXER_VOL_MASK             0x00FE
 51 #define ARIZONA_MIXER_VOL_SHIFT                 1
 52 #define ARIZONA_MIXER_VOL_WIDTH                 7
 53 
 54 #define ARIZONA_CLK_6MHZ   0
 55 #define ARIZONA_CLK_12MHZ  1
 56 #define ARIZONA_CLK_24MHZ  2
 57 #define ARIZONA_CLK_49MHZ  3
 58 #define ARIZONA_CLK_73MHZ  4
 59 #define ARIZONA_CLK_98MHZ  5
 60 #define ARIZONA_CLK_147MHZ 6
 61 
 62 #define ARIZONA_MAX_DAI  10
 63 #define ARIZONA_MAX_ADSP 4
 64 
 65 #define ARIZONA_DVFS_SR1_RQ     0x001
 66 #define ARIZONA_DVFS_ADSP1_RQ   0x100
 67 
 68 /* Notifier events */
 69 #define ARIZONA_NOTIFY_VOICE_TRIGGER   0x1
 70 
 71 struct wm_adsp;
 72 
 73 struct arizona_dai_priv {
 74         int clk;
 75 
 76         struct snd_pcm_hw_constraint_list constraint;
 77 };
 78 
 79 struct arizona_priv {
 80         struct wm_adsp adsp[ARIZONA_MAX_ADSP];
 81         struct arizona *arizona;
 82         int sysclk;
 83         int asyncclk;
 84         struct arizona_dai_priv dai[ARIZONA_MAX_DAI];
 85 
 86         int num_inputs;
 87         unsigned int in_pending;
 88 
 89         unsigned int out_up_pending;
 90         unsigned int out_up_delay;
 91         unsigned int out_down_pending;
 92         unsigned int out_down_delay;
 93 
 94         unsigned int dvfs_reqs;
 95         struct mutex dvfs_lock;
 96         bool dvfs_cached;
 97 };
 98 
 99 struct arizona_voice_trigger_info {
100         int core;
101 };
102 
103 #define ARIZONA_NUM_MIXER_INPUTS 104
104 
105 extern const unsigned int arizona_mixer_tlv[];
106 extern const char * const arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS];
107 extern unsigned int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
108 
109 #define ARIZONA_GAINMUX_CONTROLS(name, base) \
110         SOC_SINGLE_RANGE_TLV(name " Input Volume", base + 1,            \
111                              ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0,    \
112                              arizona_mixer_tlv)
113 
114 #define ARIZONA_MIXER_CONTROLS(name, base) \
115         SOC_SINGLE_RANGE_TLV(name " Input 1 Volume", base + 1,          \
116                              ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0,    \
117                              arizona_mixer_tlv),                        \
118         SOC_SINGLE_RANGE_TLV(name " Input 2 Volume", base + 3,          \
119                              ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0,    \
120                              arizona_mixer_tlv),                        \
121         SOC_SINGLE_RANGE_TLV(name " Input 3 Volume", base + 5,          \
122                              ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0,    \
123                              arizona_mixer_tlv),                        \
124         SOC_SINGLE_RANGE_TLV(name " Input 4 Volume", base + 7,          \
125                              ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0,    \
126                              arizona_mixer_tlv)
127 
128 #define ARIZONA_MUX_ENUM_DECL(name, reg) \
129         SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL( \
130                 name, reg, 0, 0xff, arizona_mixer_texts, arizona_mixer_values)
131 
132 #define ARIZONA_MUX_CTL_DECL(name) \
133         const struct snd_kcontrol_new name##_mux =      \
134                 SOC_DAPM_ENUM("Route", name##_enum)
135 
136 #define ARIZONA_MUX_ENUMS(name, base_reg) \
137         static ARIZONA_MUX_ENUM_DECL(name##_enum, base_reg);      \
138         static ARIZONA_MUX_CTL_DECL(name)
139 
140 #define ARIZONA_MIXER_ENUMS(name, base_reg) \
141         ARIZONA_MUX_ENUMS(name##_in1, base_reg);     \
142         ARIZONA_MUX_ENUMS(name##_in2, base_reg + 2); \
143         ARIZONA_MUX_ENUMS(name##_in3, base_reg + 4); \
144         ARIZONA_MUX_ENUMS(name##_in4, base_reg + 6)
145 
146 #define ARIZONA_DSP_AUX_ENUMS(name, base_reg) \
147         ARIZONA_MUX_ENUMS(name##_aux1, base_reg);       \
148         ARIZONA_MUX_ENUMS(name##_aux2, base_reg + 8);   \
149         ARIZONA_MUX_ENUMS(name##_aux3, base_reg + 16);  \
150         ARIZONA_MUX_ENUMS(name##_aux4, base_reg + 24);  \
151         ARIZONA_MUX_ENUMS(name##_aux5, base_reg + 32);  \
152         ARIZONA_MUX_ENUMS(name##_aux6, base_reg + 40)
153 
154 #define ARIZONA_MUX(name, ctrl) \
155         SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, 0, 0, ctrl)
156 
157 #define ARIZONA_MUX_WIDGETS(name, name_str) \
158         ARIZONA_MUX(name_str " Input", &name##_mux)
159 
160 #define ARIZONA_MIXER_WIDGETS(name, name_str)   \
161         ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \
162         ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \
163         ARIZONA_MUX(name_str " Input 3", &name##_in3_mux), \
164         ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \
165         SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
166 
167 #define ARIZONA_DSP_WIDGETS(name, name_str) \
168         ARIZONA_MIXER_WIDGETS(name##L, name_str "L"), \
169         ARIZONA_MIXER_WIDGETS(name##R, name_str "R"), \
170         ARIZONA_MUX(name_str " Aux 1", &name##_aux1_mux), \
171         ARIZONA_MUX(name_str " Aux 2", &name##_aux2_mux), \
172         ARIZONA_MUX(name_str " Aux 3", &name##_aux3_mux), \
173         ARIZONA_MUX(name_str " Aux 4", &name##_aux4_mux), \
174         ARIZONA_MUX(name_str " Aux 5", &name##_aux5_mux), \
175         ARIZONA_MUX(name_str " Aux 6", &name##_aux6_mux)
176 
177 #define ARIZONA_MUX_ROUTES(widget, name) \
178         { widget, NULL, name " Input" }, \
179         ARIZONA_MIXER_INPUT_ROUTES(name " Input")
180 
181 #define ARIZONA_MIXER_ROUTES(widget, name) \
182         { widget, NULL, name " Mixer" },         \
183         { name " Mixer", NULL, name " Input 1" }, \
184         { name " Mixer", NULL, name " Input 2" }, \
185         { name " Mixer", NULL, name " Input 3" }, \
186         { name " Mixer", NULL, name " Input 4" }, \
187         ARIZONA_MIXER_INPUT_ROUTES(name " Input 1"), \
188         ARIZONA_MIXER_INPUT_ROUTES(name " Input 2"), \
189         ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \
190         ARIZONA_MIXER_INPUT_ROUTES(name " Input 4")
191 
192 #define ARIZONA_DSP_ROUTES(name) \
193         { name, NULL, name " Preloader"}, \
194         { name " Preloader", NULL, "SYSCLK" }, \
195         { name " Preload", NULL, name " Preloader"}, \
196         { name, NULL, name " Aux 1" }, \
197         { name, NULL, name " Aux 2" }, \
198         { name, NULL, name " Aux 3" }, \
199         { name, NULL, name " Aux 4" }, \
200         { name, NULL, name " Aux 5" }, \
201         { name, NULL, name " Aux 6" }, \
202         ARIZONA_MIXER_INPUT_ROUTES(name " Aux 1"), \
203         ARIZONA_MIXER_INPUT_ROUTES(name " Aux 2"), \
204         ARIZONA_MIXER_INPUT_ROUTES(name " Aux 3"), \
205         ARIZONA_MIXER_INPUT_ROUTES(name " Aux 4"), \
206         ARIZONA_MIXER_INPUT_ROUTES(name " Aux 5"), \
207         ARIZONA_MIXER_INPUT_ROUTES(name " Aux 6"), \
208         ARIZONA_MIXER_ROUTES(name, name "L"), \
209         ARIZONA_MIXER_ROUTES(name, name "R")
210 
211 #define ARIZONA_EQ_CONTROL(xname, xbase)                      \
212 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
213         .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
214         .put = arizona_eq_coeff_put, .private_value =         \
215         ((unsigned long)&(struct soc_bytes) { .base = xbase,  \
216          .num_regs = 20, .mask = ~ARIZONA_EQ1_B1_MODE }) }
217 
218 #define ARIZONA_LHPF_CONTROL(xname, xbase)                    \
219 {       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,   \
220         .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
221         .put = arizona_lhpf_coeff_put, .private_value =       \
222         ((unsigned long)&(struct soc_bytes) { .base = xbase,  \
223          .num_regs = 1 }) }
224 
225 #define ARIZONA_RATE_ENUM_SIZE 4
226 #define ARIZONA_SAMPLE_RATE_ENUM_SIZE 14
227 
228 extern const char * const arizona_rate_text[ARIZONA_RATE_ENUM_SIZE];
229 extern const unsigned int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE];
230 extern const char * const arizona_sample_rate_text[ARIZONA_SAMPLE_RATE_ENUM_SIZE];
231 extern const unsigned int arizona_sample_rate_val[ARIZONA_SAMPLE_RATE_ENUM_SIZE];
232 
233 extern const struct soc_enum arizona_isrc_fsl[];
234 extern const struct soc_enum arizona_isrc_fsh[];
235 extern const struct soc_enum arizona_asrc_rate1;
236 
237 extern const struct soc_enum arizona_in_vi_ramp;
238 extern const struct soc_enum arizona_in_vd_ramp;
239 
240 extern const struct soc_enum arizona_out_vi_ramp;
241 extern const struct soc_enum arizona_out_vd_ramp;
242 
243 extern const struct soc_enum arizona_lhpf1_mode;
244 extern const struct soc_enum arizona_lhpf2_mode;
245 extern const struct soc_enum arizona_lhpf3_mode;
246 extern const struct soc_enum arizona_lhpf4_mode;
247 
248 extern const struct soc_enum arizona_ng_hold;
249 extern const struct soc_enum arizona_in_hpf_cut_enum;
250 extern const struct soc_enum arizona_in_dmic_osr[];
251 
252 extern const struct snd_kcontrol_new arizona_adsp2_rate_controls[];
253 
254 extern const struct soc_enum arizona_anc_input_src[];
255 extern const struct soc_enum arizona_anc_ng_enum;
256 extern const struct soc_enum arizona_output_anc_src[];
257 
258 extern const struct snd_kcontrol_new arizona_voice_trigger_switch[];
259 
260 int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
261                   int event);
262 int arizona_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
263                    int event);
264 int arizona_hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
265                   int event);
266 int arizona_anc_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
267                    int event);
268 
269 int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol,
270                          struct snd_ctl_elem_value *ucontrol);
271 int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol,
272                            struct snd_ctl_elem_value *ucontrol);
273 
274 int arizona_clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
275                    int event);
276 int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, int source,
277                        unsigned int freq, int dir);
278 
279 extern const struct snd_soc_dai_ops arizona_dai_ops;
280 extern const struct snd_soc_dai_ops arizona_simple_dai_ops;
281 
282 #define ARIZONA_FLL_NAME_LEN 20
283 
284 struct arizona_fll {
285         struct arizona *arizona;
286         int id;
287         unsigned int base;
288         unsigned int vco_mult;
289 
290         unsigned int fout;
291         int sync_src;
292         unsigned int sync_freq;
293         int ref_src;
294         unsigned int ref_freq;
295 
296         char lock_name[ARIZONA_FLL_NAME_LEN];
297         char clock_ok_name[ARIZONA_FLL_NAME_LEN];
298 };
299 
300 int arizona_dvfs_up(struct snd_soc_codec *codec, unsigned int flags);
301 int arizona_dvfs_down(struct snd_soc_codec *codec, unsigned int flags);
302 int arizona_dvfs_sysclk_ev(struct snd_soc_dapm_widget *w,
303                            struct snd_kcontrol *kcontrol, int event);
304 void arizona_init_dvfs(struct arizona_priv *priv);
305 
306 int arizona_init_fll(struct arizona *arizona, int id, int base,
307                      int lock_irq, int ok_irq, struct arizona_fll *fll);
308 int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
309                            unsigned int Fref, unsigned int Fout);
310 int arizona_set_fll(struct arizona_fll *fll, int source,
311                     unsigned int Fref, unsigned int Fout);
312 
313 int arizona_init_spk(struct snd_soc_codec *codec);
314 int arizona_init_gpio(struct snd_soc_codec *codec);
315 int arizona_init_mono(struct snd_soc_codec *codec);
316 int arizona_init_notifiers(struct snd_soc_codec *codec);
317 
318 int arizona_init_spk_irqs(struct arizona *arizona);
319 int arizona_free_spk_irqs(struct arizona *arizona);
320 
321 int arizona_init_dai(struct arizona_priv *priv, int dai);
322 
323 int arizona_set_output_mode(struct snd_soc_codec *codec, int output,
324                             bool diff);
325 
326 bool arizona_input_analog(struct snd_soc_codec *codec, int shift);
327 
328 const char *arizona_sample_rate_val_to_name(unsigned int rate_val);
329 
330 static inline int arizona_register_notifier(struct snd_soc_codec *codec,
331                                             struct notifier_block *nb,
332                                             int (*notify)
333                                             (struct notifier_block *nb,
334                                             unsigned long action, void *data))
335 {
336         struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
337         struct arizona *arizona = priv->arizona;
338 
339         nb->notifier_call = notify;
340 
341         return blocking_notifier_chain_register(&arizona->notifier, nb);
342 }
343 
344 static inline int arizona_unregister_notifier(struct snd_soc_codec *codec,
345                                               struct notifier_block *nb)
346 {
347         struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
348         struct arizona *arizona = priv->arizona;
349 
350         return blocking_notifier_chain_unregister(&arizona->notifier, nb);
351 }
352 
353 #endif
354 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp