Lines Matching +full:bias +full:- +full:ctrl +full:- +full:value
1 // SPDX-License-Identifier: GPL-2.0-only
22 #include <media/media-entity.h>
23 #include <media/v4l2-ctrls.h>
24 #include <media/v4l2-device.h>
25 #include <media/v4l2-subdev.h>
26 #include <media/v4l2-mediabus.h>
31 static int s5c73m3_get_af_status(struct s5c73m3 *state, struct v4l2_ctrl *ctrl) in s5c73m3_get_af_status() argument
41 ctrl->val = V4L2_AUTO_FOCUS_STATUS_BUSY; in s5c73m3_get_af_status()
45 ctrl->val = V4L2_AUTO_FOCUS_STATUS_REACHED; in s5c73m3_get_af_status()
48 v4l2_info(&state->sensor_sd, "Unknown AF status %#x\n", reg); in s5c73m3_get_af_status()
53 ctrl->val = V4L2_AUTO_FOCUS_STATUS_FAILED; in s5c73m3_get_af_status()
60 static int s5c73m3_g_volatile_ctrl(struct v4l2_ctrl *ctrl) in s5c73m3_g_volatile_ctrl() argument
62 struct v4l2_subdev *sd = ctrl_to_sensor_sd(ctrl); in s5c73m3_g_volatile_ctrl()
66 if (state->power == 0) in s5c73m3_g_volatile_ctrl()
67 return -EBUSY; in s5c73m3_g_volatile_ctrl()
69 switch (ctrl->id) { in s5c73m3_g_volatile_ctrl()
71 ret = s5c73m3_get_af_status(state, state->ctrls.af_status); in s5c73m3_g_volatile_ctrl()
95 v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd, in s5c73m3_set_colorfx()
97 v4l2_ctrl_get_menu(state->ctrls.colorfx->id)[i]); in s5c73m3_set_colorfx()
102 return -EINVAL; in s5c73m3_set_colorfx()
105 /* Set exposure metering/exposure bias */
108 struct v4l2_subdev *sd = &state->sensor_sd; in s5c73m3_set_exposure()
109 struct s5c73m3_ctrls *ctrls = &state->ctrls; in s5c73m3_set_exposure()
112 if (ctrls->exposure_metering->is_new) { in s5c73m3_set_exposure()
115 switch (ctrls->exposure_metering->val) { in s5c73m3_set_exposure()
130 if (!ret && ctrls->exposure_bias->is_new) { in s5c73m3_set_exposure()
131 u16 exp_bias = ctrls->exposure_bias->val; in s5c73m3_set_exposure()
136 "%s: exposure bias: %#x, metering: %#x (%d)\n", __func__, in s5c73m3_set_exposure()
137 ctrls->exposure_bias->val, ctrls->exposure_metering->val, ret); in s5c73m3_set_exposure()
158 v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd, in s5c73m3_set_white_balance()
160 v4l2_ctrl_get_menu(state->ctrls.auto_wb->id)[i]); in s5c73m3_set_white_balance()
165 return -EINVAL; in s5c73m3_set_white_balance()
170 struct s5c73m3_ctrls *c = &state->ctrls; in s5c73m3_af_run()
176 if (c->focus_auto->val) in s5c73m3_af_run()
183 static int s5c73m3_3a_lock(struct s5c73m3 *state, struct v4l2_ctrl *ctrl) in s5c73m3_3a_lock() argument
185 bool awb_lock = ctrl->val & V4L2_LOCK_WHITE_BALANCE; in s5c73m3_3a_lock()
186 bool ae_lock = ctrl->val & V4L2_LOCK_EXPOSURE; in s5c73m3_3a_lock()
187 bool af_lock = ctrl->val & V4L2_LOCK_FOCUS; in s5c73m3_3a_lock()
190 if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_EXPOSURE) { in s5c73m3_3a_lock()
197 if (((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_WHITE_BALANCE) in s5c73m3_3a_lock()
198 && state->ctrls.auto_wb->val) { in s5c73m3_3a_lock()
205 if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS) in s5c73m3_3a_lock()
213 struct s5c73m3_ctrls *c = &state->ctrls; in s5c73m3_set_auto_focus()
216 if (c->af_distance->is_new) { in s5c73m3_set_auto_focus()
217 u16 mode = (c->af_distance->val == V4L2_AUTO_FOCUS_RANGE_MACRO) in s5c73m3_set_auto_focus()
224 if (!ret || (c->focus_auto->is_new && c->focus_auto->val) || in s5c73m3_set_auto_focus()
225 c->af_start->is_new) in s5c73m3_set_auto_focus()
227 else if ((c->focus_auto->is_new && !c->focus_auto->val) || in s5c73m3_set_auto_focus()
228 c->af_stop->is_new) in s5c73m3_set_auto_focus()
238 u16 reg = (val < 0) ? -val + 2 : val; in s5c73m3_set_contrast()
244 u16 reg = (val < 0) ? -val + 2 : val; in s5c73m3_set_saturation()
250 u16 reg = (val < 0) ? -val + 2 : val; in s5c73m3_set_sharpness()
259 iso = state->ctrls.iso->val + 1; in s5c73m3_set_iso()
268 struct v4l2_subdev *sd = &state->sensor_sd; in s5c73m3_set_stabilization()
309 v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd, "Setting %s scene mode\n", in s5c73m3_set_scene_program()
310 v4l2_ctrl_get_menu(state->ctrls.scene_mode->id)[val]); in s5c73m3_set_scene_program()
337 static int s5c73m3_s_ctrl(struct v4l2_ctrl *ctrl) in s5c73m3_s_ctrl() argument
339 struct v4l2_subdev *sd = ctrl_to_sensor_sd(ctrl); in s5c73m3_s_ctrl()
343 v4l2_dbg(1, s5c73m3_dbg, sd, "set_ctrl: %s, value: %d\n", in s5c73m3_s_ctrl()
344 ctrl->name, ctrl->val); in s5c73m3_s_ctrl()
346 mutex_lock(&state->lock); in s5c73m3_s_ctrl()
350 * the controls will be restored right after power-up. in s5c73m3_s_ctrl()
352 if (state->power == 0) in s5c73m3_s_ctrl()
355 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) { in s5c73m3_s_ctrl()
356 ret = -EINVAL; in s5c73m3_s_ctrl()
360 switch (ctrl->id) { in s5c73m3_s_ctrl()
362 ret = s5c73m3_3a_lock(state, ctrl); in s5c73m3_s_ctrl()
366 ret = s5c73m3_set_white_balance(state, ctrl->val); in s5c73m3_s_ctrl()
370 ret = s5c73m3_set_contrast(state, ctrl->val); in s5c73m3_s_ctrl()
374 ret = s5c73m3_set_colorfx(state, ctrl->val); in s5c73m3_s_ctrl()
378 ret = s5c73m3_set_exposure(state, ctrl->val); in s5c73m3_s_ctrl()
382 ret = s5c73m3_set_auto_focus(state, ctrl->val); in s5c73m3_s_ctrl()
386 ret = s5c73m3_set_stabilization(state, ctrl->val); in s5c73m3_s_ctrl()
390 ret = s5c73m3_set_iso(state, ctrl->val); in s5c73m3_s_ctrl()
394 ret = s5c73m3_set_jpeg_quality(state, ctrl->val); in s5c73m3_s_ctrl()
398 ret = s5c73m3_set_power_line_freq(state, ctrl->val); in s5c73m3_s_ctrl()
402 ret = s5c73m3_set_saturation(state, ctrl->val); in s5c73m3_s_ctrl()
406 ret = s5c73m3_set_scene_program(state, ctrl->val); in s5c73m3_s_ctrl()
410 ret = s5c73m3_set_sharpness(state, ctrl->val); in s5c73m3_s_ctrl()
414 ret = s5c73m3_isp_command(state, COMM_WDR, !!ctrl->val); in s5c73m3_s_ctrl()
418 ret = s5c73m3_isp_command(state, COMM_ZOOM_STEP, ctrl->val); in s5c73m3_s_ctrl()
422 mutex_unlock(&state->lock); in s5c73m3_s_ctrl()
437 /* Supported exposure bias values (-2.0EV...+2.0EV) */
440 -2000, -1500, -1000, -500, 0, 500, 1000, 1500, 2000
446 struct s5c73m3_ctrls *ctrls = &state->ctrls; in s5c73m3_init_controls()
447 struct v4l2_ctrl_handler *hdl = &ctrls->handler; in s5c73m3_init_controls()
454 ctrls->auto_wb = v4l2_ctrl_new_std_menu(hdl, ops, in s5c73m3_init_controls()
459 ctrls->auto_exposure = v4l2_ctrl_new_std_menu(hdl, ops, in s5c73m3_init_controls()
462 ctrls->exposure_bias = v4l2_ctrl_new_int_menu(hdl, ops, in s5c73m3_init_controls()
464 ARRAY_SIZE(ev_bias_qmenu) - 1, in s5c73m3_init_controls()
465 ARRAY_SIZE(ev_bias_qmenu)/2 - 1, in s5c73m3_init_controls()
468 ctrls->exposure_metering = v4l2_ctrl_new_std_menu(hdl, ops, in s5c73m3_init_controls()
473 ctrls->focus_auto = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
476 ctrls->af_start = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
479 ctrls->af_stop = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
482 ctrls->af_status = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
489 ctrls->af_distance = v4l2_ctrl_new_std_menu(hdl, ops, in s5c73m3_init_controls()
496 ctrls->auto_iso = v4l2_ctrl_new_std_menu(hdl, ops, in s5c73m3_init_controls()
500 ctrls->iso = v4l2_ctrl_new_int_menu(hdl, ops, in s5c73m3_init_controls()
501 V4L2_CID_ISO_SENSITIVITY, ARRAY_SIZE(iso_qmenu) - 1, in s5c73m3_init_controls()
502 ARRAY_SIZE(iso_qmenu)/2 - 1, iso_qmenu); in s5c73m3_init_controls()
504 ctrls->contrast = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
505 V4L2_CID_CONTRAST, -2, 2, 1, 0); in s5c73m3_init_controls()
507 ctrls->saturation = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
508 V4L2_CID_SATURATION, -2, 2, 1, 0); in s5c73m3_init_controls()
510 ctrls->sharpness = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
511 V4L2_CID_SHARPNESS, -2, 2, 1, 0); in s5c73m3_init_controls()
513 ctrls->zoom = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
516 ctrls->colorfx = v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_COLORFX, in s5c73m3_init_controls()
519 ctrls->wdr = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
522 ctrls->stabilization = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
529 ctrls->jpeg_quality = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
532 ctrls->scene_mode = v4l2_ctrl_new_std_menu(hdl, ops, in s5c73m3_init_controls()
536 ctrls->aaa_lock = v4l2_ctrl_new_std(hdl, ops, in s5c73m3_init_controls()
539 if (hdl->error) { in s5c73m3_init_controls()
540 ret = hdl->error; in s5c73m3_init_controls()
545 v4l2_ctrl_auto_cluster(3, &ctrls->auto_exposure, 0, false); in s5c73m3_init_controls()
546 ctrls->auto_iso->flags |= V4L2_CTRL_FLAG_VOLATILE | in s5c73m3_init_controls()
548 v4l2_ctrl_auto_cluster(2, &ctrls->auto_iso, 0, false); in s5c73m3_init_controls()
549 ctrls->af_status->flags |= V4L2_CTRL_FLAG_VOLATILE; in s5c73m3_init_controls()
550 v4l2_ctrl_cluster(5, &ctrls->focus_auto); in s5c73m3_init_controls()
552 state->sensor_sd.ctrl_handler = hdl; in s5c73m3_init_controls()