dm355_ccdc.h 7.8 KB

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