2 * @file microdia-sysfs.c
3 * @author Nicolas VIVIEN
7 * @brief Sysfs interface for image settings
9 * @note Copyright (C) Nicolas VIVIEN
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
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>
47 * @param class Class device
49 * @retval buf Adress of buffer with the 'release' value
51 * @returns Size of buffer
53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
54 static ssize_t
show_release(struct class_device
*class, char *buf
)
56 static ssize_t
show_release(struct device
*class, struct device_attribute
*attr
, char *buf
)
59 struct video_device
*vdev
= to_video_device(class);
60 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
62 return sprintf(buf
, "%d\n", dev
->release
);
67 * @brief show_videostatus
69 * @param class Class device
71 * @retval buf Adress of buffer with the 'videostatus' value
73 * @returns Size of buffer
75 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
76 static ssize_t
show_videostatus(struct class_device
*class, char *buf
)
78 static ssize_t
show_videostatus(struct device
*class, struct device_attribute
*attr
, char *buf
)
81 struct video_device
*vdev
= to_video_device(class);
82 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
85 "Overflow frames : %d\n"
86 "Incomplete frames : %d\n"
87 "Dropped frames : %d\n",
88 dev
->vframes_overflow
,
89 dev
->vframes_incomplete
,
90 dev
->vframes_dropped
);
95 * @brief show_informations
97 * @param class Class device
99 * @retval buf Adress of buffer with the 'informations' value
101 * @returns Size of buffer
103 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
104 static ssize_t
show_informations(struct class_device
*class, char *buf
)
106 static ssize_t
show_informations(struct device
*class, struct device_attribute
*attr
, char *buf
)
109 char *pixelfmt
= NULL
;
111 struct video_device
*vdev
= to_video_device(class);
112 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
114 char *palette_bgr24
= "BGR24 - BGR-8-8-8 - 24 bits";
115 char *palette_rgb24
= "RGB24 - RGB-8-8-8 - 24 bits";
116 char *palette_yuyv
= "YUYV - YUV 4:2:2 - 16 bits";
117 char *palette_i420
= "I420 - YUV 4:2:0 - 12 bits";
120 switch (dev
->vsettings
.format
.pixelformat
) {
121 case V4L2_PIX_FMT_BGR24
:
122 pixelfmt
= palette_bgr24
;
125 case V4L2_PIX_FMT_RGB24
:
126 pixelfmt
= palette_rgb24
;
129 case V4L2_PIX_FMT_YUYV
:
130 pixelfmt
= palette_yuyv
;
133 case V4L2_PIX_FMT_YUV420
:
134 pixelfmt
= palette_i420
;
139 "Driver Resolution : %dx%d\n"
143 "Brightness : 0x%X\n"
148 "Horizontal flip : %d\n"
149 "Vertical flip : %d\n"
150 "Auto-exposure : %d\n"
151 "Auto-whitebalance : %d\n",
152 dev
->vsettings
.format
.width
,
153 dev
->vsettings
.format
.height
,
155 0xFFFF & dev
->vsettings
.brightness
,
156 0xFFFF & dev
->vsettings
.contrast
,
157 0xFFFF & dev
->vsettings
.whiteness
,
158 0xFFFF & dev
->vsettings
.exposure
,
159 0x3F & dev
->vsettings
.sharpness
,
160 dev
->vsettings
.hflip
,
161 dev
->vsettings
.vflip
,
162 dev
->vsettings
.auto_exposure
,
163 dev
->vsettings
.auto_whitebalance
);
170 * @param class Class device
172 * @retval buf Adress of buffer with the 'fps' value
174 * @returns Size of buffer
176 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
177 static ssize_t
show_fps(struct class_device
*class, char *buf
)
179 static ssize_t
show_fps(struct device
*class, struct device_attribute
*attr
, char *buf
)
182 struct video_device
*vdev
= to_video_device(class);
183 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
185 return sprintf(buf
, "%d\n", dev
->vsettings
.fps
);
189 * @brief show_rgb_gain
191 * @param class Class device
193 * @retval buf Address of buffer with the 'rgb_gain' value
195 * @returns Size of buffer
197 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
198 static ssize_t
show_rgb_gain(struct class_device
*class, char *buf
)
200 static ssize_t
show_rgb_gain(struct device
*class,
201 struct device_attribute
*attr
, char *buf
)
206 struct video_device
*vdev
= to_video_device(class);
207 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
208 rgb_gain
|= dev
->vsettings
.rgb_gain
[0] << 16;
209 rgb_gain
|= dev
->vsettings
.rgb_gain
[1] << 8;
210 rgb_gain
|= dev
->vsettings
.rgb_gain
[3];
211 return sprintf(buf
, "0x%06X\n", rgb_gain
);
215 * @brief store_exposure
217 * @param class Class device
219 * @param count Counter
221 * @returns Size of buffer
223 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
224 static ssize_t
store_rgb_gain(struct class_device
*class,
225 const char *buf
, size_t count
)
227 static ssize_t
store_rgb_gain(struct device
*class,
228 struct device_attribute
*attr
, const char *buf
, size_t count
)
232 unsigned long rgb_gain
;
234 struct video_device
*vdev
= to_video_device(class);
235 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
237 rgb_gain
= simple_strtoul(buf
, &endp
, 16);
239 dev
->vsettings
.rgb_gain
[0] = (rgb_gain
>> 16) & 0x7f;
240 dev
->vsettings
.rgb_gain
[1] = (rgb_gain
>> 8) & 0x7f;
241 dev
->vsettings
.rgb_gain
[2] = (rgb_gain
>> 8) & 0x7f;
242 dev
->vsettings
.rgb_gain
[3] = rgb_gain
& 0x7f;
244 dev_microdia_camera_set_rgb_gain(dev
);
250 * @brief show_exposure
252 * @param class Class device
254 * @retval buf Adress of buffer with the 'exposure' value
256 * @returns Size of buffer
258 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
259 static ssize_t
show_exposure(struct class_device
*class, char *buf
)
261 static ssize_t
show_exposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
264 struct video_device
*vdev
= to_video_device(class);
265 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
267 return sprintf(buf
, "%X\n", dev
->vsettings
.exposure
);
271 * @brief store_exposure
273 * @param class Class device
275 * @param count Counter
277 * @returns Size of buffer
279 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
280 static ssize_t
store_exposure(struct class_device
*class, const char *buf
, size_t count
)
282 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
283 const char *buf
, size_t count
)
289 struct video_device
*vdev
= to_video_device(class);
290 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
292 value
= simple_strtoul(buf
, &endp
, 16);
294 dev
->vsettings
.exposure
= (int) value
;
296 dev_microdia_camera_set_exposure(dev
);
302 * @brief show_brightness
304 * @param class Class device
306 * @retval buf Adress of buffer with the 'brightness' value
308 * @returns Size of buffer
310 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
311 static ssize_t
show_brightness(struct class_device
*class, char *buf
)
313 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
316 struct video_device
*vdev
= to_video_device(class);
317 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
319 return sprintf(buf
, "%X\n", dev
->vsettings
.brightness
);
323 * @brief store_brightness
325 * @param class Class device
327 * @param count Counter
329 * @returns Size of buffer
331 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
332 static ssize_t
store_brightness(struct class_device
*class, const char *buf
, size_t count
)
334 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
335 const char *buf
, size_t count
)
341 struct video_device
*vdev
= to_video_device(class);
342 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
344 value
= simple_strtoul(buf
, &endp
, 16);
346 dev
->vsettings
.brightness
= (int) value
;
348 dev_microdia_camera_set_brightness(dev
);
354 * @brief show_contrast
356 * @param class Class device
358 * @retval buf Adress of buffer with the 'contrast' value
360 * @returns Size of buffer
362 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
363 static ssize_t
show_contrast(struct class_device
*class, char *buf
)
365 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
368 struct video_device
*vdev
= to_video_device(class);
369 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
371 return sprintf(buf
, "%X\n", dev
->vsettings
.contrast
);
376 * @brief store_contrast
378 * @param class Class device
380 * @param count Counter
382 * @returns Size of buffer
384 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
385 static ssize_t
store_contrast(struct class_device
*class, const char *buf
, size_t count
)
387 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
388 const char *buf
, size_t count
)
394 struct video_device
*vdev
= to_video_device(class);
395 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
397 value
= simple_strtoul(buf
, &endp
, 16);
399 dev
->vsettings
.contrast
= (int) value
;
401 dev_microdia_camera_set_contrast(dev
);
402 // dev_microdia_set_camera_quality(dev);
409 * @brief show_whitebalance
411 * @param class Class device
413 * @retval buf Adress of buffer with the 'whitebalance' value
415 * @returns Size of buffer
417 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
418 static ssize_t
show_whitebalance(struct class_device
*class, char *buf
)
420 static ssize_t
show_whitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
423 struct video_device
*vdev
= to_video_device(class);
424 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
426 return sprintf(buf
, "%X\n", dev
->vsettings
.whiteness
);
431 * @brief store_whitebalance
433 * @param class Class device
435 * @param count Counter
437 * @returns Size of buffer
439 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
440 static ssize_t
store_whitebalance(struct class_device
*class, const char *buf
, size_t count
)
442 static ssize_t
store_whitebalance(struct device
*class, struct device_attribute
*attr
,
443 const char *buf
, size_t count
)
449 struct video_device
*vdev
= to_video_device(class);
450 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
452 value
= simple_strtoul(buf
, &endp
, 16);
454 dev
->vsettings
.whiteness
= (int) value
;
456 dev_microdia_camera_set_gamma(dev
);
457 // dev_microdia_set_camera_quality(dev);
466 * @param class Class device
468 * @retval buf Adress of buffer with the 'colour' value
470 * @returns Size of buffer
472 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
473 static ssize_t show_colour(struct class_device *class, char *buf)
475 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
478 struct video_device *vdev = to_video_device(class);
479 struct usb_microdia *dev = video_get_drvdata(vdev);
481 return sprintf(buf, "%X\n", dev->vsettings.colour);
486 * @brief store_colour
488 * @param class Class device
490 * @param count Counter
492 * @returns Size of buffer
494 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
495 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
497 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
498 const char *buf, size_t count)
504 struct video_device *vdev = to_video_device(class);
505 struct usb_microdia *dev = video_get_drvdata(vdev);
507 value = simple_strtoul(buf, &endp, 16);
509 dev->vsettings.colour = (int) value;
511 // dev_microdia_set_camera_quality(dev);
519 * @brief show_sharpness
521 * @param class Class device
523 * @retval buf Adress of buffer with the 'sharpness' value
525 * @returns Size of buffer
527 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
528 static ssize_t
show_sharpness(struct class_device
*class, char *buf
)
530 static ssize_t
show_sharpness(struct device
*class, struct device_attribute
*attr
, char *buf
)
533 struct video_device
*vdev
= to_video_device(class);
534 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
536 return sprintf(buf
, "%X\n", dev
->vsettings
.sharpness
);
540 * @brief store_sharpness
542 * @param class Class device
544 * @param count Counter
546 * @returns Size of buffer
548 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
549 static ssize_t
store_sharpness(struct class_device
*class, const char *buf
, size_t count
)
551 static ssize_t
store_sharpness(struct device
*class, struct device_attribute
*attr
,
552 const char *buf
, size_t count
)
558 struct video_device
*vdev
= to_video_device(class);
559 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
561 value
= simple_strtoul(buf
, &endp
, 16);
563 if (value
< 0 || value
> 0x3f)
566 dev
->vsettings
.sharpness
= (int) value
;
568 dev_microdia_camera_set_sharpness(dev
);
577 * @param class Class device
579 * @retval buf Adress of buffer with the 'hflip' value
581 * @returns Size of buffer
583 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
584 static ssize_t
show_hflip(struct class_device
*class, char *buf
)
586 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
589 struct video_device
*vdev
= to_video_device(class);
590 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
592 return sprintf(buf
, "%d\n", dev
->vsettings
.hflip
);
599 * @param class Class device
601 * @param count Counter
603 * @returns Size of buffer
605 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
606 static ssize_t
store_hflip(struct class_device
*class, const char *buf
, size_t count
)
608 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
609 const char *buf
, size_t count
)
612 struct video_device
*vdev
= to_video_device(class);
613 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
615 if (strncmp(buf
, "1", 1) == 0)
616 dev
->vsettings
.hflip
= 1;
617 else if (strncmp(buf
, "0", 1) == 0)
618 dev
->vsettings
.hflip
= 0;
622 dev_microdia_camera_set_hvflip(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_microdia
*dev
= video_get_drvdata(vdev
);
646 return sprintf(buf
, "%d\n", dev
->vsettings
.vflip
);
653 * @param class Class device
655 * @param count Counter
657 * @returns Size of buffer
659 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
660 static ssize_t
store_vflip(struct class_device
*class, const char *buf
, size_t count
)
662 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
665 struct video_device
*vdev
= to_video_device(class);
666 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
668 if (strncmp(buf
, "1", 1) == 0)
669 dev
->vsettings
.vflip
= 1;
670 else if (strncmp(buf
, "0", 1) == 0)
671 dev
->vsettings
.vflip
= 0;
675 dev_microdia_camera_set_hvflip(dev
);
682 * @brief show_autoexposure
684 * @param class Class device
686 * @retval buf Adress of buffer with the 'hflip' value
688 * @returns Size of buffer
690 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
691 static ssize_t
show_autoexposure(struct class_device
*class, char *buf
)
693 static ssize_t
show_autoexposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
696 struct video_device
*vdev
= to_video_device(class);
697 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
699 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_exposure
);
704 * @brief store_autoexposure
706 * @param class Class device
708 * @param count Counter
710 * @returns Size of buffer
712 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
713 static ssize_t
store_autoexposure(struct class_device
*class, const char *buf
, size_t count
)
715 static ssize_t
store_autoexposure(struct device
*class, struct device_attribute
*attr
,
716 const char *buf
, size_t count
)
719 struct video_device
*vdev
= to_video_device(class);
720 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
722 if (strncmp(buf
, "1", 1) == 0)
723 dev
->vsettings
.auto_exposure
= 1;
724 else if (strncmp(buf
, "0", 1) == 0)
725 dev
->vsettings
.auto_exposure
= 0;
729 dev_microdia_camera_set_auto_exposure(dev
);
736 * @brief show_autowhitebalance
738 * @param class Class device
740 * @retval buf Adress of buffer with the 'vflip' value
742 * @returns Size of buffer
744 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
745 static ssize_t
show_autowhitebalance(struct class_device
*class, char *buf
)
747 static ssize_t
show_autowhitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
750 struct video_device
*vdev
= to_video_device(class);
751 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
753 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_whitebalance
);
758 * @brief store_autowhitebalance
760 * @param class Class device
762 * @param count Counter
764 * @returns Size of buffer
766 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
767 static ssize_t
store_autowhitebalance(struct class_device
*class, const char *buf
, size_t count
)
769 static ssize_t
store_autowhitebalance(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
772 struct video_device
*vdev
= to_video_device(class);
773 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
775 if (strncmp(buf
, "1", 1) == 0)
776 dev
->vsettings
.auto_whitebalance
= 1;
777 else if (strncmp(buf
, "0", 1) == 0)
778 dev
->vsettings
.auto_whitebalance
= 0;
782 dev_microdia_camera_set_auto_whitebalance(dev
);
787 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
788 static CLASS_DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
789 static CLASS_DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
790 static CLASS_DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
791 static CLASS_DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
792 static CLASS_DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
793 static CLASS_DEVICE_ATTR(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
794 static CLASS_DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Brightness exposure */
795 static CLASS_DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
796 static CLASS_DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
797 static CLASS_DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
798 //static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
799 static CLASS_DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
800 static CLASS_DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
801 static CLASS_DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
802 static CLASS_DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
804 static DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
805 static DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
806 static DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
807 static DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
808 static DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
809 static DEVICE_ATTR(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
810 static DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
811 static DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
812 static DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
813 static DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
814 //static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
815 static DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
816 static DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
817 static DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
818 static DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
823 * @brief Create the 'sys' entries.
825 * This function permits to create all the entries in the 'sys' filesystem.
827 * @param vdev Video device structure
829 * @returns 0 if all is OK
831 int microdia_create_sysfs_files(struct video_device
*vdev
)
835 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
836 ret
= video_device_create_file(vdev
, &class_device_attr_release
);
837 ret
= video_device_create_file(vdev
, &class_device_attr_videostatus
);
838 ret
= video_device_create_file(vdev
, &class_device_attr_informations
);
839 ret
= video_device_create_file(vdev
, &class_device_attr_fps
);
840 ret
= video_device_create_file(vdev
, &class_device_attr_brightness
);
841 ret
= video_device_create_file(vdev
, &class_device_attr_rgb_gain
);
842 ret
= video_device_create_file(vdev
, &class_device_attr_exposure
);
843 ret
= video_device_create_file(vdev
, &class_device_attr_contrast
);
844 ret
= video_device_create_file(vdev
, &class_device_attr_whitebalance
);
845 ret
= video_device_create_file(vdev
, &class_device_attr_sharpness
);
846 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
847 ret
= video_device_create_file(vdev
, &class_device_attr_hflip
);
848 ret
= video_device_create_file(vdev
, &class_device_attr_vflip
);
849 ret
= video_device_create_file(vdev
, &class_device_attr_auto_exposure
);
850 ret
= video_device_create_file(vdev
, &class_device_attr_auto_whitebalance
);
851 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
852 ret
= video_device_create_file(vdev
, &dev_attr_release
);
853 ret
= video_device_create_file(vdev
, &dev_attr_videostatus
);
854 ret
= video_device_create_file(vdev
, &dev_attr_informations
);
855 ret
= video_device_create_file(vdev
, &dev_attr_fps
);
856 ret
= video_device_create_file(vdev
, &dev_attr_brightness
);
857 ret
= video_device_create_file(vdev
, &dev_attr_rgb_gain
);
858 ret
= video_device_create_file(vdev
, &dev_attr_exposure
);
859 ret
= video_device_create_file(vdev
, &dev_attr_contrast
);
860 ret
= video_device_create_file(vdev
, &dev_attr_whitebalance
);
861 ret
= video_device_create_file(vdev
, &dev_attr_sharpness
);
862 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
863 ret
= video_device_create_file(vdev
, &dev_attr_hflip
);
864 ret
= video_device_create_file(vdev
, &dev_attr_vflip
);
865 ret
= video_device_create_file(vdev
, &dev_attr_auto_exposure
);
866 ret
= video_device_create_file(vdev
, &dev_attr_auto_whitebalance
);
868 ret
= device_create_file(&vdev
->dev
, &dev_attr_release
);
869 ret
= device_create_file(&vdev
->dev
, &dev_attr_videostatus
);
870 ret
= device_create_file(&vdev
->dev
, &dev_attr_informations
);
871 ret
= device_create_file(&vdev
->dev
, &dev_attr_fps
);
872 ret
= device_create_file(&vdev
->dev
, &dev_attr_brightness
);
873 ret
= device_create_file(&vdev
->dev
, &dev_attr_rgb_gain
);
874 ret
= device_create_file(&vdev
->dev
, &dev_attr_exposure
);
875 ret
= device_create_file(&vdev
->dev
, &dev_attr_contrast
);
876 ret
= device_create_file(&vdev
->dev
, &dev_attr_whitebalance
);
877 ret
= device_create_file(&vdev
->dev
, &dev_attr_sharpness
);
878 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
879 ret
= device_create_file(&vdev
->dev
, &dev_attr_hflip
);
880 ret
= device_create_file(&vdev
->dev
, &dev_attr_vflip
);
881 ret
= device_create_file(&vdev
->dev
, &dev_attr_auto_exposure
);
882 ret
= device_create_file(&vdev
->dev
, &dev_attr_auto_whitebalance
);
889 * @brief Remove the 'sys' entries.
891 * This function permits to remove all the entries in the 'sys' filesystem.
893 * @param vdev Video device structure
895 * @returns 0 if all is OK
897 void microdia_remove_sysfs_files(struct video_device
*vdev
)
899 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
900 video_device_remove_file(vdev
, &class_device_attr_release
);
901 video_device_remove_file(vdev
, &class_device_attr_videostatus
);
902 video_device_remove_file(vdev
, &class_device_attr_informations
);
903 video_device_remove_file(vdev
, &class_device_attr_fps
);
904 video_device_remove_file(vdev
, &class_device_attr_brightness
);
905 video_device_remove_file(vdev
, &class_device_attr_exposure
);
906 video_device_remove_file(vdev
, &class_device_attr_rgb_gain
);
907 video_device_remove_file(vdev
, &class_device_attr_contrast
);
908 video_device_remove_file(vdev
, &class_device_attr_whitebalance
);
909 video_device_remove_file(vdev
, &class_device_attr_sharpness
);
910 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
911 video_device_remove_file(vdev
, &class_device_attr_hflip
);
912 video_device_remove_file(vdev
, &class_device_attr_vflip
);
913 video_device_remove_file(vdev
, &class_device_attr_auto_exposure
);
914 video_device_remove_file(vdev
, &class_device_attr_auto_whitebalance
);
915 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
916 video_device_remove_file(vdev
, &dev_attr_release
);
917 video_device_remove_file(vdev
, &dev_attr_videostatus
);
918 video_device_remove_file(vdev
, &dev_attr_informations
);
919 video_device_remove_file(vdev
, &dev_attr_fps
);
920 video_device_remove_file(vdev
, &dev_attr_brightness
);
921 video_device_remove_file(vdev
, &dev_attr_rgb_gain
);
922 video_device_remove_file(vdev
, &dev_attr_exposure
);
923 video_device_remove_file(vdev
, &dev_attr_contrast
);
924 video_device_remove_file(vdev
, &dev_attr_whitebalance
);
925 video_device_remove_file(vdev
, &dev_attr_sharpness
);
926 /*video_device_remove_file(vdev, &dev_attr_colour);*/
927 video_device_remove_file(vdev
, &dev_attr_hflip
);
928 video_device_remove_file(vdev
, &dev_attr_vflip
);
929 video_device_remove_file(vdev
, &dev_attr_auto_exposure
);
930 video_device_remove_file(vdev
, &dev_attr_auto_whitebalance
);
932 device_remove_file(&vdev
->dev
, &dev_attr_release
);
933 device_remove_file(&vdev
->dev
, &dev_attr_videostatus
);
934 device_remove_file(&vdev
->dev
, &dev_attr_informations
);
935 device_remove_file(&vdev
->dev
, &dev_attr_fps
);
936 device_remove_file(&vdev
->dev
, &dev_attr_brightness
);
937 device_remove_file(&vdev
->dev
, &dev_attr_rgb_gain
);
938 device_remove_file(&vdev
->dev
, &dev_attr_exposure
);
939 device_remove_file(&vdev
->dev
, &dev_attr_contrast
);
940 device_remove_file(&vdev
->dev
, &dev_attr_whitebalance
);
941 device_remove_file(&vdev
->dev
, &dev_attr_sharpness
);
942 /*video_device_remove_file(vdev, &dev_attr_colour);*/
943 device_remove_file(&vdev
->dev
, &dev_attr_hflip
);
944 device_remove_file(&vdev
->dev
, &dev_attr_vflip
);
945 device_remove_file(&vdev
->dev
, &dev_attr_auto_exposure
);
946 device_remove_file(&vdev
->dev
, &dev_attr_auto_whitebalance
);