fimc-is-param.c 24 KB

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