Path: blob/master/drivers/gpu/drm/amd/display/dc/dc_stream.h
29294 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;205struct dc_info_packet avi_infopacket;206uint8_t dsc_packed_pps[128];207struct rect src; /* composition area */208struct rect dst; /* stream addressable area */209210struct audio_info audio_info;211212struct dc_info_packet hdr_static_metadata;213PHYSICAL_ADDRESS_LOC dmdata_address;214bool use_dynamic_meta;215216struct dc_transfer_func out_transfer_func;217struct colorspace_transform gamut_remap_matrix;218struct dc_csc_transform csc_color_matrix;219220enum dc_color_space output_color_space;221enum display_content_type content_type;222enum dc_dither_option dither_option;223224enum view_3d_format view_format;225226bool use_vsc_sdp_for_colorimetry;227bool ignore_msa_timing_param;228229/**230* @allow_freesync:231*232* It say if Freesync is enabled or not.233*/234bool allow_freesync;235236/**237* @vrr_active_variable:238*239* It describes if VRR is in use.240*/241bool vrr_active_variable;242bool freesync_on_desktop;243bool vrr_active_fixed;244245bool converter_disable_audio;246uint8_t qs_bit;247uint8_t qy_bit;248249/* TODO: custom INFO packets */250/* TODO: ABM info (DMCU) */251/* TODO: CEA VIC */252253/* DMCU info */254unsigned int abm_level;255256struct periodic_interrupt_config periodic_interrupt;257258/* from core_stream struct */259struct dc_context *ctx;260261/* used by DCP and FMT */262struct bit_depth_reduction_params bit_depth_params;263struct clamping_and_pixel_encoding_params clamping;264265int phy_pix_clk;266enum signal_type signal;267bool dpms_off;268269void *dm_stream_context;270271struct dc_cursor_attributes cursor_attributes;272struct dc_cursor_position cursor_position;273bool hw_cursor_req;274275uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode276277/* from stream struct */278struct kref refcount;279280struct crtc_trigger_info triggered_crtc_reset;281282/* writeback */283unsigned int num_wb_info;284struct dc_writeback_info writeback_info[MAX_DWB_PIPES];285const struct dc_transfer_func *func_shaper;286const struct dc_3dlut *lut3d_func;287/* Computed state bits */288bool mode_changed : 1;289290/* Output from DC when stream state is committed or altered291* DC may only access these values during:292* dc_commit_state, dc_commit_state_no_check, dc_commit_streams293* values may not change outside of those calls294*/295struct {296// For interrupt management, some hardware instance297// offsets need to be exposed to DM298uint8_t otg_offset;299} out;300301bool apply_edp_fast_boot_optimization;302bool apply_seamless_boot_optimization;303uint32_t apply_boot_odm_mode;304305uint32_t stream_id;306307struct test_pattern test_pattern;308union stream_update_flags update_flags;309310bool has_non_synchronizable_pclk;311bool vblank_synchronized;312bool is_phantom;313314struct luminance_data lumin_data;315bool scaler_sharpener_update;316bool sharpening_required;317};318319#define ABM_LEVEL_IMMEDIATE_DISABLE 255320321struct dc_stream_update {322struct dc_stream_state *stream;323324struct rect src;325struct rect dst;326struct dc_transfer_func *out_transfer_func;327struct dc_info_packet *hdr_static_metadata;328unsigned int *abm_level;329330struct periodic_interrupt_config *periodic_interrupt;331332struct dc_info_packet *vrr_infopacket;333struct dc_info_packet *vsc_infopacket;334struct dc_info_packet *vsp_infopacket;335struct dc_info_packet *hfvsif_infopacket;336struct dc_info_packet *vtem_infopacket;337struct dc_info_packet *adaptive_sync_infopacket;338struct dc_info_packet *avi_infopacket;339340bool *dpms_off;341bool integer_scaling_update;342bool *allow_freesync;343bool *vrr_active_variable;344bool *vrr_active_fixed;345346struct colorspace_transform *gamut_remap;347enum dc_color_space *output_color_space;348enum dc_dither_option *dither_option;349350struct dc_csc_transform *output_csc_transform;351352struct dc_writeback_update *wb_update;353struct dc_dsc_config *dsc_config;354struct dc_mst_stream_bw_update *mst_bw_update;355struct dc_transfer_func *func_shaper;356struct dc_3dlut *lut3d_func;357358struct test_pattern *pending_test_pattern;359struct dc_crtc_timing_adjust *crtc_timing_adjust;360361struct dc_cursor_attributes *cursor_attributes;362struct dc_cursor_position *cursor_position;363bool *hw_cursor_req;364bool *scaler_sharpener_update;365bool *sharpening_required;366};367368bool dc_is_stream_unchanged(369struct dc_stream_state *old_stream, struct dc_stream_state *stream);370bool dc_is_stream_scaling_unchanged(371struct dc_stream_state *old_stream, struct dc_stream_state *stream);372373/*374* Setup stream attributes if no stream updates are provided375* there will be no impact on the stream parameters376*377* Set up surface attributes and associate to a stream378* The surfaces parameter is an absolute set of all surface active for the stream.379* If no surfaces are provided, the stream will be blanked; no memory read.380* Any flip related attribute changes must be done through this interface.381*382* After this call:383* Surfaces attributes are programmed and configured to be composed into stream.384* This does not trigger a flip. No surface address is programmed.385*386*/387bool dc_update_planes_and_stream(struct dc *dc,388struct dc_surface_update *surface_updates, int surface_count,389struct dc_stream_state *dc_stream,390struct dc_stream_update *stream_update);391392/*393* Set up surface attributes and associate to a stream394* The surfaces parameter is an absolute set of all surface active for the stream.395* If no surfaces are provided, the stream will be blanked; no memory read.396* Any flip related attribute changes must be done through this interface.397*398* After this call:399* Surfaces attributes are programmed and configured to be composed into stream.400* This does not trigger a flip. No surface address is programmed.401*/402void dc_commit_updates_for_stream(struct dc *dc,403struct dc_surface_update *srf_updates,404int surface_count,405struct dc_stream_state *stream,406struct dc_stream_update *stream_update,407struct dc_state *state);408/*409* Log the current stream state.410*/411void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream);412413uint8_t dc_get_current_stream_count(struct dc *dc);414struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);415416/*417* Return the current frame counter.418*/419uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);420421/*422* Send dp sdp message.423*/424bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream,425const uint8_t *custom_sdp_message,426unsigned int sdp_message_size);427428/* TODO: Return parsed values rather than direct register read429* This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos)430* being refactored properly to be dce-specific431*/432bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,433uint32_t *v_blank_start,434uint32_t *v_blank_end,435uint32_t *h_position,436uint32_t *v_position);437438bool dc_stream_add_writeback(struct dc *dc,439struct dc_stream_state *stream,440struct dc_writeback_info *wb_info);441442bool dc_stream_fc_disable_writeback(struct dc *dc,443struct dc_stream_state *stream,444uint32_t dwb_pipe_inst);445446bool dc_stream_remove_writeback(struct dc *dc,447struct dc_stream_state *stream,448uint32_t dwb_pipe_inst);449450enum dc_status dc_stream_add_dsc_to_resource(struct dc *dc,451struct dc_state *state,452struct dc_stream_state *stream);453454bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream);455456bool dc_stream_set_dynamic_metadata(struct dc *dc,457struct dc_stream_state *stream,458struct dc_dmdata_attributes *dmdata_attr);459460enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);461462/*463* Enable stereo when commit_streams is not required,464* for example, frame alternate.465*/466void dc_enable_stereo(467struct dc *dc,468struct dc_state *context,469struct dc_stream_state *streams[],470uint8_t stream_count);471472/* Triggers multi-stream synchronization. */473void dc_trigger_sync(struct dc *dc, struct dc_state *context);474475enum surface_update_type dc_check_update_surfaces_for_stream(476struct dc *dc,477struct dc_surface_update *updates,478int surface_count,479struct dc_stream_update *stream_update,480const struct dc_stream_status *stream_status);481482/**483* Create a new default stream for the requested sink484*/485struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);486487struct dc_stream_state *dc_copy_stream(const struct dc_stream_state *stream);488489void update_stream_signal(struct dc_stream_state *stream, struct dc_sink *sink);490491void dc_stream_retain(struct dc_stream_state *dc_stream);492void dc_stream_release(struct dc_stream_state *dc_stream);493494struct dc_stream_status *dc_stream_get_status(495struct dc_stream_state *dc_stream);496497/*******************************************************************************498* Cursor interfaces - To manages the cursor within a stream499******************************************************************************/500/* TODO: Deprecated once we switch to dc_set_cursor_position */501502void program_cursor_attributes(503struct dc *dc,504struct dc_stream_state *stream);505506void program_cursor_position(507struct dc *dc,508struct dc_stream_state *stream);509510bool dc_stream_check_cursor_attributes(511const struct dc_stream_state *stream,512struct dc_state *state,513const struct dc_cursor_attributes *attributes);514515bool dc_stream_set_cursor_attributes(516struct dc_stream_state *stream,517const struct dc_cursor_attributes *attributes);518519bool dc_stream_program_cursor_attributes(520struct dc_stream_state *stream,521const struct dc_cursor_attributes *attributes);522523bool dc_stream_set_cursor_position(524struct dc_stream_state *stream,525const struct dc_cursor_position *position);526527bool dc_stream_program_cursor_position(528struct dc_stream_state *stream,529const struct dc_cursor_position *position);530531532bool dc_stream_adjust_vmin_vmax(struct dc *dc,533struct dc_stream_state *stream,534struct dc_crtc_timing_adjust *adjust);535536bool dc_stream_get_last_used_drr_vtotal(struct dc *dc,537struct dc_stream_state *stream,538uint32_t *refresh_rate);539540#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)541bool dc_stream_forward_crc_window(struct dc_stream_state *stream,542struct rect *rect,543uint8_t phy_id,544bool is_stop);545546bool dc_stream_forward_multiple_crc_window(struct dc_stream_state *stream,547struct crc_window *window,548uint8_t phy_id,549bool stop);550#endif551552bool dc_stream_configure_crc(struct dc *dc,553struct dc_stream_state *stream,554struct crc_params *crc_window,555bool enable,556bool continuous,557uint8_t idx,558bool reset);559560bool dc_stream_get_crc(struct dc *dc,561struct dc_stream_state *stream,562uint8_t idx,563uint32_t *r_cr,564uint32_t *g_y,565uint32_t *b_cb);566567void dc_stream_set_static_screen_params(struct dc *dc,568struct dc_stream_state **stream,569int num_streams,570const struct dc_static_screen_params *params);571572void dc_stream_set_dyn_expansion(struct dc *dc, struct dc_stream_state *stream,573enum dc_dynamic_expansion option);574575void dc_stream_set_dither_option(struct dc_stream_state *stream,576enum dc_dither_option option);577578bool dc_stream_set_gamut_remap(struct dc *dc,579const struct dc_stream_state *stream);580581bool dc_stream_program_csc_matrix(struct dc *dc,582struct dc_stream_state *stream);583584struct dc_rmcm_3dlut *dc_stream_get_3dlut_for_stream(585const struct dc *dc,586const struct dc_stream_state *stream,587bool allocate_one);588589void dc_stream_release_3dlut_for_stream(590const struct dc *dc,591const struct dc_stream_state *stream);592593void dc_stream_init_rmcm_3dlut(struct dc *dc);594595struct pipe_ctx *dc_stream_get_pipe_ctx(struct dc_stream_state *stream);596597void dc_dmub_update_dirty_rect(struct dc *dc,598int surface_count,599struct dc_stream_state *stream,600struct dc_surface_update *srf_updates,601struct dc_state *context);602603bool dc_stream_is_cursor_limit_pending(struct dc *dc, struct dc_stream_state *stream);604bool dc_stream_can_clear_cursor_limit(struct dc *dc, struct dc_stream_state *stream);605606#endif /* DC_STREAM_H_ */607608609