diff options
Diffstat (limited to 'drivers/media/i2c/ov23850.c')
-rw-r--r-- | drivers/media/i2c/ov23850.c | 80 |
1 files changed, 23 insertions, 57 deletions
diff --git a/drivers/media/i2c/ov23850.c b/drivers/media/i2c/ov23850.c index 6f0dd4504..210152c2e 100644 --- a/drivers/media/i2c/ov23850.c +++ b/drivers/media/i2c/ov23850.c | |||
@@ -114,11 +114,9 @@ static u16 ov23850_to_gain(u32 rep, int shift) | |||
114 | return gain; | 114 | return gain; |
115 | } | 115 | } |
116 | 116 | ||
117 | static int ov23850_g_volatile_ctrl(struct v4l2_ctrl *ctrl); | ||
118 | static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl); | 117 | static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl); |
119 | 118 | ||
120 | static const struct v4l2_ctrl_ops ov23850_ctrl_ops = { | 119 | static const struct v4l2_ctrl_ops ov23850_ctrl_ops = { |
121 | .g_volatile_ctrl = ov23850_g_volatile_ctrl, | ||
122 | .s_ctrl = ov23850_s_ctrl, | 120 | .s_ctrl = ov23850_s_ctrl, |
123 | }; | 121 | }; |
124 | 122 | ||
@@ -830,10 +828,18 @@ static int ov23850_eeprom_device_init(struct ov23850 *priv) | |||
830 | return 0; | 828 | return 0; |
831 | } | 829 | } |
832 | 830 | ||
833 | static int ov23850_read_eeprom(struct ov23850 *priv, | 831 | static int ov23850_read_eeprom(struct ov23850 *priv) |
834 | struct v4l2_ctrl *ctrl) | ||
835 | { | 832 | { |
836 | int err, i; | 833 | int err, i; |
834 | struct v4l2_ctrl *ctrl; | ||
835 | |||
836 | ctrl = v4l2_ctrl_find(&priv->ctrl_handler, | ||
837 | TEGRA_CAMERA_CID_EEPROM_DATA); | ||
838 | if (!ctrl) { | ||
839 | dev_err(&priv->i2c_client->dev, | ||
840 | "could not find device ctrl.\n"); | ||
841 | return -EINVAL; | ||
842 | } | ||
837 | 843 | ||
838 | for (i = 0; i < OV23850_EEPROM_NUM_BLOCKS; i++) { | 844 | for (i = 0; i < OV23850_EEPROM_NUM_BLOCKS; i++) { |
839 | err = regmap_bulk_read(priv->eeprom[i].regmap, 0, | 845 | err = regmap_bulk_read(priv->eeprom[i].regmap, 0, |
@@ -978,10 +984,6 @@ static int ov23850_otp_setup(struct ov23850 *priv) | |||
978 | struct v4l2_ctrl *ctrl; | 984 | struct v4l2_ctrl *ctrl; |
979 | u8 otp_buf[OV23850_OTP_SIZE]; | 985 | u8 otp_buf[OV23850_OTP_SIZE]; |
980 | 986 | ||
981 | err = camera_common_s_power(priv->subdev, true); | ||
982 | if (err) | ||
983 | return -ENODEV; | ||
984 | |||
985 | err = ov23850_read_otp_manual(priv, | 987 | err = ov23850_read_otp_manual(priv, |
986 | otp_buf, | 988 | otp_buf, |
987 | OV23850_OTP_START_ADDR, | 989 | OV23850_OTP_START_ADDR, |
@@ -1000,10 +1002,6 @@ static int ov23850_otp_setup(struct ov23850 *priv) | |||
1000 | otp_buf[i]); | 1002 | otp_buf[i]); |
1001 | ctrl->p_cur.p_char = ctrl->p_new.p_char; | 1003 | ctrl->p_cur.p_char = ctrl->p_new.p_char; |
1002 | 1004 | ||
1003 | err = camera_common_s_power(priv->subdev, false); | ||
1004 | if (err) | ||
1005 | return -ENODEV; | ||
1006 | |||
1007 | return 0; | 1005 | return 0; |
1008 | } | 1006 | } |
1009 | 1007 | ||
@@ -1015,10 +1013,6 @@ static int ov23850_fuse_id_setup(struct ov23850 *priv) | |||
1015 | struct v4l2_ctrl *ctrl; | 1013 | struct v4l2_ctrl *ctrl; |
1016 | u8 fuse_id[OV23850_FUSE_ID_SIZE]; | 1014 | u8 fuse_id[OV23850_FUSE_ID_SIZE]; |
1017 | 1015 | ||
1018 | err = camera_common_s_power(priv->subdev, true); | ||
1019 | if (err) | ||
1020 | return -ENODEV; | ||
1021 | |||
1022 | err = ov23850_read_otp_manual(priv, | 1016 | err = ov23850_read_otp_manual(priv, |
1023 | fuse_id, | 1017 | fuse_id, |
1024 | OV23850_FUSE_ID_OTP_START_ADDR, | 1018 | OV23850_FUSE_ID_OTP_START_ADDR, |
@@ -1037,39 +1031,9 @@ static int ov23850_fuse_id_setup(struct ov23850 *priv) | |||
1037 | fuse_id[i]); | 1031 | fuse_id[i]); |
1038 | ctrl->p_cur.p_char = ctrl->p_new.p_char; | 1032 | ctrl->p_cur.p_char = ctrl->p_new.p_char; |
1039 | 1033 | ||
1040 | err = camera_common_s_power(priv->subdev, false); | ||
1041 | if (err) | ||
1042 | return -ENODEV; | ||
1043 | |||
1044 | return 0; | 1034 | return 0; |
1045 | } | 1035 | } |
1046 | 1036 | ||
1047 | static int ov23850_g_volatile_ctrl(struct v4l2_ctrl *ctrl) | ||
1048 | { | ||
1049 | struct ov23850 *priv = | ||
1050 | container_of(ctrl->handler, struct ov23850, ctrl_handler); | ||
1051 | struct device *dev = &priv->i2c_client->dev; | ||
1052 | int err = 0; | ||
1053 | |||
1054 | if (priv->power.state == SWITCH_OFF) | ||
1055 | return 0; | ||
1056 | |||
1057 | switch (ctrl->id) { | ||
1058 | case TEGRA_CAMERA_CID_EEPROM_DATA: | ||
1059 | #if 0 | ||
1060 | err = ov23850_read_eeprom(priv, ctrl); | ||
1061 | if (err) | ||
1062 | return err; | ||
1063 | #endif | ||
1064 | break; | ||
1065 | default: | ||
1066 | dev_err(dev, "%s: unknown ctrl id.\n", __func__); | ||
1067 | return -EINVAL; | ||
1068 | } | ||
1069 | |||
1070 | return err; | ||
1071 | } | ||
1072 | |||
1073 | static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl) | 1037 | static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl) |
1074 | { | 1038 | { |
1075 | struct ov23850 *priv = | 1039 | struct ov23850 *priv = |
@@ -1101,15 +1065,6 @@ static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl) | |||
1101 | err = ov23850_set_group_hold(priv); | 1065 | err = ov23850_set_group_hold(priv); |
1102 | } | 1066 | } |
1103 | break; | 1067 | break; |
1104 | case TEGRA_CAMERA_CID_EEPROM_DATA: | ||
1105 | #if 0 | ||
1106 | if (!ctrl->p_new.p_char[0]) | ||
1107 | break; | ||
1108 | err = ov23850_write_eeprom(priv, ctrl->p_new.p_char); | ||
1109 | if (err) | ||
1110 | return err; | ||
1111 | #endif | ||
1112 | break; | ||
1113 | case TEGRA_CAMERA_CID_HDR_EN: | 1068 | case TEGRA_CAMERA_CID_HDR_EN: |
1114 | break; | 1069 | break; |
1115 | default: | 1070 | default: |
@@ -1166,22 +1121,33 @@ static int ov23850_ctrls_init(struct ov23850 *priv) | |||
1166 | goto error; | 1121 | goto error; |
1167 | } | 1122 | } |
1168 | 1123 | ||
1124 | err = camera_common_s_power(priv->subdev, true); | ||
1125 | if (err) { | ||
1126 | dev_err(&client->dev, | ||
1127 | "Error %d during power on\n", err); | ||
1128 | err = -ENODEV; | ||
1129 | goto error; | ||
1130 | } | ||
1131 | |||
1169 | err = ov23850_otp_setup(priv); | 1132 | err = ov23850_otp_setup(priv); |
1170 | if (err) { | 1133 | if (err) { |
1171 | dev_err(&client->dev, | 1134 | dev_err(&client->dev, |
1172 | "Error %d reading otp data\n", err); | 1135 | "Error %d reading otp data\n", err); |
1173 | goto error; | 1136 | goto error_hw; |
1174 | } | 1137 | } |
1175 | 1138 | ||
1176 | err = ov23850_fuse_id_setup(priv); | 1139 | err = ov23850_fuse_id_setup(priv); |
1177 | if (err) { | 1140 | if (err) { |
1178 | dev_err(&client->dev, | 1141 | dev_err(&client->dev, |
1179 | "Error %d reading fuse id data\n", err); | 1142 | "Error %d reading fuse id data\n", err); |
1180 | goto error; | 1143 | goto error_hw; |
1181 | } | 1144 | } |
1182 | 1145 | ||
1146 | camera_common_s_power(priv->subdev, false); | ||
1183 | return 0; | 1147 | return 0; |
1184 | 1148 | ||
1149 | error_hw: | ||
1150 | camera_common_s_power(priv->subdev, false); | ||
1185 | error: | 1151 | error: |
1186 | v4l2_ctrl_handler_free(&priv->ctrl_handler); | 1152 | v4l2_ctrl_handler_free(&priv->ctrl_handler); |
1187 | return err; | 1153 | return err; |