dm644x_ccdc.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright (C) 2006-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 _DM644X_CCDC_H
  19. #define _DM644X_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_15_6, /* use bits 15-6 for gamma */
  41. CCDC_GAMMA_BITS_14_5,
  42. CCDC_GAMMA_BITS_13_4,
  43. CCDC_GAMMA_BITS_12_3,
  44. CCDC_GAMMA_BITS_11_2,
  45. CCDC_GAMMA_BITS_10_1,
  46. CCDC_GAMMA_BITS_09_0 /* use bits 9-0 for gamma */
  47. };
  48. /* returns the highest bit used for the gamma */
  49. static inline u8 ccdc_gamma_width_max_bit(enum ccdc_gamma_width width)
  50. {
  51. return 15 - width;
  52. }
  53. enum ccdc_data_size {
  54. CCDC_DATA_16BITS,
  55. CCDC_DATA_15BITS,
  56. CCDC_DATA_14BITS,
  57. CCDC_DATA_13BITS,
  58. CCDC_DATA_12BITS,
  59. CCDC_DATA_11BITS,
  60. CCDC_DATA_10BITS,
  61. CCDC_DATA_8BITS
  62. };
  63. /* returns the highest bit used for this data size */
  64. static inline u8 ccdc_data_size_max_bit(enum ccdc_data_size sz)
  65. {
  66. return sz == CCDC_DATA_8BITS ? 7 : 15 - sz;
  67. }
  68. /* structure for ALaw */
  69. struct ccdc_a_law {
  70. /* Enable/disable A-Law */
  71. unsigned char enable;
  72. /* Gamma Width Input */
  73. enum ccdc_gamma_width gamma_wd;
  74. };
  75. /* structure for Black Clamping */
  76. struct ccdc_black_clamp {
  77. unsigned char enable;
  78. /* only if bClampEnable is TRUE */
  79. enum ccdc_sample_length sample_pixel;
  80. /* only if bClampEnable is TRUE */
  81. enum ccdc_sample_line sample_ln;
  82. /* only if bClampEnable is TRUE */
  83. unsigned short start_pixel;
  84. /* only if bClampEnable is TRUE */
  85. unsigned short sgain;
  86. /* only if bClampEnable is FALSE */
  87. unsigned short dc_sub;
  88. };
  89. /* structure for Black Level Compensation */
  90. struct ccdc_black_compensation {
  91. /* Constant value to subtract from Red component */
  92. char r;
  93. /* Constant value to subtract from Gr component */
  94. char gr;
  95. /* Constant value to subtract from Blue component */
  96. char b;
  97. /* Constant value to subtract from Gb component */
  98. char gb;
  99. };
  100. /* structure for fault pixel correction */
  101. struct ccdc_fault_pixel {
  102. /* Enable or Disable fault pixel correction */
  103. unsigned char enable;
  104. /* Number of fault pixel */
  105. unsigned short fp_num;
  106. /* Address of fault pixel table */
  107. unsigned long fpc_table_addr;
  108. };
  109. /* Structure for CCDC configuration parameters for raw capture mode passed
  110. * by application
  111. */
  112. struct ccdc_config_params_raw {
  113. /* data size value from 8 to 16 bits */
  114. enum ccdc_data_size data_sz;
  115. /* Structure for Optional A-Law */
  116. struct ccdc_a_law alaw;
  117. /* Structure for Optical Black Clamp */
  118. struct ccdc_black_clamp blk_clamp;
  119. /* Structure for Black Compensation */
  120. struct ccdc_black_compensation blk_comp;
  121. /* Structure for Fault Pixel Module Configuration */
  122. struct ccdc_fault_pixel fault_pxl;
  123. };
  124. #ifdef __KERNEL__
  125. #include <linux/io.h>
  126. /* Define to enable/disable video port */
  127. #define FP_NUM_BYTES 4
  128. /* Define for extra pixel/line and extra lines/frame */
  129. #define NUM_EXTRAPIXELS 8
  130. #define NUM_EXTRALINES 8
  131. /* settings for commonly used video formats */
  132. #define CCDC_WIN_PAL {0, 0, 720, 576}
  133. /* ntsc square pixel */
  134. #define CCDC_WIN_VGA {0, 0, (640 + NUM_EXTRAPIXELS), (480 + NUM_EXTRALINES)}
  135. /* Structure for CCDC configuration parameters for raw capture mode */
  136. struct ccdc_params_raw {
  137. /* pixel format */
  138. enum ccdc_pixfmt pix_fmt;
  139. /* progressive or interlaced frame */
  140. enum ccdc_frmfmt frm_fmt;
  141. /* video window */
  142. struct v4l2_rect win;
  143. /* field id polarity */
  144. enum vpfe_pin_pol fid_pol;
  145. /* vertical sync polarity */
  146. enum vpfe_pin_pol vd_pol;
  147. /* horizontal sync polarity */
  148. enum vpfe_pin_pol hd_pol;
  149. /* interleaved or separated fields */
  150. enum ccdc_buftype buf_type;
  151. /*
  152. * enable to store the image in inverse
  153. * order in memory(bottom to top)
  154. */
  155. unsigned char image_invert_enable;
  156. /* configurable paramaters */
  157. struct ccdc_config_params_raw config_params;
  158. };
  159. struct ccdc_params_ycbcr {
  160. /* pixel format */
  161. enum ccdc_pixfmt pix_fmt;
  162. /* progressive or interlaced frame */
  163. enum ccdc_frmfmt frm_fmt;
  164. /* video window */
  165. struct v4l2_rect win;
  166. /* field id polarity */
  167. enum vpfe_pin_pol fid_pol;
  168. /* vertical sync polarity */
  169. enum vpfe_pin_pol vd_pol;
  170. /* horizontal sync polarity */
  171. enum vpfe_pin_pol hd_pol;
  172. /* enable BT.656 embedded sync mode */
  173. int bt656_enable;
  174. /* cb:y:cr:y or y:cb:y:cr in memory */
  175. enum ccdc_pixorder pix_order;
  176. /* interleaved or separated fields */
  177. enum ccdc_buftype buf_type;
  178. };
  179. #endif
  180. #endif /* _DM644X_CCDC_H */