1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2012-14 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev * Authors: AMD 23*b843c749SSergey Zigachev * 24*b843c749SSergey Zigachev */ 25*b843c749SSergey Zigachev 26*b843c749SSergey Zigachev #ifndef DC_STREAM_H_ 27*b843c749SSergey Zigachev #define DC_STREAM_H_ 28*b843c749SSergey Zigachev 29*b843c749SSergey Zigachev #include "dc_types.h" 30*b843c749SSergey Zigachev #include "grph_object_defs.h" 31*b843c749SSergey Zigachev 32*b843c749SSergey Zigachev /******************************************************************************* 33*b843c749SSergey Zigachev * Stream Interfaces 34*b843c749SSergey Zigachev ******************************************************************************/ 35*b843c749SSergey Zigachev 36*b843c749SSergey Zigachev struct dc_stream_status { 37*b843c749SSergey Zigachev int primary_otg_inst; 38*b843c749SSergey Zigachev int stream_enc_inst; 39*b843c749SSergey Zigachev int plane_count; 40*b843c749SSergey Zigachev struct dc_plane_state *plane_states[MAX_SURFACE_NUM]; 41*b843c749SSergey Zigachev 42*b843c749SSergey Zigachev /* 43*b843c749SSergey Zigachev * link this stream passes through 44*b843c749SSergey Zigachev */ 45*b843c749SSergey Zigachev struct dc_link *link; 46*b843c749SSergey Zigachev }; 47*b843c749SSergey Zigachev 48*b843c749SSergey Zigachev struct dc_stream_state { 49*b843c749SSergey Zigachev struct dc_sink *sink; 50*b843c749SSergey Zigachev struct dc_crtc_timing timing; 51*b843c749SSergey Zigachev struct dc_crtc_timing_adjust timing_adjust; 52*b843c749SSergey Zigachev struct vrr_params vrr_params; 53*b843c749SSergey Zigachev 54*b843c749SSergey Zigachev struct rect src; /* composition area */ 55*b843c749SSergey Zigachev struct rect dst; /* stream addressable area */ 56*b843c749SSergey Zigachev 57*b843c749SSergey Zigachev struct audio_info audio_info; 58*b843c749SSergey Zigachev 59*b843c749SSergey Zigachev struct freesync_context freesync_ctx; 60*b843c749SSergey Zigachev 61*b843c749SSergey Zigachev struct dc_info_packet hdr_static_metadata; 62*b843c749SSergey Zigachev PHYSICAL_ADDRESS_LOC dmdata_address; 63*b843c749SSergey Zigachev bool use_dynamic_meta; 64*b843c749SSergey Zigachev 65*b843c749SSergey Zigachev struct dc_transfer_func *out_transfer_func; 66*b843c749SSergey Zigachev struct colorspace_transform gamut_remap_matrix; 67*b843c749SSergey Zigachev struct dc_csc_transform csc_color_matrix; 68*b843c749SSergey Zigachev 69*b843c749SSergey Zigachev enum dc_color_space output_color_space; 70*b843c749SSergey Zigachev enum dc_dither_option dither_option; 71*b843c749SSergey Zigachev 72*b843c749SSergey Zigachev enum view_3d_format view_format; 73*b843c749SSergey Zigachev 74*b843c749SSergey Zigachev bool ignore_msa_timing_param; 75*b843c749SSergey Zigachev 76*b843c749SSergey Zigachev unsigned long long periodic_fn_vsync_delta; 77*b843c749SSergey Zigachev 78*b843c749SSergey Zigachev /* TODO: custom INFO packets */ 79*b843c749SSergey Zigachev /* TODO: ABM info (DMCU) */ 80*b843c749SSergey Zigachev /* PSR info */ 81*b843c749SSergey Zigachev unsigned char psr_version; 82*b843c749SSergey Zigachev /* TODO: CEA VIC */ 83*b843c749SSergey Zigachev 84*b843c749SSergey Zigachev /* DMCU info */ 85*b843c749SSergey Zigachev unsigned int abm_level; 86*b843c749SSergey Zigachev unsigned int bl_pwm_level; 87*b843c749SSergey Zigachev 88*b843c749SSergey Zigachev /* from core_stream struct */ 89*b843c749SSergey Zigachev struct dc_context *ctx; 90*b843c749SSergey Zigachev 91*b843c749SSergey Zigachev /* used by DCP and FMT */ 92*b843c749SSergey Zigachev struct bit_depth_reduction_params bit_depth_params; 93*b843c749SSergey Zigachev struct clamping_and_pixel_encoding_params clamping; 94*b843c749SSergey Zigachev 95*b843c749SSergey Zigachev int phy_pix_clk; 96*b843c749SSergey Zigachev enum signal_type signal; 97*b843c749SSergey Zigachev bool dpms_off; 98*b843c749SSergey Zigachev 99*b843c749SSergey Zigachev struct dc_stream_status status; 100*b843c749SSergey Zigachev 101*b843c749SSergey Zigachev struct dc_cursor_attributes cursor_attributes; 102*b843c749SSergey Zigachev struct dc_cursor_position cursor_position; 103*b843c749SSergey Zigachev uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode 104*b843c749SSergey Zigachev 105*b843c749SSergey Zigachev /* from stream struct */ 106*b843c749SSergey Zigachev struct kref refcount; 107*b843c749SSergey Zigachev 108*b843c749SSergey Zigachev struct crtc_trigger_info triggered_crtc_reset; 109*b843c749SSergey Zigachev 110*b843c749SSergey Zigachev /* Computed state bits */ 111*b843c749SSergey Zigachev bool mode_changed : 1; 112*b843c749SSergey Zigachev 113*b843c749SSergey Zigachev }; 114*b843c749SSergey Zigachev 115*b843c749SSergey Zigachev struct dc_stream_update { 116*b843c749SSergey Zigachev struct rect src; 117*b843c749SSergey Zigachev struct rect dst; 118*b843c749SSergey Zigachev struct dc_transfer_func *out_transfer_func; 119*b843c749SSergey Zigachev struct dc_info_packet *hdr_static_metadata; 120*b843c749SSergey Zigachev unsigned int *abm_level; 121*b843c749SSergey Zigachev 122*b843c749SSergey Zigachev unsigned long long *periodic_fn_vsync_delta; 123*b843c749SSergey Zigachev }; 124*b843c749SSergey Zigachev 125*b843c749SSergey Zigachev bool dc_is_stream_unchanged( 126*b843c749SSergey Zigachev struct dc_stream_state *old_stream, struct dc_stream_state *stream); 127*b843c749SSergey Zigachev bool dc_is_stream_scaling_unchanged( 128*b843c749SSergey Zigachev struct dc_stream_state *old_stream, struct dc_stream_state *stream); 129*b843c749SSergey Zigachev 130*b843c749SSergey Zigachev /* 131*b843c749SSergey Zigachev * Set up surface attributes and associate to a stream 132*b843c749SSergey Zigachev * The surfaces parameter is an absolute set of all surface active for the stream. 133*b843c749SSergey Zigachev * If no surfaces are provided, the stream will be blanked; no memory read. 134*b843c749SSergey Zigachev * Any flip related attribute changes must be done through this interface. 135*b843c749SSergey Zigachev * 136*b843c749SSergey Zigachev * After this call: 137*b843c749SSergey Zigachev * Surfaces attributes are programmed and configured to be composed into stream. 138*b843c749SSergey Zigachev * This does not trigger a flip. No surface address is programmed. 139*b843c749SSergey Zigachev */ 140*b843c749SSergey Zigachev 141*b843c749SSergey Zigachev void dc_commit_updates_for_stream(struct dc *dc, 142*b843c749SSergey Zigachev struct dc_surface_update *srf_updates, 143*b843c749SSergey Zigachev int surface_count, 144*b843c749SSergey Zigachev struct dc_stream_state *stream, 145*b843c749SSergey Zigachev struct dc_stream_update *stream_update, 146*b843c749SSergey Zigachev struct dc_plane_state **plane_states, 147*b843c749SSergey Zigachev struct dc_state *state); 148*b843c749SSergey Zigachev /* 149*b843c749SSergey Zigachev * Log the current stream state. 150*b843c749SSergey Zigachev */ 151*b843c749SSergey Zigachev void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream); 152*b843c749SSergey Zigachev 153*b843c749SSergey Zigachev uint8_t dc_get_current_stream_count(struct dc *dc); 154*b843c749SSergey Zigachev struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i); 155*b843c749SSergey Zigachev 156*b843c749SSergey Zigachev /* 157*b843c749SSergey Zigachev * Return the current frame counter. 158*b843c749SSergey Zigachev */ 159*b843c749SSergey Zigachev uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream); 160*b843c749SSergey Zigachev 161*b843c749SSergey Zigachev /* TODO: Return parsed values rather than direct register read 162*b843c749SSergey Zigachev * This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos) 163*b843c749SSergey Zigachev * being refactored properly to be dce-specific 164*b843c749SSergey Zigachev */ 165*b843c749SSergey Zigachev bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream, 166*b843c749SSergey Zigachev uint32_t *v_blank_start, 167*b843c749SSergey Zigachev uint32_t *v_blank_end, 168*b843c749SSergey Zigachev uint32_t *h_position, 169*b843c749SSergey Zigachev uint32_t *v_position); 170*b843c749SSergey Zigachev 171*b843c749SSergey Zigachev enum dc_status dc_add_stream_to_ctx( 172*b843c749SSergey Zigachev struct dc *dc, 173*b843c749SSergey Zigachev struct dc_state *new_ctx, 174*b843c749SSergey Zigachev struct dc_stream_state *stream); 175*b843c749SSergey Zigachev 176*b843c749SSergey Zigachev enum dc_status dc_remove_stream_from_ctx( 177*b843c749SSergey Zigachev struct dc *dc, 178*b843c749SSergey Zigachev struct dc_state *new_ctx, 179*b843c749SSergey Zigachev struct dc_stream_state *stream); 180*b843c749SSergey Zigachev 181*b843c749SSergey Zigachev 182*b843c749SSergey Zigachev bool dc_add_plane_to_context( 183*b843c749SSergey Zigachev const struct dc *dc, 184*b843c749SSergey Zigachev struct dc_stream_state *stream, 185*b843c749SSergey Zigachev struct dc_plane_state *plane_state, 186*b843c749SSergey Zigachev struct dc_state *context); 187*b843c749SSergey Zigachev 188*b843c749SSergey Zigachev bool dc_remove_plane_from_context( 189*b843c749SSergey Zigachev const struct dc *dc, 190*b843c749SSergey Zigachev struct dc_stream_state *stream, 191*b843c749SSergey Zigachev struct dc_plane_state *plane_state, 192*b843c749SSergey Zigachev struct dc_state *context); 193*b843c749SSergey Zigachev 194*b843c749SSergey Zigachev bool dc_rem_all_planes_for_stream( 195*b843c749SSergey Zigachev const struct dc *dc, 196*b843c749SSergey Zigachev struct dc_stream_state *stream, 197*b843c749SSergey Zigachev struct dc_state *context); 198*b843c749SSergey Zigachev 199*b843c749SSergey Zigachev bool dc_add_all_planes_for_stream( 200*b843c749SSergey Zigachev const struct dc *dc, 201*b843c749SSergey Zigachev struct dc_stream_state *stream, 202*b843c749SSergey Zigachev struct dc_plane_state * const *plane_states, 203*b843c749SSergey Zigachev int plane_count, 204*b843c749SSergey Zigachev struct dc_state *context); 205*b843c749SSergey Zigachev 206*b843c749SSergey Zigachev enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream); 207*b843c749SSergey Zigachev 208*b843c749SSergey Zigachev /* 209*b843c749SSergey Zigachev * Set up streams and links associated to drive sinks 210*b843c749SSergey Zigachev * The streams parameter is an absolute set of all active streams. 211*b843c749SSergey Zigachev * 212*b843c749SSergey Zigachev * After this call: 213*b843c749SSergey Zigachev * Phy, Encoder, Timing Generator are programmed and enabled. 214*b843c749SSergey Zigachev * New streams are enabled with blank stream; no memory read. 215*b843c749SSergey Zigachev */ 216*b843c749SSergey Zigachev /* 217*b843c749SSergey Zigachev * Enable stereo when commit_streams is not required, 218*b843c749SSergey Zigachev * for example, frame alternate. 219*b843c749SSergey Zigachev */ 220*b843c749SSergey Zigachev bool dc_enable_stereo( 221*b843c749SSergey Zigachev struct dc *dc, 222*b843c749SSergey Zigachev struct dc_state *context, 223*b843c749SSergey Zigachev struct dc_stream_state *streams[], 224*b843c749SSergey Zigachev uint8_t stream_count); 225*b843c749SSergey Zigachev 226*b843c749SSergey Zigachev 227*b843c749SSergey Zigachev enum surface_update_type dc_check_update_surfaces_for_stream( 228*b843c749SSergey Zigachev struct dc *dc, 229*b843c749SSergey Zigachev struct dc_surface_update *updates, 230*b843c749SSergey Zigachev int surface_count, 231*b843c749SSergey Zigachev struct dc_stream_update *stream_update, 232*b843c749SSergey Zigachev const struct dc_stream_status *stream_status); 233*b843c749SSergey Zigachev 234*b843c749SSergey Zigachev /** 235*b843c749SSergey Zigachev * Create a new default stream for the requested sink 236*b843c749SSergey Zigachev */ 237*b843c749SSergey Zigachev struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink); 238*b843c749SSergey Zigachev 239*b843c749SSergey Zigachev void update_stream_signal(struct dc_stream_state *stream); 240*b843c749SSergey Zigachev 241*b843c749SSergey Zigachev void dc_stream_retain(struct dc_stream_state *dc_stream); 242*b843c749SSergey Zigachev void dc_stream_release(struct dc_stream_state *dc_stream); 243*b843c749SSergey Zigachev 244*b843c749SSergey Zigachev struct dc_stream_status *dc_stream_get_status( 245*b843c749SSergey Zigachev struct dc_stream_state *dc_stream); 246*b843c749SSergey Zigachev 247*b843c749SSergey Zigachev /******************************************************************************* 248*b843c749SSergey Zigachev * Cursor interfaces - To manages the cursor within a stream 249*b843c749SSergey Zigachev ******************************************************************************/ 250*b843c749SSergey Zigachev /* TODO: Deprecated once we switch to dc_set_cursor_position */ 251*b843c749SSergey Zigachev bool dc_stream_set_cursor_attributes( 252*b843c749SSergey Zigachev struct dc_stream_state *stream, 253*b843c749SSergey Zigachev const struct dc_cursor_attributes *attributes); 254*b843c749SSergey Zigachev 255*b843c749SSergey Zigachev bool dc_stream_set_cursor_position( 256*b843c749SSergey Zigachev struct dc_stream_state *stream, 257*b843c749SSergey Zigachev const struct dc_cursor_position *position); 258*b843c749SSergey Zigachev 259*b843c749SSergey Zigachev 260*b843c749SSergey Zigachev bool dc_stream_adjust_vmin_vmax(struct dc *dc, 261*b843c749SSergey Zigachev struct dc_stream_state **stream, 262*b843c749SSergey Zigachev int num_streams, 263*b843c749SSergey Zigachev int vmin, 264*b843c749SSergey Zigachev int vmax); 265*b843c749SSergey Zigachev 266*b843c749SSergey Zigachev bool dc_stream_get_crtc_position(struct dc *dc, 267*b843c749SSergey Zigachev struct dc_stream_state **stream, 268*b843c749SSergey Zigachev int num_streams, 269*b843c749SSergey Zigachev unsigned int *v_pos, 270*b843c749SSergey Zigachev unsigned int *nom_v_pos); 271*b843c749SSergey Zigachev 272*b843c749SSergey Zigachev bool dc_stream_configure_crc(struct dc *dc, 273*b843c749SSergey Zigachev struct dc_stream_state *stream, 274*b843c749SSergey Zigachev bool enable, 275*b843c749SSergey Zigachev bool continuous); 276*b843c749SSergey Zigachev 277*b843c749SSergey Zigachev bool dc_stream_get_crc(struct dc *dc, 278*b843c749SSergey Zigachev struct dc_stream_state *stream, 279*b843c749SSergey Zigachev uint32_t *r_cr, 280*b843c749SSergey Zigachev uint32_t *g_y, 281*b843c749SSergey Zigachev uint32_t *b_cb); 282*b843c749SSergey Zigachev 283*b843c749SSergey Zigachev void dc_stream_set_static_screen_events(struct dc *dc, 284*b843c749SSergey Zigachev struct dc_stream_state **stream, 285*b843c749SSergey Zigachev int num_streams, 286*b843c749SSergey Zigachev const struct dc_static_screen_events *events); 287*b843c749SSergey Zigachev 288*b843c749SSergey Zigachev void dc_stream_set_dither_option(struct dc_stream_state *stream, 289*b843c749SSergey Zigachev enum dc_dither_option option); 290*b843c749SSergey Zigachev 291*b843c749SSergey Zigachev #endif /* DC_STREAM_H_ */ 292