s5c73m3-ctrls.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Samsung LSI S5C73M3 8M pixel camera driver
  4. *
  5. * Copyright (C) 2012, Samsung Electronics, Co., Ltd.
  6. * Sylwester Nawrocki <[email protected]>
  7. * Andrzej Hajda <[email protected]>
  8. */
  9. #include <linux/sizes.h>
  10. #include <linux/delay.h>
  11. #include <linux/firmware.h>
  12. #include <linux/gpio.h>
  13. #include <linux/i2c.h>
  14. #include <linux/init.h>
  15. #include <linux/media.h>
  16. #include <linux/module.h>
  17. #include <linux/regulator/consumer.h>
  18. #include <linux/slab.h>
  19. #include <linux/spi/spi.h>
  20. #include <linux/videodev2.h>
  21. #include <media/media-entity.h>
  22. #include <media/v4l2-ctrls.h>
  23. #include <media/v4l2-device.h>
  24. #include <media/v4l2-subdev.h>
  25. #include <media/v4l2-mediabus.h>
  26. #include <media/i2c/s5c73m3.h>
  27. #include "s5c73m3.h"
  28. static int s5c73m3_get_af_status(struct s5c73m3 *state, struct v4l2_ctrl *ctrl)
  29. {
  30. u16 reg = REG_AF_STATUS_UNFOCUSED;
  31. int ret = s5c73m3_read(state, REG_AF_STATUS, &reg);
  32. switch (reg) {
  33. case REG_CAF_STATUS_FIND_SEARCH_DIR:
  34. case REG_AF_STATUS_FOCUSING:
  35. case REG_CAF_STATUS_FOCUSING:
  36. ctrl->val = V4L2_AUTO_FOCUS_STATUS_BUSY;
  37. break;
  38. case REG_CAF_STATUS_FOCUSED:
  39. case REG_AF_STATUS_FOCUSED:
  40. ctrl->val = V4L2_AUTO_FOCUS_STATUS_REACHED;
  41. break;
  42. default:
  43. v4l2_info(&state->sensor_sd, "Unknown AF status %#x\n", reg);
  44. fallthrough;
  45. case REG_CAF_STATUS_UNFOCUSED:
  46. case REG_AF_STATUS_UNFOCUSED:
  47. case REG_AF_STATUS_INVALID:
  48. ctrl->val = V4L2_AUTO_FOCUS_STATUS_FAILED;
  49. break;
  50. }
  51. return ret;
  52. }
  53. static int s5c73m3_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
  54. {
  55. struct v4l2_subdev *sd = ctrl_to_sensor_sd(ctrl);
  56. struct s5c73m3 *state = sensor_sd_to_s5c73m3(sd);
  57. int ret;
  58. if (state->power == 0)
  59. return -EBUSY;
  60. switch (ctrl->id) {
  61. case V4L2_CID_FOCUS_AUTO:
  62. ret = s5c73m3_get_af_status(state, state->ctrls.af_status);
  63. if (ret)
  64. return ret;
  65. break;
  66. }
  67. return 0;
  68. }
  69. static int s5c73m3_set_colorfx(struct s5c73m3 *state, int val)
  70. {
  71. static const unsigned short colorfx[][2] = {
  72. { V4L2_COLORFX_NONE, COMM_IMAGE_EFFECT_NONE },
  73. { V4L2_COLORFX_BW, COMM_IMAGE_EFFECT_MONO },
  74. { V4L2_COLORFX_SEPIA, COMM_IMAGE_EFFECT_SEPIA },
  75. { V4L2_COLORFX_NEGATIVE, COMM_IMAGE_EFFECT_NEGATIVE },
  76. { V4L2_COLORFX_AQUA, COMM_IMAGE_EFFECT_AQUA },
  77. };
  78. int i;
  79. for (i = 0; i < ARRAY_SIZE(colorfx); i++) {
  80. if (colorfx[i][0] != val)
  81. continue;
  82. v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd,
  83. "Setting %s color effect\n",
  84. v4l2_ctrl_get_menu(state->ctrls.colorfx->id)[i]);
  85. return s5c73m3_isp_command(state, COMM_IMAGE_EFFECT,
  86. colorfx[i][1]);
  87. }
  88. return -EINVAL;
  89. }
  90. /* Set exposure metering/exposure bias */
  91. static int s5c73m3_set_exposure(struct s5c73m3 *state, int auto_exp)
  92. {
  93. struct v4l2_subdev *sd = &state->sensor_sd;
  94. struct s5c73m3_ctrls *ctrls = &state->ctrls;
  95. int ret = 0;
  96. if (ctrls->exposure_metering->is_new) {
  97. u16 metering;
  98. switch (ctrls->exposure_metering->val) {
  99. case V4L2_EXPOSURE_METERING_CENTER_WEIGHTED:
  100. metering = COMM_METERING_CENTER;
  101. break;
  102. case V4L2_EXPOSURE_METERING_SPOT:
  103. metering = COMM_METERING_SPOT;
  104. break;
  105. default:
  106. metering = COMM_METERING_AVERAGE;
  107. break;
  108. }
  109. ret = s5c73m3_isp_command(state, COMM_METERING, metering);
  110. }
  111. if (!ret && ctrls->exposure_bias->is_new) {
  112. u16 exp_bias = ctrls->exposure_bias->val;
  113. ret = s5c73m3_isp_command(state, COMM_EV, exp_bias);
  114. }
  115. v4l2_dbg(1, s5c73m3_dbg, sd,
  116. "%s: exposure bias: %#x, metering: %#x (%d)\n", __func__,
  117. ctrls->exposure_bias->val, ctrls->exposure_metering->val, ret);
  118. return ret;
  119. }
  120. static int s5c73m3_set_white_balance(struct s5c73m3 *state, int val)
  121. {
  122. static const unsigned short wb[][2] = {
  123. { V4L2_WHITE_BALANCE_INCANDESCENT, COMM_AWB_MODE_INCANDESCENT},
  124. { V4L2_WHITE_BALANCE_FLUORESCENT, COMM_AWB_MODE_FLUORESCENT1},
  125. { V4L2_WHITE_BALANCE_FLUORESCENT_H, COMM_AWB_MODE_FLUORESCENT2},
  126. { V4L2_WHITE_BALANCE_CLOUDY, COMM_AWB_MODE_CLOUDY},
  127. { V4L2_WHITE_BALANCE_DAYLIGHT, COMM_AWB_MODE_DAYLIGHT},
  128. { V4L2_WHITE_BALANCE_AUTO, COMM_AWB_MODE_AUTO},
  129. };
  130. int i;
  131. for (i = 0; i < ARRAY_SIZE(wb); i++) {
  132. if (wb[i][0] != val)
  133. continue;
  134. v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd,
  135. "Setting white balance to: %s\n",
  136. v4l2_ctrl_get_menu(state->ctrls.auto_wb->id)[i]);
  137. return s5c73m3_isp_command(state, COMM_AWB_MODE, wb[i][1]);
  138. }
  139. return -EINVAL;
  140. }
  141. static int s5c73m3_af_run(struct s5c73m3 *state, bool on)
  142. {
  143. struct s5c73m3_ctrls *c = &state->ctrls;
  144. if (!on)
  145. return s5c73m3_isp_command(state, COMM_AF_CON,
  146. COMM_AF_CON_STOP);
  147. if (c->focus_auto->val)
  148. return s5c73m3_isp_command(state, COMM_AF_MODE,
  149. COMM_AF_MODE_PREVIEW_CAF_START);
  150. return s5c73m3_isp_command(state, COMM_AF_CON, COMM_AF_CON_START);
  151. }
  152. static int s5c73m3_3a_lock(struct s5c73m3 *state, struct v4l2_ctrl *ctrl)
  153. {
  154. bool awb_lock = ctrl->val & V4L2_LOCK_WHITE_BALANCE;
  155. bool ae_lock = ctrl->val & V4L2_LOCK_EXPOSURE;
  156. bool af_lock = ctrl->val & V4L2_LOCK_FOCUS;
  157. int ret = 0;
  158. if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_EXPOSURE) {
  159. ret = s5c73m3_isp_command(state, COMM_AE_CON,
  160. ae_lock ? COMM_AE_STOP : COMM_AE_START);
  161. if (ret)
  162. return ret;
  163. }
  164. if (((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_WHITE_BALANCE)
  165. && state->ctrls.auto_wb->val) {
  166. ret = s5c73m3_isp_command(state, COMM_AWB_CON,
  167. awb_lock ? COMM_AWB_STOP : COMM_AWB_START);
  168. if (ret)
  169. return ret;
  170. }
  171. if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS)
  172. ret = s5c73m3_af_run(state, !af_lock);
  173. return ret;
  174. }
  175. static int s5c73m3_set_auto_focus(struct s5c73m3 *state, int caf)
  176. {
  177. struct s5c73m3_ctrls *c = &state->ctrls;
  178. int ret = 1;
  179. if (c->af_distance->is_new) {
  180. u16 mode = (c->af_distance->val == V4L2_AUTO_FOCUS_RANGE_MACRO)
  181. ? COMM_AF_MODE_MACRO : COMM_AF_MODE_NORMAL;
  182. ret = s5c73m3_isp_command(state, COMM_AF_MODE, mode);
  183. if (ret != 0)
  184. return ret;
  185. }
  186. if (!ret || (c->focus_auto->is_new && c->focus_auto->val) ||
  187. c->af_start->is_new)
  188. ret = s5c73m3_af_run(state, 1);
  189. else if ((c->focus_auto->is_new && !c->focus_auto->val) ||
  190. c->af_stop->is_new)
  191. ret = s5c73m3_af_run(state, 0);
  192. else
  193. ret = 0;
  194. return ret;
  195. }
  196. static int s5c73m3_set_contrast(struct s5c73m3 *state, int val)
  197. {
  198. u16 reg = (val < 0) ? -val + 2 : val;
  199. return s5c73m3_isp_command(state, COMM_CONTRAST, reg);
  200. }
  201. static int s5c73m3_set_saturation(struct s5c73m3 *state, int val)
  202. {
  203. u16 reg = (val < 0) ? -val + 2 : val;
  204. return s5c73m3_isp_command(state, COMM_SATURATION, reg);
  205. }
  206. static int s5c73m3_set_sharpness(struct s5c73m3 *state, int val)
  207. {
  208. u16 reg = (val < 0) ? -val + 2 : val;
  209. return s5c73m3_isp_command(state, COMM_SHARPNESS, reg);
  210. }
  211. static int s5c73m3_set_iso(struct s5c73m3 *state, int val)
  212. {
  213. u32 iso;
  214. if (val == V4L2_ISO_SENSITIVITY_MANUAL)
  215. iso = state->ctrls.iso->val + 1;
  216. else
  217. iso = 0;
  218. return s5c73m3_isp_command(state, COMM_ISO, iso);
  219. }
  220. static int s5c73m3_set_stabilization(struct s5c73m3 *state, int val)
  221. {
  222. struct v4l2_subdev *sd = &state->sensor_sd;
  223. v4l2_dbg(1, s5c73m3_dbg, sd, "Image stabilization: %d\n", val);
  224. return s5c73m3_isp_command(state, COMM_FRAME_RATE, val ?
  225. COMM_FRAME_RATE_ANTI_SHAKE : COMM_FRAME_RATE_AUTO_SET);
  226. }
  227. static int s5c73m3_set_jpeg_quality(struct s5c73m3 *state, int quality)
  228. {
  229. int reg;
  230. if (quality <= 65)
  231. reg = COMM_IMAGE_QUALITY_NORMAL;
  232. else if (quality <= 75)
  233. reg = COMM_IMAGE_QUALITY_FINE;
  234. else
  235. reg = COMM_IMAGE_QUALITY_SUPERFINE;
  236. return s5c73m3_isp_command(state, COMM_IMAGE_QUALITY, reg);
  237. }
  238. static int s5c73m3_set_scene_program(struct s5c73m3 *state, int val)
  239. {
  240. static const unsigned short scene_lookup[] = {
  241. COMM_SCENE_MODE_NONE, /* V4L2_SCENE_MODE_NONE */
  242. COMM_SCENE_MODE_AGAINST_LIGHT,/* V4L2_SCENE_MODE_BACKLIGHT */
  243. COMM_SCENE_MODE_BEACH, /* V4L2_SCENE_MODE_BEACH_SNOW */
  244. COMM_SCENE_MODE_CANDLE, /* V4L2_SCENE_MODE_CANDLE_LIGHT */
  245. COMM_SCENE_MODE_DAWN, /* V4L2_SCENE_MODE_DAWN_DUSK */
  246. COMM_SCENE_MODE_FALL, /* V4L2_SCENE_MODE_FALL_COLORS */
  247. COMM_SCENE_MODE_FIRE, /* V4L2_SCENE_MODE_FIREWORKS */
  248. COMM_SCENE_MODE_LANDSCAPE, /* V4L2_SCENE_MODE_LANDSCAPE */
  249. COMM_SCENE_MODE_NIGHT, /* V4L2_SCENE_MODE_NIGHT */
  250. COMM_SCENE_MODE_INDOOR, /* V4L2_SCENE_MODE_PARTY_INDOOR */
  251. COMM_SCENE_MODE_PORTRAIT, /* V4L2_SCENE_MODE_PORTRAIT */
  252. COMM_SCENE_MODE_SPORTS, /* V4L2_SCENE_MODE_SPORTS */
  253. COMM_SCENE_MODE_SUNSET, /* V4L2_SCENE_MODE_SUNSET */
  254. COMM_SCENE_MODE_TEXT, /* V4L2_SCENE_MODE_TEXT */
  255. };
  256. v4l2_dbg(1, s5c73m3_dbg, &state->sensor_sd, "Setting %s scene mode\n",
  257. v4l2_ctrl_get_menu(state->ctrls.scene_mode->id)[val]);
  258. return s5c73m3_isp_command(state, COMM_SCENE_MODE, scene_lookup[val]);
  259. }
  260. static int s5c73m3_set_power_line_freq(struct s5c73m3 *state, int val)
  261. {
  262. unsigned int pwr_line_freq = COMM_FLICKER_NONE;
  263. switch (val) {
  264. case V4L2_CID_POWER_LINE_FREQUENCY_DISABLED:
  265. pwr_line_freq = COMM_FLICKER_NONE;
  266. break;
  267. case V4L2_CID_POWER_LINE_FREQUENCY_50HZ:
  268. pwr_line_freq = COMM_FLICKER_AUTO_50HZ;
  269. break;
  270. case V4L2_CID_POWER_LINE_FREQUENCY_60HZ:
  271. pwr_line_freq = COMM_FLICKER_AUTO_60HZ;
  272. break;
  273. default:
  274. case V4L2_CID_POWER_LINE_FREQUENCY_AUTO:
  275. pwr_line_freq = COMM_FLICKER_NONE;
  276. }
  277. return s5c73m3_isp_command(state, COMM_FLICKER_MODE, pwr_line_freq);
  278. }
  279. static int s5c73m3_s_ctrl(struct v4l2_ctrl *ctrl)
  280. {
  281. struct v4l2_subdev *sd = ctrl_to_sensor_sd(ctrl);
  282. struct s5c73m3 *state = sensor_sd_to_s5c73m3(sd);
  283. int ret = 0;
  284. v4l2_dbg(1, s5c73m3_dbg, sd, "set_ctrl: %s, value: %d\n",
  285. ctrl->name, ctrl->val);
  286. mutex_lock(&state->lock);
  287. /*
  288. * If the device is not powered up by the host driver do
  289. * not apply any controls to H/W at this time. Instead
  290. * the controls will be restored right after power-up.
  291. */
  292. if (state->power == 0)
  293. goto unlock;
  294. if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) {
  295. ret = -EINVAL;
  296. goto unlock;
  297. }
  298. switch (ctrl->id) {
  299. case V4L2_CID_3A_LOCK:
  300. ret = s5c73m3_3a_lock(state, ctrl);
  301. break;
  302. case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
  303. ret = s5c73m3_set_white_balance(state, ctrl->val);
  304. break;
  305. case V4L2_CID_CONTRAST:
  306. ret = s5c73m3_set_contrast(state, ctrl->val);
  307. break;
  308. case V4L2_CID_COLORFX:
  309. ret = s5c73m3_set_colorfx(state, ctrl->val);
  310. break;
  311. case V4L2_CID_EXPOSURE_AUTO:
  312. ret = s5c73m3_set_exposure(state, ctrl->val);
  313. break;
  314. case V4L2_CID_FOCUS_AUTO:
  315. ret = s5c73m3_set_auto_focus(state, ctrl->val);
  316. break;
  317. case V4L2_CID_IMAGE_STABILIZATION:
  318. ret = s5c73m3_set_stabilization(state, ctrl->val);
  319. break;
  320. case V4L2_CID_ISO_SENSITIVITY:
  321. ret = s5c73m3_set_iso(state, ctrl->val);
  322. break;
  323. case V4L2_CID_JPEG_COMPRESSION_QUALITY:
  324. ret = s5c73m3_set_jpeg_quality(state, ctrl->val);
  325. break;
  326. case V4L2_CID_POWER_LINE_FREQUENCY:
  327. ret = s5c73m3_set_power_line_freq(state, ctrl->val);
  328. break;
  329. case V4L2_CID_SATURATION:
  330. ret = s5c73m3_set_saturation(state, ctrl->val);
  331. break;
  332. case V4L2_CID_SCENE_MODE:
  333. ret = s5c73m3_set_scene_program(state, ctrl->val);
  334. break;
  335. case V4L2_CID_SHARPNESS:
  336. ret = s5c73m3_set_sharpness(state, ctrl->val);
  337. break;
  338. case V4L2_CID_WIDE_DYNAMIC_RANGE:
  339. ret = s5c73m3_isp_command(state, COMM_WDR, !!ctrl->val);
  340. break;
  341. case V4L2_CID_ZOOM_ABSOLUTE:
  342. ret = s5c73m3_isp_command(state, COMM_ZOOM_STEP, ctrl->val);
  343. break;
  344. }
  345. unlock:
  346. mutex_unlock(&state->lock);
  347. return ret;
  348. }
  349. static const struct v4l2_ctrl_ops s5c73m3_ctrl_ops = {
  350. .g_volatile_ctrl = s5c73m3_g_volatile_ctrl,
  351. .s_ctrl = s5c73m3_s_ctrl,
  352. };
  353. /* Supported manual ISO values */
  354. static const s64 iso_qmenu[] = {
  355. /* COMM_ISO: 0x0001...0x0004 */
  356. 100, 200, 400, 800,
  357. };
  358. /* Supported exposure bias values (-2.0EV...+2.0EV) */
  359. static const s64 ev_bias_qmenu[] = {
  360. /* COMM_EV: 0x0000...0x0008 */
  361. -2000, -1500, -1000, -500, 0, 500, 1000, 1500, 2000
  362. };
  363. int s5c73m3_init_controls(struct s5c73m3 *state)
  364. {
  365. const struct v4l2_ctrl_ops *ops = &s5c73m3_ctrl_ops;
  366. struct s5c73m3_ctrls *ctrls = &state->ctrls;
  367. struct v4l2_ctrl_handler *hdl = &ctrls->handler;
  368. int ret = v4l2_ctrl_handler_init(hdl, 22);
  369. if (ret)
  370. return ret;
  371. /* White balance */
  372. ctrls->auto_wb = v4l2_ctrl_new_std_menu(hdl, ops,
  373. V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
  374. 9, ~0x15e, V4L2_WHITE_BALANCE_AUTO);
  375. /* Exposure (only automatic exposure) */
  376. ctrls->auto_exposure = v4l2_ctrl_new_std_menu(hdl, ops,
  377. V4L2_CID_EXPOSURE_AUTO, 0, ~0x01, V4L2_EXPOSURE_AUTO);
  378. ctrls->exposure_bias = v4l2_ctrl_new_int_menu(hdl, ops,
  379. V4L2_CID_AUTO_EXPOSURE_BIAS,
  380. ARRAY_SIZE(ev_bias_qmenu) - 1,
  381. ARRAY_SIZE(ev_bias_qmenu)/2 - 1,
  382. ev_bias_qmenu);
  383. ctrls->exposure_metering = v4l2_ctrl_new_std_menu(hdl, ops,
  384. V4L2_CID_EXPOSURE_METERING,
  385. 2, ~0x7, V4L2_EXPOSURE_METERING_AVERAGE);
  386. /* Auto focus */
  387. ctrls->focus_auto = v4l2_ctrl_new_std(hdl, ops,
  388. V4L2_CID_FOCUS_AUTO, 0, 1, 1, 0);
  389. ctrls->af_start = v4l2_ctrl_new_std(hdl, ops,
  390. V4L2_CID_AUTO_FOCUS_START, 0, 1, 1, 0);
  391. ctrls->af_stop = v4l2_ctrl_new_std(hdl, ops,
  392. V4L2_CID_AUTO_FOCUS_STOP, 0, 1, 1, 0);
  393. ctrls->af_status = v4l2_ctrl_new_std(hdl, ops,
  394. V4L2_CID_AUTO_FOCUS_STATUS, 0,
  395. (V4L2_AUTO_FOCUS_STATUS_BUSY |
  396. V4L2_AUTO_FOCUS_STATUS_REACHED |
  397. V4L2_AUTO_FOCUS_STATUS_FAILED),
  398. 0, V4L2_AUTO_FOCUS_STATUS_IDLE);
  399. ctrls->af_distance = v4l2_ctrl_new_std_menu(hdl, ops,
  400. V4L2_CID_AUTO_FOCUS_RANGE,
  401. V4L2_AUTO_FOCUS_RANGE_MACRO,
  402. ~(1 << V4L2_AUTO_FOCUS_RANGE_NORMAL |
  403. 1 << V4L2_AUTO_FOCUS_RANGE_MACRO),
  404. V4L2_AUTO_FOCUS_RANGE_NORMAL);
  405. /* ISO sensitivity */
  406. ctrls->auto_iso = v4l2_ctrl_new_std_menu(hdl, ops,
  407. V4L2_CID_ISO_SENSITIVITY_AUTO, 1, 0,
  408. V4L2_ISO_SENSITIVITY_AUTO);
  409. ctrls->iso = v4l2_ctrl_new_int_menu(hdl, ops,
  410. V4L2_CID_ISO_SENSITIVITY, ARRAY_SIZE(iso_qmenu) - 1,
  411. ARRAY_SIZE(iso_qmenu)/2 - 1, iso_qmenu);
  412. ctrls->contrast = v4l2_ctrl_new_std(hdl, ops,
  413. V4L2_CID_CONTRAST, -2, 2, 1, 0);
  414. ctrls->saturation = v4l2_ctrl_new_std(hdl, ops,
  415. V4L2_CID_SATURATION, -2, 2, 1, 0);
  416. ctrls->sharpness = v4l2_ctrl_new_std(hdl, ops,
  417. V4L2_CID_SHARPNESS, -2, 2, 1, 0);
  418. ctrls->zoom = v4l2_ctrl_new_std(hdl, ops,
  419. V4L2_CID_ZOOM_ABSOLUTE, 0, 30, 1, 0);
  420. ctrls->colorfx = v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_COLORFX,
  421. V4L2_COLORFX_AQUA, ~0x40f, V4L2_COLORFX_NONE);
  422. ctrls->wdr = v4l2_ctrl_new_std(hdl, ops,
  423. V4L2_CID_WIDE_DYNAMIC_RANGE, 0, 1, 1, 0);
  424. ctrls->stabilization = v4l2_ctrl_new_std(hdl, ops,
  425. V4L2_CID_IMAGE_STABILIZATION, 0, 1, 1, 0);
  426. v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_POWER_LINE_FREQUENCY,
  427. V4L2_CID_POWER_LINE_FREQUENCY_AUTO, 0,
  428. V4L2_CID_POWER_LINE_FREQUENCY_AUTO);
  429. ctrls->jpeg_quality = v4l2_ctrl_new_std(hdl, ops,
  430. V4L2_CID_JPEG_COMPRESSION_QUALITY, 1, 100, 1, 80);
  431. ctrls->scene_mode = v4l2_ctrl_new_std_menu(hdl, ops,
  432. V4L2_CID_SCENE_MODE, V4L2_SCENE_MODE_TEXT, ~0x3fff,
  433. V4L2_SCENE_MODE_NONE);
  434. ctrls->aaa_lock = v4l2_ctrl_new_std(hdl, ops,
  435. V4L2_CID_3A_LOCK, 0, 0x7, 0, 0);
  436. if (hdl->error) {
  437. ret = hdl->error;
  438. v4l2_ctrl_handler_free(hdl);
  439. return ret;
  440. }
  441. v4l2_ctrl_auto_cluster(3, &ctrls->auto_exposure, 0, false);
  442. ctrls->auto_iso->flags |= V4L2_CTRL_FLAG_VOLATILE |
  443. V4L2_CTRL_FLAG_UPDATE;
  444. v4l2_ctrl_auto_cluster(2, &ctrls->auto_iso, 0, false);
  445. ctrls->af_status->flags |= V4L2_CTRL_FLAG_VOLATILE;
  446. v4l2_ctrl_cluster(5, &ctrls->focus_auto);
  447. state->sensor_sd.ctrl_handler = hdl;
  448. return 0;
  449. }