OSDN Git Service

sound: import xiaomi changes
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / sound / soc / codecs / tfa98xx / tfa_internal.h
1 /*
2         internal functions for TFA layer (not shared with SRV and HAL layer!)
3 */
4
5 #ifndef __TFA_INTERNAL_H__
6 #define __TFA_INTERNAL_H__
7
8 #include "tfa_dsp_fw.h"
9 #include "tfa_service.h"
10 #include "config.h"
11
12 #if __GNUC__ >= 4
13   #define TFA_INTERNAL __attribute__ ((visibility ("hidden")))
14 #else
15   #define TFA_INTERNAL
16 #endif
17
18
19 #define TFA98XX_GENERIC_SLAVE_ADDRESS 0x1C
20
21 enum featureSupport {
22         supportNotSet, /* the default is not set yet, so = 0 */
23         supportNo,
24         supportYes
25 };
26
27 typedef enum featureSupport featureSupport_t;
28
29 /*
30  * tfa98xx control structure gathers data related to a single control
31  * (a 'control' can be related to an interface file)
32  * Some operations can be flagged as deferrable, meaning that they can be
33  *   scheduled for later execution. This can be used for operations that
34  *   require the i2s clock to run, and if it is not available while applying
35  *   the control.
36  * The Some operations can as well be cache-able (supposedly they are the same
37  *   operations as the deferrable). Cache-able means that the status or
38  *   register value may not be accesable while accessing the control. Caching
39  *   allows to get the last programmed value.
40  *
41  * Fields:
42  * deferrable:
43  *   true: means the action or register accces can be run later (for example
44  *   when an active i2s clock will be available).
45  *   false: meams the operation can be applied immediately
46  * triggered: true if the deferred operation was triggered and is scheduled
47  *   to run later
48  * wr_value: the value to write in the deferred action (if applicable)
49  * rd_value: the cached value to report on a cached read (if applicable)
50  * rd_valid: true if the rd_value was initialized (and can be reported)
51  */
52
53 struct tfa98xx_control {
54         bool deferrable;
55         bool triggered;
56         int wr_value;
57         int rd_value;
58         bool rd_valid;
59 };
60
61 struct tfa98xx_controls {
62         struct tfa98xx_control otc;
63         struct tfa98xx_control mtpex;
64         struct tfa98xx_control calib;
65 };
66
67 struct tfa_device_ops {
68         enum Tfa98xx_Error (*tfa_init)(Tfa98xx_handle_t dev_idx);
69         enum Tfa98xx_Error (*tfa_dsp_reset)(Tfa98xx_handle_t dev_idx, int state);
70         enum Tfa98xx_Error (*tfa_dsp_system_stable)(Tfa98xx_handle_t handle, int *ready);
71         enum Tfa98xx_Error (*tfa_dsp_write_tables)(Tfa98xx_handle_t dev_idx, int sample_rate);
72         struct tfa98xx_controls controls;
73 };
74
75 struct Tfa98xx_handle_private {
76         int in_use;
77         int buffer_size;
78         unsigned char slave_address;
79         unsigned short rev;
80         unsigned char tfa_family; /* tfa1/tfa2 */
81         enum featureSupport supportDrc;
82         enum featureSupport supportFramework;
83         enum featureSupport support_saam;
84         int sw_feature_bits[2]; /* cached feature bits data */
85         int hw_feature_bits; /* cached feature bits data */
86         int profile;    /* cached active profile */
87         int vstep[2]; /* cached active vsteps */
88         unsigned char spkr_count;
89         unsigned char spkr_select;
90         unsigned char support_tcoef;
91         enum Tfa98xx_DAI daimap;
92         int mohm[3]; /* > speaker calibration values in milli ohms -1 is error */
93         struct tfa_device_ops dev_ops;
94         uint16_t interrupt_enable[3];
95         uint16_t interrupt_status[3];
96 };
97
98 /* tfa_core.c */
99 extern TFA_INTERNAL struct Tfa98xx_handle_private handles_local[];
100 TFA_INTERNAL int tfa98xx_handle_is_open(Tfa98xx_handle_t h);
101 TFA_INTERNAL enum Tfa98xx_Error tfa98xx_check_rpc_status(Tfa98xx_handle_t handle, int *pRpcStatus);
102 TFA_INTERNAL enum Tfa98xx_Error tfa98xx_wait_result(Tfa98xx_handle_t handle, int waitRetryCount);
103 TFA_INTERNAL void tfa98xx_apply_deferred_calibration(Tfa98xx_handle_t handle);
104 TFA_INTERNAL void tfa98xx_deferred_calibration_status(Tfa98xx_handle_t handle, int calibrateDone);
105 TFA_INTERNAL int print_calibration(Tfa98xx_handle_t handle, char *str, size_t size);
106
107 #endif /* __TFA_INTERNAL_H__ */
108