diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-11-03 07:19:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-06 08:00:35 -0500 |
commit | a650bf1eff31d9719b51f33716617692a17b6794 (patch) | |
tree | 99ad73c5aaa520e606ddd27d1a28ed3f99815c67 /drivers/media/video/mt9m111.c | |
parent | 47921932f36c79e51f3bf40ab9632fa50309079a (diff) |
[media] mt9m111: power down most circuits when suspended
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9m111.c')
-rw-r--r-- | drivers/media/video/mt9m111.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 71d862bfd9fd..1405005266c2 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -226,7 +226,6 @@ struct mt9m111 { | |||
226 | const struct mt9m111_datafmt *fmt; | 226 | const struct mt9m111_datafmt *fmt; |
227 | int lastpage; /* PageMap cache value */ | 227 | int lastpage; /* PageMap cache value */ |
228 | unsigned char datawidth; | 228 | unsigned char datawidth; |
229 | unsigned int powered:1; | ||
230 | }; | 229 | }; |
231 | 230 | ||
232 | static struct mt9m111 *to_mt9m111(const struct i2c_client *client) | 231 | static struct mt9m111 *to_mt9m111(const struct i2c_client *client) |
@@ -360,12 +359,7 @@ static int mt9m111_setup_rect(struct mt9m111 *mt9m111, | |||
360 | static int mt9m111_enable(struct mt9m111 *mt9m111) | 359 | static int mt9m111_enable(struct mt9m111 *mt9m111) |
361 | { | 360 | { |
362 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); | 361 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); |
363 | int ret; | 362 | return reg_write(RESET, MT9M111_RESET_CHIP_ENABLE); |
364 | |||
365 | ret = reg_set(RESET, MT9M111_RESET_CHIP_ENABLE); | ||
366 | if (!ret) | ||
367 | mt9m111->powered = 1; | ||
368 | return ret; | ||
369 | } | 363 | } |
370 | 364 | ||
371 | static int mt9m111_reset(struct mt9m111 *mt9m111) | 365 | static int mt9m111_reset(struct mt9m111 *mt9m111) |
@@ -751,9 +745,20 @@ static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl) | |||
751 | 745 | ||
752 | static int mt9m111_suspend(struct mt9m111 *mt9m111) | 746 | static int mt9m111_suspend(struct mt9m111 *mt9m111) |
753 | { | 747 | { |
748 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); | ||
749 | int ret; | ||
750 | |||
754 | v4l2_ctrl_s_ctrl(mt9m111->gain, mt9m111_get_global_gain(mt9m111)); | 751 | v4l2_ctrl_s_ctrl(mt9m111->gain, mt9m111_get_global_gain(mt9m111)); |
755 | 752 | ||
756 | return 0; | 753 | ret = reg_set(RESET, MT9M111_RESET_RESET_MODE); |
754 | if (!ret) | ||
755 | ret = reg_set(RESET, MT9M111_RESET_RESET_SOC | | ||
756 | MT9M111_RESET_OUTPUT_DISABLE | | ||
757 | MT9M111_RESET_ANALOG_STANDBY); | ||
758 | if (!ret) | ||
759 | ret = reg_clear(RESET, MT9M111_RESET_CHIP_ENABLE); | ||
760 | |||
761 | return ret; | ||
757 | } | 762 | } |
758 | 763 | ||
759 | static void mt9m111_restore_state(struct mt9m111 *mt9m111) | 764 | static void mt9m111_restore_state(struct mt9m111 *mt9m111) |
@@ -766,15 +771,12 @@ static void mt9m111_restore_state(struct mt9m111 *mt9m111) | |||
766 | 771 | ||
767 | static int mt9m111_resume(struct mt9m111 *mt9m111) | 772 | static int mt9m111_resume(struct mt9m111 *mt9m111) |
768 | { | 773 | { |
769 | int ret = 0; | 774 | int ret = mt9m111_enable(mt9m111); |
775 | if (!ret) | ||
776 | ret = mt9m111_reset(mt9m111); | ||
777 | if (!ret) | ||
778 | mt9m111_restore_state(mt9m111); | ||
770 | 779 | ||
771 | if (mt9m111->powered) { | ||
772 | ret = mt9m111_enable(mt9m111); | ||
773 | if (!ret) | ||
774 | ret = mt9m111_reset(mt9m111); | ||
775 | if (!ret) | ||
776 | mt9m111_restore_state(mt9m111); | ||
777 | } | ||
778 | return ret; | 780 | return ret; |
779 | } | 781 | } |
780 | 782 | ||