blob: e5c7605616c54fc0571e6841e79a9c1a03799b66 [file] [log] [blame]
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -08001#ifndef __UAPI_CAM_SENSOR_H__
2#define __UAPI_CAM_SENSOR_H__
3
4#include <linux/types.h>
5#include <linux/ioctl.h>
6#include <media/cam_defs.h>
7
8#define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1)
Jigarkumar Zala35226272017-04-19 16:05:24 -07009#define CAM_FLASH_MAX_LED_TRIGGERS 3
Vivek Veenam281516b2017-08-17 17:39:04 +053010#define MAX_OIS_NAME_SIZE 32
Lakshmi Narayana Kalavala2c714282017-09-08 12:27:36 -070011#define CAM_CSIPHY_SECURE_MODE_ENABLED 1
Om Parkash48b8c002018-12-13 20:18:20 +053012#define CAM_IR_LED_SUPPORTED
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -080013/**
14 * struct cam_sensor_query_cap - capabilities info for sensor
15 *
16 * @slot_info : Indicates about the slotId or cell Index
17 * @secure_camera : Camera is in secure/Non-secure mode
18 * @pos_pitch : Sensor position pitch
19 * @pos_roll : Sensor position roll
20 * @pos_yaw : Sensor position yaw
21 * @actuator_slot_id : Actuator slot id which connected to sensor
22 * @eeprom_slot_id : EEPROM slot id which connected to sensor
23 * @ois_slot_id : OIS slot id which connected to sensor
24 * @flash_slot_id : Flash slot id which connected to sensor
25 * @csiphy_slot_id : CSIphy slot id which connected to sensor
Om Parkash48b8c002018-12-13 20:18:20 +053026 * @irled_slot_id : IRLED slot id which connected to sensor
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -080027 *
28 */
29struct cam_sensor_query_cap {
30 uint32_t slot_info;
31 uint32_t secure_camera;
32 uint32_t pos_pitch;
33 uint32_t pos_roll;
34 uint32_t pos_yaw;
35 uint32_t actuator_slot_id;
36 uint32_t eeprom_slot_id;
37 uint32_t ois_slot_id;
38 uint32_t flash_slot_id;
39 uint32_t csiphy_slot_id;
Om Parkash48b8c002018-12-13 20:18:20 +053040 uint32_t ir_led_slot_id;
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -080041} __attribute__((packed));
42
43/**
44 * struct cam_csiphy_query_cap - capabilities info for csiphy
45 *
46 * @slot_info : Indicates about the slotId or cell Index
47 * @version : CSIphy version
48 * @clk lane : Of the 5 lanes, informs lane configured
49 * as clock lane
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -070050 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -080051 */
52struct cam_csiphy_query_cap {
53 uint32_t slot_info;
54 uint32_t version;
55 uint32_t clk_lane;
56 uint32_t reserved;
57} __attribute__((packed));
58
59/**
60 * struct cam_actuator_query_cap - capabilities info for actuator
61 *
62 * @slot_info : Indicates about the slotId or cell Index
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -070063 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -080064 */
65struct cam_actuator_query_cap {
66 uint32_t slot_info;
67 uint32_t reserved;
68} __attribute__((packed));
69
70/**
Vivek Veenam2ad8de12017-04-04 18:56:22 +053071 * struct cam_eeprom_query_cap_t - capabilities info for eeprom
72 *
73 * @slot_info : Indicates about the slotId or cell Index
74 * @eeprom_kernel_probe : Indicates about the kernel or userspace probe
75 */
76struct cam_eeprom_query_cap_t {
77 uint32_t slot_info;
78 uint16_t eeprom_kernel_probe;
79 uint16_t reserved;
80} __attribute__((packed));
81
82/**
Vivek Veenam281516b2017-08-17 17:39:04 +053083 * struct cam_ois_query_cap_t - capabilities info for ois
84 *
85 * @slot_info : Indicates about the slotId or cell Index
86 */
87struct cam_ois_query_cap_t {
88 uint32_t slot_info;
89 uint16_t reserved;
90} __attribute__((packed));
91
92/**
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -080093 * struct cam_cmd_i2c_info - Contains slave I2C related info
94 *
95 * @slave_addr : Slave address
96 * @i2c_freq_mode : 4 bits are used for I2c freq mode
97 * @cmd_type : Explains type of command
98 */
99struct cam_cmd_i2c_info {
100 uint16_t slave_addr;
101 uint8_t i2c_freq_mode;
102 uint8_t cmd_type;
103} __attribute__((packed));
104
105/**
Vivek Veenam281516b2017-08-17 17:39:04 +0530106 * struct cam_ois_opcode - Contains OIS opcode
107 *
108 * @prog : OIS FW prog register address
109 * @coeff : OIS FW coeff register address
110 * @pheripheral : OIS pheripheral
111 * @memory : OIS memory
112 */
113struct cam_ois_opcode {
114 uint32_t prog;
115 uint32_t coeff;
116 uint32_t pheripheral;
117 uint32_t memory;
118} __attribute__((packed));
119
120/**
121 * struct cam_cmd_ois_info - Contains OIS slave info
122 *
123 * @slave_addr : OIS i2c slave address
124 * @i2c_freq_mode : i2c frequency mode
Depeng Shaocac61942017-12-29 08:17:44 +0800125 * @cmd_type : Explains type of command
Vivek Veenam281516b2017-08-17 17:39:04 +0530126 * @ois_fw_flag : indicates if fw is present or not
127 * @is_ois_calib : indicates the calibration data is available
128 * @ois_name : OIS name
129 * @opcode : opcode
Vivek Veenam281516b2017-08-17 17:39:04 +0530130 */
131struct cam_cmd_ois_info {
132 uint16_t slave_addr;
133 uint8_t i2c_freq_mode;
Depeng Shaocac61942017-12-29 08:17:44 +0800134 uint8_t cmd_type;
Vivek Veenam281516b2017-08-17 17:39:04 +0530135 uint8_t ois_fw_flag;
136 uint8_t is_ois_calib;
137 char ois_name[MAX_OIS_NAME_SIZE];
138 struct cam_ois_opcode opcode;
Vivek Veenam281516b2017-08-17 17:39:04 +0530139} __attribute__((packed));
140
141/**
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800142 * struct cam_cmd_probe - Contains sensor slave info
143 *
144 * @data_type : Slave register data type
145 * @addr_type : Slave register address type
146 * @op_code : Don't Care
147 * @cmd_type : Explains type of command
148 * @reg_addr : Slave register address
149 * @expected_data : Data expected at slave register address
150 * @data_mask : Data mask if only few bits are valid
151 * @camera_id : Indicates the slot to which camera
152 * needs to be probed
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700153 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800154 */
155struct cam_cmd_probe {
156 uint8_t data_type;
157 uint8_t addr_type;
158 uint8_t op_code;
159 uint8_t cmd_type;
160 uint32_t reg_addr;
161 uint32_t expected_data;
162 uint32_t data_mask;
163 uint16_t camera_id;
164 uint16_t reserved;
165} __attribute__((packed));
166
167/**
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700168 * struct cam_power_settings - Contains sensor power setting info
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800169 *
170 * @power_seq_type : Type of power sequence
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700171 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800172 * @config_val_low : Lower 32 bit value configuration value
173 * @config_val_high : Higher 32 bit value configuration value
174 *
175 */
176struct cam_power_settings {
177 uint16_t power_seq_type;
178 uint16_t reserved;
179 uint32_t config_val_low;
180 uint32_t config_val_high;
181} __attribute__((packed));
182
183/**
184 * struct cam_cmd_power - Explains about the power settings
185 *
186 * @count : Number of power settings follows
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700187 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800188 * @cmd_type : Explains type of command
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700189 * @power_settings : Contains power setting info
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800190 */
191struct cam_cmd_power {
192 uint16_t count;
193 uint8_t reserved;
194 uint8_t cmd_type;
195 struct cam_power_settings power_settings[1];
196} __attribute__((packed));
197
198/**
199 * struct i2c_rdwr_header - header of READ/WRITE I2C command
200 *
201 * @ count : Number of registers / data / reg-data pairs
202 * @ op_code : Operation code
203 * @ cmd_type : Command buffer type
204 * @ data_type : I2C data type
205 * @ addr_type : I2C address type
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700206 * @ reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800207 */
208struct i2c_rdwr_header {
209 uint16_t count;
210 uint8_t op_code;
211 uint8_t cmd_type;
212 uint8_t data_type;
213 uint8_t addr_type;
214 uint16_t reserved;
215} __attribute__((packed));
216
217/**
218 * struct i2c_random_wr_payload - payload for I2C random write
219 *
220 * @ reg_addr : Register address
221 * @ reg_data : Register data
222 *
223 */
224struct i2c_random_wr_payload {
225 uint32_t reg_addr;
226 uint32_t reg_data;
227} __attribute__((packed));
228
229/**
230 * struct cam_cmd_i2c_random_wr - I2C random write command
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700231 * @ header : header of READ/WRITE I2C command
232 * @ random_wr_payload : payload for I2C random write
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800233 */
234struct cam_cmd_i2c_random_wr {
235 struct i2c_rdwr_header header;
236 struct i2c_random_wr_payload random_wr_payload[1];
237} __attribute__((packed));
238
239/**
240 * struct cam_cmd_read - I2C read command
241 * @ reg_data : Register data
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700242 * @ reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800243 */
244struct cam_cmd_read {
245 uint32_t reg_data;
246 uint32_t reserved;
247} __attribute__((packed));
248
249/**
250 * struct cam_cmd_i2c_continuous_wr - I2C continuous write command
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700251 * @ header : header of READ/WRITE I2C command
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800252 * @ reg_addr : Register address
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700253 * @ data_read : I2C read command
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800254 */
255struct cam_cmd_i2c_continuous_wr {
256 struct i2c_rdwr_header header;
257 uint32_t reg_addr;
258 struct cam_cmd_read data_read[1];
259} __attribute__((packed));
260
261/**
262 * struct cam_cmd_i2c_random_rd - I2C random read command
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700263 * @ header : header of READ/WRITE I2C command
264 * @ data_read : I2C read command
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800265 */
266struct cam_cmd_i2c_random_rd {
267 struct i2c_rdwr_header header;
268 struct cam_cmd_read data_read[1];
269} __attribute__((packed));
270
271/**
272 * struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700273 * @ header : header of READ/WRITE I2C command
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800274 * @ reg_addr : Register address
275 *
276 */
277struct cam_cmd_i2c_continuous_rd {
278 struct i2c_rdwr_header header;
279 uint32_t reg_addr;
280} __attribute__((packed));
281
282/**
283 * struct cam_cmd_conditional_wait - Conditional wait command
284 * @data_type : Data type
285 * @addr_type : Address type
286 * @op_code : Opcode
287 * @cmd_type : Explains type of command
288 * @timeout : Timeout for retries
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700289 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800290 * @reg_addr : Register Address
291 * @reg_data : Register data
292 * @data_mask : Data mask if only few bits are valid
293 * @camera_id : Indicates the slot to which camera
294 * needs to be probed
295 *
296 */
297struct cam_cmd_conditional_wait {
298 uint8_t data_type;
299 uint8_t addr_type;
300 uint8_t op_code;
301 uint8_t cmd_type;
302 uint16_t timeout;
303 uint16_t reserved;
304 uint32_t reg_addr;
305 uint32_t reg_data;
306 uint32_t data_mask;
307} __attribute__((packed));
308
309/**
310 * struct cam_cmd_unconditional_wait - Un-conditional wait command
311 * @delay : Delay
312 * @op_code : Opcode
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700313 * @cmd_type : Explains type of command
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800314 */
315struct cam_cmd_unconditional_wait {
316 int16_t delay;
317 uint8_t op_code;
318 uint8_t cmd_type;
319} __attribute__((packed));
320
321/**
322 * cam_csiphy_info: Provides cmdbuffer structre
Lakshmi Narayana Kalavala2c714282017-09-08 12:27:36 -0700323 * @lane_mask : Lane mask details
324 * @lane_assign : Lane sensor will be using
325 * @csiphy_3phase : Total number of lanes
326 * @combo_mode : Info regarding combo_mode is enable / disable
327 * @lane_cnt : Total number of lanes
328 * @secure_mode : Secure mode flag to enable / disable
329 * @3phase : Details whether 3Phase / 2Phase operation
330 * @settle_time : Settling time in ms
331 * @data_rate : Data rate
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800332 *
333 */
334struct cam_csiphy_info {
335 uint16_t lane_mask;
336 uint16_t lane_assign;
337 uint8_t csiphy_3phase;
338 uint8_t combo_mode;
339 uint8_t lane_cnt;
Lakshmi Narayana Kalavala2c714282017-09-08 12:27:36 -0700340 uint8_t secure_mode;
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800341 uint64_t settle_time;
342 uint64_t data_rate;
343} __attribute__((packed));
344
345/**
346 * cam_csiphy_acquire_dev_info : Information needed for
347 * csiphy at the time of acquire
348 * @combo_mode : Indicates the device mode of operation
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700349 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800350 *
351 */
352struct cam_csiphy_acquire_dev_info {
353 uint32_t combo_mode;
354 uint32_t reserved;
355} __attribute__((packed));
356
357/**
358 * cam_sensor_acquire_dev : Updates sensor acuire cmd
359 * @device_handle : Updates device handle
360 * @session_handle : Session handle for acquiring device
361 * @handle_type : Resource handle type
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700362 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800363 * @info_handle : Handle to additional info
364 * needed for sensor sub modules
365 *
366 */
367struct cam_sensor_acquire_dev {
368 uint32_t session_handle;
369 uint32_t device_handle;
370 uint32_t handle_type;
371 uint32_t reserved;
372 uint64_t info_handle;
373} __attribute__((packed));
374
375/**
376 * cam_sensor_streamon_dev : StreamOn command for the sensor
377 * @session_handle : Session handle for acquiring device
378 * @device_handle : Updates device handle
379 * @handle_type : Resource handle type
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700380 * @reserved
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800381 * @info_handle : Information Needed at the time of streamOn
382 *
383 */
384struct cam_sensor_streamon_dev {
385 uint32_t session_handle;
386 uint32_t device_handle;
387 uint32_t handle_type;
388 uint32_t reserved;
389 uint64_t info_handle;
390} __attribute__((packed));
391
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700392/**
393 * struct cam_flash_init : Init command for the flash
394 * @flash_type : flash hw type
395 * @reserved
396 * @cmd_type : command buffer type
397 */
398struct cam_flash_init {
399 uint8_t flash_type;
400 uint16_t reserved;
401 uint8_t cmd_type;
402} __attribute__((packed));
403
404/**
405 * struct cam_flash_set_rer : RedEyeReduction command buffer
406 *
407 * @count : Number of flash leds
408 * @opcode : Command buffer opcode
409 * CAM_FLASH_FIRE_RER
410 * @cmd_type : command buffer operation type
411 * @num_iteration : Number of led turn on/off sequence
412 * @reserved
413 * @led_on_delay_ms : flash led turn on time in ms
414 * @led_off_delay_ms : flash led turn off time in ms
415 * @led_current_ma : flash led current in ma
416 *
417 */
418struct cam_flash_set_rer {
419 uint16_t count;
420 uint8_t opcode;
421 uint8_t cmd_type;
422 uint16_t num_iteration;
423 uint16_t reserved;
424 uint32_t led_on_delay_ms;
425 uint32_t led_off_delay_ms;
Jigarkumar Zala35226272017-04-19 16:05:24 -0700426 uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700427} __attribute__((packed));
428
429/**
430 * struct cam_flash_set_on_off : led turn on/off command buffer
431 *
432 * @count : Number of Flash leds
433 * @opcode : command buffer opcodes
434 * CAM_FLASH_FIRE_LOW
435 * CAM_FLASH_FIRE_HIGH
436 * CAM_FLASH_OFF
437 * @cmd_type : command buffer operation type
438 * @led_current_ma : flash led current in ma
439 *
440 */
441struct cam_flash_set_on_off {
442 uint16_t count;
443 uint8_t opcode;
444 uint8_t cmd_type;
Jigarkumar Zala35226272017-04-19 16:05:24 -0700445 uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700446} __attribute__((packed));
447
448/**
449 * struct cam_flash_query_curr : query current command buffer
450 *
451 * @reserved
452 * @opcode : command buffer opcode
453 * @cmd_type : command buffer operation type
454 * @query_current_ma : battery current in ma
455 *
456 */
457struct cam_flash_query_curr {
458 uint16_t reserved;
459 uint8_t opcode;
460 uint8_t cmd_type;
461 uint32_t query_current_ma;
462} __attribute__ ((packed));
463
464/**
465 * struct cam_flash_query_cap : capabilities info for flash
466 *
467 * @slot_info : Indicates about the slotId or cell Index
468 * @max_current_flash : max supported current for flash
469 * @max_duration_flash : max flash turn on duration
470 * @max_current_torch : max supported current for torch
471 *
472 */
473struct cam_flash_query_cap_info {
474 uint32_t slot_info;
Jigarkumar Zala35226272017-04-19 16:05:24 -0700475 uint32_t max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS];
476 uint32_t max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
477 uint32_t max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
Jigarkumar Zalaa98014d2017-04-20 15:03:39 -0700478} __attribute__ ((packed));
479
Om Parkash48b8c002018-12-13 20:18:20 +0530480/**
481 * struct cam_ir_led_query_cap : capabilities info for ir_led
482 *
483 * @slot_info : Indicates about the slotId or cell Index
484 *
485 */
486struct cam_ir_led_query_cap_info {
487 uint32_t slot_info;
488} __attribute__ ((packed));
489
490/**
491 * struct cam_ir_ledset_on_off : led turn on/off command buffer
492 *
493 * @opcode : command buffer opcodes
494 * @cmd_type : command buffer operation type
495 * @ir_led_intensity : ir led intensity level
496 *
497 */
498struct cam_ir_led_set_on_off {
499 uint16_t reserved;
500 uint8_t opcode;
501 uint8_t cmd_type;
502 uint32_t ir_led_intensity;
503} __attribute__((packed));
504
Viswanadha Raju Thotakura29a2c772017-02-28 13:11:19 -0800505#endif