3 * @author Nicolas VIVIEN
6 * @brief Device specific functions
8 * @note Copyright (C) Nicolas VIVIEN
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
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>
33 #include "omnivision.h"
36 struct sensor_info sensors
[] = {
71 .probe
= mt9m111_probe
77 .probe
= mt9v111_probe
83 .probe
= mt9v011_probe
89 .probe
= mt9m001_probe
94 * @brief Wrapper function for camera-setting functions
96 * @param dev Pointer to device structure
100 int dev_microdia_camera_settings(struct usb_microdia
*dev
)
102 dev_microdia_camera_set_contrast(dev
);
103 dev_microdia_camera_set_brightness(dev
);
104 dev_microdia_camera_set_gamma(dev
);
105 dev_microdia_camera_set_exposure(dev
);
106 dev_microdia_camera_set_hvflip(dev
);
107 dev_microdia_camera_set_sharpness(dev
);
108 dev_microdia_camera_set_rgb_gain(dev
);
109 dev_microdia_camera_set_auto_exposure(dev
);
110 dev_microdia_camera_set_auto_whitebalance(dev
);
115 * @brief Wrapper function for device-specific contrast functions
117 * @param dev Pointer to device structure
119 * @returns 0 or negative error value
122 int dev_microdia_camera_set_contrast(struct usb_microdia
*dev
)
125 if (dev
&& dev
->camera
.set_contrast
)
126 ret
= dev
->camera
.set_contrast(dev
);
131 * @brief Wrapper function for device-specific brightness functions
133 * @param dev Pointer to device structure
135 * @returns 0 or negative error value
138 int dev_microdia_camera_set_brightness(struct usb_microdia
*dev
)
141 if (dev
&& dev
->camera
.set_brightness
)
142 ret
= dev
->camera
.set_brightness(dev
);
147 * @brief Wrapper function for device-specific gamma functions
149 * @param dev Pointer to device structure
151 * @returns 0 or negative error value
154 int dev_microdia_camera_set_gamma(struct usb_microdia
*dev
)
157 if (dev
&& dev
->camera
.set_gamma
)
158 ret
= dev
->camera
.set_gamma(dev
);
163 * @brief Wrapper function for device-specific exposure functions
165 * @param dev Pointer to device structure
167 * @returns 0 or negative error value
170 int dev_microdia_camera_set_exposure(struct usb_microdia
*dev
)
172 if (dev
&& dev
->camera
.set_exposure
!= NULL
)
173 return dev
->camera
.set_exposure(dev
);
179 * @brief Wrapper function for device-specific hvflip functions
181 * @param dev Pointer to device structure
183 * @returns 0 or negative error value
186 int dev_microdia_camera_set_hvflip(struct usb_microdia
*dev
)
189 if (dev
&& dev
->camera
.set_hvflip
)
190 ret
= dev
->camera
.set_hvflip(dev
);
196 * @brief Wrapper function for device-specific sharpness functions
198 * @param dev Pointer to device structure
200 * @returns 0 or negative error value
203 int dev_microdia_camera_set_sharpness(struct usb_microdia
*dev
)
206 if (dev
&& dev
->camera
.set_sharpness
)
207 ret
= dev
->camera
.set_sharpness(dev
);
213 * @brief Wrapper function for device-specific rgb-gain functions
215 * @param dev Pointer to device structure
217 * @returns 0 or negative error value
220 int dev_microdia_camera_set_rgb_gain(struct usb_microdia
*dev
)
223 if (dev
&& dev
->camera
.set_rgb_gain
)
224 ret
= dev
->camera
.set_rgb_gain(dev
);
230 * @brief Wrapper function for device-specific auto-exposure functions
232 * @param dev Pointer to device structure
234 * @returns 0 or negative error value
237 int dev_microdia_camera_set_auto_exposure(struct usb_microdia
*dev
)
240 if (dev
&& dev
->camera
.set_auto_exposure
)
241 ret
= dev
->camera
.set_auto_exposure(dev
);
247 * @brief Wrapper function for device-specific auto-whitebalance functions
249 * @param dev Pointer to device structure
251 * @returns 0 or negative error value
254 int dev_microdia_camera_set_auto_whitebalance(struct usb_microdia
*dev
)
257 if (dev
&& dev
->camera
.set_auto_whitebalance
)
258 ret
= dev
->camera
.set_auto_whitebalance(dev
);
264 * @brief function to probe sensor attached to bridge
266 * @param dev pointer to device structure
268 * @returns 0 or negative error value
270 * This function will probe the bridge for the proper sensor
272 int dev_microdia_probe_sensor(struct usb_microdia
*dev
)
275 dev
->camera
.sensor_flags
= SN9C20X_I2C_2WIRE
;
277 for (i
= 0; i
< ARRAY_SIZE(sensors
); i
++) {
278 dev
->camera
.sensor_slave_address
= sensors
[i
].address
;
279 ret
= sensors
[i
].probe(dev
);
280 if (ret
== sensors
[i
].id
) {
281 UDIA_INFO("Detected sensor: %s\n", sensors
[i
].name
);
286 return UNKNOWN_SENSOR
;
290 * @brief Wrapper function for device-specific initialization functions
292 * @param dev Pointer to device structure
295 * @returns 0 or negative error value
298 int dev_microdia_initialize_device(struct usb_microdia
*dev
, __u32 flags
)
300 switch (flags
>> 16) {
301 case (SN9C20X_BRIDGE
>> 16):
302 UDIA_INFO("Detected SN9C20X Bridge\n");
303 return sn9c20x_initialize(dev
);
305 UDIA_INFO("Unsupported bridge\n");
311 * @brief Wrapper function for for enable video stream for specific bridge
313 * @param dev Pointer to device structure
314 * @param enable Contains the wanted state
319 int dev_microdia_enable_video(struct usb_microdia
*dev
, int enable
)
322 if (dev
&& dev
->camera
.enable_video
)
323 ret
= dev
->camera
.enable_video(dev
, enable
);