0001
0002
0003
0004
0005
0006 #ifndef _WM8994_H
0007 #define _WM8994_H
0008
0009 #include <linux/clk.h>
0010 #include <sound/soc.h>
0011 #include <linux/firmware.h>
0012 #include <linux/completion.h>
0013 #include <linux/workqueue.h>
0014 #include <linux/mutex.h>
0015
0016 #include "wm_hubs.h"
0017
0018 enum {
0019 WM8994_MCLK1,
0020 WM8994_MCLK2,
0021 WM8994_NUM_MCLK
0022 };
0023
0024
0025 #define WM8994_SYSCLK_MCLK1 1
0026 #define WM8994_SYSCLK_MCLK2 2
0027 #define WM8994_SYSCLK_FLL1 3
0028 #define WM8994_SYSCLK_FLL2 4
0029
0030
0031 #define WM8994_SYSCLK_OPCLK 5
0032
0033 #define WM8994_FLL1 1
0034 #define WM8994_FLL2 2
0035
0036 #define WM8994_FLL_SRC_MCLK1 1
0037 #define WM8994_FLL_SRC_MCLK2 2
0038 #define WM8994_FLL_SRC_LRCLK 3
0039 #define WM8994_FLL_SRC_BCLK 4
0040 #define WM8994_FLL_SRC_INTERNAL 5
0041
0042 enum wm8994_vmid_mode {
0043 WM8994_VMID_NORMAL,
0044 WM8994_VMID_FORCE,
0045 };
0046
0047 typedef void (*wm1811_micdet_cb)(void *data);
0048 typedef void (*wm1811_mic_id_cb)(void *data, u16 status);
0049
0050 int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
0051 int micbias);
0052 int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
0053 wm1811_micdet_cb det_cb, void *det_cb_data,
0054 wm1811_mic_id_cb id_cb, void *id_cb_data);
0055
0056 int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode);
0057
0058 int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
0059 struct snd_kcontrol *kcontrol, int event);
0060
0061 void wm8958_dsp2_init(struct snd_soc_component *component);
0062
0063 struct wm8994_micdet {
0064 struct snd_soc_jack *jack;
0065 bool detecting;
0066 };
0067
0068
0069 struct wm8994_fll_config {
0070 int src;
0071 int in;
0072 int out;
0073 };
0074
0075 #define WM8994_NUM_DRC 3
0076 #define WM8994_NUM_EQ 3
0077
0078 struct wm8994;
0079
0080 struct wm8994_priv {
0081 struct wm_hubs_data hubs;
0082 struct wm8994 *wm8994;
0083 struct clk_bulk_data mclk[WM8994_NUM_MCLK];
0084 int sysclk[2];
0085 int sysclk_rate[2];
0086 int mclk_rate[2];
0087 int aifclk[2];
0088 int aifdiv[2];
0089 int channels[2];
0090 struct wm8994_fll_config fll[2], fll_suspend[2];
0091 struct completion fll_locked[2];
0092 bool fll_locked_irq;
0093 bool fll_byp;
0094 bool clk_has_run;
0095
0096 int vmid_refcount;
0097 int active_refcount;
0098 enum wm8994_vmid_mode vmid_mode;
0099
0100 int dac_rates[2];
0101 int lrclk_shared[2];
0102
0103 int mbc_ena[3];
0104 int hpf1_ena[3];
0105 int hpf2_ena[3];
0106 int vss_ena[3];
0107 int enh_eq_ena[3];
0108
0109
0110 const char **drc_texts;
0111 int drc_cfg[WM8994_NUM_DRC];
0112 struct soc_enum drc_enum;
0113
0114
0115 int num_retune_mobile_texts;
0116 const char **retune_mobile_texts;
0117 int retune_mobile_cfg[WM8994_NUM_EQ];
0118 struct soc_enum retune_mobile_enum;
0119
0120
0121 int mbc_cfg;
0122 const char **mbc_texts;
0123 struct soc_enum mbc_enum;
0124
0125
0126 int vss_cfg;
0127 const char **vss_texts;
0128 struct soc_enum vss_enum;
0129
0130
0131 int vss_hpf_cfg;
0132 const char **vss_hpf_texts;
0133 struct soc_enum vss_hpf_enum;
0134
0135
0136 int enh_eq_cfg;
0137 const char **enh_eq_texts;
0138 struct soc_enum enh_eq_enum;
0139
0140 struct mutex accdet_lock;
0141 struct wm8994_micdet micdet[2];
0142 struct delayed_work mic_work;
0143 struct delayed_work open_circuit_work;
0144 struct delayed_work mic_complete_work;
0145 u16 mic_status;
0146 bool mic_detecting;
0147 bool jack_mic;
0148 int btn_mask;
0149 bool jackdet;
0150 int jackdet_mode;
0151 struct delayed_work jackdet_bootstrap;
0152
0153 int micdet_irq;
0154 wm1811_micdet_cb micd_cb;
0155 void *micd_cb_data;
0156 wm1811_mic_id_cb mic_id_cb;
0157 void *mic_id_cb_data;
0158
0159 unsigned int aif1clk_enable:1;
0160 unsigned int aif2clk_enable:1;
0161
0162 unsigned int aif1clk_disable:1;
0163 unsigned int aif2clk_disable:1;
0164
0165 struct mutex fw_lock;
0166 int dsp_active;
0167 const struct firmware *cur_fw;
0168 const struct firmware *mbc;
0169 const struct firmware *mbc_vss;
0170 const struct firmware *enh_eq;
0171 };
0172
0173 #endif