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>
38 struct sensor_info sensors
[] = {
67 .probe
= mt9m111_probe
72 .probe
= mt9v111_probe
77 .probe
= mt9v011_probe
82 .probe
= mt9m001_probe
87 * @brief Wrapper function for camera-setting functions
89 * @param dev Pointer to device structure
93 int dev_microdia_camera_settings(struct usb_microdia
*dev
)
95 dev_microdia_camera_set_contrast(dev
);
96 dev_microdia_camera_set_brightness(dev
);
97 dev_microdia_camera_set_gamma(dev
);
98 dev_microdia_camera_set_exposure(dev
);
99 dev_microdia_camera_set_hvflip(dev
);
100 dev_microdia_camera_set_sharpness(dev
);
101 dev_microdia_camera_set_rgb_gain(dev
);
102 dev_microdia_camera_set_auto_exposure(dev
);
103 dev_microdia_camera_set_auto_whitebalance(dev
);
108 * @brief Wrapper function for device-specific contrast functions
110 * @param dev Pointer to device structure
112 * @returns 0 or negative error value
115 int dev_microdia_camera_set_contrast(struct usb_microdia
*dev
)
118 if (dev
&& dev
->camera
.set_contrast
)
119 ret
= dev
->camera
.set_contrast(dev
);
124 * @brief Wrapper function for device-specific brightness functions
126 * @param dev Pointer to device structure
128 * @returns 0 or negative error value
131 int dev_microdia_camera_set_brightness(struct usb_microdia
*dev
)
134 if (dev
&& dev
->camera
.set_brightness
)
135 ret
= dev
->camera
.set_brightness(dev
);
140 * @brief Wrapper function for device-specific gamma functions
142 * @param dev Pointer to device structure
144 * @returns 0 or negative error value
147 int dev_microdia_camera_set_gamma(struct usb_microdia
*dev
)
150 if (dev
&& dev
->camera
.set_gamma
)
151 ret
= dev
->camera
.set_gamma(dev
);
156 * @brief Wrapper function for device-specific exposure functions
158 * @param dev Pointer to device structure
160 * @returns 0 or negative error value
163 int dev_microdia_camera_set_exposure(struct usb_microdia
*dev
)
165 if (dev
&& dev
->camera
.set_exposure
!= NULL
)
166 return dev
->camera
.set_exposure(dev
);
172 * @brief Wrapper function for device-specific hvflip functions
174 * @param dev Pointer to device structure
176 * @returns 0 or negative error value
179 int dev_microdia_camera_set_hvflip(struct usb_microdia
*dev
)
182 if (dev
&& dev
->camera
.set_hvflip
)
183 ret
= dev
->camera
.set_hvflip(dev
);
189 * @brief Wrapper function for device-specific sharpness functions
191 * @param dev Pointer to device structure
193 * @returns 0 or negative error value
196 int dev_microdia_camera_set_sharpness(struct usb_microdia
*dev
)
199 if (dev
&& dev
->camera
.set_sharpness
)
200 ret
= dev
->camera
.set_sharpness(dev
);
206 * @brief Wrapper function for device-specific rgb-gain functions
208 * @param dev Pointer to device structure
210 * @returns 0 or negative error value
213 int dev_microdia_camera_set_rgb_gain(struct usb_microdia
*dev
)
216 if (dev
&& dev
->camera
.set_rgb_gain
)
217 ret
= dev
->camera
.set_rgb_gain(dev
);
223 * @brief Wrapper function for device-specific auto-exposure functions
225 * @param dev Pointer to device structure
227 * @returns 0 or negative error value
230 int dev_microdia_camera_set_auto_exposure(struct usb_microdia
*dev
)
233 if (dev
&& dev
->camera
.set_auto_exposure
)
234 ret
= dev
->camera
.set_auto_exposure(dev
);
240 * @brief Wrapper function for device-specific auto-whitebalance functions
242 * @param dev Pointer to device structure
244 * @returns 0 or negative error value
247 int dev_microdia_camera_set_auto_whitebalance(struct usb_microdia
*dev
)
250 if (dev
&& dev
->camera
.set_auto_whitebalance
)
251 ret
= dev
->camera
.set_auto_whitebalance(dev
);
257 * @brief function to probe sensor attached to bridge
259 * @param dev pointer to device structure
261 * @returns 0 or negative error value
263 * This function will probe the bridge for the proper sensor
265 int dev_microdia_probe_sensor(struct usb_microdia
*dev
)
268 dev
->camera
.sensor_flags
= SN9C20X_I2C_2WIRE
;
270 for (i
= 0; i
< ARRAY_SIZE(sensors
); i
++) {
271 ret
= sensors
[i
].probe(dev
);
272 if (ret
== sensors
[i
].id
) {
273 UDIA_INFO("Detected sensor: %s\n", sensors
[i
].name
);
278 return UNKNOWN_SENSOR
;
282 * @brief Wrapper function for device-specific initialization functions
284 * @param dev Pointer to device structure
287 * @returns 0 or negative error value
290 int dev_microdia_initialize_device(struct usb_microdia
*dev
, __u32 flags
)
292 switch (flags
>> 16) {
293 case (SN9C20X_BRIDGE
>> 16):
294 UDIA_INFO("Detected SN9C20X Bridge\n");
295 return sn9c20x_initialize(dev
);
297 UDIA_INFO("Unsupported bridge\n");
303 * @brief Wrapper function for for enable video stream for specific bridge
305 * @param dev Pointer to device structure
306 * @param enable Contains the wanted state
311 int dev_microdia_enable_video(struct usb_microdia
*dev
, int enable
)
314 if (dev
&& dev
->camera
.enable_video
)
315 ret
= dev
->camera
.enable_video(dev
, enable
);