]>
Commit | Line | Data |
---|---|---|
e79753ed PM |
1 | /* |
2 | * Copyright (C) 2008-2009 QUALCOMM Incorporated. | |
3 | */ | |
4 | ||
5 | #ifndef __ASM__ARCH_CAMERA_H | |
6 | #define __ASM__ARCH_CAMERA_H | |
7 | ||
8 | #include <linux/list.h> | |
9 | #include <linux/poll.h> | |
10 | #include <linux/cdev.h> | |
11 | #include <linux/platform_device.h> | |
12 | #include "linux/types.h" | |
13 | ||
14 | #include <mach/board.h> | |
15 | #include <media/msm_camera.h> | |
16 | ||
17 | #ifdef CONFIG_MSM_CAMERA_DEBUG | |
18 | #define CDBG(fmt, args...) printk(KERN_INFO "msm_camera: " fmt, ##args) | |
19 | #else | |
20 | #define CDBG(fmt, args...) do { } while (0) | |
21 | #endif | |
22 | ||
23 | #define MSM_CAMERA_MSG 0 | |
24 | #define MSM_CAMERA_EVT 1 | |
25 | #define NUM_WB_EXP_NEUTRAL_REGION_LINES 4 | |
26 | #define NUM_WB_EXP_STAT_OUTPUT_BUFFERS 3 | |
27 | #define NUM_AUTOFOCUS_MULTI_WINDOW_GRIDS 16 | |
28 | #define NUM_AF_STAT_OUTPUT_BUFFERS 3 | |
29 | ||
30 | enum msm_queue { | |
31 | MSM_CAM_Q_CTRL, /* control command or control command status */ | |
32 | MSM_CAM_Q_VFE_EVT, /* adsp event */ | |
33 | MSM_CAM_Q_VFE_MSG, /* adsp message */ | |
34 | MSM_CAM_Q_V4L2_REQ, /* v4l2 request */ | |
35 | }; | |
36 | ||
37 | enum vfe_resp_msg { | |
38 | VFE_EVENT, | |
39 | VFE_MSG_GENERAL, | |
40 | VFE_MSG_SNAPSHOT, | |
41 | VFE_MSG_OUTPUT1, | |
42 | VFE_MSG_OUTPUT2, | |
43 | VFE_MSG_STATS_AF, | |
44 | VFE_MSG_STATS_WE, | |
45 | }; | |
46 | ||
47 | struct msm_vfe_phy_info { | |
48 | uint32_t sbuf_phy; | |
49 | uint32_t y_phy; | |
50 | uint32_t cbcr_phy; | |
51 | }; | |
52 | ||
53 | struct msm_vfe_resp { | |
54 | enum vfe_resp_msg type; | |
55 | struct msm_vfe_evt_msg evt_msg; | |
56 | struct msm_vfe_phy_info phy; | |
57 | void *extdata; | |
58 | int32_t extlen; | |
59 | }; | |
60 | ||
61 | struct msm_vfe_callback { | |
62 | void (*vfe_resp)(struct msm_vfe_resp *, | |
63 | enum msm_queue, void *syncdata); | |
64 | void* (*vfe_alloc)(int, void *syncdata); | |
65 | }; | |
66 | ||
67 | struct msm_camvfe_fn { | |
68 | int (*vfe_init)(struct msm_vfe_callback *, struct platform_device *); | |
69 | int (*vfe_enable)(struct camera_enable_cmd *); | |
70 | int (*vfe_config)(struct msm_vfe_cfg_cmd *, void *); | |
71 | int (*vfe_disable)(struct camera_enable_cmd *, | |
72 | struct platform_device *dev); | |
73 | void (*vfe_release)(struct platform_device *); | |
74 | }; | |
75 | ||
76 | struct msm_sensor_ctrl { | |
77 | int (*s_init)(const struct msm_camera_sensor_info *); | |
78 | int (*s_release)(void); | |
79 | int (*s_config)(void __user *); | |
80 | }; | |
81 | ||
82 | struct msm_sync { | |
83 | /* These two queues are accessed from a process context only. */ | |
84 | struct hlist_head frame; /* most-frequently accessed */ | |
85 | struct hlist_head stats; | |
86 | ||
87 | /* The message queue is used by the control thread to send commands | |
88 | * to the config thread, and also by the DSP to send messages to the | |
89 | * config thread. Thus it is the only queue that is accessed from | |
90 | * both interrupt and process context. | |
91 | */ | |
92 | spinlock_t msg_event_q_lock; | |
93 | struct list_head msg_event_q; | |
94 | wait_queue_head_t msg_event_wait; | |
95 | ||
96 | /* This queue contains preview frames. It is accessed by the DSP (in | |
97 | * in interrupt context, and by the frame thread. | |
98 | */ | |
99 | spinlock_t prev_frame_q_lock; | |
100 | struct list_head prev_frame_q; | |
101 | wait_queue_head_t prev_frame_wait; | |
102 | int unblock_poll_frame; | |
103 | ||
104 | /* This queue contains snapshot frames. It is accessed by the DSP (in | |
105 | * interrupt context, and by the control thread. | |
106 | */ | |
107 | spinlock_t pict_frame_q_lock; | |
108 | struct list_head pict_frame_q; | |
109 | wait_queue_head_t pict_frame_wait; | |
110 | ||
111 | struct msm_camera_sensor_info *sdata; | |
112 | struct msm_camvfe_fn vfefn; | |
113 | struct msm_sensor_ctrl sctrl; | |
114 | struct platform_device *pdev; | |
115 | uint8_t opencnt; | |
116 | void *cropinfo; | |
117 | int croplen; | |
118 | unsigned pict_pp; | |
119 | ||
120 | const char *apps_id; | |
121 | ||
122 | struct mutex lock; | |
123 | struct list_head list; | |
124 | }; | |
125 | ||
126 | #define MSM_APPS_ID_V4L2 "msm_v4l2" | |
127 | #define MSM_APPS_ID_PROP "msm_qct" | |
128 | ||
129 | struct msm_device { | |
130 | struct msm_sync *sync; /* most-frequently accessed */ | |
131 | struct device *device; | |
132 | struct cdev cdev; | |
133 | /* opened is meaningful only for the config and frame nodes, | |
134 | * which may be opened only once. | |
135 | */ | |
136 | atomic_t opened; | |
137 | }; | |
138 | ||
139 | struct msm_control_device_queue { | |
140 | spinlock_t ctrl_status_q_lock; | |
141 | struct list_head ctrl_status_q; | |
142 | wait_queue_head_t ctrl_status_wait; | |
143 | }; | |
144 | ||
145 | struct msm_control_device { | |
146 | struct msm_device *pmsm; | |
147 | ||
148 | /* This queue used by the config thread to send responses back to the | |
149 | * control thread. It is accessed only from a process context. | |
150 | */ | |
151 | struct msm_control_device_queue ctrl_q; | |
152 | }; | |
153 | ||
154 | /* this structure is used in kernel */ | |
155 | struct msm_queue_cmd { | |
156 | struct list_head list; | |
157 | enum msm_queue type; | |
158 | void *command; | |
159 | }; | |
160 | ||
161 | struct register_address_value_pair { | |
162 | uint16_t register_address; | |
163 | uint16_t register_value; | |
164 | }; | |
165 | ||
166 | struct msm_pmem_region { | |
167 | struct hlist_node list; | |
168 | int type; | |
169 | void *vaddr; | |
170 | unsigned long paddr; | |
171 | unsigned long len; | |
172 | struct file *file; | |
173 | uint32_t y_off; | |
174 | uint32_t cbcr_off; | |
175 | int fd; | |
176 | uint8_t active; | |
177 | }; | |
178 | ||
179 | struct axidata { | |
180 | uint32_t bufnum1; | |
181 | uint32_t bufnum2; | |
182 | struct msm_pmem_region *region; | |
183 | }; | |
184 | ||
185 | #ifdef CONFIG_MSM_CAMERA_FLASH | |
186 | int msm_camera_flash_set_led_state(unsigned led_state); | |
187 | #else | |
188 | static inline int msm_camera_flash_set_led_state(unsigned led_state) | |
189 | { | |
190 | return -ENOTSUPP; | |
191 | } | |
192 | #endif | |
193 | ||
194 | /* Below functions are added for V4L2 kernel APIs */ | |
195 | struct msm_v4l2_driver { | |
196 | struct msm_sync *sync; | |
197 | int (*open)(struct msm_sync *, const char *apps_id); | |
198 | int (*release)(struct msm_sync *); | |
199 | int (*ctrl)(struct msm_sync *, struct msm_ctrl_cmd *); | |
200 | int (*reg_pmem)(struct msm_sync *, struct msm_pmem_info *); | |
201 | int (*get_frame) (struct msm_sync *, struct msm_frame *); | |
202 | int (*put_frame) (struct msm_sync *, struct msm_frame *); | |
203 | int (*get_pict) (struct msm_sync *, struct msm_ctrl_cmd *); | |
204 | unsigned int (*drv_poll) (struct msm_sync *, struct file *, | |
205 | struct poll_table_struct *); | |
206 | }; | |
207 | ||
208 | int msm_v4l2_register(struct msm_v4l2_driver *); | |
209 | int msm_v4l2_unregister(struct msm_v4l2_driver *); | |
210 | ||
211 | void msm_camvfe_init(void); | |
212 | int msm_camvfe_check(void *); | |
213 | void msm_camvfe_fn_init(struct msm_camvfe_fn *, void *); | |
214 | int msm_camera_drv_start(struct platform_device *dev, | |
215 | int (*sensor_probe)(const struct msm_camera_sensor_info *, | |
216 | struct msm_sensor_ctrl *)); | |
217 | ||
218 | enum msm_camio_clk_type { | |
219 | CAMIO_VFE_MDC_CLK, | |
220 | CAMIO_MDC_CLK, | |
221 | CAMIO_VFE_CLK, | |
222 | CAMIO_VFE_AXI_CLK, | |
223 | ||
224 | CAMIO_MAX_CLK | |
225 | }; | |
226 | ||
227 | enum msm_camio_clk_src_type { | |
228 | MSM_CAMIO_CLK_SRC_INTERNAL, | |
229 | MSM_CAMIO_CLK_SRC_EXTERNAL, | |
230 | MSM_CAMIO_CLK_SRC_MAX | |
231 | }; | |
232 | ||
233 | enum msm_s_test_mode { | |
234 | S_TEST_OFF, | |
235 | S_TEST_1, | |
236 | S_TEST_2, | |
237 | S_TEST_3 | |
238 | }; | |
239 | ||
240 | enum msm_s_resolution { | |
241 | S_QTR_SIZE, | |
242 | S_FULL_SIZE, | |
243 | S_INVALID_SIZE | |
244 | }; | |
245 | ||
246 | enum msm_s_reg_update { | |
247 | /* Sensor egisters that need to be updated during initialization */ | |
248 | S_REG_INIT, | |
249 | /* Sensor egisters that needs periodic I2C writes */ | |
250 | S_UPDATE_PERIODIC, | |
251 | /* All the sensor Registers will be updated */ | |
252 | S_UPDATE_ALL, | |
253 | /* Not valid update */ | |
254 | S_UPDATE_INVALID | |
255 | }; | |
256 | ||
257 | enum msm_s_setting { | |
258 | S_RES_PREVIEW, | |
259 | S_RES_CAPTURE | |
260 | }; | |
261 | ||
262 | int msm_camio_enable(struct platform_device *dev); | |
263 | ||
264 | int msm_camio_clk_enable(enum msm_camio_clk_type clk); | |
265 | int msm_camio_clk_disable(enum msm_camio_clk_type clk); | |
266 | int msm_camio_clk_config(uint32_t freq); | |
267 | void msm_camio_clk_rate_set(int rate); | |
268 | void msm_camio_clk_axi_rate_set(int rate); | |
269 | ||
270 | void msm_camio_camif_pad_reg_reset(void); | |
271 | void msm_camio_camif_pad_reg_reset_2(void); | |
272 | ||
273 | void msm_camio_vfe_blk_reset(void); | |
274 | ||
275 | void msm_camio_clk_sel(enum msm_camio_clk_src_type); | |
276 | void msm_camio_disable(struct platform_device *); | |
277 | int msm_camio_probe_on(struct platform_device *); | |
278 | int msm_camio_probe_off(struct platform_device *); | |
279 | #endif |