Readd MT9V111 and MT9V011 (6270)
[microdia.git] / microdia-dev.c
blob74d2780801bcdea589dc9339398b8088a5c00d62
1 /**
2 * @file microdia-dev.c
3 * @author Nicolas VIVIEN
4 * @date 2008-02-01
6 * @brief Device specific functions
8 * @note Copyright (C) Nicolas VIVIEN
10 * @par Licences
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/errno.h>
28 #include <linux/string.h>
29 #include <stdarg.h>
31 #include "microdia.h"
32 #include "sn9c20x.h"
33 #include "ov7670.h"
34 #include "ov965x.h"
35 #include "mt9vx11.h"
36 #include "ov7660.h"
38 struct sensor_info sensors[] = {
40 .id = OV9650_SENSOR,
41 .name = "OV9650",
42 .probe = ov_probe
45 .id = OV9655_SENSOR,
46 .name = "OV9655",
47 .probe = ov_probe
50 .id = SOI968_SENSOR,
51 .name = "SOI968",
52 .probe = ov_probe
55 .id = OV7660_SENSOR,
56 .name = "OV7660",
57 .probe = ov_probe
60 .id = OV7670_SENSOR,
61 .name = "OV7670",
62 .probe = ov_probe
65 .id = MT9M111_SENSOR,
66 .name = "MT9M111",
67 .probe = mt9m111_probe
70 .id = MT9V111_SENSOR,
71 .name = "MT9V111",
72 .probe = mt9v111_probe
75 .id = MT9V011_SENSOR,
76 .name = "MT9V011",
77 .probe = mt9v011_probe
81 /**
82 * @brief Wrapper function for camera-setting functions
84 * @param dev Pointer to device structure
86 * @returns 0
88 int dev_microdia_camera_settings(struct usb_microdia *dev)
90 dev_microdia_camera_set_contrast(dev);
91 dev_microdia_camera_set_brightness(dev);
92 dev_microdia_camera_set_gamma(dev);
93 dev_microdia_camera_set_exposure(dev);
94 dev_microdia_camera_set_hvflip(dev);
95 dev_microdia_camera_set_sharpness(dev);
96 dev_microdia_camera_set_rgb_gain(dev);
97 dev_microdia_camera_set_auto_exposure(dev);
98 dev_microdia_camera_set_auto_whitebalance(dev);
99 return 0;
103 * @brief Wrapper function for device-specific contrast functions
105 * @param dev Pointer to device structure
107 * @returns 0 or negative error value
110 int dev_microdia_camera_set_contrast(struct usb_microdia *dev)
112 int ret = -ENODEV;
113 if (dev && dev->camera.set_contrast)
114 ret = dev->camera.set_contrast(dev);
115 return ret;
119 * @brief Wrapper function for device-specific brightness functions
121 * @param dev Pointer to device structure
123 * @returns 0 or negative error value
126 int dev_microdia_camera_set_brightness(struct usb_microdia *dev)
128 int ret = -ENODEV;
129 if (dev && dev->camera.set_brightness)
130 ret = dev->camera.set_brightness(dev);
131 return ret;
135 * @brief Wrapper function for device-specific gamma functions
137 * @param dev Pointer to device structure
139 * @returns 0 or negative error value
142 int dev_microdia_camera_set_gamma(struct usb_microdia *dev)
144 int ret = -ENODEV;
145 if (dev && dev->camera.set_gamma)
146 ret = dev->camera.set_gamma(dev);
147 return ret;
151 * @brief Wrapper function for device-specific exposure functions
153 * @param dev Pointer to device structure
155 * @returns 0 or negative error value
158 int dev_microdia_camera_set_exposure(struct usb_microdia *dev)
160 if (dev && dev->camera.set_exposure != NULL)
161 return dev->camera.set_exposure(dev);
163 return 0;
167 * @brief Wrapper function for device-specific hvflip functions
169 * @param dev Pointer to device structure
171 * @returns 0 or negative error value
174 int dev_microdia_camera_set_hvflip(struct usb_microdia *dev)
176 int ret = -ENODEV;
177 if (dev && dev->camera.set_hvflip)
178 ret = dev->camera.set_hvflip(dev);
180 return ret;
184 * @brief Wrapper function for device-specific sharpness functions
186 * @param dev Pointer to device structure
188 * @returns 0 or negative error value
191 int dev_microdia_camera_set_sharpness(struct usb_microdia *dev)
193 int ret = -ENODEV;
194 if (dev && dev->camera.set_sharpness)
195 ret = dev->camera.set_sharpness(dev);
197 return ret;
201 * @brief Wrapper function for device-specific rgb-gain functions
203 * @param dev Pointer to device structure
205 * @returns 0 or negative error value
208 int dev_microdia_camera_set_rgb_gain(struct usb_microdia *dev)
210 int ret = -ENODEV;
211 if (dev && dev->camera.set_rgb_gain)
212 ret = dev->camera.set_rgb_gain(dev);
214 return ret;
218 * @brief Wrapper function for device-specific auto-exposure functions
220 * @param dev Pointer to device structure
222 * @returns 0 or negative error value
225 int dev_microdia_camera_set_auto_exposure(struct usb_microdia *dev)
227 int ret = -ENODEV;
228 if (dev && dev->camera.set_auto_exposure)
229 ret = dev->camera.set_auto_exposure(dev);
231 return ret;
235 * @brief Wrapper function for device-specific auto-whitebalance functions
237 * @param dev Pointer to device structure
239 * @returns 0 or negative error value
242 int dev_microdia_camera_set_auto_whitebalance(struct usb_microdia *dev)
244 int ret = -ENODEV;
245 if (dev && dev->camera.set_auto_whitebalance)
246 ret = dev->camera.set_auto_whitebalance(dev);
248 return ret;
252 * @brief function to probe sensor attached to bridge
254 * @param dev pointer to device structure
256 * @returns 0 or negative error value
258 * This function will probe the bridge for the proper sensor
260 int dev_microdia_probe_sensor(struct usb_microdia *dev)
262 int i, ret;
263 dev->camera.sensor_flags = SN9C20X_I2C_2WIRE;
265 for (i = 0; i < ARRAY_SIZE(sensors); i++) {
266 ret = sensors[i].probe(dev);
267 if (ret == sensors[i].id) {
268 UDIA_INFO("Detected sensor: %s\n", sensors[i].name);
269 return ret;
273 return UNKNOWN_SENSOR;
277 * @brief Wrapper function for device-specific initialization functions
279 * @param dev Pointer to device structure
280 * @param flags
282 * @returns 0 or negative error value
285 int dev_microdia_initialize_device(struct usb_microdia *dev, __u32 flags)
287 switch (flags >> 16) {
288 case (SN9C20X_BRIDGE >> 16):
289 UDIA_INFO("Detected SN9C20X Bridge\n");
290 return sn9c20x_initialize(dev);
291 default:
292 UDIA_INFO("Unsupported bridge\n");
294 return -ENODEV;
298 * @brief Wrapper function for for enable video stream for specific bridge
300 * @param dev Pointer to device structure
301 * @param enable Contains the wanted state
303 * @returns 0
306 int dev_microdia_enable_video(struct usb_microdia *dev, int enable)
308 int ret = -ENODEV;
309 if (dev && dev->camera.enable_video)
310 ret = dev->camera.enable_video(dev, enable);
312 return ret;