This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/media_tree.git tree:

Subject: [media] pwc: do not start isoc stream on /dev/video open
Author:  Hans de Goede <[email protected]>
Date:    Tue Nov 16 11:39:25 2010 -0300

pwc was starting streaming on /dev/video# open rather then on STREAM_ON. Now
that the v4l1 compat code is removed from the pwc driver there is no reason
left to do this. So this patch changes the pwc driver to delay starting
the isoc stream (and thus using valuable usb bandwidth) until the application
does a STREAM_ON

Signed-off-by: Hans de Goede <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 drivers/media/video/pwc/pwc-ctrl.c |    7 ++++-
 drivers/media/video/pwc/pwc-if.c   |   54 +++++++++--------------------------
 drivers/media/video/pwc/pwc-v4l.c  |   13 ++++----
 drivers/media/video/pwc/pwc.h      |    1 -
 4 files changed, 27 insertions(+), 48 deletions(-)

---

http://git.linuxtv.org/media_tree.git?a=commitdiff;h=49696bcefc9f39a55eda3536652ef459806f53f9

diff --git a/drivers/media/video/pwc/pwc-ctrl.c 
b/drivers/media/video/pwc/pwc-ctrl.c
index 6b8fbdd..1593f8d 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -1386,11 +1386,16 @@ long pwc_ioctl(struct pwc_device *pdev, unsigned int 
cmd, void *arg)
        {
                ARG_DEF(int, qual)
 
+               if (pdev->iso_init) {
+                       ret = -EBUSY;
+                       break;
+               }
+
                ARG_IN(qual)
                if (ARGR(qual) < 0 || ARGR(qual) > 3)
                        ret = -EINVAL;
                else
-                       ret = pwc_try_video_mode(pdev, pdev->view.x, 
pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot);
+                       ret = pwc_set_video_mode(pdev, pdev->view.x, 
pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot);
                if (ret >= 0)
                        pdev->vcompression = ARGR(qual);
                break;
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index fc5f02e..2d76fc9 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -967,36 +967,6 @@ void pwc_isoc_cleanup(struct pwc_device *pdev)
        PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n");
 }
 
-int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int 
new_fps, int new_compression, int new_snapshot)
-{
-       int ret, start;
-
-       /* Stop isoc stuff */
-       pwc_isoc_cleanup(pdev);
-       /* Reset parameters */
-       pwc_reset_buffers(pdev);
-       /* Try to set video mode... */
-       start = ret = pwc_set_video_mode(pdev, width, height, new_fps, 
new_compression, new_snapshot);
-       if (ret) {
-               PWC_DEBUG_FLOW("pwc_set_video_mode attempt 1 failed.\n");
-               /* That failed... restore old mode (we know that worked) */
-               start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, 
pdev->vframes, pdev->vcompression, pdev->vsnapshot);
-               if (start) {
-                       PWC_DEBUG_FLOW("pwc_set_video_mode attempt 2 
failed.\n");
-               }
-       }
-       if (start == 0)
-       {
-               if (pwc_isoc_init(pdev) < 0)
-               {
-                       PWC_WARNING("Failed to restart ISOC transfers in 
pwc_try_video_mode.\n");
-                       ret = -EAGAIN; /* let's try again, who knows if it 
works a second time */
-               }
-       }
-       pdev->drop_frames++; /* try to avoid garbage during switch */
-       return ret; /* Return original error code */
-}
-
 /*********
  * sysfs
  *********/
@@ -1176,7 +1146,7 @@ static int pwc_video_open(struct file *file)
        /* Set some defaults */
        pdev->vsnapshot = 0;
 
-       /* Start iso pipe for video; first try the last used video size
+       /* Set video size, first try the last used video size
           (or the default one); if that fails try QCIF/10 or QSIF/10;
           it that fails too, give up.
         */
@@ -1203,15 +1173,6 @@ static int pwc_video_open(struct file *file)
                return i;
        }
 
