davinci_vpfe_user.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. /*
  2. * Copyright (C) 2012 Texas Instruments Inc
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. *
  17. * Contributors:
  18. * Manjunath Hadli <manjunath.hadli@ti.com>
  19. * Prabhakar Lad <prabhakar.lad@ti.com>
  20. */
  21. #ifndef _DAVINCI_VPFE_USER_H
  22. #define _DAVINCI_VPFE_USER_H
  23. #include <linux/types.h>
  24. #include <linux/videodev2.h>
  25. /*
  26. * Private IOCTL
  27. *
  28. * VIDIOC_VPFE_ISIF_S_RAW_PARAMS: Set raw params in isif
  29. * VIDIOC_VPFE_ISIF_G_RAW_PARAMS: Get raw params from isif
  30. * VIDIOC_VPFE_PRV_S_CONFIG: Set ipipe engine configuration
  31. * VIDIOC_VPFE_PRV_G_CONFIG: Get ipipe engine configuration
  32. * VIDIOC_VPFE_RSZ_S_CONFIG: Set resizer engine configuration
  33. * VIDIOC_VPFE_RSZ_G_CONFIG: Get resizer engine configuration
  34. */
  35. #define VIDIOC_VPFE_ISIF_S_RAW_PARAMS \
  36. _IOW('V', BASE_VIDIOC_PRIVATE + 1, struct vpfe_isif_raw_config)
  37. #define VIDIOC_VPFE_ISIF_G_RAW_PARAMS \
  38. _IOR('V', BASE_VIDIOC_PRIVATE + 2, struct vpfe_isif_raw_config)
  39. #define VIDIOC_VPFE_IPIPE_S_CONFIG \
  40. _IOWR('P', BASE_VIDIOC_PRIVATE + 3, struct vpfe_ipipe_config)
  41. #define VIDIOC_VPFE_IPIPE_G_CONFIG \
  42. _IOWR('P', BASE_VIDIOC_PRIVATE + 4, struct vpfe_ipipe_config)
  43. #define VIDIOC_VPFE_RSZ_S_CONFIG \
  44. _IOWR('R', BASE_VIDIOC_PRIVATE + 5, struct vpfe_rsz_config)
  45. #define VIDIOC_VPFE_RSZ_G_CONFIG \
  46. _IOWR('R', BASE_VIDIOC_PRIVATE + 6, struct vpfe_rsz_config)
  47. /*
  48. * Private Control's for ISIF
  49. */
  50. #define VPFE_ISIF_CID_CRGAIN (V4L2_CID_USER_BASE | 0xa001)
  51. #define VPFE_ISIF_CID_CGRGAIN (V4L2_CID_USER_BASE | 0xa002)
  52. #define VPFE_ISIF_CID_CGBGAIN (V4L2_CID_USER_BASE | 0xa003)
  53. #define VPFE_ISIF_CID_CBGAIN (V4L2_CID_USER_BASE | 0xa004)
  54. #define VPFE_ISIF_CID_GAIN_OFFSET (V4L2_CID_USER_BASE | 0xa005)
  55. /*
  56. * Private Control's for ISIF and IPIPEIF
  57. */
  58. #define VPFE_CID_DPCM_PREDICTOR (V4L2_CID_USER_BASE | 0xa006)
  59. /************************************************************************
  60. * Vertical Defect Correction parameters
  61. ***********************************************************************/
  62. /**
  63. * vertical defect correction methods
  64. */
  65. enum vpfe_isif_vdfc_corr_mode {
  66. /* Defect level subtraction. Just fed through if saturating */
  67. VPFE_ISIF_VDFC_NORMAL,
  68. /**
  69. * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
  70. * if data saturating
  71. */
  72. VPFE_ISIF_VDFC_HORZ_INTERPOL_IF_SAT,
  73. /* Horizontal interpolation (((i-2)+(i+2))/2) */
  74. VPFE_ISIF_VDFC_HORZ_INTERPOL
  75. };
  76. /**
  77. * Max Size of the Vertical Defect Correction table
  78. */
  79. #define VPFE_ISIF_VDFC_TABLE_SIZE 8
  80. /**
  81. * Values used for shifting up the vdfc defect level
  82. */
  83. enum vpfe_isif_vdfc_shift {
  84. /* No Shift */
  85. VPFE_ISIF_VDFC_NO_SHIFT,
  86. /* Shift by 1 bit */
  87. VPFE_ISIF_VDFC_SHIFT_1,
  88. /* Shift by 2 bit */
  89. VPFE_ISIF_VDFC_SHIFT_2,
  90. /* Shift by 3 bit */
  91. VPFE_ISIF_VDFC_SHIFT_3,
  92. /* Shift by 4 bit */
  93. VPFE_ISIF_VDFC_SHIFT_4
  94. };
  95. /**
  96. * Defect Correction (DFC) table entry
  97. */
  98. struct vpfe_isif_vdfc_entry {
  99. /* vertical position of defect */
  100. unsigned short pos_vert;
  101. /* horizontal position of defect */
  102. unsigned short pos_horz;
  103. /**
  104. * Defect level of Vertical line defect position. This is subtracted
  105. * from the data at the defect position
  106. */
  107. unsigned char level_at_pos;
  108. /**
  109. * Defect level of the pixels upper than the vertical line defect.
  110. * This is subtracted from the data
  111. */
  112. unsigned char level_up_pixels;
  113. /**
  114. * Defect level of the pixels lower than the vertical line defect.
  115. * This is subtracted from the data
  116. */
  117. unsigned char level_low_pixels;
  118. };
  119. /**
  120. * Structure for Defect Correction (DFC) parameter
  121. */
  122. struct vpfe_isif_dfc {
  123. /* enable vertical defect correction */
  124. unsigned char en;
  125. /* Correction methods */
  126. enum vpfe_isif_vdfc_corr_mode corr_mode;
  127. /**
  128. * 0 - whole line corrected, 1 - not
  129. * pixels upper than the defect
  130. */
  131. unsigned char corr_whole_line;
  132. /**
  133. * defect level shift value. level_at_pos, level_upper_pos,
  134. * and level_lower_pos can be shifted up by this value
  135. */
  136. enum vpfe_isif_vdfc_shift def_level_shift;
  137. /* defect saturation level */
  138. unsigned short def_sat_level;
  139. /* number of vertical defects. Max is VPFE_ISIF_VDFC_TABLE_SIZE */
  140. short num_vdefects;
  141. /* VDFC table ptr */
  142. struct vpfe_isif_vdfc_entry table[VPFE_ISIF_VDFC_TABLE_SIZE];
  143. };
  144. /************************************************************************
  145. * Digital/Black clamp or DC Subtract parameters
  146. ************************************************************************/
  147. /**
  148. * Horizontal Black Clamp modes
  149. */
  150. enum vpfe_isif_horz_bc_mode {
  151. /**
  152. * Horizontal clamp disabled. Only vertical clamp
  153. * value is subtracted
  154. */
  155. VPFE_ISIF_HORZ_BC_DISABLE,
  156. /**
  157. * Horizontal clamp value is calculated and subtracted
  158. * from image data along with vertical clamp value
  159. */
  160. VPFE_ISIF_HORZ_BC_CLAMP_CALC_ENABLED,
  161. /**
  162. * Horizontal clamp value calculated from previous image
  163. * is subtracted from image data along with vertical clamp
  164. * value. How the horizontal clamp value for the first image
  165. * is calculated in this case ???
  166. */
  167. VPFE_ISIF_HORZ_BC_CLAMP_NOT_UPDATED
  168. };
  169. /**
  170. * Base window selection for Horizontal Black Clamp calculations
  171. */
  172. enum vpfe_isif_horz_bc_base_win_sel {
  173. /* Select Most left window for bc calculation */
  174. VPFE_ISIF_SEL_MOST_LEFT_WIN,
  175. /* Select Most right window for bc calculation */
  176. VPFE_ISIF_SEL_MOST_RIGHT_WIN,
  177. };
  178. /* Size of window in horizontal direction for horizontal bc */
  179. enum vpfe_isif_horz_bc_sz_h {
  180. VPFE_ISIF_HORZ_BC_SZ_H_2PIXELS,
  181. VPFE_ISIF_HORZ_BC_SZ_H_4PIXELS,
  182. VPFE_ISIF_HORZ_BC_SZ_H_8PIXELS,
  183. VPFE_ISIF_HORZ_BC_SZ_H_16PIXELS
  184. };
  185. /* Size of window in vertcal direction for vertical bc */
  186. enum vpfe_isif_horz_bc_sz_v {
  187. VPFE_ISIF_HORZ_BC_SZ_H_32PIXELS,
  188. VPFE_ISIF_HORZ_BC_SZ_H_64PIXELS,
  189. VPFE_ISIF_HORZ_BC_SZ_H_128PIXELS,
  190. VPFE_ISIF_HORZ_BC_SZ_H_256PIXELS
  191. };
  192. /**
  193. * Structure for Horizontal Black Clamp config params
  194. */
  195. struct vpfe_isif_horz_bclamp {
  196. /* horizontal clamp mode */
  197. enum vpfe_isif_horz_bc_mode mode;
  198. /**
  199. * pixel value limit enable.
  200. * 0 - limit disabled
  201. * 1 - pixel value limited to 1023
  202. */
  203. unsigned char clamp_pix_limit;
  204. /**
  205. * Select most left or right window for clamp val
  206. * calculation
  207. */
  208. enum vpfe_isif_horz_bc_base_win_sel base_win_sel_calc;
  209. /* Window count per color for calculation. range 1-32 */
  210. unsigned char win_count_calc;
  211. /* Window start position - horizontal for calculation. 0 - 8191 */
  212. unsigned short win_start_h_calc;
  213. /* Window start position - vertical for calculation 0 - 8191 */
  214. unsigned short win_start_v_calc;
  215. /* Width of the sample window in pixels for calculation */
  216. enum vpfe_isif_horz_bc_sz_h win_h_sz_calc;
  217. /* Height of the sample window in pixels for calculation */
  218. enum vpfe_isif_horz_bc_sz_v win_v_sz_calc;
  219. };
  220. /**
  221. * Black Clamp vertical reset values
  222. */
  223. enum vpfe_isif_vert_bc_reset_val_sel {
  224. /* Reset value used is the clamp value calculated */
  225. VPFE_ISIF_VERT_BC_USE_HORZ_CLAMP_VAL,
  226. /* Reset value used is reset_clamp_val configured */
  227. VPFE_ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL,
  228. /* No update, previous image value is used */
  229. VPFE_ISIF_VERT_BC_NO_UPDATE
  230. };
  231. enum vpfe_isif_vert_bc_sz_h {
  232. VPFE_ISIF_VERT_BC_SZ_H_2PIXELS,
  233. VPFE_ISIF_VERT_BC_SZ_H_4PIXELS,
  234. VPFE_ISIF_VERT_BC_SZ_H_8PIXELS,
  235. VPFE_ISIF_VERT_BC_SZ_H_16PIXELS,
  236. VPFE_ISIF_VERT_BC_SZ_H_32PIXELS,
  237. VPFE_ISIF_VERT_BC_SZ_H_64PIXELS
  238. };
  239. /**
  240. * Structure for Vertical Black Clamp configuration params
  241. */
  242. struct vpfe_isif_vert_bclamp {
  243. /* Reset value selection for vertical clamp calculation */
  244. enum vpfe_isif_vert_bc_reset_val_sel reset_val_sel;
  245. /* U12 value if reset_sel = ISIF_BC_VERT_USE_CONFIG_CLAMP_VAL */
  246. unsigned short reset_clamp_val;
  247. /**
  248. * U8Q8. Line average coefficient used in vertical clamp
  249. * calculation
  250. */
  251. unsigned char line_ave_coef;
  252. /* Width in pixels of the optical black region used for calculation. */
  253. enum vpfe_isif_vert_bc_sz_h ob_h_sz_calc;
  254. /* Height of the optical black region for calculation */
  255. unsigned short ob_v_sz_calc;
  256. /* Optical black region start position - horizontal. 0 - 8191 */
  257. unsigned short ob_start_h;
  258. /* Optical black region start position - vertical 0 - 8191 */
  259. unsigned short ob_start_v;
  260. };
  261. /**
  262. * Structure for Black Clamp configuration params
  263. */
  264. struct vpfe_isif_black_clamp {
  265. /**
  266. * this offset value is added irrespective of the clamp
  267. * enable status. S13
  268. */
  269. unsigned short dc_offset;
  270. /**
  271. * Enable black/digital clamp value to be subtracted
  272. * from the image data
  273. */
  274. unsigned char en;
  275. /**
  276. * black clamp mode. same/separate clamp for 4 colors
  277. * 0 - disable - same clamp value for all colors
  278. * 1 - clamp value calculated separately for all colors
  279. */
  280. unsigned char bc_mode_color;
  281. /* Vertical start position for bc subtraction */
  282. unsigned short vert_start_sub;
  283. /* Black clamp for horizontal direction */
  284. struct vpfe_isif_horz_bclamp horz;
  285. /* Black clamp for vertical direction */
  286. struct vpfe_isif_vert_bclamp vert;
  287. };
  288. /*************************************************************************
  289. ** Color Space Conversion (CSC)
  290. *************************************************************************/
  291. /**
  292. * Number of Coefficient values used for CSC
  293. */
  294. #define VPFE_ISIF_CSC_NUM_COEFF 16
  295. struct float_8_bit {
  296. /* 8 bit integer part */
  297. __u8 integer;
  298. /* 8 bit decimal part */
  299. __u8 decimal;
  300. };
  301. struct float_16_bit {
  302. /* 16 bit integer part */
  303. __u16 integer;
  304. /* 16 bit decimal part */
  305. __u16 decimal;
  306. };
  307. /*************************************************************************
  308. ** Color Space Conversion parameters
  309. *************************************************************************/
  310. /**
  311. * Structure used for CSC config params
  312. */
  313. struct vpfe_isif_color_space_conv {
  314. /* Enable color space conversion */
  315. unsigned char en;
  316. /**
  317. * csc coefficient table. S8Q5, M00 at index 0, M01 at index 1, and
  318. * so forth
  319. */
  320. struct float_8_bit coeff[VPFE_ISIF_CSC_NUM_COEFF];
  321. };
  322. enum vpfe_isif_datasft {
  323. /* No Shift */
  324. VPFE_ISIF_NO_SHIFT,
  325. /* 1 bit Shift */
  326. VPFE_ISIF_1BIT_SHIFT,
  327. /* 2 bit Shift */
  328. VPFE_ISIF_2BIT_SHIFT,
  329. /* 3 bit Shift */
  330. VPFE_ISIF_3BIT_SHIFT,
  331. /* 4 bit Shift */
  332. VPFE_ISIF_4BIT_SHIFT,
  333. /* 5 bit Shift */
  334. VPFE_ISIF_5BIT_SHIFT,
  335. /* 6 bit Shift */
  336. VPFE_ISIF_6BIT_SHIFT
  337. };
  338. #define VPFE_ISIF_LINEAR_TAB_SIZE 192
  339. /*************************************************************************
  340. ** Linearization parameters
  341. *************************************************************************/
  342. /**
  343. * Structure for Sensor data linearization
  344. */
  345. struct vpfe_isif_linearize {
  346. /* Enable or Disable linearization of data */
  347. unsigned char en;
  348. /* Shift value applied */
  349. enum vpfe_isif_datasft corr_shft;
  350. /* scale factor applied U11Q10 */
  351. struct float_16_bit scale_fact;
  352. /* Size of the linear table */
  353. unsigned short table[VPFE_ISIF_LINEAR_TAB_SIZE];
  354. };
  355. /*************************************************************************
  356. ** ISIF Raw configuration parameters
  357. *************************************************************************/
  358. enum vpfe_isif_fmt_mode {
  359. VPFE_ISIF_SPLIT,
  360. VPFE_ISIF_COMBINE
  361. };
  362. enum vpfe_isif_lnum {
  363. VPFE_ISIF_1LINE,
  364. VPFE_ISIF_2LINES,
  365. VPFE_ISIF_3LINES,
  366. VPFE_ISIF_4LINES
  367. };
  368. enum vpfe_isif_line {
  369. VPFE_ISIF_1STLINE,
  370. VPFE_ISIF_2NDLINE,
  371. VPFE_ISIF_3RDLINE,
  372. VPFE_ISIF_4THLINE
  373. };
  374. struct vpfe_isif_fmtplen {
  375. /**
  376. * number of program entries for SET0, range 1 - 16
  377. * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
  378. * ISIF_COMBINE
  379. */
  380. unsigned short plen0;
  381. /**
  382. * number of program entries for SET1, range 1 - 16
  383. * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
  384. * ISIF_COMBINE
  385. */
  386. unsigned short plen1;
  387. /**
  388. * number of program entries for SET2, range 1 - 16
  389. * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
  390. * ISIF_COMBINE
  391. */
  392. unsigned short plen2;
  393. /**
  394. * number of program entries for SET3, range 1 - 16
  395. * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
  396. * ISIF_COMBINE
  397. */
  398. unsigned short plen3;
  399. };
  400. struct vpfe_isif_fmt_cfg {
  401. /* Split or combine or line alternate */
  402. enum vpfe_isif_fmt_mode fmtmode;
  403. /* enable or disable line alternating mode */
  404. unsigned char ln_alter_en;
  405. /* Split/combine line number */
  406. enum vpfe_isif_lnum lnum;
  407. /* Address increment Range 1 - 16 */
  408. unsigned int addrinc;
  409. };
  410. struct vpfe_isif_fmt_addr_ptr {
  411. /* Initial address */
  412. unsigned int init_addr;
  413. /* output line number */
  414. enum vpfe_isif_line out_line;
  415. };
  416. struct vpfe_isif_fmtpgm_ap {
  417. /* program address pointer */
  418. unsigned char pgm_aptr;
  419. /* program address increment or decrement */
  420. unsigned char pgmupdt;
  421. };
  422. struct vpfe_isif_data_formatter {
  423. /* Enable/Disable data formatter */
  424. unsigned char en;
  425. /* data formatter configuration */
  426. struct vpfe_isif_fmt_cfg cfg;
  427. /* Formatter program entries length */
  428. struct vpfe_isif_fmtplen plen;
  429. /* first pixel in a line fed to formatter */
  430. unsigned short fmtrlen;
  431. /* HD interval for output line. Only valid when split line */
  432. unsigned short fmthcnt;
  433. /* formatter address pointers */
  434. struct vpfe_isif_fmt_addr_ptr fmtaddr_ptr[16];
  435. /* program enable/disable */
  436. unsigned char pgm_en[32];
  437. /* program address pointers */
  438. struct vpfe_isif_fmtpgm_ap fmtpgm_ap[32];
  439. };
  440. struct vpfe_isif_df_csc {
  441. /* Color Space Conversion configuration, 0 - csc, 1 - df */
  442. unsigned int df_or_csc;
  443. /* csc configuration valid if df_or_csc is 0 */
  444. struct vpfe_isif_color_space_conv csc;
  445. /* data formatter configuration valid if df_or_csc is 1 */
  446. struct vpfe_isif_data_formatter df;
  447. /* start pixel in a line at the input */
  448. unsigned int start_pix;
  449. /* number of pixels in input line */
  450. unsigned int num_pixels;
  451. /* start line at the input */
  452. unsigned int start_line;
  453. /* number of lines at the input */
  454. unsigned int num_lines;
  455. };
  456. struct vpfe_isif_gain_offsets_adj {
  457. /* Enable or Disable Gain adjustment for SDRAM data */
  458. unsigned char gain_sdram_en;
  459. /* Enable or Disable Gain adjustment for IPIPE data */
  460. unsigned char gain_ipipe_en;
  461. /* Enable or Disable Gain adjustment for H3A data */
  462. unsigned char gain_h3a_en;
  463. /* Enable or Disable Gain adjustment for SDRAM data */
  464. unsigned char offset_sdram_en;
  465. /* Enable or Disable Gain adjustment for IPIPE data */
  466. unsigned char offset_ipipe_en;
  467. /* Enable or Disable Gain adjustment for H3A data */
  468. unsigned char offset_h3a_en;
  469. };
  470. struct vpfe_isif_cul {
  471. /* Horizontal Cull pattern for odd lines */
  472. unsigned char hcpat_odd;
  473. /* Horizontal Cull pattern for even lines */
  474. unsigned char hcpat_even;
  475. /* Vertical Cull pattern */
  476. unsigned char vcpat;
  477. /* Enable or disable lpf. Apply when cull is enabled */
  478. unsigned char en_lpf;
  479. };
  480. /* all the stuff in this struct will be provided by userland */
  481. struct vpfe_isif_raw_config {
  482. /* Linearization parameters for image sensor data input */
  483. struct vpfe_isif_linearize linearize;
  484. /* Data formatter or CSC */
  485. struct vpfe_isif_df_csc df_csc;
  486. /* Defect Pixel Correction (DFC) confguration */
  487. struct vpfe_isif_dfc dfc;
  488. /* Black/Digital Clamp configuration */
  489. struct vpfe_isif_black_clamp bclamp;
  490. /* Gain, offset adjustments */
  491. struct vpfe_isif_gain_offsets_adj gain_offset;
  492. /* Culling */
  493. struct vpfe_isif_cul culling;
  494. /* horizontal offset for Gain/LSC/DFC */
  495. unsigned short horz_offset;
  496. /* vertical offset for Gain/LSC/DFC */
  497. unsigned short vert_offset;
  498. };
  499. /**********************************************************************
  500. IPIPE API Structures
  501. **********************************************************************/
  502. /* IPIPE module configurations */
  503. /* IPIPE input configuration */
  504. #define VPFE_IPIPE_INPUT_CONFIG (1 << 0)
  505. /* LUT based Defect Pixel Correction */
  506. #define VPFE_IPIPE_LUTDPC (1 << 1)
  507. /* On the fly (OTF) Defect Pixel Correction */
  508. #define VPFE_IPIPE_OTFDPC (1 << 2)
  509. /* Noise Filter - 1 */
  510. #define VPFE_IPIPE_NF1 (1 << 3)
  511. /* Noise Filter - 2 */
  512. #define VPFE_IPIPE_NF2 (1 << 4)
  513. /* White Balance. Also a control ID */
  514. #define VPFE_IPIPE_WB (1 << 5)
  515. /* 1st RGB to RBG Blend module */
  516. #define VPFE_IPIPE_RGB2RGB_1 (1 << 6)
  517. /* 2nd RGB to RBG Blend module */
  518. #define VPFE_IPIPE_RGB2RGB_2 (1 << 7)
  519. /* Gamma Correction */
  520. #define VPFE_IPIPE_GAMMA (1 << 8)
  521. /* 3D LUT color conversion */
  522. #define VPFE_IPIPE_3D_LUT (1 << 9)
  523. /* RGB to YCbCr module */
  524. #define VPFE_IPIPE_RGB2YUV (1 << 10)
  525. /* YUV 422 conversion module */
  526. #define VPFE_IPIPE_YUV422_CONV (1 << 11)
  527. /* Edge Enhancement */
  528. #define VPFE_IPIPE_YEE (1 << 12)
  529. /* Green Imbalance Correction */
  530. #define VPFE_IPIPE_GIC (1 << 13)
  531. /* CFA Interpolation */
  532. #define VPFE_IPIPE_CFA (1 << 14)
  533. /* Chroma Artifact Reduction */
  534. #define VPFE_IPIPE_CAR (1 << 15)
  535. /* Chroma Gain Suppression */
  536. #define VPFE_IPIPE_CGS (1 << 16)
  537. /* Global brightness and contrast control */
  538. #define VPFE_IPIPE_GBCE (1 << 17)
  539. #define VPFE_IPIPE_MAX_MODULES 18
  540. struct ipipe_float_u16 {
  541. unsigned short integer;
  542. unsigned short decimal;
  543. };
  544. struct ipipe_float_s16 {
  545. short integer;
  546. unsigned short decimal;
  547. };
  548. struct ipipe_float_u8 {
  549. unsigned char integer;
  550. unsigned char decimal;
  551. };
  552. /* Copy method selection for vertical correction
  553. * Used when ipipe_dfc_corr_meth is IPIPE_DPC_CTORB_AFTER_HINT
  554. */
  555. enum vpfe_ipipe_dpc_corr_meth {
  556. /* replace by black or white dot specified by repl_white */
  557. VPFE_IPIPE_DPC_REPL_BY_DOT = 0,
  558. /* Copy from left */
  559. VPFE_IPIPE_DPC_CL = 1,
  560. /* Copy from right */
  561. VPFE_IPIPE_DPC_CR = 2,
  562. /* Horizontal interpolation */
  563. VPFE_IPIPE_DPC_H_INTP = 3,
  564. /* Vertical interpolation */
  565. VPFE_IPIPE_DPC_V_INTP = 4,
  566. /* Copy from top */
  567. VPFE_IPIPE_DPC_CT = 5,
  568. /* Copy from bottom */
  569. VPFE_IPIPE_DPC_CB = 6,
  570. /* 2D interpolation */
  571. VPFE_IPIPE_DPC_2D_INTP = 7,
  572. };
  573. struct vpfe_ipipe_lutdpc_entry {
  574. /* Horizontal position */
  575. unsigned short horz_pos;
  576. /* vertical position */
  577. unsigned short vert_pos;
  578. enum vpfe_ipipe_dpc_corr_meth method;
  579. };
  580. #define VPFE_IPIPE_MAX_SIZE_DPC 256
  581. /* Structure for configuring DPC module */
  582. struct vpfe_ipipe_lutdpc {
  583. /* 0 - disable, 1 - enable */
  584. unsigned char en;
  585. /* 0 - replace with black dot, 1 - white dot when correction
  586. * method is IPIPE_DFC_REPL_BY_DOT=0,
  587. */
  588. unsigned char repl_white;
  589. /* number of entries in the correction table. Currently only
  590. * support up-to 256 entries. infinite mode is not supported
  591. */
  592. unsigned short dpc_size;
  593. struct vpfe_ipipe_lutdpc_entry table[VPFE_IPIPE_MAX_SIZE_DPC];
  594. };
  595. enum vpfe_ipipe_otfdpc_det_meth {
  596. VPFE_IPIPE_DPC_OTF_MIN_MAX,
  597. VPFE_IPIPE_DPC_OTF_MIN_MAX2
  598. };
  599. struct vpfe_ipipe_otfdpc_thr {
  600. unsigned short r;
  601. unsigned short gr;
  602. unsigned short gb;
  603. unsigned short b;
  604. };
  605. enum vpfe_ipipe_otfdpc_alg {
  606. VPFE_IPIPE_OTFDPC_2_0,
  607. VPFE_IPIPE_OTFDPC_3_0
  608. };
  609. struct vpfe_ipipe_otfdpc_2_0_cfg {
  610. /* defect detection threshold for MIN_MAX2 method (DPC 2.0 alg) */
  611. struct vpfe_ipipe_otfdpc_thr det_thr;
  612. /* defect correction threshold for MIN_MAX2 method (DPC 2.0 alg) or
  613. * maximum value for MIN_MAX method
  614. */
  615. struct vpfe_ipipe_otfdpc_thr corr_thr;
  616. };
  617. struct vpfe_ipipe_otfdpc_3_0_cfg {
  618. /* DPC3.0 activity adj shf. activity = (max2-min2) >> (6 -shf)
  619. */
  620. unsigned char act_adj_shf;
  621. /* DPC3.0 detection threshold, THR */
  622. unsigned short det_thr;
  623. /* DPC3.0 detection threshold slope, SLP */
  624. unsigned short det_slp;
  625. /* DPC3.0 detection threshold min, MIN */
  626. unsigned short det_thr_min;
  627. /* DPC3.0 detection threshold max, MAX */
  628. unsigned short det_thr_max;
  629. /* DPC3.0 correction threshold, THR */
  630. unsigned short corr_thr;
  631. /* DPC3.0 correction threshold slope, SLP */
  632. unsigned short corr_slp;
  633. /* DPC3.0 correction threshold min, MIN */
  634. unsigned short corr_thr_min;
  635. /* DPC3.0 correction threshold max, MAX */
  636. unsigned short corr_thr_max;
  637. };
  638. struct vpfe_ipipe_otfdpc {
  639. /* 0 - disable, 1 - enable */
  640. unsigned char en;
  641. /* defect detection method */
  642. enum vpfe_ipipe_otfdpc_det_meth det_method;
  643. /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
  644. * used
  645. */
  646. enum vpfe_ipipe_otfdpc_alg alg;
  647. union {
  648. /* if alg is IPIPE_OTFDPC_2_0 */
  649. struct vpfe_ipipe_otfdpc_2_0_cfg dpc_2_0;
  650. /* if alg is IPIPE_OTFDPC_3_0 */
  651. struct vpfe_ipipe_otfdpc_3_0_cfg dpc_3_0;
  652. } alg_cfg;
  653. };
  654. /* Threshold values table size */
  655. #define VPFE_IPIPE_NF_THR_TABLE_SIZE 8
  656. /* Intensity values table size */
  657. #define VPFE_IPIPE_NF_STR_TABLE_SIZE 8
  658. /* NF, sampling method for green pixels */
  659. enum vpfe_ipipe_nf_sampl_meth {
  660. /* Same as R or B */
  661. VPFE_IPIPE_NF_BOX,
  662. /* Diamond mode */
  663. VPFE_IPIPE_NF_DIAMOND
  664. };
  665. /* Structure for configuring NF module */
  666. struct vpfe_ipipe_nf {
  667. /* 0 - disable, 1 - enable */
  668. unsigned char en;
  669. /* Sampling method for green pixels */
  670. enum vpfe_ipipe_nf_sampl_meth gr_sample_meth;
  671. /* Down shift value in LUT reference address
  672. */
  673. unsigned char shft_val;
  674. /* Spread value in NF algorithm
  675. */
  676. unsigned char spread_val;
  677. /* Apply LSC gain to threshold. Enable this only if
  678. * LSC is enabled in ISIF
  679. */
  680. unsigned char apply_lsc_gain;
  681. /* Threshold values table */
  682. unsigned short thr[VPFE_IPIPE_NF_THR_TABLE_SIZE];
  683. /* intensity values table */
  684. unsigned char str[VPFE_IPIPE_NF_STR_TABLE_SIZE];
  685. /* Edge detection minimum threshold */
  686. unsigned short edge_det_min_thr;
  687. /* Edge detection maximum threshold */
  688. unsigned short edge_det_max_thr;
  689. };
  690. enum vpfe_ipipe_gic_alg {
  691. VPFE_IPIPE_GIC_ALG_CONST_GAIN,
  692. VPFE_IPIPE_GIC_ALG_ADAPT_GAIN
  693. };
  694. enum vpfe_ipipe_gic_thr_sel {
  695. VPFE_IPIPE_GIC_THR_REG,
  696. VPFE_IPIPE_GIC_THR_NF
  697. };
  698. enum vpfe_ipipe_gic_wt_fn_type {
  699. /* Use difference as index */
  700. VPFE_IPIPE_GIC_WT_FN_TYP_DIF,
  701. /* Use weight function as index */
  702. VPFE_IPIPE_GIC_WT_FN_TYP_HP_VAL
  703. };
  704. /* structure for Green Imbalance Correction */
  705. struct vpfe_ipipe_gic {
  706. /* 0 - disable, 1 - enable */
  707. unsigned char en;
  708. /* 0 - Constant gain , 1 - Adaptive gain algorithm */
  709. enum vpfe_ipipe_gic_alg gic_alg;
  710. /* GIC gain or weight. Used for Constant gain and Adaptive algorithms
  711. */
  712. unsigned short gain;
  713. /* Threshold selection. GIC register values or NF2 thr table */
  714. enum vpfe_ipipe_gic_thr_sel thr_sel;
  715. /* thr1. Used when thr_sel is IPIPE_GIC_THR_REG */
  716. unsigned short thr;
  717. /* this value is used for thr2-thr1, thr3-thr2 or
  718. * thr4-thr3 when wt_fn_type is index. Otherwise it
  719. * is the
  720. */
  721. unsigned short slope;
  722. /* Apply LSC gain to threshold. Enable this only if
  723. * LSC is enabled in ISIF & thr_sel is IPIPE_GIC_THR_REG
  724. */
  725. unsigned char apply_lsc_gain;
  726. /* Multiply Nf2 threshold by this gain. Use this when thr_sel
  727. * is IPIPE_GIC_THR_NF
  728. */
  729. struct ipipe_float_u8 nf2_thr_gain;
  730. /* Weight function uses difference as index or high pass value.
  731. * Used for adaptive gain algorithm
  732. */
  733. enum vpfe_ipipe_gic_wt_fn_type wt_fn_type;
  734. };
  735. /* Structure for configuring WB module */
  736. struct vpfe_ipipe_wb {
  737. /* Offset (S12) for R */
  738. short ofst_r;
  739. /* Offset (S12) for Gr */
  740. short ofst_gr;
  741. /* Offset (S12) for Gb */
  742. short ofst_gb;
  743. /* Offset (S12) for B */
  744. short ofst_b;
  745. /* Gain (U13Q9) for Red */
  746. struct ipipe_float_u16 gain_r;
  747. /* Gain (U13Q9) for Gr */
  748. struct ipipe_float_u16 gain_gr;
  749. /* Gain (U13Q9) for Gb */
  750. struct ipipe_float_u16 gain_gb;
  751. /* Gain (U13Q9) for Blue */
  752. struct ipipe_float_u16 gain_b;
  753. };
  754. enum vpfe_ipipe_cfa_alg {
  755. /* Algorithm is 2DirAC */
  756. VPFE_IPIPE_CFA_ALG_2DIRAC,
  757. /* Algorithm is 2DirAC + Digital Antialiasing (DAA) */
  758. VPFE_IPIPE_CFA_ALG_2DIRAC_DAA,
  759. /* Algorithm is DAA */
  760. VPFE_IPIPE_CFA_ALG_DAA
  761. };
  762. /* Structure for CFA Interpolation */
  763. struct vpfe_ipipe_cfa {
  764. /* 2DirAC or 2DirAC + DAA */
  765. enum vpfe_ipipe_cfa_alg alg;
  766. /* 2Dir CFA HP value Low Threshold */
  767. unsigned short hpf_thr_2dir;
  768. /* 2Dir CFA HP value slope */
  769. unsigned short hpf_slp_2dir;
  770. /* 2Dir CFA HP mix threshold */
  771. unsigned short hp_mix_thr_2dir;
  772. /* 2Dir CFA HP mix slope */
  773. unsigned short hp_mix_slope_2dir;
  774. /* 2Dir Direction threshold */
  775. unsigned short dir_thr_2dir;
  776. /* 2Dir Direction slope */
  777. unsigned short dir_slope_2dir;
  778. /* 2Dir Non Directional Weight */
  779. unsigned short nd_wt_2dir;
  780. /* DAA Mono Hue Fraction */
  781. unsigned short hue_fract_daa;
  782. /* DAA Mono Edge threshold */
  783. unsigned short edge_thr_daa;
  784. /* DAA Mono threshold minimum */
  785. unsigned short thr_min_daa;
  786. /* DAA Mono threshold slope */
  787. unsigned short thr_slope_daa;
  788. /* DAA Mono slope minimum */
  789. unsigned short slope_min_daa;
  790. /* DAA Mono slope slope */
  791. unsigned short slope_slope_daa;
  792. /* DAA Mono LP wight */
  793. unsigned short lp_wt_daa;
  794. };
  795. /* Struct for configuring RGB2RGB blending module */
  796. struct vpfe_ipipe_rgb2rgb {
  797. /* Matrix coefficient for RR S12Q8 for ID = 1 and S11Q8 for ID = 2 */
  798. struct ipipe_float_s16 coef_rr;
  799. /* Matrix coefficient for GR S12Q8/S11Q8 */
  800. struct ipipe_float_s16 coef_gr;
  801. /* Matrix coefficient for BR S12Q8/S11Q8 */
  802. struct ipipe_float_s16 coef_br;
  803. /* Matrix coefficient for RG S12Q8/S11Q8 */
  804. struct ipipe_float_s16 coef_rg;
  805. /* Matrix coefficient for GG S12Q8/S11Q8 */
  806. struct ipipe_float_s16 coef_gg;
  807. /* Matrix coefficient for BG S12Q8/S11Q8 */
  808. struct ipipe_float_s16 coef_bg;
  809. /* Matrix coefficient for RB S12Q8/S11Q8 */
  810. struct ipipe_float_s16 coef_rb;
  811. /* Matrix coefficient for GB S12Q8/S11Q8 */
  812. struct ipipe_float_s16 coef_gb;
  813. /* Matrix coefficient for BB S12Q8/S11Q8 */
  814. struct ipipe_float_s16 coef_bb;
  815. /* Output offset for R S13/S11 */
  816. int out_ofst_r;
  817. /* Output offset for G S13/S11 */
  818. int out_ofst_g;
  819. /* Output offset for B S13/S11 */
  820. int out_ofst_b;
  821. };
  822. #define VPFE_IPIPE_MAX_SIZE_GAMMA 512
  823. enum vpfe_ipipe_gamma_tbl_size {
  824. VPFE_IPIPE_GAMMA_TBL_SZ_64 = 64,
  825. VPFE_IPIPE_GAMMA_TBL_SZ_128 = 128,
  826. VPFE_IPIPE_GAMMA_TBL_SZ_256 = 256,
  827. VPFE_IPIPE_GAMMA_TBL_SZ_512 = 512,
  828. };
  829. enum vpfe_ipipe_gamma_tbl_sel {
  830. VPFE_IPIPE_GAMMA_TBL_RAM = 0,
  831. VPFE_IPIPE_GAMMA_TBL_ROM = 1,
  832. };
  833. struct vpfe_ipipe_gamma_entry {
  834. /* 10 bit slope */
  835. short slope;
  836. /* 10 bit offset */
  837. unsigned short offset;
  838. };
  839. /* Structure for configuring Gamma correction module */
  840. struct vpfe_ipipe_gamma {
  841. /* 0 - Enable Gamma correction for Red
  842. * 1 - bypass Gamma correction. Data is divided by 16
  843. */
  844. unsigned char bypass_r;
  845. /* 0 - Enable Gamma correction for Blue
  846. * 1 - bypass Gamma correction. Data is divided by 16
  847. */
  848. unsigned char bypass_b;
  849. /* 0 - Enable Gamma correction for Green
  850. * 1 - bypass Gamma correction. Data is divided by 16
  851. */
  852. unsigned char bypass_g;
  853. /* IPIPE_GAMMA_TBL_RAM or IPIPE_GAMMA_TBL_ROM */
  854. enum vpfe_ipipe_gamma_tbl_sel tbl_sel;
  855. /* Table size for RAM gamma table.
  856. */
  857. enum vpfe_ipipe_gamma_tbl_size tbl_size;
  858. /* R table */
  859. struct vpfe_ipipe_gamma_entry table_r[VPFE_IPIPE_MAX_SIZE_GAMMA];
  860. /* Blue table */
  861. struct vpfe_ipipe_gamma_entry table_b[VPFE_IPIPE_MAX_SIZE_GAMMA];
  862. /* Green table */
  863. struct vpfe_ipipe_gamma_entry table_g[VPFE_IPIPE_MAX_SIZE_GAMMA];
  864. };
  865. #define VPFE_IPIPE_MAX_SIZE_3D_LUT 729
  866. struct vpfe_ipipe_3d_lut_entry {
  867. /* 10 bit entry for red */
  868. unsigned short r;
  869. /* 10 bit entry for green */
  870. unsigned short g;
  871. /* 10 bit entry for blue */
  872. unsigned short b;
  873. };
  874. /* structure for 3D-LUT */
  875. struct vpfe_ipipe_3d_lut {
  876. /* enable/disable 3D lut */
  877. unsigned char en;
  878. /* 3D - LUT table entry */
  879. struct vpfe_ipipe_3d_lut_entry table[VPFE_IPIPE_MAX_SIZE_3D_LUT];
  880. };
  881. /* Struct for configuring rgb2ycbcr module */
  882. struct vpfe_ipipe_rgb2yuv {
  883. /* Matrix coefficient for RY S12Q8 */
  884. struct ipipe_float_s16 coef_ry;
  885. /* Matrix coefficient for GY S12Q8 */
  886. struct ipipe_float_s16 coef_gy;
  887. /* Matrix coefficient for BY S12Q8 */
  888. struct ipipe_float_s16 coef_by;
  889. /* Matrix coefficient for RCb S12Q8 */
  890. struct ipipe_float_s16 coef_rcb;
  891. /* Matrix coefficient for GCb S12Q8 */
  892. struct ipipe_float_s16 coef_gcb;
  893. /* Matrix coefficient for BCb S12Q8 */
  894. struct ipipe_float_s16 coef_bcb;
  895. /* Matrix coefficient for RCr S12Q8 */
  896. struct ipipe_float_s16 coef_rcr;
  897. /* Matrix coefficient for GCr S12Q8 */
  898. struct ipipe_float_s16 coef_gcr;
  899. /* Matrix coefficient for BCr S12Q8 */
  900. struct ipipe_float_s16 coef_bcr;
  901. /* Output offset for R S11 */
  902. int out_ofst_y;
  903. /* Output offset for Cb S11 */
  904. int out_ofst_cb;
  905. /* Output offset for Cr S11 */
  906. int out_ofst_cr;
  907. };
  908. enum vpfe_ipipe_gbce_type {
  909. VPFE_IPIPE_GBCE_Y_VAL_TBL = 0,
  910. VPFE_IPIPE_GBCE_GAIN_TBL = 1,
  911. };
  912. #define VPFE_IPIPE_MAX_SIZE_GBCE_LUT 1024
  913. /* structure for Global brightness and Contrast */
  914. struct vpfe_ipipe_gbce {
  915. /* enable/disable GBCE */
  916. unsigned char en;
  917. /* Y - value table or Gain table */
  918. enum vpfe_ipipe_gbce_type type;
  919. /* ptr to LUT for GBCE with 1024 entries */
  920. unsigned short table[VPFE_IPIPE_MAX_SIZE_GBCE_LUT];
  921. };
  922. /* Chrominance position. Applicable only for YCbCr input
  923. * Applied after edge enhancement
  924. */
  925. enum vpfe_chr_pos {
  926. /* Co-siting, same position with luminance */
  927. VPFE_IPIPE_YUV422_CHR_POS_COSITE = 0,
  928. /* Centering, In the middle of luminance */
  929. VPFE_IPIPE_YUV422_CHR_POS_CENTRE = 1,
  930. };
  931. /* Structure for configuring yuv422 conversion module */
  932. struct vpfe_ipipe_yuv422_conv {
  933. /* Max Chrominance value */
  934. unsigned char en_chrom_lpf;
  935. /* 1 - enable LPF for chrminance, 0 - disable */
  936. enum vpfe_chr_pos chrom_pos;
  937. };
  938. #define VPFE_IPIPE_MAX_SIZE_YEE_LUT 1024
  939. enum vpfe_ipipe_yee_merge_meth {
  940. VPFE_IPIPE_YEE_ABS_MAX = 0,
  941. VPFE_IPIPE_YEE_EE_ES = 1,
  942. };
  943. /* Structure for configuring YUV Edge Enhancement module */
  944. struct vpfe_ipipe_yee {
  945. /* 1 - enable enhancement, 0 - disable */
  946. unsigned char en;
  947. /* enable/disable halo reduction in edge sharpner */
  948. unsigned char en_halo_red;
  949. /* Merge method between Edge Enhancer and Edge sharpner */
  950. enum vpfe_ipipe_yee_merge_meth merge_meth;
  951. /* HPF Shift length */
  952. unsigned char hpf_shft;
  953. /* HPF Coefficient 00, S10 */
  954. short hpf_coef_00;
  955. /* HPF Coefficient 01, S10 */
  956. short hpf_coef_01;
  957. /* HPF Coefficient 02, S10 */
  958. short hpf_coef_02;
  959. /* HPF Coefficient 10, S10 */
  960. short hpf_coef_10;
  961. /* HPF Coefficient 11, S10 */
  962. short hpf_coef_11;
  963. /* HPF Coefficient 12, S10 */
  964. short hpf_coef_12;
  965. /* HPF Coefficient 20, S10 */
  966. short hpf_coef_20;
  967. /* HPF Coefficient 21, S10 */
  968. short hpf_coef_21;
  969. /* HPF Coefficient 22, S10 */
  970. short hpf_coef_22;
  971. /* Lower threshold before referring to LUT */
  972. unsigned short yee_thr;
  973. /* Edge sharpener Gain */
  974. unsigned short es_gain;
  975. /* Edge sharpener lower threshold */
  976. unsigned short es_thr1;
  977. /* Edge sharpener upper threshold */
  978. unsigned short es_thr2;
  979. /* Edge sharpener gain on gradient */
  980. unsigned short es_gain_grad;
  981. /* Edge sharpener offset on gradient */
  982. unsigned short es_ofst_grad;
  983. /* Ptr to EE table. Must have 1024 entries */
  984. short table[VPFE_IPIPE_MAX_SIZE_YEE_LUT];
  985. };
  986. enum vpfe_ipipe_car_meth {
  987. /* Chromatic Gain Control */
  988. VPFE_IPIPE_CAR_CHR_GAIN_CTRL = 0,
  989. /* Dynamic switching between CHR_GAIN_CTRL
  990. * and MED_FLTR
  991. */
  992. VPFE_IPIPE_CAR_DYN_SWITCH = 1,
  993. /* Median Filter */
  994. VPFE_IPIPE_CAR_MED_FLTR = 2,
  995. };
  996. enum vpfe_ipipe_car_hpf_type {
  997. VPFE_IPIPE_CAR_HPF_Y = 0,
  998. VPFE_IPIPE_CAR_HPF_H = 1,
  999. VPFE_IPIPE_CAR_HPF_V = 2,
  1000. VPFE_IPIPE_CAR_HPF_2D = 3,
  1001. /* 2D HPF from YUV Edge Enhancement */
  1002. VPFE_IPIPE_CAR_HPF_2D_YEE = 4,
  1003. };
  1004. struct vpfe_ipipe_car_gain {
  1005. /* csup_gain */
  1006. unsigned char gain;
  1007. /* csup_shf. */
  1008. unsigned char shft;
  1009. /* gain minimum */
  1010. unsigned short gain_min;
  1011. };
  1012. /* Structure for Chromatic Artifact Reduction */
  1013. struct vpfe_ipipe_car {
  1014. /* enable/disable */
  1015. unsigned char en;
  1016. /* Gain control or Dynamic switching */
  1017. enum vpfe_ipipe_car_meth meth;
  1018. /* Gain1 function configuration for Gain control */
  1019. struct vpfe_ipipe_car_gain gain1;
  1020. /* Gain2 function configuration for Gain control */
  1021. struct vpfe_ipipe_car_gain gain2;
  1022. /* HPF type used for CAR */
  1023. enum vpfe_ipipe_car_hpf_type hpf;
  1024. /* csup_thr: HPF threshold for Gain control */
  1025. unsigned char hpf_thr;
  1026. /* Down shift value for hpf. 2 bits */
  1027. unsigned char hpf_shft;
  1028. /* switch limit for median filter */
  1029. unsigned char sw0;
  1030. /* switch coefficient for Gain control */
  1031. unsigned char sw1;
  1032. };
  1033. /* structure for Chromatic Gain Suppression */
  1034. struct vpfe_ipipe_cgs {
  1035. /* enable/disable */
  1036. unsigned char en;
  1037. /* gain1 bright side threshold */
  1038. unsigned char h_thr;
  1039. /* gain1 bright side slope */
  1040. unsigned char h_slope;
  1041. /* gain1 down shift value for bright side */
  1042. unsigned char h_shft;
  1043. /* gain1 bright side minimum gain */
  1044. unsigned char h_min;
  1045. };
  1046. /* Max pixels allowed in the input. If above this either decimation
  1047. * or frame division mode to be enabled
  1048. */
  1049. #define VPFE_IPIPE_MAX_INPUT_WIDTH 2600
  1050. struct vpfe_ipipe_input_config {
  1051. unsigned int vst;
  1052. unsigned int hst;
  1053. };
  1054. /**
  1055. * struct vpfe_ipipe_config - IPIPE engine configuration (user)
  1056. * @input_config: Pointer to structure for ipipe configuration.
  1057. * @flag: Specifies which ISP IPIPE functions should be enabled.
  1058. * @lutdpc: Pointer to luma enhancement structure.
  1059. * @otfdpc: Pointer to structure for defect correction.
  1060. * @nf1: Pointer to structure for Noise Filter.
  1061. * @nf2: Pointer to structure for Noise Filter.
  1062. * @gic: Pointer to structure for Green Imbalance.
  1063. * @wbal: Pointer to structure for White Balance.
  1064. * @cfa: Pointer to structure containing the CFA interpolation.
  1065. * @rgb2rgb1: Pointer to structure for RGB to RGB Blending.
  1066. * @rgb2rgb2: Pointer to structure for RGB to RGB Blending.
  1067. * @gamma: Pointer to gamma structure.
  1068. * @lut: Pointer to structure for 3D LUT.
  1069. * @rgb2yuv: Pointer to structure for RGB-YCbCr conversion.
  1070. * @gbce: Pointer to structure for Global Brightness,Contrast Control.
  1071. * @yuv422_conv: Pointer to structure for YUV 422 conversion.
  1072. * @yee: Pointer to structure for Edge Enhancer.
  1073. * @car: Pointer to structure for Chromatic Artifact Reduction.
  1074. * @cgs: Pointer to structure for Chromatic Gain Suppression.
  1075. */
  1076. struct vpfe_ipipe_config {
  1077. __u32 flag;
  1078. struct vpfe_ipipe_input_config __user *input_config;
  1079. struct vpfe_ipipe_lutdpc __user *lutdpc;
  1080. struct vpfe_ipipe_otfdpc __user *otfdpc;
  1081. struct vpfe_ipipe_nf __user *nf1;
  1082. struct vpfe_ipipe_nf __user *nf2;
  1083. struct vpfe_ipipe_gic __user *gic;
  1084. struct vpfe_ipipe_wb __user *wbal;
  1085. struct vpfe_ipipe_cfa __user *cfa;
  1086. struct vpfe_ipipe_rgb2rgb __user *rgb2rgb1;
  1087. struct vpfe_ipipe_rgb2rgb __user *rgb2rgb2;
  1088. struct vpfe_ipipe_gamma __user *gamma;
  1089. struct vpfe_ipipe_3d_lut __user *lut;
  1090. struct vpfe_ipipe_rgb2yuv __user *rgb2yuv;
  1091. struct vpfe_ipipe_gbce __user *gbce;
  1092. struct vpfe_ipipe_yuv422_conv __user *yuv422_conv;
  1093. struct vpfe_ipipe_yee __user *yee;
  1094. struct vpfe_ipipe_car __user *car;
  1095. struct vpfe_ipipe_cgs __user *cgs;
  1096. };
  1097. /*******************************************************************
  1098. ** Resizer API structures
  1099. *******************************************************************/
  1100. /* Interpolation types used for horizontal rescale */
  1101. enum vpfe_rsz_intp_t {
  1102. VPFE_RSZ_INTP_CUBIC,
  1103. VPFE_RSZ_INTP_LINEAR
  1104. };
  1105. /* Horizontal LPF intensity selection */
  1106. enum vpfe_rsz_h_lpf_lse_t {
  1107. VPFE_RSZ_H_LPF_LSE_INTERN,
  1108. VPFE_RSZ_H_LPF_LSE_USER_VAL
  1109. };
  1110. enum vpfe_rsz_down_scale_ave_sz {
  1111. VPFE_IPIPE_DWN_SCALE_1_OVER_2,
  1112. VPFE_IPIPE_DWN_SCALE_1_OVER_4,
  1113. VPFE_IPIPE_DWN_SCALE_1_OVER_8,
  1114. VPFE_IPIPE_DWN_SCALE_1_OVER_16,
  1115. VPFE_IPIPE_DWN_SCALE_1_OVER_32,
  1116. VPFE_IPIPE_DWN_SCALE_1_OVER_64,
  1117. VPFE_IPIPE_DWN_SCALE_1_OVER_128,
  1118. VPFE_IPIPE_DWN_SCALE_1_OVER_256
  1119. };
  1120. struct vpfe_rsz_output_spec {
  1121. /* enable horizontal flip */
  1122. unsigned char h_flip;
  1123. /* enable vertical flip */
  1124. unsigned char v_flip;
  1125. /* line start offset for y. */
  1126. unsigned int vst_y;
  1127. /* line start offset for c. Only for 420 */
  1128. unsigned int vst_c;
  1129. /* vertical rescale interpolation type, YCbCr or Luminance */
  1130. enum vpfe_rsz_intp_t v_typ_y;
  1131. /* vertical rescale interpolation type for Chrominance */
  1132. enum vpfe_rsz_intp_t v_typ_c;
  1133. /* vertical lpf intensity - Luminance */
  1134. unsigned char v_lpf_int_y;
  1135. /* vertical lpf intensity - Chrominance */
  1136. unsigned char v_lpf_int_c;
  1137. /* horizontal rescale interpolation types, YCbCr or Luminance */
  1138. enum vpfe_rsz_intp_t h_typ_y;
  1139. /* horizontal rescale interpolation types, Chrominance */
  1140. enum vpfe_rsz_intp_t h_typ_c;
  1141. /* horizontal lpf intensity - Luminance */
  1142. unsigned char h_lpf_int_y;
  1143. /* horizontal lpf intensity - Chrominance */
  1144. unsigned char h_lpf_int_c;
  1145. /* Use down scale mode for scale down */
  1146. unsigned char en_down_scale;
  1147. /* if downscale, set the downscale more average size for horizontal
  1148. * direction. Used only if output width and height is less than
  1149. * input sizes
  1150. */
  1151. enum vpfe_rsz_down_scale_ave_sz h_dscale_ave_sz;
  1152. /* if downscale, set the downscale more average size for vertical
  1153. * direction. Used only if output width and height is less than
  1154. * input sizes
  1155. */
  1156. enum vpfe_rsz_down_scale_ave_sz v_dscale_ave_sz;
  1157. /* Y offset. If set, the offset would be added to the base address
  1158. */
  1159. unsigned int user_y_ofst;
  1160. /* C offset. If set, the offset would be added to the base address
  1161. */
  1162. unsigned int user_c_ofst;
  1163. };
  1164. struct vpfe_rsz_config_params {
  1165. unsigned int vst;
  1166. /* horizontal start position of the image
  1167. * data to IPIPE
  1168. */
  1169. unsigned int hst;
  1170. /* output spec of the image data coming out of resizer - 0(UYVY).
  1171. */
  1172. struct vpfe_rsz_output_spec output1;
  1173. /* output spec of the image data coming out of resizer - 1(UYVY).
  1174. */
  1175. struct vpfe_rsz_output_spec output2;
  1176. /* 0 , chroma sample at odd pixel, 1 - even pixel */
  1177. unsigned char chroma_sample_even;
  1178. unsigned char frame_div_mode_en;
  1179. unsigned char yuv_y_min;
  1180. unsigned char yuv_y_max;
  1181. unsigned char yuv_c_min;
  1182. unsigned char yuv_c_max;
  1183. enum vpfe_chr_pos out_chr_pos;
  1184. unsigned char bypass;
  1185. };
  1186. /* Structure for VIDIOC_VPFE_RSZ_[S/G]_CONFIG IOCTLs */
  1187. struct vpfe_rsz_config {
  1188. struct vpfe_rsz_config_params *config;
  1189. };
  1190. #endif /* _DAVINCI_VPFE_USER_H */