dc_stream.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /*
  2. * Copyright 2012-14 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 DC_STREAM_H_
  26. #define DC_STREAM_H_
  27. #include "dc_types.h"
  28. #include "grph_object_defs.h"
  29. /*******************************************************************************
  30. * Stream Interfaces
  31. ******************************************************************************/
  32. struct dc_stream_status {
  33. int primary_otg_inst;
  34. int stream_enc_inst;
  35. int plane_count;
  36. struct dc_plane_state *plane_states[MAX_SURFACE_NUM];
  37. /*
  38. * link this stream passes through
  39. */
  40. struct dc_link *link;
  41. };
  42. // TODO: References to this needs to be removed..
  43. struct freesync_context {
  44. bool dummy;
  45. };
  46. struct dc_stream_state {
  47. struct dc_sink *sink;
  48. struct dc_crtc_timing timing;
  49. struct dc_crtc_timing_adjust adjust;
  50. struct dc_info_packet vrr_infopacket;
  51. struct dc_info_packet vsc_infopacket;
  52. struct rect src; /* composition area */
  53. struct rect dst; /* stream addressable area */
  54. // TODO: References to this needs to be removed..
  55. struct freesync_context freesync_ctx;
  56. struct audio_info audio_info;
  57. struct dc_info_packet hdr_static_metadata;
  58. PHYSICAL_ADDRESS_LOC dmdata_address;
  59. bool use_dynamic_meta;
  60. struct dc_transfer_func *out_transfer_func;
  61. struct colorspace_transform gamut_remap_matrix;
  62. struct dc_csc_transform csc_color_matrix;
  63. enum dc_color_space output_color_space;
  64. enum dc_dither_option dither_option;
  65. enum view_3d_format view_format;
  66. bool ignore_msa_timing_param;
  67. unsigned long long periodic_fn_vsync_delta;
  68. /* TODO: custom INFO packets */
  69. /* TODO: ABM info (DMCU) */
  70. /* PSR info */
  71. unsigned char psr_version;
  72. /* TODO: CEA VIC */
  73. /* DMCU info */
  74. unsigned int abm_level;
  75. unsigned int bl_pwm_level;
  76. /* from core_stream struct */
  77. struct dc_context *ctx;
  78. /* used by DCP and FMT */
  79. struct bit_depth_reduction_params bit_depth_params;
  80. struct clamping_and_pixel_encoding_params clamping;
  81. int phy_pix_clk;
  82. enum signal_type signal;
  83. bool dpms_off;
  84. bool apply_edp_fast_boot_optimization;
  85. struct dc_stream_status status;
  86. struct dc_cursor_attributes cursor_attributes;
  87. struct dc_cursor_position cursor_position;
  88. uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode
  89. /* from stream struct */
  90. struct kref refcount;
  91. struct crtc_trigger_info triggered_crtc_reset;
  92. /* Computed state bits */
  93. bool mode_changed : 1;
  94. };
  95. struct dc_stream_update {
  96. struct rect src;
  97. struct rect dst;
  98. struct dc_transfer_func *out_transfer_func;
  99. struct dc_info_packet *hdr_static_metadata;
  100. unsigned int *abm_level;
  101. unsigned long long *periodic_fn_vsync_delta;
  102. struct dc_crtc_timing_adjust *adjust;
  103. struct dc_info_packet *vrr_infopacket;
  104. struct dc_info_packet *vsc_infopacket;
  105. bool *dpms_off;
  106. struct colorspace_transform *gamut_remap;
  107. enum dc_color_space *output_color_space;
  108. struct dc_csc_transform *output_csc_transform;
  109. };
  110. bool dc_is_stream_unchanged(
  111. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  112. bool dc_is_stream_scaling_unchanged(
  113. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  114. /*
  115. * Set up surface attributes and associate to a stream
  116. * The surfaces parameter is an absolute set of all surface active for the stream.
  117. * If no surfaces are provided, the stream will be blanked; no memory read.
  118. * Any flip related attribute changes must be done through this interface.
  119. *
  120. * After this call:
  121. * Surfaces attributes are programmed and configured to be composed into stream.
  122. * This does not trigger a flip. No surface address is programmed.
  123. */
  124. void dc_commit_updates_for_stream(struct dc *dc,
  125. struct dc_surface_update *srf_updates,
  126. int surface_count,
  127. struct dc_stream_state *stream,
  128. struct dc_stream_update *stream_update,
  129. struct dc_plane_state **plane_states,
  130. struct dc_state *state);
  131. /*
  132. * Log the current stream state.
  133. */
  134. void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream);
  135. uint8_t dc_get_current_stream_count(struct dc *dc);
  136. struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
  137. /*
  138. * Return the current frame counter.
  139. */
  140. uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
  141. /* TODO: Return parsed values rather than direct register read
  142. * This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos)
  143. * being refactored properly to be dce-specific
  144. */
  145. bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
  146. uint32_t *v_blank_start,
  147. uint32_t *v_blank_end,
  148. uint32_t *h_position,
  149. uint32_t *v_position);
  150. enum dc_status dc_add_stream_to_ctx(
  151. struct dc *dc,
  152. struct dc_state *new_ctx,
  153. struct dc_stream_state *stream);
  154. enum dc_status dc_remove_stream_from_ctx(
  155. struct dc *dc,
  156. struct dc_state *new_ctx,
  157. struct dc_stream_state *stream);
  158. bool dc_add_plane_to_context(
  159. const struct dc *dc,
  160. struct dc_stream_state *stream,
  161. struct dc_plane_state *plane_state,
  162. struct dc_state *context);
  163. bool dc_remove_plane_from_context(
  164. const struct dc *dc,
  165. struct dc_stream_state *stream,
  166. struct dc_plane_state *plane_state,
  167. struct dc_state *context);
  168. bool dc_rem_all_planes_for_stream(
  169. const struct dc *dc,
  170. struct dc_stream_state *stream,
  171. struct dc_state *context);
  172. bool dc_add_all_planes_for_stream(
  173. const struct dc *dc,
  174. struct dc_stream_state *stream,
  175. struct dc_plane_state * const *plane_states,
  176. int plane_count,
  177. struct dc_state *context);
  178. enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);
  179. /*
  180. * Set up streams and links associated to drive sinks
  181. * The streams parameter is an absolute set of all active streams.
  182. *
  183. * After this call:
  184. * Phy, Encoder, Timing Generator are programmed and enabled.
  185. * New streams are enabled with blank stream; no memory read.
  186. */
  187. /*
  188. * Enable stereo when commit_streams is not required,
  189. * for example, frame alternate.
  190. */
  191. bool dc_enable_stereo(
  192. struct dc *dc,
  193. struct dc_state *context,
  194. struct dc_stream_state *streams[],
  195. uint8_t stream_count);
  196. enum surface_update_type dc_check_update_surfaces_for_stream(
  197. struct dc *dc,
  198. struct dc_surface_update *updates,
  199. int surface_count,
  200. struct dc_stream_update *stream_update,
  201. const struct dc_stream_status *stream_status);
  202. /**
  203. * Create a new default stream for the requested sink
  204. */
  205. struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
  206. void update_stream_signal(struct dc_stream_state *stream);
  207. void dc_stream_retain(struct dc_stream_state *dc_stream);
  208. void dc_stream_release(struct dc_stream_state *dc_stream);
  209. struct dc_stream_status *dc_stream_get_status(
  210. struct dc_stream_state *dc_stream);
  211. /*******************************************************************************
  212. * Cursor interfaces - To manages the cursor within a stream
  213. ******************************************************************************/
  214. /* TODO: Deprecated once we switch to dc_set_cursor_position */
  215. bool dc_stream_set_cursor_attributes(
  216. struct dc_stream_state *stream,
  217. const struct dc_cursor_attributes *attributes);
  218. bool dc_stream_set_cursor_position(
  219. struct dc_stream_state *stream,
  220. const struct dc_cursor_position *position);
  221. bool dc_stream_adjust_vmin_vmax(struct dc *dc,
  222. struct dc_stream_state *stream,
  223. struct dc_crtc_timing_adjust *adjust);
  224. bool dc_stream_get_crtc_position(struct dc *dc,
  225. struct dc_stream_state **stream,
  226. int num_streams,
  227. unsigned int *v_pos,
  228. unsigned int *nom_v_pos);
  229. bool dc_stream_configure_crc(struct dc *dc,
  230. struct dc_stream_state *stream,
  231. bool enable,
  232. bool continuous);
  233. bool dc_stream_get_crc(struct dc *dc,
  234. struct dc_stream_state *stream,
  235. uint32_t *r_cr,
  236. uint32_t *g_y,
  237. uint32_t *b_cb);
  238. void dc_stream_set_static_screen_events(struct dc *dc,
  239. struct dc_stream_state **stream,
  240. int num_streams,
  241. const struct dc_static_screen_events *events);
  242. void dc_stream_set_dither_option(struct dc_stream_state *stream,
  243. enum dc_dither_option option);
  244. bool dc_stream_set_gamut_remap(struct dc *dc,
  245. const struct dc_stream_state *stream);
  246. bool dc_stream_program_csc_matrix(struct dc *dc,
  247. struct dc_stream_state *stream);
  248. bool dc_stream_get_crtc_position(struct dc *dc,
  249. struct dc_stream_state **stream,
  250. int num_streams,
  251. unsigned int *v_pos,
  252. unsigned int *nom_v_pos);
  253. #endif /* DC_STREAM_H_ */