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"
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
43 int strict_strtoul(const char *cp
, unsigned int base
, unsigned long *res
)
54 val
= simple_strtoul(cp
, &tail
, base
);
55 if ((*tail
== '\0') ||
56 ((len
== (size_t)(tail
- cp
) + 1) && (*tail
== '\n'))) {
64 int strict_strtol(const char *cp
, unsigned int base
, long *res
)
68 ret
= strict_strtoul(cp
+ 1, base
, (unsigned long *)res
);
72 ret
= strict_strtoul(cp
, base
, (unsigned long *)res
);
81 * @param class Class device
83 * @retval buf Adress of buffer with the 'release' value
85 * @returns Size of buffer
87 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
88 static ssize_t
show_release(struct class_device
*class, char *buf
)
90 static ssize_t
show_release(struct device
*class, struct device_attribute
*attr
, char *buf
)
93 struct video_device
*vdev
= to_video_device(class);
94 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
96 return sprintf(buf
, "%d\n", dev
->release
);
101 * @brief show_videostatus
103 * @param class Class device
105 * @retval buf Adress of buffer with the 'videostatus' value
107 * @returns Size of buffer
109 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
110 static ssize_t
show_videostatus(struct class_device
*class, char *buf
)
112 static ssize_t
show_videostatus(struct device
*class, struct device_attribute
*attr
, char *buf
)
115 struct video_device
*vdev
= to_video_device(class);
116 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
119 "Overflow frames : %d\n"
120 "Incomplete frames : %d\n"
121 "Dropped frames : %d\n",
122 dev
->vframes_overflow
,
123 dev
->vframes_incomplete
,
124 dev
->vframes_dropped
);
129 * @brief show_information
131 * @param class Class device
133 * @retval buf Address of buffer with the 'information' value
135 * @returns Size of buffer
137 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
138 static ssize_t
show_information(struct class_device
*class, char *buf
)
140 static ssize_t
show_information(struct device
*class, struct device_attribute
*attr
, char *buf
)
143 char *pixelfmt
= NULL
;
145 struct video_device
*vdev
= to_video_device(class);
146 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
148 char *palette_bayer
= "BAYER - BGGR - 8 bits";
149 char *palette_i420
= "SN9C20X_I420 - YUV 4:2:0 - 12 bits";
150 char *palette_jpeg
= "JPEG - YUV 4:2:2 - 16 bits";
153 switch (dev
->vsettings
.format
.pixelformat
) {
154 case V4L2_PIX_FMT_SBGGR8
:
155 pixelfmt
= palette_bayer
;
158 case V4L2_PIX_FMT_JPEG
:
159 pixelfmt
= palette_jpeg
;
162 case V4L2_PIX_FMT_SN9C20X_I420
:
163 pixelfmt
= palette_i420
;
168 "Driver Resolution : %dx%d\n"
181 "Blue Balance : %u\n"
182 "Horizontal flip : %d\n"
183 "Vertical flip : %d\n"
184 "Auto-exposure : %d\n"
186 "Auto-whitebalance : %d\n",
187 dev
->vsettings
.format
.width
,
188 dev
->vsettings
.format
.height
,
190 dev
->vsettings
.brightness
,
191 dev
->vsettings
.contrast
,
193 dev
->vsettings
.colour
,
194 dev
->vsettings
.gamma
,
195 dev
->vsettings
.exposure
,
197 dev
->vsettings
.sharpness
,
198 dev
->vsettings
.red_gain
,
199 dev
->vsettings
.blue_gain
,
200 dev
->vsettings
.hflip
,
201 dev
->vsettings
.vflip
,
202 dev
->vsettings
.auto_exposure
,
203 dev
->vsettings
.auto_gain
,
204 dev
->vsettings
.auto_whitebalance
);
211 * @param class Class device
213 * @retval buf Adress of buffer with the 'fps' value
215 * @returns Size of buffer
217 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
218 static ssize_t
show_fps(struct class_device
*class, char *buf
)
220 static ssize_t
show_fps(struct device
*class, struct device_attribute
*attr
, char *buf
)
223 struct video_device
*vdev
= to_video_device(class);
224 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
226 return sprintf(buf
, "%d\n", dev
->vsettings
.fps
);
232 * @param class Class device
234 * @retval buf Adress of buffer with the 'gain' value
236 * @returns Size of buffer
238 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
239 static ssize_t
show_gain(struct class_device
*class, char *buf
)
241 static ssize_t
show_gain(struct device
*class, struct device_attribute
*attr
, char *buf
)
244 struct video_device
*vdev
= to_video_device(class);
245 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
247 return sprintf(buf
, "%u\n", dev
->vsettings
.gain
);
253 * @param class Class device
255 * @param count Counter
258 * @returns Size of buffer
260 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
261 static ssize_t
store_gain(struct class_device
*class, const char *buf
, size_t count
)
263 static ssize_t
store_gain(struct device
*class, struct device_attribute
*attr
,
264 const char *buf
, size_t count
)
269 struct video_device
*vdev
= to_video_device(class);
270 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
272 if (strict_strtoul(buf
, 10, &value
) < 0)
278 sn9c20x_set_camera_control(dev
,
285 * @brief show_exposure
287 * @param class Class device
289 * @retval buf Adress of buffer with the 'exposure' value
291 * @returns Size of buffer
293 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
294 static ssize_t
show_exposure(struct class_device
*class, char *buf
)
296 static ssize_t
show_exposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
299 struct video_device
*vdev
= to_video_device(class);
300 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
302 return sprintf(buf
, "%u\n", dev
->vsettings
.exposure
);
306 * @brief store_exposure
308 * @param class Class device
310 * @param count Counter
313 * @returns Size of buffer
315 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
316 static ssize_t
store_exposure(struct class_device
*class, const char *buf
, size_t count
)
318 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
319 const char *buf
, size_t count
)
324 struct video_device
*vdev
= to_video_device(class);
325 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
327 if (strict_strtoul(buf
, 10, &value
) < 0)
333 sn9c20x_set_camera_control(dev
,
341 * @brief show_brightness
343 * @param class Class device
345 * @retval buf Adress of buffer with the 'brightness' value
347 * @returns Size of buffer
349 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
350 static ssize_t
show_brightness(struct class_device
*class, char *buf
)
352 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
355 struct video_device
*vdev
= to_video_device(class);
356 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
358 return sprintf(buf
, "%u\n", dev
->vsettings
.brightness
);
362 * @brief store_brightness
364 * @param class Class device
366 * @param count Counter
369 * @returns Size of buffer
371 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
372 static ssize_t
store_brightness(struct class_device
*class, const char *buf
, size_t count
)
374 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
375 const char *buf
, size_t count
)
380 struct video_device
*vdev
= to_video_device(class);
381 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
383 if (strict_strtoul(buf
, 10, &value
) < 0)
389 sn9c20x_set_camera_control(dev
,
397 * @brief show_contrast
399 * @param class Class device
401 * @retval buf Adress of buffer with the 'contrast' value
403 * @returns Size of buffer
405 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
406 static ssize_t
show_contrast(struct class_device
*class, char *buf
)
408 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
411 struct video_device
*vdev
= to_video_device(class);
412 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
414 return sprintf(buf
, "%u\n", dev
->vsettings
.contrast
);
419 * @brief store_contrast
421 * @param class Class device
423 * @param count Counter
426 * @returns Size of buffer
428 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
429 static ssize_t
store_contrast(struct class_device
*class, const char *buf
, size_t count
)
431 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
432 const char *buf
, size_t count
)
437 struct video_device
*vdev
= to_video_device(class);
438 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
440 if (strict_strtoul(buf
, 10, &value
) < 0)
446 sn9c20x_set_camera_control(dev
,
457 * @brief show_saturation
459 * @param class Class device
461 * @retval buf Adress of buffer with the 'contrast' value
463 * @returns Size of buffer
465 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
466 static ssize_t
show_saturation(struct class_device
*class, char *buf
)
468 static ssize_t
show_saturation(struct device
*class,
469 struct device_attribute
*attr
, char *buf
)
472 struct video_device
*vdev
= to_video_device(class);
473 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
475 return sprintf(buf
, "%u\n", dev
->vsettings
.colour
);
480 * @brief store_saturation
482 * @param class Class device
484 * @param count Counter
487 * @returns Size of buffer
489 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
490 static ssize_t
store_saturation(struct class_device
*class,
494 static ssize_t
store_saturation(struct device
*class,
495 struct device_attribute
*attr
,
502 struct video_device
*vdev
= to_video_device(class);
503 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
505 if (strict_strtoul(buf
, 10, &value
) < 0)
511 sn9c20x_set_camera_control(dev
,
523 * @param class Class device
525 * @retval buf Adress of buffer with the 'contrast' value
527 * @returns Size of buffer
529 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
530 static ssize_t
show_hue(struct class_device
*class,
533 static ssize_t
show_hue(struct device
*class,
534 struct device_attribute
*attr
,
538 struct video_device
*vdev
= to_video_device(class);
539 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
541 return sprintf(buf
, "%d\n", dev
->vsettings
.hue
);
548 * @param class Class device
550 * @param count Counter
553 * @returns Size of buffer
555 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
556 static ssize_t
store_hue(struct class_device
*class,
560 static ssize_t
store_hue(struct device
*class,
561 struct device_attribute
*attr
,
562 const char *buf
, size_t count
)
567 struct video_device
*vdev
= to_video_device(class);
568 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
570 if (strict_strtol(buf
, 10, &value
) < 0)
573 if (value
> 180 || value
< -180)
576 sn9c20x_set_camera_control(dev
,
587 * @brief show_whitebalance
589 * @param class Class device
591 * @retval buf Adress of buffer with the 'whitebalance' value
593 * @returns Size of buffer
595 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
596 static ssize_t
show_gamma(struct class_device
*class,
599 static ssize_t
show_gamma(struct device
*class,
600 struct device_attribute
*attr
,
604 struct video_device
*vdev
= to_video_device(class);
605 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
607 return sprintf(buf
, "%u\n", dev
->vsettings
.gamma
);
614 * @param class Class device
616 * @param count Counter
619 * @returns Size of buffer
621 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
622 static ssize_t
store_gamma(struct class_device
*class,
626 static ssize_t
store_gamma(struct device
*class,
627 struct device_attribute
*attr
,
628 const char *buf
, size_t count
)
633 struct video_device
*vdev
= to_video_device(class);
634 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
636 if (strict_strtoul(buf
, 10, &value
) < 0)
642 sn9c20x_set_camera_control(dev
,
653 * @brief show_sharpness
655 * @param class Class device
657 * @retval buf Adress of buffer with the 'sharpness' value
659 * @returns Size of buffer
661 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
662 static ssize_t
show_sharpness(struct class_device
*class, char *buf
)
664 static ssize_t
show_sharpness(struct device
*class, struct device_attribute
*attr
, char *buf
)
667 struct video_device
*vdev
= to_video_device(class);
668 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
670 return sprintf(buf
, "%u\n", dev
->vsettings
.sharpness
);
674 * @brief store_sharpness
676 * @param class Class device
678 * @param count Counter
681 * @returns Size of buffer
683 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
684 static ssize_t
store_sharpness(struct class_device
*class, const char *buf
, size_t count
)
686 static ssize_t
store_sharpness(struct device
*class, struct device_attribute
*attr
,
687 const char *buf
, size_t count
)
692 struct video_device
*vdev
= to_video_device(class);
693 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
695 if (strict_strtoul(buf
, 10, &value
) < 0)
701 sn9c20x_set_camera_control(dev
,
712 * @param class Class device
714 * @retval buf Adress of buffer with the 'hflip' value
716 * @returns Size of buffer
718 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
719 static ssize_t
show_hflip(struct class_device
*class, char *buf
)
721 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
724 struct video_device
*vdev
= to_video_device(class);
725 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
727 return sprintf(buf
, "%d\n", dev
->vsettings
.hflip
);
734 * @param class Class device
736 * @param count Counter
739 * @returns Size of buffer
741 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
742 static ssize_t
store_hflip(struct class_device
*class, const char *buf
, size_t count
)
744 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
745 const char *buf
, size_t count
)
749 struct video_device
*vdev
= to_video_device(class);
750 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
752 if (strict_strtoul(buf
, 10, &value
) < 0)
755 if (value
!= 0 && value
!= 1)
758 sn9c20x_set_camera_control(dev
,
769 * @param class Class device
771 * @retval buf Adress of buffer with the 'vflip' value
773 * @returns Size of buffer
775 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
776 static ssize_t
show_vflip(struct class_device
*class, char *buf
)
778 static ssize_t
show_vflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
781 struct video_device
*vdev
= to_video_device(class);
782 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
784 return sprintf(buf
, "%d\n", dev
->vsettings
.vflip
);
791 * @param class Class device
793 * @param count Counter
796 * @returns Size of buffer
798 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
799 static ssize_t
store_vflip(struct class_device
*class, const char *buf
, size_t count
)
801 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
805 struct video_device
*vdev
= to_video_device(class);
806 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
808 if (strict_strtoul(buf
, 10, &value
) < 0)
811 if (value
!= 0 && value
!= 1)
814 sn9c20x_set_camera_control(dev
,
823 * @brief show_autoexposure
825 * @param class Class device
827 * @retval buf Adress of buffer with the 'hflip' value
829 * @returns Size of buffer
831 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
832 static ssize_t
show_autoexposure(struct class_device
*class, char *buf
)
834 static ssize_t
show_autoexposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
837 struct video_device
*vdev
= to_video_device(class);
838 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
840 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_exposure
);
845 * @brief store_autoexposure
847 * @param class Class device
849 * @param count Counter
852 * @returns Size of buffer
854 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
855 static ssize_t
store_autoexposure(struct class_device
*class, const char *buf
, size_t count
)
857 static ssize_t
store_autoexposure(struct device
*class, struct device_attribute
*attr
,
858 const char *buf
, size_t count
)
862 struct video_device
*vdev
= to_video_device(class);
863 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
865 if (strict_strtoul(buf
, 10, &value
) < 0)
868 if (value
!= 0 && value
!= 1)
871 sn9c20x_set_camera_control(dev
,
872 V4L2_CID_EXPOSURE_AUTO
,
880 * @brief show_autowhitebalance
882 * @param class Class device
884 * @retval buf Adress of buffer with the 'vflip' value
886 * @returns Size of buffer
888 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
889 static ssize_t
show_autowhitebalance(struct class_device
*class, char *buf
)
891 static ssize_t
show_autowhitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
894 struct video_device
*vdev
= to_video_device(class);
895 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
897 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_whitebalance
);
902 * @brief store_autowhitebalance
904 * @param class Class device
906 * @param count Counter
909 * @returns Size of buffer
911 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
912 static ssize_t
store_autowhitebalance(struct class_device
*class, const char *buf
, size_t count
)
914 static ssize_t
store_autowhitebalance(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
918 struct video_device
*vdev
= to_video_device(class);
919 struct usb_sn9c20x
*dev
= video_get_drvdata(vdev
);
921 if (strict_strtoul(buf
, 10, &value
) < 0)
924 if (value
!= 0 && value
!= 1)
927 sn9c20x_set_camera_control(dev
,
928 V4L2_CID_AUTO_WHITE_BALANCE
,
934 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
935 static CLASS_DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
936 static CLASS_DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
937 static CLASS_DEVICE_ATTR(information
, S_IRUGO
, show_information
, NULL
); /**< Information */
938 static CLASS_DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
939 static CLASS_DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
940 static CLASS_DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
941 static CLASS_DEVICE_ATTR(gain
, S_IRUGO
| S_IWUGO
, show_gain
, store_gain
); /**< Gain value */
942 static CLASS_DEVICE_ATTR(saturation
, S_IRUGO
| S_IWUGO
, show_saturation
, store_saturation
); /**< Saturation value */
943 static CLASS_DEVICE_ATTR(hue
, S_IRUGO
| S_IWUGO
, show_hue
, store_hue
); /**< Hue value */
944 static CLASS_DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
945 static CLASS_DEVICE_ATTR(gamma
, S_IRUGO
| S_IWUGO
, show_gamma
, store_gamma
); /**< Gamma value */
946 static CLASS_DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
947 static CLASS_DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
948 static CLASS_DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
949 static CLASS_DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
950 static CLASS_DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
952 static DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
953 static DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
954 static DEVICE_ATTR(information
, S_IRUGO
, show_information
, NULL
); /**< Information */
955 static DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
956 static DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
957 static DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
958 static DEVICE_ATTR(gain
, S_IRUGO
| S_IWUGO
, show_gain
, store_gain
); /**< Gain value */
959 static DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
960 static DEVICE_ATTR(saturation
, S_IRUGO
| S_IWUGO
, show_saturation
, store_saturation
); /**< Saturation value */
961 static DEVICE_ATTR(hue
, S_IRUGO
| S_IWUGO
, show_hue
, store_hue
); /**< Hue value */
962 static DEVICE_ATTR(gamma
, S_IRUGO
| S_IWUGO
, show_gamma
, store_gamma
); /**< Gamma value */
963 static DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
964 static DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
965 static DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
966 static DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
967 static DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
972 * @brief Create the 'sys' entries.
974 * This function permits to create all the entries in the 'sys' filesystem.
976 * @param vdev Video device structure
978 * @returns 0 if all is OK
980 int sn9c20x_create_sysfs_files(struct video_device
*vdev
)
984 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
985 ret
= video_device_create_file(vdev
, &class_device_attr_release
);
986 ret
= video_device_create_file(vdev
, &class_device_attr_videostatus
);
987 ret
= video_device_create_file(vdev
, &class_device_attr_information
);
988 ret
= video_device_create_file(vdev
, &class_device_attr_fps
);
989 ret
= video_device_create_file(vdev
, &class_device_attr_brightness
);
990 ret
= video_device_create_file(vdev
, &class_device_attr_exposure
);
991 ret
= video_device_create_file(vdev
, &class_device_attr_gain
);
992 ret
= video_device_create_file(vdev
, &class_device_attr_contrast
);
993 ret
= video_device_create_file(vdev
, &class_device_attr_saturation
);
994 ret
= video_device_create_file(vdev
, &class_device_attr_hue
);
995 ret
= video_device_create_file(vdev
, &class_device_attr_gamma
);
996 ret
= video_device_create_file(vdev
, &class_device_attr_sharpness
);
997 ret
= video_device_create_file(vdev
, &class_device_attr_hflip
);
998 ret
= video_device_create_file(vdev
, &class_device_attr_vflip
);
999 ret
= video_device_create_file(vdev
, &class_device_attr_auto_exposure
);
1000 ret
= video_device_create_file(vdev
, &class_device_attr_auto_whitebalance
);
1001 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
1002 ret
= video_device_create_file(vdev
, &dev_attr_release
);
1003 ret
= video_device_create_file(vdev
, &dev_attr_videostatus
);
1004 ret
= video_device_create_file(vdev
, &dev_attr_information
);
1005 ret
= video_device_create_file(vdev
, &dev_attr_fps
);
1006 ret
= video_device_create_file(vdev
, &dev_attr_brightness
);
1007 ret
= video_device_create_file(vdev
, &dev_attr_exposure
);
1008 ret
= video_device_create_file(vdev
, &dev_attr_gain
);
1009 ret
= video_device_create_file(vdev
, &dev_attr_contrast
);
1010 ret
= video_device_create_file(vdev
, &dev_attr_saturation
);
1011 ret
= video_device_create_file(vdev
, &dev_attr_hue
);
1012 ret
= video_device_create_file(vdev
, &dev_attr_gamma
);
1013 ret
= video_device_create_file(vdev
, &dev_attr_sharpness
);
1014 ret
= video_device_create_file(vdev
, &dev_attr_hflip
);
1015 ret
= video_device_create_file(vdev
, &dev_attr_vflip
);
1016 ret
= video_device_create_file(vdev
, &dev_attr_auto_exposure
);
1017 ret
= video_device_create_file(vdev
, &dev_attr_auto_whitebalance
);
1019 ret
= device_create_file(&vdev
->dev
, &dev_attr_release
);
1020 ret
= device_create_file(&vdev
->dev
, &dev_attr_videostatus
);
1021 ret
= device_create_file(&vdev
->dev
, &dev_attr_information
);
1022 ret
= device_create_file(&vdev
->dev
, &dev_attr_fps
);
1023 ret
= device_create_file(&vdev
->dev
, &dev_attr_brightness
);
1024 ret
= device_create_file(&vdev
->dev
, &dev_attr_exposure
);
1025 ret
= device_create_file(&vdev
->dev
, &dev_attr_gain
);
1026 ret
= device_create_file(&vdev
->dev
, &dev_attr_contrast
);
1027 ret
= device_create_file(&vdev
->dev
, &dev_attr_saturation
);
1028 ret
= device_create_file(&vdev
->dev
, &dev_attr_hue
);
1029 ret
= device_create_file(&vdev
->dev
, &dev_attr_gamma
);
1030 ret
= device_create_file(&vdev
->dev
, &dev_attr_sharpness
);
1031 ret
= device_create_file(&vdev
->dev
, &dev_attr_hflip
);
1032 ret
= device_create_file(&vdev
->dev
, &dev_attr_vflip
);
1033 ret
= device_create_file(&vdev
->dev
, &dev_attr_auto_exposure
);
1034 ret
= device_create_file(&vdev
->dev
, &dev_attr_auto_whitebalance
);
1041 * @brief Remove the 'sys' entries.
1043 * This function permits to remove all the entries in the 'sys' filesystem.
1045 * @param vdev Video device structure
1047 * @returns 0 if all is OK
1049 void sn9c20x_remove_sysfs_files(struct video_device
*vdev
)
1051 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
1052 video_device_remove_file(vdev
, &class_device_attr_release
);
1053 video_device_remove_file(vdev
, &class_device_attr_videostatus
);
1054 video_device_remove_file(vdev
, &class_device_attr_information
);
1055 video_device_remove_file(vdev
, &class_device_attr_fps
);
1056 video_device_remove_file(vdev
, &class_device_attr_brightness
);
1057 video_device_remove_file(vdev
, &class_device_attr_exposure
);
1058 video_device_remove_file(vdev
, &class_device_attr_gain
);
1059 video_device_remove_file(vdev
, &class_device_attr_contrast
);
1060 video_device_remove_file(vdev
, &class_device_attr_saturation
);
1061 video_device_remove_file(vdev
, &class_device_attr_hue
);
1062 video_device_remove_file(vdev
, &class_device_attr_gamma
);
1063 video_device_remove_file(vdev
, &class_device_attr_sharpness
);
1064 video_device_remove_file(vdev
, &class_device_attr_hflip
);
1065 video_device_remove_file(vdev
, &class_device_attr_vflip
);
1066 video_device_remove_file(vdev
, &class_device_attr_auto_exposure
);
1067 video_device_remove_file(vdev
, &class_device_attr_auto_whitebalance
);
1068 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
1069 video_device_remove_file(vdev
, &dev_attr_release
);
1070 video_device_remove_file(vdev
, &dev_attr_videostatus
);
1071 video_device_remove_file(vdev
, &dev_attr_information
);
1072 video_device_remove_file(vdev
, &dev_attr_fps
);
1073 video_device_remove_file(vdev
, &dev_attr_brightness
);
1074 video_device_remove_file(vdev
, &dev_attr_exposure
);
1075 video_device_remove_file(vdev
, &dev_attr_gain
);
1076 video_device_remove_file(vdev
, &dev_attr_contrast
);
1077 video_device_remove_file(vdev
, &dev_attr_saturation
);
1078 video_device_remove_file(vdev
, &dev_attr_hue
);
1079 video_device_remove_file(vdev
, &dev_attr_gamma
);
1080 video_device_remove_file(vdev
, &dev_attr_sharpness
);
1081 video_device_remove_file(vdev
, &dev_attr_hflip
);
1082 video_device_remove_file(vdev
, &dev_attr_vflip
);
1083 video_device_remove_file(vdev
, &dev_attr_auto_exposure
);
1084 video_device_remove_file(vdev
, &dev_attr_auto_whitebalance
);
1086 device_remove_file(&vdev
->dev
, &dev_attr_release
);
1087 device_remove_file(&vdev
->dev
, &dev_attr_videostatus
);
1088 device_remove_file(&vdev
->dev
, &dev_attr_information
);
1089 device_remove_file(&vdev
->dev
, &dev_attr_fps
);
1090 device_remove_file(&vdev
->dev
, &dev_attr_brightness
);
1091 device_remove_file(&vdev
->dev
, &dev_attr_exposure
);
1092 device_remove_file(&vdev
->dev
, &dev_attr_gain
);
1093 device_remove_file(&vdev
->dev
, &dev_attr_contrast
);
1094 device_remove_file(&vdev
->dev
, &dev_attr_saturation
);
1095 device_remove_file(&vdev
->dev
, &dev_attr_hue
);
1096 device_remove_file(&vdev
->dev
, &dev_attr_gamma
);
1097 device_remove_file(&vdev
->dev
, &dev_attr_sharpness
);
1098 device_remove_file(&vdev
->dev
, &dev_attr_hflip
);
1099 device_remove_file(&vdev
->dev
, &dev_attr_vflip
);
1100 device_remove_file(&vdev
->dev
, &dev_attr_auto_exposure
);
1101 device_remove_file(&vdev
->dev
, &dev_attr_auto_whitebalance
);