fimc-is-param.c 25 KB

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