summaryrefslogtreecommitdiff
path: root/sm8150/kernel-headers/media/cam_sensor.h
blob: 12483fac3035053a82bf51e81aca18212311db68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#ifndef __UAPI_CAM_SENSOR_H__
#define __UAPI_CAM_SENSOR_H__

#include <linux/types.h>
#include <linux/ioctl.h>
#include <media/cam_defs.h>

#define CAM_SENSOR_PROBE_CMD   (CAM_COMMON_OPCODE_MAX + 1)
#define CAM_FLASH_MAX_LED_TRIGGERS 3
#define MAX_OIS_NAME_SIZE 32
#define MAX_RAINBOW_CONFIG_SIZE 32
#define CAM_CSIPHY_SECURE_MODE_ENABLED 1

enum rainbow_op_type {
	RAINBOW_SEQ_READ,
	RAINBOW_RANDOM_READ,
	RAINBOW_SEQ_WRITE,
	RAINBOW_RANDOM_WRITE
};

enum strobe_type {
	STROBE_ALTERNATIVE,
	STROBE_SYNCHRONIZE,
	STROBE_NONE
};

enum silego_self_test_result_type {
	SILEGO_TEST_FAILED,
	SILEGO_TEST_PASS,
	SILEGO_TEST_BYPASS
};

struct rainbow_config {
	enum rainbow_op_type operation;
	uint32_t             size;
	uint32_t             reg_addr[MAX_RAINBOW_CONFIG_SIZE];
	uint32_t             reg_data[MAX_RAINBOW_CONFIG_SIZE];
} __attribute__((packed));

struct silego_self_test_result {
	enum silego_self_test_result_type result;
	bool is_cracked;
} __attribute__((packed));

#define RAINBOW_CONFIG \
	_IOWR('R', 1, struct rainbow_config)

#define LM36011_SET_CERTIFICATION_STATUS \
	_IOWR('R', 1, bool)

#define LM36011_SILEGO_SELF_TEST \
	_IOWR('R', 1, struct silego_self_test_result)

/**
 * struct cam_sensor_query_cap - capabilities info for sensor
 *
 * @slot_info        :  Indicates about the slotId or cell Index
 * @secure_camera    :  Camera is in secure/Non-secure mode
 * @pos_pitch        :  Sensor position pitch
 * @pos_roll         :  Sensor position roll
 * @pos_yaw          :  Sensor position yaw
 * @actuator_slot_id :  Actuator slot id which connected to sensor
 * @eeprom_slot_id   :  EEPROM slot id which connected to sensor
 * @ois_slot_id      :  OIS slot id which connected to sensor
 * @flash_slot_id    :  Flash slot id which connected to sensor
 * @csiphy_slot_id   :  CSIphy slot id which connected to sensor
 *
 */
struct  cam_sensor_query_cap {
	uint32_t        slot_info;
	uint32_t        secure_camera;
	uint32_t        pos_pitch;
	uint32_t        pos_roll;
	uint32_t        pos_yaw;
	uint32_t        actuator_slot_id;
	uint32_t        eeprom_slot_id;
	uint32_t        ois_slot_id;
	uint32_t        flash_slot_id;
	uint32_t        csiphy_slot_id;
} __attribute__((packed));

/**
 * struct cam_csiphy_query_cap - capabilities info for csiphy
 *
 * @slot_info        :  Indicates about the slotId or cell Index
 * @version          :  CSIphy version
 * @clk lane         :  Of the 5 lanes, informs lane configured
 *                      as clock lane
 * @reserved
 */
struct cam_csiphy_query_cap {
	uint32_t            slot_info;
	uint32_t            version;
	uint32_t            clk_lane;
	uint32_t            reserved;
} __attribute__((packed));

/**
 * struct cam_actuator_query_cap - capabilities info for actuator
 *
 * @slot_info        :  Indicates about the slotId or cell Index
 * @reserved
 */
struct cam_actuator_query_cap {
	uint32_t            slot_info;
	uint32_t            reserved;
} __attribute__((packed));

/**
 * struct cam_eeprom_query_cap_t - capabilities info for eeprom
 *
 * @slot_info                  :  Indicates about the slotId or cell Index
 * @eeprom_kernel_probe        :  Indicates about the kernel or userspace probe
 */
struct cam_eeprom_query_cap_t {
	uint32_t            slot_info;
	uint16_t            eeprom_kernel_probe;
	uint16_t            reserved;
} __attribute__((packed));

/**
 * struct cam_ois_query_cap_t - capabilities info for ois
 *
 * @slot_info                  :  Indicates about the slotId or cell Index
 */
struct cam_ois_query_cap_t {
	uint32_t            slot_info;
	uint16_t            reserved;
} __attribute__((packed));

