Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 226276
b: refs/heads/master
c: 3751e28
h: refs/heads/master
v: v3
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Dec 29, 2010
1 parent 0a90609 commit 068835a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 49 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a931910d3be6f63464befb2dde94ec58a6eaf5c1
refs/heads/master: 3751e288bcf3d77652ef979edc0b3ea8b21d8b97
7 changes: 6 additions & 1 deletion trunk/drivers/media/video/pwc/pwc-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
54 changes: 14 additions & 40 deletions trunk/drivers/media/video/pwc/pwc-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,36 +966,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
*********/
Expand Down Expand Up @@ -1175,7 +1145,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.
*/
Expand All @@ -1202,15 +1172,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);
Expand Down Expand Up @@ -1325,6 +1286,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 */
Expand Down Expand Up @@ -1394,13 +1360,21 @@ 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;
pdev = video_get_drvdata(vdev);
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;
Expand Down
13 changes: 7 additions & 6 deletions trunk/drivers/media/video/pwc/pwc-v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/media/video/pwc/pwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 068835a

Please sign in to comment.