opp.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. * Copyright 2012-15 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef __DAL_OPP_H__
  26. #define __DAL_OPP_H__
  27. #include "hw_shared.h"
  28. #include "dc_hw_types.h"
  29. #include "transform.h"
  30. struct fixed31_32;
  31. /* TODO: Need cleanup */
  32. enum clamping_range {
  33. CLAMPING_FULL_RANGE = 0, /* No Clamping */
  34. CLAMPING_LIMITED_RANGE_8BPC, /* 8 bpc: Clamping 1 to FE */
  35. CLAMPING_LIMITED_RANGE_10BPC, /* 10 bpc: Clamping 4 to 3FB */
  36. CLAMPING_LIMITED_RANGE_12BPC, /* 12 bpc: Clamping 10 to FEF */
  37. /* Use programmable clampping value on FMT_CLAMP_COMPONENT_R/G/B. */
  38. CLAMPING_LIMITED_RANGE_PROGRAMMABLE
  39. };
  40. struct clamping_and_pixel_encoding_params {
  41. enum dc_pixel_encoding pixel_encoding; /* Pixel Encoding */
  42. enum clamping_range clamping_level; /* Clamping identifier */
  43. enum dc_color_depth c_depth; /* Deep color use. */
  44. };
  45. struct bit_depth_reduction_params {
  46. struct {
  47. /* truncate/round */
  48. /* trunc/round enabled*/
  49. uint32_t TRUNCATE_ENABLED:1;
  50. /* 2 bits: 0=6 bpc, 1=8 bpc, 2 = 10bpc*/
  51. uint32_t TRUNCATE_DEPTH:2;
  52. /* truncate or round*/
  53. uint32_t TRUNCATE_MODE:1;
  54. /* spatial dither */
  55. /* Spatial Bit Depth Reduction enabled*/
  56. uint32_t SPATIAL_DITHER_ENABLED:1;
  57. /* 2 bits: 0=6 bpc, 1 = 8 bpc, 2 = 10bpc*/
  58. uint32_t SPATIAL_DITHER_DEPTH:2;
  59. /* 0-3 to select patterns*/
  60. uint32_t SPATIAL_DITHER_MODE:2;
  61. /* Enable RGB random dithering*/
  62. uint32_t RGB_RANDOM:1;
  63. /* Enable Frame random dithering*/
  64. uint32_t FRAME_RANDOM:1;
  65. /* Enable HighPass random dithering*/
  66. uint32_t HIGHPASS_RANDOM:1;
  67. /* temporal dither*/
  68. /* frame modulation enabled*/
  69. uint32_t FRAME_MODULATION_ENABLED:1;
  70. /* same as for trunc/spatial*/
  71. uint32_t FRAME_MODULATION_DEPTH:2;
  72. /* 2/4 gray levels*/
  73. uint32_t TEMPORAL_LEVEL:1;
  74. uint32_t FRC25:2;
  75. uint32_t FRC50:2;
  76. uint32_t FRC75:2;
  77. } flags;
  78. uint32_t r_seed_value;
  79. uint32_t b_seed_value;
  80. uint32_t g_seed_value;
  81. enum dc_pixel_encoding pixel_encoding;
  82. };
  83. enum wide_gamut_regamma_mode {
  84. /* 0x0 - BITS2:0 Bypass */
  85. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_BYPASS,
  86. /* 0x1 - Fixed curve sRGB 2.4 */
  87. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_SRGB24,
  88. /* 0x2 - Fixed curve xvYCC 2.22 */
  89. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_XYYCC22,
  90. /* 0x3 - Programmable control A */
  91. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_A,
  92. /* 0x4 - Programmable control B */
  93. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_B,
  94. /* 0x0 - BITS6:4 Bypass */
  95. WIDE_GAMUT_REGAMMA_MODE_OVL_BYPASS,
  96. /* 0x1 - Fixed curve sRGB 2.4 */
  97. WIDE_GAMUT_REGAMMA_MODE_OVL_SRGB24,
  98. /* 0x2 - Fixed curve xvYCC 2.22 */
  99. WIDE_GAMUT_REGAMMA_MODE_OVL_XYYCC22,
  100. /* 0x3 - Programmable control A */
  101. WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_A,
  102. /* 0x4 - Programmable control B */
  103. WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_B
  104. };
  105. struct gamma_pixel {
  106. struct fixed31_32 r;
  107. struct fixed31_32 g;
  108. struct fixed31_32 b;
  109. };
  110. enum channel_name {
  111. CHANNEL_NAME_RED,
  112. CHANNEL_NAME_GREEN,
  113. CHANNEL_NAME_BLUE
  114. };
  115. struct custom_float_format {
  116. uint32_t mantissa_bits;
  117. uint32_t exponenta_bits;
  118. bool sign;
  119. };
  120. struct custom_float_value {
  121. uint32_t mantissa;
  122. uint32_t exponenta;
  123. uint32_t value;
  124. bool negative;
  125. };
  126. struct hw_x_point {
  127. uint32_t custom_float_x;
  128. struct fixed31_32 x;
  129. struct fixed31_32 regamma_y_red;
  130. struct fixed31_32 regamma_y_green;
  131. struct fixed31_32 regamma_y_blue;
  132. };
  133. struct pwl_float_data_ex {
  134. struct fixed31_32 r;
  135. struct fixed31_32 g;
  136. struct fixed31_32 b;
  137. struct fixed31_32 delta_r;
  138. struct fixed31_32 delta_g;
  139. struct fixed31_32 delta_b;
  140. };
  141. enum hw_point_position {
  142. /* hw point sits between left and right sw points */
  143. HW_POINT_POSITION_MIDDLE,
  144. /* hw point lays left from left (smaller) sw point */
  145. HW_POINT_POSITION_LEFT,
  146. /* hw point lays stays from right (bigger) sw point */
  147. HW_POINT_POSITION_RIGHT
  148. };
  149. struct gamma_point {
  150. int32_t left_index;
  151. int32_t right_index;
  152. enum hw_point_position pos;
  153. struct fixed31_32 coeff;
  154. };
  155. struct pixel_gamma_point {
  156. struct gamma_point r;
  157. struct gamma_point g;
  158. struct gamma_point b;
  159. };
  160. struct gamma_coefficients {
  161. struct fixed31_32 a0[3];
  162. struct fixed31_32 a1[3];
  163. struct fixed31_32 a2[3];
  164. struct fixed31_32 a3[3];
  165. struct fixed31_32 user_gamma[3];
  166. struct fixed31_32 user_contrast;
  167. struct fixed31_32 user_brightness;
  168. };
  169. struct pwl_float_data {
  170. struct fixed31_32 r;
  171. struct fixed31_32 g;
  172. struct fixed31_32 b;
  173. };
  174. struct mpc_tree_cfg {
  175. int num_pipes;
  176. int dpp[MAX_PIPES];
  177. int mpcc[MAX_PIPES];
  178. };
  179. struct output_pixel_processor {
  180. struct dc_context *ctx;
  181. uint32_t inst;
  182. struct pwl_params regamma_params;
  183. struct mpc_tree_cfg mpc_tree;
  184. bool mpcc_disconnect_pending[MAX_PIPES];
  185. const struct opp_funcs *funcs;
  186. };
  187. enum fmt_stereo_action {
  188. FMT_STEREO_ACTION_ENABLE = 0,
  189. FMT_STEREO_ACTION_DISABLE,
  190. FMT_STEREO_ACTION_UPDATE_POLARITY
  191. };
  192. struct opp_grph_csc_adjustment {
  193. //enum grph_color_adjust_option color_adjust_option;
  194. enum dc_color_space c_space;
  195. enum dc_color_depth color_depth; /* clean up to uint32_t */
  196. enum graphics_csc_adjust_type csc_adjust_type;
  197. int32_t adjust_divider;
  198. int32_t grph_cont;
  199. int32_t grph_sat;
  200. int32_t grph_bright;
  201. int32_t grph_hue;
  202. };
  203. /* Underlay related types */
  204. struct hw_adjustment_range {
  205. int32_t hw_default;
  206. int32_t min;
  207. int32_t max;
  208. int32_t step;
  209. uint32_t divider; /* (actually HW range is min/divider; divider !=0) */
  210. };
  211. enum ovl_csc_adjust_item {
  212. OVERLAY_BRIGHTNESS = 0,
  213. OVERLAY_GAMMA,
  214. OVERLAY_CONTRAST,
  215. OVERLAY_SATURATION,
  216. OVERLAY_HUE,
  217. OVERLAY_ALPHA,
  218. OVERLAY_ALPHA_PER_PIX,
  219. OVERLAY_COLOR_TEMPERATURE
  220. };
  221. struct opp_funcs {
  222. /* FORMATTER RELATED */
  223. void (*opp_program_fmt)(
  224. struct output_pixel_processor *opp,
  225. struct bit_depth_reduction_params *fmt_bit_depth,
  226. struct clamping_and_pixel_encoding_params *clamping);
  227. void (*opp_set_dyn_expansion)(
  228. struct output_pixel_processor *opp,
  229. enum dc_color_space color_sp,
  230. enum dc_color_depth color_dpth,
  231. enum signal_type signal);
  232. void (*opp_program_bit_depth_reduction)(
  233. struct output_pixel_processor *opp,
  234. const struct bit_depth_reduction_params *params);
  235. /* underlay related */
  236. void (*opp_get_underlay_adjustment_range)(
  237. struct output_pixel_processor *opp,
  238. enum ovl_csc_adjust_item overlay_adjust_item,
  239. struct hw_adjustment_range *range);
  240. void (*opp_destroy)(struct output_pixel_processor **opp);
  241. void (*opp_set_stereo_polarity)(
  242. struct output_pixel_processor *opp,
  243. bool enable,
  244. bool rightEyePolarity);
  245. void (*opp_set_test_pattern)(
  246. struct output_pixel_processor *opp,
  247. bool enable);
  248. void (*opp_dpg_blank_enable)(
  249. struct output_pixel_processor *opp,
  250. bool enable,
  251. const struct tg_color *color,
  252. int width,
  253. int height);
  254. void (*opp_convert_pti)(
  255. struct output_pixel_processor *opp,
  256. bool enable,
  257. bool polarity);
  258. };
  259. #endif