opp.h 8.4 KB

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