summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/ov5693.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/i2c/ov5693.c')
-rw-r--r--drivers/media/i2c/ov5693.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index 508688b42..6aeadd31c 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -26,6 +26,7 @@
26#include <linux/of_device.h> 26#include <linux/of_device.h>
27#include <linux/of_gpio.h> 27#include <linux/of_gpio.h>
28 28
29#include <media/tegra-v4l2-camera.h>
29#include <media/camera_common.h> 30#include <media/camera_common.h>
30#include <media/ov5693.h> 31#include <media/ov5693.h>
31 32
@@ -99,7 +100,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
99/* Do not change the name field for the controls! */ 100/* Do not change the name field for the controls! */
100 { 101 {
101 .ops = &ov5693_ctrl_ops, 102 .ops = &ov5693_ctrl_ops,
102 .id = V4L2_CID_GAIN, 103 .id = TEGRA_CAMERA_CID_GAIN,
103 .name = "Gain", 104 .name = "Gain",
104 .type = V4L2_CTRL_TYPE_INTEGER, 105 .type = V4L2_CTRL_TYPE_INTEGER,
105 .flags = V4L2_CTRL_FLAG_SLIDER, 106 .flags = V4L2_CTRL_FLAG_SLIDER,
@@ -110,7 +111,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
110 }, 111 },
111 { 112 {
112 .ops = &ov5693_ctrl_ops, 113 .ops = &ov5693_ctrl_ops,
113 .id = V4L2_CID_FRAME_LENGTH, 114 .id = TEGRA_CAMERA_CID_FRAME_LENGTH,
114 .name = "Frame Length", 115 .name = "Frame Length",
115 .type = V4L2_CTRL_TYPE_INTEGER, 116 .type = V4L2_CTRL_TYPE_INTEGER,
116 .flags = V4L2_CTRL_FLAG_SLIDER, 117 .flags = V4L2_CTRL_FLAG_SLIDER,
@@ -121,7 +122,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
121 }, 122 },
122 { 123 {
123 .ops = &ov5693_ctrl_ops, 124 .ops = &ov5693_ctrl_ops,
124 .id = V4L2_CID_COARSE_TIME, 125 .id = TEGRA_CAMERA_CID_COARSE_TIME,
125 .name = "Coarse Time", 126 .name = "Coarse Time",
126 .type = V4L2_CTRL_TYPE_INTEGER, 127 .type = V4L2_CTRL_TYPE_INTEGER,
127 .flags = V4L2_CTRL_FLAG_SLIDER, 128 .flags = V4L2_CTRL_FLAG_SLIDER,
@@ -132,7 +133,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
132 }, 133 },
133 { 134 {
134 .ops = &ov5693_ctrl_ops, 135 .ops = &ov5693_ctrl_ops,
135 .id = V4L2_CID_COARSE_TIME_SHORT, 136 .id = TEGRA_CAMERA_CID_COARSE_TIME_SHORT,
136 .name = "Coarse Time Short", 137 .name = "Coarse Time Short",
137 .type = V4L2_CTRL_TYPE_INTEGER, 138 .type = V4L2_CTRL_TYPE_INTEGER,
138 .flags = V4L2_CTRL_FLAG_SLIDER, 139 .flags = V4L2_CTRL_FLAG_SLIDER,
@@ -143,7 +144,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
143 }, 144 },
144 { 145 {
145 .ops = &ov5693_ctrl_ops, 146 .ops = &ov5693_ctrl_ops,
146 .id = V4L2_CID_GROUP_HOLD, 147 .id = TEGRA_CAMERA_CID_GROUP_HOLD,
147 .name = "Group Hold", 148 .name = "Group Hold",
148 .type = V4L2_CTRL_TYPE_INTEGER_MENU, 149 .type = V4L2_CTRL_TYPE_INTEGER_MENU,
149 .min = 0, 150 .min = 0,
@@ -154,7 +155,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
154 }, 155 },
155 { 156 {
156 .ops = &ov5693_ctrl_ops, 157 .ops = &ov5693_ctrl_ops,
157 .id = V4L2_CID_HDR_EN, 158 .id = TEGRA_CAMERA_CID_HDR_EN,
158 .name = "HDR enable", 159 .name = "HDR enable",
159 .type = V4L2_CTRL_TYPE_INTEGER_MENU, 160 .type = V4L2_CTRL_TYPE_INTEGER_MENU,
160 .min = 0, 161 .min = 0,
@@ -165,7 +166,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
165 }, 166 },
166 { 167 {
167 .ops = &ov5693_ctrl_ops, 168 .ops = &ov5693_ctrl_ops,
168 .id = V4L2_CID_EEPROM_DATA, 169 .id = TEGRA_CAMERA_CID_EEPROM_DATA,
169 .name = "EEPROM Data", 170 .name = "EEPROM Data",
170 .type = V4L2_CTRL_TYPE_STRING, 171 .type = V4L2_CTRL_TYPE_STRING,
171 .flags = V4L2_CTRL_FLAG_VOLATILE, 172 .flags = V4L2_CTRL_FLAG_VOLATILE,
@@ -175,7 +176,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
175 }, 176 },
176 { 177 {
177 .ops = &ov5693_ctrl_ops, 178 .ops = &ov5693_ctrl_ops,
178 .id = V4L2_CID_OTP_DATA, 179 .id = TEGRA_CAMERA_CID_OTP_DATA,
179 .name = "OTP Data", 180 .name = "OTP Data",
180 .type = V4L2_CTRL_TYPE_STRING, 181 .type = V4L2_CTRL_TYPE_STRING,
181 .flags = V4L2_CTRL_FLAG_READ_ONLY, 182 .flags = V4L2_CTRL_FLAG_READ_ONLY,
@@ -185,7 +186,7 @@ static struct v4l2_ctrl_config ctrl_config_list[] = {
185 }, 186 },
186 { 187 {
187 .ops = &ov5693_ctrl_ops, 188 .ops = &ov5693_ctrl_ops,
188 .id = V4L2_CID_FUSE_ID, 189 .id = TEGRA_CAMERA_CID_FUSE_ID,
189 .name = "Fuse ID", 190 .name = "Fuse ID",
190 .type = V4L2_CTRL_TYPE_STRING, 191 .type = V4L2_CTRL_TYPE_STRING,
191 .flags = V4L2_CTRL_FLAG_READ_ONLY, 192 .flags = V4L2_CTRL_FLAG_READ_ONLY,
@@ -528,14 +529,14 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
528 * coarse integration time, and gain. Failures to write 529 * coarse integration time, and gain. Failures to write
529 * overrides are non-fatal 530 * overrides are non-fatal
530 */ 531 */
531 control.id = V4L2_CID_GAIN; 532 control.id = TEGRA_CAMERA_CID_GAIN;
532 err = v4l2_g_ctrl(&priv->ctrl_handler, &control); 533 err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
533 err |= ov5693_set_gain(priv, control.value); 534 err |= ov5693_set_gain(priv, control.value);
534 if (err) 535 if (err)
535 dev_dbg(&client->dev, "%s: warning gain override failed\n", 536 dev_dbg(&client->dev, "%s: warning gain override failed\n",
536 __func__); 537 __func__);
537 538
538 control.id = V4L2_CID_FRAME_LENGTH; 539 control.id = TEGRA_CAMERA_CID_FRAME_LENGTH;
539 err = v4l2_g_ctrl(&priv->ctrl_handler, &control); 540 err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
540 err |= ov5693_set_frame_length(priv, control.value); 541 err |= ov5693_set_frame_length(priv, control.value);
541 if (err) 542 if (err)
@@ -543,7 +544,7 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
543 "%s: warning frame length override failed\n", 544 "%s: warning frame length override failed\n",
544 __func__); 545 __func__);
545 546
546 control.id = V4L2_CID_COARSE_TIME; 547 control.id = TEGRA_CAMERA_CID_COARSE_TIME;
547 err = v4l2_g_ctrl(&priv->ctrl_handler, &control); 548 err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
548 err |= ov5693_set_coarse_time(priv, control.value); 549 err |= ov5693_set_coarse_time(priv, control.value);
549 if (err) 550 if (err)
@@ -551,7 +552,7 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
551 "%s: warning coarse time override failed\n", 552 "%s: warning coarse time override failed\n",
552 __func__); 553 __func__);
553 554
554 control.id = V4L2_CID_COARSE_TIME_SHORT; 555 control.id = TEGRA_CAMERA_CID_COARSE_TIME_SHORT;
555 err = v4l2_g_ctrl(&priv->ctrl_handler, &control); 556 err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
556 err |= ov5693_set_coarse_time_short(priv, control.value); 557 err |= ov5693_set_coarse_time_short(priv, control.value);
557 if (err) 558 if (err)
@@ -741,8 +742,8 @@ fail:
741static void ov5693_update_ctrl_range(struct ov5693 *priv, s32 frame_length) 742static void ov5693_update_ctrl_range(struct ov5693 *priv, s32 frame_length)
742{ 743{
743 struct v4l2_ctrl *ctrl = NULL; 744 struct v4l2_ctrl *ctrl = NULL;
744 int ctrl_ids[2] = {V4L2_CID_COARSE_TIME, 745 int ctrl_ids[2] = {TEGRA_CAMERA_CID_COARSE_TIME,
745 V4L2_CID_COARSE_TIME_SHORT}; 746 TEGRA_CAMERA_CID_COARSE_TIME_SHORT};
746 s32 max, min, def; 747 s32 max, min, def;
747 int i, j; 748 int i, j;
748 749
@@ -853,7 +854,7 @@ static int ov5693_set_coarse_time_short(struct ov5693 *priv, s32 val)
853 ov5693_set_group_hold(priv); 854 ov5693_set_group_hold(priv);
854 855
855 /* check hdr enable ctrl */ 856 /* check hdr enable ctrl */
856 hdr_control.id = V4L2_CID_HDR_EN; 857 hdr_control.id = TEGRA_CAMERA_CID_HDR_EN;
857 858
858 err = camera_common_g_ctrl(priv->s_data, &hdr_control); 859 err = camera_common_g_ctrl(priv->s_data, &hdr_control);
859 if (err < 0) { 860 if (err < 0) {
@@ -1044,7 +1045,7 @@ static int ov5693_otp_setup(struct ov5693 *priv)
1044 } 1045 }
1045 } 1046 }
1046 1047
1047 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, V4L2_CID_OTP_DATA); 1048 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_OTP_DATA);
1048 if (!ctrl) { 1049 if (!ctrl) {
1049 dev_err(&priv->i2c_client->dev, 1050 dev_err(&priv->i2c_client->dev,
1050 "could not find device ctrl.\n"); 1051 "could not find device ctrl.\n");
@@ -1085,7 +1086,7 @@ static int ov5693_fuse_id_setup(struct ov5693 *priv)
1085 goto ret; 1086 goto ret;
1086 } 1087 }
1087 1088
1088 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, V4L2_CID_FUSE_ID); 1089 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_FUSE_ID);
1089 if (!ctrl) { 1090 if (!ctrl) {
1090 dev_err(&priv->i2c_client->dev, 1091 dev_err(&priv->i2c_client->dev,
1091 "could not find device ctrl.\n"); 1092 "could not find device ctrl.\n");
@@ -1114,7 +1115,7 @@ static int ov5693_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
1114 return 0; 1115 return 0;
1115 1116
1116 switch (ctrl->id) { 1117 switch (ctrl->id) {
1117 case V4L2_CID_EEPROM_DATA: 1118 case TEGRA_CAMERA_CID_EEPROM_DATA:
1118 err = ov5693_read_eeprom(priv, ctrl); 1119 err = ov5693_read_eeprom(priv, ctrl);
1119 if (err) 1120 if (err)
1120 return err; 1121 return err;
@@ -1137,19 +1138,19 @@ static int ov5693_s_ctrl(struct v4l2_ctrl *ctrl)
1137 return 0; 1138 return 0;
1138 1139
1139 switch (ctrl->id) { 1140 switch (ctrl->id) {
1140 case V4L2_CID_GAIN: 1141 case TEGRA_CAMERA_CID_GAIN:
1141 err = ov5693_set_gain(priv, ctrl->val); 1142 err = ov5693_set_gain(priv, ctrl->val);
1142 break; 1143 break;
1143 case V4L2_CID_FRAME_LENGTH: 1144 case TEGRA_CAMERA_CID_FRAME_LENGTH:
1144 err = ov5693_set_frame_length(priv, ctrl->val); 1145 err = ov5693_set_frame_length(priv, ctrl->val);
1145 break; 1146 break;
1146 case V4L2_CID_COARSE_TIME: 1147 case TEGRA_CAMERA_CID_COARSE_TIME:
1147 err = ov5693_set_coarse_time(priv, ctrl->val); 1148 err = ov5693_set_coarse_time(priv, ctrl->val);
1148 break; 1149 break;
1149 case V4L2_CID_COARSE_TIME_SHORT: 1150 case TEGRA_CAMERA_CID_COARSE_TIME_SHORT:
1150 err = ov5693_set_coarse_time_short(priv, ctrl->val); 1151 err = ov5693_set_coarse_time_short(priv, ctrl->val);
1151 break; 1152 break;
1152 case V4L2_CID_GROUP_HOLD: 1153 case TEGRA_CAMERA_CID_GROUP_HOLD:
1153 if (switch_ctrl_qmenu[ctrl->val] == SWITCH_ON) { 1154 if (switch_ctrl_qmenu[ctrl->val] == SWITCH_ON) {
1154 priv->group_hold_en = true; 1155 priv->group_hold_en = true;
1155 } else { 1156 } else {
@@ -1157,14 +1158,14 @@ static int ov5693_s_ctrl(struct v4l2_ctrl *ctrl)
1157 err = ov5693_set_group_hold(priv); 1158 err = ov5693_set_group_hold(priv);
1158 } 1159 }
1159 break; 1160 break;
1160 case V4L2_CID_EEPROM_DATA: 1161 case TEGRA_CAMERA_CID_EEPROM_DATA:
1161 if (!ctrl->p_new.p_char[0]) 1162 if (!ctrl->p_new.p_char[0])
1162 break; 1163 break;
1163 err = ov5693_write_eeprom(priv, ctrl->p_new.p_char); 1164 err = ov5693_write_eeprom(priv, ctrl->p_new.p_char);
1164 if (err) 1165 if (err)
1165 return err; 1166 return err;
1166 break; 1167 break;
1167 case V4L2_CID_HDR_EN: 1168 case TEGRA_CAMERA_CID_HDR_EN:
1168 break; 1169 break;
1169 default: 1170 default:
1170 pr_err("%s: unknown ctrl id.\n", __func__); 1171 pr_err("%s: unknown ctrl id.\n", __func__);
@@ -1189,8 +1190,11 @@ static int ov5693_ctrls_init(struct ov5693 *priv, bool eeprom_ctrl)
1189 v4l2_ctrl_handler_init(&priv->ctrl_handler, numctrls); 1190 v4l2_ctrl_handler_init(&priv->ctrl_handler, numctrls);
1190 1191
1191 for (i = 0; i < numctrls; i++) { 1192 for (i = 0; i < numctrls; i++) {
1192 /* Skip control 'V4L2_CID_EEPROM_DATA' if eeprom inint err */ 1193 /*
1193 if (ctrl_config_list[i].id == V4L2_CID_EEPROM_DATA) { 1194 * Skip control 'TEGRA_CAMERA_CID_EEPROM_DATA'
1195 * if eeprom inint err
1196 */
1197 if (ctrl_config_list[i].id == TEGRA_CAMERA_CID_EEPROM_DATA) {
1194 if (!eeprom_ctrl) { 1198 if (!eeprom_ctrl) {
1195 common_data->numctrls -= 1; 1199 common_data->numctrls -= 1;
1196 continue; 1200 continue;