fimc-is-param.c 24 KB

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