dm644x_ccdc.h 4.7 KB

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