Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / dream / include / mach / camera.h
blobc20f0423abd47059969bba43b5a222470a341501
1 /*
2 * Copyright (C) 2008-2009 QUALCOMM Incorporated.
3 */
5 #ifndef __ASM__ARCH_CAMERA_H
6 #define __ASM__ARCH_CAMERA_H
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"
14 #include <mach/board.h>
15 #include <media/msm_camera.h>
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
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
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 */
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,
47 struct msm_vfe_phy_info {
48 uint32_t sbuf_phy;
49 uint32_t y_phy;
50 uint32_t cbcr_phy;
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;
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);
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 *);
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 *);
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;
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.
92 spinlock_t msg_event_q_lock;
93 struct list_head msg_event_q;
94 wait_queue_head_t msg_event_wait;
96 /* This queue contains preview frames. It is accessed by the DSP (in
97 * in interrupt context, and by the frame thread.
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;
104 /* This queue contains snapshot frames. It is accessed by the DSP (in
105 * interrupt context, and by the control thread.
107 spinlock_t pict_frame_q_lock;
108 struct list_head pict_frame_q;
109 wait_queue_head_t pict_frame_wait;
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;
120 const char *apps_id;
122 struct mutex lock;
123 struct list_head list;
126 #define MSM_APPS_ID_V4L2 "msm_v4l2"
127 #define MSM_APPS_ID_PROP "msm_qct"
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.
136 atomic_t opened;
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;
145 struct msm_control_device {
146 struct msm_device *pmsm;
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.
151 struct msm_control_device_queue ctrl_q;
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;
161 struct register_address_value_pair {
162 uint16_t register_address;
163 uint16_t register_value;
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;
179 struct axidata {
180 uint32_t bufnum1;
181 uint32_t bufnum2;
182 struct msm_pmem_region *region;
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)
190 return -ENOTSUPP;
192 #endif
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 *);
208 int msm_v4l2_register(struct msm_v4l2_driver *);
209 int msm_v4l2_unregister(struct msm_v4l2_driver *);
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 *));
218 enum msm_camio_clk_type {
219 CAMIO_VFE_MDC_CLK,
220 CAMIO_MDC_CLK,
221 CAMIO_VFE_CLK,
222 CAMIO_VFE_AXI_CLK,
224 CAMIO_MAX_CLK
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
233 enum msm_s_test_mode {
234 S_TEST_OFF,
235 S_TEST_1,
236 S_TEST_2,
237 S_TEST_3
240 enum msm_s_resolution {
241 S_QTR_SIZE,
242 S_FULL_SIZE,
243 S_INVALID_SIZE
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
257 enum msm_s_setting {
258 S_RES_PREVIEW,
259 S_RES_CAPTURE
262 int msm_camio_enable(struct platform_device *dev);
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);
270 void msm_camio_camif_pad_reg_reset(void);
271 void msm_camio_camif_pad_reg_reset_2(void);
273 void msm_camio_vfe_blk_reset(void);
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