Fix checkpatch errors in mt9vx11.h
[microdia.git] / microdia-sysfs.c
blob6328a2428686066f8c266de07d5a5bd266afefce
1 /**
2 * @file microdia-sysfs.c
3 * @author Nicolas VIVIEN
4 * @date 2008-02-01
5 * @version v0.0.0
7 * @brief Sysfs interface for image settings
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"
43 /**
44 * @brief show_release
46 * @param class Class device
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_microdia *dev = video_get_drvdata(vdev);
61 return sprintf(buf, "%d\n", dev->release);
65 /**
66 * @brief show_videostatus
68 * @param class Class device
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_microdia *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
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_microdia *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 "Whiteness : 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.whiteness,
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);
166 /**
167 * @brief show_fps
169 * @param class Class device
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_microdia *dev = video_get_drvdata(vdev);
184 return sprintf(buf, "%d\n", dev->vsettings.fps);
188 * @brief show_rgb_gain
190 * @param class Class device
192 * @retval buf Address of buffer with the 'rgb_gain' value
194 * @returns Size of buffer
196 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
197 static ssize_t show_rgb_gain(struct class_device *class, char *buf)
198 #else
199 static ssize_t show_rgb_gain(struct device *class,
200 struct device_attribute *attr, char *buf)
201 #endif
203 int rgb_gain = 0;
205 struct video_device *vdev = to_video_device(class);
206 struct usb_microdia *dev = video_get_drvdata(vdev);
207 rgb_gain |= dev->vsettings.rgb_gain[0] << 16;
208 rgb_gain |= dev->vsettings.rgb_gain[1] << 8;
209 rgb_gain |= dev->vsettings.rgb_gain[3];
210 return sprintf(buf, "0x%06X\n", rgb_gain);
214 * @brief store_exposure
216 * @param class Class device
217 * @param buf Buffer
218 * @param count Counter
220 * @returns Size of buffer
222 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
223 static ssize_t store_rgb_gain(struct class_device *class,
224 const char *buf, size_t count)
225 #else
226 static ssize_t store_rgb_gain(struct device *class,
227 struct device_attribute *attr, const char *buf, size_t count)
228 #endif
230 char *endp;
231 unsigned long rgb_gain;
233 struct video_device *vdev = to_video_device(class);
234 struct usb_microdia *dev = video_get_drvdata(vdev);
236 rgb_gain = simple_strtoul(buf, &endp, 16);
238 dev->vsettings.rgb_gain[0] = (rgb_gain >> 16) & 0x7f;
239 dev->vsettings.rgb_gain[1] = (rgb_gain >> 8) & 0x7f;
240 dev->vsettings.rgb_gain[2] = (rgb_gain >> 8) & 0x7f;
241 dev->vsettings.rgb_gain[3] = rgb_gain & 0x7f;
243 dev_microdia_camera_set_rgb_gain(dev);
245 return strlen(buf);
248 /**
249 * @brief show_exposure
251 * @param class Class device
253 * @retval buf Adress of buffer with the 'exposure' value
255 * @returns Size of buffer
257 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
258 static ssize_t show_exposure(struct class_device *class, char *buf)
259 #else
260 static ssize_t show_exposure(struct device *class, struct device_attribute *attr, char *buf)
261 #endif
263 struct video_device *vdev = to_video_device(class);
264 struct usb_microdia *dev = video_get_drvdata(vdev);
266 return sprintf(buf, "%X\n", dev->vsettings.exposure);
270 * @brief store_exposure
272 * @param class Class device
273 * @param buf Buffer
274 * @param count Counter
276 * @returns Size of buffer
278 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
279 static ssize_t store_exposure(struct class_device *class, const char *buf, size_t count)
280 #else
281 static ssize_t store_exposure(struct device *class, struct device_attribute *attr,
282 const char *buf, size_t count)
283 #endif
285 char *endp;
286 unsigned long value;
288 struct video_device *vdev = to_video_device(class);
289 struct usb_microdia *dev = video_get_drvdata(vdev);
291 value = simple_strtoul(buf, &endp, 16);
293 dev->vsettings.exposure = (int) value;
295 dev_microdia_camera_set_exposure(dev);
297 return strlen(buf);
300 /**
301 * @brief show_brightness
303 * @param class Class device
305 * @retval buf Adress of buffer with the 'brightness' value
307 * @returns Size of buffer
309 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
310 static ssize_t show_brightness(struct class_device *class, char *buf)
311 #else
312 static ssize_t show_brightness(struct device *class, struct device_attribute *attr, char *buf)
313 #endif
315 struct video_device *vdev = to_video_device(class);
316 struct usb_microdia *dev = video_get_drvdata(vdev);
318 return sprintf(buf, "%X\n", dev->vsettings.brightness);
321 /**
322 * @brief store_brightness
324 * @param class Class device
325 * @param buf Buffer
326 * @param count Counter
328 * @returns Size of buffer
330 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
331 static ssize_t store_brightness(struct class_device *class, const char *buf, size_t count)
332 #else
333 static ssize_t store_brightness(struct device *class, struct device_attribute *attr,
334 const char *buf, size_t count)
335 #endif
337 char *endp;
338 unsigned long value;
340 struct video_device *vdev = to_video_device(class);
341 struct usb_microdia *dev = video_get_drvdata(vdev);
343 value = simple_strtoul(buf, &endp, 16);
345 dev->vsettings.brightness = (int) value;
347 dev_microdia_camera_set_brightness(dev);
349 return strlen(buf);
352 /**
353 * @brief show_contrast
355 * @param class Class device
357 * @retval buf Adress of buffer with the 'contrast' value
359 * @returns Size of buffer
361 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
362 static ssize_t show_contrast(struct class_device *class, char *buf)
363 #else
364 static ssize_t show_contrast(struct device *class, struct device_attribute *attr, char *buf)
365 #endif
367 struct video_device *vdev = to_video_device(class);
368 struct usb_microdia *dev = video_get_drvdata(vdev);
370 return sprintf(buf, "%X\n", dev->vsettings.contrast);
374 /**
375 * @brief store_contrast
377 * @param class Class device
378 * @param buf Buffer
379 * @param count Counter
381 * @returns Size of buffer
383 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
384 static ssize_t store_contrast(struct class_device *class, const char *buf, size_t count)
385 #else
386 static ssize_t store_contrast(struct device *class, struct device_attribute *attr,
387 const char *buf, size_t count)
388 #endif
390 char *endp;
391 unsigned long value;
393 struct video_device *vdev = to_video_device(class);
394 struct usb_microdia *dev = video_get_drvdata(vdev);
396 value = simple_strtoul(buf, &endp, 16);
398 dev->vsettings.contrast = (int) value;
400 dev_microdia_camera_set_contrast(dev);
401 // dev_microdia_set_camera_quality(dev);
403 return strlen(buf);
407 /**
408 * @brief show_whitebalance
410 * @param class Class device
412 * @retval buf Adress of buffer with the 'whitebalance' value
414 * @returns Size of buffer
416 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
417 static ssize_t show_whitebalance(struct class_device *class, char *buf)
418 #else
419 static ssize_t show_whitebalance(struct device *class, struct device_attribute *attr, char *buf)
420 #endif
422 struct video_device *vdev = to_video_device(class);
423 struct usb_microdia *dev = video_get_drvdata(vdev);
425 return sprintf(buf, "%X\n", dev->vsettings.whiteness);
429 /**
430 * @brief store_whitebalance
432 * @param class Class device
433 * @param buf Buffer
434 * @param count Counter
436 * @returns Size of buffer
438 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
439 static ssize_t store_whitebalance(struct class_device *class, const char *buf, size_t count)
440 #else
441 static ssize_t store_whitebalance(struct device *class, struct device_attribute *attr,
442 const char *buf, size_t count)
443 #endif
445 char *endp;
446 unsigned long value;
448 struct video_device *vdev = to_video_device(class);
449 struct usb_microdia *dev = video_get_drvdata(vdev);
451 value = simple_strtoul(buf, &endp, 16);
453 dev->vsettings.whiteness = (int) value;
455 dev_microdia_camera_set_gamma(dev);
456 // dev_microdia_set_camera_quality(dev);
458 return strlen(buf);
462 /**
463 * @brief show_colour
465 * @param class Class device
467 * @retval buf Adress of buffer with the 'colour' value
469 * @returns Size of buffer
471 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
472 static ssize_t show_colour(struct class_device *class, char *buf)
473 #else
474 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
475 #endif
477 struct video_device *vdev = to_video_device(class);
478 struct usb_microdia *dev = video_get_drvdata(vdev);
480 return sprintf(buf, "%X\n", dev->vsettings.colour);
484 /**
485 * @brief store_colour
487 * @param class Class device
488 * @param buf Buffer
489 * @param count Counter
491 * @returns Size of buffer
493 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
494 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
495 #else
496 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
497 const char *buf, size_t count)
498 #endif
500 char *endp;
501 unsigned long value;
503 struct video_device *vdev = to_video_device(class);
504 struct usb_microdia *dev = video_get_drvdata(vdev);
506 value = simple_strtoul(buf, &endp, 16);
508 dev->vsettings.colour = (int) value;
510 // dev_microdia_set_camera_quality(dev);
512 return strlen(buf);
517 /**
518 * @brief show_sharpness
520 * @param class Class device
522 * @retval buf Adress of buffer with the 'sharpness' value
524 * @returns Size of buffer
526 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
527 static ssize_t show_sharpness(struct class_device *class, char *buf)
528 #else
529 static ssize_t show_sharpness(struct device *class, struct device_attribute *attr, char *buf)
530 #endif
532 struct video_device *vdev = to_video_device(class);
533 struct usb_microdia *dev = video_get_drvdata(vdev);
535 return sprintf(buf, "%X\n", dev->vsettings.sharpness);
538 /**
539 * @brief store_sharpness
541 * @param class Class device
542 * @param buf Buffer
543 * @param count Counter
545 * @returns Size of buffer
547 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
548 static ssize_t store_sharpness(struct class_device *class, const char *buf, size_t count)
549 #else
550 static ssize_t store_sharpness(struct device *class, struct device_attribute *attr,
551 const char *buf, size_t count)
552 #endif
554 char *endp;
555 unsigned long value;
557 struct video_device *vdev = to_video_device(class);
558 struct usb_microdia *dev = video_get_drvdata(vdev);
560 value = simple_strtoul(buf, &endp, 16);
562 if (value < 0 || value > 0x3f)
563 return -EINVAL;
565 dev->vsettings.sharpness = (int) value;
567 dev_microdia_camera_set_sharpness(dev);
569 return strlen(buf);
573 /**
574 * @brief show_hflip
576 * @param class Class device
578 * @retval buf Adress of buffer with the 'hflip' value
580 * @returns Size of buffer
582 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
583 static ssize_t show_hflip(struct class_device *class, char *buf)
584 #else
585 static ssize_t show_hflip(struct device *class, struct device_attribute *attr, char *buf)
586 #endif
588 struct video_device *vdev = to_video_device(class);
589 struct usb_microdia *dev = video_get_drvdata(vdev);
591 return sprintf(buf, "%d\n", dev->vsettings.hflip);
595 /**
596 * @brief store_hflip
598 * @param class Class device
599 * @param buf Buffer
600 * @param count Counter
602 * @returns Size of buffer
604 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
605 static ssize_t store_hflip(struct class_device *class, const char *buf, size_t count)
606 #else
607 static ssize_t store_hflip(struct device *class, struct device_attribute *attr,
608 const char *buf, size_t count)
609 #endif
611 struct video_device *vdev = to_video_device(class);
612 struct usb_microdia *dev = video_get_drvdata(vdev);
614 if (strncmp(buf, "1", 1) == 0)
615 dev->vsettings.hflip = 1;
616 else if (strncmp(buf, "0", 1) == 0)
617 dev->vsettings.hflip = 0;
618 else
619 return -EINVAL;
621 dev_microdia_camera_set_hvflip(dev);
623 return strlen(buf);
627 /**
628 * @brief show_vflip
630 * @param class Class device
632 * @retval buf Adress of buffer with the 'vflip' value
634 * @returns Size of buffer
636 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
637 static ssize_t show_vflip(struct class_device *class, char *buf)
638 #else
639 static ssize_t show_vflip(struct device *class, struct device_attribute *attr, char *buf)
640 #endif
642 struct video_device *vdev = to_video_device(class);
643 struct usb_microdia *dev = video_get_drvdata(vdev);
645 return sprintf(buf, "%d\n", dev->vsettings.vflip);
649 /**
650 * @brief store_vflip
652 * @param class Class device
653 * @param buf Buffer
654 * @param count Counter
656 * @returns Size of buffer
658 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
659 static ssize_t store_vflip(struct class_device *class, const char *buf, size_t count)
660 #else
661 static ssize_t store_vflip(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
662 #endif
664 struct video_device *vdev = to_video_device(class);
665 struct usb_microdia *dev = video_get_drvdata(vdev);
667 if (strncmp(buf, "1", 1) == 0)
668 dev->vsettings.vflip = 1;
669 else if (strncmp(buf, "0", 1) == 0)
670 dev->vsettings.vflip = 0;
671 else
672 return -EINVAL;
674 dev_microdia_camera_set_hvflip(dev);
676 return strlen(buf);
680 /**
681 * @brief show_autoexposure
683 * @param class Class device
685 * @retval buf Adress of buffer with the 'hflip' value
687 * @returns Size of buffer
689 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
690 static ssize_t show_autoexposure(struct class_device *class, char *buf)
691 #else
692 static ssize_t show_autoexposure(struct device *class, struct device_attribute *attr, char *buf)
693 #endif
695 struct video_device *vdev = to_video_device(class);
696 struct usb_microdia *dev = video_get_drvdata(vdev);
698 return sprintf(buf, "%d\n", dev->vsettings.auto_exposure);
702 /**
703 * @brief store_autoexposure
705 * @param class Class device
706 * @param buf Buffer
707 * @param count Counter
709 * @returns Size of buffer
711 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
712 static ssize_t store_autoexposure(struct class_device *class, const char *buf, size_t count)
713 #else
714 static ssize_t store_autoexposure(struct device *class, struct device_attribute *attr,
715 const char *buf, size_t count)
716 #endif
718 struct video_device *vdev = to_video_device(class);
719 struct usb_microdia *dev = video_get_drvdata(vdev);
721 if (strncmp(buf, "1", 1) == 0)
722 dev->vsettings.auto_exposure = 1;
723 else if (strncmp(buf, "0", 1) == 0)
724 dev->vsettings.auto_exposure = 0;
725 else
726 return -EINVAL;
728 dev_microdia_camera_set_auto_exposure(dev);
730 return strlen(buf);
734 /**
735 * @brief show_autowhitebalance
737 * @param class Class device
739 * @retval buf Adress of buffer with the 'vflip' value
741 * @returns Size of buffer
743 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
744 static ssize_t show_autowhitebalance(struct class_device *class, char *buf)
745 #else
746 static ssize_t show_autowhitebalance(struct device *class, struct device_attribute *attr, char *buf)
747 #endif
749 struct video_device *vdev = to_video_device(class);
750 struct usb_microdia *dev = video_get_drvdata(vdev);
752 return sprintf(buf, "%d\n", dev->vsettings.auto_whitebalance);
756 /**
757 * @brief store_autowhitebalance
759 * @param class Class device
760 * @param buf Buffer
761 * @param count Counter
763 * @returns Size of buffer
765 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
766 static ssize_t store_autowhitebalance(struct class_device *class, const char *buf, size_t count)
767 #else
768 static ssize_t store_autowhitebalance(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
769 #endif
771 struct video_device *vdev = to_video_device(class);
772 struct usb_microdia *dev = video_get_drvdata(vdev);
774 if (strncmp(buf, "1", 1) == 0)
775 dev->vsettings.auto_whitebalance = 1;
776 else if (strncmp(buf, "0", 1) == 0)
777 dev->vsettings.auto_whitebalance = 0;
778 else
779 return -EINVAL;
781 dev_microdia_camera_set_auto_whitebalance(dev);
783 return strlen(buf);
786 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
787 static CLASS_DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
788 static CLASS_DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
789 static CLASS_DEVICE_ATTR(informations, S_IRUGO, show_informations, NULL); /**< Informations */
790 static CLASS_DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
791 static CLASS_DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
792 static CLASS_DEVICE_ATTR(rgb_gain, S_IRUGO | S_IWUGO, show_rgb_gain, store_rgb_gain); /**< RGB Gain */
793 static CLASS_DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Brightness exposure */
794 static CLASS_DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
795 static CLASS_DEVICE_ATTR(whitebalance, S_IRUGO | S_IWUGO, show_whitebalance, store_whitebalance); /**< Whitebalance value */
796 static CLASS_DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
797 //static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
798 static CLASS_DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
799 static CLASS_DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
800 static CLASS_DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
801 static CLASS_DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
802 #else
803 static DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
804 static DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
805 static DEVICE_ATTR(informations, S_IRUGO, show_informations, NULL); /**< Informations */
806 static DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
807 static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
808 static DEVICE_ATTR(rgb_gain, S_IRUGO | S_IWUGO, show_rgb_gain, store_rgb_gain); /**< RGB Gain */
809 static DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Exposure value */
810 static DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
811 static DEVICE_ATTR(whitebalance, S_IRUGO | S_IWUGO, show_whitebalance, store_whitebalance); /**< Whitebalance value */
812 static DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
813 //static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
814 static DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
815 static DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
816 static DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
817 static DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
818 #endif
821 /**
822 * @brief Create the 'sys' entries.
824 * This function permits to create all the entries in the 'sys' filesystem.
826 * @param vdev Video device structure
828 * @returns 0 if all is OK
830 int microdia_create_sysfs_files(struct video_device *vdev)
832 int ret;
834 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
835 ret = video_device_create_file(vdev, &class_device_attr_release);
836 ret = video_device_create_file(vdev, &class_device_attr_videostatus);
837 ret = video_device_create_file(vdev, &class_device_attr_informations);
838 ret = video_device_create_file(vdev, &class_device_attr_fps);
839 ret = video_device_create_file(vdev, &class_device_attr_brightness);
840 ret = video_device_create_file(vdev, &class_device_attr_rgb_gain);
841 ret = video_device_create_file(vdev, &class_device_attr_exposure);
842 ret = video_device_create_file(vdev, &class_device_attr_contrast);
843 ret = video_device_create_file(vdev, &class_device_attr_whitebalance);
844 ret = video_device_create_file(vdev, &class_device_attr_sharpness);
845 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
846 ret = video_device_create_file(vdev, &class_device_attr_hflip);
847 ret = video_device_create_file(vdev, &class_device_attr_vflip);
848 ret = video_device_create_file(vdev, &class_device_attr_auto_exposure);
849 ret = video_device_create_file(vdev, &class_device_attr_auto_whitebalance);
850 #else
851 ret = video_device_create_file(vdev, &dev_attr_release);
852 ret = video_device_create_file(vdev, &dev_attr_videostatus);
853 ret = video_device_create_file(vdev, &dev_attr_informations);
854 ret = video_device_create_file(vdev, &dev_attr_fps);
855 ret = video_device_create_file(vdev, &dev_attr_brightness);
856 ret = video_device_create_file(vdev, &dev_attr_rgb_gain);
857 ret = video_device_create_file(vdev, &dev_attr_exposure);
858 ret = video_device_create_file(vdev, &dev_attr_contrast);
859 ret = video_device_create_file(vdev, &dev_attr_whitebalance);
860 ret = video_device_create_file(vdev, &dev_attr_sharpness);
861 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
862 ret = video_device_create_file(vdev, &dev_attr_hflip);
863 ret = video_device_create_file(vdev, &dev_attr_vflip);
864 ret = video_device_create_file(vdev, &dev_attr_auto_exposure);
865 ret = video_device_create_file(vdev, &dev_attr_auto_whitebalance);
866 #endif
867 return ret;
871 /**
872 * @brief Remove the 'sys' entries.
874 * This function permits to remove all the entries in the 'sys' filesystem.
876 * @param vdev Video device structure
878 * @returns 0 if all is OK
880 void microdia_remove_sysfs_files(struct video_device *vdev)
882 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
883 video_device_remove_file(vdev, &class_device_attr_release);
884 video_device_remove_file(vdev, &class_device_attr_videostatus);
885 video_device_remove_file(vdev, &class_device_attr_informations);
886 video_device_remove_file(vdev, &class_device_attr_fps);
887 video_device_remove_file(vdev, &class_device_attr_brightness);
888 video_device_remove_file(vdev, &class_device_attr_exposure);
889 video_device_remove_file(vdev, &class_device_attr_rgb_gain);
890 video_device_remove_file(vdev, &class_device_attr_contrast);
891 video_device_remove_file(vdev, &class_device_attr_whitebalance);
892 video_device_remove_file(vdev, &class_device_attr_sharpness);
893 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
894 video_device_remove_file(vdev, &class_device_attr_hflip);
895 video_device_remove_file(vdev, &class_device_attr_vflip);
896 video_device_remove_file(vdev, &class_device_attr_auto_exposure);
897 video_device_remove_file(vdev, &class_device_attr_auto_whitebalance);
898 #else
899 video_device_remove_file(vdev, &dev_attr_release);
900 video_device_remove_file(vdev, &dev_attr_videostatus);
901 video_device_remove_file(vdev, &dev_attr_informations);
902 video_device_remove_file(vdev, &dev_attr_fps);
903 video_device_remove_file(vdev, &dev_attr_brightness);
904 video_device_remove_file(vdev, &dev_attr_rgb_gain);
905 video_device_remove_file(vdev, &dev_attr_exposure);
906 video_device_remove_file(vdev, &dev_attr_contrast);
907 video_device_remove_file(vdev, &dev_attr_whitebalance);
908 video_device_remove_file(vdev, &dev_attr_sharpness);
909 /*video_device_remove_file(vdev, &dev_attr_colour);*/
910 video_device_remove_file(vdev, &dev_attr_hflip);
911 video_device_remove_file(vdev, &dev_attr_vflip);
912 video_device_remove_file(vdev, &dev_attr_auto_exposure);
913 video_device_remove_file(vdev, &dev_attr_auto_whitebalance);
914 #endif