camera driver v0.2.1 for RK30
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / include / mach / rk_camera.h
1 /*
2     camera.h - PXA camera driver header file
3
4     Copyright (C) 2003, Intel Corporation
5     Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
6
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.
11
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.
16
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.
20 */
21
22 #ifndef __ASM_ARCH_CAMERA_H_
23 #define __ASM_ARCH_CAMERA_H_
24
25 #include <linux/videodev2.h>
26 #include <media/soc_camera.h>
27 #define RK_CAM_DRV_NAME "rkxx-camera"
28 #define RK_CAM_PLATFORM_DEV_ID_0 33
29 #define RK_CAM_PLATFORM_DEV_ID_1 (RK_CAM_PLATFORM_DEV_ID_0+1)
30 #define INVALID_GPIO -1
31 #define INVALID_VALUE -1
32 #define RK_CAM_IO_SUCCESS 0
33 #define RK_CAM_EIO_INVALID -1
34 #define RK_CAM_EIO_REQUESTFAIL -2
35
36 #define RK_CAM_NUM_PER_HOST 2
37 /*---------------- Camera Sensor Must Define Macro Begin  ------------------------*/
38 #define RK_CAM_SENSOR_OV7675 ov7675
39 #define RK_CAM_SENSOR_OV9650 ov9650
40 #define RK_CAM_SENSOR_OV2640 ov2640
41 #define RK_CAM_SENSOR_OV2655 ov2655
42 #define RK_CAM_SENSOR_OV2659 ov2659
43 #define RK_CAM_SENSOR_OV7690 ov7690
44 #define RK_CAM_SENSOR_OV3640 ov3640
45 #define RK_CAM_SENSOR_OV5640 ov5640
46 #define RK_CAM_SENSOR_OV5642 ov5642
47 #define RK_CAM_SENSOR_S5K6AA s5k6aa
48 #define RK_CAM_SENSOR_MT9D112 mt9d112
49 #define RK_CAM_SENSOR_MT9D113 mt9d113
50 #define RK_CAM_SENSOR_MT9P111 mt9p111
51 #define RK_CAM_SENSOR_MT9T111 mt9t111
52 #define RK_CAM_SENSOR_GT2005  gt2005
53 #define RK_CAM_SENSOR_GC0307  gc0307
54 #define RK_CAM_SENSOR_GC0308  gc0308
55 #define RK_CAM_SENSOR_GC0309  gc0309
56 #define RK_CAM_SENSOR_GC2015  gc2015
57 #define RK_CAM_SENSOR_SIV120B  siv120b
58 #define RK_CAM_SENSOR_SID130B  sid130B
59 #define RK_CAM_SENSOR_HI253  hi253
60 #define RK_CAM_SENSOR_HI704  hi704
61 #define RK_CAM_SENSOR_NT99250 nt99250
62
63 #define RK_CAM_SENSOR_NAME_OV7675 "ov7675"
64 #define RK_CAM_SENSOR_NAME_OV9650 "ov9650"
65 #define RK_CAM_SENSOR_NAME_OV2640 "ov2640"
66 #define RK_CAM_SENSOR_NAME_OV2655 "ov2655"
67 #define RK_CAM_SENSOR_NAME_OV2659 "ov2659"
68 #define RK_CAM_SENSOR_NAME_OV7690 "ov7690"
69 #define RK_CAM_SENSOR_NAME_OV3640 "ov3640"
70 #define RK_CAM_SENSOR_NAME_OV5640 "ov5640"
71 #define RK_CAM_SENSOR_NAME_OV5642 "ov5642"
72 #define RK_CAM_SENSOR_NAME_S5K6AA "s5k6aa"
73 #define RK_CAM_SENSOR_NAME_MT9D112 "mt9d112"
74 #define RK_CAM_SENSOR_NAME_MT9D113 "mt9d113"
75 #define RK_CAM_SENSOR_NAME_MT9P111 "mt9p111"
76 #define RK_CAM_SENSOR_NAME_MT9T111 "mt9t111"
77 #define RK_CAM_SENSOR_NAME_GT2005  "gt2005"
78 #define RK_CAM_SENSOR_NAME_GC0307  "gc0307"
79 #define RK_CAM_SENSOR_NAME_GC0308  "gc0308"
80 #define RK_CAM_SENSOR_NAME_GC0309  "gc0309"
81 #define RK_CAM_SENSOR_NAME_GC2015  "gc2015"
82 #define RK_CAM_SENSOR_NAME_SIV120B "siv120b"
83 #define RK_CAM_SENSOR_NAME_SID130B "sid130B"
84 #define RK_CAM_SENSOR_NAME_HI253  "hi253"
85 #define RK_CAM_SENSOR_NAME_HI704  "hi704"
86 #define RK_CAM_SENSOR_NAME_NT99250 "nt99250"
87
88 #define ov7675_FULL_RESOLUTION     0x30000            // 0.3 megapixel
89 #define ov9650_FULL_RESOLUTION     0x130000           // 1.3 megapixel   
90 #define ov2640_FULL_RESOLUTION     0x200000           // 2 megapixel
91 #define ov2655_FULL_RESOLUTION     0x200000           // 2 megapixel
92 #define ov2659_FULL_RESOLUTION     0x200000           // 2 megapixel
93 #define ov7690_FULL_RESOLUTION     0x300000           // 2 megapixel
94 #define ov3640_FULL_RESOLUTION     0x300000           // 3 megapixel
95 #define ov5640_FULL_RESOLUTION     0x500000           // 5 megapixel
96 #define ov5642_FULL_RESOLUTION     0x500000           // 5 megapixel
97 #define s5k6aa_FULL_RESOLUTION     0x130000           // 1.3 megapixel
98 #define mt9d112_FULL_RESOLUTION    0x200000           // 2 megapixel
99 #define mt9d113_FULL_RESOLUTION    0x200000           // 2 megapixel
100 #define mt9t111_FULL_RESOLUTION    0x300000           // 3 megapixel
101 #define mt9p111_FULL_RESOLUTION    0x500000           // 5 megapixel
102 #define gt2005_FULL_RESOLUTION     0x200000           // 2 megapixel
103 #define gc0308_FULL_RESOLUTION     0x30000            // 0.3 megapixel
104 #define gc0309_FULL_RESOLUTION     0x30000            // 0.3 megapixel
105 #define gc2015_FULL_RESOLUTION     0x200000           // 2 megapixel
106 #define siv120b_FULL_RESOLUTION     0x30000            // 0.3 megapixel
107 #define sid130B_FULL_RESOLUTION     0x200000           // 2 megapixel    
108 #define hi253_FULL_RESOLUTION       0x200000           // 2 megapixel
109 #define hi704_FULL_RESOLUTION       0x30000            // 0.3 megapixel
110 #define nt99250_FULL_RESOLUTION     0x200000           // 2 megapixel
111 /*---------------- Camera Sensor Must Define Macro End  ------------------------*/
112
113
114 #define RK_CAM_POWERACTIVE_BITPOS       0x00
115 #define RK_CAM_POWERACTIVE_MASK (1<<RK_CAM_POWERACTIVE_BITPOS)
116 #define RK_CAM_POWERACTIVE_H    (0x01<<RK_CAM_POWERACTIVE_BITPOS)
117 #define RK_CAM_POWERACTIVE_L    (0x00<<RK_CAM_POWERACTIVE_BITPOS)
118
119 #define RK_CAM_RESETACTIVE_BITPOS       0x01
120 #define RK_CAM_RESETACTIVE_MASK (1<<RK_CAM_RESETACTIVE_BITPOS)
121 #define RK_CAM_RESETACTIVE_H    (0x01<<RK_CAM_RESETACTIVE_BITPOS)
122 #define RK_CAM_RESETACTIVE_L  (0x00<<RK_CAM_RESETACTIVE_BITPOS)
123
124 #define RK_CAM_POWERDNACTIVE_BITPOS     0x02
125 #define RK_CAM_POWERDNACTIVE_MASK       (1<<RK_CAM_POWERDNACTIVE_BITPOS)
126 #define RK_CAM_POWERDNACTIVE_H  (0x01<<RK_CAM_POWERDNACTIVE_BITPOS)
127 #define RK_CAM_POWERDNACTIVE_L  (0x00<<RK_CAM_POWERDNACTIVE_BITPOS)
128
129 #define RK_CAM_FLASHACTIVE_BITPOS       0x03
130 #define RK_CAM_FLASHACTIVE_MASK (1<<RK_CAM_FLASHACTIVE_BITPOS)
131 #define RK_CAM_FLASHACTIVE_H    (0x01<<RK_CAM_FLASHACTIVE_BITPOS)
132 #define RK_CAM_FLASHACTIVE_L  (0x00<<RK_CAM_FLASHACTIVE_BITPOS)
133
134 /* v4l2_subdev_core_ops.ioctl  ioctl_cmd macro */
135 #define RK_CAM_SUBDEV_ACTIVATE            0x00
136 #define RK_CAM_SUBDEV_DEACTIVATE          0x01
137 #define RK_CAM_SUBDEV_IOREQUEST                 0x02
138 #define RK_CAM_SUBDEV_CB_REGISTER         0x03
139
140 enum rkcamera_ioctrl_cmd
141 {
142         Cam_Power,
143         Cam_Reset,
144         Cam_PowerDown,
145         Cam_Flash
146 };
147
148 enum rksensor_power_cmd
149 {
150         Sensor_Reset,
151         Sensor_PowerDown,
152         Sensor_Flash
153 };
154
155 enum rkcamera_flash_cmd
156 {
157     Flash_Off,
158     Flash_On,
159     Flash_Torch
160 };
161
162 struct rkcamera_gpio_res {
163         unsigned int gpio_reset;
164         unsigned int gpio_power;
165         unsigned int gpio_powerdown;
166         unsigned int gpio_flash;
167         unsigned int gpio_flag;
168         unsigned int gpio_init;
169         const char *dev_name;
170 };
171
172 struct rkcamera_mem_res {
173         const char *name;
174         unsigned int start;
175         unsigned int size;
176 };
177 struct rkcamera_info {
178     const char *dev_name;
179     unsigned int orientation;
180     struct v4l2_frmivalenum fival[10];
181 };
182
183 struct reginfo_t
184 {
185         u16 reg;
186         u16 val;
187         u16 reg_len;
188         u16 rev;
189 };
190 typedef struct rk_sensor_user_init_data{
191         int rk_sensor_init_width;
192         int rk_sensor_init_height;
193         unsigned long rk_sensor_init_bus_param;
194         enum v4l2_mbus_pixelcode rk_sensor_init_pixelcode;
195         struct reginfo_t * rk_sensor_init_data;
196         int rk_sensor_winseq_size;
197         struct reginfo_t * rk_sensor_init_winseq;
198 }rk_sensor_user_init_data_s;
199 struct rkcamera_platform_data {
200         int (*io_init)(int);
201         int (*io_deinit)(int);
202         int (*sensor_ioctrl)(struct device *dev,enum rkcamera_ioctrl_cmd cmd,int on);
203         rk_sensor_user_init_data_s* sensor_init_data[RK_CAM_NUM_PER_HOST];
204         struct rkcamera_gpio_res gpio_res[RK_CAM_NUM_PER_HOST];
205         struct rkcamera_mem_res meminfo;
206         struct rkcamera_info info[RK_CAM_NUM_PER_HOST];
207 };
208
209 struct rkcamera_platform_ioctl_cb {
210     int (*sensor_power_cb)(struct rkcamera_gpio_res *res, int on);
211     int (*sensor_reset_cb)(struct rkcamera_gpio_res *res, int on);
212     int (*sensor_powerdown_cb)(struct rkcamera_gpio_res *res, int on);
213     int (*sensor_flash_cb)(struct rkcamera_gpio_res *res, int on);    
214 };
215
216 typedef struct rk_camera_sensor_cb {
217     int (*sensor_cb)(void *arg); 
218 }rk_camera_sensor_cb_s;
219
220
221 #endif /* __ASM_ARCH_CAMERA_H_ */
222