OSDN Git Service

sound: import xiaomi changes
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / sound / soc / codecs / tfa98xx / config.h
1 #ifndef __CONFIG_LINUX_KERNEL_INC__
2 #define __CONFIG_LINUX_KERNEL_INC__
3
4 #include <linux/kernel.h>
5 #include <linux/types.h>
6 #include <linux/ctype.h>
7 #include <linux/delay.h>
8 #include <linux/slab.h>
9 #include <linux/crc32.h>
10 #include <linux/ftrace.h>
11 #include <linux/of_device.h>
12 #include <sound/pcm.h>
13
14 /*
15         i2c transaction on Linux limited to 64k
16         (See Linux kernel documentation: Documentation/i2c/writing-clients)
17 */
18 #define MAX_I2C_BUFFER_SIZE 65536
19 #define TFA98XX_FLAG_TDM_DEVICE (1 << 10)
20 /* max. length of a alsa mixer control name */
21 #define MAX_CONTROL_NAME        48
22
23 /* dbgprint.h */
24 #define PRINT(fmt) "%s: " fmt, __func__
25
26 #define _ASSERT(e)
27 #define PRINT_ASSERT(e)if ((e)) printk(KERN_ERR "PrintAssert:%s (%s:%d) error code:%d\n", __FUNCTION__, __FILE__, __LINE__, e)
28
29 #define TFA98XX_MAX_REGISTER    0xff
30
31 #define TFA98XX_FLAG_DSP_START_ON_MUTE  (1 << 0)
32 #define TFA98XX_FLAG_SKIP_INTERRUPTS    (1 << 1)
33 #define TFA98XX_FLAG_SAAM_AVAILABLE     (1 << 2)
34 #define TFA98XX_FLAG_STEREO_DEVICE      (1 << 3)
35 #define TFA98XX_FLAG_MULTI_MIC_INPUTS   (1 << 4)
36 #define TFA98XX_FLAG_TAPDET_AVAILABLE   (1 << 5)
37 #define TFA98XX_FLAG_TFA9890_FAM_DEV    (1 << 6)
38 #define TFA98XX_FLAG_TFA9897_FAM_DEV    (1 << 7)
39
40 #define TFA98XX_NUM_RATES               9
41 /* DSP init status */
42 enum tfa98xx_dsp_init_state {
43         TFA98XX_DSP_INIT_STOPPED,       /* DSP not running */
44         TFA98XX_DSP_INIT_RECOVER,       /* DSP error detected at runtime */
45         TFA98XX_DSP_INIT_FAIL,          /* DSP init failed */
46         TFA98XX_DSP_INIT_PENDING,       /* DSP start requested */
47         TFA98XX_DSP_INIT_DONE,          /* DSP running */
48         TFA98XX_DSP_INIT_INVALIDATED,   /* DSP was running, requires re-init */
49 };
50
51 enum tfa98xx_dsp_fw_state {
52         TFA98XX_DSP_FW_NONE = 0,
53         TFA98XX_DSP_FW_PENDING,
54         TFA98XX_DSP_FW_FAIL,
55         TFA98XX_DSP_FW_OK,
56 };
57
58 struct tfa98xx_firmware {
59         void                    *base;
60         struct tfa98xx_device   *dev;
61         char                    name[9];
62 };
63
64 struct tfa98xx_baseprofile {
65         char basename[MAX_CONTROL_NAME];    /* profile basename */
66         int len;                            /* profile length */
67         int item_id;                        /* profile id */
68         int sr_rate_sup[TFA98XX_NUM_RATES]; /* sample rates supported by this profile */
69         struct list_head list;              /* list of all profiles */
70 };
71
72 struct tfa98xx {
73         struct regmap *regmap;
74         struct i2c_client *i2c;
75         struct regulator *vdd;
76         struct snd_soc_codec *codec;
77         struct workqueue_struct *tfa98xx_wq;
78         struct delayed_work init_work;
79         struct delayed_work monitor_work;
80         struct delayed_work interrupt_work;
81         struct delayed_work tapdet_work;
82         struct mutex dsp_lock;
83         int dsp_init;
84         int dsp_fw_state;
85         int sysclk;
86         int rst_gpio;
87         u16 rev;
88         int has_drc;
89         int audio_mode;
90         struct tfa98xx_firmware fw;
91         char *fw_name;
92         int rate;
93         wait_queue_head_t wq;
94         struct device *dev;
95         unsigned int init_count;
96         int pstream;
97         int cstream;
98         struct input_dev *input;
99         bool tapdet_enabled;            /* service enabled */
100         bool tapdet_open;               /* device file opened */
101         unsigned int tapdet_profiles;   /* tapdet profile bitfield */
102         bool tapdet_poll;               /* tapdet running on polling mode */
103
104         unsigned int rate_constraint_list[TFA98XX_NUM_RATES];
105         struct snd_pcm_hw_constraint_list rate_constraint;
106
107         int reset_gpio;
108         int power_gpio;
109         int irq_gpio;
110
111         int handle;
112
113 #ifdef CONFIG_DEBUG_FS
114         struct dentry *dbg_dir;
115 #endif
116         u8 reg;
117
118         unsigned int count_wait_for_source_state;
119         unsigned int count_noclk;
120         unsigned int flags;
121
122         struct device_node *spk_id_gpio_p;
123 };
124
125 #if defined(CONFIG_TRACING) && defined(DEBUG)
126         #define tfa98xx_trace_printk(...) trace_printk(__VA_ARGS__)
127 #else
128         #define tfa98xx_trace_printk(...)
129 #endif
130
131 /*
132         i2c transaction on Linux limited to 64k
133         (See Linux kernel documentation: Documentation/i2c/writing-clients)
134 */
135 static inline int NXP_I2C_BufferSize(void)
136 {
137         return 65536;
138 }
139
140 #endif /* __CONFIG_LINUX_KERNEL_INC__ */
141