diff options
author | Andrew Chew <achew@nvidia.com> | 2011-06-23 20:19:44 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 17:53:30 -0300 |
commit | 95904d4b6a188ea2f0f1781498f6ca626e21b9ac (patch) | |
tree | 72a38d167129b07bdf1ee4fd9428a33903991575 /drivers/media | |
parent | e29c9bfb3823b7733448a3232d1864c14f28fb44 (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.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/media/video/ov9740.c b/drivers/media/video/ov9740.c index cd63eaae2df..ede48f2ed70 100644 --- a/drivers/media/video/ov9740.c +++ b/drivers/media/video/ov9740.c @@ -201,6 +201,10 @@ struct ov9740_priv { bool flag_vflip; bool flag_hflip; + + /* For suspend/resume. */ + struct v4l2_mbus_framefmt current_mf; + bool current_enable; }; static const struct ov9740_reg ov9740_defaults[] = { @@ -551,6 +555,8 @@ static int ov9740_s_stream(struct v4l2_subdev *sd, int enable) 0x00); } + priv->current_enable = enable; + return ret; } @@ -702,6 +708,7 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = v4l2_get_subdevdata(sd); + struct ov9740_priv *priv = to_ov9740(sd); enum v4l2_colorspace cspace; enum v4l2_mbus_pixelcode code = mf->code; int ret; @@ -728,6 +735,8 @@ static int ov9740_s_fmt(struct v4l2_subdev *sd, mf->code = code; mf->colorspace = cspace; + memcpy(&priv->current_mf, mf, sizeof(struct v4l2_mbus_framefmt)); + return ret; } @@ -829,6 +838,24 @@ static int ov9740_g_chip_ident(struct v4l2_subdev *sd, return 0; } +static int ov9740_s_power(struct v4l2_subdev *sd, int on) +{ + struct ov9740_priv *priv = to_ov9740(sd); + + if (!priv->current_enable) + return 0; + + if (on) { + ov9740_s_fmt(sd, &priv->current_mf); + ov9740_s_stream(sd, priv->current_enable); + } else { + ov9740_s_stream(sd, 0); + priv->current_enable = true; + } + + return 0; +} + #ifdef CONFIG_VIDEO_ADV_DEBUG static int ov9740_get_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -942,6 +969,7 @@ static struct v4l2_subdev_core_ops ov9740_core_ops = { .g_ctrl = ov9740_g_ctrl, .s_ctrl = ov9740_s_ctrl, .g_chip_ident = ov9740_g_chip_ident, + .s_power = ov9740_s_power, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov9740_get_register, .s_register = ov9740_set_register, |