2 * @file sn9c20x-sysfs.c
3 * @author Nicolas VIVIEN
6 * @brief Sysfs interface for image settings
8 * @note Copyright (C) Nicolas VIVIEN
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/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>
40 #include "sn9c20x-bridge.h"
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
)
55 static ssize_t
show_release(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
);
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
)
77 static ssize_t
show_videostatus(struct device
*class, struct device_attribute
*attr
, char *buf
)
80 struct video_device
*vdev
= to_video_device(class);
81 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
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
);
94 * @brief show_information
96 * @param class Class device
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
)
105 static ssize_t
show_information(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
;
123 case V4L2_PIX_FMT_JPEG
:
124 pixelfmt
= palette_jpeg
;
127 case V4L2_PIX_FMT_SN9C20X_I420
:
128 pixelfmt
= palette_i420
;
133 "Driver Resolution : %dx%d\n"
137 "Brightness : 0x%02X\n"
138 "Contrast : 0x%02X\n"
140 "Exposure : 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"
149 "Auto-whitebalance : %d\n",
150 dev
->vsettings
.format
.width
,
151 dev
->vsettings
.format
.height
,
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
);
172 * @param class Class device
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
)
181 static ssize_t
show_fps(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
);
193 * @param class Class device
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
)
202 static ssize_t
show_gain(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
);
214 * @param class Class device
216 * @param count Counter
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
)
224 static ssize_t
store_gain(struct device
*class, struct device_attribute
*attr
,
225 const char *buf
, size_t count
)
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
,
243 * @brief show_exposure
245 * @param class Class device
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
)
254 static ssize_t
show_exposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
268 * @param count Counter
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
)
276 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
277 const char *buf
, size_t count
)
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
,
296 * @brief show_brightness
298 * @param class Class device
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
)
307 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
321 * @param count Counter
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
)
329 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
330 const char *buf
, size_t count
)
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
,
349 * @brief show_contrast
351 * @param class Class device
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
)
360 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
375 * @param count Counter
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
)
383 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
384 const char *buf
, size_t count
)
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
,
404 * @brief show_whitebalance
406 * @param class Class device
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
)
415 static ssize_t
show_gamma(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
);
428 * @param class Class device
430 * @param count Counter
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
)
438 static ssize_t
store_gamma(struct device
*class, struct device_attribute
*attr
,
439 const char *buf
, size_t count
)
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
,
461 * @param class Class device
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)
470 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
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
485 * @param count Counter
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)
493 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
494 const char *buf, size_t count)
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); /
515 * @brief show_sharpness
517 * @param class Class device
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
)
526 static ssize_t
show_sharpness(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
540 * @param count Counter
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
)
548 static ssize_t
store_sharpness(struct device
*class, struct device_attribute
*attr
,
549 const char *buf
, size_t count
)
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)
563 sn9c20x_set_camera_control(dev
,
574 * @param class Class device
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
)
583 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
);
596 * @param class Class device
598 * @param count Counter
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
)
606 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
607 const char *buf
, size_t count
)
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)
620 sn9c20x_set_camera_control(dev
,
631 * @param class Class device
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
)
640 static ssize_t
show_vflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
);
653 * @param class Class device
655 * @param count Counter
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
)
663 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
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)
676 sn9c20x_set_camera_control(dev
,
685 * @brief show_autoexposure
687 * @param class Class device
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
)
696 static ssize_t
show_autoexposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
711 * @param count Counter
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
)
719 static ssize_t
store_autoexposure(struct device
*class, struct device_attribute
*attr
,
720 const char *buf
, size_t count
)
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)
729 else if (strncmp(buf
, "0", 1) == 0)
734 sn9c20x_set_camera_control(dev
,
735 V4L2_CID_EXPOSURE_AUTO
,
743 * @brief show_autowhitebalance
745 * @param class Class device
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
)
754 static ssize_t
show_autowhitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
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
769 * @param count Counter
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
)
777 static ssize_t
store_autowhitebalance(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
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)
790 sn9c20x_set_camera_control(dev
,
791 V4L2_CID_AUTO_WHITE_BALANCE
,
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 */
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 */
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
)
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
);
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
);
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
);
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
);