Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 261445
b: refs/heads/master
c: b824bb4
h: refs/heads/master
i:
  261443: 810226e
v: v3
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Jul 27, 2011
1 parent c76fa57 commit f43e8bd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 24 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: 1a4ede65f30315a31cb9b239bec0d4bb32834691
refs/heads/master: b824bb4b12548fedd622686d443310d574eb084e
38 changes: 17 additions & 21 deletions trunk/drivers/media/video/pwc/pwc-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,7 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev)

pwc_iso_stop(pdev);
pwc_iso_free(pdev);

/* Stop camera, but only if we are sure the camera is still there (unplug
is signalled by EPIPE)
*/
if (pdev->error_status != EPIPE) {
PWC_DEBUG_OPEN("Setting alternate interface 0.\n");
usb_set_interface(pdev->udev, 0, 0);
}
usb_set_interface(pdev->udev, 0, 0);

pdev->iso_init = 0;
PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n");
Expand Down Expand Up @@ -719,6 +712,9 @@ static int pwc_video_open(struct file *file)
PWC_DEBUG_OPEN(">> video_open called(vdev = 0x%p).\n", vdev);

pdev = video_get_drvdata(vdev);
if (!pdev->udev)
return -ENODEV;

if (pdev->vopen) {
PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n");
return -EBUSY;
Expand Down Expand Up @@ -760,7 +756,6 @@ static int pwc_video_open(struct file *file)

/* Reset buffers & parameters */
pdev->visoc_errors = 0;
pdev->error_status = 0;
pwc_construct(pdev); /* set min/max sizes correct */

/* Set some defaults */
Expand Down Expand Up @@ -837,7 +832,7 @@ static int pwc_video_close(struct file *file)
pwc_free_buffers(pdev);

/* Turn off LEDS and power down camera, but only when not unplugged */
if (!pdev->unplugged) {
if (pdev->udev) {
/* Turn LEDs off */
if (pwc_set_leds(pdev, 0, 0) < 0)
PWC_DEBUG_MODULE("Failed to set LED on/off time.\n");
Expand All @@ -859,8 +854,8 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
struct video_device *vdev = file->private_data;
struct pwc_device *pdev = video_get_drvdata(vdev);

if (pdev->error_status)
return -pdev->error_status;
if (!pdev->udev)
return -ENODEV;

return vb2_read(&pdev->vb_queue, buf, count, ppos,
file->f_flags & O_NONBLOCK);
Expand All @@ -871,7 +866,7 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
struct video_device *vdev = file->private_data;
struct pwc_device *pdev = video_get_drvdata(vdev);

if (pdev->error_status)
if (!pdev->udev)
return POLL_ERR;

return vb2_poll(&pdev->vb_queue, file, wait);
Expand Down Expand Up @@ -923,8 +918,8 @@ static int buffer_prepare(struct vb2_buffer *vb)
struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);

/* Don't allow queing new buffers after device disconnection */
if (pdev->error_status)
return -pdev->error_status;
if (!pdev->udev)
return -ENODEV;

return 0;
}
Expand Down Expand Up @@ -964,14 +959,18 @@ static int start_streaming(struct vb2_queue *vq)
{
struct pwc_device *pdev = vb2_get_drv_priv(vq);

if (!pdev->udev)
return -ENODEV;

return pwc_isoc_init(pdev);
}

static int stop_streaming(struct vb2_queue *vq)
{
struct pwc_device *pdev = vb2_get_drv_priv(vq);

pwc_isoc_cleanup(pdev);
if (pdev->udev)
pwc_isoc_cleanup(pdev);
pwc_cleanup_queued_bufs(pdev);

return 0;
Expand Down Expand Up @@ -1389,15 +1388,12 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
struct pwc_device *pdev = usb_get_intfdata(intf);

mutex_lock(&pdev->modlock);
usb_set_intfdata (intf, NULL);

/* We got unplugged; this is signalled by an EPIPE error code */
pdev->error_status = EPIPE;
pdev->unplugged = 1;

usb_set_intfdata(intf, NULL);
/* No need to keep the urbs around after disconnection */
pwc_isoc_cleanup(pdev);
pwc_cleanup_queued_bufs(pdev);
pdev->udev = NULL;

mutex_unlock(&pdev->modlock);

Expand Down
24 changes: 24 additions & 0 deletions trunk/drivers/media/video/pwc/pwc-v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, struct v4l2_format *f)
{
int ret, fps, snapshot, compression, pixelformat;

if (!pdev->udev)
return -ENODEV;

ret = pwc_vidioc_try_fmt(pdev, f);
if (ret<0)
return ret;
Expand Down Expand Up @@ -346,6 +349,9 @@ static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap
struct video_device *vdev = video_devdata(file);
struct pwc_device *pdev = video_drvdata(file);

if (!pdev->udev)
return -ENODEV;

strcpy(cap->driver, PWC_NAME);
strlcpy(cap->card, vdev->name, sizeof(cap->card));
usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info));
Expand Down Expand Up @@ -414,6 +420,9 @@ static int pwc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c)
struct pwc_device *pdev = video_drvdata(file);
int ret;

if (!pdev->udev)
return -ENODEV;

switch (c->id) {
case V4L2_CID_BRIGHTNESS:
c->value = pwc_get_brightness(pdev);
Expand Down Expand Up @@ -517,6 +526,9 @@ static int pwc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
struct pwc_device *pdev = video_drvdata(file);
int ret;

if (!pdev->udev)
return -ENODEV;

switch (c->id) {
case V4L2_CID_BRIGHTNESS:
c->value <<= 9;
Expand Down Expand Up @@ -692,27 +704,39 @@ static int pwc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
{
struct pwc_device *pdev = video_drvdata(file);

if (!pdev->udev)
return -ENODEV;

return vb2_qbuf(&pdev->vb_queue, buf);
}

static int pwc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
{
struct pwc_device *pdev = video_drvdata(file);

if (!pdev->udev)
return -ENODEV;

return vb2_dqbuf(&pdev->vb_queue, buf, file->f_flags & O_NONBLOCK);
}

static int pwc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
{
struct pwc_device *pdev = video_drvdata(file);

if (!pdev->udev)
return -ENODEV;

return vb2_streamon(&pdev->vb_queue, i);
}

static int pwc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
{
struct pwc_device *pdev = video_drvdata(file);

if (!pdev->udev)
return -ENODEV;

return vb2_streamoff(&pdev->vb_queue, i);
}

Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/media/video/pwc/pwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ struct pwc_device
int release; /* release number */
int features; /* feature bits */
char serial[30]; /* serial number (string) */
int error_status; /* set when something goes wrong */
int usb_init; /* set when the cam has been initialized */

/*** Video data ***/
Expand All @@ -180,7 +179,6 @@ struct pwc_device
char vsnapshot; /* snapshot mode */
char vsync; /* used by isoc handler */
char vmirror; /* for ToUCaM series */
char unplugged;

int cmd_len;
unsigned char cmd_buf[13];
Expand Down

0 comments on commit f43e8bd

Please sign in to comment.