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 * $Date: 2008-02-05 10:10:01 +0100 (mar, 05 fév 2008) $
30 * $Author: nicklas79 $
31 * $HeadURL: https://syntekdriver.svn.sourceforge.net/svnroot/syntekdriver/trunk/driver/microdia-sysfs.c $
34 #include <linux/module.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/version.h>
38 #include <linux/errno.h>
39 #include <linux/slab.h>
40 #include <linux/kref.h>
41 #include <linux/device.h>
43 #include <linux/usb.h>
44 #include <media/v4l2-common.h>
50 extern const struct microdia_coord microdia_image_sizes
[MICRODIA_NBR_SIZES
];
56 * @param class Class device
58 * @retval buf Adress of buffer with the 'release' value
60 * @returns Size of buffer
62 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
63 static ssize_t
show_release(struct class_device
*class, char *buf
)
65 static ssize_t
show_release(struct device
*class, struct device_attribute
*attr
, char *buf
)
68 struct video_device
*vdev
= to_video_device(class);
69 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
71 return sprintf(buf
, "%d\n", dev
->release
);
76 * @brief show_videostatus
78 * @param class Class device
80 * @retval buf Adress of buffer with the 'videostatus' value
82 * @returns Size of buffer
84 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
85 static ssize_t
show_videostatus(struct class_device
*class, char *buf
)
87 static ssize_t
show_videostatus(struct device
*class, struct device_attribute
*attr
, char *buf
)
90 struct video_device
*vdev
= to_video_device(class);
91 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
94 "Nbr ISOC errors : %d\n"
95 "Nbr dropped frames : %d\n"
96 "Nbr dumped frames : %d\n",
104 * @brief show_informations
106 * @param class Class device
108 * @retval buf Adress of buffer with the 'informations' value
110 * @returns Size of buffer
112 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
113 static ssize_t
show_informations(struct class_device
*class, char *buf
)
115 static ssize_t
show_informations(struct device
*class, struct device_attribute
*attr
, char *buf
)
119 char *pixelfmt
= NULL
;
121 struct video_device
*vdev
= to_video_device(class);
122 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
124 char *palette_rgb24
= "RGB24 - RGB-8-8-8 - 24 bits";
125 char *palette_rgb32
= "RGB32 - RGB-8-8-8-8 - 32 bits";
126 char *palette_bgr24
= "BGR24 - BGR-8-8-8 - 24 bits";
127 char *palette_bgr32
= "BGR32 - BGR-8-8-8-8 - 32 bits";
128 char *palette_uyvy
= "UYVY - YUV 4:2:2 - 16 bits";
129 char *palette_yuyv
= "YUYV - YUV 4:2:2 - 16 bits";
130 char *palette_i420
= "I420 - YUV 4:2:0 - 12 bits";
133 switch (dev
->vsettings
.palette
) {
134 case MICRODIA_PALETTE_RGB24
:
135 pixelfmt
= palette_rgb24
;
138 case MICRODIA_PALETTE_RGB32
:
139 pixelfmt
= palette_rgb32
;
142 case MICRODIA_PALETTE_BGR24
:
143 pixelfmt
= palette_bgr24
;
146 case MICRODIA_PALETTE_BGR32
:
147 pixelfmt
= palette_bgr32
;
150 case MICRODIA_PALETTE_UYVY
:
151 pixelfmt
= palette_uyvy
;
154 case MICRODIA_PALETTE_YUYV
:
155 pixelfmt
= palette_yuyv
;
158 case MICRODIA_PALETTE_I420
:
159 pixelfmt
= palette_i420
;
163 switch (dev
->resolution
) {
165 /*case MICRODIA_128x96:*/
166 case MICRODIA_160x120
:
167 /*case MICRODIA_213x160: */
168 case MICRODIA_320x240
:
169 case MICRODIA_640x480
:
170 width
= microdia_image_sizes
[MICRODIA_640x480
].x
;
171 height
= microdia_image_sizes
[MICRODIA_640x480
].y
;
174 case MICRODIA_800x600
:
175 case MICRODIA_1024x768
:
176 case MICRODIA_1280x1024
:
177 width
= microdia_image_sizes
[MICRODIA_1280x1024
].x
;
178 height
= microdia_image_sizes
[MICRODIA_1280x1024
].y
;
187 "Asked resolution : %dx%d\n"
188 "Driver resolution : %dx%d\n"
189 "Webcam resolution : %dx%d\n"
193 "Brightness : 0x%X\n"
197 dev
->view
.x
, dev
->view
.y
,
198 microdia_image_sizes
[dev
->resolution
].x
, microdia_image_sizes
[dev
->resolution
].y
,
201 0xFFFF & dev
->vsettings
.brightness
,
202 0xFFFF & dev
->vsettings
.contrast
,
203 0xFFFF & dev
->vsettings
.whiteness
,
204 0xFFFF & dev
->vsettings
.exposure
);
211 * @param class Class device
213 * @retval buf Adress of buffer with the 'fps' value
215 * @returns Size of buffer
217 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
218 static ssize_t
show_fps(struct class_device
*class, char *buf
)
220 static ssize_t
show_fps(struct device
*class, struct device_attribute
*attr
, char *buf
)
223 struct video_device
*vdev
= to_video_device(class);
224 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
226 return sprintf(buf
, "%d\n", dev
->vsettings
.fps
);
231 * @brief show_exposure
233 * @param class Class device
235 * @retval buf Adress of buffer with the 'exposure' value
237 * @returns Size of buffer
239 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
240 static ssize_t
show_exposure(struct class_device
*class, char *buf
)
242 static ssize_t
show_exposure(struct device
*class, struct device_attribute
*attr
, char *buf
)
245 struct video_device
*vdev
= to_video_device(class);
246 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
248 return sprintf(buf
, "%X\n", dev
->vsettings
.exposure
);
252 * @brief store_exposure
254 * @param class Class device
256 * @param count Counter
258 * @returns Size of buffer
260 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
261 static ssize_t
store_exposure(struct class_device
*class, const char *buf
, size_t count
)
263 static ssize_t
store_exposure(struct device
*class, struct device_attribute
*attr
,
264 const char *buf
, size_t count
)
270 struct video_device
*vdev
= to_video_device(class);
271 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
273 value
= simple_strtoul(buf
, &endp
, 16);
275 dev
->vsettings
.exposure
= (int) value
;
277 dev_microdia_camera_set_exposure(dev
);
283 * @brief show_brightness
285 * @param class Class device
287 * @retval buf Adress of buffer with the 'brightness' value
289 * @returns Size of buffer
291 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
292 static ssize_t
show_brightness(struct class_device
*class, char *buf
)
294 static ssize_t
show_brightness(struct device
*class, struct device_attribute
*attr
, char *buf
)
297 struct video_device
*vdev
= to_video_device(class);
298 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
300 return sprintf(buf
, "%X\n", dev
->vsettings
.brightness
);
304 * @brief store_brightness
306 * @param class Class device
308 * @param count Counter
310 * @returns Size of buffer
312 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
313 static ssize_t
store_brightness(struct class_device
*class, const char *buf
, size_t count
)
315 static ssize_t
store_brightness(struct device
*class, struct device_attribute
*attr
,
316 const char *buf
, size_t count
)
322 struct video_device
*vdev
= to_video_device(class);
323 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
325 value
= simple_strtoul(buf
, &endp
, 16);
327 dev
->vsettings
.brightness
= (int) value
;
329 dev_microdia_camera_set_brightness(dev
);
335 * @brief show_contrast
337 * @param class Class device
339 * @retval buf Adress of buffer with the 'contrast' value
341 * @returns Size of buffer
343 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
344 static ssize_t
show_contrast(struct class_device
*class, char *buf
)
346 static ssize_t
show_contrast(struct device
*class, struct device_attribute
*attr
, char *buf
)
349 struct video_device
*vdev
= to_video_device(class);
350 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
352 return sprintf(buf
, "%X\n", dev
->vsettings
.contrast
);
357 * @brief store_contrast
359 * @param class Class device
361 * @param count Counter
363 * @returns Size of buffer
365 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
366 static ssize_t
store_contrast(struct class_device
*class, const char *buf
, size_t count
)
368 static ssize_t
store_contrast(struct device
*class, struct device_attribute
*attr
,
369 const char *buf
, size_t count
)
375 struct video_device
*vdev
= to_video_device(class);
376 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
378 value
= simple_strtoul(buf
, &endp
, 16);
380 dev
->vsettings
.contrast
= (int) value
;
382 dev_microdia_camera_set_contrast(dev
);
383 // dev_microdia_set_camera_quality(dev);
390 * @brief show_whitebalance
392 * @param class Class device
394 * @retval buf Adress of buffer with the 'whitebalance' value
396 * @returns Size of buffer
398 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
399 static ssize_t
show_whitebalance(struct class_device
*class, char *buf
)
401 static ssize_t
show_whitebalance(struct device
*class, struct device_attribute
*attr
, char *buf
)
404 struct video_device
*vdev
= to_video_device(class);
405 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
407 return sprintf(buf
, "%X\n", dev
->vsettings
.whiteness
);
412 * @brief store_whitebalance
414 * @param class Class device
416 * @param count Counter
418 * @returns Size of buffer
420 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
421 static ssize_t
store_whitebalance(struct class_device
*class, const char *buf
, size_t count
)
423 static ssize_t
store_whitebalance(struct device
*class, struct device_attribute
*attr
,
424 const char *buf
, size_t count
)
430 struct video_device
*vdev
= to_video_device(class);
431 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
433 value
= simple_strtoul(buf
, &endp
, 16);
435 dev
->vsettings
.whiteness
= (int) value
;
437 dev_microdia_camera_set_gamma(dev
);
438 // dev_microdia_set_camera_quality(dev);
447 * @param class Class device
449 * @retval buf Adress of buffer with the 'colour' value
451 * @returns Size of buffer
453 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
454 static ssize_t show_colour(struct class_device *class, char *buf)
456 static ssize_t show_colour(struct device *class, struct device_attribute *attr, char *buf)
459 struct video_device *vdev = to_video_device(class);
460 struct usb_microdia *dev = video_get_drvdata(vdev);
462 return sprintf(buf, "%X\n", dev->vsettings.colour);
467 * @brief store_colour
469 * @param class Class device
471 * @param count Counter
473 * @returns Size of buffer
475 /*#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
476 static ssize_t store_colour(struct class_device *class, const char *buf, size_t count)
478 static ssize_t store_colour(struct device *class, struct device_attribute *attr,
479 const char *buf, size_t count)
485 struct video_device *vdev = to_video_device(class);
486 struct usb_microdia *dev = video_get_drvdata(vdev);
488 value = simple_strtoul(buf, &endp, 16);
490 dev->vsettings.colour = (int) value;
492 // dev_microdia_set_camera_quality(dev);
501 * @param class Class device
503 * @retval buf Adress of buffer with the 'hflip' value
505 * @returns Size of buffer
507 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
508 static ssize_t
show_hflip(struct class_device
*class, char *buf
)
510 static ssize_t
show_hflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
513 struct video_device
*vdev
= to_video_device(class);
514 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
516 return sprintf(buf
, "%d\n", dev
->vsettings
.hflip
);
523 * @param class Class device
525 * @param count Counter
527 * @returns Size of buffer
529 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
530 static ssize_t
store_hflip(struct class_device
*class, const char *buf
, size_t count
)
532 static ssize_t
store_hflip(struct device
*class, struct device_attribute
*attr
,
533 const char *buf
, size_t count
)
536 struct video_device
*vdev
= to_video_device(class);
537 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
539 if (strncmp(buf
, "1", 1) == 0)
540 dev
->vsettings
.hflip
= 1;
541 else if (strncmp(buf
, "0", 1) == 0)
542 dev
->vsettings
.hflip
= 0;
553 * @param class Class device
555 * @retval buf Adress of buffer with the 'vflip' value
557 * @returns Size of buffer
559 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
560 static ssize_t
show_vflip(struct class_device
*class, char *buf
)
562 static ssize_t
show_vflip(struct device
*class, struct device_attribute
*attr
, char *buf
)
565 struct video_device
*vdev
= to_video_device(class);
566 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
568 return sprintf(buf
, "%d\n", dev
->vsettings
.vflip
);
575 * @param class Class device
577 * @param count Counter
579 * @returns Size of buffer
581 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
582 static ssize_t
store_vflip(struct class_device
*class, const char *buf
, size_t count
)
584 static ssize_t
store_vflip(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
587 struct video_device
*vdev
= to_video_device(class);
588 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
590 if (strncmp(buf
, "1", 1) == 0)
591 dev
->vsettings
.vflip
= 1;
592 else if (strncmp(buf
, "0", 1) == 0)
593 dev
->vsettings
.vflip
= 0;
602 * @brief show_register adress
604 * @param class Class device
606 * @retval buf Adress of buffer with the 'register' value
608 * @returns Size of buffer
610 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
611 static ssize_t
show_register(struct class_device
*class, char *buf
)
613 static ssize_t
show_register(struct device
*class, struct device_attribute
*attr
, char *buf
)
618 struct video_device
*vdev
= to_video_device(class);
619 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
621 usb_microdia_control_read(dev
, dev
->vsettings
.reg
, &buf1
, 1);
623 dev
->vsettings
.val
= buf1
;
625 return sprintf(buf
, "0x%x = 0x%x\n",dev
->vsettings
.reg
, dev
->vsettings
.val
);
630 * @brief store_register
632 * @param class Class device
634 * @param count Counter
636 * @returns Size of buffer
638 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
639 static ssize_t
store_register(struct class_device
*class, const char *buf
, size_t count
)
641 static ssize_t
store_register(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
648 struct video_device
*vdev
= to_video_device(class);
649 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
651 value
= simple_strtoul(buf
, &endp
, 16);
653 dev
->vsettings
.val
= (int) value
;
654 buf1
= dev
->vsettings
.val
;
655 usb_microdia_control_write(dev
, dev
->vsettings
.reg
, &buf1
, 1);
663 * @param class Class device
667 * @returns Size of buffer
669 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
670 static ssize_t
show_adress(struct class_device
*class, char *buf
)
672 static ssize_t
show_adress(struct device
*class, struct device_attribute
*attr
, char *buf
)
675 struct video_device
*vdev
= to_video_device(class);
676 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
678 return sprintf(buf
, "0x%x\n", dev
->vsettings
.reg
);
683 * @brief store_adress
685 * @param class Class device
687 * @param count Counter
689 * @returns Size of buffer
691 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
692 static ssize_t
store_adress(struct class_device
*class, const char *buf
, size_t count
)
694 static ssize_t
store_adress(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
700 struct video_device
*vdev
= to_video_device(class);
701 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
703 value
= simple_strtoul(buf
, &endp
, 16);
705 dev
->vsettings
.reg
= (int) value
;
713 * @param class Class device
717 * @returns Size of buffer
719 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
720 static ssize_t
show_i2cadr(struct class_device
*class, char *buf
)
722 static ssize_t
show_i2cadr(struct device
*class, struct device_attribute
*attr
, char *buf
)
725 struct video_device
*vdev
= to_video_device(class);
726 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
728 return sprintf(buf
, "0x%x\n", dev
->vsettings
.i2creg
);
733 * @brief store_i2cadr
735 * @param class Class device
737 * @param count Counter
739 * @returns Size of buffer
741 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
742 static ssize_t
store_i2cadr(struct class_device
*class, const char *buf
, size_t count
)
744 static ssize_t
store_i2cadr(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
750 struct video_device
*vdev
= to_video_device(class);
751 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
753 value
= simple_strtoul(buf
, &endp
, 16);
755 dev
->vsettings
.i2creg
= (int) value
;
761 * @brief show_i2creg adress
763 * @param class Class device
767 * @returns Size of buffer
769 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
770 static ssize_t
show_i2creg(struct class_device
*class, char *buf
)
772 static ssize_t
show_i2creg(struct device
*class, struct device_attribute
*attr
, char *buf
)
776 // __u8 sensor_slave_id = 0x30; /* slave ID currently hard coded !! */
777 __u8 i2c_flags
= SN9C20X_I2C_2WIRE
;
779 struct video_device
*vdev
= to_video_device(class);
780 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
782 sn9c20x_read_i2c_data(dev
, dev
->vsettings
.i2cslave
/*sensor_slave_id*/,
783 dev
->vsettings
.reg
, dev
->vsettings
.i2creg
, i2c_flags
, buf1
);
785 dev
->vsettings
.i2cval
= buf1
[0];
786 return sprintf(buf
, "I2C-register 0x%x = 0x%x 0x%x (%d)\n",
787 dev
->vsettings
.i2creg
,buf1
[0],buf1
[1],dev
->vsettings
.reg
);
788 // return strlen(buf);
793 * @brief store_i2creg
795 * @param class Class device
797 * @param count Counter
799 * @returns Size of buffer
801 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
802 static ssize_t
store_i2creg(struct class_device
*class, const char *buf
, size_t count
)
804 static ssize_t
store_i2creg(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
811 // __u8 sensor_slave_id = 0x30; /* slave ID currently hard coded !! */
812 __u8 i2c_flags
= SN9C20X_I2C_2WIRE
;
814 struct video_device
*vdev
= to_video_device(class);
815 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
817 value
= simple_strtoul(buf
, &endp
, 16);
819 dev
->vsettings
.i2cval
= (int) value
;
820 buf1
[0] = ((dev
->vsettings
.i2cval
& 0xff00) >> 8);
821 buf1
[1] = (dev
->vsettings
.i2cval
& 0xFF);
826 sn9c20x_write_i2c_data(dev
,dev
->vsettings
.i2cslave
/*sensor_slave_id*/,
827 dev
->vsettings
.reg
, dev
->vsettings
.i2creg
, i2c_flags
, buf1
);
828 // sprintf(buf, "store_i2creg: set I2C-reg. 0x%x to 0x%x 0x%x (%d)\n",
829 // dev->vsettings.i2creg,buf1[0],buf1[1],dev->vsettings.reg);
835 * @brief store_i2c_slave_adr
837 * @param class Class device
839 * @param count Counter
841 * @returns Size of buffer
843 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
844 static ssize_t
store_i2c_slave_adr(struct class_device
*class, const char *buf
, size_t count
)
846 static ssize_t
store_i2c_slave_adr(struct device
*class, struct device_attribute
*attr
, const char *buf
, size_t count
)
852 struct video_device
*vdev
= to_video_device(class);
853 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
855 value
= simple_strtoul(buf
, &endp
, 16);
857 dev
->vsettings
.i2cslave
= (int) value
;
864 * @brief show_i2c_slave_adr
866 * @param class Class device
870 * @returns Size of buffer
872 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
873 static ssize_t
show_i2c_slave_adr(struct class_device
*class, char *buf
)
875 static ssize_t
show_i2c_slave_adr(struct device
*class, struct device_attribute
*attr
, char *buf
)
878 struct video_device
*vdev
= to_video_device(class);
879 struct usb_microdia
*dev
= video_get_drvdata(vdev
);
881 return sprintf(buf
, "0x%x\n", dev
->vsettings
.i2cslave
);
887 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
888 static CLASS_DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
889 static CLASS_DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
890 static CLASS_DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
891 static CLASS_DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
892 static CLASS_DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
893 static CLASS_DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Brightness exposure */
894 static CLASS_DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
895 static CLASS_DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
896 //static CLASS_DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
897 static CLASS_DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal filp value */
898 static CLASS_DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical filp value */
899 static CLASS_DEVICE_ATTR(adr
, S_IRUGO
| S_IWUGO
, show_adress
, store_adress
); /**< Register adress */
900 static CLASS_DEVICE_ATTR(reg
, S_IRUGO
| S_IWUGO
, show_register
, store_register
); /**< Register value */
901 static CLASS_DEVICE_ATTR(i2cadr
, S_IRUGO
| S_IWUGO
, show_i2cadr
, store_i2cadr
); /**< I2C Register adress */
902 static CLASS_DEVICE_ATTR(i2creg
, S_IRUGO
| S_IWUGO
, show_i2creg
, store_i2creg
); /**< I2C Register value */
903 static CLASS_DEVICE_ATTR(i2cslave
, S_IRUGO
| S_IWUGO
, show_i2c_slave_adr
, store_i2c_slave_adr
); /**< I2C Slave adress */
905 static DEVICE_ATTR(release
, S_IRUGO
, show_release
, NULL
); /**< Release value */
906 static DEVICE_ATTR(videostatus
, S_IRUGO
, show_videostatus
, NULL
); /**< Video status */
907 static DEVICE_ATTR(informations
, S_IRUGO
, show_informations
, NULL
); /**< Informations */
908 static DEVICE_ATTR(fps
, S_IRUGO
, show_fps
, NULL
); /**< FPS value */
909 static DEVICE_ATTR(brightness
, S_IRUGO
| S_IWUGO
, show_brightness
, store_brightness
); /**< Brightness value */
910 static DEVICE_ATTR(exposure
, S_IRUGO
| S_IWUGO
, show_exposure
, store_exposure
); /**< Exposure value */
911 static DEVICE_ATTR(contrast
, S_IRUGO
| S_IWUGO
, show_contrast
, store_contrast
); /**< Contrast value */
912 static DEVICE_ATTR(whitebalance
, S_IRUGO
| S_IWUGO
, show_whitebalance
, store_whitebalance
); /**< Whitebalance value */
913 //static DEVICE_ATTR(colour, S_IRUGO | S_IWUGO, show_colour, store_colour); /**< Hue value */
914 static DEVICE_ATTR(hflip
, S_IRUGO
| S_IWUGO
, show_hflip
, store_hflip
); /**< Horizontal filp value */
915 static DEVICE_ATTR(vflip
, S_IRUGO
| S_IWUGO
, show_vflip
, store_vflip
); /**< Vertical filp value */
916 static DEVICE_ATTR(adr
, S_IRUGO
| S_IWUGO
, show_adress
, store_adress
); /**< Register adress */
917 static DEVICE_ATTR(reg
, S_IRUGO
| S_IWUGO
, show_register
, store_register
); /**< Register value */
918 static DEVICE_ATTR(i2cadr
, S_IRUGO
| S_IWUGO
, show_i2cadr
, store_i2cadr
); /**< I2C Register adress */
919 static DEVICE_ATTR(i2creg
, S_IRUGO
| S_IWUGO
, show_i2creg
, store_i2creg
); /**< I2C Register value */
920 static DEVICE_ATTR(i2cslave
, S_IRUGO
| S_IWUGO
, show_i2c_slave_adr
, store_i2c_slave_adr
); /**< I2C Slave adress */
925 * @brief Create the 'sys' entries.
927 * This function permits to create all the entries in the 'sys' filesystem.
929 * @param vdev Video device structure
931 * @returns 0 if all is OK
933 int microdia_create_sysfs_files(struct video_device
*vdev
)
937 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
938 ret
= video_device_create_file(vdev
, &class_device_attr_release
);
939 ret
= video_device_create_file(vdev
, &class_device_attr_videostatus
);
940 ret
= video_device_create_file(vdev
, &class_device_attr_informations
);
941 ret
= video_device_create_file(vdev
, &class_device_attr_fps
);
942 ret
= video_device_create_file(vdev
, &class_device_attr_brightness
);
943 ret
= video_device_create_file(vdev
, &class_device_attr_exposure
);
944 ret
= video_device_create_file(vdev
, &class_device_attr_contrast
);
945 ret
= video_device_create_file(vdev
, &class_device_attr_whitebalance
);
946 /*ret = video_device_create_file(vdev, &class_device_attr_colour);*/
947 ret
= video_device_create_file(vdev
, &class_device_attr_hflip
);
948 ret
= video_device_create_file(vdev
, &class_device_attr_vflip
);
949 ret
= video_device_create_file(vdev
, &class_device_attr_reg
);
950 ret
= video_device_create_file(vdev
, &class_device_attr_adr
);
951 ret
= video_device_create_file(vdev
, &class_device_attr_i2creg
);
952 ret
= video_device_create_file(vdev
, &class_device_attr_i2cadr
);
953 ret
= video_device_create_file(vdev
, &class_device_attr_i2cslave
);
955 ret
= video_device_create_file(vdev
, &dev_attr_release
);
956 ret
= video_device_create_file(vdev
, &dev_attr_videostatus
);
957 ret
= video_device_create_file(vdev
, &dev_attr_informations
);
958 ret
= video_device_create_file(vdev
, &dev_attr_fps
);
959 ret
= video_device_create_file(vdev
, &dev_attr_brightness
);
960 ret
= video_device_create_file(vdev
, &dev_attr_exposure
);
961 ret
= video_device_create_file(vdev
, &dev_attr_contrast
);
962 ret
= video_device_create_file(vdev
, &dev_attr_whitebalance
);
963 /*ret = video_device_create_file(vdev, &dev_attr_colour);*/
964 ret
= video_device_create_file(vdev
, &dev_attr_hflip
);
965 ret
= video_device_create_file(vdev
, &dev_attr_vflip
);
966 ret
= video_device_create_file(vdev
, &dev_attr_reg
);
967 ret
= video_device_create_file(vdev
, &dev_attr_adr
);
968 ret
= video_device_create_file(vdev
, &dev_attr_i2creg
);
969 ret
= video_device_create_file(vdev
, &dev_attr_i2cadr
);
970 ret
= video_device_create_file(vdev
, &dev_attr_i2cslave
);
977 * @brief Remove the 'sys' entries.
979 * This function permits to remove all the entries in the 'sys' filesystem.
981 * @param vdev Video device structure
983 * @returns 0 if all is OK
985 void microdia_remove_sysfs_files(struct video_device
*vdev
)
987 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
988 video_device_remove_file(vdev
, &class_device_attr_release
);
989 video_device_remove_file(vdev
, &class_device_attr_videostatus
);
990 video_device_remove_file(vdev
, &class_device_attr_informations
);
991 video_device_remove_file(vdev
, &class_device_attr_fps
);
992 video_device_remove_file(vdev
, &class_device_attr_brightness
);
993 video_device_remove_file(vdev
, &class_device_attr_exposure
);
994 video_device_remove_file(vdev
, &class_device_attr_contrast
);
995 video_device_remove_file(vdev
, &class_device_attr_whitebalance
);
996 /*video_device_remove_file(vdev, &class_device_attr_colour);*/
997 video_device_remove_file(vdev
, &class_device_attr_hflip
);
998 video_device_remove_file(vdev
, &class_device_attr_vflip
);
999 video_device_remove_file(vdev
, &class_device_attr_reg
);
1000 video_device_remove_file(vdev
, &class_device_attr_adr
);
1001 video_device_remove_file(vdev
, &class_device_attr_i2creg
);
1002 video_device_remove_file(vdev
, &class_device_attr_i2cadr
);
1003 video_device_remove_file(vdev
, &class_device_attr_i2cslave
);
1005 video_device_remove_file(vdev
, &dev_attr_release
);
1006 video_device_remove_file(vdev
, &dev_attr_videostatus
);
1007 video_device_remove_file(vdev
, &dev_attr_informations
);
1008 video_device_remove_file(vdev
, &dev_attr_fps
);
1009 video_device_remove_file(vdev
, &dev_attr_brightness
);
1010 video_device_remove_file(vdev
, &dev_attr_exposure
);
1011 video_device_remove_file(vdev
, &dev_attr_contrast
);
1012 video_device_remove_file(vdev
, &dev_attr_whitebalance
);
1013 /*video_device_remove_file(vdev, &dev_attr_colour);*/
1014 video_device_remove_file(vdev
, &dev_attr_hflip
);
1015 video_device_remove_file(vdev
, &dev_attr_vflip
);
1016 video_device_remove_file(vdev
, &dev_attr_reg
);
1017 video_device_remove_file(vdev
, &dev_attr_adr
);
1018 video_device_remove_file(vdev
, &dev_attr_i2creg
);
1019 video_device_remove_file(vdev
, &dev_attr_i2cadr
);
1020 video_device_remove_file(vdev
, &dev_attr_i2cslave
);