/**
 * struct cam_cmd_i2c_info - Contains slave I2C related info
 *
 * @slave_addr      :    Slave address
 * @i2c_freq_mode   :    4 bits are used for I2c freq mode
 * @cmd_type        :    Explains type of command
 */
struct cam_cmd_i2c_info {
	uint16_t    slave_addr;
	uint8_t     i2c_freq_mode;
	uint8_t     cmd_type;
} __attribute__((packed));

/**
 * struct cam_cmd_get_ois_data - Contains OIS data read cmd
 *
 * @reg_addr            :    register addr to read data from
 * @reg_data            :    number of bytes to read
 * @query_size_handle   :    handle to user space query_size address
 * @query_data_handle   :    handle to user space query_data address
 */
struct cam_cmd_get_ois_data {
	uint32_t           reg_addr;
	uint32_t           reg_data;
	uint64_t           query_size_handle;
	uint64_t           query_data_handle;
} __attribute__((packed));

/**
 * struct cam_ois_shift - Contains OIS shift data
 *
 * @ois_shift_x         :    shift in x dim
 * @ois_shift_y         :    shift in y dim
 * @af_lop1             :    shift in z dim (0x764)
 * @time_readout        :    time that the shift is read out
 */
struct cam_ois_shift {
	int16_t             ois_shift_x;
	int16_t             ois_shift_y;
	int16_t             af_lop1;
	int64_t             time_readout;
} __attribute__((packed));

/**
 * struct cam_ois_opcode - Contains OIS opcode
 *
 * @prog            :    OIS FW prog register address
 * @coeff           :    OIS FW coeff register address
 * @pheripheral     :    OIS pheripheral
 * @memory          :    OIS memory
 */
struct cam_ois_opcode {
	uint32_t prog;
	uint32_t coeff;
	uint32_t pheripheral;
	uint32_t memory;
} __attribute__((packed));

/**
 * struct cam_cmd_ois_info - Contains OIS slave info
 *
 * @slave_addr            :    OIS i2c slave address
 * @i2c_freq_mode         :    i2c frequency mode
 * @cmd_type              :    Explains type of command
 * @ois_fw_flag           :    indicates if fw is present or not
 * @is_ois_calib          :    indicates the calibration data is available
 * @ois_name              :    OIS name
 * @opcode                :    opcode
 */
struct cam_cmd_ois_info {
	uint16_t              slave_addr;
	uint8_t               i2c_freq_mode;
	uint8_t               cmd_type;
	uint8_t               ois_fw_flag;
	uint8_t               is_ois_calib;
	char                  ois_name[MAX_OIS_NAME_SIZE];
	struct cam_ois_opcode opcode;
} __attribute__((packed));

/**
 * struct cam_cmd_probe - Contains sensor slave info
 *
 * @data_type       :   Slave register data type
 * @addr_type       :   Slave register address type
 * @op_code         :   Don't Care
 * @cmd_type        :   Explains type of command
 * @reg_addr        :   Slave register address
 * @expected_data   :   Data expected at slave register address
 * @data_mask       :   Data mask if only few bits are valid
 * @camera_id       :   Indicates the slot to which camera
 *                      needs to be probed
 * @fw_update_flag  :   Update OIS firmware
 * @reserved
 */
struct cam_cmd_probe {
	uint8_t     data_type;
	uint8_t     addr_type;
	uint8_t     op_code;
	uint8_t     cmd_type;
	uint32_t    reg_addr;
	uint32_t    expected_data;
	uint32_t    data_mask;
	uint16_t    camera_id;
	uint8_t     fw_update_flag;
	uint16_t    reserved;
} __attribute__((packed));

/**
 * struct cam_power_settings - Contains sensor power setting info
 *
 * @power_seq_type  :   Type of power sequence
 * @reserved
 * @config_val_low  :   Lower 32 bit value configuration value
 * @config_val_high :   Higher 32 bit value configuration value
 *
 */
struct cam_power_settings {
	uint16_t    power_seq_type;
	uint16_t    reserved;
	uint32_t    config_val_low;
	uint32_t    config_val_high;
} __attribute__((packed));

/**
 * struct cam_cmd_power - Explains about the power settings
 *
 * @count           :    Number of power settings follows
 * @reserved
 * @cmd_type        :    Explains type of command
 * @power_settings  :    Contains power setting info
 */
struct cam_cmd_power {
	uint16_t                    count;
	uint8_t                     reserved;
	uint8_t                     cmd_type;
	struct cam_power_settings   power_settings[1];
} __attribute__((packed));

