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 * @brief Wrapper function for camera-setting functions
69 * @param dev Pointer to device structure
73 int dev_microdia_camera_settings(struct usb_microdia
*dev
)
75 dev_microdia_camera_set_contrast(dev
);
76 dev_microdia_camera_set_brightness(dev
);
77 dev_microdia_camera_set_gamma(dev
);
78 dev_microdia_camera_set_exposure(dev
);
79 dev_microdia_camera_set_hvflip(dev
);
80 dev_microdia_camera_set_sharpness(dev
);
81 dev_microdia_camera_set_rgb_gain(dev
);
82 dev_microdia_camera_set_auto_exposure(dev
);
83 dev_microdia_camera_set_auto_whitebalance(dev
);
88 * @brief Wrapper function for device-specific contrast functions
90 * @param dev Pointer to device structure
92 * @returns 0 or negative error value
95 int dev_microdia_camera_set_contrast(struct usb_microdia
*dev
)
98 if (dev
&& dev
->camera
.set_contrast
)
99 ret
= dev
->camera
.set_contrast(dev
);
104 * @brief Wrapper function for device-specific brightness functions
106 * @param dev Pointer to device structure
108 * @returns 0 or negative error value
111 int dev_microdia_camera_set_brightness(struct usb_microdia
*dev
)
114 if (dev
&& dev
->camera
.set_brightness
)
115 ret
= dev
->camera
.set_brightness(dev
);
120 * @brief Wrapper function for device-specific gamma functions
122 * @param dev Pointer to device structure
124 * @returns 0 or negative error value
127 int dev_microdia_camera_set_gamma(struct usb_microdia
*dev
)
130 if (dev
&& dev
->camera
.set_gamma
)
131 ret
= dev
->camera
.set_gamma(dev
);
136 * @brief Wrapper function for device-specific exposure functions
138 * @param dev Pointer to device structure
140 * @returns 0 or negative error value
143 int dev_microdia_camera_set_exposure(struct usb_microdia
*dev
)
145 if (dev
&& dev
->camera
.set_exposure
!= NULL
)
146 return dev
->camera
.set_exposure(dev
);
152 * @brief Wrapper function for device-specific hvflip functions
154 * @param dev Pointer to device structure
156 * @returns 0 or negative error value
159 int dev_microdia_camera_set_hvflip(struct usb_microdia
*dev
)
162 if (dev
&& dev
->camera
.set_hvflip
)
163 ret
= dev
->camera
.set_hvflip(dev
);
169 * @brief Wrapper function for device-specific sharpness functions
171 * @param dev Pointer to device structure
173 * @returns 0 or negative error value
176 int dev_microdia_camera_set_sharpness(struct usb_microdia
*dev
)
179 if (dev
&& dev
->camera
.set_sharpness
)
180 ret
= dev
->camera
.set_sharpness(dev
);
186 * @brief Wrapper function for device-specific rgb-gain functions
188 * @param dev Pointer to device structure
190 * @returns 0 or negative error value
193 int dev_microdia_camera_set_rgb_gain(struct usb_microdia
*dev
)
196 if (dev
&& dev
->camera
.set_rgb_gain
)
197 ret
= dev
->camera
.set_rgb_gain(dev
);
203 * @brief Wrapper function for device-specific auto-exposure functions
205 * @param dev Pointer to device structure
207 * @returns 0 or negative error value
210 int dev_microdia_camera_set_auto_exposure(struct usb_microdia
*dev
)
213 if (dev
&& dev
->camera
.set_auto_exposure
)
214 ret
= dev
->camera
.set_auto_exposure(dev
);
220 * @brief Wrapper function for device-specific auto-whitebalance functions
222 * @param dev Pointer to device structure
224 * @returns 0 or negative error value
227 int dev_microdia_camera_set_auto_whitebalance(struct usb_microdia
*dev
)
230 if (dev
&& dev
->camera
.set_auto_whitebalance
)
231 ret
= dev
->camera
.set_auto_whitebalance(dev
);
237 * @brief function to probe sensor attached to bridge
239 * @param dev pointer to device structure
241 * @returns 0 or negative error value
243 * This function will probe the bridge for the proper sensor
245 int dev_microdia_probe_sensor(struct usb_microdia
*dev
)
248 dev
->camera
.sensor_flags
= SN9C20X_I2C_2WIRE
;
250 for (i
= 0; i
< ARRAY_SIZE(sensors
); i
++) {
251 ret
= sensors
[i
].probe(dev
);
252 if (ret
== sensors
[i
].id
) {
253 UDIA_INFO("Detected sensor: %s\n", sensors
[i
].name
);
258 return UNKNOWN_SENSOR
;
262 * @brief Wrapper function for device-specific initialization functions
264 * @param dev Pointer to device structure
267 * @returns 0 or negative error value
270 int dev_microdia_initialize_device(struct usb_microdia
*dev
, __u32 flags
)
272 switch (flags
>> 16) {
273 case (SN9C20X_BRIDGE
>> 16):
274 UDIA_INFO("Detected SN9C20X Bridge\n");
275 return sn9c20x_initialize(dev
);
277 UDIA_INFO("Unsupported bridge\n");
283 * @brief Wrapper function for for enable video stream for specific bridge
285 * @param dev Pointer to device structure
286 * @param enable Contains the wanted state
291 int dev_microdia_enable_video(struct usb_microdia
*dev
, int enable
)
294 if (dev
&& dev
->camera
.enable_video
)
295 ret
= dev
->camera
.enable_video(dev
, enable
);