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>
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_microdia
*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_microdia
*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_informations
96 * @param class Class device
98 * @retval buf Adress of buffer with the 'informations' value
100 * @returns Size of buffer
102 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
103 static ssize_t
show_informations(struct class_device
*class, char *buf
)
105 static ssize_t
show_informations(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_microdia
*dev
= video_get_drvdata(vdev
);
113 char *palette_bgr24
= "BGR24 - BGR-8-8-8 - 24 bits";
114 char *palette_rgb24
= "RGB24 - RGB-8-8-8 - 24 bits";
115 char *palette_yuyv
= "YUYV - YUV 4:2:2 - 16 bits";
116 char *palette_i420
= "I420 - YUV 4:2:0 - 12 bits";
119 switch (dev
->vsettings
.format
.pixelformat
) {
120 case V4L2_PIX_FMT_BGR24
:
121 pixelfmt
= palette_bgr24
;
124 case V4L2_PIX_FMT_RGB24
:
125 pixelfmt
= palette_rgb24
;
128 case V4L2_PIX_FMT_YUYV
:
129 pixelfmt
= palette_yuyv
;
132 case V4L2_PIX_FMT_YUV420
:
133 pixelfmt
= palette_i420
;
138 "Driver Resolution : %dx%d\n"
142 "Brightness : 0x%X\n"
147 "Horizontal flip : %d\n"
148 "Vertical flip : %d\n"
149 "Auto-exposure : %d\n"
150 "Auto-whitebalance : %d\n",
151 dev
->vsettings
.format
.width
,
152 dev
->vsettings
.format
.height
,
154 0xFFFF & dev
->vsettings
.brightness
,
155 0xFFFF & dev
->vsettings
.contrast
,
156 0xFFFF & dev
->vsettings
.whiteness
,
157 0xFFFF & dev
->vsettings
.exposure
,
158 0x3F & dev
->vsettings
.sharpness
,
159 dev
->vsettings
.hflip
,
160 dev
->vsettings
.vflip
,
161 dev
->vsettings
.auto_exposure
,
162 dev
->vsettings
.auto_whitebalance
);
169 * @param class Class device
171 * @retval buf Adress of buffer with the 'fps' value
173 * @returns Size of buffer
175 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
176 static ssize_t
show_fps(struct class_device
*class, char *buf
)
178 static ssize_t
show_fps(struct device
*class, struct device_attribute
*attr
, char *buf
)
181 struct video_device
*vdev
= to_video_device(class);
182 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
184 return sprintf(buf
, "%d\n", dev
->vsettings
.fps
);
188 * @brief show_rgb_gain
190 * @param class Class device
192 * @retval buf Address of buffer with the 'rgb_gain' value
194 * @returns Size of buffer
196 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
197 static ssize_t
show_rgb_gain(struct class_device
*class, char *buf
)
199 static ssize_t
show_rgb_gain(struct device
*class,
200 struct device_attribute
*attr
, char *buf
)
205 struct video_device
*vdev
= to_video_device(class);
206 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
207 rgb_gain
|= dev
->vsettings
.rgb_gain
[0] << 16;
208 rgb_gain
|= dev
->vsettings
.rgb_gain
[1] << 8;
209 rgb_gain
|= dev
->vsettings
.rgb_gain
[3];
210 return sprintf(buf
, "0x%06X\n", rgb_gain
);
214 * @brief store_exposure
216 * @param class Class device
218 * @param count Counter
220 * @returns Size of buffer
222 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
223 static ssize_t
store_rgb_gain(struct class_device
*class,
224 const char *buf
, size_t count
)
226 static ssize_t
store_rgb_gain(struct device
*class,
227 struct device_attribute
*attr
, const char *buf
, size_t count
)
231 unsigned long rgb_gain
;
233 struct video_device
*vdev
= to_video_device(class);
234 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
236 rgb_gain
= simple_strtoul(buf
, &endp
, 16);
238 dev
->vsettings
.rgb_gain
[0] = (rgb_gain
>> 16) & 0x7f;
239 dev
->vsettings
.rgb_gain
[1] = (rgb_gain
>> 8) & 0x7f;
240 dev
->vsettings
.rgb_gain
[2] = (rgb_gain
>> 8) & 0x7f;
241 dev
->vsettings
.rgb_gain
[3] = rgb_gain
& 0x7f;
243 dev_microdia_camera_set_rgb_gain(dev
);
249 * @brief show_exposure
251 * @param class Class device
253 * @retval buf Adress of buffer with the 'exposure' value
255 * @returns Size of buffer
257 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
258 static ssize_t
show_exposure(struct class_device
*class, char *buf
)
260 static ssize_t
show_exposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
263 struct video_device
*vdev
= to_video_device(class);
264 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
266 return sprintf(buf
, "%X\n", dev
->vsettings
.exposure
);
270 * @brief store_exposure
272 * @param class Class device
274 * @param count Counter
276 * @returns Size of buffer
278 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
279 static ssize_t
store_exposure(struct class_device
*class, const char *buf
, size_t count
)
281 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
282 const char *buf
, size_t count
)
288 struct video_device
*vdev
= to_video_device(class);
289 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
291 value
= simple_strtoul(buf
, &endp
, 16);
293 dev
->vsettings
.exposure
= (int) value
;
295 dev_microdia_camera_set_exposure(dev
);
301 * @brief show_brightness
303 * @param class Class device
305 * @retval buf Adress of buffer with the 'brightness' value
307 * @returns Size of buffer
309 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
310 static ssize_t
show_brightness(struct class_device
*class, char *buf
)
312 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
315 struct video_device
*vdev
= to_video_device(class);
316 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
318 return sprintf(buf
, "%X\n", dev
->vsettings
.brightness
);
322 * @brief store_brightness
324 * @param class Class device
326 * @param count Counter
328 * @returns Size of buffer
330 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
331 static ssize_t
store_brightness(struct class_device
*class, const char *buf
, size_t count
)
333 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
334 const char *buf
, size_t count
)
340 struct video_device
*vdev
= to_video_device(class);
341 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
343 value
= simple_strtoul(buf
, &endp
, 16);
345 dev
->vsettings
.brightness
= (int) value
;
347 dev_microdia_camera_set_brightness(dev
);
353 * @brief show_contrast
355 * @param class Class device
357 * @retval buf Adress of buffer with the 'contrast' value
359 * @returns Size of buffer
361 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
362 static ssize_t
show_contrast(struct class_device
*class, char *buf
)
364 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
367 struct video_device
*vdev
= to_video_device(class);
368 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
370 return sprintf(buf
, "%X\n", dev
->vsettings
.contrast
);
375 * @brief store_contrast
377 * @param class Class device
379 * @param count Counter
381 * @returns Size of buffer
383 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
384 static ssize_t
store_contrast(struct class_device
*class, const char *buf
, size_t count
)
386 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
387 const char *buf
, size_t count
)
393 struct video_device
*vdev
= to_video_device(class);
394 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
396 value
= simple_strtoul(buf
, &endp
, 16);
398 dev
->vsettings
.contrast
= (int) value
;
400 dev_microdia_camera_set_contrast(dev
);
401 // dev_microdia_set_camera_quality(dev);
408 * @brief show_whitebalance
410 * @param class Class device
412 * @retval buf Adress of buffer with the 'whitebalance' value
414 * @returns Size of buffer
416 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
417 static ssize_t
show_whitebalance(struct class_device
*class, char *buf
)
419 static ssize_t
show_whitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
422 struct video_device
*vdev
= to_video_device(class);
423 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
425 return sprintf(buf
, "%X\n", dev
->vsettings
.whiteness
);
430 * @brief store_whitebalance
432 * @param class Class device
434 * @param count Counter
436 * @returns Size of buffer
438 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
439 static ssize_t
store_whitebalance(struct class_device
*class, const char *buf
, size_t count
)
441 static ssize_t
store_whitebalance(struct device
*class, struct device_attribute
*attr
,
442 const char *buf
, size_t count
)
448 struct video_device
*vdev
= to_video_device(class);
449 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
451 value
= simple_strtoul(buf
, &endp
, 16);
453 dev
->vsettings
.whiteness
= (int) value
;
455 dev_microdia_camera_set_gamma(dev
);
456 // dev_microdia_set_camera_quality(dev);
465 * @param class Class device
467 * @retval buf Adress of buffer with the 'colour' value
469 * @returns Size of buffer
471 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
472 static ssize_t show_colour(struct class_device *class, char *buf)
474 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
477 struct video_device *vdev = to_video_device(class);
478 struct usb_microdia *dev = video_get_drvdata(vdev);
480 return sprintf(buf, "%X\n", dev->vsettings.colour);
485 * @brief store_colour
487 * @param class Class device
489 * @param count Counter
491 * @returns Size of buffer
493 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
494 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
496 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
497 const char *buf, size_t count)
503 struct video_device *vdev = to_video_device(class);
504 struct usb_microdia *dev = video_get_drvdata(vdev);
506 value = simple_strtoul(buf, &endp, 16);
508 dev->vsettings.colour = (int) value;
510 // dev_microdia_set_camera_quality(dev);
518 * @brief show_sharpness
520 * @param class Class device
522 * @retval buf Adress of buffer with the 'sharpness' value
524 * @returns Size of buffer
526 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
527 static ssize_t
show_sharpness(struct class_device
*class, char *buf
)
529 static ssize_t
show_sharpness(struct device
*class, struct device_attribute
*attr
, char *buf
)
532 struct video_device
*vdev
= to_video_device(class);
533 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
535 return sprintf(buf
, "%X\n", dev
->vsettings
.sharpness
);
539 * @brief store_sharpness
541 * @param class Class device
543 * @param count Counter
545 * @returns Size of buffer
547 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
548 static ssize_t
store_sharpness(struct class_device
*class, const char *buf
, size_t count
)
550 static ssize_t
store_sharpness(struct device
*class, struct device_attribute
*attr
,
551 const char *buf
, size_t count
)
557 struct video_device
*vdev
= to_video_device(class);
558 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
560 value
= simple_strtoul(buf
, &endp
, 16);
562 if (value
< 0 || value
> 0x3f)
565 dev
->vsettings
.sharpness
= (int) value
;
567 dev_microdia_camera_set_sharpness(dev
);
576 * @param class Class device
578 * @retval buf Adress of buffer with the 'hflip' value
580 * @returns Size of buffer
582 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
583 static ssize_t
show_hflip(struct class_device
*class, char *buf
)
585 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
588 struct video_device
*vdev
= to_video_device(class);
589 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
591 return sprintf(buf
, "%d\n", dev
->vsettings
.hflip
);
598 * @param class Class device
600 * @param count Counter
602 * @returns Size of buffer
604 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
605 static ssize_t
store_hflip(struct class_device
*class, const char *buf
, size_t count
)
607 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
608 const char *buf
, size_t count
)
611 struct video_device
*vdev
= to_video_device(class);
612 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
614 if (strncmp(buf
, "1", 1) == 0)
615 dev
->vsettings
.hflip
= 1;
616 else if (strncmp(buf
, "0", 1) == 0)
617 dev
->vsettings
.hflip
= 0;
621 dev_microdia_camera_set_hvflip(dev
);
630 * @param class Class device
632 * @retval buf Adress of buffer with the 'vflip' value
634 * @returns Size of buffer
636 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
637 static ssize_t
show_vflip(struct class_device
*class, char *buf
)
639 static ssize_t
show_vflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
642 struct video_device
*vdev
= to_video_device(class);
643 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
645 return sprintf(buf
, "%d\n", dev
->vsettings
.vflip
);
652 * @param class Class device
654 * @param count Counter
656 * @returns Size of buffer
658 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
659 static ssize_t
store_vflip(struct class_device
*class, const char *buf
, size_t count
)
661 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
664 struct video_device
*vdev
= to_video_device(class);
665 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
667 if (strncmp(buf
, "1", 1) == 0)
668 dev
->vsettings
.vflip
= 1;
669 else if (strncmp(buf
, "0", 1) == 0)
670 dev
->vsettings
.vflip
= 0;
674 dev_microdia_camera_set_hvflip(dev
);
681 * @brief show_autoexposure
683 * @param class Class device
685 * @retval buf Adress of buffer with the 'hflip' value
687 * @returns Size of buffer
689 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
690 static ssize_t
show_autoexposure(struct class_device
*class, char *buf
)
692 static ssize_t
show_autoexposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
695 struct video_device
*vdev
= to_video_device(class);
696 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
698 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_exposure
);
703 * @brief store_autoexposure
705 * @param class Class device
707 * @param count Counter
709 * @returns Size of buffer
711 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
712 static ssize_t
store_autoexposure(struct class_device
*class, const char *buf
, size_t count
)
714 static ssize_t
store_autoexposure(struct device
*class, struct device_attribute
*attr
,
715 const char *buf
, size_t count
)
718 struct video_device
*vdev
= to_video_device(class);
719 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
721 if (strncmp(buf
, "1", 1) == 0)
722 dev
->vsettings
.auto_exposure
= 1;
723 else if (strncmp(buf
, "0", 1) == 0)
724 dev
->vsettings
.auto_exposure
= 0;
728 dev_microdia_camera_set_auto_exposure(dev
);
735 * @brief show_autowhitebalance
737 * @param class Class device
739 * @retval buf Adress of buffer with the 'vflip' value
741 * @returns Size of buffer
743 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
744 static ssize_t
show_autowhitebalance(struct class_device
*class, char *buf
)
746 static ssize_t
show_autowhitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
749 struct video_device
*vdev
= to_video_device(class);
750 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
752 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_whitebalance
);
757 * @brief store_autowhitebalance
759 * @param class Class device
761 * @param count Counter
763 * @returns Size of buffer
765 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
766 static ssize_t
store_autowhitebalance(struct class_device
*class, const char *buf
, size_t count
)
768 static ssize_t
store_autowhitebalance(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
771 struct video_device
*vdev
= to_video_device(class);
772 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
774 if (strncmp(buf
, "1", 1) == 0)
775 dev
->vsettings
.auto_whitebalance
= 1;
776 else if (strncmp(buf
, "0", 1) == 0)
777 dev
->vsettings
.auto_whitebalance
= 0;
781 dev_microdia_camera_set_auto_whitebalance(dev
);
786 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
787 static CLASS_DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
788 static CLASS_DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
789 static CLASS_DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
790 static CLASS_DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
791 static CLASS_DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
792 static CLASS_DEVICE_ATTR(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
793 static CLASS_DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Brightness exposure */
794 static CLASS_DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
795 static CLASS_DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
796 static CLASS_DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
797 //static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
798 static CLASS_DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
799 static CLASS_DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
800 static CLASS_DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
801 static CLASS_DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
803 static DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
804 static DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
805 static DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
806 static DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
807 static DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
808 static DEVICE_ATTR(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
809 static DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
810 static DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
811 static DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
812 static DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
813 //static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
814 static DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
815 static DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
816 static DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
817 static DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
822 * @brief Create the 'sys' entries.
824 * This function permits to create all the entries in the 'sys' filesystem.
826 * @param vdev Video device structure
828 * @returns 0 if all is OK
830 int microdia_create_sysfs_files(struct video_device
*vdev
)
834 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
835 ret
= video_device_create_file(vdev
, &class_device_attr_release
);
836 ret
= video_device_create_file(vdev
, &class_device_attr_videostatus
);
837 ret
= video_device_create_file(vdev
, &class_device_attr_informations
);
838 ret
= video_device_create_file(vdev
, &class_device_attr_fps
);
839 ret
= video_device_create_file(vdev
, &class_device_attr_brightness
);
840 ret
= video_device_create_file(vdev
, &class_device_attr_rgb_gain
);
841 ret
= video_device_create_file(vdev
, &class_device_attr_exposure
);
842 ret
= video_device_create_file(vdev
, &class_device_attr_contrast
);
843 ret
= video_device_create_file(vdev
, &class_device_attr_whitebalance
);
844 ret
= video_device_create_file(vdev
, &class_device_attr_sharpness
);
845 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
846 ret
= video_device_create_file(vdev
, &class_device_attr_hflip
);
847 ret
= video_device_create_file(vdev
, &class_device_attr_vflip
);
848 ret
= video_device_create_file(vdev
, &class_device_attr_auto_exposure
);
849 ret
= video_device_create_file(vdev
, &class_device_attr_auto_whitebalance
);
851 ret
= video_device_create_file(vdev
, &dev_attr_release
);
852 ret
= video_device_create_file(vdev
, &dev_attr_videostatus
);
853 ret
= video_device_create_file(vdev
, &dev_attr_informations
);
854 ret
= video_device_create_file(vdev
, &dev_attr_fps
);
855 ret
= video_device_create_file(vdev
, &dev_attr_brightness
);
856 ret
= video_device_create_file(vdev
, &dev_attr_rgb_gain
);
857 ret
= video_device_create_file(vdev
, &dev_attr_exposure
);
858 ret
= video_device_create_file(vdev
, &dev_attr_contrast
);
859 ret
= video_device_create_file(vdev
, &dev_attr_whitebalance
);
860 ret
= video_device_create_file(vdev
, &dev_attr_sharpness
);
861 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
862 ret
= video_device_create_file(vdev
, &dev_attr_hflip
);
863 ret
= video_device_create_file(vdev
, &dev_attr_vflip
);
864 ret
= video_device_create_file(vdev
, &dev_attr_auto_exposure
);
865 ret
= video_device_create_file(vdev
, &dev_attr_auto_whitebalance
);
872 * @brief Remove the 'sys' entries.
874 * This function permits to remove all the entries in the 'sys' filesystem.
876 * @param vdev Video device structure
878 * @returns 0 if all is OK
880 void microdia_remove_sysfs_files(struct video_device
*vdev
)
882 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
883 video_device_remove_file(vdev
, &class_device_attr_release
);
884 video_device_remove_file(vdev
, &class_device_attr_videostatus
);
885 video_device_remove_file(vdev
, &class_device_attr_informations
);
886 video_device_remove_file(vdev
, &class_device_attr_fps
);
887 video_device_remove_file(vdev
, &class_device_attr_brightness
);
888 video_device_remove_file(vdev
, &class_device_attr_exposure
);
889 video_device_remove_file(vdev
, &class_device_attr_rgb_gain
);
890 video_device_remove_file(vdev
, &class_device_attr_contrast
);
891 video_device_remove_file(vdev
, &class_device_attr_whitebalance
);
892 video_device_remove_file(vdev
, &class_device_attr_sharpness
);
893 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
894 video_device_remove_file(vdev
, &class_device_attr_hflip
);
895 video_device_remove_file(vdev
, &class_device_attr_vflip
);
896 video_device_remove_file(vdev
, &class_device_attr_auto_exposure
);
897 video_device_remove_file(vdev
, &class_device_attr_auto_whitebalance
);
899 video_device_remove_file(vdev
, &dev_attr_release
);
900 video_device_remove_file(vdev
, &dev_attr_videostatus
);
901 video_device_remove_file(vdev
, &dev_attr_informations
);
902 video_device_remove_file(vdev
, &dev_attr_fps
);
903 video_device_remove_file(vdev
, &dev_attr_brightness
);
904 video_device_remove_file(vdev
, &dev_attr_rgb_gain
);
905 video_device_remove_file(vdev
, &dev_attr_exposure
);
906 video_device_remove_file(vdev
, &dev_attr_contrast
);
907 video_device_remove_file(vdev
, &dev_attr_whitebalance
);
908 video_device_remove_file(vdev
, &dev_attr_sharpness
);
909 /*video_device_remove_file(vdev, &dev_attr_colour);*/
910 video_device_remove_file(vdev
, &dev_attr_hflip
);
911 video_device_remove_file(vdev
, &dev_attr_vflip
);
912 video_device_remove_file(vdev
, &dev_attr_auto_exposure
);
913 video_device_remove_file(vdev
, &dev_attr_auto_whitebalance
);