blob: 6ebd58bd8a3aba8b7c1304006f5a6da809d955c0 [file] [log] [blame]
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -07001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
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 and
5 * only version 2 as 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
13#ifndef _CAM_SENSOR_CMN_HEADER_
14#define _CAM_SENSOR_CMN_HEADER_
15
16#include <linux/i2c.h>
17#include <linux/types.h>
18#include <linux/kernel.h>
19#include <linux/slab.h>
20#include <linux/timer.h>
21#include <linux/delay.h>
22#include <linux/list.h>
23#include <media/cam_sensor.h>
24#include <media/cam_req_mgr.h>
25
26#define MAX_REGULATOR 5
27#define MAX_POWER_CONFIG 12
28
29#define MAX_PER_FRAME_ARRAY 8
30
31#define CAM_SENSOR_NAME "cam-sensor"
32#define CAM_ACTUATOR_NAME "cam-actuator"
33#define CAM_CSIPHY_NAME "cam-csiphy"
Jigarkumar Zala35226272017-04-19 16:05:24 -070034#define CAM_FLASH_NAME "cam-flash"
Vivek Veenam2ad8de12017-04-04 18:56:22 +053035#define CAM_EEPROM_NAME "cam-eeprom"
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -070036
37#define MAX_SYSTEM_PIPELINE_DELAY 2
38
39#define CAM_PKT_NOP_OPCODE 127
40
41enum camera_sensor_cmd_type {
42 CAMERA_SENSOR_CMD_TYPE_INVALID,
43 CAMERA_SENSOR_CMD_TYPE_PROBE,
44 CAMERA_SENSOR_CMD_TYPE_PWR_UP,
45 CAMERA_SENSOR_CMD_TYPE_PWR_DOWN,
46 CAMERA_SENSOR_CMD_TYPE_I2C_INFO,
47 CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR,
48 CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_RD,
49 CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR,
50 CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD,
51 CAMERA_SENSOR_CMD_TYPE_WAIT,
Jigarkumar Zala35226272017-04-19 16:05:24 -070052 CAMERA_SENSOR_FLASH_CMD_TYPE_INIT,
53 CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE,
54 CAMERA_SENSOR_FLASH_CMD_TYPE_RER,
55 CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR,
56 CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET,
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -070057 CAMERA_SENSOR_CMD_TYPE_MAX,
58};
59
60enum camera_sensor_i2c_op_code {
61 CAMERA_SENSOR_I2C_OP_INVALID,
62 CAMERA_SENSOR_I2C_OP_RNDM_WR,
63 CAMERA_SENSOR_I2C_OP_RNDM_WR_VERF,
64 CAMERA_SENSOR_I2C_OP_CONT_WR_BRST,
65 CAMERA_SENSOR_I2C_OP_CONT_WR_BRST_VERF,
66 CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN,
67 CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN_VERF,
68 CAMERA_SENSOR_I2C_OP_MAX,
69};
70
71enum camera_sensor_wait_op_code {
72 CAMERA_SENSOR_WAIT_OP_INVALID,
73 CAMERA_SENSOR_WAIT_OP_COND,
74 CAMERA_SENSOR_WAIT_OP_HW_UCND,
75 CAMERA_SENSOR_WAIT_OP_SW_UCND,
76 CAMERA_SENSOR_WAIT_OP_MAX,
77};
78
Jigarkumar Zala35226272017-04-19 16:05:24 -070079enum camera_flash_opcode {
80 CAMERA_SENSOR_FLASH_OP_INVALID,
81 CAMERA_SENSOR_FLASH_OP_OFF,
82 CAMERA_SENSOR_FLASH_OP_FIRELOW,
83 CAMERA_SENSOR_FLASH_OP_FIREHIGH,
84 CAMERA_SENSOR_FLASH_OP_MAX,
85};
86
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -070087enum camera_sensor_i2c_type {
88 CAMERA_SENSOR_I2C_TYPE_INVALID,
89 CAMERA_SENSOR_I2C_TYPE_BYTE,
90 CAMERA_SENSOR_I2C_TYPE_WORD,
91 CAMERA_SENSOR_I2C_TYPE_3B,
92 CAMERA_SENSOR_I2C_TYPE_DWORD,
93 CAMERA_SENSOR_I2C_TYPE_MAX,
94};
95
96enum i2c_freq_mode {
97 I2C_STANDARD_MODE,
98 I2C_FAST_MODE,
99 I2C_CUSTOM_MODE,
100 I2C_FAST_PLUS_MODE,
101 I2C_MAX_MODES,
102};
103
104enum position_roll {
105 ROLL_0 = 0,
106 ROLL_90 = 90,
107 ROLL_180 = 180,
108 ROLL_270 = 270,
109 ROLL_INVALID = 360,
110};
111
112enum position_yaw {
113 FRONT_CAMERA_YAW = 0,
114 REAR_CAMERA_YAW = 180,
115 INVALID_YAW = 360,
116};
117
118enum position_pitch {
119 LEVEL_PITCH = 0,
120 INVALID_PITCH = 360,
121};
122
123enum sensor_sub_module {
124 SUB_MODULE_SENSOR,
125 SUB_MODULE_ACTUATOR,
126 SUB_MODULE_EEPROM,
127 SUB_MODULE_LED_FLASH,
128 SUB_MODULE_CSID,
129 SUB_MODULE_CSIPHY,
130 SUB_MODULE_OIS,
131 SUB_MODULE_EXT,
132 SUB_MODULE_MAX,
133};
134
135enum msm_camera_power_seq_type {
136 SENSOR_MCLK,
137 SENSOR_VANA,
138 SENSOR_VDIG,
139 SENSOR_VIO,
140 SENSOR_VAF,
141 SENSOR_VAF_PWDM,
142 SENSOR_CUSTOM_REG1,
143 SENSOR_CUSTOM_REG2,
144 SENSOR_RESET,
145 SENSOR_STANDBY,
146 SENSOR_CUSTOM_GPIO1,
147 SENSOR_CUSTOM_GPIO2,
148 SENSOR_SEQ_TYPE_MAX,
149};
150
151enum cam_sensor_packet_opcodes {
152 CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON,
153 CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE,
154 CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG,
155 CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE
156};
157
158enum cam_actuator_packet_opcodes {
159 CAM_ACTUATOR_PACKET_OPCODE_INIT,
160 CAM_ACTUATOR_PACKET_AUTO_MOVE_LENS,
161 CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS
162};
163
Vivek Veenam2ad8de12017-04-04 18:56:22 +0530164enum cam_eeprom_packet_opcodes {
165 CAM_EEPROM_PACKET_OPCODE_INIT
166};
167
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700168enum msm_bus_perf_setting {
169 S_INIT,
170 S_PREVIEW,
171 S_VIDEO,
172 S_CAPTURE,
173 S_ZSL,
174 S_STEREO_VIDEO,
175 S_STEREO_CAPTURE,
176 S_DEFAULT,
177 S_LIVESHOT,
178 S_DUAL,
179 S_EXIT
180};
181
182enum msm_camera_device_type_t {
183 MSM_CAMERA_I2C_DEVICE,
184 MSM_CAMERA_PLATFORM_DEVICE,
185 MSM_CAMERA_SPI_DEVICE,
186};
187
Jigarkumar Zala35226272017-04-19 16:05:24 -0700188enum cam_flash_device_type {
189 CAMERA_FLASH_DEVICE_TYPE_PMIC = 0,
190 CAMERA_FLASH_DEVICE_TYPE_I2C,
191 CAMERA_FLASH_DEVICE_TYPE_GPIO,
192};
193
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700194enum cci_i2c_master_t {
195 MASTER_0,
196 MASTER_1,
197 MASTER_MAX,
198};
199
200enum camera_vreg_type {
201 VREG_TYPE_DEFAULT,
202 VREG_TYPE_CUSTOM,
203};
204
205enum cam_sensor_i2c_cmd_type {
206 CAM_SENSOR_I2C_WRITE_RANDOM,
Karthik Anantha Ram0fb02a32017-08-23 11:52:50 -0700207 CAM_SENSOR_I2C_WRITE_BURST,
208 CAM_SENSOR_I2C_WRITE_SEQ,
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700209 CAM_SENSOR_I2C_READ,
210 CAM_SENSOR_I2C_POLL
211};
212
213struct common_header {
214 uint16_t first_word;
215 uint8_t third_byte;
216 uint8_t cmd_type;
217};
218
219struct camera_vreg_t {
220 const char *reg_name;
221 int min_voltage;
222 int max_voltage;
223 int op_mode;
224 uint32_t delay;
225 const char *custom_vreg_name;
226 enum camera_vreg_type type;
227};
228
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700229struct msm_camera_gpio_num_info {
230 uint16_t gpio_num[SENSOR_SEQ_TYPE_MAX];
231 uint8_t valid[SENSOR_SEQ_TYPE_MAX];
232};
233
234struct msm_cam_clk_info {
235 const char *clk_name;
236 long clk_rate;
237 uint32_t delay;
238};
239
240struct msm_pinctrl_info {
241 struct pinctrl *pinctrl;
242 struct pinctrl_state *gpio_state_active;
243 struct pinctrl_state *gpio_state_suspend;
244 bool use_pinctrl;
245};
246
247struct cam_sensor_i2c_reg_array {
248 uint32_t reg_addr;
249 uint32_t reg_data;
250 uint32_t delay;
251 uint32_t data_mask;
252};
253
254struct cam_sensor_i2c_reg_setting {
255 struct cam_sensor_i2c_reg_array *reg_setting;
256 unsigned short size;
257 enum camera_sensor_i2c_type addr_type;
258 enum camera_sensor_i2c_type data_type;
259 unsigned short delay;
260};
261
262struct i2c_settings_list {
263 struct cam_sensor_i2c_reg_setting i2c_settings;
264 enum cam_sensor_i2c_cmd_type op_code;
265 struct list_head list;
266};
267
268struct i2c_settings_array {
269 struct list_head list_head;
270 int32_t is_settings_valid;
271 int64_t request_id;
272};
273
274struct i2c_data_settings {
275 struct i2c_settings_array init_settings;
276 struct i2c_settings_array *per_frame;
277};
278
279struct cam_sensor_power_ctrl_t {
280 struct device *dev;
281 struct cam_sensor_power_setting *power_setting;
282 uint16_t power_setting_size;
283 struct cam_sensor_power_setting *power_down_setting;
284 uint16_t power_down_setting_size;
Alok Pandey01b1b352017-06-25 20:38:54 +0530285 struct msm_camera_gpio_num_info *gpio_num_info;
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700286 struct msm_pinctrl_info pinctrl_info;
287 uint8_t cam_pinctrl_status;
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700288};
289
290struct cam_camera_slave_info {
291 uint16_t sensor_slave_addr;
292 uint16_t sensor_id_reg_addr;
293 uint16_t sensor_id;
294 uint16_t sensor_id_mask;
295};
296
297struct msm_sensor_init_params {
298 int modes_supported;
299 unsigned int sensor_mount_angle;
300};
301
302enum msm_sensor_camera_id_t {
303 CAMERA_0,
304 CAMERA_1,
305 CAMERA_2,
306 CAMERA_3,
307 MAX_CAMERAS,
308};
309
310struct msm_sensor_id_info_t {
311 unsigned short sensor_id_reg_addr;
312 unsigned short sensor_id;
313 unsigned short sensor_id_mask;
314};
315
316enum msm_sensor_output_format_t {
317 MSM_SENSOR_BAYER,
318 MSM_SENSOR_YCBCR,
319 MSM_SENSOR_META,
320};
321
322struct cam_sensor_power_setting {
323 enum msm_camera_power_seq_type seq_type;
324 unsigned short seq_val;
325 long config_val;
326 unsigned short delay;
327 void *data[10];
328};
329
Viswanadha Raju Thotakura426ec662017-03-15 17:00:29 -0700330struct cam_sensor_board_info {
331 struct cam_camera_slave_info slave_info;
332 int32_t sensor_mount_angle;
333 int32_t secure_mode;
334 int modes_supported;
335 int32_t pos_roll;
336 int32_t pos_yaw;
337 int32_t pos_pitch;
338 int32_t subdev_id[SUB_MODULE_MAX];
339 int32_t subdev_intf[SUB_MODULE_MAX];
340 const char *misc_regulator;
341 struct cam_sensor_power_ctrl_t power_info;
342};
343
344enum msm_camera_vreg_name_t {
345 CAM_VDIG,
346 CAM_VIO,
347 CAM_VANA,
348 CAM_VAF,
349 CAM_V_CUSTOM1,
350 CAM_V_CUSTOM2,
351 CAM_VREG_MAX,
352};
353
354struct msm_camera_gpio_conf {
355 void *cam_gpiomux_conf_tbl;
356 uint8_t cam_gpiomux_conf_tbl_size;
357 struct gpio *cam_gpio_common_tbl;
358 uint8_t cam_gpio_common_tbl_size;
359 struct gpio *cam_gpio_req_tbl;
360 uint8_t cam_gpio_req_tbl_size;
361 uint32_t gpio_no_mux;
362 uint32_t *camera_off_table;
363 uint8_t camera_off_table_size;
364 uint32_t *camera_on_table;
365 uint8_t camera_on_table_size;
366 struct msm_camera_gpio_num_info *gpio_num_info;
367};
368
369#endif /* _CAM_SENSOR_CMN_HEADER_ */