2 * @file microdia-sysfs.c
3 * @author Nicolas VIVIEN
7 * @brief Driver for Microdia USB video camera
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>
44 extern const struct microdia_coord microdia_image_sizes
[MICRODIA_NBR_SIZES
];
50 * @param class Class device
52 * @retval buf Adress of buffer with the 'release' value
54 * @returns Size of buffer
56 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
57 static ssize_t
show_release(struct class_device
*class, char *buf
)
59 static ssize_t
show_release(struct device
*class, struct device_attribute
*attr
, char *buf
)
62 struct video_device
*vdev
= to_video_device(class);
63 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
65 return sprintf(buf
, "%d\n", dev
->release
);
70 * @brief show_videostatus
72 * @param class Class device
74 * @retval buf Adress of buffer with the 'videostatus' value
76 * @returns Size of buffer
78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
79 static ssize_t
show_videostatus(struct class_device
*class, char *buf
)
81 static ssize_t
show_videostatus(struct device
*class, struct device_attribute
*attr
, char *buf
)
84 struct video_device
*vdev
= to_video_device(class);
85 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
88 "Overflow frames : %d\n"
89 "Incomplete frames : %d\n"
90 "Dropped frames : %d\n",
91 dev
->vframes_overflow
,
92 dev
->vframes_incomplete
,
93 dev
->vframes_dropped
);
98 * @brief show_informations
100 * @param class Class device
102 * @retval buf Adress of buffer with the 'informations' value
104 * @returns Size of buffer
106 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
107 static ssize_t
show_informations(struct class_device
*class, char *buf
)
109 static ssize_t
show_informations(struct device
*class, struct device_attribute
*attr
, char *buf
)
113 char *pixelfmt
= NULL
;
115 struct video_device
*vdev
= to_video_device(class);
116 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
118 char *palette_bgr24
= "BGR24 - BGR-8-8-8 - 24 bits";
119 char *palette_rgb24
= "RGB24 - RGB-8-8-8 - 24 bits";
120 char *palette_yuyv
= "YUYV - YUV 4:2:2 - 16 bits";
121 char *palette_i420
= "I420 - YUV 4:2:0 - 12 bits";
124 switch (dev
->vsettings
.format
.pixelformat
) {
125 case V4L2_PIX_FMT_BGR24
:
126 pixelfmt
= palette_bgr24
;
129 case V4L2_PIX_FMT_RGB24
:
130 pixelfmt
= palette_rgb24
;
133 case V4L2_PIX_FMT_YUYV
:
134 pixelfmt
= palette_yuyv
;
137 case V4L2_PIX_FMT_YUV420
:
138 pixelfmt
= palette_i420
;
142 switch (dev
->resolution
) {
144 /*case MICRODIA_128x96:*/
145 case MICRODIA_160x120
:
146 /*case MICRODIA_213x160: */
147 case MICRODIA_320x240
:
148 case MICRODIA_640x480
:
149 width
= microdia_image_sizes
[MICRODIA_640x480
].x
;
150 height
= microdia_image_sizes
[MICRODIA_640x480
].y
;
153 case MICRODIA_800x600
:
154 case MICRODIA_1024x768
:
155 case MICRODIA_1280x1024
:
156 width
= microdia_image_sizes
[MICRODIA_1280x1024
].x
;
157 height
= microdia_image_sizes
[MICRODIA_1280x1024
].y
;
166 "Asked resolution : %dx%d\n"
167 "Driver resolution : %dx%d\n"
168 "Webcam resolution : %dx%d\n"
172 "Brightness : 0x%X\n"
177 "Horizontal flip : %d\n"
178 "Vertical flip : %d\n"
179 "Auto-exposure : %d\n"
180 "Auto-whitebalance : %d\n",
181 dev
->view
.x
, dev
->view
.y
,
182 microdia_image_sizes
[dev
->resolution
].x
, microdia_image_sizes
[dev
->resolution
].y
,
185 0xFFFF & dev
->vsettings
.brightness
,
186 0xFFFF & dev
->vsettings
.contrast
,
187 0xFFFF & dev
->vsettings
.whiteness
,
188 0xFFFF & dev
->vsettings
.exposure
,
189 0x3F & dev
->vsettings
.sharpness
,
190 dev
->vsettings
.hflip
,
191 dev
->vsettings
.vflip
,
192 dev
->vsettings
.auto_exposure
,
193 dev
->vsettings
.auto_whitebalance
);
200 * @param class Class device
202 * @retval buf Adress of buffer with the 'fps' value
204 * @returns Size of buffer
206 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
207 static ssize_t
show_fps(struct class_device
*class, char *buf
)
209 static ssize_t
show_fps(struct device
*class, struct device_attribute
*attr
, char *buf
)
212 struct video_device
*vdev
= to_video_device(class);
213 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
215 return sprintf(buf
, "%d\n", dev
->vsettings
.fps
);
219 * @brief show_rgb_gain
221 * @param class Class device
223 * @retval buf Address of buffer with the 'rgb_gain' value
225 * @returns Size of buffer
227 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
228 static ssize_t
show_rgb_gain(struct class_device
*class, char *buf
)
230 static ssize_t
show_rgb_gain(struct device
*class,
231 struct device_attribute
*attr
, char *buf
)
236 struct video_device
*vdev
= to_video_device(class);
237 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
238 rgb_gain
|= dev
->vsettings
.rgb_gain
[0] << 16;
239 rgb_gain
|= dev
->vsettings
.rgb_gain
[1] << 8;
240 rgb_gain
|= dev
->vsettings
.rgb_gain
[3];
241 return sprintf(buf
, "0x%06X\n", rgb_gain
);
245 * @brief store_exposure
247 * @param class Class device
249 * @param count Counter
251 * @returns Size of buffer
253 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
254 static ssize_t
store_rgb_gain(struct class_device
*class,
255 const char *buf
, size_t count
)
257 static ssize_t
store_rgb_gain(struct device
*class,
258 struct device_attribute
*attr
, const char *buf
, size_t count
)
262 unsigned long rgb_gain
;
264 struct video_device
*vdev
= to_video_device(class);
265 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
267 rgb_gain
= simple_strtoul(buf
, &endp
, 16);
269 dev
->vsettings
.rgb_gain
[0] = (rgb_gain
>> 16) & 0x7f;
270 dev
->vsettings
.rgb_gain
[1] = (rgb_gain
>> 8) & 0x7f;
271 dev
->vsettings
.rgb_gain
[2] = (rgb_gain
>> 8) & 0x7f;
272 dev
->vsettings
.rgb_gain
[3] = rgb_gain
& 0x7f;
274 dev_microdia_camera_set_rgb_gain(dev
);
280 * @brief show_exposure
282 * @param class Class device
284 * @retval buf Adress of buffer with the 'exposure' value
286 * @returns Size of buffer
288 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
289 static ssize_t
show_exposure(struct class_device
*class, char *buf
)
291 static ssize_t
show_exposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
294 struct video_device
*vdev
= to_video_device(class);
295 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
297 return sprintf(buf
, "%X\n", dev
->vsettings
.exposure
);
301 * @brief store_exposure
303 * @param class Class device
305 * @param count Counter
307 * @returns Size of buffer
309 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
310 static ssize_t
store_exposure(struct class_device
*class, const char *buf
, size_t count
)
312 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
313 const char *buf
, size_t count
)
319 struct video_device
*vdev
= to_video_device(class);
320 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
322 value
= simple_strtoul(buf
, &endp
, 16);
324 dev
->vsettings
.exposure
= (int) value
;
326 dev_microdia_camera_set_exposure(dev
);
332 * @brief show_brightness
334 * @param class Class device
336 * @retval buf Adress of buffer with the 'brightness' value
338 * @returns Size of buffer
340 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
341 static ssize_t
show_brightness(struct class_device
*class, char *buf
)
343 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
346 struct video_device
*vdev
= to_video_device(class);
347 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
349 return sprintf(buf
, "%X\n", dev
->vsettings
.brightness
);
353 * @brief store_brightness
355 * @param class Class device
357 * @param count Counter
359 * @returns Size of buffer
361 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
362 static ssize_t
store_brightness(struct class_device
*class, const char *buf
, size_t count
)
364 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
365 const char *buf
, size_t count
)
371 struct video_device
*vdev
= to_video_device(class);
372 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
374 value
= simple_strtoul(buf
, &endp
, 16);
376 dev
->vsettings
.brightness
= (int) value
;
378 dev_microdia_camera_set_brightness(dev
);
384 * @brief show_contrast
386 * @param class Class device
388 * @retval buf Adress of buffer with the 'contrast' value
390 * @returns Size of buffer
392 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
393 static ssize_t
show_contrast(struct class_device
*class, char *buf
)
395 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
398 struct video_device
*vdev
= to_video_device(class);
399 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
401 return sprintf(buf
, "%X\n", dev
->vsettings
.contrast
);
406 * @brief store_contrast
408 * @param class Class device
410 * @param count Counter
412 * @returns Size of buffer
414 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
415 static ssize_t
store_contrast(struct class_device
*class, const char *buf
, size_t count
)
417 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
418 const char *buf
, size_t count
)
424 struct video_device
*vdev
= to_video_device(class);
425 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
427 value
= simple_strtoul(buf
, &endp
, 16);
429 dev
->vsettings
.contrast
= (int) value
;
431 dev_microdia_camera_set_contrast(dev
);
432 // dev_microdia_set_camera_quality(dev);
439 * @brief show_whitebalance
441 * @param class Class device
443 * @retval buf Adress of buffer with the 'whitebalance' value
445 * @returns Size of buffer
447 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
448 static ssize_t
show_whitebalance(struct class_device
*class, char *buf
)
450 static ssize_t
show_whitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
453 struct video_device
*vdev
= to_video_device(class);
454 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
456 return sprintf(buf
, "%X\n", dev
->vsettings
.whiteness
);
461 * @brief store_whitebalance
463 * @param class Class device
465 * @param count Counter
467 * @returns Size of buffer
469 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
470 static ssize_t
store_whitebalance(struct class_device
*class, const char *buf
, size_t count
)
472 static ssize_t
store_whitebalance(struct device
*class, struct device_attribute
*attr
,
473 const char *buf
, size_t count
)
479 struct video_device
*vdev
= to_video_device(class);
480 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
482 value
= simple_strtoul(buf
, &endp
, 16);
484 dev
->vsettings
.whiteness
= (int) value
;
486 dev_microdia_camera_set_gamma(dev
);
487 // dev_microdia_set_camera_quality(dev);
496 * @param class Class device
498 * @retval buf Adress of buffer with the 'colour' value
500 * @returns Size of buffer
502 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
503 static ssize_t show_colour(struct class_device *class, char *buf)
505 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
508 struct video_device *vdev = to_video_device(class);
509 struct usb_microdia *dev = video_get_drvdata(vdev);
511 return sprintf(buf, "%X\n", dev->vsettings.colour);
516 * @brief store_colour
518 * @param class Class device
520 * @param count Counter
522 * @returns Size of buffer
524 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
525 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
527 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
528 const char *buf, size_t count)
534 struct video_device *vdev = to_video_device(class);
535 struct usb_microdia *dev = video_get_drvdata(vdev);
537 value = simple_strtoul(buf, &endp, 16);
539 dev->vsettings.colour = (int) value;
541 // dev_microdia_set_camera_quality(dev);
549 * @brief show_sharpness
551 * @param class Class device
553 * @retval buf Adress of buffer with the 'sharpness' value
555 * @returns Size of buffer
557 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
558 static ssize_t
show_sharpness(struct class_device
*class, char *buf
)
560 static ssize_t
show_sharpness(struct device
*class, struct device_attribute
*attr
, char *buf
)
563 struct video_device
*vdev
= to_video_device(class);
564 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
566 return sprintf(buf
, "%X\n", dev
->vsettings
.sharpness
);
570 * @brief store_sharpness
572 * @param class Class device
574 * @param count Counter
576 * @returns Size of buffer
578 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
579 static ssize_t
store_sharpness(struct class_device
*class, const char *buf
, size_t count
)
581 static ssize_t
store_sharpness(struct device
*class, struct device_attribute
*attr
,
582 const char *buf
, size_t count
)
588 struct video_device
*vdev
= to_video_device(class);
589 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
591 value
= simple_strtoul(buf
, &endp
, 16);
593 if (value
< 0 || value
> 0x3f)
596 dev
->vsettings
.sharpness
= (int) value
;
598 dev_microdia_camera_set_sharpness(dev
);
607 * @param class Class device
609 * @retval buf Adress of buffer with the 'hflip' value
611 * @returns Size of buffer
613 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
614 static ssize_t
show_hflip(struct class_device
*class, char *buf
)
616 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
619 struct video_device
*vdev
= to_video_device(class);
620 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
622 return sprintf(buf
, "%d\n", dev
->vsettings
.hflip
);
629 * @param class Class device
631 * @param count Counter
633 * @returns Size of buffer
635 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
636 static ssize_t
store_hflip(struct class_device
*class, const char *buf
, size_t count
)
638 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
639 const char *buf
, size_t count
)
642 struct video_device
*vdev
= to_video_device(class);
643 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
645 if (strncmp(buf
, "1", 1) == 0)
646 dev
->vsettings
.hflip
= 1;
647 else if (strncmp(buf
, "0", 1) == 0)
648 dev
->vsettings
.hflip
= 0;
652 dev_microdia_camera_set_hvflip(dev
);
661 * @param class Class device
663 * @retval buf Adress of buffer with the 'vflip' value
665 * @returns Size of buffer
667 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
668 static ssize_t
show_vflip(struct class_device
*class, char *buf
)
670 static ssize_t
show_vflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
673 struct video_device
*vdev
= to_video_device(class);
674 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
676 return sprintf(buf
, "%d\n", dev
->vsettings
.vflip
);
683 * @param class Class device
685 * @param count Counter
687 * @returns Size of buffer
689 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
690 static ssize_t
store_vflip(struct class_device
*class, const char *buf
, size_t count
)
692 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
695 struct video_device
*vdev
= to_video_device(class);
696 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
698 if (strncmp(buf
, "1", 1) == 0)
699 dev
->vsettings
.vflip
= 1;
700 else if (strncmp(buf
, "0", 1) == 0)
701 dev
->vsettings
.vflip
= 0;
705 dev_microdia_camera_set_hvflip(dev
);
712 * @brief show_autoexposure
714 * @param class Class device
716 * @retval buf Adress of buffer with the 'hflip' value
718 * @returns Size of buffer
720 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
721 static ssize_t
show_autoexposure(struct class_device
*class, char *buf
)
723 static ssize_t
show_autoexposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
726 struct video_device
*vdev
= to_video_device(class);
727 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
729 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_exposure
);
734 * @brief store_autoexposure
736 * @param class Class device
738 * @param count Counter
740 * @returns Size of buffer
742 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
743 static ssize_t
store_autoexposure(struct class_device
*class, const char *buf
, size_t count
)
745 static ssize_t
store_autoexposure(struct device
*class, struct device_attribute
*attr
,
746 const char *buf
, size_t count
)
749 struct video_device
*vdev
= to_video_device(class);
750 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
752 if (strncmp(buf
, "1", 1) == 0)
753 dev
->vsettings
.auto_exposure
= 1;
754 else if (strncmp(buf
, "0", 1) == 0)
755 dev
->vsettings
.auto_exposure
= 0;
759 dev_microdia_camera_set_auto_exposure(dev
);
766 * @brief show_autowhitebalance
768 * @param class Class device
770 * @retval buf Adress of buffer with the 'vflip' value
772 * @returns Size of buffer
774 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
775 static ssize_t
show_autowhitebalance(struct class_device
*class, char *buf
)
777 static ssize_t
show_autowhitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
780 struct video_device
*vdev
= to_video_device(class);
781 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
783 return sprintf(buf
, "%d\n", dev
->vsettings
.auto_whitebalance
);
788 * @brief store_autowhitebalance
790 * @param class Class device
792 * @param count Counter
794 * @returns Size of buffer
796 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
797 static ssize_t
store_autowhitebalance(struct class_device
*class, const char *buf
, size_t count
)
799 static ssize_t
store_autowhitebalance(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
802 struct video_device
*vdev
= to_video_device(class);
803 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
805 if (strncmp(buf
, "1", 1) == 0)
806 dev
->vsettings
.auto_whitebalance
= 1;
807 else if (strncmp(buf
, "0", 1) == 0)
808 dev
->vsettings
.auto_whitebalance
= 0;
812 dev_microdia_camera_set_auto_whitebalance(dev
);
817 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
818 static CLASS_DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
819 static CLASS_DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
820 static CLASS_DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
821 static CLASS_DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
822 static CLASS_DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
823 static CLASS_DEVICE_ATTR(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
824 static CLASS_DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Brightness exposure */
825 static CLASS_DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
826 static CLASS_DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
827 static CLASS_DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
828 //static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
829 static CLASS_DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
830 static CLASS_DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
831 static CLASS_DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
832 static CLASS_DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
834 static DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
835 static DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
836 static DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
837 static DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
838 static DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
839 static DEVICE_ATTR(rgb_gain
, S_IRUGO
| S_IWUGO
, show_rgb_gain
, store_rgb_gain
); /**< RGB Gain */
840 static DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
841 static DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
842 static DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
843 static DEVICE_ATTR(sharpness
, S_IRUGO
| S_IWUGO
, show_sharpness
, store_sharpness
); /**< Sharpness value */
844 //static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
845 static DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal flip value */
846 static DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical flip value */
847 static DEVICE_ATTR(auto_exposure
, S_IRUGO
| S_IWUGO
, show_autoexposure
, store_autoexposure
); /**< Automatic exposure control value */
848 static DEVICE_ATTR(auto_whitebalance
, S_IRUGO
| S_IWUGO
, show_autowhitebalance
, store_autowhitebalance
); /**< Automatic whitebalance control value */
853 * @brief Create the 'sys' entries.
855 * This function permits to create all the entries in the 'sys' filesystem.
857 * @param vdev Video device structure
859 * @returns 0 if all is OK
861 int microdia_create_sysfs_files(struct video_device
*vdev
)
865 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
866 ret
= video_device_create_file(vdev
, &class_device_attr_release
);
867 ret
= video_device_create_file(vdev
, &class_device_attr_videostatus
);
868 ret
= video_device_create_file(vdev
, &class_device_attr_informations
);
869 ret
= video_device_create_file(vdev
, &class_device_attr_fps
);
870 ret
= video_device_create_file(vdev
, &class_device_attr_brightness
);
871 ret
= video_device_create_file(vdev
, &class_device_attr_rgb_gain
);
872 ret
= video_device_create_file(vdev
, &class_device_attr_exposure
);
873 ret
= video_device_create_file(vdev
, &class_device_attr_contrast
);
874 ret
= video_device_create_file(vdev
, &class_device_attr_whitebalance
);
875 ret
= video_device_create_file(vdev
, &class_device_attr_sharpness
);
876 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
877 ret
= video_device_create_file(vdev
, &class_device_attr_hflip
);
878 ret
= video_device_create_file(vdev
, &class_device_attr_vflip
);
879 ret
= video_device_create_file(vdev
, &class_device_attr_auto_exposure
);
880 ret
= video_device_create_file(vdev
, &class_device_attr_auto_whitebalance
);
882 ret
= video_device_create_file(vdev
, &dev_attr_release
);
883 ret
= video_device_create_file(vdev
, &dev_attr_videostatus
);
884 ret
= video_device_create_file(vdev
, &dev_attr_informations
);
885 ret
= video_device_create_file(vdev
, &dev_attr_fps
);
886 ret
= video_device_create_file(vdev
, &dev_attr_brightness
);
887 ret
= video_device_create_file(vdev
, &dev_attr_rgb_gain
);
888 ret
= video_device_create_file(vdev
, &dev_attr_exposure
);
889 ret
= video_device_create_file(vdev
, &dev_attr_contrast
);
890 ret
= video_device_create_file(vdev
, &dev_attr_whitebalance
);
891 ret
= video_device_create_file(vdev
, &dev_attr_sharpness
);
892 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
893 ret
= video_device_create_file(vdev
, &dev_attr_hflip
);
894 ret
= video_device_create_file(vdev
, &dev_attr_vflip
);
895 ret
= video_device_create_file(vdev
, &dev_attr_auto_exposure
);
896 ret
= video_device_create_file(vdev
, &dev_attr_auto_whitebalance
);
903 * @brief Remove the 'sys' entries.
905 * This function permits to remove all the entries in the 'sys' filesystem.
907 * @param vdev Video device structure
909 * @returns 0 if all is OK
911 void microdia_remove_sysfs_files(struct video_device
*vdev
)
913 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
914 video_device_remove_file(vdev
, &class_device_attr_release
);
915 video_device_remove_file(vdev
, &class_device_attr_videostatus
);
916 video_device_remove_file(vdev
, &class_device_attr_informations
);
917 video_device_remove_file(vdev
, &class_device_attr_fps
);
918 video_device_remove_file(vdev
, &class_device_attr_brightness
);
919 video_device_remove_file(vdev
, &class_device_attr_exposure
);
920 video_device_remove_file(vdev
, &class_device_attr_rgb_gain
);
921 video_device_remove_file(vdev
, &class_device_attr_contrast
);
922 video_device_remove_file(vdev
, &class_device_attr_whitebalance
);
923 video_device_remove_file(vdev
, &class_device_attr_sharpness
);
924 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
925 video_device_remove_file(vdev
, &class_device_attr_hflip
);
926 video_device_remove_file(vdev
, &class_device_attr_vflip
);
927 video_device_remove_file(vdev
, &class_device_attr_auto_exposure
);
928 video_device_remove_file(vdev
, &class_device_attr_auto_whitebalance
);
930 video_device_remove_file(vdev
, &dev_attr_release
);
931 video_device_remove_file(vdev
, &dev_attr_videostatus
);
932 video_device_remove_file(vdev
, &dev_attr_informations
);
933 video_device_remove_file(vdev
, &dev_attr_fps
);
934 video_device_remove_file(vdev
, &dev_attr_brightness
);
935 video_device_remove_file(vdev
, &dev_attr_rgb_gain
);
936 video_device_remove_file(vdev
, &dev_attr_exposure
);
937 video_device_remove_file(vdev
, &dev_attr_contrast
);
938 video_device_remove_file(vdev
, &dev_attr_whitebalance
);
939 video_device_remove_file(vdev
, &dev_attr_sharpness
);
940 /*video_device_remove_file(vdev, &dev_attr_colour);*/
941 video_device_remove_file(vdev
, &dev_attr_hflip
);
942 video_device_remove_file(vdev
, &dev_attr_vflip
);
943 video_device_remove_file(vdev
, &dev_attr_auto_exposure
);
944 video_device_remove_file(vdev
, &dev_attr_auto_whitebalance
);