Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320033
b: refs/heads/master
c: 587a576
h: refs/heads/master
i:
  320031: 186bcf4
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jun 21, 2012
1 parent 7a9dbec commit 21bac36
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 13 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: a065729d1224641f056688c57745fdd469714e22
refs/heads/master: 587a5765b2a6ee48bad72e0fdc56a5b496d23af3
69 changes: 57 additions & 12 deletions trunk/drivers/media/video/zr364xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ struct zr364xx_camera {

const struct zr364xx_fmt *fmt;
struct videobuf_queue vb_vidq;
bool was_streaming;
};

/* buffer for one video frame */
Expand Down Expand Up @@ -1119,20 +1120,10 @@ static inline int zr364xx_stop_acquire(struct zr364xx_camera *cam)
return 0;
}

static int zr364xx_vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
static int zr364xx_prepare(struct zr364xx_camera *cam)
{
struct zr364xx_camera *cam = video_drvdata(file);
int i, j;
int res;

DBG("%s\n", __func__);

if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;

if (cam->owner && cam->owner != priv)
return -EBUSY;
int i, j;

for (i = 0; init[cam->method][i].size != -1; i++) {
res = send_control_msg(cam->udev, 1, init[cam->method][i].value,
Expand All @@ -1153,6 +1144,27 @@ static int zr364xx_vidioc_streamon(struct file *file, void *priv,
cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE;
cam->buffer.frame[j].cur_size = 0;
}
v4l2_ctrl_handler_setup(&cam->ctrl_handler);
return 0;
}

static int zr364xx_vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
struct zr364xx_camera *cam = video_drvdata(file);
int res;

DBG("%s\n", __func__);

if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;

if (cam->owner && cam->owner != priv)
return -EBUSY;

res = zr364xx_prepare(cam);
if (res)
return res;
res = videobuf_streamon(&cam->vb_vidq);
if (res == 0) {
zr364xx_start_acquire(cam);
Expand Down Expand Up @@ -1578,6 +1590,34 @@ static void zr364xx_disconnect(struct usb_interface *intf)
}


#ifdef CONFIG_PM
static int zr364xx_suspend(struct usb_interface *intf, pm_message_t message)
{
struct zr364xx_camera *cam = usb_get_intfdata(intf);

cam->was_streaming = cam->b_acquire;
if (!cam->was_streaming)
return 0;
zr364xx_stop_acquire(cam);
zr364xx_stop_readpipe(cam);
return 0;
}

static int zr364xx_resume(struct usb_interface *intf)
{
struct zr364xx_camera *cam = usb_get_intfdata(intf);
int res;

if (!cam->was_streaming)
return 0;

zr364xx_start_readpipe(cam);
res = zr364xx_prepare(cam);
if (!res)
zr364xx_start_acquire(cam);
return res;
}
#endif

/**********************/
/* Module integration */
Expand All @@ -1587,6 +1627,11 @@ static struct usb_driver zr364xx_driver = {
.name = "zr364xx",
.probe = zr364xx_probe,
.disconnect = zr364xx_disconnect,
#ifdef CONFIG_PM
.suspend = zr364xx_suspend,
.resume = zr364xx_resume,
.reset_resume = zr364xx_resume,
#endif
.id_table = device_table
};

Expand Down

0 comments on commit 21bac36

Please sign in to comment.