Fix warnings and errors when compiled under rt kernel
[microdia.git] / microdia-sysfs.c
blobd519a782307c4092b9493e846c77124378694134
1 /**
2 * @file microdia-sysfs.c
3 * @author Nicolas VIVIEN
4 * @date 2008-02-01
5 * @version v0.0.0
7 * @brief Driver for Microdia USB video camera
9 * @note Copyright (C) Nicolas VIVIEN
11 * @par Licences
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/kernel.h>
31 #include <linux/version.h>
32 #include <linux/errno.h>
33 #include <linux/slab.h>
34 #include <linux/kref.h>
35 #include <linux/device.h>
37 #include <linux/usb.h>
38 #include <media/v4l2-common.h>
40 #include "microdia.h"
41 #include "sn9c20x.h"
44 extern const struct microdia_coord microdia_image_sizes[MICRODIA_NBR_SIZES];
47 /**
48 * @brief show_release
50 * @param class Class device
52 * @retval buf Adress of buffer with the 'release' value
54 * @returns Size of buffer
56 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
57 static ssize_t show_release(struct class_device *class, char *buf)
58 #else
59 static ssize_t show_release(struct device *class, struct device_attribute *attr, char *buf)
60 #endif
62 struct video_device *vdev = to_video_device(class);
63 struct usb_microdia *dev = video_get_drvdata(vdev);
65 return sprintf(buf, "%d\n", dev->release);
69 /**
70 * @brief show_videostatus
72 * @param class Class device
74 * @retval buf Adress of buffer with the 'videostatus' value
76 * @returns Size of buffer
78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
79 static ssize_t show_videostatus(struct class_device *class, char *buf)
80 #else
81 static ssize_t show_videostatus(struct device *class, struct device_attribute *attr, char *buf)
82 #endif
84 struct video_device *vdev = to_video_device(class);
85 struct usb_microdia *dev = video_get_drvdata(vdev);
87 return sprintf(buf,
88 "Overflow frames : %d\n"
89 "Incomplete frames : %d\n"
90 "Dropped frames : %d\n",
91 dev->vframes_overflow,
92 dev->vframes_incomplete,
93 dev->vframes_dropped);
97 /**
98 * @brief show_informations
100 * @param class Class device
102 * @retval buf Adress of buffer with the 'informations' value
104 * @returns Size of buffer
106 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
107 static ssize_t show_informations(struct class_device *class, char *buf)
108 #else
109 static ssize_t show_informations(struct device *class, struct device_attribute *attr, char *buf)
110 #endif
112 int width, height;
113 char *pixelfmt = NULL;
115 struct video_device *vdev = to_video_device(class);
116 struct usb_microdia *dev = video_get_drvdata(vdev);
118 char *palette_bgr24 = "BGR24 - BGR-8-8-8 - 24 bits";
119 char *palette_rgb24 = "RGB24 - RGB-8-8-8 - 24 bits";
120 char *palette_yuyv = "YUYV - YUV 4:2:2 - 16 bits";
121 char *palette_i420 = "I420 - YUV 4:2:0 - 12 bits";
124 switch (dev->vsettings.format.pixelformat) {
125 case V4L2_PIX_FMT_BGR24:
126 pixelfmt = palette_bgr24;
127 break;
129 case V4L2_PIX_FMT_RGB24:
130 pixelfmt = palette_rgb24;
131 break;
133 case V4L2_PIX_FMT_YUYV:
134 pixelfmt = palette_yuyv;
135 break;
137 case V4L2_PIX_FMT_YUV420:
138 pixelfmt = palette_i420;
139 break;
142 switch (dev->resolution) {
143 case MICRODIA_80x60:
144 /*case MICRODIA_128x96:*/
145 case MICRODIA_160x120:
146 /*case MICRODIA_213x160: */
147 case MICRODIA_320x240:
148 case MICRODIA_640x480:
149 width = microdia_image_sizes[MICRODIA_640x480].x;
150 height = microdia_image_sizes[MICRODIA_640x480].y;
151 break;
153 case MICRODIA_800x600:
154 case MICRODIA_1024x768:
155 case MICRODIA_1280x1024:
156 width = microdia_image_sizes[MICRODIA_1280x1024].x;
157 height = microdia_image_sizes[MICRODIA_1280x1024].y;
158 break;
160 default:
161 width = 0;
162 height = 0;
165 return sprintf(buf,
166 "Asked resolution : %dx%d\n"
167 "Driver resolution : %dx%d\n"
168 "Webcam resolution : %dx%d\n"
169 "\n"
170 "%s\n"
171 "\n"
172 "Brightness : 0x%X\n"
173 "Contrast : 0x%X\n"
174 "Whiteness : 0x%X\n"
175 "Exposure : 0x%X\n"
176 "Sharpness : 0x%X\n"
177 "Horizontal flip : %d\n"
178 "Vertical flip : %d\n"
179 "Auto-exposure : %d\n"
180 "Auto-whitebalance : %d\n",
181 dev->view.x, dev->view.y,
182 microdia_image_sizes[dev->resolution].x, microdia_image_sizes[dev->resolution].y,
183 width, height,
184 pixelfmt,
185 0xFFFF & dev->vsettings.brightness,
186 0xFFFF & dev->vsettings.contrast,
187 0xFFFF & dev->vsettings.whiteness,
188 0xFFFF & dev->vsettings.exposure,
189 0x3F & dev->vsettings.sharpness,
190 dev->vsettings.hflip,
191 dev->vsettings.vflip,
192 dev->vsettings.auto_exposure,
193 dev->vsettings.auto_whitebalance);
197 /**
198 * @brief show_fps
200 * @param class Class device
202 * @retval buf Adress of buffer with the 'fps' value
204 * @returns Size of buffer
206 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
207 static ssize_t show_fps(struct class_device *class, char *buf)
208 #else
209 static ssize_t show_fps(struct device *class, struct device_attribute *attr, char *buf)
210 #endif
212 struct video_device *vdev = to_video_device(class);
213 struct usb_microdia *dev = video_get_drvdata(vdev);
215 return sprintf(buf, "%d\n", dev->vsettings.fps);
219 * @brief show_rgb_gain
221 * @param class Class device
223 * @retval buf Address of buffer with the 'rgb_gain' value
225 * @returns Size of buffer
227 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
228 static ssize_t show_rgb_gain(struct class_device *class, char *buf)
229 #else
230 static ssize_t show_rgb_gain(struct device *class,
231 struct device_attribute *attr, char *buf)
232 #endif
234 int rgb_gain = 0;
236 struct video_device *vdev = to_video_device(class);
237 struct usb_microdia *dev = video_get_drvdata(vdev);
238 rgb_gain |= dev->vsettings.rgb_gain[0] << 16;
239 rgb_gain |= dev->vsettings.rgb_gain[1] << 8;
240 rgb_gain |= dev->vsettings.rgb_gain[3];
241 return sprintf(buf, "0x%06X\n", rgb_gain);
245 * @brief store_exposure
247 * @param class Class device
248 * @param buf Buffer
249 * @param count Counter
251 * @returns Size of buffer
253 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
254 static ssize_t store_rgb_gain(struct class_device *class,
255 const char *buf, size_t count)
256 #else
257 static ssize_t store_rgb_gain(struct device *class,
258 struct device_attribute *attr, const char *buf, size_t count)
259 #endif
261 char *endp;
262 unsigned long rgb_gain;
264 struct video_device *vdev = to_video_device(class);
265 struct usb_microdia *dev = video_get_drvdata(vdev);
267 rgb_gain = simple_strtoul(buf, &endp, 16);
269 dev->vsettings.rgb_gain[0] = (rgb_gain >> 16) & 0x7f;
270 dev->vsettings.rgb_gain[1] = (rgb_gain >> 8) & 0x7f;
271 dev->vsettings.rgb_gain[2] = (rgb_gain >> 8) & 0x7f;
272 dev->vsettings.rgb_gain[3] = rgb_gain & 0x7f;
274 dev_microdia_camera_set_rgb_gain(dev);
276 return strlen(buf);
279 /**
280 * @brief show_exposure
282 * @param class Class device
284 * @retval buf Adress of buffer with the 'exposure' value
286 * @returns Size of buffer
288 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
289 static ssize_t show_exposure(struct class_device *class, char *buf)
290 #else
291 static ssize_t show_exposure(struct device *class, struct device_attribute *attr, char *buf)
292 #endif
294 struct video_device *vdev = to_video_device(class);
295 struct usb_microdia *dev = video_get_drvdata(vdev);
297 return sprintf(buf, "%X\n", dev->vsettings.exposure);
301 * @brief store_exposure
303 * @param class Class device
304 * @param buf Buffer
305 * @param count Counter
307 * @returns Size of buffer
309 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
310 static ssize_t store_exposure(struct class_device *class, const char *buf, size_t count)
311 #else
312 static ssize_t store_exposure(struct device *class, struct device_attribute *attr,
313 const char *buf, size_t count)
314 #endif
316 char *endp;
317 unsigned long value;
319 struct video_device *vdev = to_video_device(class);
320 struct usb_microdia *dev = video_get_drvdata(vdev);
322 value = simple_strtoul(buf, &endp, 16);
324 dev->vsettings.exposure = (int) value;
326 dev_microdia_camera_set_exposure(dev);
328 return strlen(buf);
331 /**
332 * @brief show_brightness
334 * @param class Class device
336 * @retval buf Adress of buffer with the 'brightness' value
338 * @returns Size of buffer
340 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
341 static ssize_t show_brightness(struct class_device *class, char *buf)
342 #else
343 static ssize_t show_brightness(struct device *class, struct device_attribute *attr, char *buf)
344 #endif
346 struct video_device *vdev = to_video_device(class);
347 struct usb_microdia *dev = video_get_drvdata(vdev);
349 return sprintf(buf, "%X\n", dev->vsettings.brightness);
352 /**
353 * @brief store_brightness
355 * @param class Class device
356 * @param buf Buffer
357 * @param count Counter
359 * @returns Size of buffer
361 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
362 static ssize_t store_brightness(struct class_device *class, const char *buf, size_t count)
363 #else
364 static ssize_t store_brightness(struct device *class, struct device_attribute *attr,
365 const char *buf, size_t count)
366 #endif
368 char *endp;
369 unsigned long value;
371 struct video_device *vdev = to_video_device(class);
372 struct usb_microdia *dev = video_get_drvdata(vdev);
374 value = simple_strtoul(buf, &endp, 16);
376 dev->vsettings.brightness = (int) value;
378 dev_microdia_camera_set_brightness(dev);
380 return strlen(buf);
383 /**
384 * @brief show_contrast
386 * @param class Class device
388 * @retval buf Adress of buffer with the 'contrast' value
390 * @returns Size of buffer
392 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
393 static ssize_t show_contrast(struct class_device *class, char *buf)
394 #else
395 static ssize_t show_contrast(struct device *class, struct device_attribute *attr, char *buf)
396 #endif
398 struct video_device *vdev = to_video_device(class);
399 struct usb_microdia *dev = video_get_drvdata(vdev);
401 return sprintf(buf, "%X\n", dev->vsettings.contrast);
405 /**
406 * @brief store_contrast
408 * @param class Class device
409 * @param buf Buffer
410 * @param count Counter
412 * @returns Size of buffer
414 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
415 static ssize_t store_contrast(struct class_device *class, const char *buf, size_t count)
416 #else
417 static ssize_t store_contrast(struct device *class, struct device_attribute *attr,
418 const char *buf, size_t count)
419 #endif
421 char *endp;
422 unsigned long value;
424 struct video_device *vdev = to_video_device(class);
425 struct usb_microdia *dev = video_get_drvdata(vdev);
427 value = simple_strtoul(buf, &endp, 16);
429 dev->vsettings.contrast = (int) value;
431 dev_microdia_camera_set_contrast(dev);
432 // dev_microdia_set_camera_quality(dev);
434 return strlen(buf);
438 /**
439 * @brief show_whitebalance
441 * @param class Class device
443 * @retval buf Adress of buffer with the 'whitebalance' value
445 * @returns Size of buffer
447 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
448 static ssize_t show_whitebalance(struct class_device *class, char *buf)
449 #else
450 static ssize_t show_whitebalance(struct device *class, struct device_attribute *attr, char *buf)
451 #endif
453 struct video_device *vdev = to_video_device(class);
454 struct usb_microdia *dev = video_get_drvdata(vdev);
456 return sprintf(buf, "%X\n", dev->vsettings.whiteness);
460 /**
461 * @brief store_whitebalance
463 * @param class Class device
464 * @param buf Buffer
465 * @param count Counter
467 * @returns Size of buffer
469 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
470 static ssize_t store_whitebalance(struct class_device *class, const char *buf, size_t count)
471 #else
472 static ssize_t store_whitebalance(struct device *class, struct device_attribute *attr,
473 const char *buf, size_t count)
474 #endif
476 char *endp;
477 unsigned long value;
479 struct video_device *vdev = to_video_device(class);
480 struct usb_microdia *dev = video_get_drvdata(vdev);
482 value = simple_strtoul(buf, &endp, 16);
484 dev->vsettings.whiteness = (int) value;
486 dev_microdia_camera_set_gamma(dev);
487 // dev_microdia_set_camera_quality(dev);
489 return strlen(buf);
493 /**
494 * @brief show_colour
496 * @param class Class device
498 * @retval buf Adress of buffer with the 'colour' value
500 * @returns Size of buffer
502 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
503 static ssize_t show_colour(struct class_device *class, char *buf)
504 #else
505 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
506 #endif
508 struct video_device *vdev = to_video_device(class);
509 struct usb_microdia *dev = video_get_drvdata(vdev);
511 return sprintf(buf, "%X\n", dev->vsettings.colour);
515 /**
516 * @brief store_colour
518 * @param class Class device
519 * @param buf Buffer
520 * @param count Counter
522 * @returns Size of buffer
524 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
525 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
526 #else
527 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
528 const char *buf, size_t count)
529 #endif
531 char *endp;
532 unsigned long value;
534 struct video_device *vdev = to_video_device(class);
535 struct usb_microdia *dev = video_get_drvdata(vdev);
537 value = simple_strtoul(buf, &endp, 16);
539 dev->vsettings.colour = (int) value;
541 // dev_microdia_set_camera_quality(dev);
543 return strlen(buf);
548 /**
549 * @brief show_sharpness
551 * @param class Class device
553 * @retval buf Adress of buffer with the 'sharpness' value
555 * @returns Size of buffer
557 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
558 static ssize_t show_sharpness(struct class_device *class, char *buf)
559 #else
560 static ssize_t show_sharpness(struct device *class, struct device_attribute *attr, char *buf)
561 #endif
563 struct video_device *vdev = to_video_device(class);
564 struct usb_microdia *dev = video_get_drvdata(vdev);
566 return sprintf(buf, "%X\n", dev->vsettings.sharpness);
569 /**
570 * @brief store_sharpness
572 * @param class Class device
573 * @param buf Buffer
574 * @param count Counter
576 * @returns Size of buffer
578 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
579 static ssize_t store_sharpness(struct class_device *class, const char *buf, size_t count)
580 #else
581 static ssize_t store_sharpness(struct device *class, struct device_attribute *attr,
582 const char *buf, size_t count)
583 #endif
585 char *endp;
586 unsigned long value;
588 struct video_device *vdev = to_video_device(class);
589 struct usb_microdia *dev = video_get_drvdata(vdev);
591 value = simple_strtoul(buf, &endp, 16);
593 if (value < 0 || value > 0x3f)
594 return -EINVAL;
596 dev->vsettings.sharpness = (int) value;
598 dev_microdia_camera_set_sharpness(dev);
600 return strlen(buf);
604 /**
605 * @brief show_hflip
607 * @param class Class device
609 * @retval buf Adress of buffer with the 'hflip' value
611 * @returns Size of buffer
613 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
614 static ssize_t show_hflip(struct class_device *class, char *buf)
615 #else
616 static ssize_t show_hflip(struct device *class, struct device_attribute *attr, char *buf)
617 #endif
619 struct video_device *vdev = to_video_device(class);
620 struct usb_microdia *dev = video_get_drvdata(vdev);
622 return sprintf(buf, "%d\n", dev->vsettings.hflip);
626 /**
627 * @brief store_hflip
629 * @param class Class device
630 * @param buf Buffer
631 * @param count Counter
633 * @returns Size of buffer
635 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
636 static ssize_t store_hflip(struct class_device *class, const char *buf, size_t count)
637 #else
638 static ssize_t store_hflip(struct device *class, struct device_attribute *attr,
639 const char *buf, size_t count)
640 #endif
642 struct video_device *vdev = to_video_device(class);
643 struct usb_microdia *dev = video_get_drvdata(vdev);
645 if (strncmp(buf, "1", 1) == 0)
646 dev->vsettings.hflip = 1;
647 else if (strncmp(buf, "0", 1) == 0)
648 dev->vsettings.hflip = 0;
649 else
650 return -EINVAL;
652 dev_microdia_camera_set_hvflip(dev);
654 return strlen(buf);
658 /**
659 * @brief show_vflip
661 * @param class Class device
663 * @retval buf Adress of buffer with the 'vflip' value
665 * @returns Size of buffer
667 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
668 static ssize_t show_vflip(struct class_device *class, char *buf)
669 #else
670 static ssize_t show_vflip(struct device *class, struct device_attribute *attr, char *buf)
671 #endif
673 struct video_device *vdev = to_video_device(class);
674 struct usb_microdia *dev = video_get_drvdata(vdev);
676 return sprintf(buf, "%d\n", dev->vsettings.vflip);
680 /**
681 * @brief store_vflip
683 * @param class Class device
684 * @param buf Buffer
685 * @param count Counter
687 * @returns Size of buffer
689 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
690 static ssize_t store_vflip(struct class_device *class, const char *buf, size_t count)
691 #else
692 static ssize_t store_vflip(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
693 #endif
695 struct video_device *vdev = to_video_device(class);
696 struct usb_microdia *dev = video_get_drvdata(vdev);
698 if (strncmp(buf, "1", 1) == 0)
699 dev->vsettings.vflip = 1;
700 else if (strncmp(buf, "0", 1) == 0)
701 dev->vsettings.vflip = 0;
702 else
703 return -EINVAL;
705 dev_microdia_camera_set_hvflip(dev);
707 return strlen(buf);
711 /**
712 * @brief show_autoexposure
714 * @param class Class device
716 * @retval buf Adress of buffer with the 'hflip' value
718 * @returns Size of buffer
720 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
721 static ssize_t show_autoexposure(struct class_device *class, char *buf)
722 #else
723 static ssize_t show_autoexposure(struct device *class, struct device_attribute *attr, char *buf)
724 #endif
726 struct video_device *vdev = to_video_device(class);
727 struct usb_microdia *dev = video_get_drvdata(vdev);
729 return sprintf(buf, "%d\n", dev->vsettings.auto_exposure);
733 /**
734 * @brief store_autoexposure
736 * @param class Class device
737 * @param buf Buffer
738 * @param count Counter
740 * @returns Size of buffer
742 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
743 static ssize_t store_autoexposure(struct class_device *class, const char *buf, size_t count)
744 #else
745 static ssize_t store_autoexposure(struct device *class, struct device_attribute *attr,
746 const char *buf, size_t count)
747 #endif
749 struct video_device *vdev = to_video_device(class);
750 struct usb_microdia *dev = video_get_drvdata(vdev);
752 if (strncmp(buf, "1", 1) == 0)
753 dev->vsettings.auto_exposure = 1;
754 else if (strncmp(buf, "0", 1) == 0)
755 dev->vsettings.auto_exposure = 0;
756 else
757 return -EINVAL;
759 dev_microdia_camera_set_auto_exposure(dev);
761 return strlen(buf);
765 /**
766 * @brief show_autowhitebalance
768 * @param class Class device
770 * @retval buf Adress of buffer with the 'vflip' value
772 * @returns Size of buffer
774 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
775 static ssize_t show_autowhitebalance(struct class_device *class, char *buf)
776 #else
777 static ssize_t show_autowhitebalance(struct device *class, struct device_attribute *attr, char *buf)
778 #endif
780 struct video_device *vdev = to_video_device(class);
781 struct usb_microdia *dev = video_get_drvdata(vdev);
783 return sprintf(buf, "%d\n", dev->vsettings.auto_whitebalance);
787 /**
788 * @brief store_autowhitebalance
790 * @param class Class device
791 * @param buf Buffer
792 * @param count Counter
794 * @returns Size of buffer
796 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
797 static ssize_t store_autowhitebalance(struct class_device *class, const char *buf, size_t count)
798 #else
799 static ssize_t store_autowhitebalance(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
800 #endif
802 struct video_device *vdev = to_video_device(class);
803 struct usb_microdia *dev = video_get_drvdata(vdev);
805 if (strncmp(buf, "1", 1) == 0)
806 dev->vsettings.auto_whitebalance = 1;
807 else if (strncmp(buf, "0", 1) == 0)
808 dev->vsettings.auto_whitebalance = 0;
809 else
810 return -EINVAL;
812 dev_microdia_camera_set_auto_whitebalance(dev);
814 return strlen(buf);
817 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
818 static CLASS_DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
819 static CLASS_DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
820 static CLASS_DEVICE_ATTR(informations, S_IRUGO, show_informations, NULL); /**< Informations */
821 static CLASS_DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
822 static CLASS_DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
823 static CLASS_DEVICE_ATTR(rgb_gain, S_IRUGO | S_IWUGO, show_rgb_gain, store_rgb_gain); /**< RGB Gain */
824 static CLASS_DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Brightness exposure */
825 static CLASS_DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
826 static CLASS_DEVICE_ATTR(whitebalance, S_IRUGO | S_IWUGO, show_whitebalance, store_whitebalance); /**< Whitebalance value */
827 static CLASS_DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
828 //static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
829 static CLASS_DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
830 static CLASS_DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
831 static CLASS_DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
832 static CLASS_DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
833 #else
834 static DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
835 static DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
836 static DEVICE_ATTR(informations, S_IRUGO, show_informations, NULL); /**< Informations */
837 static DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
838 static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
839 static DEVICE_ATTR(rgb_gain, S_IRUGO | S_IWUGO, show_rgb_gain, store_rgb_gain); /**< RGB Gain */
840 static DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Exposure value */
841 static DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
842 static DEVICE_ATTR(whitebalance, S_IRUGO | S_IWUGO, show_whitebalance, store_whitebalance); /**< Whitebalance value */
843 static DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
844 //static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
845 static DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
846 static DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
847 static DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
848 static DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
849 #endif
852 /**
853 * @brief Create the 'sys' entries.
855 * This function permits to create all the entries in the 'sys' filesystem.
857 * @param vdev Video device structure
859 * @returns 0 if all is OK
861 int microdia_create_sysfs_files(struct video_device *vdev)
863 int ret;
865 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
866 ret = video_device_create_file(vdev, &class_device_attr_release);
867 ret = video_device_create_file(vdev, &class_device_attr_videostatus);
868 ret = video_device_create_file(vdev, &class_device_attr_informations);
869 ret = video_device_create_file(vdev, &class_device_attr_fps);
870 ret = video_device_create_file(vdev, &class_device_attr_brightness);
871 ret = video_device_create_file(vdev, &class_device_attr_rgb_gain);
872 ret = video_device_create_file(vdev, &class_device_attr_exposure);
873 ret = video_device_create_file(vdev, &class_device_attr_contrast);
874 ret = video_device_create_file(vdev, &class_device_attr_whitebalance);
875 ret = video_device_create_file(vdev, &class_device_attr_sharpness);
876 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
877 ret = video_device_create_file(vdev, &class_device_attr_hflip);
878 ret = video_device_create_file(vdev, &class_device_attr_vflip);
879 ret = video_device_create_file(vdev, &class_device_attr_auto_exposure);
880 ret = video_device_create_file(vdev, &class_device_attr_auto_whitebalance);
881 #else
882 ret = video_device_create_file(vdev, &dev_attr_release);
883 ret = video_device_create_file(vdev, &dev_attr_videostatus);
884 ret = video_device_create_file(vdev, &dev_attr_informations);
885 ret = video_device_create_file(vdev, &dev_attr_fps);
886 ret = video_device_create_file(vdev, &dev_attr_brightness);
887 ret = video_device_create_file(vdev, &dev_attr_rgb_gain);
888 ret = video_device_create_file(vdev, &dev_attr_exposure);
889 ret = video_device_create_file(vdev, &dev_attr_contrast);
890 ret = video_device_create_file(vdev, &dev_attr_whitebalance);
891 ret = video_device_create_file(vdev, &dev_attr_sharpness);
892 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
893 ret = video_device_create_file(vdev, &dev_attr_hflip);
894 ret = video_device_create_file(vdev, &dev_attr_vflip);
895 ret = video_device_create_file(vdev, &dev_attr_auto_exposure);
896 ret = video_device_create_file(vdev, &dev_attr_auto_whitebalance);
897 #endif
898 return ret;
902 /**
903 * @brief Remove the 'sys' entries.
905 * This function permits to remove all the entries in the 'sys' filesystem.
907 * @param vdev Video device structure
909 * @returns 0 if all is OK
911 void microdia_remove_sysfs_files(struct video_device *vdev)
913 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
914 video_device_remove_file(vdev, &class_device_attr_release);
915 video_device_remove_file(vdev, &class_device_attr_videostatus);
916 video_device_remove_file(vdev, &class_device_attr_informations);
917 video_device_remove_file(vdev, &class_device_attr_fps);
918 video_device_remove_file(vdev, &class_device_attr_brightness);
919 video_device_remove_file(vdev, &class_device_attr_exposure);
920 video_device_remove_file(vdev, &class_device_attr_rgb_gain);
921 video_device_remove_file(vdev, &class_device_attr_contrast);
922 video_device_remove_file(vdev, &class_device_attr_whitebalance);
923 video_device_remove_file(vdev, &class_device_attr_sharpness);
924 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
925 video_device_remove_file(vdev, &class_device_attr_hflip);
926 video_device_remove_file(vdev, &class_device_attr_vflip);
927 video_device_remove_file(vdev, &class_device_attr_auto_exposure);
928 video_device_remove_file(vdev, &class_device_attr_auto_whitebalance);
929 #else
930 video_device_remove_file(vdev, &dev_attr_release);
931 video_device_remove_file(vdev, &dev_attr_videostatus);
932 video_device_remove_file(vdev, &dev_attr_informations);
933 video_device_remove_file(vdev, &dev_attr_fps);
934 video_device_remove_file(vdev, &dev_attr_brightness);
935 video_device_remove_file(vdev, &dev_attr_rgb_gain);
936 video_device_remove_file(vdev, &dev_attr_exposure);
937 video_device_remove_file(vdev, &dev_attr_contrast);
938 video_device_remove_file(vdev, &dev_attr_whitebalance);
939 video_device_remove_file(vdev, &dev_attr_sharpness);
940 /*video_device_remove_file(vdev, &dev_attr_colour);*/
941 video_device_remove_file(vdev, &dev_attr_hflip);
942 video_device_remove_file(vdev, &dev_attr_vflip);
943 video_device_remove_file(vdev, &dev_attr_auto_exposure);
944 video_device_remove_file(vdev, &dev_attr_auto_whitebalance);
945 #endif