aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/m5mols/m5mols.h7
-rw-r--r--drivers/media/video/m5mols/m5mols_controls.c56
2 files changed, 63 insertions, 0 deletions
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index 87684c47d372..598bb0fe6036 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -162,6 +162,8 @@ struct m5mols_version {
162 * @handle: control handler 162 * @handle: control handler
163 * @auto_exposure: auto/manual exposure control 163 * @auto_exposure: auto/manual exposure control
164 * @exposure: manual exposure control 164 * @exposure: manual exposure control
165 * @auto_iso: auto/manual ISO sensitivity control
166 * @iso: manual ISO sensitivity control
165 * @autowb: Auto White Balance control 167 * @autowb: Auto White Balance control
166 * @colorfx: color effect control 168 * @colorfx: color effect control
167 * @saturation: saturation control 169 * @saturation: saturation control
@@ -193,6 +195,11 @@ struct m5mols_info {
193 struct v4l2_ctrl *auto_exposure; 195 struct v4l2_ctrl *auto_exposure;
194 struct v4l2_ctrl *exposure; 196 struct v4l2_ctrl *exposure;
195 }; 197 };
198 struct {
199 /* iso/auto iso cluster */
200 struct v4l2_ctrl *auto_iso;
201 struct v4l2_ctrl *iso;
202 };
196 203
197 struct v4l2_ctrl *auto_wb; 204 struct v4l2_ctrl *auto_wb;
198 struct v4l2_ctrl *colorfx; 205 struct v4l2_ctrl *colorfx;
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c
index 477660132c01..f1c88507de4b 100644
--- a/drivers/media/video/m5mols/m5mols_controls.c
+++ b/drivers/media/video/m5mols/m5mols_controls.c
@@ -319,6 +319,39 @@ static int m5mols_set_color_effect(struct m5mols_info *info, int val)
319 return ret; 319 return ret;
320} 320}
321 321
322static int m5mols_set_iso(struct m5mols_info *info, int auto_iso)
323{
324 u32 iso = auto_iso ? 0 : info->iso->val + 1;
325
326 return m5mols_write(&info->sd, AE_ISO, iso);
327}
328
329static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
330{
331 struct v4l2_subdev *sd = to_sd(ctrl);
332 struct m5mols_info *info = to_m5mols(sd);
333 int ret = 0;
334 u8 status;
335
336 v4l2_dbg(1, m5mols_debug, sd, "%s: ctrl: %s (%d)\n",
337 __func__, ctrl->name, info->isp_ready);
338
339 if (!info->isp_ready)
340 return -EBUSY;
341
342 switch (ctrl->id) {
343 case V4L2_CID_ISO_SENSITIVITY_AUTO:
344 ret = m5mols_read_u8(sd, AE_ISO, &status);
345 if (ret == 0)
346 ctrl->val = !status;
347 if (status != REG_ISO_AUTO)
348 info->iso->val = status - 1;
349 break;
350 }
351
352 return ret;
353}
354
322static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl) 355static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
323{ 356{
324 unsigned int ctrl_mode = m5mols_get_ctrl_mode(ctrl); 357 unsigned int ctrl_mode = m5mols_get_ctrl_mode(ctrl);
@@ -354,6 +387,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
354 ret = m5mols_set_exposure(info, ctrl->val); 387 ret = m5mols_set_exposure(info, ctrl->val);
355 break; 388 break;
356 389
390 case V4L2_CID_ISO_SENSITIVITY:
391 ret = m5mols_set_iso(info, ctrl->val);
392 break;
393
357 case V4L2_CID_AUTO_WHITE_BALANCE: 394 case V4L2_CID_AUTO_WHITE_BALANCE:
358 ret = m5mols_set_white_balance(info, ctrl->val); 395 ret = m5mols_set_white_balance(info, ctrl->val);
359 break; 396 break;
@@ -374,9 +411,16 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
374} 411}
375 412
376static const struct v4l2_ctrl_ops m5mols_ctrl_ops = { 413static const struct v4l2_ctrl_ops m5mols_ctrl_ops = {
414 .g_volatile_ctrl = m5mols_g_volatile_ctrl,
377 .s_ctrl = m5mols_s_ctrl, 415 .s_ctrl = m5mols_s_ctrl,
378}; 416};
379 417
418/* Supported manual ISO values */
419static const s64 iso_qmenu[] = {
420 /* AE_ISO: 0x01...0x07 */
421 50, 100, 200, 400, 800, 1600, 3200
422};
423
380int m5mols_init_controls(struct v4l2_subdev *sd) 424int m5mols_init_controls(struct v4l2_subdev *sd)
381{ 425{
382 struct m5mols_info *info = to_m5mols(sd); 426 struct m5mols_info *info = to_m5mols(sd);
@@ -404,6 +448,14 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
404 &m5mols_ctrl_ops, V4L2_CID_EXPOSURE, 448 &m5mols_ctrl_ops, V4L2_CID_EXPOSURE,
405 0, exposure_max, 1, exposure_max / 2); 449 0, exposure_max, 1, exposure_max / 2);
406 450
451 /* ISO control cluster */
452 info->auto_iso = v4l2_ctrl_new_std_menu(&info->handle, &m5mols_ctrl_ops,
453 V4L2_CID_ISO_SENSITIVITY_AUTO, 1, ~0x03, 1);
454
455 info->iso = v4l2_ctrl_new_int_menu(&info->handle, &m5mols_ctrl_ops,
456 V4L2_CID_ISO_SENSITIVITY, ARRAY_SIZE(iso_qmenu) - 1,
457 ARRAY_SIZE(iso_qmenu)/2 - 1, iso_qmenu);
458
407 info->saturation = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops, 459 info->saturation = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
408 V4L2_CID_SATURATION, 1, 5, 1, 3); 460 V4L2_CID_SATURATION, 1, 5, 1, 3);
409 461
@@ -422,6 +474,10 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
422 474
423 v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false); 475 v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false);
424 476
477 info->auto_iso->flags |= V4L2_CTRL_FLAG_VOLATILE |
478 V4L2_CTRL_FLAG_UPDATE;
479 v4l2_ctrl_auto_cluster(2, &info->auto_iso, 0, false);
480
425 m5mols_set_ctrl_mode(info->auto_exposure, REG_PARAMETER); 481 m5mols_set_ctrl_mode(info->auto_exposure, REG_PARAMETER);
426 m5mols_set_ctrl_mode(info->auto_wb, REG_PARAMETER); 482 m5mols_set_ctrl_mode(info->auto_wb, REG_PARAMETER);
427 m5mols_set_ctrl_mode(info->colorfx, REG_MONITOR); 483 m5mols_set_ctrl_mode(info->colorfx, REG_MONITOR);