aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/stk-webcam.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/stk-webcam.c')
-rw-r--r--drivers/media/video/stk-webcam.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index f308c38d744f..ad36af30e099 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -34,6 +34,7 @@
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/videodev2.h> 35#include <linux/videodev2.h>
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
37 38
38#include "stk-webcam.h" 39#include "stk-webcam.h"
39 40
@@ -340,17 +341,19 @@ static int stk_create_sysfs_files(struct video_device *vdev)
340{ 341{
341 int ret; 342 int ret;
342 343
343 ret = video_device_create_file(vdev, &dev_attr_brightness); 344 ret = device_create_file(&vdev->dev, &dev_attr_brightness);
344 ret += video_device_create_file(vdev, &dev_attr_hflip); 345 ret += device_create_file(&vdev->dev, &dev_attr_hflip);
345 ret += video_device_create_file(vdev, &dev_attr_vflip); 346 ret += device_create_file(&vdev->dev, &dev_attr_vflip);
347 if (ret)
348 STK_WARNING("Could not create sysfs files\n");
346 return ret; 349 return ret;
347} 350}
348 351
349static void stk_remove_sysfs_files(struct video_device *vdev) 352static void stk_remove_sysfs_files(struct video_device *vdev)
350{ 353{
351 video_device_remove_file(vdev, &dev_attr_brightness); 354 device_remove_file(&vdev->dev, &dev_attr_brightness);
352 video_device_remove_file(vdev, &dev_attr_hflip); 355 device_remove_file(&vdev->dev, &dev_attr_hflip);
353 video_device_remove_file(vdev, &dev_attr_vflip); 356 device_remove_file(&vdev->dev, &dev_attr_vflip);
354} 357}
355 358
356#else 359#else
@@ -442,18 +445,19 @@ static void stk_isoc_handler(struct urb *urb)
442 fb->v4lbuf.bytesused = 0; 445 fb->v4lbuf.bytesused = 0;
443 fill = fb->buffer; 446 fill = fb->buffer;
444 } else if (fb->v4lbuf.bytesused == dev->frame_size) { 447 } else if (fb->v4lbuf.bytesused == dev->frame_size) {
445 list_move_tail(dev->sio_avail.next, 448 if (list_is_singular(&dev->sio_avail)) {
446 &dev->sio_full); 449 /* Always reuse the last buffer */
447 wake_up(&dev->wait_frame); 450 fb->v4lbuf.bytesused = 0;
448 if (list_empty(&dev->sio_avail)) { 451 fill = fb->buffer;
449 (void) (printk_ratelimit() && 452 } else {
450 STK_ERROR("No buffer available\n")); 453 list_move_tail(dev->sio_avail.next,
451 goto resubmit; 454 &dev->sio_full);
455 wake_up(&dev->wait_frame);
456 fb = list_first_entry(&dev->sio_avail,
457 struct stk_sio_buffer, list);
458 fb->v4lbuf.bytesused = 0;
459 fill = fb->buffer;
452 } 460 }
453 fb = list_first_entry(&dev->sio_avail,
454 struct stk_sio_buffer, list);
455 fb->v4lbuf.bytesused = 0;
456 fill = fb->buffer;
457 } 461 }
458 } else { 462 } else {
459 framelen -= 4; 463 framelen -= 4;
@@ -1327,20 +1331,7 @@ static struct file_operations v4l_stk_fops = {
1327 .llseek = no_llseek 1331 .llseek = no_llseek
1328}; 1332};
1329 1333
1330static void stk_v4l_dev_release(struct video_device *vd) 1334static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = {
1331{
1332}
1333
1334static struct video_device stk_v4l_data = {
1335 .name = "stkwebcam",
1336 .type = VFL_TYPE_GRABBER,
1337 .type2 = VID_TYPE_CAPTURE,
1338 .minor = -1,
1339 .tvnorms = V4L2_STD_UNKNOWN,
1340 .current_norm = V4L2_STD_UNKNOWN,
1341 .fops = &v4l_stk_fops,
1342 .release = stk_v4l_dev_release,
1343
1344 .vidioc_querycap = stk_vidioc_querycap, 1335 .vidioc_querycap = stk_vidioc_querycap,
1345 .vidioc_enum_fmt_vid_cap = stk_vidioc_enum_fmt_vid_cap, 1336 .vidioc_enum_fmt_vid_cap = stk_vidioc_enum_fmt_vid_cap,
1346 .vidioc_try_fmt_vid_cap = stk_vidioc_try_fmt_vid_cap, 1337 .vidioc_try_fmt_vid_cap = stk_vidioc_try_fmt_vid_cap,
@@ -1362,6 +1353,20 @@ static struct video_device stk_v4l_data = {
1362 .vidioc_g_parm = stk_vidioc_g_parm, 1353 .vidioc_g_parm = stk_vidioc_g_parm,
1363}; 1354};
1364 1355
1356static void stk_v4l_dev_release(struct video_device *vd)
1357{
1358}
1359
1360static struct video_device stk_v4l_data = {
1361 .name = "stkwebcam",
1362 .minor = -1,
1363 .tvnorms = V4L2_STD_UNKNOWN,
1364 .current_norm = V4L2_STD_UNKNOWN,
1365 .fops = &v4l_stk_fops,
1366 .ioctl_ops = &v4l_stk_ioctl_ops,
1367 .release = stk_v4l_dev_release,
1368};
1369
1365 1370
1366static int stk_register_video_device(struct stk_camera *dev) 1371static int stk_register_video_device(struct stk_camera *dev)
1367{ 1372{
@@ -1369,7 +1374,7 @@ static int stk_register_video_device(struct stk_camera *dev)
1369 1374
1370 dev->vdev = stk_v4l_data; 1375 dev->vdev = stk_v4l_data;
1371 dev->vdev.debug = debug; 1376 dev->vdev.debug = debug;
1372 dev->vdev.dev = &dev->interface->dev; 1377 dev->vdev.parent = &dev->interface->dev;
1373 dev->vdev.priv = dev; 1378 dev->vdev.priv = dev;
1374 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); 1379 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
1375 if (err) 1380 if (err)