dc_stream.h 8.4 KB

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