[media] pwc: do not start isoc stream on /dev/video open
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 <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
a931910d3b
commit
3751e288bc
@ -1386,11 +1386,16 @@ long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
|
|||||||
{
|
{
|
||||||
ARG_DEF(int, qual)
|
ARG_DEF(int, qual)
|
||||||
|
|
||||||
|
if (pdev->iso_init) {
|
||||||
|
ret = -EBUSY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ARG_IN(qual)
|
ARG_IN(qual)
|
||||||
if (ARGR(qual) < 0 || ARGR(qual) > 3)
|
if (ARGR(qual) < 0 || ARGR(qual) > 3)
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
else
|
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)
|
if (ret >= 0)
|
||||||
pdev->vcompression = ARGR(qual);
|
pdev->vcompression = ARGR(qual);
|
||||||
break;
|
break;
|
||||||
|
@ -966,36 +966,6 @@ void pwc_isoc_cleanup(struct pwc_device *pdev)
|
|||||||
PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n");
|
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
|
* sysfs
|
||||||
*********/
|
*********/
|
||||||
@ -1175,7 +1145,7 @@ static int pwc_video_open(struct file *file)
|
|||||||
/* Set some defaults */
|
/* Set some defaults */
|
||||||
pdev->vsnapshot = 0;
|
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;
|
(or the default one); if that fails try QCIF/10 or QSIF/10;
|
||||||
it that fails too, give up.
|
it that fails too, give up.
|
||||||
*/
|
*/
|
||||||
@ -1202,15 +1172,6 @@ static int pwc_video_open(struct file *file)
|
|||||||
return i;
|
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 */
|
/* Initialize the webcam to sane value */
|
||||||
pwc_set_brightness(pdev, 0x7fff);
|
pwc_set_brightness(pdev, 0x7fff);
|
||||||
pwc_set_agc(pdev, 1, 0);
|
pwc_set_agc(pdev, 1, 0);
|
||||||
@ -1325,6 +1286,11 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
|
|||||||
goto err_out;
|
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 */
|
/* In case we're doing partial reads, we don't have to wait for a frame */
|
||||||
if (pdev->image_read_pos == 0) {
|
if (pdev->image_read_pos == 0) {
|
||||||
/* Do wait queueing according to the (doc)book */
|
/* Do wait queueing according to the (doc)book */
|
||||||
@ -1394,6 +1360,7 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
|
|||||||
{
|
{
|
||||||
struct video_device *vdev = file->private_data;
|
struct video_device *vdev = file->private_data;
|
||||||
struct pwc_device *pdev;
|
struct pwc_device *pdev;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (vdev == NULL)
|
if (vdev == NULL)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
@ -1401,6 +1368,13 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
|
|||||||
if (pdev == NULL)
|
if (pdev == NULL)
|
||||||
return -EFAULT;
|
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);
|
poll_wait(file, &pdev->frameq, wait);
|
||||||
if (pdev->error_status)
|
if (pdev->error_status)
|
||||||
return POLLERR;
|
return POLLERR;
|
||||||
|
@ -309,7 +309,10 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, struct v4l2_format *f)
|
|||||||
pixelformat != V4L2_PIX_FMT_PWC2)
|
pixelformat != V4L2_PIX_FMT_PWC2)
|
||||||
return -EINVAL;
|
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",
|
"compression=%d snapshot=%d format=%c%c%c%c\n",
|
||||||
f->fmt.pix.width, f->fmt.pix.height, fps,
|
f->fmt.pix.width, f->fmt.pix.height, fps,
|
||||||
compression, snapshot,
|
compression, snapshot,
|
||||||
@ -318,14 +321,14 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, struct v4l2_format *f)
|
|||||||
(pixelformat>>16)&255,
|
(pixelformat>>16)&255,
|
||||||
(pixelformat>>24)&255);
|
(pixelformat>>24)&255);
|
||||||
|
|
||||||
ret = pwc_try_video_mode(pdev,
|
ret = pwc_set_video_mode(pdev,
|
||||||
f->fmt.pix.width,
|
f->fmt.pix.width,
|
||||||
f->fmt.pix.height,
|
f->fmt.pix.height,
|
||||||
fps,
|
fps,
|
||||||
compression,
|
compression,
|
||||||
snapshot);
|
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)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -882,9 +885,7 @@ long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg)
|
|||||||
|
|
||||||
case VIDIOC_STREAMON:
|
case VIDIOC_STREAMON:
|
||||||
{
|
{
|
||||||
/* WARNING: pwc_try_video_mode() called pwc_isoc_init */
|
return pwc_isoc_init(pdev);
|
||||||
pwc_isoc_init(pdev);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_STREAMOFF:
|
case VIDIOC_STREAMOFF:
|
||||||
|
@ -275,7 +275,6 @@ extern int pwc_trace;
|
|||||||
extern int pwc_mbufs;
|
extern int pwc_mbufs;
|
||||||
|
|
||||||
/** functions in pwc-if.c */
|
/** 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);
|
int pwc_handle_frame(struct pwc_device *pdev);
|
||||||
void pwc_next_image(struct pwc_device *pdev);
|
void pwc_next_image(struct pwc_device *pdev);
|
||||||
int pwc_isoc_init(struct pwc_device *pdev);
|
int pwc_isoc_init(struct pwc_device *pdev);
|
||||||
|
Reference in New Issue
Block a user