aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2011-06-05 07:27:39 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:22 -0400
commit14c5ea9bb411f094160626daed03c67641be076a (patch)
treed417bdf4b2afbba89c3fbdbe782bee597b513065 /drivers
parent2768cbbba3a131e5f483832ff0ff75d97392caa8 (diff)
[media] V4L: mt9m111: switch to v4l2-subdev .s_power() method
Eliminate soc-camera specific .suspend() and .restore() methods in favour of the standard v4l2-subdev .s_power() method Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/mt9m111.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index 0495def412ad..7962334a386b 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -169,6 +169,8 @@ struct mt9m111 {
169 * from v4l2-chip-ident.h */ 169 * from v4l2-chip-ident.h */
170 enum mt9m111_context context; 170 enum mt9m111_context context;
171 struct v4l2_rect rect; 171 struct v4l2_rect rect;
172 struct mutex power_lock; /* lock to protect power_count */
173 int power_count;
172 const struct mt9m111_datafmt *fmt; 174 const struct mt9m111_datafmt *fmt;
173 unsigned int gain; 175 unsigned int gain;
174 unsigned char autoexposure; 176 unsigned char autoexposure;
@@ -726,12 +728,7 @@ static const struct v4l2_queryctrl mt9m111_controls[] = {
726 } 728 }
727}; 729};
728 730
729static int mt9m111_resume(struct soc_camera_device *icd);
730static int mt9m111_suspend(struct soc_camera_device *icd, pm_message_t state);
731
732static struct soc_camera_ops mt9m111_ops = { 731static struct soc_camera_ops mt9m111_ops = {
733 .suspend = mt9m111_suspend,
734 .resume = mt9m111_resume,
735 .query_bus_param = mt9m111_query_bus_param, 732 .query_bus_param = mt9m111_query_bus_param,
736 .set_bus_param = mt9m111_set_bus_param, 733 .set_bus_param = mt9m111_set_bus_param,
737 .controls = mt9m111_controls, 734 .controls = mt9m111_controls,
@@ -901,11 +898,8 @@ static int mt9m111_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
901 return ret; 898 return ret;
902} 899}
903 900
904static int mt9m111_suspend(struct soc_camera_device *icd, pm_message_t state) 901static int mt9m111_suspend(struct mt9m111 *mt9m111)
905{ 902{
906 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
907 struct mt9m111 *mt9m111 = to_mt9m111(client);
908
909 mt9m111->gain = mt9m111_get_global_gain(mt9m111); 903 mt9m111->gain = mt9m111_get_global_gain(mt9m111);
910 904
911 return 0; 905 return 0;
@@ -923,10 +917,8 @@ static void mt9m111_restore_state(struct mt9m111 *mt9m111)
923 mt9m111_set_autowhitebalance(mt9m111, mt9m111->autowhitebalance); 917 mt9m111_set_autowhitebalance(mt9m111, mt9m111->autowhitebalance);
924} 918}
925 919
926static int mt9m111_resume(struct soc_camera_device *icd) 920static int mt9m111_resume(struct mt9m111 *mt9m111)
927{ 921{
928 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
929 struct mt9m111 *mt9m111 = to_mt9m111(client);
930 int ret = 0; 922 int ret = 0;
931 923
932 if (mt9m111->powered) { 924 if (mt9m111->powered) {
@@ -1008,10 +1000,45 @@ ei2c:
1008 return ret; 1000 return ret;
1009} 1001}
1010 1002
1003static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
1004{
1005 struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
1006 struct i2c_client *client = v4l2_get_subdevdata(sd);
1007 int ret = 0;
1008
1009 mutex_lock(&mt9m111->power_lock);
1010
1011 /*
1012 * If the power count is modified from 0 to != 0 or from != 0 to 0,
1013 * update the power state.
1014 */
1015 if (mt9m111->power_count == !on) {
1016 if (on) {
1017 ret = mt9m111_resume(mt9m111);
1018 if (ret) {
1019 dev_err(&client->dev,
1020 "Failed to resume the sensor: %d\n", ret);
1021 goto out;
1022 }
1023 } else {
1024 mt9m111_suspend(mt9m111);
1025 }
1026 }
1027
1028 /* Update the power count. */
1029 mt9m111->power_count += on ? 1 : -1;
1030 WARN_ON(mt9m111->power_count < 0);
1031
1032out:
1033 mutex_unlock(&mt9m111->power_lock);
1034 return ret;
1035}
1036
1011static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = { 1037static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
1012 .g_ctrl = mt9m111_g_ctrl, 1038 .g_ctrl = mt9m111_g_ctrl,
1013 .s_ctrl = mt9m111_s_ctrl, 1039 .s_ctrl = mt9m111_s_ctrl,
1014 .g_chip_ident = mt9m111_g_chip_ident, 1040 .g_chip_ident = mt9m111_g_chip_ident,
1041 .s_power = mt9m111_s_power,
1015#ifdef CONFIG_VIDEO_ADV_DEBUG 1042#ifdef CONFIG_VIDEO_ADV_DEBUG
1016 .g_register = mt9m111_g_register, 1043 .g_register = mt9m111_g_register,
1017 .s_register = mt9m111_s_register, 1044 .s_register = mt9m111_s_register,