Release 1.2.1
[syntekdriver.git] / stk11xx-v4l.c
bloba0e09706ac04dfa5adc32240dbb567e92637cb2b
1 /**
2 * @file stk11xx-v4l.c
3 * @author Nicolas VIVIEN
4 * @date 2006-10-23
5 * @version v1.2.0
7 * @brief Driver for Syntek USB video camera
9 * @note Copyright (C) Nicolas VIVIEN
11 * @par Licences
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
16 * any later version.
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
27 * @par SubVersion
28 * $Date$
29 * $Revision$
30 * $Author$
31 * $HeadURL$
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/vmalloc.h>
43 #include <linux/usb.h>
44 #include <media/v4l2-common.h>
46 #include "stk11xx.h"
49 static struct file_operations v4l_stk11xx_fops;
52 /**
53 * @var stk11xx_image_sizes
54 * List of all resolutions supported by the driver
56 const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES] = {
57 { 80, 60 },
58 { 128, 96 },
59 { 160, 120 },
60 { 213, 160 },
61 { 320, 240 },
62 { 640, 480 },
63 { 800, 600 },
64 { 1024, 768 },
65 { 1280, 1024 }
69 /**
70 * @var stk11xx_controls
71 * List of all V4Lv2 controls supported by the driver
73 static struct v4l2_queryctrl stk11xx_controls[] = {
75 .id = V4L2_CID_BRIGHTNESS,
76 .type = V4L2_CTRL_TYPE_INTEGER,
77 .name = "Brightness",
78 .minimum = 0,
79 .maximum = 0xff00,
80 .step = 1,
81 .default_value = 0x7f00,
84 .id = V4L2_CID_WHITENESS,
85 .type = V4L2_CTRL_TYPE_INTEGER,
86 .name = "Whiteness",
87 .minimum = 0,
88 .maximum = 0xff00,
89 .step = 1,
90 .default_value = 0x7f00,
93 .id = V4L2_CID_SATURATION,
94 .type = V4L2_CTRL_TYPE_INTEGER,
95 .name = "Saturation",
96 .minimum = 0,
97 .maximum = 0xff00,
98 .step = 1,
99 .default_value = 0x7f00,
102 .id = V4L2_CID_CONTRAST,
103 .type = V4L2_CTRL_TYPE_INTEGER,
104 .name = "Contrast",
105 .minimum = 0,
106 .maximum = 0xff00,
107 .step = 1,
108 .default_value = 0x7f00,
113 /**
114 * @param dev
115 * @param width Width of wished resolution
116 * @param height Height of wished resolution
118 * @returns 0 if all is OK
120 * @brief Select a video mode
122 * This function permits to check and select a video mode.
124 int v4l_stk11xx_select_video_mode(struct usb_stk11xx *dev, int width, int height)
126 int i;
127 int find;
130 // Check width and height
131 // Notice : this test is usefull for the Kopete application !
133 // Driver can't build an image smaller than the minimal resolution !
134 if ((width < stk11xx_image_sizes[0].x)
135 || (height < stk11xx_image_sizes[0].y)) {
136 width = stk11xx_image_sizes[0].x;
137 height = stk11xx_image_sizes[0].y;
140 // Driver can't build an image bigger than the maximal resolution !
141 switch (dev->webcam_type) {
142 case STK11XX_SXGA:
143 if ((width > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x)
144 || (height > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y)) {
145 width = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x;
146 height = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y;
148 break;
150 case STK11XX_VGA:
151 if ((width > stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].x)
152 || (height > stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].y)) {
153 width = stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].x;
154 height = stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].y;
156 break;
158 default:
159 return -1;
163 // Seek the best resolution
164 switch (dev->webcam_type) {
165 case STK11XX_SXGA:
166 for (i=0, find=0; i<STK11XX_NBR_SIZES; i++) {
167 if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
168 find = i;
170 break;
172 case STK11XX_VGA:
173 for (i=0, find=0; i<STK11XX_NBR_SIZES-3; i++) {
174 if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
175 find = i;
177 break;
179 default:
180 return -1;
183 // Save the new resolution
184 dev->resolution = find;
186 STK_DEBUG("Set mode %d [%dx%d]\n", dev->resolution,
187 stk11xx_image_sizes[dev->resolution].x, stk11xx_image_sizes[dev->resolution].y);
189 // Save the new size
190 dev->view.x = width;
191 dev->view.y = height;
194 // Calculate the frame size
195 switch (dev->resolution) {
196 case STK11XX_80x60:
197 case STK11XX_128x96:
198 case STK11XX_160x120:
199 case STK11XX_213x160:
200 case STK11XX_320x240:
201 case STK11XX_640x480:
202 dev->image.x = stk11xx_image_sizes[STK11XX_640x480].x;
203 dev->image.y = stk11xx_image_sizes[STK11XX_640x480].y;
204 dev->frame_size = dev->image.x * dev->image.y;
205 break;
207 case STK11XX_800x600:
208 case STK11XX_1024x768:
209 case STK11XX_1280x1024:
210 dev->image.x = stk11xx_image_sizes[STK11XX_1280x1024].x;
211 dev->image.y = stk11xx_image_sizes[STK11XX_1280x1024].y;
212 dev->frame_size = dev->image.x * dev->image.y;
213 break;
217 // Calculate the image size
218 switch (dev->vsettings.palette) {
219 case STK11XX_PALETTE_RGB24:
220 case STK11XX_PALETTE_BGR24:
221 dev->image_size = 3 * dev->frame_size;
222 break;
224 case STK11XX_PALETTE_RGB32:
225 case STK11XX_PALETTE_BGR32:
226 dev->image_size = 4 * dev->frame_size;
227 break;
229 case STK11XX_PALETTE_UYVY:
230 dev->image_size = 2 * dev->frame_size;
231 break;
233 case STK11XX_PALETTE_YUYV:
234 dev->image_size = 2 * dev->frame_size;
235 break;
238 return 0;
242 /**
243 * @param inode Pointer on an inode
244 * @param fp File pointer
246 * @returns 0 if all is OK
248 * @brief Open the video device
250 * This function permits to open a video device (/dev/videoX)
252 static int v4l_stk11xx_open(struct inode *inode, struct file *fp)
254 int err;
256 struct usb_stk11xx *dev;
257 struct video_device *vdev;
259 vdev = video_devdata(fp);
260 dev = video_get_drvdata(video_devdata(fp));
262 if (dev == NULL) {
263 STK_ERROR("Device not initialized !!!\n");
264 BUG();
267 if (dev->vopen) {
268 STK_DEBUG("Device is busy, someone is using the device\n");
269 return -EBUSY;
272 // Allocate memory
273 err = stk11xx_allocate_buffers(dev);
275 if (err < 0) {
276 STK_ERROR("Failed to allocate buffer memory !\n");
277 return err;
280 // Reset buffers and parameters
281 stk11xx_reset_buffers(dev);
283 // Settings
284 dev->error_status = 0;
285 dev->visoc_errors = 0;
286 dev->vframes_error = 0;
287 dev->vframes_dumped = 0;
288 dev->vsettings.hue = 0xffff;
289 dev->vsettings.depth = 24;
290 dev->vsettings.palette = STK11XX_PALETTE_BGR24;
292 // Select the resolution by default
293 v4l_stk11xx_select_video_mode(dev, 640, 480);
295 // Initialize the device
296 dev_stk11xx_init_camera(dev);
297 dev_stk11xx_camera_on(dev);
298 dev_stk11xx_reconf_camera(dev);
300 // Init Isoc and URB
301 err = usb_stk11xx_isoc_init(dev);
303 if (err) {
304 STK_ERROR("Failed to init ISOC stuff !\n");
305 usb_stk11xx_isoc_cleanup(dev);
306 stk11xx_free_buffers(dev);
307 return err;
310 // Start the video stream
311 dev_stk11xx_start_stream(dev);
313 // Video settings
314 dev_stk11xx_camera_settings(dev);
316 dev->vopen++;
317 fp->private_data = vdev;
319 return 0;
323 /**
324 * @param inode Pointer on inode
325 * @param fp File pointer
327 * @returns 0 if all is OK
329 * @brief Release an opened file.
331 * This function permits to release an opened file with the 'open' method.
333 static int v4l_stk11xx_release(struct inode *inode, struct file *fp)
335 struct usb_stk11xx *dev;
336 struct video_device *vdev;
338 vdev = video_devdata(fp);
339 dev = video_get_drvdata(video_devdata(fp));
341 if (dev->vopen == 0)
342 STK_ERROR("v4l_release called on closed device\n");
344 // Stop the video stream
345 dev_stk11xx_stop_stream(dev);
347 // ISOC and URB cleanup
348 usb_stk11xx_isoc_cleanup(dev);
350 // Free memory
351 stk11xx_free_buffers(dev);
353 // Switch off the camera
354 dev_stk11xx_camera_off(dev);
356 dev_stk11xx_camera_asleep(dev);
358 dev->vopen--;
360 return 0;
364 /**
365 * @param fp File pointer
367 * @retval buf Buffer in user space
368 * @retval count
369 * @retval f_pos
371 * @returns Count value
373 * @brief Read the video device
375 * This function is called by the application is reading the video device.
377 static ssize_t v4l_stk11xx_read(struct file *fp, char __user *buf,
378 size_t count, loff_t *f_pos)
380 int noblock = fp->f_flags & O_NONBLOCK;
382 struct usb_stk11xx *dev;
383 struct video_device *vdev;
385 int bytes_to_read;
386 void *image_buffer_addr;
388 DECLARE_WAITQUEUE(wait, current);
390 vdev = video_devdata(fp);
391 dev = video_get_drvdata(video_devdata(fp));
393 STK_STREAM("Read vdev=0x%p, buf=0x%p, count=%zd\n", vdev, buf, count);
395 if (dev == NULL)
396 return -EFAULT;
398 if (vdev == NULL)
399 return -EFAULT;
401 if (dev->image_read_pos == 0) {
402 add_wait_queue(&dev->wait_frame, &wait);
404 while (dev->full_frames == NULL) {
405 if (dev->error_status) {
406 remove_wait_queue(&dev->wait_frame, &wait);
407 set_current_state(TASK_RUNNING);
408 return -dev->error_status ;
411 if (noblock) {
412 remove_wait_queue(&dev->wait_frame, &wait);
413 set_current_state(TASK_RUNNING);
414 return -EWOULDBLOCK;
417 if (signal_pending(current)) {
418 remove_wait_queue(&dev->wait_frame, &wait);
419 set_current_state(TASK_RUNNING);
420 return -ERESTARTSYS;
423 schedule();
424 set_current_state(TASK_INTERRUPTIBLE);
427 remove_wait_queue(&dev->wait_frame, &wait);
428 set_current_state(TASK_RUNNING);
430 if (stk11xx_handle_frame(dev))
431 return -EFAULT;
434 bytes_to_read = dev->image_size;
436 if (count + dev->image_read_pos > bytes_to_read)
437 count = bytes_to_read - dev->image_read_pos;
439 image_buffer_addr = dev->image_data;
440 image_buffer_addr += dev->images[dev->fill_image].offset;
441 image_buffer_addr += dev->image_read_pos;
443 if (copy_to_user(buf, image_buffer_addr, count))
444 return -EFAULT;
446 dev->image_read_pos += count;
448 if (dev->image_read_pos >= bytes_to_read) {
449 dev->image_read_pos = 0;
450 stk11xx_next_image(dev);
453 return count;
457 /**
458 * @param fp File pointer
459 * @param wait
461 * @returns 0 if all is OK
463 * @brief Polling function
465 static unsigned int v4l_stk11xx_poll(struct file *fp, poll_table *wait)
467 struct usb_stk11xx *dev;
468 struct video_device *vdev;
470 vdev = video_devdata(fp);
471 dev = video_get_drvdata(video_devdata(fp));
473 STK_STREAM("Poll\n");
475 if (vdev == NULL)
476 return -EFAULT;
478 if (dev == NULL)
479 return -EFAULT;
481 poll_wait(fp, &dev->wait_frame, wait);
483 if (dev->error_status)
484 return POLLERR;
486 if (dev->full_frames != NULL)
487 return (POLLIN | POLLRDNORM);
489 return 0;
493 /**
494 * @param fp File pointer
495 * @param vma VMA structure
497 * @returns 0 if all is OK
499 * @brief Memory map
501 * This function permits to map a memory space.
503 static int v4l_stk11xx_mmap(struct file *fp, struct vm_area_struct *vma)
505 unsigned int i;
507 unsigned long size;
508 unsigned long start;
509 unsigned long pos;
510 unsigned long page;
512 struct usb_stk11xx *dev;
514 struct video_device *vdev;
516 vdev = video_devdata(fp);
517 dev = video_get_drvdata(video_devdata(fp));
519 STK_STREAM("mmap\n");
521 start = vma->vm_start;
522 size = vma->vm_end - vma->vm_start;
524 // Find the buffer for this mapping...
525 for (i=0; i<dev->nbuffers; i++) {
526 pos = dev->images[i].offset;
528 if ((pos >> PAGE_SHIFT) == vma->vm_pgoff)
529 break;
532 // If no buffer found !
533 if (i == STK11XX_MAX_IMAGES) {
534 STK_ERROR("mmap no buffer found !\n");
535 return -EINVAL;
538 if (i == 0) {
539 unsigned long total_size;
541 total_size = dev->nbuffers * dev->len_per_image;
543 if (size != dev->len_per_image && size != total_size)
544 return -EINVAL;
546 else if (size > dev->len_per_image)
547 return -EINVAL;
549 vma->vm_flags |= VM_IO;
551 pos = (unsigned long) dev->image_data;
553 while (size > 0) {
554 page = vmalloc_to_pfn((void *) pos);
556 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
557 return -EAGAIN;
559 start += PAGE_SIZE;
560 pos += PAGE_SIZE;
562 if (size > PAGE_SIZE)
563 size -= PAGE_SIZE;
564 else
565 size = 0;
568 return 0;
572 /**
573 * @param inode Inode pointer
574 * @param fp File pointer
575 * @param cmd Command
576 * @param arg Arguments of the command
578 * @returns 0 if all is OK
580 * @brief Manage IOCTL
582 * This function permits to manage all the IOCTL from the application.
584 static int v4l_stk11xx_do_ioctl(struct inode *inode, struct file *fp,
585 unsigned int cmd, void __user *arg)
587 struct usb_stk11xx *dev;
588 struct video_device *vdev;
590 DECLARE_WAITQUEUE(wait, current);
592 vdev = video_devdata(fp);
593 dev = video_get_drvdata(video_devdata(fp));
595 #if (CONFIG_STK11XX_DEBUG == 1)
596 v4l_printk_ioctl(cmd);
597 #endif
599 switch (cmd) {
600 // Video 4 Linux v1
602 case VIDIOCGCAP:
604 struct video_capability *cap = arg;
606 STK_DEBUG("VIDIOCGCAP\n");
608 memset(cap, 0, sizeof(*cap));
609 strlcpy(cap->name, "stk11xx", sizeof(cap->name));
610 cap->type = VID_TYPE_CAPTURE;
611 cap->channels = 1;
612 cap->audios = 0;
614 switch (dev->webcam_type) {
615 case STK11XX_SXGA:
616 cap->minwidth = stk11xx_image_sizes[STK11XX_80x60].x;
617 cap->minheight = stk11xx_image_sizes[STK11XX_80x60].y;
618 cap->maxwidth = stk11xx_image_sizes[STK11XX_1280x1024].x;
619 cap->maxheight = stk11xx_image_sizes[STK11XX_1280x1024].y;
620 break;
622 case STK11XX_VGA:
623 cap->minwidth = stk11xx_image_sizes[STK11XX_80x60].x;
624 cap->minheight = stk11xx_image_sizes[STK11XX_80x60].y;
625 cap->maxwidth = stk11xx_image_sizes[STK11XX_640x480].x;
626 cap->maxheight = stk11xx_image_sizes[STK11XX_640x480].y;
627 break;
630 break;
632 case VIDIOCGCHAN:
634 struct video_channel *v = arg;
636 STK_DEBUG("VIDIOCGCHAN\n");
638 if (v->channel != 0)
639 return -EINVAL;
641 v->flags = 0;
642 v->tuners = 0;
643 v->type = VIDEO_TYPE_CAMERA;
644 strcpy(v->name, "Webcam");
646 break;
648 case VIDIOCSCHAN:
650 struct video_channel *v = arg;
652 STK_DEBUG("VIDIOCSCHAN\n");
654 if (v->channel != 0)
655 return -EINVAL;
657 break;
659 case VIDIOCGPICT:
661 struct video_picture *p = arg;
663 STK_DEBUG("VIDIOCGPICT\n");
665 p->brightness = dev->vsettings.brightness;
666 p->contrast = dev->vsettings.contrast;
667 p->whiteness = dev->vsettings.whiteness;
668 p->colour = dev->vsettings.colour;
669 p->depth = dev->vsettings.depth;
670 p->palette = dev->vsettings.palette;
671 p->hue = dev->vsettings.hue;
673 switch (dev->vsettings.palette) {
674 case STK11XX_PALETTE_BGR24:
675 p->palette = VIDEO_PALETTE_RGB24;
676 break;
678 case STK11XX_PALETTE_BGR32:
679 p->palette = VIDEO_PALETTE_RGB32;
680 break;
682 case STK11XX_PALETTE_UYVY:
683 p->palette = VIDEO_PALETTE_UYVY;
684 break;
686 case STK11XX_PALETTE_YUYV:
687 p->palette = VIDEO_PALETTE_YUYV;
688 break;
691 break;
693 case VIDIOCSPICT:
695 struct video_picture *p = arg;
697 STK_DEBUG("VIDIOCSPICT\n");
699 dev->vsettings.brightness = p->brightness;
700 dev->vsettings.contrast = p->contrast;
701 dev->vsettings.whiteness = p->whiteness;
702 dev->vsettings.colour = p->colour;
703 dev->vsettings.hue = p->hue;
705 if (p->palette && p->palette != dev->vsettings.palette) {
706 switch (p->palette) {
707 case VIDEO_PALETTE_RGB24:
708 dev->vsettings.depth = 24;
709 dev->vsettings.palette = STK11XX_PALETTE_BGR24;
710 break;
712 case VIDEO_PALETTE_RGB32:
713 dev->vsettings.depth = 32;
714 dev->vsettings.palette = STK11XX_PALETTE_BGR32;
715 break;
717 case VIDEO_PALETTE_UYVY:
718 dev->vsettings.depth = 16;
719 dev->vsettings.palette = STK11XX_PALETTE_UYVY;
720 break;
722 case VIDEO_PALETTE_YUYV:
723 dev->vsettings.depth = 16;
724 dev->vsettings.palette = STK11XX_PALETTE_YUYV;
725 break;
727 default:
728 return -EINVAL;
732 dev_stk11xx_camera_settings(dev);
734 STK_DEBUG("VIDIOCSPICT done\n");
736 break;
738 case VIDIOCGWIN:
740 struct video_window *vw = arg;
742 STK_DEBUG("VIDIOCGWIN\n");
744 vw->x = 0;
745 vw->y = 0;
746 vw->width = dev->view.x;
747 vw->height = dev->view.y;
748 vw->chromakey = 0;
750 break;
752 case VIDIOCSWIN:
754 struct video_window *vw = arg;
756 STK_DEBUG("VIDIOCSWIN\n");
758 STK_DEBUG("Set x=%d, y=%d\n", vw->x, vw->y);
759 STK_DEBUG("Set width=%d, height=%d\n", vw->width, vw->height);
760 STK_DEBUG("Flags = %X\n", vw->flags);
762 // Stop the video stream
763 dev_stk11xx_stop_stream(dev);
765 // ISOC and URB cleanup
766 usb_stk11xx_isoc_cleanup(dev);
768 // Switch off the camera
769 dev_stk11xx_camera_off(dev);
771 dev_stk11xx_camera_asleep(dev);
773 // Select the new video mode
774 if (v4l_stk11xx_select_video_mode(dev, vw->width, vw->height)) {
775 STK_ERROR("Select video mode failed !\n");
776 return -EAGAIN;
779 // Clear the buffers
780 stk11xx_clear_buffers(dev);
782 // Initialize the device
783 dev_stk11xx_init_camera(dev);
784 dev_stk11xx_camera_on(dev);
785 dev_stk11xx_reconf_camera(dev);
787 // ISOC and URB init
788 usb_stk11xx_isoc_init(dev);
790 // Re-start the stream
791 dev_stk11xx_start_stream(dev);
793 // Video settings
794 dev_stk11xx_camera_settings(dev);
796 break;
798 case VIDIOCGFBUF:
800 struct video_buffer *vb = arg;
802 STK_DEBUG("VIDIOCGFBUF\n");
804 memset(vb, 0, sizeof(*vb));
806 break;
808 case VIDIOCGMBUF:
810 int i;
811 struct video_mbuf *vm = arg;
813 STK_DEBUG("VIDIOCGMBUF\n");
815 memset(vm, 0, sizeof(*vm));
817 vm->size = dev->nbuffers * dev->len_per_image;
818 vm->frames = dev->nbuffers;
820 for (i=0; i<dev->nbuffers; i++)
821 vm->offsets[i] = i * dev->len_per_image;
823 break;
825 case VIDIOCMCAPTURE:
827 struct video_mmap *vm = arg;
829 STK_DEBUG("VIDIOCMCAPTURE format=%d\n", vm->format);
831 if (vm->frame < 0 || vm->frame >= dev->nbuffers)
832 return -EINVAL;
834 if (vm->format) {
835 switch (vm->format) {
836 case VIDEO_PALETTE_RGB32:
837 break;
839 case VIDEO_PALETTE_RGB24:
840 break;
842 case VIDEO_PALETTE_UYVY:
843 break;
845 case VIDEO_PALETTE_YUYV:
846 break;
848 default:
849 return -EINVAL;
853 if ((vm->width != dev->view.x) || (vm->height != dev->view.y))
854 return -EAGAIN;
856 if (dev->image_used[vm->frame])
857 return -EBUSY;
859 dev->image_used[vm->frame] = 1;
861 STK_DEBUG("VIDIOCMCAPTURE done\n");
863 break;
865 case VIDIOCSYNC:
867 int ret;
868 int *mbuf = arg;
870 STK_DEBUG("VIDIOCSYNC\n");
872 if (*mbuf < 0 || *mbuf >= dev->nbuffers)
873 return -EINVAL;
875 if (dev->image_used[*mbuf] == 0)
876 return -EINVAL;
878 add_wait_queue(&dev->wait_frame, &wait);
880 while (dev->full_frames == NULL) {
881 if (dev->error_status) {
882 remove_wait_queue(&dev->wait_frame, &wait);
883 set_current_state(TASK_RUNNING);
884 return -dev->error_status;
887 if (signal_pending(current)) {
888 remove_wait_queue(&dev->wait_frame, &wait);
889 set_current_state(TASK_RUNNING);
890 return -ERESTARTSYS;
893 schedule();
894 set_current_state(TASK_INTERRUPTIBLE);
897 remove_wait_queue(&dev->wait_frame, &wait);
898 set_current_state(TASK_RUNNING);
900 STK_DEBUG("VIDIOCSYNC: frame ready\n");
902 dev->fill_image = *mbuf;
904 ret = stk11xx_handle_frame(dev);
906 if (ret != 0)
907 STK_ERROR("VIDIOCSYNC error !\n");
909 dev->image_used[*mbuf] = 0;
911 break;
913 case VIDIOCGAUDIO:
914 STK_DEBUG("VIDIOCGAUDIO\n");
915 return -EINVAL;
916 break;
918 case VIDIOCSAUDIO:
919 STK_DEBUG("VIDIOCSAUDIO\n");
920 return -EINVAL;
921 break;
923 case VIDIOCGUNIT:
925 struct video_unit *vu = arg;
927 vu->video = dev->vdev->minor & 0x3f;
928 vu->audio = -1;
929 vu->vbi = -1;
930 vu->radio = -1;
931 vu->teletext = -1;
933 break;
936 // Video 4 Linux v2
938 case VIDIOC_QUERYCAP:
940 struct v4l2_capability *cap = arg;
942 STK_DEBUG("VIDIOC_QUERYCAP\n");
944 memset(cap, 0, sizeof(*cap));
945 strlcpy(cap->driver, "stk11xx", sizeof(cap->driver));
947 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
948 cap->version = (__u32) DRIVER_VERSION_NUM, strlcpy(cap->card, dev->vdev->name, sizeof(cap->card));
950 if (usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)) < 0)
951 strlcpy(cap->bus_info, dev->vdev->name, sizeof(cap->bus_info));
953 break;
955 case VIDIOC_ENUMINPUT:
957 struct v4l2_input *i = arg;
959 STK_DEBUG("VIDIOC_ENUMINPUT %d\n", i->index);
961 if (i->index)
962 return -EINVAL;
964 strlcpy(i->name, "USB", sizeof(i->name));
965 i->type = V4L2_INPUT_TYPE_CAMERA;
967 break;
969 case VIDIOC_G_INPUT:
971 struct v4l2_input *i = arg;
973 STK_DEBUG("GET INPUT %d\n", i->index);
975 if (i->index)
976 return -EINVAL;
978 break;
980 case VIDIOC_S_INPUT:
982 struct v4l2_input *i = arg;
984 STK_DEBUG("SET INPUT %d\n", i->index);
986 if (i->index != 0)
987 return -EINVAL;
989 break;
991 case VIDIOC_QUERYCTRL:
993 int i;
994 int nbr;
995 struct v4l2_queryctrl *c = arg;
997 STK_DEBUG("VIDIOC_QUERYCTRL id = %d\n", c->id);
999 nbr = sizeof(stk11xx_controls)/sizeof(struct v4l2_queryctrl);
1001 for (i=0; i<nbr; i++) {
1002 if (stk11xx_controls[i].id == c->id) {
1003 STK_DEBUG("VIDIOC_QUERYCTRL found\n");
1004 memcpy(c, &stk11xx_controls[i], sizeof(struct v4l2_queryctrl));
1005 break;
1009 if (i >= nbr)
1010 return -EINVAL;
1012 break;
1014 case VIDIOC_G_CTRL:
1016 struct v4l2_control *c = arg;
1018 STK_DEBUG("GET CTRL id=%d\n", c->id);
1020 switch (c->id) {
1021 case V4L2_CID_BRIGHTNESS:
1022 c->value = dev->vsettings.brightness;
1023 break;
1025 case V4L2_CID_WHITENESS:
1026 c->value = dev->vsettings.whiteness;
1027 break;
1029 case V4L2_CID_SATURATION:
1030 c->value = dev->vsettings.colour;
1031 break;
1033 case V4L2_CID_CONTRAST:
1034 c->value = dev->vsettings.contrast;
1035 break;
1037 default:
1038 return -EINVAL;
1041 break;
1043 case VIDIOC_S_CTRL:
1045 struct v4l2_control *c = arg;
1047 STK_DEBUG("SET CTRL id=%d value=%d\n", c->id, c->value);
1049 switch (c->id) {
1050 case V4L2_CID_BRIGHTNESS:
1051 dev->vsettings.brightness = (0xff00 & c->value);
1052 break;
1054 case V4L2_CID_WHITENESS:
1055 dev->vsettings.whiteness = (0xff00 & c->value);
1056 break;
1058 case V4L2_CID_SATURATION:
1059 dev->vsettings.colour = (0xff00 & c->value);
1060 break;
1062 case V4L2_CID_CONTRAST:
1063 dev->vsettings.contrast = (0xff00 & c->value);
1064 break;
1066 default:
1067 return -EINVAL;
1070 dev_stk11xx_camera_settings(dev);
1072 break;
1074 case VIDIOC_ENUM_FMT:
1076 int index;
1077 struct v4l2_fmtdesc *fmtd = arg;
1079 STK_DEBUG("VIDIOC_ENUM_FMT %d\n", fmtd->index);
1081 if (fmtd->index != 0)
1082 return -EINVAL;
1084 index = fmtd->index;
1086 memset(fmtd, 0, sizeof(*fmtd));
1088 fmtd->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1089 fmtd->index = index;
1091 switch (index) {
1092 case 0:
1093 fmtd->flags = 0;
1094 fmtd->pixelformat = V4L2_PIX_FMT_RGB24;
1096 strcpy(fmtd->description, "rgb24");
1097 break;
1099 case 1:
1100 fmtd->flags = 0;
1101 fmtd->pixelformat = V4L2_PIX_FMT_RGB32;
1103 strcpy(fmtd->description, "rgb32");
1104 break;
1106 case 2:
1107 fmtd->flags = 0;
1108 fmtd->pixelformat = V4L2_PIX_FMT_BGR24;
1110 strcpy(fmtd->description, "bgr24");
1111 break;
1113 case 3:
1114 fmtd->flags = 0;
1115 fmtd->pixelformat = V4L2_PIX_FMT_BGR32;
1117 strcpy(fmtd->description, "bgr32");
1118 break;
1120 case 4:
1121 fmtd->flags = 0;
1122 fmtd->pixelformat = V4L2_PIX_FMT_UYVY;
1124 strcpy(fmtd->description, "uyvy");
1125 break;
1127 case 5:
1128 fmtd->flags = 0;
1129 fmtd->pixelformat = V4L2_PIX_FMT_YUYV;
1131 strcpy(fmtd->description, "yuyv");
1132 break;
1134 default:
1135 return -EINVAL;
1138 break;
1140 case VIDIOC_G_FMT:
1142 struct v4l2_format *fmtd = arg;
1143 struct v4l2_pix_format pix_format;
1145 STK_DEBUG("GET FMT %d\n", fmtd->type);
1147 if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1148 return -EINVAL;
1150 pix_format.width = dev->view.x;
1151 pix_format.height = dev->view.y;
1152 pix_format.field = V4L2_FIELD_NONE;
1153 pix_format.colorspace = V4L2_COLORSPACE_SRGB;
1154 pix_format.priv = 0;
1156 switch (dev->vsettings.palette) {
1157 case STK11XX_PALETTE_RGB24:
1158 pix_format.pixelformat = V4L2_PIX_FMT_RGB24;
1159 pix_format.sizeimage = pix_format.width * pix_format.height * 3;
1160 pix_format.bytesperline = 3 * pix_format.width;
1161 break;
1163 case STK11XX_PALETTE_RGB32:
1164 pix_format.pixelformat = V4L2_PIX_FMT_RGB32;
1165 pix_format.sizeimage = pix_format.width * pix_format.height * 4;
1166 pix_format.bytesperline = 4 * pix_format.width;
1167 break;
1169 case STK11XX_PALETTE_BGR24:
1170 pix_format.pixelformat = V4L2_PIX_FMT_BGR24;
1171 pix_format.sizeimage = pix_format.width * pix_format.height * 3;
1172 pix_format.bytesperline = 3 * pix_format.width;
1173 break;
1175 case STK11XX_PALETTE_BGR32:
1176 pix_format.pixelformat = V4L2_PIX_FMT_BGR32;
1177 pix_format.sizeimage = pix_format.width * pix_format.height * 4;
1178 pix_format.bytesperline = 4 * pix_format.width;
1179 break;
1181 case STK11XX_PALETTE_UYVY:
1182 pix_format.pixelformat = V4L2_PIX_FMT_UYVY;
1183 pix_format.sizeimage = pix_format.width * pix_format.height * 2;
1184 pix_format.bytesperline = 2 * pix_format.width;
1185 break;
1187 case STK11XX_PALETTE_YUYV:
1188 pix_format.pixelformat = V4L2_PIX_FMT_YUYV;
1189 pix_format.sizeimage = pix_format.width * pix_format.height * 2;
1190 pix_format.bytesperline = 2 * pix_format.width;
1191 break;
1194 memcpy(&(fmtd->fmt.pix), &pix_format, sizeof(pix_format));
1196 break;
1198 case VIDIOC_TRY_FMT:
1200 struct v4l2_format *fmtd = arg;
1202 STK_DEBUG("TRY FMT %d\n", fmtd->type);
1204 if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1205 return -EINVAL;
1207 switch (fmtd->fmt.pix.pixelformat) {
1208 case V4L2_PIX_FMT_RGB24:
1209 case V4L2_PIX_FMT_BGR24:
1210 dev->vsettings.depth = 24;
1211 break;
1213 case V4L2_PIX_FMT_RGB32:
1214 case V4L2_PIX_FMT_BGR32:
1215 dev->vsettings.depth = 32;
1216 break;
1218 case V4L2_PIX_FMT_UYVY:
1219 case V4L2_PIX_FMT_YUYV:
1220 dev->vsettings.depth = 16;
1221 break;
1223 default:
1224 return -EINVAL;
1227 switch (dev->webcam_type) {
1228 case STK11XX_SXGA:
1229 if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x)
1230 fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x;
1231 else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].x)
1232 fmtd->fmt.pix.width = stk11xx_image_sizes[0].x;
1234 if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y)
1235 fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y;
1236 else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].y)
1237 fmtd->fmt.pix.height = stk11xx_image_sizes[0].y;
1238 break;
1240 case STK11XX_VGA:
1241 if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].x)
1242 fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].x;
1243 else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].x)
1244 fmtd->fmt.pix.width = stk11xx_image_sizes[0].x;
1246 if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].y)
1247 fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].y;
1248 else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].y)
1249 fmtd->fmt.pix.height = stk11xx_image_sizes[0].y;
1250 break;
1254 break;
1256 case VIDIOC_S_FMT:
1258 struct v4l2_format *fmtd = arg;
1260 STK_DEBUG("SET FMT %d : %d\n", fmtd->type, fmtd->fmt.pix.pixelformat);
1262 if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1263 return -EINVAL;
1265 switch (fmtd->fmt.pix.pixelformat) {
1266 case V4L2_PIX_FMT_RGB24:
1267 dev->vsettings.depth = 24;
1268 dev->vsettings.palette = STK11XX_PALETTE_RGB24;
1269 break;
1271 case V4L2_PIX_FMT_RGB32:
1272 dev->vsettings.depth = 32;
1273 dev->vsettings.palette = STK11XX_PALETTE_RGB32;
1274 break;
1276 case V4L2_PIX_FMT_BGR24:
1277 dev->vsettings.depth = 24;
1278 dev->vsettings.palette = STK11XX_PALETTE_BGR24;
1279 break;
1281 case V4L2_PIX_FMT_BGR32:
1282 dev->vsettings.depth = 32;
1283 dev->vsettings.palette = STK11XX_PALETTE_BGR32;
1284 break;
1286 case V4L2_PIX_FMT_UYVY:
1287 dev->vsettings.depth = 16;
1288 dev->vsettings.palette = STK11XX_PALETTE_UYVY;
1289 break;
1291 case V4L2_PIX_FMT_YUYV:
1292 dev->vsettings.depth = 16;
1293 dev->vsettings.palette = STK11XX_PALETTE_YUYV;
1294 break;
1296 default:
1297 return -EINVAL;
1300 STK_DEBUG("Set width=%d, height=%d\n", fmtd->fmt.pix.width, fmtd->fmt.pix.height);
1302 // Stop the video stream
1303 dev_stk11xx_stop_stream(dev);
1305 // ISOC and URB cleanup
1306 usb_stk11xx_isoc_cleanup(dev);
1308 // Switch off the camera
1309 dev_stk11xx_camera_off(dev);
1311 dev_stk11xx_camera_asleep(dev);
1313 // Select the new video mode
1314 if (v4l_stk11xx_select_video_mode(dev, fmtd->fmt.pix.width, fmtd->fmt.pix.height)) {
1315 STK_ERROR("Select video mode failed !\n");
1316 return -EAGAIN;
1319 // Clear the buffers
1320 stk11xx_clear_buffers(dev);
1322 // Initialize the device
1323 dev_stk11xx_init_camera(dev);
1324 dev_stk11xx_camera_on(dev);
1325 dev_stk11xx_reconf_camera(dev);
1327 // ISOC and URB init
1328 usb_stk11xx_isoc_init(dev);
1330 // Re-start the stream
1331 dev_stk11xx_start_stream(dev);
1333 // Video settings
1334 dev_stk11xx_camera_settings(dev);
1336 break;
1338 case VIDIOC_QUERYSTD:
1340 STK_DEBUG("QUERY STD\n");
1341 return -EINVAL;
1343 break;
1345 case VIDIOC_G_STD:
1347 v4l2_std_id *std = arg;
1349 STK_DEBUG("GET STD\n");
1351 *std = V4L2_STD_UNKNOWN;
1353 break;
1355 case VIDIOC_S_STD:
1357 v4l2_std_id *std = arg;
1359 STK_DEBUG("SET STD\n");
1361 if (*std != V4L2_STD_UNKNOWN)
1362 return -EINVAL;
1364 break;
1366 case VIDIOC_ENUMSTD:
1368 struct v4l2_standard *std = arg;
1370 STK_DEBUG("VIDIOC_ENUMSTD\n");
1372 if (std->index != 0)
1373 return -EINVAL;
1375 std->id = V4L2_STD_UNKNOWN;
1376 strncpy(std->name, "webcam", sizeof(std->name));
1378 break;
1381 case VIDIOC_REQBUFS:
1383 int nbuffers;
1384 struct v4l2_requestbuffers *rb = arg;
1386 if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1387 return -EINVAL;
1389 if (rb->memory != V4L2_MEMORY_MMAP)
1390 return -EINVAL;
1392 nbuffers = rb->count;
1394 if (nbuffers < 2)
1395 nbuffers = 2;
1396 else if (nbuffers > dev->nbuffers)
1397 nbuffers = dev->nbuffers;
1399 rb->count = dev->nbuffers;
1401 break;
1403 case VIDIOC_QUERYBUF:
1405 int index;
1406 struct v4l2_buffer *buf = arg;
1408 STK_DEBUG("QUERY BUFFERS %d %d\n", buf->index, dev->nbuffers);
1410 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1411 return -EINVAL;
1413 if (buf->memory != V4L2_MEMORY_MMAP)
1414 return -EINVAL;
1416 index = buf->index;
1418 if (index < 0 || index >= dev->nbuffers)
1419 return -EINVAL;
1421 memset(buf, 0, sizeof(struct v4l2_buffer));
1423 buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1424 buf->index = index;
1425 buf->m.offset = index * dev->len_per_image;
1426 buf->bytesused = dev->image_size;
1427 buf->field = V4L2_FIELD_NONE;
1428 buf->memory = V4L2_MEMORY_MMAP;
1429 buf->length = dev->len_per_image;
1431 break;
1433 case VIDIOC_QBUF:
1435 struct v4l2_buffer *buf = arg;
1437 STK_DEBUG("VIDIOC_QBUF\n");
1439 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1440 return -EINVAL;
1442 if (buf->memory != V4L2_MEMORY_MMAP)
1443 return -EINVAL;
1445 if (buf->index < 0 || buf->index >= dev->nbuffers)
1446 return -EINVAL;
1448 buf->flags |= V4L2_BUF_FLAG_QUEUED;
1449 buf->flags &= ~V4L2_BUF_FLAG_DONE;
1451 break;
1453 case VIDIOC_DQBUF:
1455 int ret;
1456 struct v4l2_buffer *buf = arg;
1458 STK_DEBUG("VIDIOC_DQBUF\n");
1460 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1461 return -EINVAL;
1463 add_wait_queue(&dev->wait_frame, &wait);
1465 while (dev->full_frames == NULL) {
1466 if (dev->error_status) {
1467 remove_wait_queue(&dev->wait_frame, &wait);
1468 set_current_state(TASK_RUNNING);
1470 return -dev->error_status;
1473 if (signal_pending(current)) {
1474 remove_wait_queue(&dev->wait_frame, &wait);
1475 set_current_state(TASK_RUNNING);
1477 return -ERESTARTSYS;
1480 schedule();
1481 set_current_state(TASK_INTERRUPTIBLE);
1484 remove_wait_queue(&dev->wait_frame, &wait);
1485 set_current_state(TASK_RUNNING);
1487 STK_DEBUG("VIDIOC_DQBUF : frame ready.\n");
1489 ret = stk11xx_handle_frame(dev);
1491 if (ret)
1492 return -EFAULT;
1494 buf->index = dev->fill_image;
1495 buf->bytesused = dev->image_size;
1496 buf->flags = V4L2_BUF_FLAG_MAPPED;
1497 buf->field = V4L2_FIELD_NONE;
1498 do_gettimeofday(&buf->timestamp);
1499 buf->sequence = 0;
1500 buf->memory = V4L2_MEMORY_MMAP;
1501 buf->m.offset = dev->fill_image * dev->len_per_image;
1502 buf->length = buf->bytesused;
1504 stk11xx_next_image(dev);
1506 break;
1508 case VIDIOC_STREAMON:
1510 STK_DEBUG("VIDIOC_STREAMON\n");
1512 usb_stk11xx_isoc_init(dev);
1514 break;
1516 case VIDIOC_STREAMOFF:
1518 STK_DEBUG("VIDIOC_STREAMOFF\n");
1520 usb_stk11xx_isoc_cleanup(dev);
1522 break;
1524 case VIDIOC_G_PARM:
1526 struct v4l2_streamparm *sp = arg;
1528 STK_DEBUG("GET PARM %d\n", sp->type);
1530 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1531 return -EINVAL;
1533 sp->parm.capture.capability = 0;
1534 sp->parm.capture.capturemode = 0;
1535 sp->parm.capture.timeperframe.numerator = 1;
1536 sp->parm.capture.timeperframe.denominator = 30;
1537 sp->parm.capture.readbuffers = 2;
1538 sp->parm.capture.extendedmode = 0;
1540 break;
1543 case VIDIOC_G_AUDIO:
1544 STK_DEBUG("GET AUDIO\n");
1545 return -EINVAL;
1546 break;
1548 case VIDIOC_S_AUDIO:
1549 STK_DEBUG("SET AUDIO\n");
1550 return -EINVAL;
1551 break;
1553 case VIDIOC_S_TUNER:
1554 STK_DEBUG("SET TUNER\n");
1555 return -EINVAL;
1556 break;
1558 case VIDIOC_G_FBUF:
1559 case VIDIOC_S_FBUF:
1560 case VIDIOC_OVERLAY:
1561 return -EINVAL;
1562 break;
1564 case VIDIOC_G_TUNER:
1565 case VIDIOC_G_FREQUENCY:
1566 case VIDIOC_S_FREQUENCY:
1567 return -EINVAL;
1568 break;
1570 case VIDIOC_QUERYMENU:
1571 return -EINVAL;
1572 break;
1574 case VIDIOC_CROPCAP:
1576 struct v4l2_cropcap cc;
1578 cc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1579 cc.pixelaspect.numerator = 1;
1580 cc.pixelaspect.denominator = 1;
1581 cc.bounds.top = 0;
1582 cc.bounds.left = 0;
1583 cc.bounds.width = 640;
1584 cc.bounds.height = 480;
1585 cc.defrect.top = 0;
1586 cc.defrect.left = 0;
1587 cc.defrect.width = 640;
1588 cc.defrect.height = 480;
1590 memcpy(arg, &cc, sizeof(cc));
1592 break;
1594 default:
1595 STK_DEBUG("IOCTL unknown !\n");
1596 return -ENOIOCTLCMD;
1599 return 0;
1603 /**
1604 * @param inode Inode pointer
1605 * @param fp File pointer
1606 * @param cmd Command
1607 * @param arg Arguements of the command
1609 * @returns 0 if all is OK
1611 * @brief Manage IOCTL
1613 * This function permits to manage all the IOCTL from the application.
1615 static int v4l_stk11xx_ioctl(struct inode *inode, struct file *fp,
1616 unsigned int cmd, unsigned long arg)
1618 int err;
1619 struct usb_stk11xx *dev;
1620 struct video_device *vdev;
1622 vdev = video_devdata(fp);
1623 dev = video_get_drvdata(video_devdata(fp));
1625 STK_DEBUG("v4l_stk11xx_ioctl %02X\n", (unsigned char) cmd);
1627 if (dev == NULL)
1628 return -EFAULT;
1630 if (vdev == NULL)
1631 return -EFAULT;
1633 // v4l_printk_ioctl(cmd);
1635 err = v4l_stk11xx_do_ioctl(inode, fp, cmd, (void __user *) arg);
1637 return err;
1641 /**
1642 * @param dev Device structure
1644 * @returns 0 if all is OK
1646 * @brief Register the video device
1648 * This function permits to register the USB device to the video device.
1650 int v4l_stk11xx_register_video_device(struct usb_stk11xx *dev)
1652 int err;
1654 strcpy(dev->vdev->name, DRIVER_DESC);
1656 dev->vdev->owner = THIS_MODULE;
1657 dev->vdev->type = VID_TYPE_CAPTURE;
1658 dev->vdev->hardware = VID_HARDWARE_STK11XX;
1659 dev->vdev->fops = &v4l_stk11xx_fops;
1660 dev->vdev->release = video_device_release;
1661 dev->vdev->minor = -1;
1663 video_set_drvdata(dev->vdev, dev);
1665 err = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1);
1667 if (err)
1668 STK_ERROR("Video register fail !\n");
1669 else
1670 STK_INFO("Syntek USB2.0 Camera is now controlling video device /dev/video%d\n", dev->vdev->minor);
1672 return err;
1676 /**
1677 * @param dev Device structure
1679 * @returns 0 if all is OK
1681 * @brief Unregister the video device
1683 * This function permits to unregister the video device.
1685 int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *dev)
1687 STK_INFO("Syntek USB2.0 Camera release resources video device /dev/video%d\n", dev->vdev->minor);
1689 video_set_drvdata(dev->vdev, NULL);
1690 video_unregister_device(dev->vdev);
1692 return 0;
1697 * @var v4l_stk11xx_fops
1699 * This variable contains some callback
1701 static struct file_operations v4l_stk11xx_fops = {
1702 .owner = THIS_MODULE,
1703 .open = v4l_stk11xx_open,
1704 .release = v4l_stk11xx_release,
1705 .read = v4l_stk11xx_read,
1706 .poll = v4l_stk11xx_poll,
1707 .mmap = v4l_stk11xx_mmap,
1708 .ioctl = v4l_stk11xx_ioctl,
1709 .llseek = no_llseek