diff options
Diffstat (limited to 'include/media/nvc.h')
-rw-r--r-- | include/media/nvc.h | 284 |
1 files changed, 284 insertions, 0 deletions
diff --git a/include/media/nvc.h b/include/media/nvc.h new file mode 100644 index 00000000000..9b24b0ea019 --- /dev/null +++ b/include/media/nvc.h | |||
@@ -0,0 +1,284 @@ | |||
1 | /* Copyright (C) 2012 NVIDIA Corporation. | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 as | ||
5 | * published by the Free Software Foundation. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
15 | * 02111-1307, USA | ||
16 | */ | ||
17 | |||
18 | #ifndef __NVC_H__ | ||
19 | #define __NVC_H__ | ||
20 | |||
21 | #include <linux/ioctl.h> | ||
22 | |||
23 | #define NVC_INT2FLOAT_DIVISOR_1K 1000 | ||
24 | #define NVC_INT2FLOAT_DIVISOR_1M 1000000 | ||
25 | #define NVC_INT2FLOAT_DIVISOR 1000 | ||
26 | |||
27 | struct nvc_param { | ||
28 | int param; | ||
29 | __u32 sizeofvalue; | ||
30 | void *p_value; | ||
31 | } __packed; | ||
32 | |||
33 | enum nvc_params { | ||
34 | NVC_PARAM_EXPOSURE = 0, | ||
35 | NVC_PARAM_GAIN, | ||
36 | NVC_PARAM_FRAMERATE, | ||
37 | NVC_PARAM_MAX_FRAMERATE, | ||
38 | NVC_PARAM_INPUT_CLOCK, | ||
39 | NVC_PARAM_LOCUS, | ||
40 | NVC_PARAM_FLASH_CAPS, | ||
41 | NVC_PARAM_FLASH_LEVEL, | ||
42 | NVC_PARAM_FLASH_PIN_STATE, | ||
43 | NVC_PARAM_TORCH_CAPS, | ||
44 | NVC_PARAM_TORCH_LEVEL, | ||
45 | NVC_PARAM_FOCAL_LEN, | ||
46 | NVC_PARAM_MAX_APERTURE, | ||
47 | NVC_PARAM_FNUMBER, | ||
48 | NVC_PARAM_EXPOSURE_LIMITS, | ||
49 | NVC_PARAM_GAIN_LIMITS, | ||
50 | NVC_PARAM_FRAMERATE_LIMITS, | ||
51 | NVC_PARAM_FRAME_RATES, | ||
52 | NVC_PARAM_CLOCK_LIMITS, | ||
53 | NVC_PARAM_EXP_LATCH_TIME, | ||
54 | NVC_PARAM_REGION_USED, | ||
55 | NVC_PARAM_CALIBRATION_DATA, | ||
56 | NVC_PARAM_CALIBRATION_OVERRIDES, | ||
57 | NVC_PARAM_SELF_TEST, | ||
58 | NVC_PARAM_STS, | ||
59 | NVC_PARAM_TESTMODE, | ||
60 | NVC_PARAM_EXPECTED_VALUES, | ||
61 | NVC_PARAM_RESET, | ||
62 | NVC_PARAM_OPTIMIZE_RES, | ||
63 | NVC_PARAM_DETECT_COLOR_TEMP, | ||
64 | NVC_PARAM_LINES_PER_SEC, | ||
65 | NVC_PARAM_CAPS, | ||
66 | NVC_PARAM_CUSTOM_BLOCK_INFO, | ||
67 | NVC_PARAM_STEREO_CAP, | ||
68 | NVC_PARAM_FOCUS_STEREO, | ||
69 | NVC_PARAM_STEREO, | ||
70 | NVC_PARAM_INHERENT_GAIN, | ||
71 | NVC_PARAM_VIEW_ANGLE_H, | ||
72 | NVC_PARAM_VIEW_ANGLE_V, | ||
73 | NVC_PARAM_ISP_SETTING, | ||
74 | NVC_PARAM_OPERATION_MODE, | ||
75 | NVC_PARAM_SUPPORT_ISP, | ||
76 | NVC_PARAM_AWB_LOCK, | ||
77 | NVC_PARAM_AE_LOCK, | ||
78 | NVC_PARAM_RES_CHANGE_WAIT_TIME, | ||
79 | NVC_PARAM_FACTORY_CALIBRATION_DATA, | ||
80 | NVC_PARAM_DEV_ID, | ||
81 | NVC_PARAM_GROUP_HOLD, | ||
82 | NVC_PARAM_BEGIN_VENDOR_EXTENSIONS = 0x10000000, | ||
83 | NVC_PARAM_CALIBRATION_STATUS, | ||
84 | NVC_PARAM_TEST_PATTERN, | ||
85 | NVC_PARAM_MODULE_INFO, | ||
86 | NVC_PARAM_FLASH_MAX_POWER, | ||
87 | NVC_PARAM_DIRECTION, | ||
88 | NVC_PARAM_SENSOR_TYPE, | ||
89 | NVC_PARAM_DLI_CHECK, | ||
90 | NVC_PARAM_PARALLEL_DLI_CHECK, | ||
91 | NVC_PARAM_BRACKET_CAPS, | ||
92 | NVC_PARAM_NUM, | ||
93 | NVC_PARAM_I2C, | ||
94 | NVC_PARAM_FORCE32 = 0x7FFFFFFF | ||
95 | }; | ||
96 | |||
97 | /* sync off */ | ||
98 | #define NVC_SYNC_OFF 0 | ||
99 | /* use only this device (the one receiving the call) */ | ||
100 | #define NVC_SYNC_MASTER 1 | ||
101 | /* use only the synced device (the "other" device) */ | ||
102 | #define NVC_SYNC_SLAVE 2 | ||
103 | /* use both synced devices at the same time */ | ||
104 | #define NVC_SYNC_STEREO 3 | ||
105 | |||
106 | #define NVC_RESET_HARD 0 | ||
107 | #define NVC_RESET_SOFT 1 | ||
108 | |||
109 | struct nvc_param_isp { | ||
110 | int attr; | ||
111 | void *p_data; | ||
112 | __u32 data_size; | ||
113 | } __packed; | ||
114 | |||
115 | struct nvc_isp_focus_param { | ||
116 | __s32 min_pos; | ||
117 | __s32 max_pos; | ||
118 | __s32 hyperfocal; | ||
119 | __s32 macro; | ||
120 | __s32 powersave; | ||
121 | } __packed; | ||
122 | |||
123 | struct nvc_isp_focus_pos { | ||
124 | __u32 is_auto; | ||
125 | __s32 value; | ||
126 | } __packed; | ||
127 | |||
128 | struct nvc_isp_focus_region { | ||
129 | __u32 num_region; | ||
130 | __s32 value; | ||
131 | } __packed; | ||
132 | |||
133 | enum nvc_params_isp { | ||
134 | NVC_PARAM_ISP_FOCUS_CAF = 16389, | ||
135 | NVC_PARAM_ISP_FOCUS_CAF_PAUSE, | ||
136 | NVC_PARAM_ISP_FOCUS_CAF_STS, | ||
137 | NVC_PARAM_ISP_FOCUS_POS = 16407, | ||
138 | NVC_PARAM_ISP_FOCUS_RANGE, | ||
139 | NVC_PARAM_ISP_FOCUS_AF_RGN = 16413, | ||
140 | NVC_PARAM_ISP_FOCUS_AF_RGN_MASK, | ||
141 | NVC_PARAM_ISP_FOCUS_AF_RGN_STS, | ||
142 | NVC_PARAM_ISP_FOCUS_CTRL = 16424, | ||
143 | NVC_PARAM_ISP_FOCUS_TRGR, | ||
144 | NVC_PARAM_ISP_FOCUS_STS, | ||
145 | }; | ||
146 | |||
147 | #define NVC_PARAM_ISP_FOCUS_STS_BUSY 0 | ||
148 | #define NVC_PARAM_ISP_FOCUS_STS_LOCKD 1 | ||
149 | #define NVC_PARAM_ISP_FOCUS_STS_FAILD 2 | ||
150 | #define NVC_PARAM_ISP_FOCUS_STS_ERR 3 | ||
151 | |||
152 | #define NVC_PARAM_ISP_FOCUS_CTRL_ON 0 | ||
153 | #define NVC_PARAM_ISP_FOCUS_CTRL_OFF 1 | ||
154 | #define NVC_PARAM_ISP_FOCUS_CTRL_AUTO 2 | ||
155 | #define NVC_PARAM_ISP_FOCUS_CTRL_ALOCK 3 | ||
156 | |||
157 | #define NVC_PARAM_ISP_FOCUS_CAF_CONVRG 1 | ||
158 | #define NVC_PARAM_ISP_FOCUS_CAF_SEARCH 2 | ||
159 | |||
160 | #define NVC_PARAM_ISP_FOCUS_POS_INF 0 | ||
161 | |||
162 | |||
163 | #define NVC_IOCTL_PWR_WR _IOW('o', 102, int) | ||
164 | #define NVC_IOCTL_PWR_RD _IOW('o', 103, int) | ||
165 | #define NVC_IOCTL_PARAM_WR _IOW('o', 104, struct nvc_param) | ||
166 | #define NVC_IOCTL_PARAM_RD _IOWR('o', 105, struct nvc_param) | ||
167 | #define NVC_IOCTL_PARAM_ISP_RD _IOWR('o', 200, struct nvc_param_isp) | ||
168 | #define NVC_IOCTL_PARAM_ISP_WR _IOWR('o', 201, struct nvc_param_isp) | ||
169 | |||
170 | |||
171 | #ifdef __KERNEL__ | ||
172 | |||
173 | #include <linux/regulator/consumer.h> | ||
174 | |||
175 | /* The NVC_CFG_ defines are for the .cfg entry in the | ||
176 | * platform data structure. | ||
177 | */ | ||
178 | /* Device not registered if not found */ | ||
179 | #define NVC_CFG_NODEV (1 << 0) | ||
180 | /* Don't return errors */ | ||
181 | #define NVC_CFG_NOERR (1 << 1) | ||
182 | /* Always go to _PWR_STDBY instead of _PWR_OFF */ | ||
183 | #define NVC_CFG_OFF2STDBY (1 << 2) | ||
184 | /* Init device at sys boot */ | ||
185 | #define NVC_CFG_BOOT_INIT (1 << 3) | ||
186 | /* Sync mode uses an I2C MUX to send at same time */ | ||
187 | #define NVC_CFG_SYNC_I2C_MUX (1 << 4) | ||
188 | |||
189 | /* Expected higher level power calls are: | ||
190 | * 1 = OFF | ||
191 | * 2 = STANDBY | ||
192 | * 3 = ON | ||
193 | * These will be multiplied by 2 before given to the driver's PM code that | ||
194 | * uses the _PWR_ defines. This allows us to insert defines to give more power | ||
195 | * granularity and still remain linear with regards to the power usage and | ||
196 | * full power state transition latency for easy implementation of PM | ||
197 | * algorithms. | ||
198 | * The PM actions: | ||
199 | * _PWR_ERR = Non-valid state. | ||
200 | * _PWR_OFF_FORCE = _PWR_OFF is forced regardless of standby mechanisms. | ||
201 | * _PWR_OFF = Device, regulators, clocks, etc is turned off. The longest | ||
202 | * transition time to _PWR_ON is from this state. | ||
203 | * _PWR_STDBY_OFF = Device is useless but powered. No communication possible. | ||
204 | * Device does not retain programming. Main purpose is for | ||
205 | * faster return to _PWR_ON without regulator delays. | ||
206 | * _PWR_STDBY = Device is in standby. Device retains programming. | ||
207 | * _PWR_COMM = Device is powered enough to communicate with the device. | ||
208 | * _PWR_ON = Device is at full power with active output. | ||
209 | * | ||
210 | * The kernel drivers treat these calls as Guaranteed Level Of Service. | ||
211 | */ | ||
212 | |||
213 | #define NVC_PWR_ERR 0 | ||
214 | #define NVC_PWR_OFF_FORCE 1 | ||
215 | #define NVC_PWR_OFF 2 | ||
216 | #define NVC_PWR_STDBY_OFF 3 | ||
217 | #define NVC_PWR_STDBY 4 | ||
218 | #define NVC_PWR_COMM 5 | ||
219 | #define NVC_PWR_ON 6 | ||
220 | |||
221 | struct nvc_regulator_init { | ||
222 | unsigned vreg_num; | ||
223 | const char *vreg_name; | ||
224 | }; | ||
225 | |||
226 | struct nvc_regulator { | ||
227 | bool vreg_flag; | ||
228 | struct regulator *vreg; | ||
229 | const char *vreg_name; | ||
230 | }; | ||
231 | |||
232 | /* The GPIO mechanism uses the _gpio_type in the device's header file as a key | ||
233 | * to define all the possible GPIO's the device will need. The key is used to | ||
234 | * combine the GPIO's defined in the platform board file using the | ||
235 | * nvc_gpio_pdata structure with the nvc_gpio structure in the nvc kernel | ||
236 | * driver. | ||
237 | */ | ||
238 | struct nvc_gpio_pdata { | ||
239 | /* use a _gpio_type enum from the device's header file */ | ||
240 | unsigned gpio_type; | ||
241 | /* the GPIO system number */ | ||
242 | unsigned gpio; | ||
243 | /* init_en is typically set to true for all GPIO's used by the driver. | ||
244 | * However, some GPIO's are used by multiple drivers (CSI MUX, reset, | ||
245 | * etc.). In this case, this is set true for only one of the drivers | ||
246 | * that uses the GPIO and false for the others. If the platform board | ||
247 | * file initializes the GPIO, then this is false for all of the drivers | ||
248 | * using the GPIO. | ||
249 | */ | ||
250 | bool init_en; | ||
251 | /* this defines the assert level for the general purpose GPIO's | ||
252 | * (_GPIO_TYPE_GPx, etc.). The _GPIO_TYPE_GPx can be used for a GPIO | ||
253 | * that the driver doesn't know about but is needed in order for the | ||
254 | * device to work (CSI select, regulator, etc.). The driver will | ||
255 | * blindly assert the GPIO when the device is operational and deassert | ||
256 | * when the device is turned off. | ||
257 | */ | ||
258 | bool active_high; | ||
259 | }; | ||
260 | |||
261 | struct nvc_gpio_init { | ||
262 | /* key to match in nvc_gpio_pdata */ | ||
263 | unsigned gpio_type; | ||
264 | /* same as in gpio.h */ | ||
265 | unsigned long flags; | ||
266 | /* same as in gpio.h */ | ||
267 | const char *label; | ||
268 | /* used instead of nvc_gpio_pdata.active_high if use_flags true */ | ||
269 | bool active_high; | ||
270 | /* false if nvc_gpio_pdata.active_high used else flags is used */ | ||
271 | bool use_flags; | ||
272 | }; | ||
273 | |||
274 | struct nvc_gpio { | ||
275 | unsigned gpio; /* system GPIO number */ | ||
276 | bool own; /* gets set if driver initializes */ | ||
277 | bool active_high; /* used for GP GPIOs */ | ||
278 | bool flag; /* scratch flag for driver implementation */ | ||
279 | }; | ||
280 | |||
281 | #endif /* __KERNEL__ */ | ||
282 | |||
283 | #endif /* __NVC_H__ */ | ||
284 | |||