dc_stream.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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_info_packet hdr_static_metadata;
  52. struct dc_transfer_func *out_transfer_func;
  53. struct colorspace_transform gamut_remap_matrix;
  54. struct dc_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. bool ignore_msa_timing_param;
  59. unsigned long long periodic_fn_vsync_delta;
  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_info_packet *hdr_static_metadata;
  90. unsigned int *abm_level;
  91. unsigned long long *periodic_fn_vsync_delta;
  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. 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. * Set up streams and links associated to drive sinks
  167. * The streams parameter is an absolute set of all active streams.
  168. *
  169. * After this call:
  170. * Phy, Encoder, Timing Generator are programmed and enabled.
  171. * New streams are enabled with blank stream; no memory read.
  172. */
  173. /*
  174. * Enable stereo when commit_streams is not required,
  175. * for example, frame alternate.
  176. */
  177. bool dc_enable_stereo(
  178. struct dc *dc,
  179. struct dc_state *context,
  180. struct dc_stream_state *streams[],
  181. uint8_t stream_count);
  182. enum surface_update_type dc_check_update_surfaces_for_stream(
  183. struct dc *dc,
  184. struct dc_surface_update *updates,
  185. int surface_count,
  186. struct dc_stream_update *stream_update,
  187. const struct dc_stream_status *stream_status);
  188. /**
  189. * Create a new default stream for the requested sink
  190. */
  191. struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
  192. void update_stream_signal(struct dc_stream_state *stream);
  193. void dc_stream_retain(struct dc_stream_state *dc_stream);
  194. void dc_stream_release(struct dc_stream_state *dc_stream);
  195. struct dc_stream_status *dc_stream_get_status(
  196. struct dc_stream_state *dc_stream);
  197. /*******************************************************************************
  198. * Cursor interfaces - To manages the cursor within a stream
  199. ******************************************************************************/
  200. /* TODO: Deprecated once we switch to dc_set_cursor_position */
  201. bool dc_stream_set_cursor_attributes(
  202. struct dc_stream_state *stream,
  203. const struct dc_cursor_attributes *attributes);
  204. bool dc_stream_set_cursor_position(
  205. struct dc_stream_state *stream,
  206. const struct dc_cursor_position *position);
  207. bool dc_stream_adjust_vmin_vmax(struct dc *dc,
  208. struct dc_stream_state **stream,
  209. int num_streams,
  210. int vmin,
  211. int vmax);
  212. bool dc_stream_get_crtc_position(struct dc *dc,
  213. struct dc_stream_state **stream,
  214. int num_streams,
  215. unsigned int *v_pos,
  216. unsigned int *nom_v_pos);
  217. bool dc_stream_configure_crc(struct dc *dc,
  218. struct dc_stream_state *stream,
  219. bool enable,
  220. bool continuous);
  221. bool dc_stream_get_crc(struct dc *dc,
  222. struct dc_stream_state *stream,
  223. uint32_t *r_cr,
  224. uint32_t *g_y,
  225. uint32_t *b_cb);
  226. void dc_stream_set_static_screen_events(struct dc *dc,
  227. struct dc_stream_state **stream,
  228. int num_streams,
  229. const struct dc_static_screen_events *events);
  230. void dc_stream_set_dither_option(struct dc_stream_state *stream,
  231. enum dc_dither_option option);
  232. bool dc_stream_adjust_vmin_vmax(struct dc *dc,
  233. struct dc_stream_state **stream,
  234. int num_streams,
  235. int vmin,
  236. int vmax);
  237. bool dc_stream_get_crtc_position(struct dc *dc,
  238. struct dc_stream_state **stream,
  239. int num_streams,
  240. unsigned int *v_pos,
  241. unsigned int *nom_v_pos);
  242. void dc_stream_set_static_screen_events(struct dc *dc,
  243. struct dc_stream_state **stream,
  244. int num_streams,
  245. const struct dc_static_screen_events *events);
  246. #endif /* DC_STREAM_H_ */