Sreesudhan Ramakrish Ramkumar | 7f723dc | 2012-10-12 22:58:13 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
| 14 | #ifndef __ASM__ARCH_CAMERA_H |
| 15 | #define __ASM__ARCH_CAMERA_H |
| 16 | |
| 17 | #include <linux/list.h> |
| 18 | #include <linux/poll.h> |
| 19 | #include <linux/cdev.h> |
| 20 | #include <linux/platform_device.h> |
Stephen Boyd | 2fcabf9 | 2012-05-30 10:41:11 -0700 | [diff] [blame] | 21 | #include <linux/pm_qos.h> |
Kevin Chan | eb6b607 | 2012-01-17 11:54:54 -0800 | [diff] [blame] | 22 | #include <linux/regulator/consumer.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | #include "linux/types.h" |
| 24 | |
| 25 | #include <mach/board.h> |
| 26 | #include <media/msm_camera.h> |
Mitchel Humpherys | 252fa6a | 2012-09-06 10:28:47 -0700 | [diff] [blame] | 27 | #include <linux/msm_ion.h> |
Laura Abbott | 5b1e6f1 | 2012-05-28 08:13:55 -0700 | [diff] [blame] | 28 | #include <mach/iommu_domains.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | |
| 30 | #define CONFIG_MSM_CAMERA_DEBUG |
| 31 | #ifdef CONFIG_MSM_CAMERA_DEBUG |
| 32 | #define CDBG(fmt, args...) pr_debug(fmt, ##args) |
| 33 | #else |
| 34 | #define CDBG(fmt, args...) do { } while (0) |
| 35 | #endif |
| 36 | |
| 37 | #define PAD_TO_2K(a, b) ((!b) ? a : (((a)+2047) & ~2047)) |
| 38 | |
| 39 | #define MSM_CAMERA_MSG 0 |
| 40 | #define MSM_CAMERA_EVT 1 |
| 41 | #define NUM_WB_EXP_NEUTRAL_REGION_LINES 4 |
| 42 | #define NUM_WB_EXP_STAT_OUTPUT_BUFFERS 3 |
| 43 | #define NUM_AUTOFOCUS_MULTI_WINDOW_GRIDS 16 |
| 44 | #define NUM_STAT_OUTPUT_BUFFERS 3 |
| 45 | #define NUM_AF_STAT_OUTPUT_BUFFERS 3 |
Mingcheng Zhu | 996be18 | 2011-10-16 16:04:23 -0700 | [diff] [blame] | 46 | #define max_control_command_size 512 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 47 | #define CROP_LEN 36 |
| 48 | |
| 49 | enum vfe_mode_of_operation{ |
| 50 | VFE_MODE_OF_OPERATION_CONTINUOUS, |
| 51 | VFE_MODE_OF_OPERATION_SNAPSHOT, |
| 52 | VFE_MODE_OF_OPERATION_VIDEO, |
| 53 | VFE_MODE_OF_OPERATION_RAW_SNAPSHOT, |
| 54 | VFE_MODE_OF_OPERATION_ZSL, |
Jignesh Mehta | 6cf8a74 | 2012-02-04 23:40:50 -0800 | [diff] [blame] | 55 | VFE_MODE_OF_OPERATION_JPEG_SNAPSHOT, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 56 | VFE_LAST_MODE_OF_OPERATION_ENUM |
| 57 | }; |
| 58 | |
| 59 | enum msm_queue { |
| 60 | MSM_CAM_Q_CTRL, /* control command or control command status */ |
| 61 | MSM_CAM_Q_VFE_EVT, /* adsp event */ |
| 62 | MSM_CAM_Q_VFE_MSG, /* adsp message */ |
| 63 | MSM_CAM_Q_V4L2_REQ, /* v4l2 request */ |
| 64 | MSM_CAM_Q_VPE_MSG, /* vpe message */ |
| 65 | MSM_CAM_Q_PP_MSG, /* pp message */ |
| 66 | }; |
| 67 | |
| 68 | enum vfe_resp_msg { |
| 69 | VFE_EVENT, |
| 70 | VFE_MSG_GENERAL, |
| 71 | VFE_MSG_SNAPSHOT, |
| 72 | VFE_MSG_OUTPUT_P, /* preview (continuous mode ) */ |
| 73 | VFE_MSG_OUTPUT_T, /* thumbnail (snapshot mode )*/ |
| 74 | VFE_MSG_OUTPUT_S, /* main image (snapshot mode )*/ |
| 75 | VFE_MSG_OUTPUT_V, /* video (continuous mode ) */ |
| 76 | VFE_MSG_STATS_AEC, |
| 77 | VFE_MSG_STATS_AF, |
| 78 | VFE_MSG_STATS_AWB, |
Kiran Kumar H N | dd12847 | 2011-12-01 09:35:34 -0800 | [diff] [blame] | 79 | VFE_MSG_STATS_RS, /* 10 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 80 | VFE_MSG_STATS_CS, |
| 81 | VFE_MSG_STATS_IHIST, |
| 82 | VFE_MSG_STATS_SKIN, |
| 83 | VFE_MSG_STATS_WE, /* AEC + AWB */ |
| 84 | VFE_MSG_SYNC_TIMER0, |
| 85 | VFE_MSG_SYNC_TIMER1, |
| 86 | VFE_MSG_SYNC_TIMER2, |
| 87 | VFE_MSG_COMMON, |
Kevin Chan | 6267cb6 | 2012-06-18 23:34:24 -0700 | [diff] [blame] | 88 | VFE_MSG_START, |
| 89 | VFE_MSG_START_RECORDING, /* 20 */ |
| 90 | VFE_MSG_CAPTURE, |
| 91 | VFE_MSG_JPEG_CAPTURE, |
Kiran Kumar H N | 0fb9dcf | 2011-07-17 12:31:53 -0700 | [diff] [blame] | 92 | VFE_MSG_OUTPUT_IRQ, |
Kevin Chan | 6267cb6 | 2012-06-18 23:34:24 -0700 | [diff] [blame] | 93 | VFE_MSG_PREVIEW, |
Kiran Kumar H N | dd12847 | 2011-12-01 09:35:34 -0800 | [diff] [blame] | 94 | VFE_MSG_OUTPUT_PRIMARY, |
| 95 | VFE_MSG_OUTPUT_SECONDARY, |
Nishant Pandit | 28feb3d | 2012-04-26 23:56:22 +0530 | [diff] [blame] | 96 | VFE_MSG_OUTPUT_TERTIARY1, |
Nishant Pandit | 5dd5442 | 2012-06-26 22:52:44 +0530 | [diff] [blame] | 97 | VFE_MSG_OUTPUT_TERTIARY2, |
Aditya Jonnalagadda | 7ea9650 | 2012-09-12 12:45:18 +0530 | [diff] [blame] | 98 | VFE_MSG_V2X_LIVESHOT_PRIMARY, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | enum vpe_resp_msg { |
| 102 | VPE_MSG_GENERAL, |
| 103 | VPE_MSG_OUTPUT_V, /* video (continuous mode ) */ |
| 104 | VPE_MSG_OUTPUT_ST_L, |
| 105 | VPE_MSG_OUTPUT_ST_R, |
| 106 | }; |
| 107 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 108 | enum msm_stereo_state { |
| 109 | STEREO_VIDEO_IDLE, |
| 110 | STEREO_VIDEO_ACTIVE, |
| 111 | STEREO_SNAP_IDLE, |
| 112 | STEREO_SNAP_STARTED, |
| 113 | STEREO_SNAP_BUFFER1_PROCESSING, |
| 114 | STEREO_SNAP_BUFFER2_PROCESSING, |
| 115 | STEREO_RAW_SNAP_IDLE, |
| 116 | STEREO_RAW_SNAP_STARTED, |
| 117 | }; |
| 118 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 119 | struct msm_vpe_phy_info { |
| 120 | uint32_t sbuf_phy; |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 121 | uint32_t planar0_off; |
| 122 | uint32_t planar1_off; |
| 123 | uint32_t planar2_off; |
| 124 | uint32_t p0_phy; |
| 125 | uint32_t p1_phy; |
| 126 | uint32_t p2_phy; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 127 | uint8_t output_id; /* VFE31_OUTPUT_MODE_PT/S/V */ |
| 128 | uint32_t frame_id; |
| 129 | }; |
| 130 | |
Kevin Chan | 3be1161 | 2012-03-22 20:05:40 -0700 | [diff] [blame] | 131 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 132 | #define VFE31_OUTPUT_MODE_PT (0x1 << 0) |
| 133 | #define VFE31_OUTPUT_MODE_S (0x1 << 1) |
| 134 | #define VFE31_OUTPUT_MODE_V (0x1 << 2) |
| 135 | #define VFE31_OUTPUT_MODE_P (0x1 << 3) |
| 136 | #define VFE31_OUTPUT_MODE_T (0x1 << 4) |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 137 | #define VFE31_OUTPUT_MODE_P_ALL_CHNLS (0x1 << 5) |
Kevin Chan | 3be1161 | 2012-03-22 20:05:40 -0700 | [diff] [blame] | 138 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 139 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 140 | struct msm_vfe_phy_info { |
| 141 | uint32_t sbuf_phy; |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 142 | uint32_t planar0_off; |
| 143 | uint32_t planar1_off; |
| 144 | uint32_t planar2_off; |
| 145 | uint32_t p0_phy; |
| 146 | uint32_t p1_phy; |
| 147 | uint32_t p2_phy; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 148 | uint8_t output_id; /* VFE31_OUTPUT_MODE_PT/S/V */ |
| 149 | uint32_t frame_id; |
| 150 | }; |
| 151 | |
| 152 | struct msm_vfe_stats_msg { |
Lakshmi Narayana Kalavala | 4ab97a9 | 2011-07-26 15:30:14 -0700 | [diff] [blame] | 153 | uint8_t awb_ymin; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 154 | uint32_t aec_buff; |
| 155 | uint32_t awb_buff; |
| 156 | uint32_t af_buff; |
| 157 | uint32_t ihist_buff; |
| 158 | uint32_t rs_buff; |
| 159 | uint32_t cs_buff; |
| 160 | uint32_t skin_buff; |
| 161 | uint32_t status_bits; |
| 162 | uint32_t frame_id; |
| 163 | }; |
| 164 | |
| 165 | struct video_crop_t{ |
| 166 | uint32_t in1_w; |
| 167 | uint32_t out1_w; |
| 168 | uint32_t in1_h; |
| 169 | uint32_t out1_h; |
| 170 | uint32_t in2_w; |
| 171 | uint32_t out2_w; |
| 172 | uint32_t in2_h; |
| 173 | uint32_t out2_h; |
| 174 | uint8_t update_flag; |
| 175 | }; |
| 176 | |
| 177 | struct msm_vpe_buf_info { |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 178 | uint32_t p0_phy; |
| 179 | uint32_t p1_phy; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 180 | struct timespec ts; |
| 181 | uint32_t frame_id; |
| 182 | struct video_crop_t vpe_crop; |
| 183 | }; |
| 184 | |
| 185 | struct msm_vfe_resp { |
| 186 | enum vfe_resp_msg type; |
| 187 | struct msm_cam_evt_msg evt_msg; |
| 188 | struct msm_vfe_phy_info phy; |
| 189 | struct msm_vfe_stats_msg stats_msg; |
| 190 | struct msm_vpe_buf_info vpe_bf; |
| 191 | void *extdata; |
| 192 | int32_t extlen; |
| 193 | }; |
| 194 | |
| 195 | struct msm_vpe_resp { |
| 196 | enum vpe_resp_msg type; |
| 197 | struct msm_cam_evt_msg evt_msg; |
| 198 | struct msm_vpe_phy_info phy; |
| 199 | void *extdata; |
| 200 | int32_t extlen; |
| 201 | }; |
| 202 | |
| 203 | struct msm_vpe_callback { |
| 204 | void (*vpe_resp)(struct msm_vpe_resp *, |
| 205 | enum msm_queue, void *syncdata, |
| 206 | void *time_stamp, gfp_t gfp); |
| 207 | void* (*vpe_alloc)(int, void *syncdata, gfp_t gfp); |
| 208 | void (*vpe_free)(void *ptr); |
| 209 | }; |
| 210 | |
| 211 | struct msm_vfe_callback { |
| 212 | void (*vfe_resp)(struct msm_vfe_resp *, |
| 213 | enum msm_queue, void *syncdata, |
| 214 | gfp_t gfp); |
| 215 | void* (*vfe_alloc)(int, void *syncdata, gfp_t gfp); |
| 216 | void (*vfe_free)(void *ptr); |
| 217 | }; |
| 218 | |
| 219 | struct msm_camvfe_fn { |
| 220 | int (*vfe_init)(struct msm_vfe_callback *, |
| 221 | struct platform_device *); |
| 222 | int (*vfe_enable)(struct camera_enable_cmd *); |
| 223 | int (*vfe_config)(struct msm_vfe_cfg_cmd *, void *); |
| 224 | int (*vfe_disable)(struct camera_enable_cmd *, |
| 225 | struct platform_device *dev); |
| 226 | void (*vfe_release)(struct platform_device *); |
| 227 | void (*vfe_stop)(void); |
| 228 | }; |
| 229 | |
| 230 | struct msm_camvfe_params { |
| 231 | struct msm_vfe_cfg_cmd *vfe_cfg; |
| 232 | void *data; |
| 233 | }; |
| 234 | |
Mingcheng Zhu | 8e9f99e | 2011-08-26 16:33:32 -0700 | [diff] [blame] | 235 | struct msm_mctl_pp_params { |
| 236 | struct msm_mctl_pp_cmd *cmd; |
| 237 | void *data; |
| 238 | }; |
| 239 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 240 | struct msm_camvpe_fn { |
| 241 | int (*vpe_reg)(struct msm_vpe_callback *); |
| 242 | int (*vpe_cfg_update) (void *); |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 243 | void (*send_frame_to_vpe) (uint32_t planar0_off, uint32_t planar1_off, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 244 | struct timespec *ts, int output_id); |
| 245 | int (*vpe_config)(struct msm_vpe_cfg_cmd *, void *); |
| 246 | void (*vpe_cfg_offset)(int frame_pack, uint32_t pyaddr, |
| 247 | uint32_t pcbcraddr, struct timespec *ts, int output_id, |
| 248 | struct msm_st_half st_half, int frameid); |
| 249 | int *dis; |
| 250 | }; |
| 251 | |
| 252 | struct msm_sensor_ctrl { |
| 253 | int (*s_init)(const struct msm_camera_sensor_info *); |
| 254 | int (*s_release)(void); |
| 255 | int (*s_config)(void __user *); |
| 256 | enum msm_camera_type s_camera_type; |
| 257 | uint32_t s_mount_angle; |
| 258 | enum msm_st_frame_packing s_video_packing; |
| 259 | enum msm_st_frame_packing s_snap_packing; |
| 260 | }; |
Sreesudhan Ramakrish Ramkumar | a4b5f30 | 2011-09-12 16:23:22 -0700 | [diff] [blame] | 261 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 262 | struct msm_strobe_flash_ctrl { |
| 263 | int (*strobe_flash_init) |
| 264 | (struct msm_camera_sensor_strobe_flash_data *); |
| 265 | int (*strobe_flash_release) |
| 266 | (struct msm_camera_sensor_strobe_flash_data *, int32_t); |
| 267 | int (*strobe_flash_charge)(int32_t, int32_t, uint32_t); |
| 268 | }; |
| 269 | |
Sreesudhan Ramakrish Ramkumar | c842b61 | 2012-05-21 17:23:24 -0700 | [diff] [blame] | 270 | enum cci_i2c_master_t { |
| 271 | MASTER_0, |
| 272 | MASTER_1, |
| 273 | }; |
| 274 | |
| 275 | enum cci_i2c_queue_t { |
| 276 | QUEUE_0, |
| 277 | QUEUE_1, |
| 278 | }; |
| 279 | |
| 280 | struct msm_camera_cci_client { |
| 281 | struct v4l2_subdev *cci_subdev; |
| 282 | uint32_t freq; |
| 283 | enum cci_i2c_master_t cci_i2c_master; |
| 284 | uint16_t sid; |
| 285 | uint16_t cid; |
| 286 | uint32_t timeout; |
| 287 | uint16_t retries; |
| 288 | uint16_t id_map; |
| 289 | }; |
| 290 | |
| 291 | enum msm_cci_cmd_type { |
| 292 | MSM_CCI_INIT, |
| 293 | MSM_CCI_RELEASE, |
| 294 | MSM_CCI_SET_SID, |
| 295 | MSM_CCI_SET_FREQ, |
| 296 | MSM_CCI_SET_SYNC_CID, |
| 297 | MSM_CCI_I2C_READ, |
| 298 | MSM_CCI_I2C_WRITE, |
| 299 | MSM_CCI_GPIO_WRITE, |
| 300 | }; |
| 301 | |
| 302 | struct msm_camera_cci_wait_sync_cfg { |
| 303 | uint16_t line; |
| 304 | uint16_t delay; |
| 305 | }; |
| 306 | |
| 307 | struct msm_camera_cci_gpio_cfg { |
| 308 | uint16_t gpio_queue; |
| 309 | uint16_t i2c_queue; |
| 310 | }; |
| 311 | |
Kevin Chan | bdcf7ef | 2012-08-24 08:33:33 -0700 | [diff] [blame] | 312 | enum msm_camera_i2c_cmd_type { |
| 313 | MSM_CAMERA_I2C_CMD_WRITE, |
| 314 | MSM_CAMERA_I2C_CMD_POLL, |
| 315 | }; |
| 316 | |
| 317 | struct msm_camera_i2c_reg_conf { |
| 318 | uint16_t reg_addr; |
| 319 | uint16_t reg_data; |
| 320 | enum msm_camera_i2c_data_type dt; |
| 321 | enum msm_camera_i2c_cmd_type cmd_type; |
| 322 | int16_t mask; |
| 323 | }; |
| 324 | |
Sreesudhan Ramakrish Ramkumar | c842b61 | 2012-05-21 17:23:24 -0700 | [diff] [blame] | 325 | struct msm_camera_cci_i2c_write_cfg { |
| 326 | struct msm_camera_i2c_reg_conf *reg_conf_tbl; |
| 327 | enum msm_camera_i2c_reg_addr_type addr_type; |
| 328 | enum msm_camera_i2c_data_type data_type; |
| 329 | uint16_t size; |
| 330 | }; |
| 331 | |
| 332 | struct msm_camera_cci_i2c_read_cfg { |
| 333 | uint16_t addr; |
| 334 | enum msm_camera_i2c_reg_addr_type addr_type; |
| 335 | uint8_t *data; |
| 336 | uint16_t num_byte; |
| 337 | }; |
| 338 | |
| 339 | struct msm_camera_cci_i2c_queue_info { |
| 340 | uint32_t max_queue_size; |
| 341 | uint32_t report_id; |
| 342 | uint32_t irq_en; |
| 343 | uint32_t capture_rep_data; |
| 344 | }; |
| 345 | |
| 346 | struct msm_camera_cci_ctrl { |
| 347 | int32_t status; |
| 348 | struct msm_camera_cci_client *cci_info; |
| 349 | enum msm_cci_cmd_type cmd; |
| 350 | union { |
| 351 | struct msm_camera_cci_i2c_write_cfg cci_i2c_write_cfg; |
| 352 | struct msm_camera_cci_i2c_read_cfg cci_i2c_read_cfg; |
| 353 | struct msm_camera_cci_wait_sync_cfg cci_wait_sync_cfg; |
| 354 | struct msm_camera_cci_gpio_cfg gpio_cfg; |
| 355 | } cfg; |
| 356 | }; |
| 357 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 358 | /* this structure is used in kernel */ |
| 359 | struct msm_queue_cmd { |
| 360 | struct list_head list_config; |
| 361 | struct list_head list_control; |
| 362 | struct list_head list_frame; |
| 363 | struct list_head list_pict; |
| 364 | struct list_head list_vpe_frame; |
Kevin Chan | 94b4c83 | 2012-03-02 21:27:16 -0800 | [diff] [blame] | 365 | struct list_head list_eventdata; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 366 | enum msm_queue type; |
| 367 | void *command; |
| 368 | atomic_t on_heap; |
| 369 | struct timespec ts; |
| 370 | uint32_t error_code; |
Ankit Premrajka | 8c9bf5d | 2012-08-07 15:45:31 -0700 | [diff] [blame] | 371 | uint32_t trans_code; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 372 | }; |
| 373 | |
| 374 | struct msm_device_queue { |
| 375 | struct list_head list; |
| 376 | spinlock_t lock; |
| 377 | wait_queue_head_t wait; |
| 378 | int max; |
| 379 | int len; |
| 380 | const char *name; |
| 381 | }; |
| 382 | |
Kevin Chan | 047053e | 2012-04-19 11:30:33 -0700 | [diff] [blame] | 383 | struct msm_mctl_stats_t { |
| 384 | struct hlist_head pmem_stats_list; |
| 385 | spinlock_t pmem_stats_spinlock; |
| 386 | }; |
| 387 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 388 | struct msm_sync { |
| 389 | /* These two queues are accessed from a process context only |
| 390 | * They contain pmem descriptors for the preview frames and the stats |
| 391 | * coming from the camera sensor. |
| 392 | */ |
| 393 | struct hlist_head pmem_frames; |
| 394 | struct hlist_head pmem_stats; |
| 395 | |
| 396 | /* The message queue is used by the control thread to send commands |
| 397 | * to the config thread, and also by the DSP to send messages to the |
| 398 | * config thread. Thus it is the only queue that is accessed from |
| 399 | * both interrupt and process context. |
| 400 | */ |
| 401 | struct msm_device_queue event_q; |
| 402 | |
| 403 | /* This queue contains preview frames. It is accessed by the DSP (in |
| 404 | * in interrupt context, and by the frame thread. |
| 405 | */ |
| 406 | struct msm_device_queue frame_q; |
| 407 | int unblock_poll_frame; |
| 408 | int unblock_poll_pic_frame; |
| 409 | |
| 410 | /* This queue contains snapshot frames. It is accessed by the DSP (in |
| 411 | * interrupt context, and by the control thread. |
| 412 | */ |
| 413 | struct msm_device_queue pict_q; |
| 414 | int get_pic_abort; |
| 415 | struct msm_device_queue vpe_q; |
| 416 | |
| 417 | struct msm_camera_sensor_info *sdata; |
| 418 | struct msm_camvfe_fn vfefn; |
| 419 | struct msm_camvpe_fn vpefn; |
| 420 | struct msm_sensor_ctrl sctrl; |
| 421 | struct msm_strobe_flash_ctrl sfctrl; |
Stephen Boyd | 2fcabf9 | 2012-05-30 10:41:11 -0700 | [diff] [blame] | 422 | struct pm_qos_request idle_pm_qos; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 423 | struct platform_device *pdev; |
| 424 | int16_t ignore_qcmd_type; |
| 425 | uint8_t ignore_qcmd; |
| 426 | uint8_t opencnt; |
| 427 | void *cropinfo; |
| 428 | int croplen; |
| 429 | int core_powered_on; |
| 430 | |
| 431 | struct fd_roi_info fdroiinfo; |
| 432 | |
| 433 | atomic_t vpe_enable; |
| 434 | uint32_t pp_mask; |
| 435 | uint8_t pp_frame_avail; |
| 436 | struct msm_queue_cmd *pp_prev; |
| 437 | struct msm_queue_cmd *pp_snap; |
| 438 | struct msm_queue_cmd *pp_thumb; |
| 439 | int video_fd; |
| 440 | |
| 441 | const char *apps_id; |
| 442 | |
| 443 | struct mutex lock; |
| 444 | struct list_head list; |
| 445 | uint8_t liveshot_enabled; |
| 446 | struct msm_cam_v4l2_device *pcam_sync; |
| 447 | |
| 448 | uint8_t stereocam_enabled; |
| 449 | struct msm_queue_cmd *pp_stereocam; |
| 450 | struct msm_queue_cmd *pp_stereocam2; |
| 451 | struct msm_queue_cmd *pp_stereosnap; |
| 452 | enum msm_stereo_state stereo_state; |
| 453 | int stcam_quality_ind; |
| 454 | uint32_t stcam_conv_value; |
| 455 | |
| 456 | spinlock_t pmem_frame_spinlock; |
| 457 | spinlock_t pmem_stats_spinlock; |
| 458 | spinlock_t abort_pict_lock; |
| 459 | int snap_count; |
| 460 | int thumb_count; |
| 461 | }; |
| 462 | |
| 463 | #define MSM_APPS_ID_V4L2 "msm_v4l2" |
| 464 | #define MSM_APPS_ID_PROP "msm_qct" |
| 465 | |
| 466 | struct msm_cam_device { |
| 467 | struct msm_sync *sync; /* most-frequently accessed */ |
| 468 | struct device *device; |
| 469 | struct cdev cdev; |
| 470 | /* opened is meaningful only for the config and frame nodes, |
| 471 | * which may be opened only once. |
| 472 | */ |
| 473 | atomic_t opened; |
| 474 | }; |
| 475 | |
| 476 | struct msm_control_device { |
| 477 | struct msm_cam_device *pmsm; |
| 478 | |
| 479 | /* Used for MSM_CAM_IOCTL_CTRL_CMD_DONE responses */ |
| 480 | uint8_t ctrl_data[max_control_command_size]; |
| 481 | struct msm_ctrl_cmd ctrl; |
| 482 | struct msm_queue_cmd qcmd; |
| 483 | |
| 484 | /* This queue used by the config thread to send responses back to the |
| 485 | * control thread. It is accessed only from a process context. |
| 486 | */ |
| 487 | struct msm_device_queue ctrl_q; |
| 488 | }; |
| 489 | |
| 490 | struct register_address_value_pair { |
| 491 | uint16_t register_address; |
| 492 | uint16_t register_value; |
| 493 | }; |
| 494 | |
| 495 | struct msm_pmem_region { |
| 496 | struct hlist_node list; |
| 497 | unsigned long paddr; |
| 498 | unsigned long len; |
| 499 | struct file *file; |
| 500 | struct msm_pmem_info info; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 501 | struct ion_handle *handle; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 502 | }; |
| 503 | |
| 504 | struct axidata { |
| 505 | uint32_t bufnum1; |
| 506 | uint32_t bufnum2; |
| 507 | uint32_t bufnum3; |
| 508 | struct msm_pmem_region *region; |
| 509 | }; |
| 510 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 511 | void msm_camvfe_init(void); |
| 512 | int msm_camvfe_check(void *); |
| 513 | void msm_camvfe_fn_init(struct msm_camvfe_fn *, void *); |
| 514 | void msm_camvpe_fn_init(struct msm_camvpe_fn *, void *); |
| 515 | int msm_camera_drv_start(struct platform_device *dev, |
| 516 | int (*sensor_probe)(const struct msm_camera_sensor_info *, |
| 517 | struct msm_sensor_ctrl *)); |
| 518 | |
| 519 | enum msm_camio_clk_type { |
| 520 | CAMIO_VFE_MDC_CLK, |
| 521 | CAMIO_MDC_CLK, |
| 522 | CAMIO_VFE_CLK, |
| 523 | CAMIO_VFE_AXI_CLK, |
| 524 | |
| 525 | CAMIO_VFE_CAMIF_CLK, |
| 526 | CAMIO_VFE_PBDG_CLK, |
| 527 | CAMIO_CAM_MCLK_CLK, |
| 528 | CAMIO_CAMIF_PAD_PBDG_CLK, |
| 529 | |
| 530 | CAMIO_CSI0_VFE_CLK, |
| 531 | CAMIO_CSI1_VFE_CLK, |
| 532 | CAMIO_VFE_PCLK, |
| 533 | |
| 534 | CAMIO_CSI_SRC_CLK, |
| 535 | CAMIO_CSI0_CLK, |
| 536 | CAMIO_CSI1_CLK, |
| 537 | CAMIO_CSI0_PCLK, |
| 538 | CAMIO_CSI1_PCLK, |
| 539 | |
| 540 | CAMIO_CSI1_SRC_CLK, |
| 541 | CAMIO_CSI_PIX_CLK, |
Sreesudhan Ramakrish Ramkumar | d6e9cb9 | 2011-10-12 17:55:18 -0700 | [diff] [blame] | 542 | CAMIO_CSI_PIX1_CLK, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 543 | CAMIO_CSI_RDI_CLK, |
Sreesudhan Ramakrish Ramkumar | d6e9cb9 | 2011-10-12 17:55:18 -0700 | [diff] [blame] | 544 | CAMIO_CSI_RDI1_CLK, |
| 545 | CAMIO_CSI_RDI2_CLK, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 546 | CAMIO_CSIPHY0_TIMER_CLK, |
| 547 | CAMIO_CSIPHY1_TIMER_CLK, |
| 548 | |
| 549 | CAMIO_JPEG_CLK, |
| 550 | CAMIO_JPEG_PCLK, |
| 551 | CAMIO_VPE_CLK, |
| 552 | CAMIO_VPE_PCLK, |
| 553 | |
| 554 | CAMIO_CSI0_PHY_CLK, |
| 555 | CAMIO_CSI1_PHY_CLK, |
| 556 | CAMIO_CSIPHY_TIMER_SRC_CLK, |
Jignesh Mehta | 95dd6e1 | 2011-11-18 17:21:16 -0800 | [diff] [blame] | 557 | CAMIO_IMEM_CLK, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 558 | |
| 559 | CAMIO_MAX_CLK |
| 560 | }; |
| 561 | |
| 562 | enum msm_camio_clk_src_type { |
| 563 | MSM_CAMIO_CLK_SRC_INTERNAL, |
| 564 | MSM_CAMIO_CLK_SRC_EXTERNAL, |
| 565 | MSM_CAMIO_CLK_SRC_MAX |
| 566 | }; |
| 567 | |
| 568 | enum msm_s_test_mode { |
| 569 | S_TEST_OFF, |
| 570 | S_TEST_1, |
| 571 | S_TEST_2, |
| 572 | S_TEST_3 |
| 573 | }; |
| 574 | |
| 575 | enum msm_s_resolution { |
| 576 | S_QTR_SIZE, |
| 577 | S_FULL_SIZE, |
| 578 | S_INVALID_SIZE |
| 579 | }; |
| 580 | |
| 581 | enum msm_s_reg_update { |
| 582 | /* Sensor egisters that need to be updated during initialization */ |
| 583 | S_REG_INIT, |
| 584 | /* Sensor egisters that needs periodic I2C writes */ |
| 585 | S_UPDATE_PERIODIC, |
| 586 | /* All the sensor Registers will be updated */ |
| 587 | S_UPDATE_ALL, |
| 588 | /* Not valid update */ |
| 589 | S_UPDATE_INVALID |
| 590 | }; |
| 591 | |
| 592 | enum msm_s_setting { |
| 593 | S_RES_PREVIEW, |
| 594 | S_RES_CAPTURE |
| 595 | }; |
| 596 | |
| 597 | enum msm_bus_perf_setting { |
| 598 | S_INIT, |
| 599 | S_PREVIEW, |
| 600 | S_VIDEO, |
| 601 | S_CAPTURE, |
| 602 | S_ZSL, |
| 603 | S_STEREO_VIDEO, |
| 604 | S_STEREO_CAPTURE, |
| 605 | S_DEFAULT, |
Kiran Kumar H N | 1d1d307 | 2012-07-05 13:40:13 -0700 | [diff] [blame] | 606 | S_LIVESHOT, |
Nishant Pandit | 221a948 | 2012-09-03 05:36:04 +0530 | [diff] [blame] | 607 | S_DUAL, |
Kiran Kumar H N | 2237043 | 2012-11-05 20:08:10 -0800 | [diff] [blame] | 608 | S_ADV_VIDEO, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 609 | S_EXIT |
| 610 | }; |
| 611 | |
| 612 | int msm_camio_enable(struct platform_device *dev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 613 | int msm_camio_vpe_clk_enable(uint32_t); |
| 614 | int msm_camio_vpe_clk_disable(void); |
| 615 | |
Kevin Chan | bb8ef86 | 2012-02-14 13:03:04 -0800 | [diff] [blame] | 616 | void msm_camio_mode_config(enum msm_camera_i2c_mux_mode mode); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 617 | int msm_camio_clk_enable(enum msm_camio_clk_type clk); |
| 618 | int msm_camio_clk_disable(enum msm_camio_clk_type clk); |
| 619 | int msm_camio_clk_config(uint32_t freq); |
| 620 | void msm_camio_clk_rate_set(int rate); |
Shuzhen Wang | e49436a | 2011-09-28 16:07:27 -0700 | [diff] [blame] | 621 | int msm_camio_vfe_clk_rate_set(int rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 622 | void msm_camio_clk_rate_set_2(struct clk *clk, int rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 623 | void msm_camio_clk_axi_rate_set(int rate); |
| 624 | void msm_disable_io_gpio_clk(struct platform_device *); |
| 625 | |
| 626 | void msm_camio_camif_pad_reg_reset(void); |
| 627 | void msm_camio_camif_pad_reg_reset_2(void); |
| 628 | |
| 629 | void msm_camio_vfe_blk_reset(void); |
Suresh Vankadara | 3a9722a | 2012-05-21 10:09:05 +0530 | [diff] [blame] | 630 | void msm_camio_vfe_blk_reset_2(void); |
| 631 | void msm_camio_vfe_blk_reset_3(void); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 632 | |
Nishant Pandit | 24153d8 | 2011-08-27 16:05:13 +0530 | [diff] [blame] | 633 | int32_t msm_camio_3d_enable(const struct msm_camera_sensor_info *sinfo); |
| 634 | void msm_camio_3d_disable(void); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 635 | void msm_camio_clk_sel(enum msm_camio_clk_src_type); |
| 636 | void msm_camio_disable(struct platform_device *); |
| 637 | int msm_camio_probe_on(struct platform_device *); |
| 638 | int msm_camio_probe_off(struct platform_device *); |
| 639 | int msm_camio_sensor_clk_off(struct platform_device *); |
| 640 | int msm_camio_sensor_clk_on(struct platform_device *); |
| 641 | int msm_camio_csi_config(struct msm_camera_csi_params *csi_params); |
| 642 | int msm_camio_csiphy_config(struct msm_camera_csiphy_params *csiphy_params); |
| 643 | int msm_camio_csid_config(struct msm_camera_csid_params *csid_params); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 644 | int add_axi_qos(void); |
| 645 | int update_axi_qos(uint32_t freq); |
| 646 | void release_axi_qos(void); |
Kiran Kumar H N | 3ee4681 | 2012-04-13 16:57:57 -0700 | [diff] [blame] | 647 | void msm_camera_io_w(u32 data, void __iomem *addr); |
| 648 | void msm_camera_io_w_mb(u32 data, void __iomem *addr); |
| 649 | u32 msm_camera_io_r(void __iomem *addr); |
| 650 | u32 msm_camera_io_r_mb(void __iomem *addr); |
| 651 | void msm_camera_io_dump(void __iomem *addr, int size); |
| 652 | void msm_camera_io_memcpy(void __iomem *dest_addr, |
| 653 | void __iomem *src_addr, u32 len); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 654 | void msm_camio_set_perf_lvl(enum msm_bus_perf_setting); |
Kevin Chan | 09f4e66 | 2011-12-16 08:17:02 -0800 | [diff] [blame] | 655 | void msm_camio_bus_scale_cfg( |
| 656 | struct msm_bus_scale_pdata *, enum msm_bus_perf_setting); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 657 | |
Shuzhen Wang | a3c1a12 | 2011-08-04 15:33:27 -0700 | [diff] [blame] | 658 | void *msm_isp_sync_alloc(int size, gfp_t gfp); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 659 | |
| 660 | void msm_isp_sync_free(void *ptr); |
Kevin Chan | 85af455 | 2011-10-25 15:07:58 -0700 | [diff] [blame] | 661 | |
| 662 | int msm_cam_clk_enable(struct device *dev, struct msm_cam_clk_info *clk_info, |
| 663 | struct clk **clk_ptr, int num_clk, int enable); |
Jeyaprakash Soundrapandian | 2474e8f | 2012-01-03 15:59:57 -0800 | [diff] [blame] | 664 | int msm_cam_core_reset(void); |
Kevin Chan | eb6b607 | 2012-01-17 11:54:54 -0800 | [diff] [blame] | 665 | |
| 666 | int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, |
Sreesudhan Ramakrish Ramkumar | 923fbad | 2012-07-26 17:31:42 -0700 | [diff] [blame] | 667 | int num_vreg, enum msm_camera_vreg_name_t *vreg_seq, |
| 668 | int num_vreg_seq, struct regulator **reg_ptr, int config); |
Kevin Chan | eb6b607 | 2012-01-17 11:54:54 -0800 | [diff] [blame] | 669 | int msm_camera_enable_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, |
Sreesudhan Ramakrish Ramkumar | 923fbad | 2012-07-26 17:31:42 -0700 | [diff] [blame] | 670 | int num_vreg, enum msm_camera_vreg_name_t *vreg_seq, |
| 671 | int num_vreg_seq, struct regulator **reg_ptr, int enable); |
Kevin Chan | eb6b607 | 2012-01-17 11:54:54 -0800 | [diff] [blame] | 672 | |
| 673 | int msm_camera_config_gpio_table |
| 674 | (struct msm_camera_sensor_info *sinfo, int gpio_en); |
| 675 | int msm_camera_request_gpio_table |
| 676 | (struct msm_camera_sensor_info *sinfo, int gpio_en); |
Kevin Chan | 7303f59 | 2012-08-23 23:36:53 -0700 | [diff] [blame] | 677 | void msm_camera_bus_scale_cfg(uint32_t bus_perf_client, |
| 678 | enum msm_bus_perf_setting perf_setting); |
Sreesudhan Ramakrish Ramkumar | 7f723dc | 2012-10-12 22:58:13 -0700 | [diff] [blame] | 679 | |
| 680 | int msm_camera_init_gpio_table(struct gpio *gpio_tbl, uint8_t gpio_tbl_size, |
| 681 | int gpio_en); |
| 682 | |
| 683 | int msm_camera_set_gpio_table(struct msm_gpio_set_tbl *gpio_tbl, |
| 684 | uint8_t gpio_tbl_size, int gpio_en); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 685 | #endif |