Path: blob/master/drivers/gpu/drm/amd/display/dc/dc_stream.h
26535 views
/*1* Copyright 2012-14 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21* Authors: AMD22*23*/2425#ifndef DC_STREAM_H_26#define DC_STREAM_H_2728#include "dc_types.h"29#include "grph_object_defs.h"3031/*******************************************************************************32* Stream Interfaces33******************************************************************************/34struct timing_sync_info {35int group_id;36int group_size;37bool master;38};3940struct mall_stream_config {41/* MALL stream config to indicate if the stream is phantom or not.42* We will use a phantom stream to indicate that the pipe is phantom.43*/44enum mall_stream_type type;45struct dc_stream_state *paired_stream; // master / slave stream46bool subvp_limit_cursor_size; /* stream has/is using subvp limiting hw cursor support */47bool cursor_size_limit_subvp; /* stream is using hw cursor config preventing subvp */48};4950struct dc_stream_status {51int primary_otg_inst;52int stream_enc_inst;5354/**55* @plane_count: Total of planes attached to a single stream56*/57int plane_count;58int audio_inst;59struct timing_sync_info timing_sync_info;60struct dc_plane_state *plane_states[MAX_SURFACES];61bool is_abm_supported;62struct mall_stream_config mall_stream_config;63bool fpo_in_use;64};6566enum hubp_dmdata_mode {67DMDATA_SW_MODE,68DMDATA_HW_MODE69};7071struct dc_dmdata_attributes {72/* Specifies whether dynamic meta data will be updated by software73* or has to be fetched by hardware (DMA mode)74*/75enum hubp_dmdata_mode dmdata_mode;76/* Specifies if current dynamic meta data is to be used only for the current frame */77bool dmdata_repeat;78/* Specifies the size of Dynamic Metadata surface in byte. Size of 0 means no Dynamic metadata is fetched */79uint32_t dmdata_size;80/* Specifies if a new dynamic meta data should be fetched for an upcoming frame */81bool dmdata_updated;82/* If hardware mode is used, the base address where DMDATA surface is located */83PHYSICAL_ADDRESS_LOC address;84/* Specifies whether QOS level will be provided by TTU or it will come from DMDATA_QOS_LEVEL */85bool dmdata_qos_mode;86/* If qos_mode = 1, this is the QOS value to be used: */87uint32_t dmdata_qos_level;88/* Specifies the value in unit of REFCLK cycles to be added to the89* current time to produce the Amortized deadline for Dynamic Metadata chunk request90*/91uint32_t dmdata_dl_delta;92/* An unbounded array of uint32s, represents software dmdata to be loaded */93uint32_t *dmdata_sw_data;94};9596struct dc_writeback_info {97bool wb_enabled;98int dwb_pipe_inst;99struct dc_dwb_params dwb_params;100struct mcif_buf_params mcif_buf_params;101struct mcif_warmup_params mcif_warmup_params;102/* the plane that is the input to TOP_MUX for MPCC that is the DWB source */103struct dc_plane_state *writeback_source_plane;104/* source MPCC instance. for use by internally by dc */105int mpcc_inst;106};107108struct dc_writeback_update {109unsigned int num_wb_info;110struct dc_writeback_info writeback_info[MAX_DWB_PIPES];111};112113enum vertical_interrupt_ref_point {114START_V_UPDATE = 0,115START_V_SYNC,116INVALID_POINT117118//For now, only v_update interrupt is used.119//START_V_BLANK,120//START_V_ACTIVE121};122123struct periodic_interrupt_config {124enum vertical_interrupt_ref_point ref_point;125int lines_offset;126};127128struct dc_mst_stream_bw_update {129bool is_increase; // is bandwidth reduced or increased130uint32_t mst_stream_bw; // new mst bandwidth in kbps131};132133union stream_update_flags {134struct {135uint32_t scaling:1;136uint32_t out_tf:1;137uint32_t out_csc:1;138uint32_t abm_level:1;139uint32_t dpms_off:1;140uint32_t gamut_remap:1;141uint32_t wb_update:1;142uint32_t dsc_changed : 1;143uint32_t mst_bw : 1;144uint32_t crtc_timing_adjust : 1;145uint32_t fams_changed : 1;146uint32_t scaler_sharpener : 1;147uint32_t sharpening_required : 1;148} bits;149150uint32_t raw;151};152153struct test_pattern {154enum dp_test_pattern type;155enum dp_test_pattern_color_space color_space;156struct link_training_settings const *p_link_settings;157unsigned char const *p_custom_pattern;158unsigned int cust_pattern_size;159};160161#define SUBVP_DRR_MARGIN_US 100 // 100us for DRR margin (SubVP + DRR)162163struct dc_stream_debug_options {164char force_odm_combine_segments;165/*166* When force_odm_combine_segments is non zero, allow dc to167* temporarily transition to ODM bypass when minimal transition state168* is required to prevent visual glitches showing on the screen169*/170char allow_transition_for_forced_odm;171};172173#define LUMINANCE_DATA_TABLE_SIZE 10174175struct luminance_data {176bool is_valid;177int refresh_rate_hz[LUMINANCE_DATA_TABLE_SIZE];178int luminance_millinits[LUMINANCE_DATA_TABLE_SIZE];179int flicker_criteria_milli_nits_GAMING;180int flicker_criteria_milli_nits_STATIC;181int nominal_refresh_rate;182int dm_max_decrease_from_nominal;183};184185struct dc_stream_state {186// sink is deprecated, new code should not reference187// this pointer188struct dc_sink *sink;189190struct dc_link *link;191/* For dynamic link encoder assignment, update the link encoder assigned to192* a stream via the volatile dc_state rather than the static dc_link.193*/194struct link_encoder *link_enc;195struct dc_stream_debug_options debug;196struct dc_panel_patch sink_patches;197struct dc_crtc_timing timing;198struct dc_crtc_timing_adjust adjust;199struct dc_info_packet vrr_infopacket;200struct dc_info_packet vsc_infopacket;201struct dc_info_packet vsp_infopacket;202struct dc_info_packet hfvsif_infopacket;203struct dc_info_packet vtem_infopacket;204struct dc_info_packet adaptive_sync_infopacket;205uint8_t dsc_packed_pps[128];206struct rect src; /* composition area */207struct rect dst; /* stream addressable area */208209struct audio_info audio_info;210211struct dc_info_packet hdr_static_metadata;212PHYSICAL_ADDRESS_LOC dmdata_address;213bool use_dynamic_meta;214215struct dc_transfer_func out_transfer_func;216struct colorspace_transform gamut_remap_matrix;217struct dc_csc_transform csc_color_matrix;218219enum dc_color_space output_color_space;220enum display_content_type content_type;221enum dc_dither_option dither_option;222223enum view_3d_format view_format;224225bool use_vsc_sdp_for_colorimetry;226bool ignore_msa_timing_param;227228/**229* @allow_freesync:230*231* It say if Freesync is enabled or not.232*/233bool allow_freesync;234235/**236* @vrr_active_variable:237*238* It describes if VRR is in use.239*/240bool vrr_active_variable;241bool freesync_on_desktop;242bool vrr_active_fixed;243244bool converter_disable_audio;245uint8_t qs_bit;246uint8_t qy_bit;247248/* TODO: custom INFO packets */249/* TODO: ABM info (DMCU) */250/* TODO: CEA VIC */251252/* DMCU info */253unsigned int abm_level;254255struct periodic_interrupt_config periodic_interrupt;256257/* from core_stream struct */258struct dc_context *ctx;259260/* used by DCP and FMT */261struct bit_depth_reduction_params bit_depth_params;262struct clamping_and_pixel_encoding_params clamping;263264int phy_pix_clk;265enum signal_type signal;266bool dpms_off;267268void *dm_stream_context;269270struct dc_cursor_attributes cursor_attributes;271struct dc_cursor_position cursor_position;272bool hw_cursor_req;273274uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode275276/* from stream struct */277struct kref refcount;278279struct crtc_trigger_info triggered_crtc_reset;280281/* writeback */282unsigned int num_wb_info;283struct dc_writeback_info writeback_info[MAX_DWB_PIPES];284const struct dc_transfer_func *func_shaper;285const struct dc_3dlut *lut3d_func;286/* Computed state bits */287bool mode_changed : 1;288289/* Output from DC when stream state is committed or altered290* DC may only access these values during:291* dc_commit_state, dc_commit_state_no_check, dc_commit_streams292* values may not change outside of those calls293*/294struct {295// For interrupt management, some hardware instance296// offsets need to be exposed to DM297uint8_t otg_offset;298} out;299300bool apply_edp_fast_boot_optimization;301bool apply_seamless_boot_optimization;302uint32_t apply_boot_odm_mode;303304uint32_t stream_id;305306struct test_pattern test_pattern;307union stream_update_flags update_flags;308309bool has_non_synchronizable_pclk;310bool vblank_synchronized;311bool is_phantom;312313struct luminance_data lumin_data;314bool scaler_sharpener_update;315bool sharpening_required;316};317318#define ABM_LEVEL_IMMEDIATE_DISABLE 255319320struct dc_stream_update {321struct dc_stream_state *stream;322323struct rect src;324struct rect dst;325struct dc_transfer_func *out_transfer_func;326struct dc_info_packet *hdr_static_metadata;327unsigned int *abm_level;328329struct periodic_interrupt_config *periodic_interrupt;330331struct dc_info_packet *vrr_infopacket;332struct dc_info_packet *vsc_infopacket;333struct dc_info_packet *vsp_infopacket;334struct dc_info_packet *hfvsif_infopacket;335struct dc_info_packet *vtem_infopacket;336struct dc_info_packet *adaptive_sync_infopacket;337bool *dpms_off;338bool integer_scaling_update;339bool *allow_freesync;340bool *vrr_active_variable;341bool *vrr_active_fixed;342343struct colorspace_transform *gamut_remap;344enum dc_color_space *output_color_space;345enum dc_dither_option *dither_option;346347struct dc_csc_transform *output_csc_transform;348349struct dc_writeback_update *wb_update;350struct dc_dsc_config *dsc_config;351struct dc_mst_stream_bw_update *mst_bw_update;352struct dc_transfer_func *func_shaper;353struct dc_3dlut *lut3d_func;354355struct test_pattern *pending_test_pattern;356struct dc_crtc_timing_adjust *crtc_timing_adjust;357358struct dc_cursor_attributes *cursor_attributes;359struct dc_cursor_position *cursor_position;360bool *hw_cursor_req;361bool *scaler_sharpener_update;362bool *sharpening_required;363};364365bool dc_is_stream_unchanged(366struct dc_stream_state *old_stream, struct dc_stream_state *stream);367bool dc_is_stream_scaling_unchanged(368struct dc_stream_state *old_stream, struct dc_stream_state *stream);369370/*371* Setup stream attributes if no stream updates are provided372* there will be no impact on the stream parameters373*374* Set up surface attributes and associate to a stream375* The surfaces parameter is an absolute set of all surface active for the stream.376* If no surfaces are provided, the stream will be blanked; no memory read.377* Any flip related attribute changes must be done through this interface.378*379* After this call:380* Surfaces attributes are programmed and configured to be composed into stream.381* This does not trigger a flip. No surface address is programmed.382*383*/384bool dc_update_planes_and_stream(struct dc *dc,385struct dc_surface_update *surface_updates, int surface_count,386struct dc_stream_state *dc_stream,387struct dc_stream_update *stream_update);388389/*390* Set up surface attributes and associate to a stream391* The surfaces parameter is an absolute set of all surface active for the stream.392* If no surfaces are provided, the stream will be blanked; no memory read.393* Any flip related attribute changes must be done through this interface.394*395* After this call:396* Surfaces attributes are programmed and configured to be composed into stream.397* This does not trigger a flip. No surface address is programmed.398*/399void dc_commit_updates_for_stream(struct dc *dc,400struct dc_surface_update *srf_updates,401int surface_count,402struct dc_stream_state *stream,403struct dc_stream_update *stream_update,404struct dc_state *state);405/*406* Log the current stream state.407*/408void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream);409410uint8_t dc_get_current_stream_count(struct dc *dc);411struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);412413/*414* Return the current frame counter.415*/416uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);417418/*419* Send dp sdp message.420*/421bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream,422const uint8_t *custom_sdp_message,423unsigned int sdp_message_size);424425/* TODO: Return parsed values rather than direct register read426* This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos)427* being refactored properly to be dce-specific428*/429bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,430uint32_t *v_blank_start,431uint32_t *v_blank_end,432uint32_t *h_position,433uint32_t *v_position);434435bool dc_stream_add_writeback(struct dc *dc,436struct dc_stream_state *stream,437struct dc_writeback_info *wb_info);438439bool dc_stream_fc_disable_writeback(struct dc *dc,440struct dc_stream_state *stream,441uint32_t dwb_pipe_inst);442443bool dc_stream_remove_writeback(struct dc *dc,444struct dc_stream_state *stream,445uint32_t dwb_pipe_inst);446447enum dc_status dc_stream_add_dsc_to_resource(struct dc *dc,448struct dc_state *state,449struct dc_stream_state *stream);450451bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream);452453bool dc_stream_set_dynamic_metadata(struct dc *dc,454struct dc_stream_state *stream,455struct dc_dmdata_attributes *dmdata_attr);456457enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);458459/*460* Enable stereo when commit_streams is not required,461* for example, frame alternate.462*/463void dc_enable_stereo(464struct dc *dc,465struct dc_state *context,466struct dc_stream_state *streams[],467uint8_t stream_count);468469/* Triggers multi-stream synchronization. */470void dc_trigger_sync(struct dc *dc, struct dc_state *context);471472enum surface_update_type dc_check_update_surfaces_for_stream(473struct dc *dc,474struct dc_surface_update *updates,475int surface_count,476struct dc_stream_update *stream_update,477const struct dc_stream_status *stream_status);478479/**480* Create a new default stream for the requested sink481*/482struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);483484struct dc_stream_state *dc_copy_stream(const struct dc_stream_state *stream);485486void update_stream_signal(struct dc_stream_state *stream, struct dc_sink *sink);487488void dc_stream_retain(struct dc_stream_state *dc_stream);489void dc_stream_release(struct dc_stream_state *dc_stream);490491struct dc_stream_status *dc_stream_get_status(492struct dc_stream_state *dc_stream);493494/*******************************************************************************495* Cursor interfaces - To manages the cursor within a stream496******************************************************************************/497/* TODO: Deprecated once we switch to dc_set_cursor_position */498499void program_cursor_attributes(500struct dc *dc,501struct dc_stream_state *stream);502503void program_cursor_position(504struct dc *dc,505struct dc_stream_state *stream);506507bool dc_stream_check_cursor_attributes(508const struct dc_stream_state *stream,509struct dc_state *state,510const struct dc_cursor_attributes *attributes);511512bool dc_stream_set_cursor_attributes(513struct dc_stream_state *stream,514const struct dc_cursor_attributes *attributes);515516bool dc_stream_program_cursor_attributes(517struct dc_stream_state *stream,518const struct dc_cursor_attributes *attributes);519520bool dc_stream_set_cursor_position(521struct dc_stream_state *stream,522const struct dc_cursor_position *position);523524bool dc_stream_program_cursor_position(525struct dc_stream_state *stream,526const struct dc_cursor_position *position);527528529bool dc_stream_adjust_vmin_vmax(struct dc *dc,530struct dc_stream_state *stream,531struct dc_crtc_timing_adjust *adjust);532533bool dc_stream_get_last_used_drr_vtotal(struct dc *dc,534struct dc_stream_state *stream,535uint32_t *refresh_rate);536537#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)538bool dc_stream_forward_crc_window(struct dc_stream_state *stream,539struct rect *rect,540uint8_t phy_id,541bool is_stop);542543bool dc_stream_forward_multiple_crc_window(struct dc_stream_state *stream,544struct crc_window *window,545uint8_t phy_id,546bool stop);547#endif548549bool dc_stream_configure_crc(struct dc *dc,550struct dc_stream_state *stream,551struct crc_params *crc_window,552bool enable,553bool continuous,554uint8_t idx,555bool reset);556557bool dc_stream_get_crc(struct dc *dc,558struct dc_stream_state *stream,559uint8_t idx,560uint32_t *r_cr,561uint32_t *g_y,562uint32_t *b_cb);563564void dc_stream_set_static_screen_params(struct dc *dc,565struct dc_stream_state **stream,566int num_streams,567const struct dc_static_screen_params *params);568569void dc_stream_set_dyn_expansion(struct dc *dc, struct dc_stream_state *stream,570enum dc_dynamic_expansion option);571572void dc_stream_set_dither_option(struct dc_stream_state *stream,573enum dc_dither_option option);574575bool dc_stream_set_gamut_remap(struct dc *dc,576const struct dc_stream_state *stream);577578bool dc_stream_program_csc_matrix(struct dc *dc,579struct dc_stream_state *stream);580581struct dc_rmcm_3dlut *dc_stream_get_3dlut_for_stream(582const struct dc *dc,583const struct dc_stream_state *stream,584bool allocate_one);585586void dc_stream_release_3dlut_for_stream(587const struct dc *dc,588const struct dc_stream_state *stream);589590void dc_stream_init_rmcm_3dlut(struct dc *dc);591592struct pipe_ctx *dc_stream_get_pipe_ctx(struct dc_stream_state *stream);593594void dc_dmub_update_dirty_rect(struct dc *dc,595int surface_count,596struct dc_stream_state *stream,597struct dc_surface_update *srf_updates,598struct dc_state *context);599600bool dc_stream_is_cursor_limit_pending(struct dc *dc, struct dc_stream_state *stream);601bool dc_stream_can_clear_cursor_limit(struct dc *dc, struct dc_stream_state *stream);602603#endif /* DC_STREAM_H_ */604605606