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>
45 #include <linux/usb.h>
46 #include <media/v4l2-common.h>
47 #include <media/v4l2-ioctl.h>
64 static ssize_t
show_release(
struct device *
class,
struct device_attribute *attr,
char *buf)
66 struct video_device *vdev = to_video_device(
class);
69 return sprintf(buf,
"%d\n", dev->
release);
82 static ssize_t
show_videostatus(
struct device *
class,
struct device_attribute *attr,
char *buf)
84 struct video_device *vdev = to_video_device(
class);
88 "Nbr ISOC errors : %d\n"
89 "Nbr dropped frames : %d\n"
90 "Nbr dumped frames : %d\n",
106 static ssize_t
show_informations(
struct device *
class,
struct device_attribute *attr,
char *buf)
109 char *pixelfmt = NULL;
111 struct video_device *vdev = to_video_device(
class);
114 char *palette_rgb24 =
"RGB24 - RGB-8-8-8 - 24 bits";
115 char *palette_rgb32 =
"RGB32 - RGB-8-8-8-8 - 32 bits";
116 char *palette_bgr24 =
"BGR24 - BGR-8-8-8 - 24 bits";
117 char *palette_bgr32 =
"BGR32 - BGR-8-8-8-8 - 32 bits";
118 char *palette_uyvy =
"UYVY - YUV 4:2:2 - 16 bits";
119 char *palette_yuyv =
"YUYV - YUV 4:2:2 - 16 bits";
123 case STK11XX_PALETTE_RGB24:
124 pixelfmt = palette_rgb24;
127 case STK11XX_PALETTE_RGB32:
128 pixelfmt = palette_rgb32;
131 case STK11XX_PALETTE_BGR24:
132 pixelfmt = palette_bgr24;
135 case STK11XX_PALETTE_BGR32:
136 pixelfmt = palette_bgr32;
139 case STK11XX_PALETTE_UYVY:
140 pixelfmt = palette_uyvy;
143 case STK11XX_PALETTE_YUYV:
144 pixelfmt = palette_yuyv;
148 switch (dev->resolution) {
151 case STK11XX_160x120:
152 case STK11XX_213x160:
153 case STK11XX_320x240:
154 case STK11XX_640x480:
159 case STK11XX_800x600:
160 case STK11XX_1024x768:
161 case STK11XX_1280x1024:
172 "Asked resolution : %dx%d\n"
173 "Driver resolution : %dx%d\n"
174 "Webcam resolution : %dx%d\n"
178 "Brightness : 0x%X\n"
182 dev->view.
x, dev->view.
y,
202 static ssize_t
show_fps(
struct device *
class,
struct device_attribute *attr,
char *buf)
204 struct video_device *vdev = to_video_device(
class);
220 static ssize_t
show_brightness(
struct device *
class,
struct device_attribute *attr,
char *buf)
222 struct video_device *vdev = to_video_device(
class);
239 const char *buf,
size_t count)
244 struct video_device *vdev = to_video_device(
class);
247 value = simple_strtoul(buf, &endp, 16);
265 static ssize_t
show_contrast(
struct device *
class,
struct device_attribute *attr,
char *buf)
267 struct video_device *vdev = to_video_device(
class);
283 static ssize_t
store_contrast(
struct device *
class,
struct device_attribute *attr,
284 const char *buf,
size_t count)
289 struct video_device *vdev = to_video_device(
class);
292 value = simple_strtoul(buf, &endp, 16);
311 static ssize_t
show_whitebalance(
struct device *
class,
struct device_attribute *attr,
char *buf)
313 struct video_device *vdev = to_video_device(
class);
330 const char *buf,
size_t count)
335 struct video_device *vdev = to_video_device(
class);
338 value = simple_strtoul(buf, &endp, 16);
357 static ssize_t
show_colour(
struct device *
class,
struct device_attribute *attr,
char *buf)
359 struct video_device *vdev = to_video_device(
class);
375 static ssize_t
store_colour(
struct device *
class,
struct device_attribute *attr,
376 const char *buf,
size_t count)
381 struct video_device *vdev = to_video_device(
class);
384 value = simple_strtoul(buf, &endp, 16);
403 static ssize_t
show_hflip(
struct device *
class,
struct device_attribute *attr,
char *buf)
405 struct video_device *vdev = to_video_device(
class);
421 static ssize_t
store_hflip(
struct device *
class,
struct device_attribute *attr,
422 const char *buf,
size_t count)
424 struct video_device *vdev = to_video_device(
class);
427 if (strncmp(buf,
"1", 1) == 0)
429 else if (strncmp(buf,
"0", 1) == 0)
447 static ssize_t
show_vflip(
struct device *
class,
struct device_attribute *attr,
char *buf)
449 struct video_device *vdev = to_video_device(
class);
465 static ssize_t
store_vflip(
struct device *
class,
struct device_attribute *attr,
const char *buf,
size_t count)
467 struct video_device *vdev = to_video_device(
class);
470 if (strncmp(buf,
"1", 1) == 0)
472 else if (strncmp(buf,
"0", 1) == 0)
506 ret = device_create_file(&
vdev->dev, &dev_attr_release);
507 ret = device_create_file(&
vdev->dev, &dev_attr_videostatus);
508 ret = device_create_file(&
vdev->dev, &dev_attr_informations);
509 ret = device_create_file(&
vdev->dev, &dev_attr_fps);
510 ret = device_create_file(&
vdev->dev, &dev_attr_brightness);
511 ret = device_create_file(&
vdev->dev, &dev_attr_contrast);
512 ret = device_create_file(&
vdev->dev, &dev_attr_whitebalance);
513 ret = device_create_file(&
vdev->dev, &dev_attr_colour);
514 ret = device_create_file(&
vdev->dev, &dev_attr_hflip);
515 ret = device_create_file(&
vdev->dev, &dev_attr_vflip);
532 device_remove_file(&
vdev->dev, &dev_attr_release);
533 device_remove_file(&
vdev->dev, &dev_attr_videostatus);
534 device_remove_file(&
vdev->dev, &dev_attr_informations);
535 device_remove_file(&
vdev->dev, &dev_attr_fps);
536 device_remove_file(&
vdev->dev, &dev_attr_brightness);
537 device_remove_file(&
vdev->dev, &dev_attr_contrast);
538 device_remove_file(&
vdev->dev, &dev_attr_whitebalance);
539 device_remove_file(&
vdev->dev, &dev_attr_colour);
540 device_remove_file(&
vdev->dev, &dev_attr_hflip);
541 device_remove_file(&
vdev->dev, &dev_attr_vflip);