/**
 * struct i2c_rdwr_header - header of READ/WRITE I2C command
 *
 * @ count           :   Number of registers / data / reg-data pairs
 * @ op_code         :   Operation code
 * @ cmd_type        :   Command buffer type
 * @ data_type       :   I2C data type
 * @ addr_type       :   I2C address type
 * @ slave_addr      :   Slave address
 */
struct i2c_rdwr_header {
	uint16_t    count;
	uint8_t     op_code;
	uint8_t     cmd_type;
	uint8_t     data_type;
	uint8_t     addr_type;
	uint16_t    slave_addr;
} __attribute__((packed));

/**
 * struct i2c_random_wr_payload - payload for I2C random write
 *
 * @ reg_addr        :   Register address
 * @ reg_data        :   Register data
 *
 */
struct i2c_random_wr_payload {
	uint32_t     reg_addr;
	uint32_t     reg_data;
} __attribute__((packed));

/**
 * struct cam_cmd_i2c_random_wr - I2C random write command
 * @ header            :   header of READ/WRITE I2C command
 * @ random_wr_payload :   payload for I2C random write
 */
struct cam_cmd_i2c_random_wr {
	struct i2c_rdwr_header       header;
	struct i2c_random_wr_payload random_wr_payload[1];
} __attribute__((packed));

/**
 * struct cam_cmd_read - I2C read command
 * @ reg_data        :   Register data
 * @ reserved
 */
struct cam_cmd_read {
	uint32_t                reg_data;
	uint32_t                reserved;
} __attribute__((packed));

/**
 * struct cam_cmd_i2c_continuous_wr - I2C continuous write command
 * @ header          :   header of READ/WRITE I2C command
 * @ reg_addr        :   Register address
 * @ data_read       :   I2C read command
 */
struct cam_cmd_i2c_continuous_wr {
	struct i2c_rdwr_header  header;
	uint32_t                reg_addr;
	struct cam_cmd_read     data_read[1];
} __attribute__((packed));

/**
 * struct cam_cmd_i2c_random_rd - I2C random read command
 * @ header          :   header of READ/WRITE I2C command
 * @ data_read       :   I2C read command
 */
struct cam_cmd_i2c_random_rd {
	struct i2c_rdwr_header  header;
	struct cam_cmd_read     data_read[1];
} __attribute__((packed));

/**
 * struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command
 * @ header          :   header of READ/WRITE I2C command
 * @ reg_addr        :   Register address
 *
 */
struct cam_cmd_i2c_continuous_rd {
	struct i2c_rdwr_header  header;
	uint32_t                reg_addr;
} __attribute__((packed));

/**
 * struct cam_cmd_conditional_wait - Conditional wait command
 * @data_type       :   Data type
 * @addr_type       :   Address type
 * @op_code         :   Opcode
 * @cmd_type        :   Explains type of command
 * @timeout         :   Timeout for retries
 * @reserved
 * @reg_addr        :   Register Address
 * @reg_data        :   Register data
 * @data_mask       :   Data mask if only few bits are valid
 * @camera_id       :   Indicates the slot to which camera
 *                      needs to be probed
 *
 */
struct cam_cmd_conditional_wait {
	uint8_t     data_type;
	uint8_t     addr_type;
	uint8_t     op_code;
	uint8_t     cmd_type;
	uint16_t    timeout;
	uint16_t    reserved;
	uint32_t    reg_addr;
	uint32_t    reg_data;
	uint32_t    data_mask;
} __attribute__((packed));

/**
 * struct cam_cmd_unconditional_wait - Un-conditional wait command
 * @delay           :   Delay
 * @op_code         :   Opcode
 * @cmd_type        :   Explains type of command
 */
struct cam_cmd_unconditional_wait {
	int16_t     delay;
	uint8_t     op_code;
	uint8_t     cmd_type;
} __attribute__((packed));

/**
 * cam_csiphy_info: Provides cmdbuffer structre
 * @lane_mask     : Lane mask details
 * @lane_assign   : Lane sensor will be using
 * @csiphy_3phase : Total number of lanes
 * @combo_mode    : Info regarding combo_mode is enable / disable
 * @lane_cnt      : Total number of lanes
 * @secure_mode   : Secure mode flag to enable / disable
 * @3phase        : Details whether 3Phase / 2Phase operation
 * @settle_time   : Settling time in ms
 * @data_rate     : Data rate
 *
 */
struct cam_csiphy_info {
	uint16_t    lane_mask;
	uint16_t    lane_assign;
	uint8_t     csiphy_3phase;
	uint8_t     combo_mode;
	uint8_t     lane_cnt;
	uint8_t     secure_mode;
	uint64_t    settle_time;
	uint64_t    data_rate;
} __attribute__((packed));

