]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - include/media/ov5693.h
e8f94859cef475aa5657d8c7e5ea1c49803fe4a6
[hercules2020/nv-tegra/linux-4.4.git] / include / media / ov5693.h
1 /*
2  * Copyright (c) 2013-2015, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 #ifndef __OV5693_H__
18 #define __OV5693_H__
19
20 #include <media/nvc.h>
21 #include <media/nvc_image.h>
22
23 #define OV5693_IOCTL_SET_MODE               _IOW('o', 1, struct ov5693_mode)
24 #define OV5693_IOCTL_SET_FRAME_LENGTH       _IOW('o', 2, __u32)
25 #define OV5693_IOCTL_SET_COARSE_TIME        _IOW('o', 3, __u32)
26 #define OV5693_IOCTL_SET_GAIN               _IOW('o', 4, __u16)
27 #define OV5693_IOCTL_GET_STATUS             _IOR('o', 5, __u8)
28 #define OV5693_IOCTL_SET_BINNING            _IOW('o', 6, __u8)
29 #define OV5693_IOCTL_TEST_PATTERN           _IOW('o', 7, \
30                                                  enum ov5693_test_pattern)
31 #define OV5693_IOCTL_SET_GROUP_HOLD         _IOW('o', 8, struct ov5693_ae)
32 /* IOCTL to set the operating mode of camera.
33  * This can be either stereo , leftOnly or rightOnly */
34 #define OV5693_IOCTL_SET_CAMERA_MODE        _IOW('o', 10, __u32)
35 #define OV5693_IOCTL_SYNC_SENSORS           _IOW('o', 11, __u32)
36 #define OV5693_IOCTL_GET_FUSEID             _IOR('o', 12, struct nvc_fuseid)
37 #define OV5693_IOCTL_SET_HDR_COARSE_TIME    _IOW('o', 13, struct ov5693_hdr)
38 #define OV5693_IOCTL_READ_OTP_BANK          _IOWR('o', 14, \
39                                                 struct ov5693_otp_bank)
40 #define OV5693_IOCTL_SET_CAL_DATA           _IOW('o', 15, \
41                                                 struct ov5693_cal_data)
42 #define OV5693_IOCTL_GET_EEPROM_DATA        _IOR('o', 20, __u8 *)
43 #define OV5693_IOCTL_SET_EEPROM_DATA        _IOW('o', 21, __u8 *)
44 #define OV5693_IOCTL_GET_CAPS               _IOR('o', 22, struct nvc_imager_cap)
45 #define OV5693_IOCTL_SET_POWER              _IOW('o', 23, __u32)
46
47 #define OV5693_INVALID_COARSE_TIME  -1
48
49 #define OV5693_EEPROM_ADDRESS           0x50
50 #define OV5693_EEPROM_SIZE              1024
51 #define OV5693_EEPROM_STR_SIZE          (OV5693_EEPROM_SIZE * 2)
52 #define OV5693_EEPROM_BLOCK_SIZE        (1 << 8)
53 #define OV5693_EEPROM_NUM_BLOCKS \
54         (OV5693_EEPROM_SIZE / OV5693_EEPROM_BLOCK_SIZE)
55
56 #define OV5693_OTP_LOAD_CTRL_ADDR       0x3D81
57 #define OV5693_OTP_BANK_SELECT_ADDR     0x3D84
58 #define OV5693_OTP_BANK_START_ADDR      0x3D00
59 #define OV5693_OTP_BANK_END_ADDR        0x3D0F
60 #define OV5693_OTP_NUM_BANKS            (32)
61 #define OV5693_OTP_BANK_SIZE \
62          (OV5693_OTP_BANK_END_ADDR - OV5693_OTP_BANK_START_ADDR + 1)
63 #define OV5693_OTP_SIZE \
64          (OV5693_OTP_BANK_SIZE * OV5693_OTP_NUM_BANKS)
65 #define OV5693_OTP_STR_SIZE (OV5693_OTP_SIZE * 2)
66
67 #define OV5693_FUSE_ID_OTP_START_ADDR   0x3D00
68 #define OV5693_FUSE_ID_OTP_BANK 0
69 #define OV5693_FUSE_ID_SIZE             8
70 #define OV5693_FUSE_ID_STR_SIZE (OV5693_FUSE_ID_SIZE * 2)
71
72 #define OV5693_FRAME_LENGTH_ADDR_MSB            0x380E
73 #define OV5693_FRAME_LENGTH_ADDR_LSB            0x380F
74 #define OV5693_COARSE_TIME_ADDR_1               0x3500
75 #define OV5693_COARSE_TIME_ADDR_2               0x3501
76 #define OV5693_COARSE_TIME_ADDR_3               0x3502
77 #define OV5693_COARSE_TIME_SHORT_ADDR_1 0x3506
78 #define OV5693_COARSE_TIME_SHORT_ADDR_2 0x3507
79 #define OV5693_COARSE_TIME_SHORT_ADDR_3 0x3508
80 #define OV5693_GAIN_ADDR_MSB                    0x350A
81 #define OV5693_GAIN_ADDR_LSB                    0x350B
82 #define OV5693_GROUP_HOLD_ADDR                  0x3208
83
84 struct ov5693_mode {
85         int res_x;
86         int res_y;
87         int fps;
88         __u32 frame_length;
89         __u32 coarse_time;
90         __u32 coarse_time_short;
91         __u16 gain;
92         __u8 hdr_en;
93 };
94
95 struct ov5693_ae {
96         __u32 frame_length;
97         __u8  frame_length_enable;
98         __u32 coarse_time;
99         __u32 coarse_time_short;
100         __u8  coarse_time_enable;
101         __s32 gain;
102         __u8  gain_enable;
103 };
104
105 struct ov5693_fuseid {
106         __u32 size;
107         __u8  id[16];
108 };
109
110 struct ov5693_hdr {
111         __u32 coarse_time_long;
112         __u32 coarse_time_short;
113 };
114
115 struct ov5693_otp_bank {
116         __u32 id;
117         __u8  buf[16];
118 };
119
120 struct ov5693_cal_data {
121         int loaded;
122         int rg_ratio;
123         int bg_ratio;
124         int rg_ratio_typical;
125         int bg_ratio_typical;
126         __u8 lenc[62];
127 };
128
129 /* See notes in the nvc.h file on the GPIO usage */
130 enum ov5693_gpio_type {
131         OV5693_GPIO_TYPE_PWRDN = 0,
132         OV5693_GPIO_TYPE_RESET,
133 };
134
135 struct ov5693_eeprom_data {
136         struct i2c_client *i2c_client;
137         struct i2c_adapter *adap;
138         struct i2c_board_info brd;
139         struct regmap *regmap;
140 };
141
142 struct ov5693_power_rail {
143         struct regulator *dvdd;
144         struct regulator *avdd;
145         struct regulator *dovdd;
146 };
147
148 struct ov5693_regulators {
149         const char *avdd;
150         const char *dvdd;
151         const char *dovdd;
152 };
153
154 struct ov5693_platform_data {
155         unsigned cfg;
156         unsigned num;
157         const char *dev_name;
158         unsigned gpio_count; /* see nvc.h GPIO notes */
159         struct nvc_gpio_pdata *gpio; /* see nvc.h GPIO notes */
160         struct nvc_imager_static_nvc *static_info;
161         bool use_vcm_vdd;
162         int (*probe_clock)(unsigned long);
163         int (*power_on)(struct ov5693_power_rail *);
164         int (*power_off)(struct ov5693_power_rail *);
165         const char *mclk_name;
166         struct nvc_imager_cap *cap;
167         struct ov5693_regulators regulators;
168         bool has_eeprom;
169         bool use_cam_gpio;
170 };
171
172 #endif  /* __OV5693_H__ */