opp.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. #include "mpc.h"
  31. struct fixed31_32;
  32. /* TODO: Need cleanup */
  33. enum clamping_range {
  34. CLAMPING_FULL_RANGE = 0, /* No Clamping */
  35. CLAMPING_LIMITED_RANGE_8BPC, /* 8 bpc: Clamping 1 to FE */
  36. CLAMPING_LIMITED_RANGE_10BPC, /* 10 bpc: Clamping 4 to 3FB */
  37. CLAMPING_LIMITED_RANGE_12BPC, /* 12 bpc: Clamping 10 to FEF */
  38. /* Use programmable clampping value on FMT_CLAMP_COMPONENT_R/G/B. */
  39. CLAMPING_LIMITED_RANGE_PROGRAMMABLE
  40. };
  41. struct clamping_and_pixel_encoding_params {
  42. enum dc_pixel_encoding pixel_encoding; /* Pixel Encoding */
  43. enum clamping_range clamping_level; /* Clamping identifier */
  44. enum dc_color_depth c_depth; /* Deep color use. */
  45. };
  46. struct bit_depth_reduction_params {
  47. struct {
  48. /* truncate/round */
  49. /* trunc/round enabled*/
  50. uint32_t TRUNCATE_ENABLED:1;
  51. /* 2 bits: 0=6 bpc, 1=8 bpc, 2 = 10bpc*/
  52. uint32_t TRUNCATE_DEPTH:2;
  53. /* truncate or round*/
  54. uint32_t TRUNCATE_MODE:1;
  55. /* spatial dither */
  56. /* Spatial Bit Depth Reduction enabled*/
  57. uint32_t SPATIAL_DITHER_ENABLED:1;
  58. /* 2 bits: 0=6 bpc, 1 = 8 bpc, 2 = 10bpc*/
  59. uint32_t SPATIAL_DITHER_DEPTH:2;
  60. /* 0-3 to select patterns*/
  61. uint32_t SPATIAL_DITHER_MODE:2;
  62. /* Enable RGB random dithering*/
  63. uint32_t RGB_RANDOM:1;
  64. /* Enable Frame random dithering*/
  65. uint32_t FRAME_RANDOM:1;
  66. /* Enable HighPass random dithering*/
  67. uint32_t HIGHPASS_RANDOM:1;
  68. /* temporal dither*/
  69. /* frame modulation enabled*/
  70. uint32_t FRAME_MODULATION_ENABLED:1;
  71. /* same as for trunc/spatial*/
  72. uint32_t FRAME_MODULATION_DEPTH:2;
  73. /* 2/4 gray levels*/
  74. uint32_t TEMPORAL_LEVEL:1;
  75. uint32_t FRC25:2;
  76. uint32_t FRC50:2;
  77. uint32_t FRC75:2;
  78. } flags;
  79. uint32_t r_seed_value;
  80. uint32_t b_seed_value;
  81. uint32_t g_seed_value;
  82. enum dc_pixel_encoding pixel_encoding;
  83. };
  84. enum wide_gamut_regamma_mode {
  85. /* 0x0 - BITS2:0 Bypass */
  86. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_BYPASS,
  87. /* 0x1 - Fixed curve sRGB 2.4 */
  88. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_SRGB24,
  89. /* 0x2 - Fixed curve xvYCC 2.22 */
  90. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_XYYCC22,
  91. /* 0x3 - Programmable control A */
  92. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_A,
  93. /* 0x4 - Programmable control B */
  94. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_B,
  95. /* 0x0 - BITS6:4 Bypass */
  96. WIDE_GAMUT_REGAMMA_MODE_OVL_BYPASS,
  97. /* 0x1 - Fixed curve sRGB 2.4 */
  98. WIDE_GAMUT_REGAMMA_MODE_OVL_SRGB24,
  99. /* 0x2 - Fixed curve xvYCC 2.22 */
  100. WIDE_GAMUT_REGAMMA_MODE_OVL_XYYCC22,
  101. /* 0x3 - Programmable control A */
  102. WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_A,
  103. /* 0x4 - Programmable control B */
  104. WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_B
  105. };
  106. struct gamma_pixel {
  107. struct fixed31_32 r;
  108. struct fixed31_32 g;
  109. struct fixed31_32 b;
  110. };
  111. enum channel_name {
  112. CHANNEL_NAME_RED,
  113. CHANNEL_NAME_GREEN,
  114. CHANNEL_NAME_BLUE
  115. };
  116. struct custom_float_format {
  117. uint32_t mantissa_bits;
  118. uint32_t exponenta_bits;
  119. bool sign;
  120. };
  121. struct custom_float_value {
  122. uint32_t mantissa;
  123. uint32_t exponenta;
  124. uint32_t value;
  125. bool negative;
  126. };
  127. struct hw_x_point {
  128. uint32_t custom_float_x;
  129. struct fixed31_32 x;
  130. struct fixed31_32 regamma_y_red;
  131. struct fixed31_32 regamma_y_green;
  132. struct fixed31_32 regamma_y_blue;
  133. };
  134. struct pwl_float_data_ex {
  135. struct fixed31_32 r;
  136. struct fixed31_32 g;
  137. struct fixed31_32 b;
  138. struct fixed31_32 delta_r;
  139. struct fixed31_32 delta_g;
  140. struct fixed31_32 delta_b;
  141. };
  142. enum hw_point_position {
  143. /* hw point sits between left and right sw points */
  144. HW_POINT_POSITION_MIDDLE,
  145. /* hw point lays left from left (smaller) sw point */
  146. HW_POINT_POSITION_LEFT,
  147. /* hw point lays stays from right (bigger) sw point */
  148. HW_POINT_POSITION_RIGHT
  149. };
  150. struct gamma_point {
  151. int32_t left_index;
  152. int32_t right_index;
  153. enum hw_point_position pos;
  154. struct fixed31_32 coeff;
  155. };
  156. struct pixel_gamma_point {
  157. struct gamma_point r;
  158. struct gamma_point g;
  159. struct gamma_point b;
  160. };
  161. struct gamma_coefficients {
  162. struct fixed31_32 a0[3];
  163. struct fixed31_32 a1[3];
  164. struct fixed31_32 a2[3];
  165. struct fixed31_32 a3[3];
  166. struct fixed31_32 user_gamma[3];
  167. struct fixed31_32 user_contrast;
  168. struct fixed31_32 user_brightness;
  169. };
  170. struct pwl_float_data {
  171. struct fixed31_32 r;
  172. struct fixed31_32 g;
  173. struct fixed31_32 b;
  174. };
  175. struct mpc_tree_cfg {
  176. int num_pipes;
  177. int dpp[MAX_PIPES];
  178. int mpcc[MAX_PIPES];
  179. };
  180. struct output_pixel_processor {
  181. struct dc_context *ctx;
  182. uint32_t inst;
  183. struct pwl_params regamma_params;
  184. struct mpc_tree mpc_tree_params;
  185. bool mpcc_disconnect_pending[MAX_PIPES];
  186. const struct opp_funcs *funcs;
  187. };
  188. enum fmt_stereo_action {
  189. FMT_STEREO_ACTION_ENABLE = 0,
  190. FMT_STEREO_ACTION_DISABLE,
  191. FMT_STEREO_ACTION_UPDATE_POLARITY
  192. };
  193. struct opp_grph_csc_adjustment {
  194. //enum grph_color_adjust_option color_adjust_option;
  195. enum dc_color_space c_space;
  196. enum dc_color_depth color_depth; /* clean up to uint32_t */
  197. enum graphics_csc_adjust_type csc_adjust_type;
  198. int32_t adjust_divider;
  199. int32_t grph_cont;
  200. int32_t grph_sat;
  201. int32_t grph_bright;
  202. int32_t grph_hue;
  203. };
  204. /* Underlay related types */
  205. struct hw_adjustment_range {
  206. int32_t hw_default;
  207. int32_t min;
  208. int32_t max;
  209. int32_t step;
  210. uint32_t divider; /* (actually HW range is min/divider; divider !=0) */
  211. };
  212. enum ovl_csc_adjust_item {
  213. OVERLAY_BRIGHTNESS = 0,
  214. OVERLAY_GAMMA,
  215. OVERLAY_CONTRAST,
  216. OVERLAY_SATURATION,
  217. OVERLAY_HUE,
  218. OVERLAY_ALPHA,
  219. OVERLAY_ALPHA_PER_PIX,
  220. OVERLAY_COLOR_TEMPERATURE
  221. };
  222. enum oppbuf_display_segmentation {
  223. OPPBUF_DISPLAY_SEGMENTATION_1_SEGMENT = 0,
  224. OPPBUF_DISPLAY_SEGMENTATION_2_SEGMENT = 1,
  225. OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT = 2,
  226. OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_LEFT = 3,
  227. OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_RIGHT = 4
  228. };
  229. struct oppbuf_params {
  230. uint32_t active_width;
  231. enum oppbuf_display_segmentation mso_segmentation;
  232. uint32_t mso_overlap_pixel_num;
  233. uint32_t pixel_repetition;
  234. };
  235. struct opp_funcs {
  236. /* FORMATTER RELATED */
  237. void (*opp_program_fmt)(
  238. struct output_pixel_processor *opp,
  239. struct bit_depth_reduction_params *fmt_bit_depth,
  240. struct clamping_and_pixel_encoding_params *clamping);
  241. void (*opp_set_dyn_expansion)(
  242. struct output_pixel_processor *opp,
  243. enum dc_color_space color_sp,
  244. enum dc_color_depth color_dpth,
  245. enum signal_type signal);
  246. void (*opp_program_bit_depth_reduction)(
  247. struct output_pixel_processor *opp,
  248. const struct bit_depth_reduction_params *params);
  249. /* underlay related */
  250. void (*opp_get_underlay_adjustment_range)(
  251. struct output_pixel_processor *opp,
  252. enum ovl_csc_adjust_item overlay_adjust_item,
  253. struct hw_adjustment_range *range);
  254. void (*opp_destroy)(struct output_pixel_processor **opp);
  255. void (*opp_program_stereo)(
  256. struct output_pixel_processor *opp,
  257. bool enable,
  258. const struct dc_crtc_timing *timing);
  259. void (*opp_pipe_clock_control)(
  260. struct output_pixel_processor *opp,
  261. bool enable);
  262. };
  263. #endif