2 camera.h - PXA camera driver header file
4 Copyright (C) 2003, Intel Corporation
5 Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef __ASM_ARCH_CAMERA_RK_H_
23 #define __ASM_ARCH_CAMERA_RK_H_
25 #include <linux/videodev2.h>
26 #include <media/soc_camera.h>
27 #include <linux/i2c.h>
28 #include <linux/platform_device.h>
29 #include "rk_camera_sensor_info.h"
31 #define RK29_CAM_PLATFORM_DEV_ID 33
32 #define RK_CAM_PLATFORM_DEV_ID_0 RK29_CAM_PLATFORM_DEV_ID
33 #define RK_CAM_PLATFORM_DEV_ID_1 (RK_CAM_PLATFORM_DEV_ID_0+1)
34 #define INVALID_VALUE -1
36 #define INVALID_GPIO INVALID_VALUE
38 #define RK29_CAM_IO_SUCCESS 0
39 #define RK29_CAM_EIO_INVALID -3
40 #define RK29_CAM_EIO_REQUESTFAIL -2
42 #define RK29_CAM_POWERACTIVE_BITPOS 0x00
43 #define RK29_CAM_RESETACTIVE_BITPOS 0x01
44 #define RK29_CAM_POWERDNACTIVE_BITPOS 0x02
45 #define RK29_CAM_FLASHACTIVE_BITPOS 0x03
46 #define RK29_CAM_AFACTIVE_BITPOS 0x04
48 #define RK_CAM_SUPPORT_RESOLUTION 0x800000
50 #define _CONS(a,b) a##b
51 #define CONS(a,b) _CONS(a,b)
53 #define _CONS4(a,b,c,d) a##b##c##d
54 #define CONS4(a,b,c,d) _CONS4(a,b,c,d)
57 #define _STR(x) __STR(x)
58 #define STR(x) _STR(x)
61 /*---------------- Camera Sensor Must Define Macro Begin ------------------------*/
63 move to rk_camera_sensor_info.h yzm
65 /*---------------- Camera Sensor Must Define Macro End ------------------------*/
68 //#define RK29_CAM_POWERACTIVE_BITPOS 0x00
69 #define RK29_CAM_POWERACTIVE_MASK (1<<RK29_CAM_POWERACTIVE_BITPOS)
70 #define RK29_CAM_POWERACTIVE_H (0x01<<RK29_CAM_POWERACTIVE_BITPOS)
71 #define RK29_CAM_POWERACTIVE_L (0x00<<RK29_CAM_POWERACTIVE_BITPOS)
73 //#define RK29_CAM_RESETACTIVE_BITPOS 0x01
74 #define RK29_CAM_RESETACTIVE_MASK (1<<RK29_CAM_RESETACTIVE_BITPOS)
75 #define RK29_CAM_RESETACTIVE_H (0x01<<RK29_CAM_RESETACTIVE_BITPOS)
76 #define RK29_CAM_RESETACTIVE_L (0x00<<RK29_CAM_RESETACTIVE_BITPOS)
78 //#define RK29_CAM_POWERDNACTIVE_BITPOS 0x02
79 #define RK29_CAM_POWERDNACTIVE_MASK (1<<RK29_CAM_POWERDNACTIVE_BITPOS)
80 #define RK29_CAM_POWERDNACTIVE_H (0x01<<RK29_CAM_POWERDNACTIVE_BITPOS)
81 #define RK29_CAM_POWERDNACTIVE_L (0x00<<RK29_CAM_POWERDNACTIVE_BITPOS)
83 //#define RK29_CAM_FLASHACTIVE_BITPOS 0x03
84 #define RK29_CAM_FLASHACTIVE_MASK (1<<RK29_CAM_FLASHACTIVE_BITPOS)
85 #define RK29_CAM_FLASHACTIVE_H (0x01<<RK29_CAM_FLASHACTIVE_BITPOS)
86 #define RK29_CAM_FLASHACTIVE_L (0x00<<RK29_CAM_FLASHACTIVE_BITPOS)
89 //#define RK29_CAM_AFACTIVE_BITPOS 0x04
90 #define RK29_CAM_AFACTIVE_MASK (1<<RK29_CAM_AFACTIVE_BITPOS)
91 #define RK29_CAM_AFACTIVE_H (0x01<<RK29_CAM_AFACTIVE_BITPOS)
92 #define RK29_CAM_AFACTIVE_L (0x00<<RK29_CAM_AFACTIVE_BITPOS)
96 #define RK_CAM_SCALE_CROP_ARM 0
97 #define RK_CAM_SCALE_CROP_IPP 1
98 #define RK_CAM_SCALE_CROP_RGA 2
99 #define RK_CAM_SCALE_CROP_PP 3
101 #define RK_CAM_INPUT_FMT_YUV422 (1<<0)
102 #define RK_CAM_INPUT_FMT_RAW10 (1<<1)
103 #define RK_CAM_INPUT_FMT_RAW12 (1<<2)
105 /* v4l2_subdev_core_ops.ioctl ioctl_cmd macro */
106 #define RK29_CAM_SUBDEV_ACTIVATE 0x00
107 #define RK29_CAM_SUBDEV_DEACTIVATE 0x01
108 #define RK29_CAM_SUBDEV_IOREQUEST 0x02
109 #define RK29_CAM_SUBDEV_CB_REGISTER 0x03
111 #define Sensor_HasBeen_PwrOff(a) (a&0x01)
112 #define Sensor_Support_DirectResume(a) ((a&0x10)==0x10)
114 #define Sensor_CropSet(a,b) a->reserved[1] = b;
115 #define Sensor_CropGet(a) a->reserved[1]
117 #define RK29_CAM_SUBDEV_HDR_EXPOSURE 0x04
119 #define RK_VIDEOBUF_HDR_EXPOSURE_MINUS_1 0x00
120 #define RK_VIDEOBUF_HDR_EXPOSURE_NORMAL 0x01
121 #define RK_VIDEOBUF_HDR_EXPOSURE_PLUS_1 0x02
122 #define RK_VIDEOBUF_HDR_EXPOSURE_FINISH 0x03
123 #define RK_VIDEOBUF_CODE_SET(rk_code,type) rk_code = (('R'<<24)|('K'<<16)|type)
124 #define RK_VIDEOBUF_CODE_CHK(rk_code) ((rk_code&(('R'<<24)|('K'<<16)))==(('R'<<24)|('K'<<16)))
126 enum rk29camera_ioctrl_cmd
136 enum rk29sensor_power_cmd
145 enum rk29camera_flash_cmd
152 struct rk29camera_gpio_res {
153 unsigned int gpio_reset;
154 unsigned int gpio_power;
155 unsigned int gpio_powerdown;
156 unsigned int gpio_flash;
157 unsigned int gpio_af;
158 unsigned int gpio_flag;
159 unsigned int gpio_init;
160 const char *dev_name;
163 struct rk29camera_mem_res {
167 void __iomem *vbase; //Ö¸ÏòIO¿Õ¼äµÄÖ¸Õ룬ΪÁËÇý¶¯³ÌÐòµÄͨÓÃÐÔ¿¼ÂÇ
169 struct rk29camera_info {
170 const char *dev_name;
171 unsigned int orientation;
172 struct v4l2_frmivalenum fival[10];
182 typedef struct rk_sensor_user_init_data{
183 int rk_sensor_init_width;
184 int rk_sensor_init_height;
185 unsigned long rk_sensor_init_bus_param;
186 enum v4l2_mbus_pixelcode rk_sensor_init_pixelcode;
187 struct reginfo_t * rk_sensor_init_data;
188 int rk_sensor_winseq_size;
189 struct reginfo_t * rk_sensor_init_winseq;
190 int rk_sensor_init_data_size;
191 }rk_sensor_user_init_data_s;
193 typedef struct rk_camera_device_register_info {
194 struct i2c_board_info i2c_cam_info;
195 struct soc_camera_desc desc_info;/*yzm*/
196 struct platform_device device_info;
197 }rk_camera_device_register_info_t;
199 struct rkcamera_platform_data {
200 rk_camera_device_register_info_t dev;
202 struct rk29camera_gpio_res io;
205 int mirror; /* bit0: 0: mirror off
210 int i2c_rate; /* 100KHz = 100000 */
211 bool flash; /* true: the sensor attached flash;
212 false: the sensor haven't attach flash;
215 int pwdn_info; /* bit4: 1: sensor isn't need to be init after exit stanby, it can streaming directly
216 0: sensor must be init after exit standby;
218 bit0: 1: sensor power have been turn off;
219 0: sensor power is always on;
222 long powerup_sequence; /*
223 bit0-bit3 --- power up sequence first step;
224 bit4-bit7 --- power up sequence second step;
227 int mclk_rate; /* MHz : 24/48 */
228 int fov_h; /* fied of view horizontal */
229 int fov_v; /* fied of view vertical */
230 const char *power_pmu_name1;
231 const char *power_pmu_name2;
232 const char *powerdown_pmu_name;
233 int power_pmu_voltage1;
234 int power_pmu_voltage2;
235 int powerdown_pmu_voltage;
236 struct device_node *of_node;
237 struct rkcamera_platform_data *next_camera;/*yzm*/
241 struct rk29camera_platform_data {
242 int (*io_init)(void);
243 int (*io_deinit)(int sensor);
244 int (*sensor_ioctrl)(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
246 int (*sensor_register)(void);
247 int (*sensor_mclk)(int cif_idx, int on, int clk_rate);
249 struct rkcamera_platform_data *register_dev_new; //sensor
250 struct device *cif_dev;/*yzm host*/
251 const char *rockchip_name;
255 struct rk29camera_platform_ioctl_cb {
256 int (*sensor_power_cb)(struct rk29camera_gpio_res *res, int on);
257 int (*sensor_reset_cb)(struct rk29camera_gpio_res *res, int on);
258 int (*sensor_powerdown_cb)(struct rk29camera_gpio_res *res, int on);
259 int (*sensor_flash_cb)(struct rk29camera_gpio_res *res, int on);
260 int (*sensor_af_cb)(struct rk29camera_gpio_res *res, int on);
263 typedef struct rk29_camera_sensor_cb {
264 int (*sensor_cb)(void *arg);
265 int (*scale_crop_cb)(struct work_struct *work);
266 }rk29_camera_sensor_cb_s;
268 #endif /* __ASM_ARCH_CAMERA_H_ */