SyntekUSBVideoCamera
stk11xx-v4l.c
Go to the documentation of this file.
1 
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>
42 #include <linux/mm.h>
43 
44 
45 #include <linux/usb.h>
46 #include <media/v4l2-common.h>
47 #include <media/v4l2-ioctl.h>
48 
49 #include "stk11xx.h"
50 
51 
52 static struct v4l2_file_operations v4l_stk11xx_fops;
53 
54 
59 const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES] = {
60  { 80, 60 },
61  { 128, 96 },
62  { 160, 120 },
63  { 213, 160 },
64  { 320, 240 },
65  { 640, 480 },
66  { 800, 600 },
67  { 1024, 768 },
68  { 1280, 1024 }
69 };
70 
71 
77 static struct v4l2_queryctrl stk11xx_controls[] = {
78  {
79  .id = V4L2_CID_BRIGHTNESS,
80  .type = V4L2_CTRL_TYPE_INTEGER,
81  .name = "Brightness",
82  .minimum = 0,
83  .maximum = 0xff00,
84  .step = 1,
85  .default_value = 0x7f00,
86  },
87  {
88  .id = V4L2_CID_WHITENESS,
89  .type = V4L2_CTRL_TYPE_INTEGER,
90  .name = "Whiteness",
91  .minimum = 0,
92  .maximum = 0xff00,
93  .step = 1,
94  .default_value = 0x7f00,
95  },
96  {
97  .id = V4L2_CID_SATURATION,
98  .type = V4L2_CTRL_TYPE_INTEGER,
99  .name = "Saturation",
100  .minimum = 0,
101  .maximum = 0xff00,
102  .step = 1,
103  .default_value = 0x7f00,
104  },
105  {
106  .id = V4L2_CID_CONTRAST,
107  .type = V4L2_CTRL_TYPE_INTEGER,
108  .name = "Contrast",
109  .minimum = 0,
110  .maximum = 0xff00,
111  .step = 1,
112  .default_value = 0x7f00,
113  },
114  {
115  .id = V4L2_CID_HFLIP,
116  .type = V4L2_CTRL_TYPE_BOOLEAN,
117  .name = "Flip Horizontally",
118  .minimum = 0,
119  .maximum = 1,
120  .step = 1,
121  .default_value = 0, // will be actually set later
122  },
123  {
124  .id = V4L2_CID_VFLIP,
125  .type = V4L2_CTRL_TYPE_BOOLEAN,
126  .name = "Flip Vertically",
127  .minimum = 0,
128  .maximum = 1,
129  .step = 1,
130  .default_value = 0, // will be actually set later
131  }
132 };
133 
134 
146 int v4l_stk11xx_select_video_mode(struct usb_stk11xx *dev, int width, int height)
147 {
148  int i;
149  int find;
150 
151 
152  // Check width and height
153  // Notice : this test is usefull for the Kopete application !
154 
155  // Driver can't build an image smaller than the minimal resolution !
156  if ((width < stk11xx_image_sizes[0].x)
157  || (height < stk11xx_image_sizes[0].y)) {
158  width = stk11xx_image_sizes[0].x;
159  height = stk11xx_image_sizes[0].y;
160  }
161 
162  // Driver can't build an image bigger than the maximal resolution !
163  switch (dev->webcam_type) {
164  case STK11XX_SXGA:
165  if ((width > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x)
166  || (height > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y)) {
167  width = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x;
168  height = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y;
169  }
170  break;
171 
172  case STK11XX_VGA:
173  if ((width > stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].x)
174  || (height > stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].y)) {
175  width = stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].x;
176  height = stk11xx_image_sizes[STK11XX_NBR_SIZES-3-1].y;
177  }
178  break;
179 
180  default:
181  return -1;
182  }
183 
184 
185  // Seek the best resolution
186  switch (dev->webcam_type) {
187  case STK11XX_SXGA:
188  for (i=0, find=0; i<STK11XX_NBR_SIZES; i++) {
189  if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
190  find = i;
191  }
192  break;
193 
194  case STK11XX_VGA:
195  for (i=0, find=0; i<STK11XX_NBR_SIZES-3; i++) {
196  if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
197  find = i;
198  }
199  break;
200 
201  default:
202  return -1;
203  }
204 
205  // Save the new resolution
206  dev->resolution = find;
207 
208  STK_DEBUG("Set mode %d [%dx%d]\n", dev->resolution,
209  stk11xx_image_sizes[dev->resolution].x, stk11xx_image_sizes[dev->resolution].y);
210 
211  // Save the new size
212  dev->view.x = width;
213  dev->view.y = height;
214 
215 
216  // Calculate the frame size
217  switch (dev->resolution) {
218  case STK11XX_80x60:
219  case STK11XX_128x96:
220  case STK11XX_160x120:
221  case STK11XX_213x160:
222  case STK11XX_320x240:
223  case STK11XX_640x480:
224  dev->image.x = stk11xx_image_sizes[STK11XX_640x480].x;
225  dev->image.y = stk11xx_image_sizes[STK11XX_640x480].y;
226  dev->frame_size = dev->image.x * dev->image.y;
227  break;
228 
229  case STK11XX_800x600:
230  case STK11XX_1024x768:
231  case STK11XX_1280x1024:
232  dev->image.x = stk11xx_image_sizes[STK11XX_1280x1024].x;
233  dev->image.y = stk11xx_image_sizes[STK11XX_1280x1024].y;
234  dev->frame_size = dev->image.x * dev->image.y;
235  break;
236  }
237 
238 
239  // Calculate the image size
240  switch (dev->vsettings.palette) {
241  case STK11XX_PALETTE_RGB24:
242  case STK11XX_PALETTE_BGR24:
243  dev->view_size = 3 * dev->view.x * dev->view.y;
244  dev->image_size = 3 * dev->frame_size;
245  break;
246 
247  case STK11XX_PALETTE_RGB32:
248  case STK11XX_PALETTE_BGR32:
249  dev->view_size = 3 * dev->view.x * dev->view.y;
250  dev->image_size = 4 * dev->frame_size;
251  break;
252 
253  case STK11XX_PALETTE_UYVY:
254  case STK11XX_PALETTE_YUYV:
255  dev->view_size = 2 * dev->view.x * dev->view.y;
256  dev->image_size = 2 * dev->frame_size;
257  break;
258  }
259 
260  return 0;
261 }
262 
263 
273 static int v4l_stk11xx_open(struct file *fp)
274 {
275  int err;
276 
277  struct usb_stk11xx *dev;
278  struct video_device *vdev;
279 
280  vdev = video_devdata(fp);
281  dev = video_get_drvdata(video_devdata(fp));
282 
283  if (dev == NULL) {
284  STK_ERROR("Device not initialized !!!\n");
285  BUG();
286  }
287  mutex_lock(&dev->modlock);
288 
289  if (dev->vopen) {
290  STK_DEBUG("Device is busy, someone is using the device\n");
291  mutex_unlock(&dev->modlock);
292  return -EBUSY;
293  }
294 
295 
296  // Allocate memory
297  err = stk11xx_allocate_buffers(dev);
298 
299  if (err < 0) {
300  STK_ERROR("Failed to allocate buffer memory !\n");
301  mutex_unlock(&dev->modlock);
302  return err;
303  }
304 
305  // Reset buffers and parameters
307 
308  // Settings
309  dev->error_status = 0;
310  dev->visoc_errors = 0;
311  dev->vframes_error = 0;
312  dev->vframes_dumped = 0;
313  dev->vsettings.hue = 0xffff;
314  dev->vsettings.depth = 24;
315  dev->vsettings.palette = STK11XX_PALETTE_BGR24;
316 
317  // Select the resolution by default
318  v4l_stk11xx_select_video_mode(dev, 640, 480);
319 
320  // Initialize the device
324 
325  // Init Isoc and URB
326  err = usb_stk11xx_isoc_init(dev);
327 
328  if (err) {
329  STK_ERROR("Failed to init ISOC stuff !\n");
332  mutex_unlock(&dev->modlock);
333  return err;
334  }
335 
336  // Start the video stream
338 
339  // Video settings
341 
342  // Register interface on power management
343  usb_autopm_get_interface(dev->interface);
344 
345  dev->vopen++;
346  fp->private_data = vdev;
347 
348  mutex_unlock(&dev->modlock);
349 
350  return 0;
351 }
352 
353 
363 static int v4l_stk11xx_release(struct file *fp)
364 {
365  struct usb_stk11xx *dev;
366  struct video_device *vdev;
367 
368  vdev = video_devdata(fp);
369  dev = video_get_drvdata(video_devdata(fp));
370 
371  if (dev->vopen == 0)
372  STK_ERROR("v4l_release called on closed device\n");
373 
374  // Stop the video stream
376 
377  // ISOC and URB cleanup
379 
380  // Free memory
382 
383  // Switch off the camera
385 
387 
388  // Unregister interface on power management
389  usb_autopm_put_interface(dev->interface);
390 
391  dev->vopen--;
392 
393  return 0;
394 }
395 
396 
410 static ssize_t v4l_stk11xx_read(struct file *fp, char __user *buf,
411  size_t count, loff_t *f_pos)
412 {
413  int noblock = fp->f_flags & O_NONBLOCK;
414 
415  struct usb_stk11xx *dev;
416  struct video_device *vdev;
417 
418  int bytes_to_read;
419  void *image_buffer_addr;
420 
421  DECLARE_WAITQUEUE(wait, current);
422 
423  vdev = video_devdata(fp);
424  dev = video_get_drvdata(video_devdata(fp));
425 
426  STK_STREAM("Read vdev=0x%p, buf=0x%p, count=%zd\n", vdev, buf, count);
427 
428  if (dev == NULL)
429  return -EFAULT;
430 
431  if (vdev == NULL)
432  return -EFAULT;
433 
434  mutex_lock(&dev->modlock);
435 
436  if (dev->image_read_pos == 0) {
437  add_wait_queue(&dev->wait_frame, &wait);
438 
439  while (dev->full_frames == NULL) {
440  if (dev->error_status) {
441  remove_wait_queue(&dev->wait_frame, &wait);
442  set_current_state(TASK_RUNNING);
443  mutex_unlock(&dev->modlock);
444  return -dev->error_status ;
445  }
446 
447  if (noblock) {
448  remove_wait_queue(&dev->wait_frame, &wait);
449  set_current_state(TASK_RUNNING);
450  mutex_unlock(&dev->modlock);
451  return -EWOULDBLOCK;
452  }
453 
454  if (signal_pending(current)) {
455  remove_wait_queue(&dev->wait_frame, &wait);
456  set_current_state(TASK_RUNNING);
457  mutex_unlock(&dev->modlock);
458  return -ERESTARTSYS;
459  }
460 
461  schedule();
462  set_current_state(TASK_INTERRUPTIBLE);
463  }
464 
465  remove_wait_queue(&dev->wait_frame, &wait);
466  set_current_state(TASK_RUNNING);
467 
468  if (stk11xx_handle_frame(dev)) {
469  mutex_unlock(&dev->modlock);
470  return -EFAULT;
471  }
472  }
473 
474  bytes_to_read = dev->view_size;
475 
476  if (count + dev->image_read_pos > bytes_to_read)
477  count = bytes_to_read - dev->image_read_pos;
478 
479  image_buffer_addr = dev->image_data;
480  image_buffer_addr += dev->images[dev->fill_image].offset;
481  image_buffer_addr += dev->image_read_pos;
482 
483  if (copy_to_user(buf, image_buffer_addr, count)) {
484  mutex_unlock(&dev->modlock);
485  return -EFAULT;
486  }
487 
488  dev->image_read_pos += count;
489 
490  if (dev->image_read_pos >= bytes_to_read) {
491  dev->image_read_pos = 0;
492  stk11xx_next_image(dev);
493  }
494 
495  mutex_unlock(&dev->modlock);
496 
497  return count;
498 }
499 
500 
509 static unsigned int v4l_stk11xx_poll(struct file *fp, poll_table *wait)
510 {
511  struct usb_stk11xx *dev;
512  struct video_device *vdev;
513 
514  vdev = video_devdata(fp);
515  dev = video_get_drvdata(video_devdata(fp));
516 
517  STK_STREAM("Poll\n");
518 
519  if (vdev == NULL)
520  return -EFAULT;
521 
522  if (dev == NULL)
523  return -EFAULT;
524 
525  poll_wait(fp, &dev->wait_frame, wait);
526 
527  if (dev->error_status)
528  return POLLERR;
529 
530  if (dev->full_frames != NULL)
531  return (POLLIN | POLLRDNORM);
532 
533  return 0;
534 }
535 
536 
547 static int v4l_stk11xx_mmap(struct file *fp, struct vm_area_struct *vma)
548 {
549  unsigned int i;
550 
551  unsigned long size;
552  unsigned long start;
553  unsigned long pos;
554  unsigned long page;
555 
556  struct usb_stk11xx *dev;
557 
558  struct video_device *vdev;
559 
560  vdev = video_devdata(fp);
561  dev = video_get_drvdata(video_devdata(fp));
562 
563  STK_STREAM("mmap\n");
564 
565  start = vma->vm_start;
566  size = vma->vm_end - vma->vm_start;
567 
568  // Find the buffer for this mapping...
569  for (i=0; i<dev->nbuffers; i++) {
570  pos = dev->images[i].offset;
571 
572  if ((pos >> PAGE_SHIFT) == vma->vm_pgoff)
573  break;
574  }
575 
576  // If no buffer found !
577  if (i == STK11XX_MAX_IMAGES) {
578  STK_ERROR("mmap no buffer found !\n");
579  return -EINVAL;
580  }
581 
582  if (i == 0) {
583  unsigned long total_size;
584 
585  total_size = dev->nbuffers * dev->len_per_image;
586 
587  if (size != dev->len_per_image && size != total_size) {
588  STK_ERROR("Wrong size (%lu) needed to be len_per_image=%d or total_size=%lu\n",
589  size, dev->len_per_image, total_size);
590 
591  return -EINVAL;
592  }
593  }
594  else if (size > dev->len_per_image)
595  return -EINVAL;
596 
597  vma->vm_flags |= VM_IO;
598 
599  pos = (unsigned long) dev->image_data;
600 
601  while (size > 0) {
602  page = vmalloc_to_pfn((void *) pos);
603 
604  if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
605  return -EAGAIN;
606 
607  start += PAGE_SIZE;
608  pos += PAGE_SIZE;
609 
610  if (size > PAGE_SIZE)
611  size -= PAGE_SIZE;
612  else
613  size = 0;
614  }
615 
616  return 0;
617 }
618 
619 
631 static long v4l_stk11xx_do_ioctl(struct file *fp,
632  unsigned int cmd, void __user *arg)
633 {
634  struct usb_stk11xx *dev;
635  struct video_device *vdev;
636 
637  DECLARE_WAITQUEUE(wait, current);
638 
639  vdev = video_devdata(fp);
640  dev = video_get_drvdata(video_devdata(fp));
641 
642 #if (CONFIG_STK11XX_DEBUG == 1)
643  v4l_printk_ioctl(cmd);
644 #endif
645 
646  switch (cmd) {
647  // Video 4 Linux v2
648 
649  case VIDIOC_QUERYCAP:
650  {
651  struct v4l2_capability *cap = arg;
652 
653  STK_DEBUG("VIDIOC_QUERYCAP\n");
654 
655  memset(cap, 0, sizeof(*cap));
656  strlcpy(cap->driver, "stk11xx", sizeof(cap->driver));
657 
658  cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
659  cap->version = (__u32) DRIVER_VERSION_NUM, strlcpy(cap->card, dev->vdev->name, sizeof(cap->card));
660 
661  if (usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)) < 0)
662  strlcpy(cap->bus_info, dev->vdev->name, sizeof(cap->bus_info));
663  }
664  break;
665 
666  case VIDIOC_ENUMINPUT:
667  {
668  struct v4l2_input *i = arg;
669 
670  STK_DEBUG("VIDIOC_ENUMINPUT %d\n", i->index);
671 
672  if (i->index)
673  return -EINVAL;
674 
675  strlcpy(i->name, "USB", sizeof(i->name));
676  i->type = V4L2_INPUT_TYPE_CAMERA;
677  }
678  break;
679 
680  case VIDIOC_G_INPUT:
681  {
682  struct v4l2_input *i = arg;
683 
684  STK_DEBUG("GET INPUT %d\n", i->index);
685 
686  if (i->index)
687  return -EINVAL;
688  }
689  break;
690 
691  case VIDIOC_S_INPUT:
692  {
693  struct v4l2_input *i = arg;
694 
695  STK_DEBUG("SET INPUT %d\n", i->index);
696 
697  if (i->index != 0)
698  return -EINVAL;
699  }
700  break;
701 
702  case VIDIOC_QUERYCTRL:
703  {
704  int i;
705  int nbr;
706  struct v4l2_queryctrl *c = arg;
707 
708  STK_DEBUG("VIDIOC_QUERYCTRL id = %d\n", c->id);
709 
710  nbr = sizeof(stk11xx_controls)/sizeof(struct v4l2_queryctrl);
711 
712  for (i=0; i<nbr; i++) {
713  if (stk11xx_controls[i].id == c->id) {
714  STK_DEBUG("VIDIOC_QUERYCTRL found\n");
715  memcpy(c, &stk11xx_controls[i], sizeof(struct v4l2_queryctrl));
716  switch(c->id)
717  {
718  case V4L2_CID_BRIGHTNESS:
719  c->default_value = dev->vsettings.default_brightness;
720  break;
721  case V4L2_CID_WHITENESS:
722  c->default_value = dev->vsettings.default_whiteness;
723  break;
724  case V4L2_CID_SATURATION:
725  c->default_value = dev->vsettings.default_colour;
726  break;
727  case V4L2_CID_CONTRAST:
728  c->default_value = dev->vsettings.default_contrast;
729  break;
730  case V4L2_CID_HFLIP:
731  c->default_value = dev->vsettings.default_hflip;
732  break;
733  case V4L2_CID_VFLIP:
734  c->default_value = dev->vsettings.default_vflip;
735  break;
736  }
737  break;
738  }
739  }
740 
741  if (i >= nbr)
742  return -EINVAL;
743  }
744  break;
745 
746  case VIDIOC_G_CTRL:
747  {
748  struct v4l2_control *c = arg;
749 
750  STK_DEBUG("GET CTRL id=%d\n", c->id);
751 
752  switch (c->id) {
753  case V4L2_CID_BRIGHTNESS:
754  c->value = dev->vsettings.brightness;
755  break;
756 
757  case V4L2_CID_WHITENESS:
758  c->value = dev->vsettings.whiteness;
759  break;
760 
761  case V4L2_CID_SATURATION:
762  c->value = dev->vsettings.colour;
763  break;
764 
765  case V4L2_CID_CONTRAST:
766  c->value = dev->vsettings.contrast;
767  break;
768 
769  case V4L2_CID_HFLIP:
770  c->value = dev->vsettings.hflip;
771  break;
772 
773  case V4L2_CID_VFLIP:
774  c->value = dev->vsettings.vflip;
775  break;
776 
777  default:
778  return -EINVAL;
779  }
780  }
781  break;
782 
783  case VIDIOC_S_CTRL:
784  {
785  struct v4l2_control *c = arg;
786 
787  STK_DEBUG("SET CTRL id=%d value=%d\n", c->id, c->value);
788 
789  switch (c->id) {
790  case V4L2_CID_BRIGHTNESS:
791  dev->vsettings.brightness = (0xff00 & c->value);
792  break;
793 
794  case V4L2_CID_WHITENESS:
795  dev->vsettings.whiteness = (0xff00 & c->value);
796  break;
797 
798  case V4L2_CID_SATURATION:
799  dev->vsettings.colour = (0xff00 & c->value);
800  break;
801 
802  case V4L2_CID_CONTRAST:
803  dev->vsettings.contrast = (0xff00 & c->value);
804  break;
805 
806  case V4L2_CID_HFLIP:
807  dev->vsettings.hflip = c->value ? 1: 0;
808  break;
809 
810  case V4L2_CID_VFLIP:
811  dev->vsettings.vflip = c->value ? 1: 0;
812  break;
813 
814  default:
815  return -EINVAL;
816  }
817 
819  }
820  break;
821 
822  case VIDIOC_ENUM_FMT:
823  {
824  int index;
825  struct v4l2_fmtdesc *fmtd = arg;
826 
827  STK_DEBUG("VIDIOC_ENUM_FMT %d\n", fmtd->index);
828 
829  if (fmtd->index != 0)
830  return -EINVAL;
831 
832  index = fmtd->index;
833 
834  memset(fmtd, 0, sizeof(*fmtd));
835 
836  fmtd->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
837  fmtd->index = index;
838 
839  switch (index) {
840  case 0:
841  fmtd->flags = 0;
842  fmtd->pixelformat = V4L2_PIX_FMT_RGB24;
843 
844  strcpy(fmtd->description, "rgb24");
845  break;
846 
847  case 1:
848  fmtd->flags = 0;
849  fmtd->pixelformat = V4L2_PIX_FMT_RGB32;
850 
851  strcpy(fmtd->description, "rgb32");
852  break;
853 
854  case 2:
855  fmtd->flags = 0;
856  fmtd->pixelformat = V4L2_PIX_FMT_BGR24;
857 
858  strcpy(fmtd->description, "bgr24");
859  break;
860 
861  case 3:
862  fmtd->flags = 0;
863  fmtd->pixelformat = V4L2_PIX_FMT_BGR32;
864 
865  strcpy(fmtd->description, "bgr32");
866  break;
867 
868  case 4:
869  fmtd->flags = 0;
870  fmtd->pixelformat = V4L2_PIX_FMT_UYVY;
871 
872  strcpy(fmtd->description, "uyvy");
873  break;
874 
875  case 5:
876  fmtd->flags = 0;
877  fmtd->pixelformat = V4L2_PIX_FMT_YUYV;
878 
879  strcpy(fmtd->description, "yuyv");
880  break;
881 
882  default:
883  return -EINVAL;
884  }
885  }
886  break;
887 
888  case VIDIOC_G_FMT:
889  {
890  struct v4l2_format *fmtd = arg;
891  struct v4l2_pix_format pix_format;
892 
893  STK_DEBUG("GET FMT %d\n", fmtd->type);
894 
895  if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
896  return -EINVAL;
897 
898  pix_format.width = dev->view.x;
899  pix_format.height = dev->view.y;
900  pix_format.field = V4L2_FIELD_NONE;
901  pix_format.colorspace = V4L2_COLORSPACE_SRGB;
902  pix_format.priv = 0;
903 
904  switch (dev->vsettings.palette) {
905  case STK11XX_PALETTE_RGB24:
906  pix_format.pixelformat = V4L2_PIX_FMT_RGB24;
907  pix_format.sizeimage = pix_format.width * pix_format.height * 3;
908  pix_format.bytesperline = 3 * pix_format.width;
909  break;
910 
911  case STK11XX_PALETTE_RGB32:
912  pix_format.pixelformat = V4L2_PIX_FMT_RGB32;
913  pix_format.sizeimage = pix_format.width * pix_format.height * 4;
914  pix_format.bytesperline = 4 * pix_format.width;
915  break;
916 
917  case STK11XX_PALETTE_BGR24:
918  pix_format.pixelformat = V4L2_PIX_FMT_BGR24;
919  pix_format.sizeimage = pix_format.width * pix_format.height * 3;
920  pix_format.bytesperline = 3 * pix_format.width;
921  break;
922 
923  case STK11XX_PALETTE_BGR32:
924  pix_format.pixelformat = V4L2_PIX_FMT_BGR32;
925  pix_format.sizeimage = pix_format.width * pix_format.height * 4;
926  pix_format.bytesperline = 4 * pix_format.width;
927  break;
928 
929  case STK11XX_PALETTE_UYVY:
930  pix_format.pixelformat = V4L2_PIX_FMT_UYVY;
931  pix_format.sizeimage = pix_format.width * pix_format.height * 2;
932  pix_format.bytesperline = 2 * pix_format.width;
933  break;
934 
935  case STK11XX_PALETTE_YUYV:
936  pix_format.pixelformat = V4L2_PIX_FMT_YUYV;
937  pix_format.sizeimage = pix_format.width * pix_format.height * 2;
938  pix_format.bytesperline = 2 * pix_format.width;
939  break;
940  }
941 
942  memcpy(&(fmtd->fmt.pix), &pix_format, sizeof(pix_format));
943  }
944  break;
945 
946  case VIDIOC_TRY_FMT:
947  {
948  struct v4l2_format *fmtd = arg;
949 
950  STK_DEBUG("TRY FMT %d\n", fmtd->type);
951 
952  if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
953  return -EINVAL;
954 
955 
956  switch (dev->webcam_type) {
957  case STK11XX_SXGA:
958  if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x)
959  fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].x;
960  else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].x)
961  fmtd->fmt.pix.width = stk11xx_image_sizes[0].x;
962 
963  if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y)
964  fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_NBR_SIZES-1].y;
965  else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].y)
966  fmtd->fmt.pix.height = stk11xx_image_sizes[0].y;
967  break;
968 
969  case STK11XX_VGA:
970  if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].x)
971  fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].x;
972  else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].x)
973  fmtd->fmt.pix.width = stk11xx_image_sizes[0].x;
974 
975  if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].y)
976  fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_NBR_SIZES-1-3].y;
977  else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].y)
978  fmtd->fmt.pix.height = stk11xx_image_sizes[0].y;
979  break;
980  }
981  fmtd->fmt.pix.field = V4L2_FIELD_NONE;
982  fmtd->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
983  fmtd->fmt.pix.priv = 0;
984  switch (fmtd->fmt.pix.pixelformat) {
985  case V4L2_PIX_FMT_RGB24:
986  dev->vsettings.depth = 24;
987  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
988  fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
989 
990  break;
991 
992  case V4L2_PIX_FMT_RGB32:
993  dev->vsettings.depth = 32;
994  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
995  fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
996 
997  break;
998 
999  case V4L2_PIX_FMT_BGR24:
1000  dev->vsettings.depth = 24;
1001  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
1002  fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
1003 
1004  break;
1005 
1006  case V4L2_PIX_FMT_BGR32:
1007  dev->vsettings.depth = 32;
1008  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
1009  fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
1010 
1011  break;
1012 
1013  case V4L2_PIX_FMT_UYVY:
1014  dev->vsettings.depth = 16;
1015  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1016  fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1017 
1018  break;
1019 
1020  case V4L2_PIX_FMT_YUYV:
1021  dev->vsettings.depth = 16;
1022  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1023  fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1024 
1025  break;
1026 
1027  default:
1028  return -EINVAL;
1029  }
1030 
1031  }
1032  break;
1033 
1034  case VIDIOC_S_FMT:
1035  {
1036  struct v4l2_format *fmtd = arg;
1037 
1038  STK_DEBUG("SET FMT %d : %d\n", fmtd->type, fmtd->fmt.pix.pixelformat);
1039 
1040  if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1041  return -EINVAL;
1042 
1043  // need to also set the fields as in G_FMT, conform v4l2 specs
1044  fmtd->fmt.pix.field = V4L2_FIELD_NONE;
1045  fmtd->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
1046  fmtd->fmt.pix.priv = 0;
1047 
1048 
1049  switch (fmtd->fmt.pix.pixelformat) {
1050  case V4L2_PIX_FMT_RGB24:
1051  dev->vsettings.depth = 24;
1052  dev->vsettings.palette = STK11XX_PALETTE_RGB24;
1053  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
1054  fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
1055 
1056  break;
1057 
1058  case V4L2_PIX_FMT_RGB32:
1059  dev->vsettings.depth = 32;
1060  dev->vsettings.palette = STK11XX_PALETTE_RGB32;
1061  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
1062  fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
1063 
1064  break;
1065 
1066  case V4L2_PIX_FMT_BGR24:
1067  dev->vsettings.depth = 24;
1068  dev->vsettings.palette = STK11XX_PALETTE_BGR24;
1069  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
1070  fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
1071 
1072  break;
1073 
1074  case V4L2_PIX_FMT_BGR32:
1075  dev->vsettings.depth = 32;
1076  dev->vsettings.palette = STK11XX_PALETTE_BGR32;
1077  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
1078  fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
1079 
1080  break;
1081 
1082  case V4L2_PIX_FMT_UYVY:
1083  dev->vsettings.depth = 16;
1084  dev->vsettings.palette = STK11XX_PALETTE_UYVY;
1085  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1086  fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1087 
1088  break;
1089 
1090  case V4L2_PIX_FMT_YUYV:
1091  dev->vsettings.depth = 16;
1092  dev->vsettings.palette = STK11XX_PALETTE_YUYV;
1093  fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1094  fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1095 
1096  break;
1097 
1098  default:
1099  return -EINVAL;
1100  }
1101 
1102  STK_DEBUG("Set width=%d, height=%d\n", fmtd->fmt.pix.width, fmtd->fmt.pix.height);
1103 
1104  // Stop the video stream
1106 
1107  // ISOC and URB cleanup
1109 
1110  // Switch off the camera
1112 
1114 
1115  // Select the new video mode
1116  if (v4l_stk11xx_select_video_mode(dev, fmtd->fmt.pix.width, fmtd->fmt.pix.height)) {
1117  STK_ERROR("Select video mode failed !\n");
1118  return -EAGAIN;
1119  }
1120 
1121  // Clear the buffers
1122  stk11xx_clear_buffers(dev);
1123 
1124  // Initialize the device
1126  dev_stk11xx_camera_on(dev);
1128 
1129  // ISOC and URB init
1130  usb_stk11xx_isoc_init(dev);
1131 
1132  // Re-start the stream
1134 
1135  // Video settings
1137  }
1138  break;
1139 
1140  case VIDIOC_QUERYSTD:
1141  {
1142  STK_DEBUG("QUERY STD\n");
1143  return -EINVAL;
1144  }
1145  break;
1146 
1147  case VIDIOC_G_STD:
1148  {
1149  v4l2_std_id *std = arg;
1150 
1151  STK_DEBUG("GET STD\n");
1152 
1153  *std = V4L2_STD_UNKNOWN;
1154  }
1155  break;
1156 
1157  case VIDIOC_S_STD:
1158  {
1159  v4l2_std_id *std = arg;
1160 
1161  STK_DEBUG("SET STD\n");
1162 
1163  if (*std != V4L2_STD_UNKNOWN)
1164  return -EINVAL;
1165  }
1166  break;
1167 
1168  case VIDIOC_ENUMSTD:
1169  {
1170  struct v4l2_standard *std = arg;
1171 
1172  STK_DEBUG("VIDIOC_ENUMSTD\n");
1173 
1174  if (std->index != 0)
1175  return -EINVAL;
1176 
1177  std->id = V4L2_STD_UNKNOWN;
1178  strncpy(std->name, "webcam", sizeof(std->name));
1179 
1180  break;
1181  }
1182 
1183  case VIDIOC_REQBUFS:
1184  {
1185  int nbuffers;
1186  struct v4l2_requestbuffers *rb = arg;
1187 
1188  if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1189  return -EINVAL;
1190 
1191  if (rb->memory != V4L2_MEMORY_MMAP)
1192  return -EINVAL;
1193 
1194  nbuffers = rb->count;
1195 
1196  if (nbuffers < 2)
1197  nbuffers = 2;
1198  else if (nbuffers > dev->nbuffers)
1199  nbuffers = dev->nbuffers;
1200 
1201  rb->count = dev->nbuffers;
1202  }
1203  break;
1204 
1205  case VIDIOC_QUERYBUF:
1206  {
1207  int index;
1208  struct v4l2_buffer *buf = arg;
1209 
1210  STK_DEBUG("QUERY BUFFERS %d %d\n", buf->index, dev->nbuffers);
1211 
1212  if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1213  return -EINVAL;
1214 
1215  if (buf->memory != V4L2_MEMORY_MMAP)
1216  return -EINVAL;
1217 
1218  index = buf->index;
1219 
1220  if (index < 0 || index >= dev->nbuffers)
1221  return -EINVAL;
1222 
1223  memset(buf, 0, sizeof(struct v4l2_buffer));
1224 
1225  buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1226  buf->index = index;
1227  buf->m.offset = index * dev->len_per_image;
1228  buf->bytesused = dev->view_size;
1229  buf->field = V4L2_FIELD_NONE;
1230  buf->memory = V4L2_MEMORY_MMAP;
1231  buf->length = dev->len_per_image;
1232  }
1233  break;
1234 
1235  case VIDIOC_QBUF:
1236  {
1237  struct v4l2_buffer *buf = arg;
1238 
1239  STK_DEBUG("VIDIOC_QBUF\n");
1240 
1241  if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1242  return -EINVAL;
1243 
1244  if (buf->memory != V4L2_MEMORY_MMAP)
1245  return -EINVAL;
1246 
1247  if (buf->index < 0 || buf->index >= dev->nbuffers)
1248  return -EINVAL;
1249 
1250  buf->flags |= V4L2_BUF_FLAG_QUEUED;
1251  buf->flags &= ~V4L2_BUF_FLAG_DONE;
1252  }
1253  break;
1254 
1255  case VIDIOC_DQBUF:
1256  {
1257  int ret;
1258  struct v4l2_buffer *buf = arg;
1259 
1260  STK_DEBUG("VIDIOC_DQBUF\n");
1261 
1262  if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1263  return -EINVAL;
1264 
1265  add_wait_queue(&dev->wait_frame, &wait);
1266 
1267  while (dev->full_frames == NULL) {
1268  if (dev->error_status) {
1269  remove_wait_queue(&dev->wait_frame, &wait);
1270  set_current_state(TASK_RUNNING);
1271 
1272  return -dev->error_status;
1273  }
1274 
1275  if (signal_pending(current)) {
1276  remove_wait_queue(&dev->wait_frame, &wait);
1277  set_current_state(TASK_RUNNING);
1278 
1279  return -ERESTARTSYS;
1280  }
1281 
1282  schedule();
1283  set_current_state(TASK_INTERRUPTIBLE);
1284  }
1285 
1286  remove_wait_queue(&dev->wait_frame, &wait);
1287  set_current_state(TASK_RUNNING);
1288 
1289  STK_DEBUG("VIDIOC_DQBUF : frame ready.\n");
1290 
1291  ret = stk11xx_handle_frame(dev);
1292 
1293  if (ret)
1294  return -EFAULT;
1295 
1296  buf->index = dev->fill_image;
1297  buf->bytesused = dev->view_size;
1298  buf->flags = V4L2_BUF_FLAG_MAPPED;
1299  buf->field = V4L2_FIELD_NONE;
1300  do_gettimeofday(&buf->timestamp);
1301  buf->sequence = 0;
1302  buf->memory = V4L2_MEMORY_MMAP;
1303  buf->m.offset = dev->fill_image * dev->len_per_image;
1304  buf->length = dev->len_per_image; //buf->bytesused;
1305 
1306  stk11xx_next_image(dev);
1307  }
1308  break;
1309 
1310  case VIDIOC_STREAMON:
1311  {
1312  STK_DEBUG("VIDIOC_STREAMON\n");
1313 
1314  usb_stk11xx_isoc_init(dev);
1315  }
1316  break;
1317 
1318  case VIDIOC_STREAMOFF:
1319  {
1320  STK_DEBUG("VIDIOC_STREAMOFF\n");
1321 
1323  }
1324  break;
1325 
1326  case VIDIOC_G_PARM:
1327  {
1328  struct v4l2_streamparm *sp = arg;
1329 
1330  STK_DEBUG("GET PARM %d\n", sp->type);
1331 
1332  if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1333  return -EINVAL;
1334 
1335  sp->parm.capture.capability = 0;
1336  sp->parm.capture.capturemode = 0;
1337  sp->parm.capture.timeperframe.numerator = 1;
1338  sp->parm.capture.timeperframe.denominator = 30;
1339  sp->parm.capture.readbuffers = 2;
1340  sp->parm.capture.extendedmode = 0;
1341  }
1342  break;
1343 
1344 
1345  case VIDIOC_G_AUDIO:
1346  STK_DEBUG("GET AUDIO\n");
1347  return -EINVAL;
1348  break;
1349 
1350  case VIDIOC_S_AUDIO:
1351  STK_DEBUG("SET AUDIO\n");
1352  return -EINVAL;
1353  break;
1354 
1355  case VIDIOC_S_TUNER:
1356  STK_DEBUG("SET TUNER\n");
1357  return -EINVAL;
1358  break;
1359 
1360  case VIDIOC_G_FBUF:
1361  case VIDIOC_S_FBUF:
1362  case VIDIOC_OVERLAY:
1363  return -EINVAL;
1364  break;
1365 
1366  case VIDIOC_G_TUNER:
1367  case VIDIOC_G_FREQUENCY:
1368  case VIDIOC_S_FREQUENCY:
1369  return -EINVAL;
1370  break;
1371 
1372  case VIDIOC_QUERYMENU:
1373  return -EINVAL;
1374  break;
1375 /*
1376  case VIDIOC_CROPCAP:
1377  {
1378  struct v4l2_cropcap cc;
1379 
1380  cc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1381  cc.pixelaspect.numerator = 1;
1382  cc.pixelaspect.denominator = 1;
1383  cc.bounds.top = 0;
1384  cc.bounds.left = 0;
1385  cc.bounds.width = 640;
1386  cc.bounds.height = 480;
1387  cc.defrect.top = 0;
1388  cc.defrect.left = 0;
1389  cc.defrect.width = 640;
1390  cc.defrect.height = 480;
1391 
1392  memcpy(arg, &cc, sizeof(cc));
1393  }
1394  break;
1395 */
1396  default:
1397  STK_DEBUG("IOCTL unknown !\n");
1398  return -ENOIOCTLCMD;
1399  }
1400 
1401  return 0;
1402 }
1403 
1404 
1416 static long v4l_stk11xx_ioctl(struct file *fp,
1417  unsigned int cmd, unsigned long arg)
1418 {
1419  long err;
1420  struct usb_stk11xx *dev;
1421  struct video_device *vdev;
1422 
1423  vdev = video_devdata(fp);
1424  dev = video_get_drvdata(video_devdata(fp));
1425 
1426  STK_DEBUG("v4l_stk11xx_ioctl %02X\n", (unsigned char) cmd);
1427 
1428  if (dev == NULL)
1429  return -EFAULT;
1430 
1431  if (vdev == NULL)
1432  return -EFAULT;
1433 
1434  mutex_lock(&dev->modlock);
1435 
1436  err = video_usercopy(fp, cmd, arg, v4l_stk11xx_do_ioctl);
1437 
1438  mutex_unlock(&dev->modlock);
1439 
1440  return err;
1441 }
1442 
1443 
1454 {
1455  int err;
1456 
1457  strcpy(dev->vdev->name, DRIVER_DESC);
1458 
1459  dev->vdev->dev = dev->interface->dev;
1460  dev->vdev->fops = &v4l_stk11xx_fops;
1461  dev->vdev->release = video_device_release;
1462  dev->vdev->minor = -1;
1463 
1464  video_set_drvdata(dev->vdev, dev);
1465 
1466  err = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1);
1467 
1468  if (err)
1469  STK_ERROR("Video register fail !\n");
1470  else
1471  STK_INFO("Syntek USB2.0 Camera is now controlling video device /dev/video%d\n", dev->vdev->minor);
1472 
1473  return err;
1474 }
1475 
1476 
1487 {
1488  STK_INFO("Syntek USB2.0 Camera release resources video device /dev/video%d\n", dev->vdev->minor);
1489 
1490  video_set_drvdata(dev->vdev, NULL);
1491  video_unregister_device(dev->vdev);
1492 
1493  return 0;
1494 }
1495 
1496 
1502 static struct v4l2_file_operations v4l_stk11xx_fops = {
1503  .owner = THIS_MODULE,
1504  .open = v4l_stk11xx_open,
1505  .release = v4l_stk11xx_release,
1506  .read = v4l_stk11xx_read,
1507  .poll = v4l_stk11xx_poll,
1508  .mmap = v4l_stk11xx_mmap,
1509  .ioctl = v4l_stk11xx_ioctl,
1510 };
1511 
usb_stk11xx::udev
struct usb_device * udev
Definition: stk11xx.h:303
usb_stk11xx::vframes_dumped
int vframes_dumped
Definition: stk11xx.h:326
stk11xx_video::hue
int hue
Definition: stk11xx.h:284
v4l_stk11xx_ioctl
static long v4l_stk11xx_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
Manage IOCTL.
Definition: stk11xx-v4l.c:1416
v4l_stk11xx_do_ioctl
static long v4l_stk11xx_do_ioctl(struct file *fp, unsigned int cmd, void __user *arg)
Manage IOCTL.
Definition: stk11xx-v4l.c:631
stk11xx_video::hflip
int hflip
Definition: stk11xx.h:285
dev_stk11xx_camera_on
int dev_stk11xx_camera_on(struct usb_stk11xx *dev)
This function switchs on the camera.
Definition: stk11xx-dev.c:241
dev_stk11xx_stop_stream
int dev_stk11xx_stop_stream(struct usb_stk11xx *dev)
This function sets the device to stop the stream.
Definition: stk11xx-dev.c:604
dev_stk11xx_camera_off
int dev_stk11xx_camera_off(struct usb_stk11xx *dev)
This function switchs off the camera.
Definition: stk11xx-dev.c:264
stk11xx_video::brightness
int brightness
Definition: stk11xx.h:278
stk11xx_coord
Definition: stk11xx.h:267
v4l_stk11xx_mmap
static int v4l_stk11xx_mmap(struct file *fp, struct vm_area_struct *vma)
Memory map.
Definition: stk11xx-v4l.c:547
stk11xx_coord::x
int x
Definition: stk11xx.h:268
v4l_stk11xx_release
static int v4l_stk11xx_release(struct file *fp)
Release an opened file.
Definition: stk11xx-v4l.c:363
STK_STREAM
#define STK_STREAM(str, args...)
Definition: stk11xx.h:172
stk11xx_controls
static struct v4l2_queryctrl stk11xx_controls[]
Definition: stk11xx-v4l.c:77
dev_stk11xx_start_stream
int dev_stk11xx_start_stream(struct usb_stk11xx *dev)
This function sets the device to start the stream.
Definition: stk11xx-dev.c:501
stk11xx.h
Driver for Syntek USB video camera.
dev_stk11xx_reconf_camera
int dev_stk11xx_reconf_camera(struct usb_stk11xx *dev)
Reconfigure the camera before the stream.
Definition: stk11xx-dev.c:552
STK_DEBUG
#define STK_DEBUG(str, args...)
Definition: stk11xx.h:149
DRIVER_VERSION_NUM
#define DRIVER_VERSION_NUM
Definition: stk11xx.h:40
stk11xx_video::colour
int colour
Definition: stk11xx.h:281
STK11XX_MAX_IMAGES
#define STK11XX_MAX_IMAGES
Definition: stk11xx.h:96
usb_stk11xx::webcam_type
int webcam_type
Definition: stk11xx.h:308
v4l_stk11xx_register_video_device
int v4l_stk11xx_register_video_device(struct usb_stk11xx *dev)
Register the video device.
Definition: stk11xx-v4l.c:1453
STK_ERROR
#define STK_ERROR(str, args...)
Definition: stk11xx.h:147
dev_stk11xx_camera_settings
int dev_stk11xx_camera_settings(struct usb_stk11xx *dev)
This function permits to modify the settings of the camera.
Definition: stk11xx-dev.c:342
v4l_stk11xx_open
static int v4l_stk11xx_open(struct file *fp)
Open the video device.
Definition: stk11xx-v4l.c:273
dev_stk11xx_camera_asleep
int dev_stk11xx_camera_asleep(struct usb_stk11xx *dev)
Wake-up the camera.
Definition: stk11xx-dev.c:287
stk11xx_video::vflip
int vflip
Definition: stk11xx.h:286
usb_stk11xx::interface
struct usb_interface * interface
Definition: stk11xx.h:304
usb_stk11xx_isoc_init
int usb_stk11xx_isoc_init(struct usb_stk11xx *dev)
Initilize an isochronous pipe.
Definition: stk11xx-usb.c:124
STK11XX_VGA
@ STK11XX_VGA
Definition: stk11xx.h:197
stk11xx_image_buf::offset
unsigned long offset
Definition: stk11xx.h:259
stk11xx_free_buffers
int stk11xx_free_buffers(struct usb_stk11xx *dev)
Release all buffers.
Definition: stk11xx-buf.c:287
stk11xx_handle_frame
int stk11xx_handle_frame(struct usb_stk11xx *dev)
Handler frame.
Definition: stk11xx-buf.c:407
usb_stk11xx::vdev
struct video_device * vdev
Definition: stk11xx.h:302
stk11xx_clear_buffers
int stk11xx_clear_buffers(struct usb_stk11xx *dev)
Clear current buffers.
Definition: stk11xx-buf.c:270
stk11xx_video::palette
int palette
Definition: stk11xx.h:283
v4l_stk11xx_read
static ssize_t v4l_stk11xx_read(struct file *fp, char __user *buf, size_t count, loff_t *f_pos)
Read the video device.
Definition: stk11xx-v4l.c:410
DRIVER_DESC
#define DRIVER_DESC
Definition: stk11xx.h:41
STK11XX_SXGA
@ STK11XX_SXGA
Definition: stk11xx.h:198
usb_stk11xx::vopen
int vopen
Definition: stk11xx.h:323
usb_stk11xx::vframes_error
int vframes_error
Definition: stk11xx.h:325
stk11xx_video::depth
int depth
Definition: stk11xx.h:282
v4l_stk11xx_select_video_mode
int v4l_stk11xx_select_video_mode(struct usb_stk11xx *dev, int width, int height)
Select a video mode.
Definition: stk11xx-v4l.c:146
dev_stk11xx_init_camera
int dev_stk11xx_init_camera(struct usb_stk11xx *dev)
This function initializes the device for the stream.
Definition: stk11xx-dev.c:115
v4l_stk11xx_poll
static unsigned int v4l_stk11xx_poll(struct file *fp, poll_table *wait)
Polling function.
Definition: stk11xx-v4l.c:509
STK_INFO
#define STK_INFO(str, args...)
Definition: stk11xx.h:146
usb_stk11xx::wait_frame
wait_queue_head_t wait_frame
Definition: stk11xx.h:331
stk11xx_next_image
void stk11xx_next_image(struct usb_stk11xx *dev)
Prepare the next image.
Definition: stk11xx-buf.c:334
stk11xx_reset_buffers
int stk11xx_reset_buffers(struct usb_stk11xx *dev)
Reset all ISOC buffers.
Definition: stk11xx-buf.c:221
stk11xx_allocate_buffers
int stk11xx_allocate_buffers(struct usb_stk11xx *dev)
Allocate all ISOC buffers.
Definition: stk11xx-buf.c:128
stk11xx_video::contrast
int contrast
Definition: stk11xx.h:279
usb_stk11xx
Definition: stk11xx.h:301
v4l_stk11xx_fops
static struct v4l2_file_operations v4l_stk11xx_fops
Definition: stk11xx-v4l.c:52
usb_stk11xx::vsettings
struct stk11xx_video vsettings
Definition: stk11xx.h:319
usb_stk11xx_isoc_cleanup
void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *dev)
Clean-up all the ISOC buffers.
Definition: stk11xx-usb.c:431
v4l_stk11xx_unregister_video_device
int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *dev)
Unregister the video device.
Definition: stk11xx-v4l.c:1486
usb_stk11xx::visoc_errors
int visoc_errors
Definition: stk11xx.h:324
stk11xx_video::whiteness
int whiteness
Definition: stk11xx.h:280
stk11xx_coord::y
int y
Definition: stk11xx.h:269
usb_stk11xx::modlock
struct mutex modlock
Definition: stk11xx.h:332
stk11xx_image_sizes
const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES]
Definition: stk11xx-v4l.c:59