Fixes missing termination in init block for the hv7131r sensor.
[microdia.git] / sn9c20x-sysfs.c
blob15bb13cb8947104e00967e2bc57765f9bd8a5772
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_information
96 * @param class Class device
97 * @param attr
98 * @retval buf Address of buffer with the 'information' value
100 * @returns Size of buffer
102 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
103 static ssize_t show_information(struct class_device *class, char *buf)
104 #else
105 static ssize_t show_information(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_bayer = "BAYER - BGGR - 8 bits";
114 char *palette_i420 = "SN9C20X_I420 - YUV 4:2:0 - 12 bits";
115 char *palette_jpeg = "JPEG - YUV 4:2:2 - 16 bits";
118 switch (dev->vsettings.format.pixelformat) {
119 case V4L2_PIX_FMT_SBGGR8:
120 pixelfmt = palette_bayer;
121 break;
123 case V4L2_PIX_FMT_JPEG:
124 pixelfmt = palette_jpeg;
125 break;
127 case V4L2_PIX_FMT_SN9C20X_I420:
128 pixelfmt = palette_i420;
129 break;
132 return sprintf(buf,
133 "Driver Resolution : %dx%d\n"
134 "\n"
135 "%s\n"
136 "\n"
137 "Brightness : 0x%02X\n"
138 "Contrast : 0x%02X\n"
139 "Gamma : 0x%02X\n"
140 "Exposure : 0x%02X\n"
141 "Gain : 0x%02X\n"
142 "Sharpness : 0x%02X\n"
143 "Red Balance : 0x%02X\n"
144 "Blue Balance : 0x%02X\n"
145 "Horizontal flip : %d\n"
146 "Vertical flip : %d\n"
147 "Auto-exposure : %d\n"
148 "Auto-gain : %d\n"
149 "Auto-whitebalance : %d\n",
150 dev->vsettings.format.width,
151 dev->vsettings.format.height,
152 pixelfmt,
153 0xFF & dev->vsettings.brightness,
154 0xFF & dev->vsettings.contrast,
155 0xFF & dev->vsettings.gamma,
156 0xFF & dev->vsettings.exposure,
157 0xFF & dev->vsettings.gain,
158 0x3F & dev->vsettings.sharpness,
159 0x7F & dev->vsettings.red_gain,
160 0x7F & dev->vsettings.blue_gain,
161 dev->vsettings.hflip,
162 dev->vsettings.vflip,
163 dev->vsettings.auto_exposure,
164 dev->vsettings.auto_gain,
165 dev->vsettings.auto_whitebalance);
170 * @brief show_fps
172 * @param class Class device
173 * @param attr
174 * @retval buf Adress of buffer with the 'fps' value
176 * @returns Size of buffer
178 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
179 static ssize_t show_fps(struct class_device *class, char *buf)
180 #else
181 static ssize_t show_fps(struct device *class, struct device_attribute *attr, char *buf)
182 #endif
184 struct video_device *vdev = to_video_device(class);
185 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
187 return sprintf(buf, "%d\n", dev->vsettings.fps);
191 * @brief show_gain
193 * @param class Class device
194 * @param attr
195 * @retval buf Adress of buffer with the 'gain' value
197 * @returns Size of buffer
199 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
200 static ssize_t show_gain(struct class_device *class, char *buf)
201 #else
202 static ssize_t show_gain(struct device *class, struct device_attribute *attr, char *buf)
203 #endif
205 struct video_device *vdev = to_video_device(class);
206 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
208 return sprintf(buf, "%X\n", dev->vsettings.gain);
212 * @brief store_gain
214 * @param class Class device
215 * @param buf Buffer
216 * @param count Counter
217 * @param attr
219 * @returns Size of buffer
221 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
222 static ssize_t store_gain(struct class_device *class, const char *buf, size_t count)
223 #else
224 static ssize_t store_gain(struct device *class, struct device_attribute *attr,
225 const char *buf, size_t count)
226 #endif
228 char *endp;
229 unsigned long value;
231 struct video_device *vdev = to_video_device(class);
232 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
234 value = simple_strtoul(buf, &endp, 16);
236 sn9c20x_set_camera_control(dev,
237 V4L2_CID_GAIN,
238 value);
240 return strlen(buf);
243 * @brief show_exposure
245 * @param class Class device
246 * @param attr
247 * @retval buf Adress of buffer with the 'exposure' value
249 * @returns Size of buffer
251 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
252 static ssize_t show_exposure(struct class_device *class, char *buf)
253 #else
254 static ssize_t show_exposure(struct device *class, struct device_attribute *attr, char *buf)
255 #endif
257 struct video_device *vdev = to_video_device(class);
258 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
260 return sprintf(buf, "%X\n", dev->vsettings.exposure);
264 * @brief store_exposure
266 * @param class Class device
267 * @param buf Buffer
268 * @param count Counter
269 * @param attr
271 * @returns Size of buffer
273 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
274 static ssize_t store_exposure(struct class_device *class, const char *buf, size_t count)
275 #else
276 static ssize_t store_exposure(struct device *class, struct device_attribute *attr,
277 const char *buf, size_t count)
278 #endif
280 char *endp;
281 unsigned long value;
283 struct video_device *vdev = to_video_device(class);
284 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
286 value = simple_strtoul(buf, &endp, 16);
288 sn9c20x_set_camera_control(dev,
289 V4L2_CID_EXPOSURE,
290 value);
292 return strlen(buf);
296 * @brief show_brightness
298 * @param class Class device
299 * @param attr
300 * @retval buf Adress of buffer with the 'brightness' value
302 * @returns Size of buffer
304 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
305 static ssize_t show_brightness(struct class_device *class, char *buf)
306 #else
307 static ssize_t show_brightness(struct device *class, struct device_attribute *attr, char *buf)
308 #endif
310 struct video_device *vdev = to_video_device(class);
311 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
313 return sprintf(buf, "%X\n", dev->vsettings.brightness);
317 * @brief store_brightness
319 * @param class Class device
320 * @param buf Buffer
321 * @param count Counter
322 * @param attr
324 * @returns Size of buffer
326 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
327 static ssize_t store_brightness(struct class_device *class, const char *buf, size_t count)
328 #else
329 static ssize_t store_brightness(struct device *class, struct device_attribute *attr,
330 const char *buf, size_t count)
331 #endif
333 char *endp;
334 unsigned long value;
336 struct video_device *vdev = to_video_device(class);
337 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
339 value = simple_strtoul(buf, &endp, 16);
341 sn9c20x_set_camera_control(dev,
342 V4L2_CID_BRIGHTNESS,
343 value);
345 return strlen(buf);
349 * @brief show_contrast
351 * @param class Class device
352 * @param attr
353 * @retval buf Adress of buffer with the 'contrast' value
355 * @returns Size of buffer
357 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
358 static ssize_t show_contrast(struct class_device *class, char *buf)
359 #else
360 static ssize_t show_contrast(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.contrast);
371 * @brief store_contrast
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_contrast(struct class_device *class, const char *buf, size_t count)
382 #else
383 static ssize_t store_contrast(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_CONTRAST,
397 value);
399 return strlen(buf);
404 * @brief show_whitebalance
406 * @param class Class device
407 * @param attr
408 * @retval buf Adress of buffer with the 'whitebalance' value
410 * @returns Size of buffer
412 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
413 static ssize_t show_gamma(struct class_device *class, char *buf)
414 #else
415 static ssize_t show_gamma(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.gamma);
426 * @brief store_gamma
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_gamma(struct class_device *class, const char *buf, size_t count)
437 #else
438 static ssize_t store_gamma(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 sn9c20x_set_camera_control(dev,
451 V4L2_CID_GAMMA,
452 value);
454 return strlen(buf);
459 * @brief show_colour
461 * @param class Class device
462 * @param attr
463 * @retval buf Adress of buffer with the 'colour' value
465 * @returns Size of buffer
467 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
468 static ssize_t show_colour(struct class_device *class, char *buf)
469 #else
470 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
471 #endif
473 struct video_device *vdev = to_video_device(class);
474 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
476 return sprintf(buf, "%X\n", dev->vsettings.colour);
481 * @brief store_colour
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_colour(struct class_device *class, const char *buf, size_t count)
492 #else
493 static ssize_t store_colour(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 dev->vsettings.colour = (int) value;
507 / dev_sn9c20x_set_camera_quality(dev); /
509 return strlen(buf);
515 * @brief show_sharpness
517 * @param class Class device
518 * @param attr
519 * @retval buf Adress of buffer with the 'sharpness' value
521 * @returns Size of buffer
523 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
524 static ssize_t show_sharpness(struct class_device *class, char *buf)
525 #else
526 static ssize_t show_sharpness(struct device *class, struct device_attribute *attr, char *buf)
527 #endif
529 struct video_device *vdev = to_video_device(class);
530 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
532 return sprintf(buf, "%X\n", dev->vsettings.sharpness);
536 * @brief store_sharpness
538 * @param class Class device
539 * @param buf Buffer
540 * @param count Counter
541 * @param attr
543 * @returns Size of buffer
545 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
546 static ssize_t store_sharpness(struct class_device *class, const char *buf, size_t count)
547 #else
548 static ssize_t store_sharpness(struct device *class, struct device_attribute *attr,
549 const char *buf, size_t count)
550 #endif
552 char *endp;
553 unsigned long value;
555 struct video_device *vdev = to_video_device(class);
556 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
558 value = simple_strtoul(buf, &endp, 16);
560 if (value < 0 || value > 0x3f)
561 return -EINVAL;
563 sn9c20x_set_camera_control(dev,
564 V4L2_CID_SHARPNESS,
565 value);
567 return strlen(buf);
572 * @brief show_hflip
574 * @param class Class device
575 * @param attr
576 * @retval buf Adress of buffer with the 'hflip' value
578 * @returns Size of buffer
580 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
581 static ssize_t show_hflip(struct class_device *class, char *buf)
582 #else
583 static ssize_t show_hflip(struct device *class, struct device_attribute *attr, char *buf)
584 #endif
586 struct video_device *vdev = to_video_device(class);
587 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
589 return sprintf(buf, "%d\n", dev->vsettings.hflip);
594 * @brief store_hflip
596 * @param class Class device
597 * @param buf Buffer
598 * @param count Counter
599 * @param attr
601 * @returns Size of buffer
603 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
604 static ssize_t store_hflip(struct class_device *class, const char *buf, size_t count)
605 #else
606 static ssize_t store_hflip(struct device *class, struct device_attribute *attr,
607 const char *buf, size_t count)
608 #endif
610 char *endp;
611 unsigned long value;
612 struct video_device *vdev = to_video_device(class);
613 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
615 value = simple_strtoul(buf, &endp, 10);
617 if (value != 0 && value != 1)
618 return -EINVAL;
620 sn9c20x_set_camera_control(dev,
621 V4L2_CID_HFLIP,
622 value);
624 return strlen(buf);
629 * @brief show_vflip
631 * @param class Class device
632 * @param attr
633 * @retval buf Adress of buffer with the 'vflip' value
635 * @returns Size of buffer
637 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
638 static ssize_t show_vflip(struct class_device *class, char *buf)
639 #else
640 static ssize_t show_vflip(struct device *class, struct device_attribute *attr, char *buf)
641 #endif
643 struct video_device *vdev = to_video_device(class);
644 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
646 return sprintf(buf, "%d\n", dev->vsettings.vflip);
651 * @brief store_vflip
653 * @param class Class device
654 * @param buf Buffer
655 * @param count Counter
656 * @param attr
658 * @returns Size of buffer
660 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
661 static ssize_t store_vflip(struct class_device *class, const char *buf, size_t count)
662 #else
663 static ssize_t store_vflip(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
664 #endif
666 char *endp;
667 unsigned long value;
668 struct video_device *vdev = to_video_device(class);
669 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
671 value = simple_strtoul(buf, &endp, 10);
673 if (value != 0 && value != 1)
674 return -EINVAL;
676 sn9c20x_set_camera_control(dev,
677 V4L2_CID_VFLIP,
678 value);
680 return strlen(buf);
685 * @brief show_autoexposure
687 * @param class Class device
688 * @param attr
689 * @retval buf Adress of buffer with the 'hflip' value
691 * @returns Size of buffer
693 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
694 static ssize_t show_autoexposure(struct class_device *class, char *buf)
695 #else
696 static ssize_t show_autoexposure(struct device *class, struct device_attribute *attr, char *buf)
697 #endif
699 struct video_device *vdev = to_video_device(class);
700 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
702 return sprintf(buf, "%d\n", dev->vsettings.auto_exposure);
707 * @brief store_autoexposure
709 * @param class Class device
710 * @param buf Buffer
711 * @param count Counter
712 * @param attr
714 * @returns Size of buffer
716 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
717 static ssize_t store_autoexposure(struct class_device *class, const char *buf, size_t count)
718 #else
719 static ssize_t store_autoexposure(struct device *class, struct device_attribute *attr,
720 const char *buf, size_t count)
721 #endif
723 unsigned long value;
724 struct video_device *vdev = to_video_device(class);
725 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
727 if (strncmp(buf, "1", 1) == 0)
728 value = 1;
729 else if (strncmp(buf, "0", 1) == 0)
730 value = 0;
731 else
732 return -EINVAL;
734 sn9c20x_set_camera_control(dev,
735 V4L2_CID_EXPOSURE_AUTO,
736 value);
738 return strlen(buf);
743 * @brief show_autowhitebalance
745 * @param class Class device
746 * @param attr
747 * @retval buf Adress of buffer with the 'vflip' value
749 * @returns Size of buffer
751 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
752 static ssize_t show_autowhitebalance(struct class_device *class, char *buf)
753 #else
754 static ssize_t show_autowhitebalance(struct device *class, struct device_attribute *attr, char *buf)
755 #endif
757 struct video_device *vdev = to_video_device(class);
758 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
760 return sprintf(buf, "%d\n", dev->vsettings.auto_whitebalance);
765 * @brief store_autowhitebalance
767 * @param class Class device
768 * @param buf Buffer
769 * @param count Counter
770 * @param attr
772 * @returns Size of buffer
774 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
775 static ssize_t store_autowhitebalance(struct class_device *class, const char *buf, size_t count)
776 #else
777 static ssize_t store_autowhitebalance(struct device *class, struct device_attribute *attr, const char *buf, size_t count)
778 #endif
780 char *endp;
781 unsigned long value;
782 struct video_device *vdev = to_video_device(class);
783 struct usb_sn9c20x *dev = video_get_drvdata(vdev);
785 value = simple_strtoul(buf, &endp, 10);
787 if (value != 0 && value != 1)
788 return -EINVAL;
790 sn9c20x_set_camera_control(dev,
791 V4L2_CID_AUTO_WHITE_BALANCE,
792 value);
794 return strlen(buf);
797 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
798 static CLASS_DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
799 static CLASS_DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
800 static CLASS_DEVICE_ATTR(information, S_IRUGO, show_information, NULL); /**< Information */
801 static CLASS_DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
802 static CLASS_DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
803 static CLASS_DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Exposure value */
804 static CLASS_DEVICE_ATTR(gain, S_IRUGO | S_IWUGO, show_gain, store_gain); /**< Gain value */
805 static CLASS_DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
806 static CLASS_DEVICE_ATTR(gamma, S_IRUGO | S_IWUGO, show_gamma, store_gamma); /**< Gamma value */
807 static CLASS_DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
808 /*static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /< Hue value */
809 static CLASS_DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
810 static CLASS_DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
811 static CLASS_DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
812 static CLASS_DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
813 #else
814 static DEVICE_ATTR(release, S_IRUGO, show_release, NULL); /**< Release value */
815 static DEVICE_ATTR(videostatus, S_IRUGO, show_videostatus, NULL); /**< Video status */
816 static DEVICE_ATTR(information, S_IRUGO, show_information, NULL); /**< Information */
817 static DEVICE_ATTR(fps, S_IRUGO, show_fps, NULL); /**< FPS value */
818 static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**< Brightness value */
819 static DEVICE_ATTR(exposure, S_IRUGO | S_IWUGO, show_exposure, store_exposure); /**< Exposure value */
820 static DEVICE_ATTR(gain, S_IRUGO | S_IWUGO, show_gain, store_gain); /**< Gain value */
821 static DEVICE_ATTR(contrast, S_IRUGO | S_IWUGO, show_contrast, store_contrast); /**< Contrast value */
822 static DEVICE_ATTR(gamma, S_IRUGO | S_IWUGO, show_gamma, store_gamma); /**< Gamma value */
823 static DEVICE_ATTR(sharpness, S_IRUGO | S_IWUGO, show_sharpness, store_sharpness); /**< Sharpness value */
824 /*static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /< Hue value */
825 static DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); /**< Horizontal flip value */
826 static DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); /**< Vertical flip value */
827 static DEVICE_ATTR(auto_exposure, S_IRUGO | S_IWUGO, show_autoexposure, store_autoexposure); /**< Automatic exposure control value */
828 static DEVICE_ATTR(auto_whitebalance, S_IRUGO | S_IWUGO, show_autowhitebalance, store_autowhitebalance); /**< Automatic whitebalance control value */
829 #endif
833 * @brief Create the 'sys' entries.
835 * This function permits to create all the entries in the 'sys' filesystem.
837 * @param vdev Video device structure
839 * @returns 0 if all is OK
841 int sn9c20x_create_sysfs_files(struct video_device *vdev)
843 int ret;
845 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
846 ret = video_device_create_file(vdev, &class_device_attr_release);
847 ret = video_device_create_file(vdev, &class_device_attr_videostatus);
848 ret = video_device_create_file(vdev, &class_device_attr_information);
849 ret = video_device_create_file(vdev, &class_device_attr_fps);
850 ret = video_device_create_file(vdev, &class_device_attr_brightness);
851 ret = video_device_create_file(vdev, &class_device_attr_exposure);
852 ret = video_device_create_file(vdev, &class_device_attr_gain);
853 ret = video_device_create_file(vdev, &class_device_attr_contrast);
854 ret = video_device_create_file(vdev, &class_device_attr_gamma);
855 ret = video_device_create_file(vdev, &class_device_attr_sharpness);
856 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
857 ret = video_device_create_file(vdev, &class_device_attr_hflip);
858 ret = video_device_create_file(vdev, &class_device_attr_vflip);
859 ret = video_device_create_file(vdev, &class_device_attr_auto_exposure);
860 ret = video_device_create_file(vdev, &class_device_attr_auto_whitebalance);
861 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
862 ret = video_device_create_file(vdev, &dev_attr_release);
863 ret = video_device_create_file(vdev, &dev_attr_videostatus);
864 ret = video_device_create_file(vdev, &dev_attr_information);
865 ret = video_device_create_file(vdev, &dev_attr_fps);
866 ret = video_device_create_file(vdev, &dev_attr_brightness);
867 ret = video_device_create_file(vdev, &dev_attr_exposure);
868 ret = video_device_create_file(vdev, &dev_attr_gain);
869 ret = video_device_create_file(vdev, &dev_attr_contrast);
870 ret = video_device_create_file(vdev, &dev_attr_gamma);
871 ret = video_device_create_file(vdev, &dev_attr_sharpness);
872 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
873 ret = video_device_create_file(vdev, &dev_attr_hflip);
874 ret = video_device_create_file(vdev, &dev_attr_vflip);
875 ret = video_device_create_file(vdev, &dev_attr_auto_exposure);
876 ret = video_device_create_file(vdev, &dev_attr_auto_whitebalance);
877 #else
878 ret = device_create_file(&vdev->dev, &dev_attr_release);
879 ret = device_create_file(&vdev->dev, &dev_attr_videostatus);
880 ret = device_create_file(&vdev->dev, &dev_attr_information);
881 ret = device_create_file(&vdev->dev, &dev_attr_fps);
882 ret = device_create_file(&vdev->dev, &dev_attr_brightness);
883 ret = device_create_file(&vdev->dev, &dev_attr_exposure);
884 ret = device_create_file(&vdev->dev, &dev_attr_gain);
885 ret = device_create_file(&vdev->dev, &dev_attr_contrast);
886 ret = device_create_file(&vdev->dev, &dev_attr_gamma);
887 ret = device_create_file(&vdev->dev, &dev_attr_sharpness);
888 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
889 ret = device_create_file(&vdev->dev, &dev_attr_hflip);
890 ret = device_create_file(&vdev->dev, &dev_attr_vflip);
891 ret = device_create_file(&vdev->dev, &dev_attr_auto_exposure);
892 ret = device_create_file(&vdev->dev, &dev_attr_auto_whitebalance);
893 #endif
894 return ret;
899 * @brief Remove the 'sys' entries.
901 * This function permits to remove all the entries in the 'sys' filesystem.
903 * @param vdev Video device structure
905 * @returns 0 if all is OK
907 void sn9c20x_remove_sysfs_files(struct video_device *vdev)
909 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
910 video_device_remove_file(vdev, &class_device_attr_release);
911 video_device_remove_file(vdev, &class_device_attr_videostatus);
912 video_device_remove_file(vdev, &class_device_attr_information);
913 video_device_remove_file(vdev, &class_device_attr_fps);
914 video_device_remove_file(vdev, &class_device_attr_brightness);
915 video_device_remove_file(vdev, &class_device_attr_exposure);
916 video_device_remove_file(vdev, &class_device_attr_gain);
917 video_device_remove_file(vdev, &class_device_attr_contrast);
918 video_device_remove_file(vdev, &class_device_attr_gamma);
919 video_device_remove_file(vdev, &class_device_attr_sharpness);
920 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
921 video_device_remove_file(vdev, &class_device_attr_hflip);
922 video_device_remove_file(vdev, &class_device_attr_vflip);
923 video_device_remove_file(vdev, &class_device_attr_auto_exposure);
924 video_device_remove_file(vdev, &class_device_attr_auto_whitebalance);
925 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
926 video_device_remove_file(vdev, &dev_attr_release);
927 video_device_remove_file(vdev, &dev_attr_videostatus);
928 video_device_remove_file(vdev, &dev_attr_information);
929 video_device_remove_file(vdev, &dev_attr_fps);
930 video_device_remove_file(vdev, &dev_attr_brightness);
931 video_device_remove_file(vdev, &dev_attr_exposure);
932 video_device_remove_file(vdev, &dev_attr_gain);
933 video_device_remove_file(vdev, &dev_attr_contrast);
934 video_device_remove_file(vdev, &dev_attr_gamma);
935 video_device_remove_file(vdev, &dev_attr_sharpness);
936 /*video_device_remove_file(vdev, &dev_attr_colour);*/
937 video_device_remove_file(vdev, &dev_attr_hflip);
938 video_device_remove_file(vdev, &dev_attr_vflip);
939 video_device_remove_file(vdev, &dev_attr_auto_exposure);
940 video_device_remove_file(vdev, &dev_attr_auto_whitebalance);
941 #else
942 device_remove_file(&vdev->dev, &dev_attr_release);
943 device_remove_file(&vdev->dev, &dev_attr_videostatus);
944 device_remove_file(&vdev->dev, &dev_attr_information);
945 device_remove_file(&vdev->dev, &dev_attr_fps);
946 device_remove_file(&vdev->dev, &dev_attr_brightness);
947 device_remove_file(&vdev->dev, &dev_attr_exposure);
948 device_remove_file(&vdev->dev, &dev_attr_gain);
949 device_remove_file(&vdev->dev, &dev_attr_contrast);
950 device_remove_file(&vdev->dev, &dev_attr_gamma);
951 device_remove_file(&vdev->dev, &dev_attr_sharpness);
952 /*video_device_remove_file(vdev, &dev_attr_colour);*/
953 device_remove_file(&vdev->dev, &dev_attr_hflip);
954 device_remove_file(&vdev->dev, &dev_attr_vflip);
955 device_remove_file(&vdev->dev, &dev_attr_auto_exposure);
956 device_remove_file(&vdev->dev, &dev_attr_auto_whitebalance);
957 #endif