blob: 1c154c33355f5ddd65917a5f6a87e050e8fcc145 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001#ifndef __LINUX_MFD_MSM_ADIE_CODEC_H
2#define __LINUX_MFD_MSM_ADIE_CODEC_H
3
4#include <linux/types.h>
5
6/* Value Represents a entry */
7#define ADIE_CODEC_ACTION_ENTRY 0x1
8/* Value representing a delay wait */
9#define ADIE_CODEC_ACTION_DELAY_WAIT 0x2
10/* Value representing a stage reached */
11#define ADIE_CODEC_ACTION_STAGE_REACHED 0x3
12
13/* This value is the state after the client sets the path */
14#define ADIE_CODEC_PATH_OFF 0x0050
15
16/* State to which client asks the drv to proceed to where it can
17 * set up the clocks and 0-fill PCM buffers
18 */
19#define ADIE_CODEC_DIGITAL_READY 0x0100
20
21/* State to which client asks the drv to proceed to where it can
22 * start sending data after internal steady state delay
23 */
24#define ADIE_CODEC_DIGITAL_ANALOG_READY 0x1000
25
26
27/* Client Asks adie to switch off the Analog portion of the
28 * the internal codec. After the use of this path
29 */
30#define ADIE_CODEC_ANALOG_OFF 0x0750
31
32
33/* Client Asks adie to switch off the digital portion of the
34 * the internal codec. After switching off the analog portion.
35 *
36 * 0-fill PCM may or maynot be sent at this point
37 *
38 */
39#define ADIE_CODEC_DIGITAL_OFF 0x0600
40
41/* State to which client asks the drv to write the default values
42 * to the registers */
43#define ADIE_CODEC_FLASH_IMAGE 0x0001
44
45/* Path type */
46#define ADIE_CODEC_RX 0
47#define ADIE_CODEC_TX 1
48#define ADIE_CODEC_LB 3
49#define ADIE_CODEC_MAX 4
50
51#define ADIE_CODEC_PACK_ENTRY(reg, mask, val) ((val)|(mask << 8)|(reg << 16))
52
53#define ADIE_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
54 do { \
55 ((reg) = ((packed >> 16) & (0xff))); \
56 ((mask) = ((packed >> 8) & (0xff))); \
57 ((val) = ((packed) & (0xff))); \
58 } while (0);
59
60struct adie_codec_action_unit {
61 u32 type;
62 u32 action;
63};
64
65struct adie_codec_hwsetting_entry{
66 struct adie_codec_action_unit *actions;
67 u32 action_sz;
Flemmarda8c9fcd2014-02-28 21:54:15 +010068#if defined(CONFIG_MSM8X60_AUDIO) && defined(CONFIG_MACH_HTC)
69 struct adie_codec_action_unit *midi_action;
70 u32 midi_action_sz;
71 struct adie_codec_action_unit *voc_action;
72 u32 voc_action_sz;
73#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074 u32 freq_plan;
75 u32 osr;
76 /* u32 VolMask;
77 * u32 SidetoneMask;
78 */
79};
80
81struct adie_codec_dev_profile {
82 u32 path_type; /* RX or TX */
83 u32 setting_sz;
84 struct adie_codec_hwsetting_entry *settings;
85};
86
87struct adie_codec_register {
88 u8 reg;
89 u8 mask;
90 u8 val;
91};
92
93struct adie_codec_register_image {
94 struct adie_codec_register *regs;
95 u32 img_sz;
96};
97
98struct adie_codec_path;
99
100struct adie_codec_anc_data {
101 u32 size;
102 u32 writes[];
103};
104
105struct adie_codec_operations {
106 int codec_id;
107 int (*codec_open) (struct adie_codec_dev_profile *profile,
108 struct adie_codec_path **path_pptr);
109 int (*codec_close) (struct adie_codec_path *path_ptr);
110 int (*codec_setpath) (struct adie_codec_path *path_ptr,
111 u32 freq_plan, u32 osr);
112 int (*codec_proceed_stage) (struct adie_codec_path *path_ptr,
113 u32 state);
114 u32 (*codec_freq_supported) (struct adie_codec_dev_profile *profile,
115 u32 requested_freq);
116 int (*codec_enable_sidetone) (struct adie_codec_path *rx_path_ptr,
117 u32 enable);
118 int (*codec_enable_anc) (struct adie_codec_path *rx_path_ptr,
119 u32 enable, struct adie_codec_anc_data *calibration_writes);
120 int (*codec_set_device_digital_volume) (
121 struct adie_codec_path *path_ptr,
122 u32 num_channels,
123 u32 vol_percentage);
124
125 int (*codec_set_device_analog_volume) (struct adie_codec_path *path_ptr,
126 u32 num_channels,
127 u32 volume);
128 int (*codec_set_master_mode) (struct adie_codec_path *path_ptr,
129 u8 master);
130};
131
132int adie_codec_register_codec_operations(
133 const struct adie_codec_operations *codec_ops);
134int adie_codec_open(struct adie_codec_dev_profile *profile,
135 struct adie_codec_path **path_pptr);
136int adie_codec_setpath(struct adie_codec_path *path_ptr,
137 u32 freq_plan, u32 osr);
138int adie_codec_proceed_stage(struct adie_codec_path *path_ptr, u32 state);
139int adie_codec_close(struct adie_codec_path *path_ptr);
140u32 adie_codec_freq_supported(struct adie_codec_dev_profile *profile,
141 u32 requested_freq);
142int adie_codec_enable_sidetone(struct adie_codec_path *rx_path_ptr, u32 enable);
143int adie_codec_enable_anc(struct adie_codec_path *rx_path_ptr, u32 enable,
144 struct adie_codec_anc_data *calibration_writes);
145int adie_codec_set_device_digital_volume(struct adie_codec_path *path_ptr,
146 u32 num_channels, u32 vol_percentage /* in percentage */);
147
148int adie_codec_set_device_analog_volume(struct adie_codec_path *path_ptr,
149 u32 num_channels, u32 volume /* in percentage */);
150
151int adie_codec_set_master_mode(struct adie_codec_path *path_ptr, u8 master);
152#endif