dc_stream.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. struct dc_stream_state {
  43. struct dc_sink *sink;
  44. struct dc_crtc_timing timing;
  45. struct rect src; /* composition area */
  46. struct rect dst; /* stream addressable area */
  47. struct audio_info audio_info;
  48. struct freesync_context freesync_ctx;
  49. struct dc_hdr_static_metadata hdr_static_metadata;
  50. struct dc_transfer_func *out_transfer_func;
  51. struct colorspace_transform gamut_remap_matrix;
  52. struct csc_transform csc_color_matrix;
  53. enum dc_color_space output_color_space;
  54. enum dc_dither_option dither_option;
  55. enum view_3d_format view_format;
  56. bool ignore_msa_timing_param;
  57. /* TODO: custom INFO packets */
  58. /* TODO: ABM info (DMCU) */
  59. /* TODO: PSR info */
  60. /* TODO: CEA VIC */
  61. /* from core_stream struct */
  62. struct dc_context *ctx;
  63. /* used by DCP and FMT */
  64. struct bit_depth_reduction_params bit_depth_params;
  65. struct clamping_and_pixel_encoding_params clamping;
  66. int phy_pix_clk;
  67. enum signal_type signal;
  68. bool dpms_off;
  69. struct dc_stream_status status;
  70. struct dc_cursor_attributes cursor_attributes;
  71. struct dc_cursor_position cursor_position;
  72. /* from stream struct */
  73. struct kref refcount;
  74. struct crtc_trigger_info triggered_crtc_reset;
  75. /* Computed state bits */
  76. bool mode_changed : 1;
  77. };
  78. struct dc_stream_update {
  79. struct rect src;
  80. struct rect dst;
  81. struct dc_transfer_func *out_transfer_func;
  82. struct dc_hdr_static_metadata *hdr_static_metadata;
  83. };
  84. bool dc_is_stream_unchanged(
  85. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  86. bool dc_is_stream_scaling_unchanged(
  87. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  88. /*
  89. * Set up surface attributes and associate to a stream
  90. * The surfaces parameter is an absolute set of all surface active for the stream.
  91. * If no surfaces are provided, the stream will be blanked; no memory read.
  92. * Any flip related attribute changes must be done through this interface.
  93. *
  94. * After this call:
  95. * Surfaces attributes are programmed and configured to be composed into stream.
  96. * This does not trigger a flip. No surface address is programmed.
  97. */
  98. bool dc_commit_planes_to_stream(
  99. struct dc *dc,
  100. struct dc_plane_state **plane_states,
  101. uint8_t new_plane_count,
  102. struct dc_stream_state *dc_stream,
  103. struct dc_state *state);
  104. void dc_commit_updates_for_stream(struct dc *dc,
  105. struct dc_surface_update *srf_updates,
  106. int surface_count,
  107. struct dc_stream_state *stream,
  108. struct dc_stream_update *stream_update,
  109. struct dc_plane_state **plane_states,
  110. struct dc_state *state);
  111. /*
  112. * Log the current stream state.
  113. */
  114. void dc_stream_log(
  115. const struct dc_stream_state *stream,
  116. struct dal_logger *dc_logger,
  117. enum dc_log_type log_type);
  118. uint8_t dc_get_current_stream_count(struct dc *dc);
  119. struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
  120. /*
  121. * Return the current frame counter.
  122. */
  123. uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
  124. /* TODO: Return parsed values rather than direct register read
  125. * This has a dependency on the caller (amdgpu_get_crtc_scanoutpos)
  126. * being refactored properly to be dce-specific
  127. */
  128. bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
  129. uint32_t *v_blank_start,
  130. uint32_t *v_blank_end,
  131. uint32_t *h_position,
  132. uint32_t *v_position);
  133. enum dc_status dc_add_stream_to_ctx(
  134. struct dc *dc,
  135. struct dc_state *new_ctx,
  136. struct dc_stream_state *stream);
  137. enum dc_status dc_remove_stream_from_ctx(
  138. struct dc *dc,
  139. struct dc_state *new_ctx,
  140. struct dc_stream_state *stream);
  141. bool dc_add_plane_to_context(
  142. const struct dc *dc,
  143. struct dc_stream_state *stream,
  144. struct dc_plane_state *plane_state,
  145. struct dc_state *context);
  146. bool dc_remove_plane_from_context(
  147. const struct dc *dc,
  148. struct dc_stream_state *stream,
  149. struct dc_plane_state *plane_state,
  150. struct dc_state *context);
  151. bool dc_rem_all_planes_for_stream(
  152. const struct dc *dc,
  153. struct dc_stream_state *stream,
  154. struct dc_state *context);
  155. bool dc_add_all_planes_for_stream(
  156. const struct dc *dc,
  157. struct dc_stream_state *stream,
  158. struct dc_plane_state * const *plane_states,
  159. int plane_count,
  160. struct dc_state *context);
  161. enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);
  162. /*
  163. * This function takes a stream and checks if it is guaranteed to be supported.
  164. * Guaranteed means that MAX_COFUNC similar streams are supported.
  165. *
  166. * After this call:
  167. * No hardware is programmed for call. Only validation is done.
  168. */
  169. /*
  170. * Set up streams and links associated to drive sinks
  171. * The streams parameter is an absolute set of all active streams.
  172. *
  173. * After this call:
  174. * Phy, Encoder, Timing Generator are programmed and enabled.
  175. * New streams are enabled with blank stream; no memory read.
  176. */
  177. /*
  178. * Enable stereo when commit_streams is not required,
  179. * for example, frame alternate.
  180. */
  181. bool dc_enable_stereo(
  182. struct dc *dc,
  183. struct dc_state *context,
  184. struct dc_stream_state *streams[],
  185. uint8_t stream_count);
  186. enum surface_update_type dc_check_update_surfaces_for_stream(
  187. struct dc *dc,
  188. struct dc_surface_update *updates,
  189. int surface_count,
  190. struct dc_stream_update *stream_update,
  191. const struct dc_stream_status *stream_status);
  192. /**
  193. * Create a new default stream for the requested sink
  194. */
  195. struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
  196. void dc_stream_retain(struct dc_stream_state *dc_stream);
  197. void dc_stream_release(struct dc_stream_state *dc_stream);
  198. struct dc_stream_status *dc_stream_get_status(
  199. struct dc_stream_state *dc_stream);
  200. /*******************************************************************************
  201. * Cursor interfaces - To manages the cursor within a stream
  202. ******************************************************************************/
  203. /* TODO: Deprecated once we switch to dc_set_cursor_position */
  204. bool dc_stream_set_cursor_attributes(
  205. struct dc_stream_state *stream,
  206. const struct dc_cursor_attributes *attributes);
  207. bool dc_stream_set_cursor_position(
  208. struct dc_stream_state *stream,
  209. const struct dc_cursor_position *position);
  210. bool dc_stream_adjust_vmin_vmax(struct dc *dc,
  211. struct dc_stream_state **stream,
  212. int num_streams,
  213. int vmin,
  214. int vmax);
  215. bool dc_stream_get_crtc_position(struct dc *dc,
  216. struct dc_stream_state **stream,
  217. int num_streams,
  218. unsigned int *v_pos,
  219. unsigned int *nom_v_pos);
  220. void dc_stream_set_static_screen_events(struct dc *dc,
  221. struct dc_stream_state **stream,
  222. int num_streams,
  223. const struct dc_static_screen_events *events);
  224. bool dc_stream_adjust_vmin_vmax(struct dc *dc,
  225. struct dc_stream_state **stream,
  226. int num_streams,
  227. int vmin,
  228. int vmax);
  229. bool dc_stream_get_crtc_position(struct dc *dc,
  230. struct dc_stream_state **stream,
  231. int num_streams,
  232. unsigned int *v_pos,
  233. unsigned int *nom_v_pos);
  234. void dc_stream_set_static_screen_events(struct dc *dc,
  235. struct dc_stream_state **stream,
  236. int num_streams,
  237. const struct dc_static_screen_events *events);
  238. #endif /* DC_STREAM_H_ */