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