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