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