dm355_ccdc.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Copyright (C) 2005-2009 Texas Instruments Inc
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef _DM355_CCDC_H
  15. #define _DM355_CCDC_H
  16. #include <media/davinci/ccdc_types.h>
  17. #include <media/davinci/vpfe_types.h>
  18. /* enum for No of pixel per line to be avg. in Black Clamping */
  19. enum ccdc_sample_length {
  20. CCDC_SAMPLE_1PIXELS,
  21. CCDC_SAMPLE_2PIXELS,
  22. CCDC_SAMPLE_4PIXELS,
  23. CCDC_SAMPLE_8PIXELS,
  24. CCDC_SAMPLE_16PIXELS
  25. };
  26. /* enum for No of lines in Black Clamping */
  27. enum ccdc_sample_line {
  28. CCDC_SAMPLE_1LINES,
  29. CCDC_SAMPLE_2LINES,
  30. CCDC_SAMPLE_4LINES,
  31. CCDC_SAMPLE_8LINES,
  32. CCDC_SAMPLE_16LINES
  33. };
  34. /* enum for Alaw gamma width */
  35. enum ccdc_gamma_width {
  36. CCDC_GAMMA_BITS_13_4,
  37. CCDC_GAMMA_BITS_12_3,
  38. CCDC_GAMMA_BITS_11_2,
  39. CCDC_GAMMA_BITS_10_1,
  40. CCDC_GAMMA_BITS_09_0
  41. };
  42. enum ccdc_colpats {
  43. CCDC_RED,
  44. CCDC_GREEN_RED,
  45. CCDC_GREEN_BLUE,
  46. CCDC_BLUE
  47. };
  48. struct ccdc_col_pat {
  49. enum ccdc_colpats olop;
  50. enum ccdc_colpats olep;
  51. enum ccdc_colpats elop;
  52. enum ccdc_colpats elep;
  53. };
  54. enum ccdc_datasft {
  55. CCDC_DATA_NO_SHIFT,
  56. CCDC_DATA_SHIFT_1BIT,
  57. CCDC_DATA_SHIFT_2BIT,
  58. CCDC_DATA_SHIFT_3BIT,
  59. CCDC_DATA_SHIFT_4BIT,
  60. CCDC_DATA_SHIFT_5BIT,
  61. CCDC_DATA_SHIFT_6BIT
  62. };
  63. enum ccdc_data_size {
  64. CCDC_DATA_16BITS,
  65. CCDC_DATA_15BITS,
  66. CCDC_DATA_14BITS,
  67. CCDC_DATA_13BITS,
  68. CCDC_DATA_12BITS,
  69. CCDC_DATA_11BITS,
  70. CCDC_DATA_10BITS,
  71. CCDC_DATA_8BITS
  72. };
  73. enum ccdc_mfilt1 {
  74. CCDC_NO_MEDIAN_FILTER1,
  75. CCDC_AVERAGE_FILTER1,
  76. CCDC_MEDIAN_FILTER1
  77. };
  78. enum ccdc_mfilt2 {
  79. CCDC_NO_MEDIAN_FILTER2,
  80. CCDC_AVERAGE_FILTER2,
  81. CCDC_MEDIAN_FILTER2
  82. };
  83. /* structure for ALaw */
  84. struct ccdc_a_law {
  85. /* Enable/disable A-Law */
  86. unsigned char enable;
  87. /* Gamma Width Input */
  88. enum ccdc_gamma_width gamma_wd;
  89. };
  90. /* structure for Black Clamping */
  91. struct ccdc_black_clamp {
  92. /* only if bClampEnable is TRUE */
  93. unsigned char b_clamp_enable;
  94. /* only if bClampEnable is TRUE */
  95. enum ccdc_sample_length sample_pixel;
  96. /* only if bClampEnable is TRUE */
  97. enum ccdc_sample_line sample_ln;
  98. /* only if bClampEnable is TRUE */
  99. unsigned short start_pixel;
  100. /* only if bClampEnable is FALSE */
  101. unsigned short sgain;
  102. unsigned short dc_sub;
  103. };
  104. /* structure for Black Level Compensation */
  105. struct ccdc_black_compensation {
  106. /* Constant value to subtract from Red component */
  107. unsigned char r;
  108. /* Constant value to subtract from Gr component */
  109. unsigned char gr;
  110. /* Constant value to subtract from Blue component */
  111. unsigned char b;
  112. /* Constant value to subtract from Gb component */
  113. unsigned char gb;
  114. };
  115. struct ccdc_float {
  116. int integer;
  117. unsigned int decimal;
  118. };
  119. #define CCDC_CSC_COEFF_TABLE_SIZE 16
  120. /* structure for color space converter */
  121. struct ccdc_csc {
  122. unsigned char enable;
  123. /*
  124. * S8Q5. Use 2 decimal precision, user values range from -3.00 to 3.99.
  125. * example - to use 1.03, set integer part as 1, and decimal part as 3
  126. * to use -1.03, set integer part as -1 and decimal part as 3
  127. */
  128. struct ccdc_float coeff[CCDC_CSC_COEFF_TABLE_SIZE];
  129. };
  130. /* Structures for Vertical Defect Correction*/
  131. enum ccdc_vdf_csl {
  132. CCDC_VDF_NORMAL,
  133. CCDC_VDF_HORZ_INTERPOL_SAT,
  134. CCDC_VDF_HORZ_INTERPOL
  135. };
  136. enum ccdc_vdf_cuda {
  137. CCDC_VDF_WHOLE_LINE_CORRECT,
  138. CCDC_VDF_UPPER_DISABLE
  139. };
  140. enum ccdc_dfc_mwr {
  141. CCDC_DFC_MWR_WRITE_COMPLETE,
  142. CCDC_DFC_WRITE_REG
  143. };
  144. enum ccdc_dfc_mrd {
  145. CCDC_DFC_READ_COMPLETE,
  146. CCDC_DFC_READ_REG
  147. };
  148. enum ccdc_dfc_ma_rst {
  149. CCDC_DFC_INCR_ADDR,
  150. CCDC_DFC_CLR_ADDR
  151. };
  152. enum ccdc_dfc_mclr {
  153. CCDC_DFC_CLEAR_COMPLETE,
  154. CCDC_DFC_CLEAR
  155. };
  156. struct ccdc_dft_corr_ctl {
  157. enum ccdc_vdf_csl vdfcsl;
  158. enum ccdc_vdf_cuda vdfcuda;
  159. unsigned int vdflsft;
  160. };
  161. struct ccdc_dft_corr_mem_ctl {
  162. enum ccdc_dfc_mwr dfcmwr;
  163. enum ccdc_dfc_mrd dfcmrd;
  164. enum ccdc_dfc_ma_rst dfcmarst;
  165. enum ccdc_dfc_mclr dfcmclr;
  166. };
  167. #define CCDC_DFT_TABLE_SIZE 16
  168. /*
  169. * Main Structure for vertical defect correction. Vertical defect
  170. * correction can correct up to 16 defects if defects less than 16
  171. * then pad the rest with 0
  172. */
  173. struct ccdc_vertical_dft {
  174. unsigned char ver_dft_en;
  175. unsigned char gen_dft_en;
  176. unsigned int saturation_ctl;
  177. struct ccdc_dft_corr_ctl dft_corr_ctl;
  178. struct ccdc_dft_corr_mem_ctl dft_corr_mem_ctl;
  179. int table_size;
  180. unsigned int dft_corr_horz[CCDC_DFT_TABLE_SIZE];
  181. unsigned int dft_corr_vert[CCDC_DFT_TABLE_SIZE];
  182. unsigned int dft_corr_sub1[CCDC_DFT_TABLE_SIZE];
  183. unsigned int dft_corr_sub2[CCDC_DFT_TABLE_SIZE];
  184. unsigned int dft_corr_sub3[CCDC_DFT_TABLE_SIZE];
  185. };
  186. struct ccdc_data_offset {
  187. unsigned char horz_offset;
  188. unsigned char vert_offset;
  189. };
  190. /*
  191. * Structure for CCDC configuration parameters for raw capture mode passed
  192. * by application
  193. */
  194. struct ccdc_config_params_raw {
  195. /* data shift to be applied before storing */
  196. enum ccdc_datasft datasft;
  197. /* data size value from 8 to 16 bits */
  198. enum ccdc_data_size data_sz;
  199. /* median filter for sdram */
  200. enum ccdc_mfilt1 mfilt1;
  201. enum ccdc_mfilt2 mfilt2;
  202. /* low pass filter enable/disable */
  203. unsigned char lpf_enable;
  204. /* Threshold of median filter */
  205. int med_filt_thres;
  206. /*
  207. * horz and vertical data offset. Appliable for defect correction
  208. * and lsc
  209. */
  210. struct ccdc_data_offset data_offset;
  211. /* Structure for Optional A-Law */
  212. struct ccdc_a_law alaw;
  213. /* Structure for Optical Black Clamp */
  214. struct ccdc_black_clamp blk_clamp;
  215. /* Structure for Black Compensation */
  216. struct ccdc_black_compensation blk_comp;
  217. /* struture for vertical Defect Correction Module Configuration */
  218. struct ccdc_vertical_dft vertical_dft;
  219. /* structure for color space converter Module Configuration */
  220. struct ccdc_csc csc;
  221. /* color patters for bayer capture */
  222. struct ccdc_col_pat col_pat_field0;
  223. struct ccdc_col_pat col_pat_field1;
  224. };
  225. #ifdef __KERNEL__
  226. #include <linux/io.h>
  227. #define CCDC_WIN_PAL {0, 0, 720, 576}
  228. #define CCDC_WIN_VGA {0, 0, 640, 480}
  229. struct ccdc_params_ycbcr {
  230. /* pixel format */
  231. enum ccdc_pixfmt pix_fmt;
  232. /* progressive or interlaced frame */
  233. enum ccdc_frmfmt frm_fmt;
  234. /* video window */
  235. struct v4l2_rect win;
  236. /* field id polarity */
  237. enum vpfe_pin_pol fid_pol;
  238. /* vertical sync polarity */
  239. enum vpfe_pin_pol vd_pol;
  240. /* horizontal sync polarity */
  241. enum vpfe_pin_pol hd_pol;
  242. /* enable BT.656 embedded sync mode */
  243. int bt656_enable;
  244. /* cb:y:cr:y or y:cb:y:cr in memory */
  245. enum ccdc_pixorder pix_order;
  246. /* interleaved or separated fields */
  247. enum ccdc_buftype buf_type;
  248. };
  249. /* Gain applied to Raw Bayer data */
  250. struct ccdc_gain {
  251. unsigned short r_ye;
  252. unsigned short gr_cy;
  253. unsigned short gb_g;
  254. unsigned short b_mg;
  255. };
  256. /* Structure for CCDC configuration parameters for raw capture mode */
  257. struct ccdc_params_raw {
  258. /* pixel format */
  259. enum ccdc_pixfmt pix_fmt;
  260. /* progressive or interlaced frame */
  261. enum ccdc_frmfmt frm_fmt;
  262. /* video window */
  263. struct v4l2_rect win;
  264. /* field id polarity */
  265. enum vpfe_pin_pol fid_pol;
  266. /* vertical sync polarity */
  267. enum vpfe_pin_pol vd_pol;
  268. /* horizontal sync polarity */
  269. enum vpfe_pin_pol hd_pol;
  270. /* interleaved or separated fields */
  271. enum ccdc_buftype buf_type;
  272. /* Gain values */
  273. struct ccdc_gain gain;
  274. /* offset */
  275. unsigned int ccdc_offset;
  276. /* horizontal flip enable */
  277. unsigned char horz_flip_enable;
  278. /*
  279. * enable to store the image in inverse order in memory
  280. * (bottom to top)
  281. */
  282. unsigned char image_invert_enable;
  283. /* Configurable part of raw data */
  284. struct ccdc_config_params_raw config_params;
  285. };
  286. #endif
  287. #endif /* DM355_CCDC_H */