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