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> 45 #include <linux/usb.h> 46 #include <media/v4l2-common.h> 47 #include <media/v4l2-ioctl.h> 80 .id = V4L2_CID_BRIGHTNESS,
81 .type = V4L2_CTRL_TYPE_INTEGER,
86 .default_value = 0x7f00,
89 .id = V4L2_CID_WHITENESS,
90 .type = V4L2_CTRL_TYPE_INTEGER,
95 .default_value = 0x7f00,
98 .id = V4L2_CID_SATURATION,
99 .type = V4L2_CTRL_TYPE_INTEGER,
100 .name =
"Saturation",
104 .default_value = 0x7f00,
107 .id = V4L2_CID_CONTRAST,
108 .type = V4L2_CTRL_TYPE_INTEGER,
113 .default_value = 0x7f00,
117 .type = V4L2_CTRL_TYPE_INTEGER,
122 .default_value = 0x7f00,
125 .id = V4L2_CID_HFLIP,
126 .type = V4L2_CTRL_TYPE_BOOLEAN,
127 .name =
"Flip Horizontally",
134 .id = V4L2_CID_VFLIP,
135 .type = V4L2_CTRL_TYPE_BOOLEAN,
136 .name =
"Flip Vertically",
166 if ((width < stk11xx_image_sizes[0].x)
167 || (height < stk11xx_image_sizes[0].y)) {
168 width = stk11xx_image_sizes[0].
x;
169 height = stk11xx_image_sizes[0].
y;
175 if ((width > stk11xx_image_sizes[STK11XX_1280x1024].x)
176 || (height > stk11xx_image_sizes[STK11XX_1280x1024].y)) {
177 width = stk11xx_image_sizes[STK11XX_1280x1024].
x;
178 height = stk11xx_image_sizes[STK11XX_1280x1024].
y;
183 if ((width > stk11xx_image_sizes[STK11XX_640x480].x)
184 || (height > stk11xx_image_sizes[STK11XX_640x480].y)) {
185 width = stk11xx_image_sizes[STK11XX_640x480].
x;
186 height = stk11xx_image_sizes[STK11XX_640x480].
y;
191 if (! (((width == 720) && (height==576))
192 || ((width == 720) && (height==480))
193 || ((width == 640) && (height==480)))) {
207 for (i=0, find=0; i<=STK11XX_1280x1024; i++) {
208 if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
214 for (i=0, find=0; i<=STK11XX_640x480; i++) {
215 if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
221 for (i=0, find=0; i<=STK11XX_720x576; i++) {
222 if (stk11xx_image_sizes[i].x <= width && stk11xx_image_sizes[i].y <= height)
232 dev->resolution = find;
234 STK_DEBUG(
"Set mode %d [%dx%d]\n", dev->resolution,
235 stk11xx_image_sizes[dev->resolution].
x, stk11xx_image_sizes[dev->resolution].
y);
239 dev->view.
y = height;
245 dev->image.
x = stk11xx_image_sizes[dev->resolution].
x;
246 dev->image.
y = stk11xx_image_sizes[dev->resolution].
y;
247 dev->frame_size = dev->image.
x * dev->image.
y;
250 switch (dev->resolution) {
253 case STK11XX_160x120:
254 case STK11XX_213x160:
255 case STK11XX_320x240:
256 case STK11XX_640x480:
257 dev->image.
x = stk11xx_image_sizes[STK11XX_640x480].
x;
258 dev->image.
y = stk11xx_image_sizes[STK11XX_640x480].
y;
259 dev->frame_size = dev->image.
x * dev->image.
y;
262 case STK11XX_720x576:
263 case STK11XX_800x600:
264 case STK11XX_1024x768:
265 case STK11XX_1280x1024:
266 dev->image.
x = stk11xx_image_sizes[STK11XX_1280x1024].
x;
267 dev->image.
y = stk11xx_image_sizes[STK11XX_1280x1024].
y;
268 dev->frame_size = dev->image.
x * dev->image.
y;
276 case STK11XX_PALETTE_RGB24:
277 case STK11XX_PALETTE_BGR24:
278 dev->view_size = 3 * dev->view.
x * dev->view.
y;
279 dev->image_size = 3 * dev->frame_size;
282 case STK11XX_PALETTE_RGB32:
283 case STK11XX_PALETTE_BGR32:
284 dev->view_size = 3 * dev->view.
x * dev->view.
y;
285 dev->image_size = 4 * dev->frame_size;
288 case STK11XX_PALETTE_UYVY:
289 case STK11XX_PALETTE_YUYV:
290 dev->view_size = 2 * dev->view.
x * dev->view.
y;
291 dev->image_size = 2 * dev->frame_size;
313 struct video_device *vdev;
315 vdev = video_devdata(fp);
316 dev = video_get_drvdata(video_devdata(fp));
319 STK_ERROR(
"Device not initialized !!!\n");
326 STK_DEBUG(
"Device is busy, someone is using the device\n");
335 STK_ERROR(
"Failed to allocate buffer memory !\n");
346 dev->error_status = 0;
367 STK_ERROR(
"Failed to init ISOC stuff !\n");
384 fp->private_data = vdev;
405 dev = video_get_drvdata(video_devdata(fp));
408 STK_ERROR(
"v4l_release called on closed device\n");
447 size_t count, loff_t *f_pos)
449 int noblock = fp->f_flags & O_NONBLOCK;
452 struct video_device *vdev;
455 void *image_buffer_addr;
457 DECLARE_WAITQUEUE(wait, current);
459 vdev = video_devdata(fp);
460 dev = video_get_drvdata(video_devdata(fp));
462 STK_STREAM(
"Read vdev=0x%p, buf=0x%p, count=%zd\n", vdev, buf, count);
472 if (dev->image_read_pos == 0) {
475 while (dev->full_frames == NULL) {
476 if (dev->error_status) {
478 set_current_state(TASK_RUNNING);
480 return -dev->error_status ;
485 set_current_state(TASK_RUNNING);
490 if (signal_pending(current)) {
492 set_current_state(TASK_RUNNING);
498 set_current_state(TASK_INTERRUPTIBLE);
502 set_current_state(TASK_RUNNING);
510 bytes_to_read = dev->view_size;
512 if (count + dev->image_read_pos > bytes_to_read)
513 count = bytes_to_read - dev->image_read_pos;
515 image_buffer_addr = dev->image_data;
516 image_buffer_addr += dev->images[dev->fill_image].
offset;
517 image_buffer_addr += dev->image_read_pos;
519 if (copy_to_user(buf, image_buffer_addr, count)) {
524 dev->image_read_pos += count;
526 if (dev->image_read_pos >= bytes_to_read) {
527 dev->image_read_pos = 0;
548 struct video_device *vdev;
550 vdev = video_devdata(fp);
551 dev = video_get_drvdata(video_devdata(fp));
563 if (dev->error_status)
566 if (dev->full_frames != NULL)
567 return (POLLIN | POLLRDNORM);
594 dev = video_get_drvdata(video_devdata(fp));
598 start = vma->vm_start;
599 size = vma->vm_end - vma->vm_start;
602 for (i=0; i<dev->nbuffers; i++) {
603 pos = dev->images[i].
offset;
605 if ((pos >> PAGE_SHIFT) == vma->vm_pgoff)
616 unsigned long total_size;
618 total_size = dev->nbuffers * dev->len_per_image;
620 if (size != dev->len_per_image && size != total_size) {
621 STK_ERROR(
"Wrong size (%lu) needed to be len_per_image=%d or total_size=%lu\n",
622 size, dev->len_per_image, total_size);
627 else if (size > dev->len_per_image)
630 vma->vm_flags |= VM_IO;
632 pos = (
unsigned long) dev->image_data;
635 page = vmalloc_to_pfn((
void *) pos);
637 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
643 if (size > PAGE_SIZE)
665 unsigned int cmd,
void __user *arg)
669 DECLARE_WAITQUEUE(wait, current);
671 dev = video_get_drvdata(video_devdata(fp));
673 #if (CONFIG_STK11XX_DEBUG == 1) 674 v4l_printk_ioctl(cmd);
678 case VIDIOC_QUERYCAP:
680 struct v4l2_capability *cap = arg;
684 memset(cap, 0,
sizeof(*cap));
685 strlcpy(cap->driver,
"stk11xx",
sizeof(cap->driver));
687 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
690 if (usb_make_path(dev->
udev, cap->bus_info,
sizeof(cap->bus_info)) < 0)
691 strlcpy(cap->bus_info, dev->
vdev->name,
sizeof(cap->bus_info));
695 case VIDIOC_ENUMINPUT:
697 struct v4l2_input *i = arg;
699 STK_DEBUG(
"VIDIOC_ENUMINPUT %d\n", i->index);
704 strlcpy(i->name,
"USB",
sizeof(i->name));
712 strlcpy(i->name,
"Input1",
sizeof(i->name));
715 strlcpy(i->name,
"Input2",
sizeof(i->name));
718 strlcpy(i->name,
"Input3",
sizeof(i->name));
721 strlcpy(i->name,
"Input4",
sizeof(i->name));
726 i->type = V4L2_INPUT_TYPE_CAMERA;
740 struct v4l2_input *i = arg;
755 case VIDIOC_QUERYCTRL:
759 struct v4l2_queryctrl *c = arg;
761 STK_DEBUG(
"VIDIOC_QUERYCTRL id = %d\n", c->id);
765 for (i=0; i<nbr; i++) {
771 case V4L2_CID_BRIGHTNESS:
772 c->default_value = dev->
vsettings.default_brightness;
774 case V4L2_CID_WHITENESS:
775 c->default_value = dev->
vsettings.default_whiteness;
777 case V4L2_CID_SATURATION:
778 c->default_value = dev->
vsettings.default_colour;
780 case V4L2_CID_CONTRAST:
781 c->default_value = dev->
vsettings.default_contrast;
784 c->default_value = dev->
vsettings.default_hflip;
787 c->default_value = dev->
vsettings.default_vflip;
801 struct v4l2_control *c = arg;
806 case V4L2_CID_BRIGHTNESS:
810 case V4L2_CID_WHITENESS:
818 case V4L2_CID_SATURATION:
822 case V4L2_CID_CONTRAST:
843 struct v4l2_control *c = arg;
845 STK_DEBUG(
"SET CTRL id=%d value=%d\n", c->id, c->value);
848 case V4L2_CID_BRIGHTNESS:
856 case V4L2_CID_SATURATION:
860 case V4L2_CID_CONTRAST:
880 case VIDIOC_ENUM_FMT:
883 struct v4l2_fmtdesc *fmtd = arg;
885 STK_DEBUG(
"VIDIOC_ENUM_FMT %d\n", fmtd->index);
889 memset(fmtd, 0,
sizeof(*fmtd));
891 fmtd->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
897 fmtd->pixelformat = V4L2_PIX_FMT_RGB24;
899 strcpy(fmtd->description,
"rgb24");
904 fmtd->pixelformat = V4L2_PIX_FMT_RGB32;
906 strcpy(fmtd->description,
"rgb32");
911 fmtd->pixelformat = V4L2_PIX_FMT_BGR24;
913 strcpy(fmtd->description,
"bgr24");
918 fmtd->pixelformat = V4L2_PIX_FMT_BGR32;
920 strcpy(fmtd->description,
"bgr32");
925 fmtd->pixelformat = V4L2_PIX_FMT_UYVY;
927 strcpy(fmtd->description,
"uyvy");
932 fmtd->pixelformat = V4L2_PIX_FMT_YUYV;
934 strcpy(fmtd->description,
"yuyv");
945 struct v4l2_format *fmtd = arg;
946 struct v4l2_pix_format pix_format;
950 if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
953 pix_format.width = dev->view.
x;
954 pix_format.height = dev->view.
y;
955 pix_format.field = V4L2_FIELD_NONE;
956 pix_format.colorspace = V4L2_COLORSPACE_SRGB;
960 case STK11XX_PALETTE_RGB24:
961 pix_format.pixelformat = V4L2_PIX_FMT_RGB24;
962 pix_format.sizeimage = pix_format.width * pix_format.height * 3;
963 pix_format.bytesperline = 3 * pix_format.width;
966 case STK11XX_PALETTE_RGB32:
967 pix_format.pixelformat = V4L2_PIX_FMT_RGB32;
968 pix_format.sizeimage = pix_format.width * pix_format.height * 4;
969 pix_format.bytesperline = 4 * pix_format.width;
972 case STK11XX_PALETTE_BGR24:
973 pix_format.pixelformat = V4L2_PIX_FMT_BGR24;
974 pix_format.sizeimage = pix_format.width * pix_format.height * 3;
975 pix_format.bytesperline = 3 * pix_format.width;
978 case STK11XX_PALETTE_BGR32:
979 pix_format.pixelformat = V4L2_PIX_FMT_BGR32;
980 pix_format.sizeimage = pix_format.width * pix_format.height * 4;
981 pix_format.bytesperline = 4 * pix_format.width;
984 case STK11XX_PALETTE_UYVY:
985 pix_format.pixelformat = V4L2_PIX_FMT_UYVY;
986 pix_format.sizeimage = pix_format.width * pix_format.height * 2;
987 pix_format.bytesperline = 2 * pix_format.width;
990 case STK11XX_PALETTE_YUYV:
991 pix_format.pixelformat = V4L2_PIX_FMT_YUYV;
992 pix_format.sizeimage = pix_format.width * pix_format.height * 2;
993 pix_format.bytesperline = 2 * pix_format.width;
997 pix_format.pixelformat = 0;
998 pix_format.sizeimage = 0;
999 pix_format.bytesperline = 0;
1002 memcpy(&(fmtd->fmt.pix), &pix_format,
sizeof(pix_format));
1006 case VIDIOC_TRY_FMT:
1008 struct v4l2_format *fmtd = arg;
1012 if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1017 if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_1280x1024].
x)
1018 fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_1280x1024].
x;
1019 else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].
x)
1020 fmtd->fmt.pix.width = stk11xx_image_sizes[0].
x;
1022 if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_1280x1024].
y)
1023 fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_1280x1024].
y;
1024 else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].
y)
1025 fmtd->fmt.pix.height = stk11xx_image_sizes[0].
y;
1029 if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_720x576].
x)
1030 fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_720x576].
x;
1031 else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].
x)
1032 fmtd->fmt.pix.width = stk11xx_image_sizes[0].
x;
1034 if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_720x576].
y)
1035 fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_720x576].
y;
1036 else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].
y)
1037 fmtd->fmt.pix.height = stk11xx_image_sizes[0].
y;
1041 if (fmtd->fmt.pix.width > stk11xx_image_sizes[STK11XX_640x480].
x)
1042 fmtd->fmt.pix.width = stk11xx_image_sizes[STK11XX_640x480].
x;
1043 else if (fmtd->fmt.pix.width < stk11xx_image_sizes[0].
x)
1044 fmtd->fmt.pix.width = stk11xx_image_sizes[0].
x;
1046 if (fmtd->fmt.pix.height > stk11xx_image_sizes[STK11XX_640x480].
y)
1047 fmtd->fmt.pix.height = stk11xx_image_sizes[STK11XX_640x480].
y;
1048 else if (fmtd->fmt.pix.height < stk11xx_image_sizes[0].
y)
1049 fmtd->fmt.pix.height = stk11xx_image_sizes[0].
y;
1054 fmtd->fmt.pix.field = V4L2_FIELD_NONE;
1055 fmtd->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
1056 fmtd->fmt.pix.priv = 0;
1058 switch (fmtd->fmt.pix.pixelformat) {
1059 case V4L2_PIX_FMT_RGB24:
1060 case V4L2_PIX_FMT_BGR24:
1062 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
1063 fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
1066 case V4L2_PIX_FMT_RGB32:
1067 case V4L2_PIX_FMT_BGR32:
1069 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
1070 fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
1073 case V4L2_PIX_FMT_UYVY:
1074 case V4L2_PIX_FMT_YUYV:
1076 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1077 fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1088 struct v4l2_format *fmtd = arg;
1090 STK_DEBUG(
"SET FMT %d : %d\n", fmtd->type, fmtd->fmt.pix.pixelformat);
1092 if (fmtd->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1095 fmtd->fmt.pix.field = V4L2_FIELD_NONE;
1096 fmtd->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
1097 fmtd->fmt.pix.priv = 0;
1099 switch (fmtd->fmt.pix.pixelformat) {
1100 case V4L2_PIX_FMT_RGB24:
1103 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
1104 fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
1107 case V4L2_PIX_FMT_RGB32:
1110 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
1111 fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
1114 case V4L2_PIX_FMT_BGR24:
1117 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 3;
1118 fmtd->fmt.pix.bytesperline = 3 * fmtd->fmt.pix.width;
1121 case V4L2_PIX_FMT_BGR32:
1124 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 4;
1125 fmtd->fmt.pix.bytesperline = 4 * fmtd->fmt.pix.width;
1128 case V4L2_PIX_FMT_UYVY:
1131 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1132 fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1135 case V4L2_PIX_FMT_YUYV:
1138 fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.width * fmtd->fmt.pix.height * 2;
1139 fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
1146 STK_DEBUG(
"Set width=%d, height=%d\n", fmtd->fmt.pix.width, fmtd->fmt.pix.height);
1161 STK_ERROR(
"Select video mode failed !\n");
1184 case VIDIOC_QUERYSTD:
1193 v4l2_std_id *std = arg;
1197 *std = V4L2_STD_UNKNOWN;
1203 v4l2_std_id *std = arg;
1207 if (*std != V4L2_STD_UNKNOWN)
1212 case VIDIOC_ENUMSTD:
1214 struct v4l2_standard *std = arg;
1218 if (std->index != 0)
1221 std->id = V4L2_STD_UNKNOWN;
1222 strncpy(std->name,
"webcam",
sizeof(std->name));
1227 case VIDIOC_REQBUFS:
1230 struct v4l2_requestbuffers *rb = arg;
1232 if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1235 if (rb->memory != V4L2_MEMORY_MMAP)
1238 nbuffers = rb->count;
1242 else if (nbuffers > dev->nbuffers)
1243 nbuffers = dev->nbuffers;
1245 rb->count = dev->nbuffers;
1249 case VIDIOC_QUERYBUF:
1252 struct v4l2_buffer *buf = arg;
1254 STK_DEBUG(
"QUERY BUFFERS %d %d\n", buf->index, dev->nbuffers);
1256 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1259 if (buf->memory != V4L2_MEMORY_MMAP)
1264 if (index < 0 || index >= dev->nbuffers)
1267 memset(buf, 0,
sizeof(
struct v4l2_buffer));
1269 buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1271 buf->m.offset = index * dev->len_per_image;
1272 buf->bytesused = dev->view_size;
1273 buf->field = V4L2_FIELD_NONE;
1274 buf->memory = V4L2_MEMORY_MMAP;
1275 buf->length = dev->len_per_image;
1281 struct v4l2_buffer *buf = arg;
1285 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1288 if (buf->memory != V4L2_MEMORY_MMAP)
1291 if (buf->index < 0 || buf->index >= dev->nbuffers)
1294 buf->flags |= V4L2_BUF_FLAG_QUEUED;
1295 buf->flags &= ~V4L2_BUF_FLAG_DONE;
1302 struct v4l2_buffer *buf = arg;
1306 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1311 while (dev->full_frames == NULL) {
1312 if (dev->error_status) {
1314 set_current_state(TASK_RUNNING);
1316 return -dev->error_status;
1319 if (signal_pending(current)) {
1321 set_current_state(TASK_RUNNING);
1323 return -ERESTARTSYS;
1327 set_current_state(TASK_INTERRUPTIBLE);
1331 set_current_state(TASK_RUNNING);
1333 STK_DEBUG(
"VIDIOC_DQBUF : frame ready.\n");
1340 buf->index = dev->fill_image;
1341 buf->bytesused = dev->view_size;
1342 buf->flags = V4L2_BUF_FLAG_MAPPED;
1343 buf->field = V4L2_FIELD_NONE;
1344 do_gettimeofday(&buf->timestamp);
1346 buf->memory = V4L2_MEMORY_MMAP;
1347 buf->m.offset = dev->fill_image * dev->len_per_image;
1348 buf->length = dev->len_per_image;
1354 case VIDIOC_STREAMON:
1362 case VIDIOC_STREAMOFF:
1372 struct v4l2_streamparm *sp = arg;
1376 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1379 sp->parm.capture.capability = 0;
1380 sp->parm.capture.capturemode = 0;
1381 sp->parm.capture.timeperframe.numerator = 1;
1382 sp->parm.capture.timeperframe.denominator = 30;
1383 sp->parm.capture.readbuffers = 2;
1384 sp->parm.capture.extendedmode = 0;
1389 case VIDIOC_G_AUDIO:
1394 case VIDIOC_S_AUDIO:
1399 case VIDIOC_S_TUNER:
1406 case VIDIOC_OVERLAY:
1410 case VIDIOC_G_TUNER:
1411 case VIDIOC_G_FREQUENCY:
1412 case VIDIOC_S_FREQUENCY:
1416 case VIDIOC_QUERYMENU:
1442 return -ENOIOCTLCMD;
1461 unsigned int cmd,
unsigned long arg)
1465 struct video_device *vdev;
1467 vdev = video_devdata(fp);
1468 dev = video_get_drvdata(video_devdata(fp));
1470 STK_DEBUG(
"v4l_stk11xx_ioctl %02X\n", (
unsigned char) cmd);
1505 dev->
vdev->release = video_device_release;
1506 dev->
vdev->minor = -1;
1508 video_set_drvdata(dev->
vdev, dev);
1510 err = video_register_device(dev->
vdev, VFL_TYPE_GRABBER, -1);
1515 STK_INFO(
"Syntek USB2.0 Camera is now controlling video device /dev/video%d\n", dev->
vdev->minor);
1532 STK_INFO(
"Syntek USB2.0 Camera release resources video device /dev/video%d\n", dev->
vdev->minor);
1534 video_set_drvdata(dev->
vdev, NULL);
1535 video_unregister_device(dev->
vdev);
1547 .owner = THIS_MODULE,
1554 #if defined(CONFIG_COMPAT) && defined(v4l_compat_ioctl32) 1555 .compat_ioctl = v4l_compat_ioctl32,
int usb_stk11xx_isoc_init(struct usb_stk11xx *dev)
Initilize an isochronous pipe.
int dev_stk11xx_camera_asleep(struct usb_stk11xx *dev)
Wake-up the camera.
int stk11xx_reset_buffers(struct usb_stk11xx *dev)
Reset all ISOC buffers.
int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *dev)
Unregister the video device.
int dev_stk11xx_camera_off(struct usb_stk11xx *dev)
This function switchs off the camera.
static long v4l_stk11xx_do_ioctl(struct file *fp, unsigned int cmd, void __user *arg)
Manage IOCTL.
int dev_stk11xx_camera_on(struct usb_stk11xx *dev)
This function switchs on the camera.
int dev_stk11xx_camera_settings(struct usb_stk11xx *dev)
This function permits to modify the settings of the camera.
int dev_stk11xx_start_stream(struct usb_stk11xx *dev)
This function sets the device to start the stream.
int dev_stk11xx_init_camera(struct usb_stk11xx *dev)
This function initializes the device for the stream.
#define STK_DEBUG(str, args...)
wait_queue_head_t wait_frame
#define STK_ERROR(str, args...)
static struct v4l2_file_operations v4l_stk11xx_fops
void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *dev)
Clean-up all the ISOC buffers.
int dev_stk11xx_stop_stream(struct usb_stk11xx *dev)
This function sets the device to stop the stream.
static int v4l_stk11xx_release(struct file *fp)
Release an opened file.
#define STK11XX_MAX_IMAGES
#define STK_STREAM(str, args...)
struct stk11xx_video vsettings
static long v4l_stk11xx_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
Manage IOCTL.
void stk11xx_next_image(struct usb_stk11xx *dev)
Prepare the next image.
const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES]
#define DRIVER_VERSION_NUM
static unsigned int v4l_stk11xx_poll(struct file *fp, poll_table *wait)
Polling function.
int stk11xx_clear_buffers(struct usb_stk11xx *dev)
Clear current buffers.
int dev_stk11xx_reconf_camera(struct usb_stk11xx *dev)
Reconfigure the camera before the stream.
static ssize_t v4l_stk11xx_read(struct file *fp, char __user *buf, size_t count, loff_t *f_pos)
Read the video device.
struct video_device * vdev
int v4l_stk11xx_select_video_mode(struct usb_stk11xx *dev, int width, int height)
Select a video mode.
static int v4l_stk11xx_mmap(struct file *fp, struct vm_area_struct *vma)
Memory map.
static int v4l_stk11xx_open(struct file *fp)
Open the video device.
int stk11xx_handle_frame(struct usb_stk11xx *dev)
Handler frame.
#define STK_INFO(str, args...)
static struct v4l2_queryctrl stk11xx_controls[]
struct usb_interface * interface
Driver for Syntek USB video camera.
int stk11xx_free_buffers(struct usb_stk11xx *dev)
Release all buffers.
int v4l_stk11xx_register_video_device(struct usb_stk11xx *dev)
Register the video device.
int stk11xx_allocate_buffers(struct usb_stk11xx *dev)
Allocate all ISOC buffers.