Jeyaprakash Soundrapandian | 2474e8f | 2012-01-03 15:59:57 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2009-2012, Code Aurora Forum. 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> |
| 21 | #include <linux/wakelock.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> |
Ankit Premrajka | c6864b8 | 2011-07-15 11:43:41 -0700 | [diff] [blame] | 27 | #include <mach/msm_subsystem_map.h> |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 28 | #include <linux/ion.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, |
Kiran Kumar H N | 0fb9dcf | 2011-07-17 12:31:53 -0700 | [diff] [blame] | 88 | VFE_MSG_V32_START, |
Kiran Kumar H N | dd12847 | 2011-12-01 09:35:34 -0800 | [diff] [blame] | 89 | VFE_MSG_V32_START_RECORDING, /* 20 */ |
Kiran Kumar H N | 0fb9dcf | 2011-07-17 12:31:53 -0700 | [diff] [blame] | 90 | VFE_MSG_V32_CAPTURE, |
Jignesh Mehta | 6cf8a74 | 2012-02-04 23:40:50 -0800 | [diff] [blame] | 91 | VFE_MSG_V32_JPEG_CAPTURE, |
Kiran Kumar H N | 0fb9dcf | 2011-07-17 12:31:53 -0700 | [diff] [blame] | 92 | VFE_MSG_OUTPUT_IRQ, |
Suresh Vankadara | 055cb8e | 2012-01-18 00:50:04 +0530 | [diff] [blame] | 93 | VFE_MSG_V2X_PREVIEW, |
| 94 | VFE_MSG_V2X_CAPTURE, |
Kiran Kumar H N | dd12847 | 2011-12-01 09:35:34 -0800 | [diff] [blame] | 95 | VFE_MSG_OUTPUT_PRIMARY, |
| 96 | VFE_MSG_OUTPUT_SECONDARY, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | enum vpe_resp_msg { |
| 100 | VPE_MSG_GENERAL, |
| 101 | VPE_MSG_OUTPUT_V, /* video (continuous mode ) */ |
| 102 | VPE_MSG_OUTPUT_ST_L, |
| 103 | VPE_MSG_OUTPUT_ST_R, |
| 104 | }; |
| 105 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 106 | enum msm_stereo_state { |
| 107 | STEREO_VIDEO_IDLE, |
| 108 | STEREO_VIDEO_ACTIVE, |
| 109 | STEREO_SNAP_IDLE, |
| 110 | STEREO_SNAP_STARTED, |
| 111 | STEREO_SNAP_BUFFER1_PROCESSING, |
| 112 | STEREO_SNAP_BUFFER2_PROCESSING, |
| 113 | STEREO_RAW_SNAP_IDLE, |
| 114 | STEREO_RAW_SNAP_STARTED, |
| 115 | }; |
| 116 | |
| 117 | enum msm_ispif_intftype { |
| 118 | PIX0, |
| 119 | RDI0, |
| 120 | PIX1, |
| 121 | RDI1, |
| 122 | PIX2, |
| 123 | RDI2, |
| 124 | }; |
| 125 | |
| 126 | enum msm_ispif_vc { |
| 127 | VC0, |
| 128 | VC1, |
| 129 | VC2, |
| 130 | VC3, |
| 131 | }; |
| 132 | |
| 133 | enum msm_ispif_cid { |
| 134 | CID0, |
| 135 | CID1, |
| 136 | CID2, |
| 137 | CID3, |
| 138 | CID4, |
| 139 | CID5, |
| 140 | CID6, |
| 141 | CID7, |
| 142 | CID8, |
| 143 | CID9, |
| 144 | CID10, |
| 145 | CID11, |
| 146 | CID12, |
| 147 | CID13, |
| 148 | CID14, |
| 149 | CID15, |
| 150 | }; |
| 151 | |
| 152 | struct msm_ispif_params { |
| 153 | uint8_t intftype; |
| 154 | uint16_t cid_mask; |
| 155 | uint8_t csid; |
| 156 | }; |
Shuzhen Wang | a3c1a12 | 2011-08-04 15:33:27 -0700 | [diff] [blame] | 157 | |
| 158 | struct msm_ispif_params_list { |
| 159 | uint32_t len; |
| 160 | struct msm_ispif_params params[3]; |
| 161 | }; |
| 162 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 163 | struct msm_vpe_phy_info { |
| 164 | uint32_t sbuf_phy; |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 165 | uint32_t planar0_off; |
| 166 | uint32_t planar1_off; |
| 167 | uint32_t planar2_off; |
| 168 | uint32_t p0_phy; |
| 169 | uint32_t p1_phy; |
| 170 | uint32_t p2_phy; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 171 | uint8_t output_id; /* VFE31_OUTPUT_MODE_PT/S/V */ |
| 172 | uint32_t frame_id; |
| 173 | }; |
| 174 | |
| 175 | struct msm_camera_csid_vc_cfg { |
| 176 | uint8_t cid; |
| 177 | uint8_t dt; |
| 178 | uint8_t decode_format; |
| 179 | }; |
| 180 | |
| 181 | struct msm_camera_csid_lut_params { |
| 182 | uint8_t num_cid; |
| 183 | struct msm_camera_csid_vc_cfg *vc_cfg; |
| 184 | }; |
| 185 | |
| 186 | struct msm_camera_csid_params { |
| 187 | uint8_t lane_cnt; |
| 188 | uint8_t lane_assign; |
| 189 | struct msm_camera_csid_lut_params lut_params; |
| 190 | }; |
| 191 | |
| 192 | struct msm_camera_csiphy_params { |
| 193 | uint8_t lane_cnt; |
| 194 | uint8_t settle_cnt; |
Hody Hung | 9ba65cf | 2012-01-17 17:34:51 -0800 | [diff] [blame] | 195 | uint8_t lane_mask; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 196 | }; |
| 197 | |
Kevin Chan | a980f39 | 2011-08-01 20:55:00 -0700 | [diff] [blame] | 198 | struct msm_camera_csi2_params { |
| 199 | struct msm_camera_csid_params csid_params; |
| 200 | struct msm_camera_csiphy_params csiphy_params; |
| 201 | }; |
| 202 | |
Kevin Chan | 3be1161 | 2012-03-22 20:05:40 -0700 | [diff] [blame^] | 203 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 204 | #define VFE31_OUTPUT_MODE_PT (0x1 << 0) |
| 205 | #define VFE31_OUTPUT_MODE_S (0x1 << 1) |
| 206 | #define VFE31_OUTPUT_MODE_V (0x1 << 2) |
| 207 | #define VFE31_OUTPUT_MODE_P (0x1 << 3) |
| 208 | #define VFE31_OUTPUT_MODE_T (0x1 << 4) |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 209 | #define VFE31_OUTPUT_MODE_P_ALL_CHNLS (0x1 << 5) |
Kevin Chan | 3be1161 | 2012-03-22 20:05:40 -0700 | [diff] [blame^] | 210 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 211 | |
| 212 | #define CSI_EMBED_DATA 0x12 |
Rajakumar Govindaram | 6bc004a | 2011-12-05 20:58:19 -0800 | [diff] [blame] | 213 | #define CSI_YUV422_8 0x1E |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 214 | #define CSI_RAW8 0x2A |
| 215 | #define CSI_RAW10 0x2B |
| 216 | #define CSI_RAW12 0x2C |
| 217 | |
| 218 | #define CSI_DECODE_6BIT 0 |
| 219 | #define CSI_DECODE_8BIT 1 |
| 220 | #define CSI_DECODE_10BIT 2 |
Sreesudhan Ramakrish Ramkumar | 8f11b8b | 2012-01-04 17:09:05 -0800 | [diff] [blame] | 221 | #define CSI_DECODE_DPCM_10_8_10 5 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 222 | |
| 223 | struct msm_vfe_phy_info { |
| 224 | uint32_t sbuf_phy; |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 225 | uint32_t planar0_off; |
| 226 | uint32_t planar1_off; |
| 227 | uint32_t planar2_off; |
| 228 | uint32_t p0_phy; |
| 229 | uint32_t p1_phy; |
| 230 | uint32_t p2_phy; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 231 | uint8_t output_id; /* VFE31_OUTPUT_MODE_PT/S/V */ |
| 232 | uint32_t frame_id; |
| 233 | }; |
| 234 | |
| 235 | struct msm_vfe_stats_msg { |
Lakshmi Narayana Kalavala | 4ab97a9 | 2011-07-26 15:30:14 -0700 | [diff] [blame] | 236 | uint8_t awb_ymin; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 237 | uint32_t aec_buff; |
| 238 | uint32_t awb_buff; |
| 239 | uint32_t af_buff; |
| 240 | uint32_t ihist_buff; |
| 241 | uint32_t rs_buff; |
| 242 | uint32_t cs_buff; |
| 243 | uint32_t skin_buff; |
| 244 | uint32_t status_bits; |
| 245 | uint32_t frame_id; |
| 246 | }; |
| 247 | |
| 248 | struct video_crop_t{ |
| 249 | uint32_t in1_w; |
| 250 | uint32_t out1_w; |
| 251 | uint32_t in1_h; |
| 252 | uint32_t out1_h; |
| 253 | uint32_t in2_w; |
| 254 | uint32_t out2_w; |
| 255 | uint32_t in2_h; |
| 256 | uint32_t out2_h; |
| 257 | uint8_t update_flag; |
| 258 | }; |
| 259 | |
| 260 | struct msm_vpe_buf_info { |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 261 | uint32_t p0_phy; |
| 262 | uint32_t p1_phy; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 263 | struct timespec ts; |
| 264 | uint32_t frame_id; |
| 265 | struct video_crop_t vpe_crop; |
| 266 | }; |
| 267 | |
| 268 | struct msm_vfe_resp { |
| 269 | enum vfe_resp_msg type; |
| 270 | struct msm_cam_evt_msg evt_msg; |
| 271 | struct msm_vfe_phy_info phy; |
| 272 | struct msm_vfe_stats_msg stats_msg; |
| 273 | struct msm_vpe_buf_info vpe_bf; |
| 274 | void *extdata; |
| 275 | int32_t extlen; |
| 276 | }; |
| 277 | |
| 278 | struct msm_vpe_resp { |
| 279 | enum vpe_resp_msg type; |
| 280 | struct msm_cam_evt_msg evt_msg; |
| 281 | struct msm_vpe_phy_info phy; |
| 282 | void *extdata; |
| 283 | int32_t extlen; |
| 284 | }; |
| 285 | |
| 286 | struct msm_vpe_callback { |
| 287 | void (*vpe_resp)(struct msm_vpe_resp *, |
| 288 | enum msm_queue, void *syncdata, |
| 289 | void *time_stamp, gfp_t gfp); |
| 290 | void* (*vpe_alloc)(int, void *syncdata, gfp_t gfp); |
| 291 | void (*vpe_free)(void *ptr); |
| 292 | }; |
| 293 | |
| 294 | struct msm_vfe_callback { |
| 295 | void (*vfe_resp)(struct msm_vfe_resp *, |
| 296 | enum msm_queue, void *syncdata, |
| 297 | gfp_t gfp); |
| 298 | void* (*vfe_alloc)(int, void *syncdata, gfp_t gfp); |
| 299 | void (*vfe_free)(void *ptr); |
| 300 | }; |
| 301 | |
| 302 | struct msm_camvfe_fn { |
| 303 | int (*vfe_init)(struct msm_vfe_callback *, |
| 304 | struct platform_device *); |
| 305 | int (*vfe_enable)(struct camera_enable_cmd *); |
| 306 | int (*vfe_config)(struct msm_vfe_cfg_cmd *, void *); |
| 307 | int (*vfe_disable)(struct camera_enable_cmd *, |
| 308 | struct platform_device *dev); |
| 309 | void (*vfe_release)(struct platform_device *); |
| 310 | void (*vfe_stop)(void); |
| 311 | }; |
| 312 | |
| 313 | struct msm_camvfe_params { |
| 314 | struct msm_vfe_cfg_cmd *vfe_cfg; |
| 315 | void *data; |
| 316 | }; |
| 317 | |
Mingcheng Zhu | 8e9f99e | 2011-08-26 16:33:32 -0700 | [diff] [blame] | 318 | struct msm_mctl_pp_params { |
| 319 | struct msm_mctl_pp_cmd *cmd; |
| 320 | void *data; |
| 321 | }; |
| 322 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 323 | struct msm_camvpe_fn { |
| 324 | int (*vpe_reg)(struct msm_vpe_callback *); |
| 325 | int (*vpe_cfg_update) (void *); |
Alekhya,Monika | fc81e10 | 2011-12-29 15:17:33 +0530 | [diff] [blame] | 326 | 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] | 327 | struct timespec *ts, int output_id); |
| 328 | int (*vpe_config)(struct msm_vpe_cfg_cmd *, void *); |
| 329 | void (*vpe_cfg_offset)(int frame_pack, uint32_t pyaddr, |
| 330 | uint32_t pcbcraddr, struct timespec *ts, int output_id, |
| 331 | struct msm_st_half st_half, int frameid); |
| 332 | int *dis; |
| 333 | }; |
| 334 | |
| 335 | struct msm_sensor_ctrl { |
| 336 | int (*s_init)(const struct msm_camera_sensor_info *); |
| 337 | int (*s_release)(void); |
| 338 | int (*s_config)(void __user *); |
| 339 | enum msm_camera_type s_camera_type; |
| 340 | uint32_t s_mount_angle; |
| 341 | enum msm_st_frame_packing s_video_packing; |
| 342 | enum msm_st_frame_packing s_snap_packing; |
| 343 | }; |
Sreesudhan Ramakrish Ramkumar | a4b5f30 | 2011-09-12 16:23:22 -0700 | [diff] [blame] | 344 | |
| 345 | struct msm_actuator_ctrl { |
| 346 | int (*a_init_table)(void); |
Rajakumar Govindaram | df6af9c | 2011-12-01 21:26:20 -0800 | [diff] [blame] | 347 | int (*a_power_up)(void *); |
| 348 | int (*a_power_down)(void *); |
Sreesudhan Ramakrish Ramkumar | a4b5f30 | 2011-09-12 16:23:22 -0700 | [diff] [blame] | 349 | int (*a_create_subdevice)(void *, void *); |
| 350 | int (*a_config)(void __user *); |
| 351 | }; |
| 352 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 353 | struct msm_strobe_flash_ctrl { |
| 354 | int (*strobe_flash_init) |
| 355 | (struct msm_camera_sensor_strobe_flash_data *); |
| 356 | int (*strobe_flash_release) |
| 357 | (struct msm_camera_sensor_strobe_flash_data *, int32_t); |
| 358 | int (*strobe_flash_charge)(int32_t, int32_t, uint32_t); |
| 359 | }; |
| 360 | |
| 361 | /* this structure is used in kernel */ |
| 362 | struct msm_queue_cmd { |
| 363 | struct list_head list_config; |
| 364 | struct list_head list_control; |
| 365 | struct list_head list_frame; |
| 366 | struct list_head list_pict; |
| 367 | struct list_head list_vpe_frame; |
| 368 | enum msm_queue type; |
| 369 | void *command; |
| 370 | atomic_t on_heap; |
| 371 | struct timespec ts; |
| 372 | uint32_t error_code; |
| 373 | }; |
| 374 | |
| 375 | struct msm_device_queue { |
| 376 | struct list_head list; |
| 377 | spinlock_t lock; |
| 378 | wait_queue_head_t wait; |
| 379 | int max; |
| 380 | int len; |
| 381 | const char *name; |
| 382 | }; |
| 383 | |
| 384 | struct msm_sync { |
| 385 | /* These two queues are accessed from a process context only |
| 386 | * They contain pmem descriptors for the preview frames and the stats |
| 387 | * coming from the camera sensor. |
| 388 | */ |
| 389 | struct hlist_head pmem_frames; |
| 390 | struct hlist_head pmem_stats; |
| 391 | |
| 392 | /* The message queue is used by the control thread to send commands |
| 393 | * to the config thread, and also by the DSP to send messages to the |
| 394 | * config thread. Thus it is the only queue that is accessed from |
| 395 | * both interrupt and process context. |
| 396 | */ |
| 397 | struct msm_device_queue event_q; |
| 398 | |
| 399 | /* This queue contains preview frames. It is accessed by the DSP (in |
| 400 | * in interrupt context, and by the frame thread. |
| 401 | */ |
| 402 | struct msm_device_queue frame_q; |
| 403 | int unblock_poll_frame; |
| 404 | int unblock_poll_pic_frame; |
| 405 | |
| 406 | /* This queue contains snapshot frames. It is accessed by the DSP (in |
| 407 | * interrupt context, and by the control thread. |
| 408 | */ |
| 409 | struct msm_device_queue pict_q; |
| 410 | int get_pic_abort; |
| 411 | struct msm_device_queue vpe_q; |
| 412 | |
| 413 | struct msm_camera_sensor_info *sdata; |
| 414 | struct msm_camvfe_fn vfefn; |
| 415 | struct msm_camvpe_fn vpefn; |
| 416 | struct msm_sensor_ctrl sctrl; |
| 417 | struct msm_strobe_flash_ctrl sfctrl; |
Sreesudhan Ramakrish Ramkumar | a4b5f30 | 2011-09-12 16:23:22 -0700 | [diff] [blame] | 418 | struct msm_actuator_ctrl actctrl; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 419 | struct wake_lock wake_lock; |
| 420 | struct platform_device *pdev; |
| 421 | int16_t ignore_qcmd_type; |
| 422 | uint8_t ignore_qcmd; |
| 423 | uint8_t opencnt; |
| 424 | void *cropinfo; |
| 425 | int croplen; |
| 426 | int core_powered_on; |
| 427 | |
| 428 | struct fd_roi_info fdroiinfo; |
| 429 | |
| 430 | atomic_t vpe_enable; |
| 431 | uint32_t pp_mask; |
| 432 | uint8_t pp_frame_avail; |
| 433 | struct msm_queue_cmd *pp_prev; |
| 434 | struct msm_queue_cmd *pp_snap; |
| 435 | struct msm_queue_cmd *pp_thumb; |
| 436 | int video_fd; |
| 437 | |
| 438 | const char *apps_id; |
| 439 | |
| 440 | struct mutex lock; |
| 441 | struct list_head list; |
| 442 | uint8_t liveshot_enabled; |
| 443 | struct msm_cam_v4l2_device *pcam_sync; |
| 444 | |
| 445 | uint8_t stereocam_enabled; |
| 446 | struct msm_queue_cmd *pp_stereocam; |
| 447 | struct msm_queue_cmd *pp_stereocam2; |
| 448 | struct msm_queue_cmd *pp_stereosnap; |
| 449 | enum msm_stereo_state stereo_state; |
| 450 | int stcam_quality_ind; |
| 451 | uint32_t stcam_conv_value; |
| 452 | |
| 453 | spinlock_t pmem_frame_spinlock; |
| 454 | spinlock_t pmem_stats_spinlock; |
| 455 | spinlock_t abort_pict_lock; |
| 456 | int snap_count; |
| 457 | int thumb_count; |
| 458 | }; |
| 459 | |
| 460 | #define MSM_APPS_ID_V4L2 "msm_v4l2" |
| 461 | #define MSM_APPS_ID_PROP "msm_qct" |
| 462 | |
| 463 | struct msm_cam_device { |
| 464 | struct msm_sync *sync; /* most-frequently accessed */ |
| 465 | struct device *device; |
| 466 | struct cdev cdev; |
| 467 | /* opened is meaningful only for the config and frame nodes, |
| 468 | * which may be opened only once. |
| 469 | */ |
| 470 | atomic_t opened; |
| 471 | }; |
| 472 | |
| 473 | struct msm_control_device { |
| 474 | struct msm_cam_device *pmsm; |
| 475 | |
| 476 | /* Used for MSM_CAM_IOCTL_CTRL_CMD_DONE responses */ |
| 477 | uint8_t ctrl_data[max_control_command_size]; |
| 478 | struct msm_ctrl_cmd ctrl; |
| 479 | struct msm_queue_cmd qcmd; |
| 480 | |
| 481 | /* This queue used by the config thread to send responses back to the |
| 482 | * control thread. It is accessed only from a process context. |
| 483 | */ |
| 484 | struct msm_device_queue ctrl_q; |
| 485 | }; |
| 486 | |
| 487 | struct register_address_value_pair { |
| 488 | uint16_t register_address; |
| 489 | uint16_t register_value; |
| 490 | }; |
| 491 | |
| 492 | struct msm_pmem_region { |
| 493 | struct hlist_node list; |
| 494 | unsigned long paddr; |
| 495 | unsigned long len; |
| 496 | struct file *file; |
| 497 | struct msm_pmem_info info; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 498 | struct ion_handle *handle; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 499 | }; |
| 500 | |
| 501 | struct axidata { |
| 502 | uint32_t bufnum1; |
| 503 | uint32_t bufnum2; |
| 504 | uint32_t bufnum3; |
| 505 | struct msm_pmem_region *region; |
| 506 | }; |
| 507 | |
| 508 | #ifdef CONFIG_MSM_CAMERA_FLASH |
| 509 | int msm_camera_flash_set_led_state( |
| 510 | struct msm_camera_sensor_flash_data *fdata, |
| 511 | unsigned led_state); |
| 512 | int msm_strobe_flash_init(struct msm_sync *sync, uint32_t sftype); |
| 513 | int msm_flash_ctrl(struct msm_camera_sensor_info *sdata, |
| 514 | struct flash_ctrl_data *flash_info); |
| 515 | #else |
| 516 | static inline int msm_camera_flash_set_led_state( |
| 517 | struct msm_camera_sensor_flash_data *fdata, |
| 518 | unsigned led_state) |
| 519 | { |
| 520 | return -ENOTSUPP; |
| 521 | } |
| 522 | static inline int msm_strobe_flash_init( |
| 523 | struct msm_sync *sync, uint32_t sftype) |
| 524 | { |
| 525 | return -ENOTSUPP; |
| 526 | } |
| 527 | static inline int msm_flash_ctrl( |
| 528 | struct msm_camera_sensor_info *sdata, |
| 529 | struct flash_ctrl_data *flash_info) |
| 530 | { |
| 531 | return -ENOTSUPP; |
| 532 | } |
| 533 | #endif |
| 534 | |
| 535 | |
| 536 | |
| 537 | void msm_camvfe_init(void); |
| 538 | int msm_camvfe_check(void *); |
| 539 | void msm_camvfe_fn_init(struct msm_camvfe_fn *, void *); |
| 540 | void msm_camvpe_fn_init(struct msm_camvpe_fn *, void *); |
| 541 | int msm_camera_drv_start(struct platform_device *dev, |
| 542 | int (*sensor_probe)(const struct msm_camera_sensor_info *, |
| 543 | struct msm_sensor_ctrl *)); |
| 544 | |
| 545 | enum msm_camio_clk_type { |
| 546 | CAMIO_VFE_MDC_CLK, |
| 547 | CAMIO_MDC_CLK, |
| 548 | CAMIO_VFE_CLK, |
| 549 | CAMIO_VFE_AXI_CLK, |
| 550 | |
| 551 | CAMIO_VFE_CAMIF_CLK, |
| 552 | CAMIO_VFE_PBDG_CLK, |
| 553 | CAMIO_CAM_MCLK_CLK, |
| 554 | CAMIO_CAMIF_PAD_PBDG_CLK, |
| 555 | |
| 556 | CAMIO_CSI0_VFE_CLK, |
| 557 | CAMIO_CSI1_VFE_CLK, |
| 558 | CAMIO_VFE_PCLK, |
| 559 | |
| 560 | CAMIO_CSI_SRC_CLK, |
| 561 | CAMIO_CSI0_CLK, |
| 562 | CAMIO_CSI1_CLK, |
| 563 | CAMIO_CSI0_PCLK, |
| 564 | CAMIO_CSI1_PCLK, |
| 565 | |
| 566 | CAMIO_CSI1_SRC_CLK, |
| 567 | CAMIO_CSI_PIX_CLK, |
Sreesudhan Ramakrish Ramkumar | d6e9cb9 | 2011-10-12 17:55:18 -0700 | [diff] [blame] | 568 | CAMIO_CSI_PIX1_CLK, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 569 | CAMIO_CSI_RDI_CLK, |
Sreesudhan Ramakrish Ramkumar | d6e9cb9 | 2011-10-12 17:55:18 -0700 | [diff] [blame] | 570 | CAMIO_CSI_RDI1_CLK, |
| 571 | CAMIO_CSI_RDI2_CLK, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 572 | CAMIO_CSIPHY0_TIMER_CLK, |
| 573 | CAMIO_CSIPHY1_TIMER_CLK, |
| 574 | |
| 575 | CAMIO_JPEG_CLK, |
| 576 | CAMIO_JPEG_PCLK, |
| 577 | CAMIO_VPE_CLK, |
| 578 | CAMIO_VPE_PCLK, |
| 579 | |
| 580 | CAMIO_CSI0_PHY_CLK, |
| 581 | CAMIO_CSI1_PHY_CLK, |
| 582 | CAMIO_CSIPHY_TIMER_SRC_CLK, |
Jignesh Mehta | 95dd6e1 | 2011-11-18 17:21:16 -0800 | [diff] [blame] | 583 | CAMIO_IMEM_CLK, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 584 | |
| 585 | CAMIO_MAX_CLK |
| 586 | }; |
| 587 | |
| 588 | enum msm_camio_clk_src_type { |
| 589 | MSM_CAMIO_CLK_SRC_INTERNAL, |
| 590 | MSM_CAMIO_CLK_SRC_EXTERNAL, |
| 591 | MSM_CAMIO_CLK_SRC_MAX |
| 592 | }; |
| 593 | |
| 594 | enum msm_s_test_mode { |
| 595 | S_TEST_OFF, |
| 596 | S_TEST_1, |
| 597 | S_TEST_2, |
| 598 | S_TEST_3 |
| 599 | }; |
| 600 | |
| 601 | enum msm_s_resolution { |
| 602 | S_QTR_SIZE, |
| 603 | S_FULL_SIZE, |
| 604 | S_INVALID_SIZE |
| 605 | }; |
| 606 | |
| 607 | enum msm_s_reg_update { |
| 608 | /* Sensor egisters that need to be updated during initialization */ |
| 609 | S_REG_INIT, |
| 610 | /* Sensor egisters that needs periodic I2C writes */ |
| 611 | S_UPDATE_PERIODIC, |
| 612 | /* All the sensor Registers will be updated */ |
| 613 | S_UPDATE_ALL, |
| 614 | /* Not valid update */ |
| 615 | S_UPDATE_INVALID |
| 616 | }; |
| 617 | |
| 618 | enum msm_s_setting { |
| 619 | S_RES_PREVIEW, |
| 620 | S_RES_CAPTURE |
| 621 | }; |
| 622 | |
| 623 | enum msm_bus_perf_setting { |
| 624 | S_INIT, |
| 625 | S_PREVIEW, |
| 626 | S_VIDEO, |
| 627 | S_CAPTURE, |
| 628 | S_ZSL, |
| 629 | S_STEREO_VIDEO, |
| 630 | S_STEREO_CAPTURE, |
| 631 | S_DEFAULT, |
| 632 | S_EXIT |
| 633 | }; |
| 634 | |
Kevin Chan | 85af455 | 2011-10-25 15:07:58 -0700 | [diff] [blame] | 635 | struct msm_cam_clk_info { |
| 636 | const char *clk_name; |
| 637 | long clk_rate; |
| 638 | }; |
| 639 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 640 | int msm_camio_enable(struct platform_device *dev); |
| 641 | int msm_camio_jpeg_clk_enable(void); |
| 642 | int msm_camio_jpeg_clk_disable(void); |
| 643 | int msm_camio_vpe_clk_enable(uint32_t); |
| 644 | int msm_camio_vpe_clk_disable(void); |
| 645 | |
Kevin Chan | bb8ef86 | 2012-02-14 13:03:04 -0800 | [diff] [blame] | 646 | void msm_camio_mode_config(enum msm_camera_i2c_mux_mode mode); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 647 | int msm_camio_clk_enable(enum msm_camio_clk_type clk); |
| 648 | int msm_camio_clk_disable(enum msm_camio_clk_type clk); |
| 649 | int msm_camio_clk_config(uint32_t freq); |
| 650 | void msm_camio_clk_rate_set(int rate); |
Shuzhen Wang | e49436a | 2011-09-28 16:07:27 -0700 | [diff] [blame] | 651 | int msm_camio_vfe_clk_rate_set(int rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 652 | void msm_camio_clk_rate_set_2(struct clk *clk, int rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 653 | void msm_camio_clk_axi_rate_set(int rate); |
| 654 | void msm_disable_io_gpio_clk(struct platform_device *); |
| 655 | |
| 656 | void msm_camio_camif_pad_reg_reset(void); |
| 657 | void msm_camio_camif_pad_reg_reset_2(void); |
| 658 | |
| 659 | void msm_camio_vfe_blk_reset(void); |
| 660 | |
Nishant Pandit | 24153d8 | 2011-08-27 16:05:13 +0530 | [diff] [blame] | 661 | int32_t msm_camio_3d_enable(const struct msm_camera_sensor_info *sinfo); |
| 662 | void msm_camio_3d_disable(void); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 663 | void msm_camio_clk_sel(enum msm_camio_clk_src_type); |
| 664 | void msm_camio_disable(struct platform_device *); |
| 665 | int msm_camio_probe_on(struct platform_device *); |
| 666 | int msm_camio_probe_off(struct platform_device *); |
| 667 | int msm_camio_sensor_clk_off(struct platform_device *); |
| 668 | int msm_camio_sensor_clk_on(struct platform_device *); |
| 669 | int msm_camio_csi_config(struct msm_camera_csi_params *csi_params); |
| 670 | int msm_camio_csiphy_config(struct msm_camera_csiphy_params *csiphy_params); |
| 671 | int msm_camio_csid_config(struct msm_camera_csid_params *csid_params); |
| 672 | void msm_io_read_interrupt(void); |
| 673 | int add_axi_qos(void); |
| 674 | int update_axi_qos(uint32_t freq); |
| 675 | void release_axi_qos(void); |
| 676 | void msm_io_w(u32 data, void __iomem *addr); |
| 677 | void msm_io_w_mb(u32 data, void __iomem *addr); |
| 678 | u32 msm_io_r(void __iomem *addr); |
| 679 | u32 msm_io_r_mb(void __iomem *addr); |
| 680 | void msm_io_dump(void __iomem *addr, int size); |
| 681 | void msm_io_memcpy(void __iomem *dest_addr, void __iomem *src_addr, u32 len); |
| 682 | void msm_camio_set_perf_lvl(enum msm_bus_perf_setting); |
Kevin Chan | 09f4e66 | 2011-12-16 08:17:02 -0800 | [diff] [blame] | 683 | void msm_camio_bus_scale_cfg( |
| 684 | struct msm_bus_scale_pdata *, enum msm_bus_perf_setting); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 685 | |
Shuzhen Wang | a3c1a12 | 2011-08-04 15:33:27 -0700 | [diff] [blame] | 686 | void *msm_isp_sync_alloc(int size, gfp_t gfp); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 687 | |
| 688 | void msm_isp_sync_free(void *ptr); |
Kevin Chan | 85af455 | 2011-10-25 15:07:58 -0700 | [diff] [blame] | 689 | |
| 690 | int msm_cam_clk_enable(struct device *dev, struct msm_cam_clk_info *clk_info, |
| 691 | struct clk **clk_ptr, int num_clk, int enable); |
Jeyaprakash Soundrapandian | 2474e8f | 2012-01-03 15:59:57 -0800 | [diff] [blame] | 692 | int msm_cam_core_reset(void); |
Kevin Chan | eb6b607 | 2012-01-17 11:54:54 -0800 | [diff] [blame] | 693 | |
| 694 | int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, |
| 695 | int num_vreg, struct regulator **reg_ptr, int config); |
| 696 | int msm_camera_enable_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, |
| 697 | int num_vreg, struct regulator **reg_ptr, int enable); |
| 698 | |
| 699 | int msm_camera_config_gpio_table |
| 700 | (struct msm_camera_sensor_info *sinfo, int gpio_en); |
| 701 | int msm_camera_request_gpio_table |
| 702 | (struct msm_camera_sensor_info *sinfo, int gpio_en); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 703 | #endif |