Complete renaming to sn920x and declare driver "v2009.01"
[microdia.git] / sn9c20x-sysfs.c
blobe2bd2b16b4013980be1346458ffb185a4742ffd3
1 /**
2 * @file sn9c20x-sysfs.c
3 * @author Nicolas VIVIEN
4 * @date 2008-02-01
6 * @brief Sysfs interface for image settings
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/module.h>
28 #include <linux/init.h>
29 #include <linux/kernel.h>
30 #include <linux/version.h>
31 #include <linux/errno.h>
32 #include <linux/slab.h>
33 #include <linux/kref.h>
34 #include <linux/device.h>
36 #include <linux/usb.h>
37 #include <media/v4l2-common.h>
39 #include "sn9c20x.h"
40 #include "sn9c20x-bridge.h"
43 /**
44 * @brief show_release
46 * @param class Class device
47 * @param attr
48 * @retval buf Adress of buffer with the 'release' value
50 * @returns Size of buffer
52 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
53 static ssize_t show_release(struct class_device *class, char *buf)
54 #else
55 static ssize_t show_release(struct device *class, struct device_attribute *attr, char *buf)
56 #endif
58 struct video_device *vdev = to_video_device(class);
59 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
61 return sprintf(buf, "%d\n", dev->release);
65 /**
66 * @brief show_videostatus
68 * @param class Class device
69 * @param attr
70 * @retval buf Adress of buffer with the 'videostatus' value
72 * @returns Size of buffer
74 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
75 static ssize_t show_videostatus(struct class_device *class, char *buf)
76 #else
77 static ssize_t show_videostatus(struct device *class, struct device_attribute *attr, char *buf)
78 #endif
80 struct video_device *vdev = to_video_device(class);
81 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
83 return sprintf(buf,
84 "Overflow frames : %d\n"
85 "Incomplete frames : %d\n"
86 "Dropped frames : %d\n",
87 dev->vframes_overflow,
88 dev->vframes_incomplete,
89 dev->vframes_dropped);
93 /**
94 * @brief show_informations
96 * @param class Class device
97 * @param attr
98 * @retval buf Adress of buffer with the 'informations' value
100 * @returns Size of buffer
102 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
103 static ssize_t show_informations(struct class_device *class, char *buf)
104 #else
105 static ssize_t show_informations(struct device *class, struct device_attribute *attr, char *buf)
106 #endif
108 char *pixelfmt = NULL;
110 struct video_device *vdev = to_video_device(class);
111 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
113 char *palette_bgr24 = "BGR24 - BGR-8-8-8 - 24 bits";
114 char *palette_rgb24 = "RGB24 - RGB-8-8-8 - 24 bits";
115 char *palette_yuyv = "YUYV - YUV 4:2:2 - 16 bits";
116 char *palette_i420 = "I420 - YUV 4:2:0 - 12 bits";
119 switch (dev->vsettings.format.pixelformat) {
120 case V4L2_PIX_FMT_BGR24:
121 pixelfmt = palette_bgr24;
122 break;
124 case V4L2_PIX_FMT_RGB24:
125 pixelfmt = palette_rgb24;
126 break;
128 case V4L2_PIX_FMT_YUYV:
129 pixelfmt = palette_yuyv;
130 break;
132 case V4L2_PIX_FMT_YUV420:
133 pixelfmt = palette_i420;
134 break;
137 return sprintf(buf,
138 "Driver Resolution : %dx%d\n"
139 "\n"
140 "%s\n"
141 "\n"
142 "Brightness : 0x%X\n"
143 "Contrast : 0x%X\n"
144 "Gamma : 0x%X\n"
145 "Exposure : 0x%X\n"
146 "Sharpness : 0x%X\n"
147 "Horizontal flip : %d\n"
148 "Vertical flip : %d\n"
149 "Auto-exposure : %d\n"
150 "Auto-whitebalance : %d\n",
151 dev->vsettings.format.width,
152 dev->vsettings.format.height,
153 pixelfmt,
154 0xFFFF & dev->vsettings.brightness,
155 0xFFFF & dev->vsettings.contrast,
156 0xFFFF & dev->vsettings.gamma,
157 0xFFFF & dev->vsettings.exposure,
158 0x3F & dev->vsettings.sharpness,
159 dev->vsettings.hflip,
160 dev->vsettings.vflip,
161 dev->vsettings.auto_exposure,
162 dev->vsettings.auto_whitebalance);
167 * @brief show_fps
169 * @param class Class device
170 * @param attr
171 * @retval buf Adress of buffer with the 'fps' value
173 * @returns Size of buffer
175 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
176 static ssize_t show_fps(struct class_device *class, char *buf)
177 #else
178 static ssize_t show_fps(struct device *class, struct device_attribute *attr, char *buf)
179 #endif
181 struct video_device *vdev = to_video_device(class);
182 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
184 return sprintf(buf, "%d\n", dev->vsettings.fps);
188 * @brief show_exposure
190 * @param class Class device
191 * @param attr
192 * @retval buf Adress of buffer with the 'exposure' value
194 * @returns Size of buffer
196 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
197 static ssize_t show_exposure(struct class_device *class, char *buf)
198 #else
199 static ssize_t show_exposure(struct device *class, struct device_attribute *attr, char *buf)
200 #endif
202 struct video_device *vdev = to_video_device(class);
203 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
205 return sprintf(buf, "%X\n", dev->vsettings.exposure);
209 * @brief store_exposure
211 * @param class Class device
212 * @param buf Buffer
213 * @param count Counter
214 * @param attr
216 * @returns Size of buffer
218 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
219 static ssize_t store_exposure(struct class_device *class, const char *buf, size_t count)
220 #else
221 static ssize_t store_exposure(struct device *class, struct device_attribute *attr,
222 const char *buf, size_t count)
223 #endif
225 char *endp;
226 unsigned long value;
228 struct video_device *vdev = to_video_device(class);
229 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
231 value = simple_strtoul(buf, &endp, 16);
233 sn9c20x_set_camera_control(dev,
234 V4L2_CID_EXPOSURE,
235 value);
237 return strlen(buf);
241 * @brief show_brightness
243 * @param class Class device
244 * @param attr
245 * @retval buf Adress of buffer with the 'brightness' value
247 * @returns Size of buffer
249 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
250 static ssize_t show_brightness(struct class_device *class, char *buf)
251 #else
252 static ssize_t show_brightness(struct device *class, struct device_attribute *attr, char *buf)
253 #endif
255 struct video_device *vdev = to_video_device(class);
256 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
258 return sprintf(buf, "%X\n", dev->vsettings.brightness);
262 * @brief store_brightness
264 * @param class Class device
265 * @param buf Buffer
266 * @param count Counter
267 * @param attr
269 * @returns Size of buffer
271 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
272 static ssize_t store_brightness(struct class_device *class, const char *buf, size_t count)
273 #else
274 static ssize_t store_brightness(struct device *class, struct device_attribute *attr,
275 const char *buf, size_t count)
276 #endif
278 char *endp;
279 unsigned long value;
281 struct video_device *vdev = to_video_device(class);
282 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
284 value = simple_strtoul(buf, &endp, 16);
286 sn9c20x_set_camera_control(dev,
287 V4L2_CID_BRIGHTNESS,
288 value);
290 return strlen(buf);
294 * @brief show_contrast
296 * @param class Class device
297 * @param attr
298 * @retval buf Adress of buffer with the 'contrast' value
300 * @returns Size of buffer
302 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
303 static ssize_t show_contrast(struct class_device *class, char *buf)
304 #else
305 static ssize_t show_contrast(struct device *class, struct device_attribute *attr, char *buf)
306 #endif
308 struct video_device *vdev = to_video_device(class);
309 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
311 return sprintf(buf, "%X\n", dev->vsettings.contrast);
316 * @brief store_contrast
318 * @param class Class device
319 * @param buf Buffer
320 * @param count Counter
321 * @param attr
323 * @returns Size of buffer
325 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
326 static ssize_t store_contrast(struct class_device *class, const char *buf, size_t count)
327 #else
328 static ssize_t store_contrast(struct device *class, struct device_attribute *attr,
329 const char *buf, size_t count)
330 #endif
332 char *endp;
333 unsigned long value;
335 struct video_device *vdev = to_video_device(class);
336 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
338 value = simple_strtoul(buf, &endp, 16);
340 sn9c20x_set_camera_control(dev,
341 V4L2_CID_CONTRAST,
342 value);
344 return strlen(buf);
349 * @brief show_whitebalance
351 * @param class Class device
352 * @param attr
353 * @retval buf Adress of buffer with the 'whitebalance' value
355 * @returns Size of buffer
357 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
358 static ssize_t show_gamma(struct class_device *class, char *buf)
359 #else
360 static ssize_t show_gamma(struct device *class, struct device_attribute *attr, char *buf)
361 #endif
363 struct video_device *vdev = to_video_device(class);
364 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
366 return sprintf(buf, "%X\n", dev->vsettings.gamma);
371 * @brief store_gamma
373 * @param class Class device
374 * @param buf Buffer
375 * @param count Counter
376 * @param attr
378 * @returns Size of buffer
380 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
381 static ssize_t store_gamma(struct class_device *class, const char *buf, size_t count)
382 #else
383 static ssize_t store_gamma(struct device *class, struct device_attribute *attr,
384 const char *buf, size_t count)
385 #endif
387 char *endp;
388 unsigned long value;
390 struct video_device *vdev = to_video_device(class);
391 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
393 value = simple_strtoul(buf, &endp, 16);
395 sn9c20x_set_camera_control(dev,
396 V4L2_CID_GAMMA,
397 value);
399 return strlen(buf);
404 * @brief show_colour
406 * @param class Class device
407 * @param attr
408 * @retval buf Adress of buffer with the 'colour' value
410 * @returns Size of buffer
412 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
413 static ssize_t show_colour(struct class_device *class, char *buf)
414 #else
415 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
416 #endif
418 struct video_device *vdev = to_video_device(class);
419 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
421 return sprintf(buf, "%X\n", dev->vsettings.colour);
426 * @brief store_colour
428 * @param class Class device
429 * @param buf Buffer
430 * @param count Counter
431 * @param attr
433 * @returns Size of buffer
435 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
436 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
437 #else
438 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
439 const char *buf, size_t count)
440 #endif
442 char *endp;
443 unsigned long value;
445 struct video_device *vdev = to_video_device(class);
446 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
448 value = simple_strtoul(buf, &endp, 16);
450 dev->vsettings.colour = (int) value;
452 / dev_sn9c20x_set_camera_quality(dev); /
454 return strlen(buf);
460 * @brief show_sharpness
462 * @param class Class device
463 * @param attr
464 * @retval buf Adress of buffer with the 'sharpness' value
466 * @returns Size of buffer
468 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
469 static ssize_t show_sharpness(struct class_device *class, char *buf)
470 #else
471 static ssize_t show_sharpness(struct device *class, struct device_attribute *attr, char *buf)
472 #endif
474 struct video_device *vdev = to_video_device(class);
475 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
477 return sprintf(buf, "%X\n", dev->vsettings.sharpness);
481 * @brief store_sharpness
483 * @param class Class device
484 * @param buf Buffer
485 * @param count Counter
486 * @param attr
488 * @returns Size of buffer
490 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
491 static ssize_t store_sharpness(struct class_device *class, const char *buf, size_t count)
492 #else
493 static ssize_t store_sharpness(struct device *class, struct device_attribute *attr,
494 const char *buf, size_t count)
495 #endif
497 char *endp;
498 unsigned long value;
500 struct video_device *vdev = to_video_device(class);
501 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
503 value = simple_strtoul(buf, &endp, 16);
505 if (value < 0 || value > 0x3f)
506 return -EINVAL;
508 sn9c20x_set_camera_control(dev,
509 V4L2_CID_SHARPNESS,
510 value);
512 return strlen(buf);
517 * @brief show_hflip
519 * @param class Class device
520 * @param attr
521 * @retval buf Adress of buffer with the 'hflip' value
523 * @returns Size of buffer
525 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
526 static ssize_t show_hflip(struct class_device *class, char *buf)
527 #else
528 static ssize_t show_hflip(struct device *class, struct device_attribute *attr, char *buf)
529 #endif
531 struct video_device *vdev = to_video_device(class);
532 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
534 return sprintf(buf, "%d\n", dev->vsettings.hflip);
539 * @brief store_hflip
541 * @param class Class device
542 * @param buf Buffer
543 * @param count Counter
544 * @param attr
546 * @returns Size of buffer
548 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
549 static ssize_t store_hflip(struct class_device *class, const char *buf, size_t count)
550 #else
551 static ssize_t store_hflip(struct device *class, struct device_attribute *attr,
552 const char *buf, size_t count)
553 #endif
555 char *endp;
556 unsigned long value;
557 struct video_device *vdev = to_video_device(class);
558 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
560 value = simple_strtoul(buf, &endp, 10);
562 if (value != 0 && value != 1)
563 return -EINVAL;
565 sn9c20x_set_camera_control(dev,
566 V4L2_CID_HFLIP,
567 value);
569 return strlen(buf);
574 * @brief show_vflip
576 * @param class Class device
577 * @param attr
578 * @retval buf Adress of buffer with the 'vflip' value
580 * @returns Size of buffer
582 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
583 static ssize_t show_vflip(struct class_device *class, char *buf)
584 #else
585 static ssize_t show_vflip(struct device *class, struct device_attribute *attr, char *buf)
586 #endif
588 struct video_device *vdev = to_video_device(class);
589 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
591 return sprintf(buf, "%d\n", dev->vsettings.vflip);
596 * @brief store_vflip
598 * @param class Class device
599 * @param buf Buffer
600 * @param count Counter
601 * @param attr
603 * @returns Size of buffer
605 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
606 static ssize_t store_vflip(struct class_device *class, const char *buf, size_t count)
607 #else
608 static ssize_t store_vflip(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
609 #endif
611 char *endp;
612 unsigned long value;
613 struct video_device *vdev = to_video_device(class);
614 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
616 value = simple_strtoul(buf, &endp, 10);
618 if (value != 0 && value != 1)
619 return -EINVAL;
621 sn9c20x_set_camera_control(dev,
622 V4L2_CID_VFLIP,
623 value);
625 return strlen(buf);
630 * @brief show_autoexposure
632 * @param class Class device
633 * @param attr
634 * @retval buf Adress of buffer with the 'hflip' value
636 * @returns Size of buffer
638 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
639 static ssize_t show_autoexposure(struct class_device *class, char *buf)
640 #else
641 static ssize_t show_autoexposure(struct device *class, struct device_attribute *attr, char *buf)
642 #endif
644 struct video_device *vdev = to_video_device(class);
645 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
647 return sprintf(buf, "%d\n", dev->vsettings.auto_exposure);
652 * @brief store_autoexposure
654 * @param class Class device
655 * @param buf Buffer
656 * @param count Counter
657 * @param attr
659 * @returns Size of buffer
661 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
662 static ssize_t store_autoexposure(struct class_device *class, const char *buf, size_t count)
663 #else
664 static ssize_t store_autoexposure(struct device *class, struct device_attribute *attr,
665 const char *buf, size_t count)
666 #endif
668 unsigned long value;
669 struct video_device *vdev = to_video_device(class);
670 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
672 if (strncmp(buf, "1", 1) == 0)
673 value = V4L2_EXPOSURE_AUTO;
674 else if (strncmp(buf, "0", 1) == 0)
675 value = V4L2_EXPOSURE_MANUAL;
676 else
677 return -EINVAL;
679 sn9c20x_set_camera_control(dev,
680 V4L2_CID_EXPOSURE_AUTO,
681 value);
683 return strlen(buf);
688 * @brief show_autowhitebalance
690 * @param class Class device
691 * @param attr
692 * @retval buf Adress of buffer with the 'vflip' value
694 * @returns Size of buffer
696 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
697 static ssize_t show_autowhitebalance(struct class_device *class, char *buf)
698 #else
699 static ssize_t show_autowhitebalance(struct device *class, struct device_attribute *attr, char *buf)
700 #endif
702 struct video_device *vdev = to_video_device(class);
703 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
705 return sprintf(buf, "%d\n", dev->vsettings.auto_whitebalance);
710 * @brief store_autowhitebalance
712 * @param class Class device
713 * @param buf Buffer
714 * @param count Counter
715 * @param attr
717 * @returns Size of buffer
719 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
720 static ssize_t store_autowhitebalance(struct class_device *class, const char *buf, size_t count)
721 #else
722 static ssize_t store_autowhitebalance(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
723 #endif
725 char *endp;
726 unsigned long value;
727 struct video_device *vdev = to_video_device(class);
728 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
730 value = simple_strtoul(buf, &endp, 10);
732 if (value != 0 && value != 1)
733 return -EINVAL;
735 sn9c20x_set_camera_control(dev,
736 V4L2_CID_AUTO_WHITE_BALANCE,
737 value);
739 return strlen(buf);
742 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
743 static CLASS_DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
744 static CLASS_DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
745 static CLASS_DEVICE_ATTR(informations, S_IRUGO, show_informations, NULL); /**< Informations */
746 static CLASS_DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
747 static CLASS_DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
748 static CLASS_DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Brightness exposure */
749 static CLASS_DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
750 static CLASS_DEVICE_ATTR(gamma, S_IRUGO | S_IWUGO, show_gamma, store_gamma); /**< Gamma value */
751 static CLASS_DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
752 /*static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /< Hue value */
753 static CLASS_DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
754 static CLASS_DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
755 static CLASS_DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
756 static CLASS_DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
757 #else
758 static DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
759 static DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
760 static DEVICE_ATTR(informations, S_IRUGO, show_informations, NULL); /**< Informations */
761 static DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
762 static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
763 static DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Exposure value */
764 static DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
765 static DEVICE_ATTR(gamma, S_IRUGO | S_IWUGO, show_gamma, store_gamma); /**< Gamma value */
766 static DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
767 /*static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /< Hue value */
768 static DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
769 static DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
770 static DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
771 static DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
772 #endif
776 * @brief Create the 'sys' entries.
778 * This function permits to create all the entries in the 'sys' filesystem.
780 * @param vdev Video device structure
782 * @returns 0 if all is OK
784 int sn9c20x_create_sysfs_files(struct video_device *vdev)
786 int ret;
788 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
789 ret = video_device_create_file(vdev, &class_device_attr_release);
790 ret = video_device_create_file(vdev, &class_device_attr_videostatus);
791 ret = video_device_create_file(vdev, &class_device_attr_informations);
792 ret = video_device_create_file(vdev, &class_device_attr_fps);
793 ret = video_device_create_file(vdev, &class_device_attr_brightness);
794 ret = video_device_create_file(vdev, &class_device_attr_exposure);
795 ret = video_device_create_file(vdev, &class_device_attr_contrast);
796 ret = video_device_create_file(vdev, &class_device_attr_gamma);
797 ret = video_device_create_file(vdev, &class_device_attr_sharpness);
798 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
799 ret = video_device_create_file(vdev, &class_device_attr_hflip);
800 ret = video_device_create_file(vdev, &class_device_attr_vflip);
801 ret = video_device_create_file(vdev, &class_device_attr_auto_exposure);
802 ret = video_device_create_file(vdev, &class_device_attr_auto_whitebalance);
803 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
804 ret = video_device_create_file(vdev, &dev_attr_release);
805 ret = video_device_create_file(vdev, &dev_attr_videostatus);
806 ret = video_device_create_file(vdev, &dev_attr_informations);
807 ret = video_device_create_file(vdev, &dev_attr_fps);
808 ret = video_device_create_file(vdev, &dev_attr_brightness);
809 ret = video_device_create_file(vdev, &dev_attr_exposure);
810 ret = video_device_create_file(vdev, &dev_attr_contrast);
811 ret = video_device_create_file(vdev, &dev_attr_gamma);
812 ret = video_device_create_file(vdev, &dev_attr_sharpness);
813 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
814 ret = video_device_create_file(vdev, &dev_attr_hflip);
815 ret = video_device_create_file(vdev, &dev_attr_vflip);
816 ret = video_device_create_file(vdev, &dev_attr_auto_exposure);
817 ret = video_device_create_file(vdev, &dev_attr_auto_whitebalance);
818 #else
819 ret = device_create_file(&vdev->dev, &dev_attr_release);
820 ret = device_create_file(&vdev->dev, &dev_attr_videostatus);
821 ret = device_create_file(&vdev->dev, &dev_attr_informations);
822 ret = device_create_file(&vdev->dev, &dev_attr_fps);
823 ret = device_create_file(&vdev->dev, &dev_attr_brightness);
824 ret = device_create_file(&vdev->dev, &dev_attr_exposure);
825 ret = device_create_file(&vdev->dev, &dev_attr_contrast);
826 ret = device_create_file(&vdev->dev, &dev_attr_gamma);
827 ret = device_create_file(&vdev->dev, &dev_attr_sharpness);
828 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
829 ret = device_create_file(&vdev->dev, &dev_attr_hflip);
830 ret = device_create_file(&vdev->dev, &dev_attr_vflip);
831 ret = device_create_file(&vdev->dev, &dev_attr_auto_exposure);
832 ret = device_create_file(&vdev->dev, &dev_attr_auto_whitebalance);
833 #endif
834 return ret;
839 * @brief Remove the 'sys' entries.
841 * This function permits to remove all the entries in the 'sys' filesystem.
843 * @param vdev Video device structure
845 * @returns 0 if all is OK
847 void sn9c20x_remove_sysfs_files(struct video_device *vdev)
849 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
850 video_device_remove_file(vdev, &class_device_attr_release);
851 video_device_remove_file(vdev, &class_device_attr_videostatus);
852 video_device_remove_file(vdev, &class_device_attr_informations);
853 video_device_remove_file(vdev, &class_device_attr_fps);
854 video_device_remove_file(vdev, &class_device_attr_brightness);
855 video_device_remove_file(vdev, &class_device_attr_exposure);
856 video_device_remove_file(vdev, &class_device_attr_contrast);
857 video_device_remove_file(vdev, &class_device_attr_gamma);
858 video_device_remove_file(vdev, &class_device_attr_sharpness);
859 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
860 video_device_remove_file(vdev, &class_device_attr_hflip);
861 video_device_remove_file(vdev, &class_device_attr_vflip);
862 video_device_remove_file(vdev, &class_device_attr_auto_exposure);
863 video_device_remove_file(vdev, &class_device_attr_auto_whitebalance);
864 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
865 video_device_remove_file(vdev, &dev_attr_release);
866 video_device_remove_file(vdev, &dev_attr_videostatus);
867 video_device_remove_file(vdev, &dev_attr_informations);
868 video_device_remove_file(vdev, &dev_attr_fps);
869 video_device_remove_file(vdev, &dev_attr_brightness);
870 video_device_remove_file(vdev, &dev_attr_exposure);
871 video_device_remove_file(vdev, &dev_attr_contrast);
872 video_device_remove_file(vdev, &dev_attr_gamma);
873 video_device_remove_file(vdev, &dev_attr_sharpness);
874 /*video_device_remove_file(vdev, &dev_attr_colour);*/
875 video_device_remove_file(vdev, &dev_attr_hflip);
876 video_device_remove_file(vdev, &dev_attr_vflip);
877 video_device_remove_file(vdev, &dev_attr_auto_exposure);
878 video_device_remove_file(vdev, &dev_attr_auto_whitebalance);
879 #else
880 device_remove_file(&vdev->dev, &dev_attr_release);
881 device_remove_file(&vdev->dev, &dev_attr_videostatus);
882 device_remove_file(&vdev->dev, &dev_attr_informations);
883 device_remove_file(&vdev->dev, &dev_attr_fps);
884 device_remove_file(&vdev->dev, &dev_attr_brightness);
885 device_remove_file(&vdev->dev, &dev_attr_exposure);
886 device_remove_file(&vdev->dev, &dev_attr_contrast);
887 device_remove_file(&vdev->dev, &dev_attr_gamma);
888 device_remove_file(&vdev->dev, &dev_attr_sharpness);
889 /*video_device_remove_file(vdev, &dev_attr_colour);*/
890 device_remove_file(&vdev->dev, &dev_attr_hflip);
891 device_remove_file(&vdev->dev, &dev_attr_vflip);
892 device_remove_file(&vdev->dev, &dev_attr_auto_exposure);
893 device_remove_file(&vdev->dev, &dev_attr_auto_whitebalance);
894 #endif