-       i = pwc_isoc_init(pdev);
-       if (i) {
-               PWC_DEBUG_OPEN("Failed to init ISOC stuff = %d.\n", i);
-               pwc_isoc_cleanup(pdev);
-               pwc_free_buffers(pdev);
-               mutex_unlock(&pdev->modlock);
-               return i;
-       }
-
        /* Initialize the webcam to sane value */
        pwc_set_brightness(pdev, 0x7fff);
        pwc_set_agc(pdev, 1, 0);
@@ -1326,6 +1287,11 @@ static ssize_t pwc_video_read(struct file *file, char 
__user *buf,
                goto err_out;
        }
 
+       /* Start the stream (if not already started) */
+       rv = pwc_isoc_init(pdev);
+       if (rv)
+               goto err_out;
+
        /* In case we're doing partial reads, we don't have to wait for a frame 
*/
        if (pdev->image_read_pos == 0) {
                /* Do wait queueing according to the (doc)book */
@@ -1395,6 +1361,7 @@ static unsigned int pwc_video_poll(struct file *file, 
poll_table *wait)
 {
        struct video_device *vdev = file->private_data;
        struct pwc_device *pdev;
+       int ret;
 
        if (vdev == NULL)
                return -EFAULT;
@@ -1402,6 +1369,13 @@ static unsigned int pwc_video_poll(struct file *file, 
poll_table *wait)
        if (pdev == NULL)
                return -EFAULT;
 
+       /* Start the stream (if not already started) */
+       mutex_lock(&pdev->modlock);
+       ret = pwc_isoc_init(pdev);
+       mutex_unlock(&pdev->modlock);
+       if (ret)
+               return ret;
+
        poll_wait(file, &pdev->frameq, wait);
        if (pdev->error_status)
                return POLLERR;
diff --git a/drivers/media/video/pwc/pwc-v4l.c 
b/drivers/media/video/pwc/pwc-v4l.c
index 7061a03..2ef1668 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -309,7 +309,10 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, 
struct v4l2_format *f)
            pixelformat != V4L2_PIX_FMT_PWC2)
                return -EINVAL;
 
-       PWC_DEBUG_IOCTL("Try to change format to: width=%d height=%d fps=%d "
+       if (pdev->iso_init)
+               return -EBUSY;
+
+       PWC_DEBUG_IOCTL("Trying to set format to: width=%d height=%d fps=%d "
                        "compression=%d snapshot=%d format=%c%c%c%c\n",
                        f->fmt.pix.width, f->fmt.pix.height, fps,
                        compression, snapshot,
@@ -318,14 +321,14 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, 
struct v4l2_format *f)
                        (pixelformat>>16)&255,
                        (pixelformat>>24)&255);
 
-       ret = pwc_try_video_mode(pdev,
+       ret = pwc_set_video_mode(pdev,
                                 f->fmt.pix.width,
                                 f->fmt.pix.height,
                                 fps,
                                 compression,
                                 snapshot);
 
-       PWC_DEBUG_IOCTL("pwc_try_video_mode(), return=%d\n", ret);
+       PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret);
 
        if (ret)
                return ret;
@@ -882,9 +885,7 @@ long pwc_video_do_ioctl(struct file *file, unsigned int 
cmd, void *arg)
 
                case VIDIOC_STREAMON:
                {
-                       /* WARNING: pwc_try_video_mode() called pwc_isoc_init */
-                       pwc_isoc_init(pdev);
-                       return 0;
+                       return pwc_isoc_init(pdev);
                }
 
                case VIDIOC_STREAMOFF:
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 36a9c83..16bbc6d 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -275,7 +275,6 @@ extern int pwc_trace;
 extern int pwc_mbufs;
 
 /** functions in pwc-if.c */
-int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int 
new_fps, int new_compression, int new_snapshot);
 int pwc_handle_frame(struct pwc_device *pdev);
 void pwc_next_image(struct pwc_device *pdev);
 int pwc_isoc_init(struct pwc_device *pdev);

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to