opp.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 "transform.h"
  29. struct fixed31_32;
  30. struct gamma_parameters;
  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. };
  82. enum wide_gamut_regamma_mode {
  83. /* 0x0 - BITS2:0 Bypass */
  84. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_BYPASS,
  85. /* 0x1 - Fixed curve sRGB 2.4 */
  86. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_SRGB24,
  87. /* 0x2 - Fixed curve xvYCC 2.22 */
  88. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_XYYCC22,
  89. /* 0x3 - Programmable control A */
  90. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_A,
  91. /* 0x4 - Programmable control B */
  92. WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_B,
  93. /* 0x0 - BITS6:4 Bypass */
  94. WIDE_GAMUT_REGAMMA_MODE_OVL_BYPASS,
  95. /* 0x1 - Fixed curve sRGB 2.4 */
  96. WIDE_GAMUT_REGAMMA_MODE_OVL_SRGB24,
  97. /* 0x2 - Fixed curve xvYCC 2.22 */
  98. WIDE_GAMUT_REGAMMA_MODE_OVL_XYYCC22,
  99. /* 0x3 - Programmable control A */
  100. WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_A,
  101. /* 0x4 - Programmable control B */
  102. WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_B
  103. };
  104. struct gamma_pixel {
  105. struct fixed31_32 r;
  106. struct fixed31_32 g;
  107. struct fixed31_32 b;
  108. };
  109. enum channel_name {
  110. CHANNEL_NAME_RED,
  111. CHANNEL_NAME_GREEN,
  112. CHANNEL_NAME_BLUE
  113. };
  114. struct custom_float_format {
  115. uint32_t mantissa_bits;
  116. uint32_t exponenta_bits;
  117. bool sign;
  118. };
  119. struct custom_float_value {
  120. uint32_t mantissa;
  121. uint32_t exponenta;
  122. uint32_t value;
  123. bool negative;
  124. };
  125. struct hw_x_point {
  126. uint32_t custom_float_x;
  127. uint32_t custom_float_x_adjusted;
  128. struct fixed31_32 x;
  129. struct fixed31_32 adjusted_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. enum opp_regamma {
  176. OPP_REGAMMA_BYPASS = 0,
  177. OPP_REGAMMA_SRGB,
  178. OPP_REGAMMA_3_6,
  179. OPP_REGAMMA_USER,
  180. };
  181. struct output_pixel_processor {
  182. struct dc_context *ctx;
  183. uint32_t inst;
  184. const struct opp_funcs *funcs;
  185. };
  186. enum fmt_stereo_action {
  187. FMT_STEREO_ACTION_ENABLE = 0,
  188. FMT_STEREO_ACTION_DISABLE,
  189. FMT_STEREO_ACTION_UPDATE_POLARITY
  190. };
  191. enum graphics_csc_adjust_type {
  192. GRAPHICS_CSC_ADJUST_TYPE_BYPASS = 0,
  193. GRAPHICS_CSC_ADJUST_TYPE_HW, /* without adjustments */
  194. GRAPHICS_CSC_ADJUST_TYPE_SW /*use adjustments */
  195. };
  196. struct default_adjustment {
  197. enum lb_pixel_depth lb_color_depth;
  198. enum dc_color_space out_color_space;
  199. enum dc_color_space in_color_space;
  200. enum dc_color_depth color_depth;
  201. enum pixel_format surface_pixel_format;
  202. enum graphics_csc_adjust_type csc_adjust_type;
  203. bool force_hw_default;
  204. };
  205. enum grph_color_adjust_option {
  206. GRPH_COLOR_MATRIX_HW_DEFAULT = 1,
  207. GRPH_COLOR_MATRIX_SW
  208. };
  209. struct opp_grph_csc_adjustment {
  210. enum grph_color_adjust_option color_adjust_option;
  211. enum dc_color_space c_space;
  212. enum dc_color_depth color_depth; /* clean up to uint32_t */
  213. enum graphics_csc_adjust_type csc_adjust_type;
  214. int32_t adjust_divider;
  215. int32_t grph_cont;
  216. int32_t grph_sat;
  217. int32_t grph_bright;
  218. int32_t grph_hue;
  219. };
  220. struct out_csc_color_matrix {
  221. enum dc_color_space color_space;
  222. uint16_t regval[12];
  223. };
  224. /* Underlay related types */
  225. struct hw_adjustment_range {
  226. int32_t hw_default;
  227. int32_t min;
  228. int32_t max;
  229. int32_t step;
  230. uint32_t divider; /* (actually HW range is min/divider; divider !=0) */
  231. };
  232. enum ovl_csc_adjust_item {
  233. OVERLAY_BRIGHTNESS = 0,
  234. OVERLAY_GAMMA,
  235. OVERLAY_CONTRAST,
  236. OVERLAY_SATURATION,
  237. OVERLAY_HUE,
  238. OVERLAY_ALPHA,
  239. OVERLAY_ALPHA_PER_PIX,
  240. OVERLAY_COLOR_TEMPERATURE
  241. };
  242. struct opp_funcs {
  243. void (*opp_power_on_regamma_lut)(
  244. struct output_pixel_processor *opp,
  245. bool power_on);
  246. bool (*opp_program_regamma_pwl)(
  247. struct output_pixel_processor *opp,
  248. const struct pwl_params *params);
  249. void (*opp_set_regamma_mode)(struct output_pixel_processor *opp,
  250. enum opp_regamma mode);
  251. void (*opp_set_csc_adjustment)(
  252. struct output_pixel_processor *opp,
  253. const struct out_csc_color_matrix *tbl_entry);
  254. void (*opp_set_csc_default)(
  255. struct output_pixel_processor *opp,
  256. const struct default_adjustment *default_adjust);
  257. /* FORMATTER RELATED */
  258. void (*opp_program_fmt)(
  259. struct output_pixel_processor *opp,
  260. struct bit_depth_reduction_params *fmt_bit_depth,
  261. struct clamping_and_pixel_encoding_params *clamping);
  262. void (*opp_set_dyn_expansion)(
  263. struct output_pixel_processor *opp,
  264. enum dc_color_space color_sp,
  265. enum dc_color_depth color_dpth,
  266. enum signal_type signal);
  267. void (*opp_program_bit_depth_reduction)(
  268. struct output_pixel_processor *opp,
  269. const struct bit_depth_reduction_params *params);
  270. /* underlay related */
  271. void (*opp_get_underlay_adjustment_range)(
  272. struct output_pixel_processor *opp,
  273. enum ovl_csc_adjust_item overlay_adjust_item,
  274. struct hw_adjustment_range *range);
  275. void (*opp_destroy)(struct output_pixel_processor **opp);
  276. };
  277. #endif