2 * @file microdia-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>
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
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
278 * @returns Size of buffer
280 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
281 static ssize_t
store_exposure(struct class_device
*class, const char *buf
, size_t count
)
283 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
284 const char *buf
, size_t count
)
290 struct video_device
*vdev
= to_video_device(class);
291 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
293 value
= simple_strtoul(buf
, &endp
, 16);
295 dev
->vsettings
.exposure
= (int) value
;
297 dev_microdia_camera_set_exposure(dev
);
303 * @brief show_brightness
305 * @param class Class device
307 * @retval buf Adress of buffer with the 'brightness' value
309 * @returns Size of buffer
311 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
312 static ssize_t
show_brightness(struct class_device
*class, char *buf
)
314 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
317 struct video_device
*vdev
= to_video_device(class);
318 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
320 return sprintf(buf
, "%X\n", dev
->vsettings
.brightness
);
324 * @brief store_brightness
326 * @param class Class device
328 * @param count Counter
331 * @returns Size of buffer
333 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
334 static ssize_t
store_brightness(struct class_device
*class, const char *buf
, size_t count
)
336 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
337 const char *buf
, size_t count
)
343 struct video_device
*vdev
= to_video_device(class);
344 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
346 value
= simple_strtoul(buf
, &endp
, 16);
348 dev
->vsettings
.brightness
= (int) value
;
350 dev_microdia_camera_set_brightness(dev
);
356 * @brief show_contrast
358 * @param class Class device
360 * @retval buf Adress of buffer with the 'contrast' value
362 * @returns Size of buffer
364 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
365 static ssize_t
show_contrast(struct class_device
*class, char *buf
)
367 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
370 struct video_device
*vdev
= to_video_device(class);
371 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
373 return sprintf(buf
, "%X\n", dev
->vsettings
.contrast
);
378 * @brief store_contrast
380 * @param class Class device
382 * @param count Counter
385 * @returns Size of buffer
387 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
388 static ssize_t
store_contrast(struct class_device
*class, const char *buf
, size_t count
)
390 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
391 const char *buf
, size_t count
)
397 struct video_device
*vdev
= to_video_device(class);
398 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
400 value
= simple_strtoul(buf
, &endp
, 16);
402 dev
->vsettings
.contrast
= (int) value
;
404 dev_microdia_camera_set_contrast(dev
);
405 /* dev_microdia_set_camera_quality(dev); */
412 * @brief show_whitebalance
414 * @param class Class device
416 * @retval buf Adress of buffer with the 'whitebalance' value
418 * @returns Size of buffer
420 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
421 static ssize_t
show_whitebalance(struct class_device
*class, char *buf
)
423 static ssize_t
show_whitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
426 struct video_device
*vdev
= to_video_device(class);
427 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
429 return sprintf(buf
, "%X\n", dev
->vsettings
.whiteness
);
434 * @brief store_whitebalance
436 * @param class Class device
438 * @param count Counter
441 * @returns Size of buffer
443 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
444 static ssize_t
store_whitebalance(struct class_device
*class, const char *buf
, size_t count
)
446 static ssize_t
store_whitebalance(struct device
*class, struct device_attribute
*attr
,
447 const char *buf
, size_t count
)
453 struct video_device
*vdev
= to_video_device(class);
454 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
456 value
= simple_strtoul(buf
, &endp
, 16);
458 dev
->vsettings
.whiteness
= (int) value
;
460 dev_microdia_camera_set_gamma(dev
);
461 /* dev_microdia_set_camera_quality(dev); */
470 * @param class Class device
472 * @retval buf Adress of buffer with the 'colour' value
474 * @returns Size of buffer
476 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
477 static ssize_t show_colour(struct class_device *class, char *buf)
479 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
482 struct video_device *vdev = to_video_device(class);
483 struct usb_microdia *dev = video_get_drvdata(vdev);
485 return sprintf(buf, "%X\n", dev->vsettings.colour);
490 * @brief store_colour
492 * @param class Class device
494 * @param count Counter
497 * @returns Size of buffer
499 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
500 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
502 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
503 const char *buf, size_t count)
509 struct video_device *vdev = to_video_device(class);
510 struct usb_microdia *dev = video_get_drvdata(vdev);
512 value = simple_strtoul(buf, &endp, 16);
514 dev->vsettings.colour = (int) value;
516 / dev_microdia_set_camera_quality(dev); /
524 * @brief show_sharpness
526 * @param class Class device
528 * @retval buf Adress of buffer with the 'sharpness' value
530 * @returns Size of buffer
532 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
533 static ssize_t
show_sharpness(struct class_device
*class, char *buf
)
535 static ssize_t
show_sharpness(struct device
*class, struct device_attribute
*attr
, char *buf
)
538 struct video_device
*vdev
= to_video_device(class);
539 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
541 return sprintf(buf
, "%X\n", dev
->vsettings
.sharpness
);
545 * @brief store_sharpness
547 * @param class Class device
549 * @param count Counter
552 * @returns Size of buffer
554 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
555 static ssize_t
store_sharpness(struct class_device
*class, const char *buf
, size_t count
)
557 static ssize_t
store_sharpness(struct device
*class, struct device_attribute
*attr
,
558 const char *buf
, size_t count
)
564 struct video_device
*vdev
= to_video_device(class);
565 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
567 value
= simple_strtoul(buf
, &endp
, 16);
569 if (value
< 0 || value
> 0x3f)
572 dev
->vsettings
.sharpness
= (int) value
;
574 dev_microdia_camera_set_sharpness(dev
);
583 * @param class Class device
585 * @retval buf Adress of buffer with the 'hflip' value
587 * @returns Size of buffer
589 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
590 static ssize_t
show_hflip(struct class_device
*class, char *buf
)
592 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
595 struct video_device
*vdev
= to_video_device(class);
596 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
598 return sprintf(buf
, "%d\n", dev
->vsettings
.hflip
);
605 * @param class Class device
607 * @param count Counter
610 * @returns Size of buffer
612 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
613 static ssize_t
store_hflip(struct class_device
*class, const char *buf
, size_t count
)
615 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
616 const char *buf
, size_t count
)
619 struct video_device
*vdev
= to_video_device(class);
620 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
622 if (strncmp(buf
, "1", 1) == 0)
623 dev
->vsettings
.hflip
= 1;
624 else if (strncmp(buf
, "0", 1) == 0)
625 dev
->vsettings
.hflip
= 0;
629 dev_microdia_camera_set_hvflip(dev
);
638 * @param class Class device
640 * @retval buf Adress of buffer with the 'vflip' value
642 * @returns Size of buffer
644 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
645 static ssize_t
show_vflip(struct class_device
*class, char *buf
)
647 static ssize_t
show_vflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
650 struct video_device
*vdev
= to_video_device(class);
651 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
653 return sprintf(buf
, "%d\n", dev
->vsettings
.vflip
);
660 * @param class Class device
662 * @param count Counter
665 * @returns Size of buffer
667 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
668 static ssize_t
store_vflip(struct class_device
*class, const char *buf
, size_t count
)
670 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
673 struct video_device
*vdev
= to_video_device(class);
674 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
676 if (strncmp(buf
, "1", 1) == 0)
677 dev
->vsettings
.vflip
= 1;
678 else if (strncmp(buf
, "0", 1) == 0)
679 dev
->vsettings
.vflip
= 0;
683 dev_microdia_camera_set_hvflip(dev
);
690 * @brief show_autoexposure
692 * @param class Class device
694 * @retval buf Adress of buffer with the 'hflip' value
696 * @returns Size of buffer
698 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
699 static ssize_t
show_autoexposure(struct class_device
*class, char *buf
)
701 static ssize_t
show_autoexposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
704 struct video_device
*vdev
= to_video_device(class);
705 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
707 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_exposure
);
712 * @brief store_autoexposure
714 * @param class Class device
716 * @param count Counter
719 * @returns Size of buffer
721 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
722 static ssize_t
store_autoexposure(struct class_device
*class, const char *buf
, size_t count
)
724 static ssize_t
store_autoexposure(struct device
*class, struct device_attribute
*attr
,
725 const char *buf
, size_t count
)
728 struct video_device
*vdev
= to_video_device(class);
729 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
731 if (strncmp(buf
, "1", 1) == 0)
732 dev
->vsettings
.auto_exposure
= 1;
733 else if (strncmp(buf
, "0", 1) == 0)
734 dev
->vsettings
.auto_exposure
= 0;
738 dev_microdia_camera_set_auto_exposure(dev
);
745 * @brief show_autowhitebalance
747 * @param class Class device
749 * @retval buf Adress of buffer with the 'vflip' value
751 * @returns Size of buffer
753 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
754 static ssize_t
show_autowhitebalance(struct class_device
*class, char *buf
)
756 static ssize_t
show_autowhitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
759 struct video_device
*vdev
= to_video_device(class);
760 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
762 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_whitebalance
);
767 * @brief store_autowhitebalance
769 * @param class Class device
771 * @param count Counter
774 * @returns Size of buffer
776 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
777 static ssize_t
store_autowhitebalance(struct class_device
*class, const char *buf
, size_t count
)
779 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_microdia
*dev
= video_get_drvdata(vdev
);
785 if (strncmp(buf
, "1", 1) == 0)
786 dev
->vsettings
.auto_whitebalance
= 1;
787 else if (strncmp(buf
, "0", 1) == 0)
788 dev
->vsettings
.auto_whitebalance
= 0;
792 dev_microdia_camera_set_auto_whitebalance(dev
);
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(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
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(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
804 static CLASS_DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Brightness exposure */
805 static CLASS_DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
806 static CLASS_DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance 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(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
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(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
820 static DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
821 static DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
822 static DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance 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 microdia_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_informations
);
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_rgb_gain
);
852 ret
= video_device_create_file(vdev
, &class_device_attr_exposure
);
853 ret
= video_device_create_file(vdev
, &class_device_attr_contrast
);
854 ret
= video_device_create_file(vdev
, &class_device_attr_whitebalance
);
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_informations
);
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_rgb_gain
);
868 ret
= video_device_create_file(vdev
, &dev_attr_exposure
);
869 ret
= video_device_create_file(vdev
, &dev_attr_contrast
);
870 ret
= video_device_create_file(vdev
, &dev_attr_whitebalance
);
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_informations
);
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_rgb_gain
);
884 ret
= device_create_file(&vdev
->dev
, &dev_attr_exposure
);
885 ret
= device_create_file(&vdev
->dev
, &dev_attr_contrast
);
886 ret
= device_create_file(&vdev
->dev
, &dev_attr_whitebalance
);
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 microdia_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_informations
);
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_rgb_gain
);
917 video_device_remove_file(vdev
, &class_device_attr_contrast
);
918 video_device_remove_file(vdev
, &class_device_attr_whitebalance
);
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_informations
);
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_rgb_gain
);
932 video_device_remove_file(vdev
, &dev_attr_exposure
);
933 video_device_remove_file(vdev
, &dev_attr_contrast
);
934 video_device_remove_file(vdev
, &dev_attr_whitebalance
);
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_informations
);
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_rgb_gain
);
948 device_remove_file(&vdev
->dev
, &dev_attr_exposure
);
949 device_remove_file(&vdev
->dev
, &dev_attr_contrast
);
950 device_remove_file(&vdev
->dev
, &dev_attr_whitebalance
);
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
);