dc_stream.h 9.0 KB

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