fimc-is-param.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
  4. *
  5. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  6. *
  7. * Authors: Younghwan Joo <yhwan.joo@samsung.com>
  8. * Sylwester Nawrocki <s.nawrocki@samsung.com>
  9. */
  10. #define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
  11. #include <linux/bitops.h>
  12. #include <linux/bug.h>
  13. #include <linux/device.h>
  14. #include <linux/errno.h>
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/slab.h>
  19. #include <linux/types.h>
  20. #include <linux/videodev2.h>
  21. #include <media/v4l2-device.h>
  22. #include <media/v4l2-ioctl.h>
  23. #include "fimc-is.h"
  24. #include "fimc-is-command.h"
  25. #include "fimc-is-errno.h"
  26. #include "fimc-is-param.h"
  27. #include "fimc-is-regs.h"
  28. #include "fimc-is-sensor.h"
  29. static void __hw_param_copy(void *dst, void *src)
  30. {
  31. memcpy(dst, src, FIMC_IS_PARAM_MAX_SIZE);
  32. }
  33. static void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is)
  34. {
  35. struct param_global_shotmode *dst, *src;
  36. dst = &is->is_p_region->parameter.global.shotmode;
  37. src = &is->config[is->config_index].global.shotmode;
  38. __hw_param_copy(dst, src);
  39. }
  40. static void __fimc_is_hw_update_param_sensor_framerate(struct fimc_is *is)
  41. {
  42. struct param_sensor_framerate *dst, *src;
  43. dst = &is->is_p_region->parameter.sensor.frame_rate;
  44. src = &is->config[is->config_index].sensor.frame_rate;
  45. __hw_param_copy(dst, src);
  46. }
  47. int __fimc_is_hw_update_param(struct fimc_is *is, u32 offset)
  48. {
  49. struct is_param_region *par = &is->is_p_region->parameter;
  50. struct chain_config *cfg = &is->config[is->config_index];
  51. switch (offset) {
  52. case PARAM_ISP_CONTROL:
  53. __hw_param_copy(&par->isp.control, &cfg->isp.control);
  54. break;
  55. case PARAM_ISP_OTF_INPUT:
  56. __hw_param_copy(&par->isp.otf_input, &cfg->isp.otf_input);
  57. break;
  58. case PARAM_ISP_DMA1_INPUT:
  59. __hw_param_copy(&par->isp.dma1_input, &cfg->isp.dma1_input);
  60. break;
  61. case PARAM_ISP_DMA2_INPUT:
  62. __hw_param_copy(&par->isp.dma2_input, &cfg->isp.dma2_input);
  63. break;
  64. case PARAM_ISP_AA:
  65. __hw_param_copy(&par->isp.aa, &cfg->isp.aa);
  66. break;
  67. case PARAM_ISP_FLASH:
  68. __hw_param_copy(&par->isp.flash, &cfg->isp.flash);
  69. break;
  70. case PARAM_ISP_AWB:
  71. __hw_param_copy(&par->isp.awb, &cfg->isp.awb);
  72. break;
  73. case PARAM_ISP_IMAGE_EFFECT:
  74. __hw_param_copy(&par->isp.effect, &cfg->isp.effect);
  75. break;
  76. case PARAM_ISP_ISO:
  77. __hw_param_copy(&par->isp.iso, &cfg->isp.iso);
  78. break;
  79. case PARAM_ISP_ADJUST:
  80. __hw_param_copy(&par->isp.adjust, &cfg->isp.adjust);
  81. break;
  82. case PARAM_ISP_METERING:
  83. __hw_param_copy(&par->isp.metering, &cfg->isp.metering);
  84. break;
  85. case PARAM_ISP_AFC:
  86. __hw_param_copy(&par->isp.afc, &cfg->isp.afc);
  87. break;
  88. case PARAM_ISP_OTF_OUTPUT:
  89. __hw_param_copy(&par->isp.otf_output, &cfg->isp.otf_output);
  90. break;
  91. case PARAM_ISP_DMA1_OUTPUT:
  92. __hw_param_copy(&par->isp.dma1_output, &cfg->isp.dma1_output);
  93. break;
  94. case PARAM_ISP_DMA2_OUTPUT:
  95. __hw_param_copy(&par->isp.dma2_output, &cfg->isp.dma2_output);
  96. break;
  97. case PARAM_DRC_CONTROL:
  98. __hw_param_copy(&par->drc.control, &cfg->drc.control);
  99. break;
  100. case PARAM_DRC_OTF_INPUT:
  101. __hw_param_copy(&par->drc.otf_input, &cfg->drc.otf_input);
  102. break;
  103. case PARAM_DRC_DMA_INPUT:
  104. __hw_param_copy(&par->drc.dma_input, &cfg->drc.dma_input);
  105. break;
  106. case PARAM_DRC_OTF_OUTPUT:
  107. __hw_param_copy(&par->drc.otf_output, &cfg->drc.otf_output);
  108. break;
  109. case PARAM_FD_CONTROL:
  110. __hw_param_copy(&par->fd.control, &cfg->fd.control);
  111. break;
  112. case PARAM_FD_OTF_INPUT:
  113. __hw_param_copy(&par->fd.otf_input, &cfg->fd.otf_input);
  114. break;
  115. case PARAM_FD_DMA_INPUT:
  116. __hw_param_copy(&par->fd.dma_input, &cfg->fd.dma_input);
  117. break;
  118. case PARAM_FD_CONFIG:
  119. __hw_param_copy(&par->fd.config, &cfg->fd.config);
  120. break;
  121. default:
  122. return -EINVAL;
  123. }
  124. return 0;
  125. }
  126. unsigned int __get_pending_param_count(struct fimc_is *is)
  127. {
  128. struct chain_config *config = &is->config[is->config_index];
  129. unsigned long flags;
  130. unsigned int count;
  131. spin_lock_irqsave(&is->slock, flags);
  132. count = hweight32(config->p_region_index[0]);
  133. count += hweight32(config->p_region_index[1]);
  134. spin_unlock_irqrestore(&is->slock, flags);
  135. return count;
  136. }
  137. int __is_hw_update_params(struct fimc_is *is)
  138. {
  139. unsigned long *p_index;
  140. int i, id, ret = 0;
  141. id = is->config_index;
  142. p_index = &is->config[id].p_region_index[0];
  143. if (test_bit(PARAM_GLOBAL_SHOTMODE, p_index))
  144. __fimc_is_hw_update_param_global_shotmode(is);
  145. if (test_bit(PARAM_SENSOR_FRAME_RATE, p_index))
  146. __fimc_is_hw_update_param_sensor_framerate(is);
  147. for (i = PARAM_ISP_CONTROL; i < PARAM_DRC_CONTROL; i++) {
  148. if (test_bit(i, p_index))
  149. ret = __fimc_is_hw_update_param(is, i);
  150. }
  151. for (i = PARAM_DRC_CONTROL; i < PARAM_SCALERC_CONTROL; i++) {
  152. if (test_bit(i, p_index))
  153. ret = __fimc_is_hw_update_param(is, i);
  154. }
  155. for (i = PARAM_FD_CONTROL; i <= PARAM_FD_CONFIG; i++) {
  156. if (test_bit(i, p_index))
  157. ret = __fimc_is_hw_update_param(is, i);
  158. }
  159. return ret;
  160. }
  161. void __is_get_frame_size(struct fimc_is *is, struct v4l2_mbus_framefmt *mf)
  162. {
  163. struct isp_param *isp;
  164. isp = &is->config[is->config_index].isp;
  165. mf->width = isp->otf_input.width;
  166. mf->height = isp->otf_input.height;
  167. }
  168. void __is_set_frame_size(struct fimc_is *is, struct v4l2_mbus_framefmt *mf)
  169. {
  170. unsigned int index = is->config_index;
  171. struct isp_param *isp;
  172. struct drc_param *drc;
  173. struct fd_param *fd;
  174. isp = &is->config[index].isp;
  175. drc = &is->config[index].drc;
  176. fd = &is->config[index].fd;
  177. /* Update isp size info (OTF only) */
  178. isp->otf_input.width = mf->width;
  179. isp->otf_input.height = mf->height;
  180. isp->otf_output.width = mf->width;
  181. isp->otf_output.height = mf->height;
  182. /* Update drc size info (OTF only) */
  183. drc->otf_input.width = mf->width;
  184. drc->otf_input.height = mf->height;
  185. drc->otf_output.width = mf->width;
  186. drc->otf_output.height = mf->height;
  187. /* Update fd size info (OTF only) */
  188. fd->otf_input.width = mf->width;
  189. fd->otf_input.height = mf->height;
  190. if (test_bit(PARAM_ISP_OTF_INPUT,
  191. &is->config[index].p_region_index[0]))
  192. return;
  193. /* Update field */
  194. fimc_is_set_param_bit(is, PARAM_ISP_OTF_INPUT);
  195. fimc_is_set_param_bit(is, PARAM_ISP_OTF_OUTPUT);
  196. fimc_is_set_param_bit(is, PARAM_DRC_OTF_INPUT);
  197. fimc_is_set_param_bit(is, PARAM_DRC_OTF_OUTPUT);
  198. fimc_is_set_param_bit(is, PARAM_FD_OTF_INPUT);
  199. }
  200. int fimc_is_hw_get_sensor_max_framerate(struct fimc_is *is)
  201. {
  202. switch (is->sensor->drvdata->id) {
  203. case FIMC_IS_SENSOR_ID_S5K6A3:
  204. return 30;
  205. default:
  206. return 15;
  207. }
  208. }
  209. void __is_set_sensor(struct fimc_is *is, int fps)
  210. {
  211. unsigned int index = is->config_index;
  212. struct sensor_param *sensor;
  213. struct isp_param *isp;
  214. sensor = &is->config[index].sensor;
  215. isp = &is->config[index].isp;
  216. if (fps == 0) {
  217. sensor->frame_rate.frame_rate =
  218. fimc_is_hw_get_sensor_max_framerate(is);
  219. isp->otf_input.frametime_min = 0;
  220. isp->otf_input.frametime_max = 66666;
  221. } else {
  222. sensor->frame_rate.frame_rate = fps;
  223. isp->otf_input.frametime_min = 0;
  224. isp->otf_input.frametime_max = (u32)1000000 / fps;
  225. }
  226. fimc_is_set_param_bit(is, PARAM_SENSOR_FRAME_RATE);
  227. fimc_is_set_param_bit(is, PARAM_ISP_OTF_INPUT);
  228. }
  229. static void __maybe_unused __is_set_init_isp_aa(struct fimc_is *is)
  230. {
  231. struct isp_param *isp;
  232. isp = &is->config[is->config_index].isp;
  233. isp->aa.cmd = ISP_AA_COMMAND_START;
  234. isp->aa.target = ISP_AA_TARGET_AF | ISP_AA_TARGET_AE |
  235. ISP_AA_TARGET_AWB;
  236. isp->aa.mode = 0;
  237. isp->aa.scene = 0;
  238. isp->aa.sleep = 0;
  239. isp->aa.face = 0;
  240. isp->aa.touch_x = 0;
  241. isp->aa.touch_y = 0;
  242. isp->aa.manual_af_setting = 0;
  243. isp->aa.err = ISP_AF_ERROR_NONE;
  244. fimc_is_set_param_bit(is, PARAM_ISP_AA);
  245. }
  246. void __is_set_isp_flash(struct fimc_is *is, u32 cmd, u32 redeye)
  247. {
  248. unsigned int index = is->config_index;
  249. struct isp_param *isp = &is->config[index].isp;
  250. isp->flash.cmd = cmd;
  251. isp->flash.redeye = redeye;
  252. isp->flash.err = ISP_FLASH_ERROR_NONE;
  253. fimc_is_set_param_bit(is, PARAM_ISP_FLASH);
  254. }
  255. void __is_set_isp_awb(struct fimc_is *is, u32 cmd, u32 val)
  256. {
  257. unsigned int index = is->config_index;
  258. struct isp_param *isp;
  259. isp = &is->config[index].isp;
  260. isp->awb.cmd = cmd;
  261. isp->awb.illumination = val;
  262. isp->awb.err = ISP_AWB_ERROR_NONE;
  263. fimc_is_set_param_bit(is, PARAM_ISP_AWB);
  264. }
  265. void __is_set_isp_effect(struct fimc_is *is, u32 cmd)
  266. {
  267. unsigned int index = is->config_index;
  268. struct isp_param *isp;
  269. isp = &is->config[index].isp;
  270. isp->effect.cmd = cmd;
  271. isp->effect.err = ISP_IMAGE_EFFECT_ERROR_NONE;
  272. fimc_is_set_param_bit(is, PARAM_ISP_IMAGE_EFFECT);
  273. }
  274. void __is_set_isp_iso(struct fimc_is *is, u32 cmd, u32 val)
  275. {
  276. unsigned int index = is->config_index;
  277. struct isp_param *isp;
  278. isp = &is->config[index].isp;
  279. isp->iso.cmd = cmd;
  280. isp->iso.value = val;
  281. isp->iso.err = ISP_ISO_ERROR_NONE;
  282. fimc_is_set_param_bit(is, PARAM_ISP_ISO);
  283. }
  284. void __is_set_isp_adjust(struct fimc_is *is, u32 cmd, u32 val)
  285. {
  286. unsigned int index = is->config_index;
  287. unsigned long *p_index;
  288. struct isp_param *isp;
  289. p_index = &is->config[index].p_region_index[0];
  290. isp = &is->config[index].isp;
  291. switch (cmd) {
  292. case ISP_ADJUST_COMMAND_MANUAL_CONTRAST:
  293. isp->adjust.contrast = val;
  294. break;
  295. case ISP_ADJUST_COMMAND_MANUAL_SATURATION:
  296. isp->adjust.saturation = val;
  297. break;
  298. case ISP_ADJUST_COMMAND_MANUAL_SHARPNESS:
  299. isp->adjust.sharpness = val;
  300. break;
  301. case ISP_ADJUST_COMMAND_MANUAL_EXPOSURE:
  302. isp->adjust.exposure = val;
  303. break;
  304. case ISP_ADJUST_COMMAND_MANUAL_BRIGHTNESS:
  305. isp->adjust.brightness = val;
  306. break;
  307. case ISP_ADJUST_COMMAND_MANUAL_HUE:
  308. isp->adjust.hue = val;
  309. break;
  310. case ISP_ADJUST_COMMAND_AUTO:
  311. isp->adjust.contrast = 0;
  312. isp->adjust.saturation = 0;
  313. isp->adjust.sharpness = 0;
  314. isp->adjust.exposure = 0;
  315. isp->adjust.brightness = 0;
  316. isp->adjust.hue = 0;
  317. break;
  318. }
  319. if (!test_bit(PARAM_ISP_ADJUST, p_index)) {
  320. isp->adjust.cmd = cmd;
  321. isp->adjust.err = ISP_ADJUST_ERROR_NONE;
  322. fimc_is_set_param_bit(is, PARAM_ISP_ADJUST);
  323. } else {
  324. isp->adjust.cmd |= cmd;
  325. }
  326. }
  327. void __is_set_isp_metering(struct fimc_is *is, u32 id, u32 val)
  328. {
  329. unsigned int index = is->config_index;
  330. struct isp_param *isp;
  331. unsigned long *p_index;
  332. p_index = &is->config[index].p_region_index[0];
  333. isp = &is->config[index].isp;
  334. switch (id) {
  335. case IS_METERING_CONFIG_CMD:
  336. isp->metering.cmd = val;
  337. break;
  338. case IS_METERING_CONFIG_WIN_POS_X:
  339. isp->metering.win_pos_x = val;
  340. break;
  341. case IS_METERING_CONFIG_WIN_POS_Y:
  342. isp->metering.win_pos_y = val;
  343. break;
  344. case IS_METERING_CONFIG_WIN_WIDTH:
  345. isp->metering.win_width = val;
  346. break;
  347. case IS_METERING_CONFIG_WIN_HEIGHT:
  348. isp->metering.win_height = val;
  349. break;
  350. default:
  351. return;
  352. }
  353. if (!test_bit(PARAM_ISP_METERING, p_index)) {
  354. isp->metering.err = ISP_METERING_ERROR_NONE;
  355. fimc_is_set_param_bit(is, PARAM_ISP_METERING);
  356. }
  357. }
  358. void __is_set_isp_afc(struct fimc_is *is, u32 cmd, u32 val)
  359. {
  360. unsigned int index = is->config_index;
  361. struct isp_param *isp;
  362. isp = &is->config[index].isp;
  363. isp->afc.cmd = cmd;
  364. isp->afc.manual = val;
  365. isp->afc.err = ISP_AFC_ERROR_NONE;
  366. fimc_is_set_param_bit(is, PARAM_ISP_AFC);
  367. }
  368. void __is_set_drc_control(struct fimc_is *is, u32 val)
  369. {
  370. unsigned int index = is->config_index;
  371. struct drc_param *drc;
  372. drc = &is->config[index].drc;
  373. drc->control.bypass = val;
  374. fimc_is_set_param_bit(is, PARAM_DRC_CONTROL);
  375. }
  376. void __is_set_fd_control(struct fimc_is *is, u32 val)
  377. {
  378. unsigned int index = is->config_index;
  379. struct fd_param *fd;
  380. unsigned long *p_index;
  381. p_index = &is->config[index].p_region_index[1];
  382. fd = &is->config[index].fd;
  383. fd->control.cmd = val;
  384. if (!test_bit((PARAM_FD_CONFIG - 32), p_index))
  385. fimc_is_set_param_bit(is, PARAM_FD_CONTROL);
  386. }
  387. void __is_set_fd_config_maxface(struct fimc_is *is, u32 val)
  388. {
  389. unsigned int index = is->config_index;
  390. struct fd_param *fd;
  391. unsigned long *p_index;
  392. p_index = &is->config[index].p_region_index[1];
  393. fd = &is->config[index].fd;
  394. fd->config.max_number = val;
  395. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  396. fd->config.cmd = FD_CONFIG_COMMAND_MAXIMUM_NUMBER;
  397. fd->config.err = ERROR_FD_NONE;
  398. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  399. } else {
  400. fd->config.cmd |= FD_CONFIG_COMMAND_MAXIMUM_NUMBER;
  401. }
  402. }
  403. void __is_set_fd_config_rollangle(struct fimc_is *is, u32 val)
  404. {
  405. unsigned int index = is->config_index;
  406. struct fd_param *fd;
  407. unsigned long *p_index;
  408. p_index = &is->config[index].p_region_index[1];
  409. fd = &is->config[index].fd;
  410. fd->config.roll_angle = val;
  411. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  412. fd->config.cmd = FD_CONFIG_COMMAND_ROLL_ANGLE;
  413. fd->config.err = ERROR_FD_NONE;
  414. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  415. } else {
  416. fd->config.cmd |= FD_CONFIG_COMMAND_ROLL_ANGLE;
  417. }
  418. }
  419. void __is_set_fd_config_yawangle(struct fimc_is *is, u32 val)
  420. {
  421. unsigned int index = is->config_index;
  422. struct fd_param *fd;
  423. unsigned long *p_index;
  424. p_index = &is->config[index].p_region_index[1];
  425. fd = &is->config[index].fd;
  426. fd->config.yaw_angle = val;
  427. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  428. fd->config.cmd = FD_CONFIG_COMMAND_YAW_ANGLE;
  429. fd->config.err = ERROR_FD_NONE;
  430. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  431. } else {
  432. fd->config.cmd |= FD_CONFIG_COMMAND_YAW_ANGLE;
  433. }
  434. }
  435. void __is_set_fd_config_smilemode(struct fimc_is *is, u32 val)
  436. {
  437. unsigned int index = is->config_index;
  438. struct fd_param *fd;
  439. unsigned long *p_index;
  440. p_index = &is->config[index].p_region_index[1];
  441. fd = &is->config[index].fd;
  442. fd->config.smile_mode = val;
  443. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  444. fd->config.cmd = FD_CONFIG_COMMAND_SMILE_MODE;
  445. fd->config.err = ERROR_FD_NONE;
  446. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  447. } else {
  448. fd->config.cmd |= FD_CONFIG_COMMAND_SMILE_MODE;
  449. }
  450. }
  451. void __is_set_fd_config_blinkmode(struct fimc_is *is, u32 val)
  452. {
  453. unsigned int index = is->config_index;
  454. struct fd_param *fd;
  455. unsigned long *p_index;
  456. p_index = &is->config[index].p_region_index[1];
  457. fd = &is->config[index].fd;
  458. fd->config.blink_mode = val;
  459. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  460. fd->config.cmd = FD_CONFIG_COMMAND_BLINK_MODE;
  461. fd->config.err = ERROR_FD_NONE;
  462. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  463. } else {
  464. fd->config.cmd |= FD_CONFIG_COMMAND_BLINK_MODE;
  465. }
  466. }
  467. void __is_set_fd_config_eyedetect(struct fimc_is *is, u32 val)
  468. {
  469. unsigned int index = is->config_index;
  470. struct fd_param *fd;
  471. unsigned long *p_index;
  472. p_index = &is->config[index].p_region_index[1];
  473. fd = &is->config[index].fd;
  474. fd->config.eye_detect = val;
  475. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  476. fd->config.cmd = FD_CONFIG_COMMAND_EYES_DETECT;
  477. fd->config.err = ERROR_FD_NONE;
  478. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  479. } else {
  480. fd->config.cmd |= FD_CONFIG_COMMAND_EYES_DETECT;
  481. }
  482. }
  483. void __is_set_fd_config_mouthdetect(struct fimc_is *is, u32 val)
  484. {
  485. unsigned int index = is->config_index;
  486. struct fd_param *fd;
  487. unsigned long *p_index;
  488. p_index = &is->config[index].p_region_index[1];
  489. fd = &is->config[index].fd;
  490. fd->config.mouth_detect = val;
  491. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  492. fd->config.cmd = FD_CONFIG_COMMAND_MOUTH_DETECT;
  493. fd->config.err = ERROR_FD_NONE;
  494. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  495. } else {
  496. fd->config.cmd |= FD_CONFIG_COMMAND_MOUTH_DETECT;
  497. }
  498. }
  499. void __is_set_fd_config_orientation(struct fimc_is *is, u32 val)
  500. {
  501. unsigned int index = is->config_index;
  502. struct fd_param *fd;
  503. unsigned long *p_index;
  504. p_index = &is->config[index].p_region_index[1];
  505. fd = &is->config[index].fd;
  506. fd->config.orientation = val;
  507. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  508. fd->config.cmd = FD_CONFIG_COMMAND_ORIENTATION;
  509. fd->config.err = ERROR_FD_NONE;
  510. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  511. } else {
  512. fd->config.cmd |= FD_CONFIG_COMMAND_ORIENTATION;
  513. }
  514. }
  515. void __is_set_fd_config_orientation_val(struct fimc_is *is, u32 val)
  516. {
  517. unsigned int index = is->config_index;
  518. struct fd_param *fd;
  519. unsigned long *p_index;
  520. p_index = &is->config[index].p_region_index[1];
  521. fd = &is->config[index].fd;
  522. fd->config.orientation_value = val;
  523. if (!test_bit((PARAM_FD_CONFIG - 32), p_index)) {
  524. fd->config.cmd = FD_CONFIG_COMMAND_ORIENTATION_VALUE;
  525. fd->config.err = ERROR_FD_NONE;
  526. fimc_is_set_param_bit(is, PARAM_FD_CONFIG);
  527. } else {
  528. fd->config.cmd |= FD_CONFIG_COMMAND_ORIENTATION_VALUE;
  529. }
  530. }
  531. void fimc_is_set_initial_params(struct fimc_is *is)
  532. {
  533. struct global_param *global;
  534. struct isp_param *isp;
  535. struct drc_param *drc;
  536. struct fd_param *fd;
  537. unsigned long *p_index;
  538. unsigned int index;
  539. index = is->config_index;
  540. global = &is->config[index].global;
  541. isp = &is->config[index].isp;
  542. drc = &is->config[index].drc;
  543. fd = &is->config[index].fd;
  544. p_index = &is->config[index].p_region_index[0];
  545. /* Global */
  546. global->shotmode.cmd = 1;
  547. fimc_is_set_param_bit(is, PARAM_GLOBAL_SHOTMODE);
  548. /* ISP */
  549. isp->control.cmd = CONTROL_COMMAND_START;
  550. isp->control.bypass = CONTROL_BYPASS_DISABLE;
  551. isp->control.err = CONTROL_ERROR_NONE;
  552. fimc_is_set_param_bit(is, PARAM_ISP_CONTROL);
  553. isp->otf_input.cmd = OTF_INPUT_COMMAND_ENABLE;
  554. if (!test_bit(PARAM_ISP_OTF_INPUT, p_index)) {
  555. isp->otf_input.width = DEFAULT_PREVIEW_STILL_WIDTH;
  556. isp->otf_input.height = DEFAULT_PREVIEW_STILL_HEIGHT;
  557. fimc_is_set_param_bit(is, PARAM_ISP_OTF_INPUT);
  558. }
  559. if (is->sensor->test_pattern)
  560. isp->otf_input.format = OTF_INPUT_FORMAT_STRGEN_COLORBAR_BAYER;
  561. else
  562. isp->otf_input.format = OTF_INPUT_FORMAT_BAYER;
  563. isp->otf_input.bitwidth = 10;
  564. isp->otf_input.order = OTF_INPUT_ORDER_BAYER_GR_BG;
  565. isp->otf_input.crop_offset_x = 0;
  566. isp->otf_input.crop_offset_y = 0;
  567. isp->otf_input.err = OTF_INPUT_ERROR_NONE;
  568. isp->dma1_input.cmd = DMA_INPUT_COMMAND_DISABLE;
  569. isp->dma1_input.width = 0;
  570. isp->dma1_input.height = 0;
  571. isp->dma1_input.format = 0;
  572. isp->dma1_input.bitwidth = 0;
  573. isp->dma1_input.plane = 0;
  574. isp->dma1_input.order = 0;
  575. isp->dma1_input.buffer_number = 0;
  576. isp->dma1_input.width = 0;
  577. isp->dma1_input.err = DMA_INPUT_ERROR_NONE;
  578. fimc_is_set_param_bit(is, PARAM_ISP_DMA1_INPUT);
  579. isp->dma2_input.cmd = DMA_INPUT_COMMAND_DISABLE;
  580. isp->dma2_input.width = 0;
  581. isp->dma2_input.height = 0;
  582. isp->dma2_input.format = 0;
  583. isp->dma2_input.bitwidth = 0;
  584. isp->dma2_input.plane = 0;
  585. isp->dma2_input.order = 0;
  586. isp->dma2_input.buffer_number = 0;
  587. isp->dma2_input.width = 0;
  588. isp->dma2_input.err = DMA_INPUT_ERROR_NONE;
  589. fimc_is_set_param_bit(is, PARAM_ISP_DMA2_INPUT);
  590. isp->aa.cmd = ISP_AA_COMMAND_START;
  591. isp->aa.target = ISP_AA_TARGET_AE | ISP_AA_TARGET_AWB;
  592. fimc_is_set_param_bit(is, PARAM_ISP_AA);
  593. if (!test_bit(PARAM_ISP_FLASH, p_index))
  594. __is_set_isp_flash(is, ISP_FLASH_COMMAND_DISABLE,
  595. ISP_FLASH_REDEYE_DISABLE);
  596. if (!test_bit(PARAM_ISP_AWB, p_index))
  597. __is_set_isp_awb(is, ISP_AWB_COMMAND_AUTO, 0);
  598. if (!test_bit(PARAM_ISP_IMAGE_EFFECT, p_index))
  599. __is_set_isp_effect(is, ISP_IMAGE_EFFECT_DISABLE);
  600. if (!test_bit(PARAM_ISP_ISO, p_index))
  601. __is_set_isp_iso(is, ISP_ISO_COMMAND_AUTO, 0);
  602. if (!test_bit(PARAM_ISP_ADJUST, p_index)) {
  603. __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_CONTRAST, 0);
  604. __is_set_isp_adjust(is,
  605. ISP_ADJUST_COMMAND_MANUAL_SATURATION, 0);
  606. __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_SHARPNESS, 0);
  607. __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_EXPOSURE, 0);
  608. __is_set_isp_adjust(is,
  609. ISP_ADJUST_COMMAND_MANUAL_BRIGHTNESS, 0);
  610. __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_HUE, 0);
  611. }
  612. if (!test_bit(PARAM_ISP_METERING, p_index)) {
  613. __is_set_isp_metering(is, 0, ISP_METERING_COMMAND_CENTER);
  614. __is_set_isp_metering(is, 1, 0);
  615. __is_set_isp_metering(is, 2, 0);
  616. __is_set_isp_metering(is, 3, 0);
  617. __is_set_isp_metering(is, 4, 0);
  618. }
  619. if (!test_bit(PARAM_ISP_AFC, p_index))
  620. __is_set_isp_afc(is, ISP_AFC_COMMAND_AUTO, 0);
  621. isp->otf_output.cmd = OTF_OUTPUT_COMMAND_ENABLE;
  622. if (!test_bit(PARAM_ISP_OTF_OUTPUT, p_index)) {
  623. isp->otf_output.width = DEFAULT_PREVIEW_STILL_WIDTH;
  624. isp->otf_output.height = DEFAULT_PREVIEW_STILL_HEIGHT;
  625. fimc_is_set_param_bit(is, PARAM_ISP_OTF_OUTPUT);
  626. }
  627. isp->otf_output.format = OTF_OUTPUT_FORMAT_YUV444;
  628. isp->otf_output.bitwidth = 12;
  629. isp->otf_output.order = 0;
  630. isp->otf_output.err = OTF_OUTPUT_ERROR_NONE;
  631. if (!test_bit(PARAM_ISP_DMA1_OUTPUT, p_index)) {
  632. isp->dma1_output.cmd = DMA_OUTPUT_COMMAND_DISABLE;
  633. isp->dma1_output.width = 0;
  634. isp->dma1_output.height = 0;
  635. isp->dma1_output.format = 0;
  636. isp->dma1_output.bitwidth = 0;
  637. isp->dma1_output.plane = 0;
  638. isp->dma1_output.order = 0;
  639. isp->dma1_output.buffer_number = 0;
  640. isp->dma1_output.buffer_address = 0;
  641. isp->dma1_output.notify_dma_done = 0;
  642. isp->dma1_output.dma_out_mask = 0;
  643. isp->dma1_output.err = DMA_OUTPUT_ERROR_NONE;
  644. fimc_is_set_param_bit(is, PARAM_ISP_DMA1_OUTPUT);
  645. }
  646. if (!test_bit(PARAM_ISP_DMA2_OUTPUT, p_index)) {
  647. isp->dma2_output.cmd = DMA_OUTPUT_COMMAND_DISABLE;
  648. isp->dma2_output.width = 0;
  649. isp->dma2_output.height = 0;
  650. isp->dma2_output.format = 0;
  651. isp->dma2_output.bitwidth = 0;
  652. isp->dma2_output.plane = 0;
  653. isp->dma2_output.order = 0;
  654. isp->dma2_output.buffer_number = 0;
  655. isp->dma2_output.buffer_address = 0;
  656. isp->dma2_output.notify_dma_done = 0;
  657. isp->dma2_output.dma_out_mask = 0;
  658. isp->dma2_output.err = DMA_OUTPUT_ERROR_NONE;
  659. fimc_is_set_param_bit(is, PARAM_ISP_DMA2_OUTPUT);
  660. }
  661. /* Sensor */
  662. if (!test_bit(PARAM_SENSOR_FRAME_RATE, p_index)) {
  663. if (is->config_index == 0)
  664. __is_set_sensor(is, 0);
  665. }
  666. /* DRC */
  667. drc->control.cmd = CONTROL_COMMAND_START;
  668. __is_set_drc_control(is, CONTROL_BYPASS_ENABLE);
  669. drc->otf_input.cmd = OTF_INPUT_COMMAND_ENABLE;
  670. if (!test_bit(PARAM_DRC_OTF_INPUT, p_index)) {
  671. drc->otf_input.width = DEFAULT_PREVIEW_STILL_WIDTH;
  672. drc->otf_input.height = DEFAULT_PREVIEW_STILL_HEIGHT;
  673. fimc_is_set_param_bit(is, PARAM_DRC_OTF_INPUT);
  674. }
  675. drc->otf_input.format = OTF_INPUT_FORMAT_YUV444;
  676. drc->otf_input.bitwidth = 12;
  677. drc->otf_input.order = 0;
  678. drc->otf_input.err = OTF_INPUT_ERROR_NONE;
  679. drc->dma_input.cmd = DMA_INPUT_COMMAND_DISABLE;
  680. drc->dma_input.width = 0;
  681. drc->dma_input.height = 0;
  682. drc->dma_input.format = 0;
  683. drc->dma_input.bitwidth = 0;
  684. drc->dma_input.plane = 0;
  685. drc->dma_input.order = 0;
  686. drc->dma_input.buffer_number = 0;
  687. drc->dma_input.width = 0;
  688. drc->dma_input.err = DMA_INPUT_ERROR_NONE;
  689. fimc_is_set_param_bit(is, PARAM_DRC_DMA_INPUT);
  690. drc->otf_output.cmd = OTF_OUTPUT_COMMAND_ENABLE;
  691. if (!test_bit(PARAM_DRC_OTF_OUTPUT, p_index)) {
  692. drc->otf_output.width = DEFAULT_PREVIEW_STILL_WIDTH;
  693. drc->otf_output.height = DEFAULT_PREVIEW_STILL_HEIGHT;
  694. fimc_is_set_param_bit(is, PARAM_DRC_OTF_OUTPUT);
  695. }
  696. drc->otf_output.format = OTF_OUTPUT_FORMAT_YUV444;
  697. drc->otf_output.bitwidth = 8;
  698. drc->otf_output.order = 0;
  699. drc->otf_output.err = OTF_OUTPUT_ERROR_NONE;
  700. /* FD */
  701. __is_set_fd_control(is, CONTROL_COMMAND_STOP);
  702. fd->control.bypass = CONTROL_BYPASS_DISABLE;
  703. fd->otf_input.cmd = OTF_INPUT_COMMAND_ENABLE;
  704. if (!test_bit(PARAM_FD_OTF_INPUT, p_index)) {
  705. fd->otf_input.width = DEFAULT_PREVIEW_STILL_WIDTH;
  706. fd->otf_input.height = DEFAULT_PREVIEW_STILL_HEIGHT;
  707. fimc_is_set_param_bit(is, PARAM_FD_OTF_INPUT);
  708. }
  709. fd->otf_input.format = OTF_INPUT_FORMAT_YUV444;
  710. fd->otf_input.bitwidth = 8;
  711. fd->otf_input.order = 0;
  712. fd->otf_input.err = OTF_INPUT_ERROR_NONE;
  713. fd->dma_input.cmd = DMA_INPUT_COMMAND_DISABLE;
  714. fd->dma_input.width = 0;
  715. fd->dma_input.height = 0;
  716. fd->dma_input.format = 0;
  717. fd->dma_input.bitwidth = 0;
  718. fd->dma_input.plane = 0;
  719. fd->dma_input.order = 0;
  720. fd->dma_input.buffer_number = 0;
  721. fd->dma_input.width = 0;
  722. fd->dma_input.err = DMA_INPUT_ERROR_NONE;
  723. fimc_is_set_param_bit(is, PARAM_FD_DMA_INPUT);
  724. __is_set_fd_config_maxface(is, 5);
  725. __is_set_fd_config_rollangle(is, FD_CONFIG_ROLL_ANGLE_FULL);
  726. __is_set_fd_config_yawangle(is, FD_CONFIG_YAW_ANGLE_45_90);
  727. __is_set_fd_config_smilemode(is, FD_CONFIG_SMILE_MODE_DISABLE);
  728. __is_set_fd_config_blinkmode(is, FD_CONFIG_BLINK_MODE_DISABLE);
  729. __is_set_fd_config_eyedetect(is, FD_CONFIG_EYES_DETECT_ENABLE);
  730. __is_set_fd_config_mouthdetect(is, FD_CONFIG_MOUTH_DETECT_DISABLE);
  731. __is_set_fd_config_orientation(is, FD_CONFIG_ORIENTATION_DISABLE);
  732. __is_set_fd_config_orientation_val(is, 0);
  733. }