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 struct timing_sync_info { 36 int group_id; 37 int group_size; 38 bool master; 39 }; 40 41 struct dc_stream_status { 42 int primary_otg_inst; 43 int stream_enc_inst; 44 int plane_count; 45 struct timing_sync_info timing_sync_info; 46 struct dc_plane_state *plane_states[MAX_SURFACE_NUM]; 47 }; 48 49 // TODO: References to this needs to be removed.. 50 struct freesync_context { 51 bool dummy; 52 }; 53 54 enum vertical_interrupt_ref_point { 55 START_V_UPDATE = 0, 56 START_V_SYNC, 57 INVALID_POINT 58 59 //For now, only v_update interrupt is used. 60 //START_V_BLANK, 61 //START_V_ACTIVE 62 }; 63 64 struct periodic_interrupt_config { 65 enum vertical_interrupt_ref_point ref_point; 66 int lines_offset; 67 }; 68 69 70 struct dc_stream_state { 71 // sink is deprecated, new code should not reference 72 // this pointer 73 struct dc_sink *sink; 74 75 struct dc_link *link; 76 struct dc_panel_patch sink_patches; 77 union display_content_support content_support; 78 struct dc_crtc_timing timing; 79 struct dc_crtc_timing_adjust adjust; 80 struct dc_info_packet vrr_infopacket; 81 struct dc_info_packet vsc_infopacket; 82 struct dc_info_packet vsp_infopacket; 83 struct dc_info_packet dpsdp_infopacket; 84 85 struct rect src; /* composition area */ 86 struct rect dst; /* stream addressable area */ 87 88 // TODO: References to this needs to be removed.. 89 struct freesync_context freesync_ctx; 90 91 struct audio_info audio_info; 92 93 struct dc_info_packet hdr_static_metadata; 94 PHYSICAL_ADDRESS_LOC dmdata_address; 95 bool use_dynamic_meta; 96 97 struct dc_transfer_func *out_transfer_func; 98 struct colorspace_transform gamut_remap_matrix; 99 struct dc_csc_transform csc_color_matrix; 100 101 enum dc_color_space output_color_space; 102 enum dc_dither_option dither_option; 103 104 enum view_3d_format view_format; 105 106 bool ignore_msa_timing_param; 107 bool converter_disable_audio; 108 uint8_t qs_bit; 109 uint8_t qy_bit; 110 111 /* TODO: custom INFO packets */ 112 /* TODO: ABM info (DMCU) */ 113 /* PSR info */ 114 unsigned char psr_version; 115 /* TODO: CEA VIC */ 116 117 /* DMCU info */ 118 unsigned int abm_level; 119 120 struct periodic_interrupt_config periodic_interrupt0; 121 struct periodic_interrupt_config periodic_interrupt1; 122 123 /* from core_stream struct */ 124 struct dc_context *ctx; 125 126 /* used by DCP and FMT */ 127 struct bit_depth_reduction_params bit_depth_params; 128 struct clamping_and_pixel_encoding_params clamping; 129 130 int phy_pix_clk; 131 enum signal_type signal; 132 bool dpms_off; 133 134 void *dm_stream_context; 135 136 struct dc_cursor_attributes cursor_attributes; 137 struct dc_cursor_position cursor_position; 138 uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode 139 140 /* from stream struct */ 141 struct kref refcount; 142 143 struct crtc_trigger_info triggered_crtc_reset; 144 145 /* Computed state bits */ 146 bool mode_changed : 1; 147 148 /* Output from DC when stream state is committed or altered 149 * DC may only access these values during: 150 * dc_commit_state, dc_commit_state_no_check, dc_commit_streams 151 * values may not change outside of those calls 152 */ 153 struct { 154 // For interrupt management, some hardware instance 155 // offsets need to be exposed to DM 156 uint8_t otg_offset; 157 } out; 158 159 bool apply_edp_fast_boot_optimization; 160 bool apply_seamless_boot_optimization; 161 162 uint32_t stream_id; 163 }; 164 165 struct dc_stream_update { 166 struct rect src; 167 struct rect dst; 168 struct dc_transfer_func *out_transfer_func; 169 struct dc_info_packet *hdr_static_metadata; 170 unsigned int *abm_level; 171 172 struct periodic_interrupt_config *periodic_interrupt0; 173 struct periodic_interrupt_config *periodic_interrupt1; 174 175 struct dc_info_packet *vrr_infopacket; 176 struct dc_info_packet *vsc_infopacket; 177 struct dc_info_packet *vsp_infopacket; 178 179 bool *dpms_off; 180 181 struct colorspace_transform *gamut_remap; 182 enum dc_color_space *output_color_space; 183 enum dc_dither_option *dither_option; 184 185 struct dc_csc_transform *output_csc_transform; 186 187 }; 188 189 bool dc_is_stream_unchanged( 190 struct dc_stream_state *old_stream, struct dc_stream_state *stream); 191 bool dc_is_stream_scaling_unchanged( 192 struct dc_stream_state *old_stream, struct dc_stream_state *stream); 193 194 /* 195 * Set up surface attributes and associate to a stream 196 * The surfaces parameter is an absolute set of all surface active for the stream. 197 * If no surfaces are provided, the stream will be blanked; no memory read. 198 * Any flip related attribute changes must be done through this interface. 199 * 200 * After this call: 201 * Surfaces attributes are programmed and configured to be composed into stream. 202 * This does not trigger a flip. No surface address is programmed. 203 */ 204 205 void dc_commit_updates_for_stream(struct dc *dc, 206 struct dc_surface_update *srf_updates, 207 int surface_count, 208 struct dc_stream_state *stream, 209 struct dc_stream_update *stream_update, 210 struct dc_state *state); 211 /* 212 * Log the current stream state. 213 */ 214 void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream); 215 216 uint8_t dc_get_current_stream_count(struct dc *dc); 217 struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i); 218 219 /* 220 * Return the current frame counter. 221 */ 222 uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream); 223 224 /* 225 * Send dp sdp message. 226 */ 227 bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream, 228 const uint8_t *custom_sdp_message, 229 unsigned int sdp_message_size); 230 231 /* TODO: Return parsed values rather than direct register read 232 * This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos) 233 * being refactored properly to be dce-specific 234 */ 235 bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream, 236 uint32_t *v_blank_start, 237 uint32_t *v_blank_end, 238 uint32_t *h_position, 239 uint32_t *v_position); 240 241 enum dc_status dc_add_stream_to_ctx( 242 struct dc *dc, 243 struct dc_state *new_ctx, 244 struct dc_stream_state *stream); 245 246 enum dc_status dc_remove_stream_from_ctx( 247 struct dc *dc, 248 struct dc_state *new_ctx, 249 struct dc_stream_state *stream); 250 251 252 bool dc_add_plane_to_context( 253 const struct dc *dc, 254 struct dc_stream_state *stream, 255 struct dc_plane_state *plane_state, 256 struct dc_state *context); 257 258 bool dc_remove_plane_from_context( 259 const struct dc *dc, 260 struct dc_stream_state *stream, 261 struct dc_plane_state *plane_state, 262 struct dc_state *context); 263 264 bool dc_rem_all_planes_for_stream( 265 const struct dc *dc, 266 struct dc_stream_state *stream, 267 struct dc_state *context); 268 269 bool dc_add_all_planes_for_stream( 270 const struct dc *dc, 271 struct dc_stream_state *stream, 272 struct dc_plane_state * const *plane_states, 273 int plane_count, 274 struct dc_state *context); 275 276 enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream); 277 278 /* 279 * Set up streams and links associated to drive sinks 280 * The streams parameter is an absolute set of all active streams. 281 * 282 * After this call: 283 * Phy, Encoder, Timing Generator are programmed and enabled. 284 * New streams are enabled with blank stream; no memory read. 285 */ 286 /* 287 * Enable stereo when commit_streams is not required, 288 * for example, frame alternate. 289 */ 290 bool dc_enable_stereo( 291 struct dc *dc, 292 struct dc_state *context, 293 struct dc_stream_state *streams[], 294 uint8_t stream_count); 295 296 297 enum surface_update_type dc_check_update_surfaces_for_stream( 298 struct dc *dc, 299 struct dc_surface_update *updates, 300 int surface_count, 301 struct dc_stream_update *stream_update, 302 const struct dc_stream_status *stream_status); 303 304 /** 305 * Create a new default stream for the requested sink 306 */ 307 struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink); 308 309 struct dc_stream_state *dc_copy_stream(const struct dc_stream_state *stream); 310 311 void update_stream_signal(struct dc_stream_state *stream, struct dc_sink *sink); 312 313 void dc_stream_retain(struct dc_stream_state *dc_stream); 314 void dc_stream_release(struct dc_stream_state *dc_stream); 315 316 struct dc_stream_status *dc_stream_get_status_from_state( 317 struct dc_state *state, 318 struct dc_stream_state *stream); 319 struct dc_stream_status *dc_stream_get_status( 320 struct dc_stream_state *dc_stream); 321 322 /******************************************************************************* 323 * Cursor interfaces - To manages the cursor within a stream 324 ******************************************************************************/ 325 /* TODO: Deprecated once we switch to dc_set_cursor_position */ 326 bool dc_stream_set_cursor_attributes( 327 struct dc_stream_state *stream, 328 const struct dc_cursor_attributes *attributes); 329 330 bool dc_stream_set_cursor_position( 331 struct dc_stream_state *stream, 332 const struct dc_cursor_position *position); 333 334 335 bool dc_stream_adjust_vmin_vmax(struct dc *dc, 336 struct dc_stream_state *stream, 337 struct dc_crtc_timing_adjust *adjust); 338 339 bool dc_stream_get_crtc_position(struct dc *dc, 340 struct dc_stream_state **stream, 341 int num_streams, 342 unsigned int *v_pos, 343 unsigned int *nom_v_pos); 344 345 bool dc_stream_configure_crc(struct dc *dc, 346 struct dc_stream_state *stream, 347 bool enable, 348 bool continuous); 349 350 bool dc_stream_get_crc(struct dc *dc, 351 struct dc_stream_state *stream, 352 uint32_t *r_cr, 353 uint32_t *g_y, 354 uint32_t *b_cb); 355 356 void dc_stream_set_static_screen_events(struct dc *dc, 357 struct dc_stream_state **stream, 358 int num_streams, 359 const struct dc_static_screen_events *events); 360 361 void dc_stream_set_dither_option(struct dc_stream_state *stream, 362 enum dc_dither_option option); 363 364 bool dc_stream_set_gamut_remap(struct dc *dc, 365 const struct dc_stream_state *stream); 366 367 bool dc_stream_program_csc_matrix(struct dc *dc, 368 struct dc_stream_state *stream); 369 370 bool dc_stream_get_crtc_position(struct dc *dc, 371 struct dc_stream_state **stream, 372 int num_streams, 373 unsigned int *v_pos, 374 unsigned int *nom_v_pos); 375 376 #endif /* DC_STREAM_H_ */ 377