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 * @brief Wrapper function for camera-setting functions
84 * @param dev Pointer to device structure
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
);
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
)
113 if (dev
&& dev
->camera
.set_contrast
)
114 ret
= dev
->camera
.set_contrast(dev
);
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
)
129 if (dev
&& dev
->camera
.set_brightness
)
130 ret
= dev
->camera
.set_brightness(dev
);
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
)
145 if (dev
&& dev
->camera
.set_gamma
)
146 ret
= dev
->camera
.set_gamma(dev
);
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
);
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
)
177 if (dev
&& dev
->camera
.set_hvflip
)
178 ret
= dev
->camera
.set_hvflip(dev
);
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
)
194 if (dev
&& dev
->camera
.set_sharpness
)
195 ret
= dev
->camera
.set_sharpness(dev
);
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
)
211 if (dev
&& dev
->camera
.set_rgb_gain
)
212 ret
= dev
->camera
.set_rgb_gain(dev
);
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
)
228 if (dev
&& dev
->camera
.set_auto_exposure
)
229 ret
= dev
->camera
.set_auto_exposure(dev
);
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
)
245 if (dev
&& dev
->camera
.set_auto_whitebalance
)
246 ret
= dev
->camera
.set_auto_whitebalance(dev
);
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
)
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
);
273 return UNKNOWN_SENSOR
;
277 * @brief Wrapper function for device-specific initialization functions
279 * @param dev Pointer to device structure
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
);
292 UDIA_INFO("Unsupported bridge\n");
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
306 int dev_microdia_enable_video(struct usb_microdia
*dev
, int enable
)
309 if (dev
&& dev
->camera
.enable_video
)
310 ret
= dev
->camera
.enable_video(dev
, enable
);