dc_stream.h 9.2 KB

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