/**
 * cam_csiphy_acquire_dev_info : Information needed for
 *                        csiphy at the time of acquire
 * @combo_mode     :    Indicates the device mode of operation
 * @reserved
 *
 */
struct cam_csiphy_acquire_dev_info {
	uint32_t    combo_mode;
	uint32_t    reserved;
} __attribute__((packed));

/**
 * cam_sensor_acquire_dev : Updates sensor acuire cmd
 * @device_handle  :    Updates device handle
 * @session_handle :    Session handle for acquiring device
 * @handle_type    :    Resource handle type
 * @reserved
 * @info_handle    :    Handle to additional info
 *                      needed for sensor sub modules
 *
 */
struct cam_sensor_acquire_dev {
	uint32_t    session_handle;
	uint32_t    device_handle;
	uint32_t    handle_type;
	uint32_t    reserved;
	uint64_t    info_handle;
} __attribute__((packed));

/**
 * cam_sensor_streamon_dev : StreamOn command for the sensor
 * @session_handle :    Session handle for acquiring device
 * @device_handle  :    Updates device handle
 * @handle_type    :    Resource handle type
 * @reserved
 * @info_handle    :    Information Needed at the time of streamOn
 *
 */
struct cam_sensor_streamon_dev {
	uint32_t    session_handle;
	uint32_t    device_handle;
	uint32_t    handle_type;
	uint32_t    reserved;
	uint64_t    info_handle;
} __attribute__((packed));

/**
 * struct cam_cmd_get_sensor_data - Contains Sensor data read cmd
 *
 * @reg_addr            :    register addr to read data from
 * @reg_data            :    number of bytes to read
 * @query_size_handle   :    handle to user space query_size address
 * @query_data_handle   :    handle to user space query_data address
 */
struct cam_cmd_get_sensor_data {
	uint32_t           reg_addr;
	uint32_t           reg_data;
	uint64_t           query_size_handle;
	uint64_t           query_data_handle;
} __attribute__((packed));

/**
 * struct cam_flash_init : Init command for the flash
 * @flash_type  :    flash hw type
 * @reserved
 * @cmd_type    :    command buffer type
 */
struct cam_flash_init {
	uint8_t     flash_type;
	uint16_t    reserved;
	uint8_t     cmd_type;
} __attribute__((packed));

/**
 * struct cam_flash_set_rer : RedEyeReduction command buffer
 *
 * @count             :   Number of flash leds
 * @opcode            :   Command buffer opcode
 *			CAM_FLASH_FIRE_RER
 * @cmd_type          :   command buffer operation type
 * @num_iteration     :   Number of led turn on/off sequence
 * @reserved
 * @led_on_delay_ms   :   flash led turn on time in ms
 * @led_off_delay_ms  :   flash led turn off time in ms
 * @led_current_ma    :   flash led current in ma
 *
 */
struct cam_flash_set_rer {
	uint16_t    count;
	uint8_t     opcode;
	uint8_t     cmd_type;
	uint16_t    num_iteration;
	uint16_t    reserved;
	uint32_t    led_on_delay_ms;
	uint32_t    led_off_delay_ms;
	uint32_t    led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__((packed));

/**
 * struct cam_flash_set_on_off : led turn on/off command buffer
 *
 * @count              :   Number of Flash leds
 * @opcode             :   command buffer opcodes
 *			CAM_FLASH_FIRE_LOW
 *			CAM_FLASH_FIRE_HIGH
 *			CAM_FLASH_OFF
 * @cmd_type           :   command buffer operation type
 * @led_current_ma     :   flash led current in ma
 *
 */
struct cam_flash_set_on_off {
	uint16_t    count;
	uint8_t     opcode;
	uint8_t     cmd_type;
	uint32_t    led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__((packed));

/**
 * struct cam_flash_query_curr : query current command buffer
 *
 * @reserved
 * @opcode            :   command buffer opcode
 * @cmd_type          :   command buffer operation type
 * @query_current_ma  :   battery current in ma
 *
 */
struct cam_flash_query_curr {
	uint16_t    reserved;
	uint8_t     opcode;
	uint8_t     cmd_type;
	uint32_t    query_current_ma;
} __attribute__ ((packed));

/**
 * struct cam_flash_query_cap  :  capabilities info for flash
 *
 * @slot_info           :  Indicates about the slotId or cell Index
 * @max_current_flash   :  max supported current for flash
 * @max_duration_flash  :  max flash turn on duration
 * @max_current_torch   :  max supported current for torch
 *
 */
struct cam_flash_query_cap_info {
	uint32_t    slot_info;
	uint32_t    max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS];
	uint32_t    max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
	uint32_t    max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__ ((packed));

#endif