aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAndrew Chew <achew@nvidia.com>2011-06-23 19:19:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:30 -0400
commit95904d4b6a188ea2f0f1781498f6ca626e21b9ac (patch)
tree72a38d167129b07bdf1ee4fd9428a33903991575 /drivers/media
parente29c9bfb3823b7733448a3232d1864c14f28fb44 (diff)
[media] V4L: ov9740: Add suspend/resume
On suspend, remember whether we are streaming or not, and at what frame format, so that on resume, we can start streaming again. Signed-off-by: Andrew Chew <achew@nvidia.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/ov9740.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/media/video/ov9740.c b/drivers/media/video/ov9740.c
index cd63eaae2dfe..ede48f2ed70c 100644
--- a/drivers/media/video/ov9740.c
+++ b/drivers/media/video/ov9740.c
@@ -201,6 +201,10 @@ struct ov9740_priv {
201 201
202 bool flag_vflip; 202 bool flag_vflip;
203 bool flag_hflip; 203 bool flag_hflip;
204
205 /* For suspend/resume. */
206 struct v4l2_mbus_framefmt current_mf;
207 bool current_enable;
204}; 208};
205 209
206static const struct ov9740_reg ov9740_defaults[] = { 210static const struct ov9740_reg ov9740_defaults[] = {
@@ -551,6 +555,8 @@ static int ov9740_s_stream(struct v4l2_subdev *sd, int enable)
551 0x00); 555 0x00);
552 } 556 }
553 557
558 priv->current_enable = enable;
559
554 return ret; 560 return ret;
555} 561}
556 562
@@ -702,6 +708,7 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd,
702 struct v4l2_mbus_framefmt *mf) 708 struct v4l2_mbus_framefmt *mf)
703{ 709{
704 struct i2c_client *client = v4l2_get_subdevdata(sd); 710 struct i2c_client *client = v4l2_get_subdevdata(sd);
711 struct ov9740_priv *priv = to_ov9740(sd);
705 enum v4l2_colorspace cspace; 712 enum v4l2_colorspace cspace;
706 enum v4l2_mbus_pixelcode code = mf->code; 713 enum v4l2_mbus_pixelcode code = mf->code;
707 int ret; 714 int ret;
@@ -728,6 +735,8 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd,
728 mf->code = code; 735 mf->code = code;
729 mf->colorspace = cspace; 736 mf->colorspace = cspace;
730 737
738 memcpy(&priv->current_mf, mf, sizeof(struct v4l2_mbus_framefmt));
739
731 return ret; 740 return ret;
732} 741}
733 742
@@ -829,6 +838,24 @@ static int ov9740_g_chip_ident(struct v4l2_subdev *sd,
829 return 0; 838 return 0;
830} 839}
831 840
841static int ov9740_s_power(struct v4l2_subdev *sd, int on)
842{
843 struct ov9740_priv *priv = to_ov9740(sd);
844
845 if (!priv->current_enable)
846 return 0;
847
848 if (on) {
849 ov9740_s_fmt(sd, &priv->current_mf);
850 ov9740_s_stream(sd, priv->current_enable);
851 } else {
852 ov9740_s_stream(sd, 0);
853 priv->current_enable = true;
854 }
855
856 return 0;
857}
858
832#ifdef CONFIG_VIDEO_ADV_DEBUG 859#ifdef CONFIG_VIDEO_ADV_DEBUG
833static int ov9740_get_register(struct v4l2_subdev *sd, 860static int ov9740_get_register(struct v4l2_subdev *sd,
834 struct v4l2_dbg_register *reg) 861 struct v4l2_dbg_register *reg)
@@ -942,6 +969,7 @@ static struct v4l2_subdev_core_ops ov9740_core_ops = {
942 .g_ctrl = ov9740_g_ctrl, 969 .g_ctrl = ov9740_g_ctrl,
943 .s_ctrl = ov9740_s_ctrl, 970 .s_ctrl = ov9740_s_ctrl,
944 .g_chip_ident = ov9740_g_chip_ident, 971 .g_chip_ident = ov9740_g_chip_ident,
972 .s_power = ov9740_s_power,
945#ifdef CONFIG_VIDEO_ADV_DEBUG 973#ifdef CONFIG_VIDEO_ADV_DEBUG
946 .g_register = ov9740_get_register, 974 .g_register = ov9740_get_register,
947 .s_register = ov9740_set_register, 975 .s_register = ov9740_set_register,