2 * Copyright (C) 2008-2009 QUALCOMM Incorporated.
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)
20 #define CDBG(fmt, args...) do { } while (0)
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
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 */
47 struct msm_vfe_phy_info
{
54 enum vfe_resp_msg type
;
55 struct msm_vfe_evt_msg evt_msg
;
56 struct msm_vfe_phy_info phy
;
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
*);
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
;
123 struct list_head list
;
126 #define MSM_APPS_ID_V4L2 "msm_v4l2"
127 #define MSM_APPS_ID_PROP "msm_qct"
130 struct msm_sync
*sync
; /* most-frequently accessed */
131 struct device
*device
;
133 /* opened is meaningful only for the config and frame nodes,
134 * which may be opened only once.
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
;
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
;
182 struct msm_pmem_region
*region
;
185 #ifdef CONFIG_MSM_CAMERA_FLASH
186 int msm_camera_flash_set_led_state(unsigned led_state
);
188 static inline int msm_camera_flash_set_led_state(unsigned led_state
)
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
{
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
{
240 enum msm_s_resolution
{
246 enum msm_s_reg_update
{
247 /* Sensor egisters that need to be updated during initialization */
249 /* Sensor egisters that needs periodic I2C writes */
251 /* All the sensor Registers will be updated */
253 /* Not valid update */
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
*);