aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2011-12-03 12:53:30 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-12-30 11:38:39 -0500
commitaa1f4601ed35820a9bd720cc5b1e3fe3c4ff7c5f (patch)
tree6fd49a9ee592c57c3850ae1b3d82fca6a03f58dc
parent5d4294b8ddf92092ffad61fe552adeeabb4242bd (diff)
[media] m5mols: Move the control handler initialization to probe()
This is prerequisite for enabling the sub-device node. The control handler is now initialized in driver's probe callback in order to allow the user space access controls before the device power is enabled with s_power. This is needed due to s_power being currently called only by the host driver. It also adds the subdev internal operations, only open() for now for the TRY format initialization. Acked-by: HeungJun Kim <riverful.kim@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/m5mols/m5mols_core.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/drivers/media/video/m5mols/m5mols_core.c b/drivers/media/video/m5mols/m5mols_core.c
index 9966d2e687f6..ea594cf0fa56 100644
--- a/drivers/media/video/m5mols/m5mols_core.c
+++ b/drivers/media/video/m5mols/m5mols_core.c
@@ -685,16 +685,25 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
685{ 685{
686 struct v4l2_subdev *sd = to_sd(ctrl); 686 struct v4l2_subdev *sd = to_sd(ctrl);
687 struct m5mols_info *info = to_m5mols(sd); 687 struct m5mols_info *info = to_m5mols(sd);
688 int isp_state = info->mode; 688 int ispstate = info->mode;
689 int ret = 0; 689 int ret;
690 690
691 ret = m5mols_mode(info, REG_PARAMETER); 691 /*
692 if (!ret) 692 * If needed, defer restoring the controls until
693 ret = m5mols_set_ctrl(ctrl); 693 * the device is fully initialized.
694 if (!ret) 694 */
695 ret = m5mols_mode(info, isp_state); 695 if (!info->isp_ready) {
696 info->ctrl_sync = 0;
697 return 0;
698 }
696 699
697 return ret; 700 ret = m5mols_mode(info, REG_PARAMETER);
701 if (ret < 0)
702 return ret;
703 ret = m5mols_set_ctrl(ctrl);
704 if (ret < 0)
705 return ret;
706 return m5mols_mode(info, ispstate);
698} 707}
699 708
700static const struct v4l2_ctrl_ops m5mols_ctrl_ops = { 709static const struct v4l2_ctrl_ops m5mols_ctrl_ops = {
@@ -855,8 +864,6 @@ static int m5mols_s_power(struct v4l2_subdev *sd, int on)
855 ret = m5mols_sensor_power(info, true); 864 ret = m5mols_sensor_power(info, true);
856 if (!ret) 865 if (!ret)
857 ret = m5mols_fw_start(sd); 866 ret = m5mols_fw_start(sd);
858 if (!ret)
859 ret = m5mols_init_controls(info);
860 if (ret) 867 if (ret)
861 return ret; 868 return ret;
862 869
@@ -881,10 +888,7 @@ static int m5mols_s_power(struct v4l2_subdev *sd, int on)
881 } 888 }
882 889
883 ret = m5mols_sensor_power(info, false); 890 ret = m5mols_sensor_power(info, false);
884 if (!ret) { 891 info->ctrl_sync = 0;
885 v4l2_ctrl_handler_free(&info->handle);
886 info->ctrl_sync = 0;
887 }
888 892
889 return ret; 893 return ret;
890} 894}
@@ -910,6 +914,21 @@ static const struct v4l2_subdev_core_ops m5mols_core_ops = {
910 .log_status = m5mols_log_status, 914 .log_status = m5mols_log_status,
911}; 915};
912 916
917/*
918 * V4L2 subdev internal operations
919 */
920static int m5mols_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
921{
922 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(fh, 0);
923
924 *format = m5mols_default_ffmt[0];
925 return 0;
926}
927
928static const struct v4l2_subdev_internal_ops m5mols_subdev_internal_ops = {
929 .open = m5mols_open,
930};
931
913static const struct v4l2_subdev_ops m5mols_ops = { 932static const struct v4l2_subdev_ops m5mols_ops = {
914 .core = &m5mols_core_ops, 933 .core = &m5mols_core_ops,
915 .pad = &m5mols_pad_ops, 934 .pad = &m5mols_pad_ops,
@@ -973,6 +992,7 @@ static int __devinit m5mols_probe(struct i2c_client *client,
973 strlcpy(sd->name, MODULE_NAME, sizeof(sd->name)); 992 strlcpy(sd->name, MODULE_NAME, sizeof(sd->name));
974 v4l2_i2c_subdev_init(sd, client, &m5mols_ops); 993 v4l2_i2c_subdev_init(sd, client, &m5mols_ops);
975 994
995 sd->internal_ops = &m5mols_subdev_internal_ops;
976 info->pad.flags = MEDIA_PAD_FL_SOURCE; 996 info->pad.flags = MEDIA_PAD_FL_SOURCE;
977 ret = media_entity_init(&sd->entity, 1, &info->pad, 0); 997 ret = media_entity_init(&sd->entity, 1, &info->pad, 0);
978 if (ret < 0) 998 if (ret < 0)
@@ -988,7 +1008,17 @@ static int __devinit m5mols_probe(struct i2c_client *client,
988 } 1008 }
989 info->res_type = M5MOLS_RESTYPE_MONITOR; 1009 info->res_type = M5MOLS_RESTYPE_MONITOR;
990 1010
991 return 0; 1011 ret = m5mols_sensor_power(info, true);
1012 if (ret)
1013 goto out_me;
1014
1015 ret = m5mols_fw_start(sd);
1016 if (!ret)
1017 ret = m5mols_init_controls(info);
1018
1019 m5mols_sensor_power(info, false);
1020 if (!ret)
1021 return 0;
992out_me: 1022out_me:
993 media_entity_cleanup(&sd->entity); 1023 media_entity_cleanup(&sd->entity);
994out_reg: 1024out_reg:
@@ -1006,6 +1036,7 @@ static int __devexit m5mols_remove(struct i2c_client *client)
1006 struct m5mols_info *info = to_m5mols(sd); 1036 struct m5mols_info *info = to_m5mols(sd);
1007 1037
1008 v4l2_device_unregister_subdev(sd); 1038 v4l2_device_unregister_subdev(sd);
1039 v4l2_ctrl_handler_free(sd->ctrl_handler);
1009 free_irq(client->irq, sd); 1040 free_irq(client->irq, sd);
1010 1041
1011 regulator_bulk_free(ARRAY_SIZE(supplies), supplies); 1042 regulator_bulk_free(ARRAY_SIZE(supplies), supplies);