aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/zr364xx.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-06-08 05:43:59 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-06-21 10:27:52 -0400
commit587a5765b2a6ee48bad72e0fdc56a5b496d23af3 (patch)
tree6bf891671e41844316c52422fb308490f7f47802 /drivers/media/video/zr364xx.c
parenta065729d1224641f056688c57745fdd469714e22 (diff)
[media] zr364xx: add suspend/resume support
And fix initial control setup. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/zr364xx.c')
-rw-r--r--drivers/media/video/zr364xx.c69
1 files changed, 57 insertions, 12 deletions
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 333f696e7fcf..9afab35878b4 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -196,6 +196,7 @@ struct zr364xx_camera {
196 196
197 const struct zr364xx_fmt *fmt; 197 const struct zr364xx_fmt *fmt;
198 struct videobuf_queue vb_vidq; 198 struct videobuf_queue vb_vidq;
199 bool was_streaming;
199}; 200};
200 201
201/* buffer for one video frame */ 202/* buffer for one video frame */
@@ -1119,20 +1120,10 @@ static inline int zr364xx_stop_acquire(struct zr364xx_camera *cam)
1119 return 0; 1120 return 0;
1120} 1121}
1121 1122
1122static int zr364xx_vidioc_streamon(struct file *file, void *priv, 1123static int zr364xx_prepare(struct zr364xx_camera *cam)
1123 enum v4l2_buf_type type)
1124{ 1124{
1125 struct zr364xx_camera *cam = video_drvdata(file);
1126 int i, j;
1127 int res; 1125 int res;
1128 1126 int i, j;
1129 DBG("%s\n", __func__);
1130
1131 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1132 return -EINVAL;
1133
1134 if (cam->owner && cam->owner != priv)
1135 return -EBUSY;
1136 1127
1137 for (i = 0; init[cam->method][i].size != -1; i++) { 1128 for (i = 0; init[cam->method][i].size != -1; i++) {
1138 res = send_control_msg(cam->udev, 1, init[cam->method][i].value, 1129 res = send_control_msg(cam->udev, 1, init[cam->method][i].value,
@@ -1153,6 +1144,27 @@ static int zr364xx_vidioc_streamon(struct file *file, void *priv,
1153 cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE; 1144 cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE;
1154 cam->buffer.frame[j].cur_size = 0; 1145 cam->buffer.frame[j].cur_size = 0;
1155 } 1146 }
1147 v4l2_ctrl_handler_setup(&cam->ctrl_handler);
1148 return 0;
1149}
1150
1151static int zr364xx_vidioc_streamon(struct file *file, void *priv,
1152 enum v4l2_buf_type type)
1153{
1154 struct zr364xx_camera *cam = video_drvdata(file);
1155 int res;
1156
1157 DBG("%s\n", __func__);
1158
1159 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1160 return -EINVAL;
1161
1162 if (cam->owner && cam->owner != priv)
1163 return -EBUSY;
1164
1165 res = zr364xx_prepare(cam);
1166 if (res)
1167 return res;
1156 res = videobuf_streamon(&cam->vb_vidq); 1168 res = videobuf_streamon(&cam->vb_vidq);
1157 if (res == 0) { 1169 if (res == 0) {
1158 zr364xx_start_acquire(cam); 1170 zr364xx_start_acquire(cam);
@@ -1578,6 +1590,34 @@ static void zr364xx_disconnect(struct usb_interface *intf)
1578} 1590}
1579 1591
1580 1592
1593#ifdef CONFIG_PM
1594static int zr364xx_suspend(struct usb_interface *intf, pm_message_t message)
1595{
1596 struct zr364xx_camera *cam = usb_get_intfdata(intf);
1597
1598 cam->was_streaming = cam->b_acquire;
1599 if (!cam->was_streaming)
1600 return 0;
1601 zr364xx_stop_acquire(cam);
1602 zr364xx_stop_readpipe(cam);
1603 return 0;
1604}
1605
1606static int zr364xx_resume(struct usb_interface *intf)
1607{
1608 struct zr364xx_camera *cam = usb_get_intfdata(intf);
1609 int res;
1610
1611 if (!cam->was_streaming)
1612 return 0;
1613
1614 zr364xx_start_readpipe(cam);
1615 res = zr364xx_prepare(cam);
1616 if (!res)
1617 zr364xx_start_acquire(cam);
1618 return res;
1619}
1620#endif
1581 1621
1582/**********************/ 1622/**********************/
1583/* Module integration */ 1623/* Module integration */
@@ -1587,6 +1627,11 @@ static struct usb_driver zr364xx_driver = {
1587 .name = "zr364xx", 1627 .name = "zr364xx",
1588 .probe = zr364xx_probe, 1628 .probe = zr364xx_probe,
1589 .disconnect = zr364xx_disconnect, 1629 .disconnect = zr364xx_disconnect,
1630#ifdef CONFIG_PM
1631 .suspend = zr364xx_suspend,
1632 .resume = zr364xx_resume,
1633 .reset_resume = zr364xx_resume,
1634#endif
1590 .id_table = device_table 1635 .id_table = device_table
1591}; 1636};
1592 1637