1 /* SPDX-License-Identifier: MIT */
3 * Copyright 2023 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef _DML2_UTILS_H_
26 #define _DML2_UTILS_H_
29 #include "dml2_dc_types.h"
32 struct dml_timing_cfg_st;
33 struct dml2_dcn_clocks;
36 void dml2_util_copy_dml_timing(struct dml_timing_cfg_st *dml_timing_array, unsigned int dst_index, unsigned int src_index);
37 void dml2_util_copy_dml_plane(struct dml_plane_cfg_st *dml_plane_array, unsigned int dst_index, unsigned int src_index);
38 void dml2_util_copy_dml_surface(struct dml_surface_cfg_st *dml_surface_array, unsigned int dst_index, unsigned int src_index);
39 void dml2_util_copy_dml_output(struct dml_output_cfg_st *dml_output_array, unsigned int dst_index, unsigned int src_index);
40 unsigned int dml2_util_get_maximum_odm_combine_for_output(bool force_odm_4to1, enum dml_output_encoder_class encoder, bool dsc_enabled);
41 void dml2_copy_clocks_to_dc_state(struct dml2_dcn_clocks *out_clks, struct dc_state *context);
42 void dml2_extract_watermark_set(struct dcn_watermarks *watermark, struct display_mode_lib_st *dml_core_ctx);
43 int dml2_helper_find_dml_pipe_idx_by_stream_id(struct dml2_context *ctx, unsigned int stream_id);
44 bool is_dtbclk_required(const struct dc *dc, struct dc_state *context);
45 bool dml2_is_stereo_timing(struct dc_stream_state *stream);
48 * dml2_dc_construct_pipes - This function will determine if we need additional pipes based
49 * on the DML calculated outputs for MPC, ODM and allocate them as necessary. This function
50 * could be called after in dml_validate_build_resource after dml_mode_pragramming like :
53 * map_hw_resources(&s->cur_display_config, &s->mode_support_info);
54 * result = dml_mode_programming(&in_ctx->dml_core_ctx, s->mode_support_params.out_lowest_state_idx, &s->cur_display_config, true);
55 * dml2_dc_construct_pipes(in_display_state, s->mode_support_info, out_hw_context);
59 * @context: To obtain res_ctx and read other information like stream ID etc.
60 * @dml_mode_support_st : To get the ODM, MPC outputs as determined by the DML.
61 * @out_hw_context : Handle to the new hardware context.
66 void dml2_dc_construct_pipes(struct dc_state *context, struct dml_mode_support_info_st *dml_mode_support_st,
67 struct resource_context *out_hw_context);
70 * dml2_predict_pipe_split - This function is the dml2 version of predict split pipe. It predicts a
71 * if pipe split is required or not and returns the output as a bool.
72 * @context : dc_state.
73 * @pipe : old_index is the index of the pipe as derived from pipe_idx.
74 * @index : index of the pipe
77 * Return: Returns the result in boolean.
79 bool dml2_predict_pipe_split(struct dc_state *context, display_pipe_params_st pipe, int index);
82 * dml2_build_mapped_resource - This function is the dml2 version of build_mapped_resource.
83 * In case of ODM, we need to build pipe hardware params again as done in dcn20_build_mapped_resource.
85 * @context : struct dc_state.
86 * @stream : stream whoose corresponding pipe params need to be modified.
89 * Return: Returns DC_OK if successful.
91 enum dc_status dml2_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
94 * dml2_extract_rq_regs - This function will extract information needed for struct _vcs_dpi_display_rq_regs_st
96 * @context: To obtain and populate the res_ctx->pipe_ctx->rq_regs with DML outputs.
97 * @support : This structure has the DML intermediate outputs required to populate rq_regs.
104 * dml2_calculate_rq_and_dlg_params - This function will call into DML2 functions needed
105 * for populating rq, ttu and dlg param structures and populate it.
107 * @context : dc_state provides a handle to selectively populate pipe_ctx
108 * @out_new_hw_state: To obtain and populate the rq, dlg and ttu regs in
109 * out_new_hw_state->pipe_ctx with DML outputs.
110 * @in_ctx : This structure has the pointer to display_mode_lib_st.
111 * @pipe_cnt : DML functions to obtain RQ, TTu and DLG params need a pipe_index.
112 * This helps provide pipe_index in the pipe_cnt loop.
117 void dml2_calculate_rq_and_dlg_params(const struct dc *dc, struct dc_state *context, struct resource_context *out_new_hw_state, struct dml2_context *in_ctx, unsigned int pipe_cnt);
120 * dml2_apply_det_buffer_allocation_policy - This function will determine the DET Buffer size
121 * and return the number of streams.
122 * @dml2 : Handle for dml2 context
123 * @dml_dispcfg : dml_dispcfg is the DML2 struct representing the current display config
126 void dml2_apply_det_buffer_allocation_policy(struct dml2_context *in_ctx, struct dml_display_cfg_st *dml_dispcfg);
129 * dml2_verify_det_buffer_configuration - This function will verify if the allocated DET buffer exceeds
130 * the total available DET size available and outputs a boolean to indicate if recalulation is needed.
131 * @dml2 : Handle for dml2 context
132 * @dml_dispcfg : dml_dispcfg is the DML2 struct representing the current display config
133 * @struct dml2_helper_det_policy_scratch : Pointer to DET helper scratch
134 * Return : returns true if recalculation is required, false otherwise.
136 bool dml2_verify_det_buffer_configuration(struct dml2_context *in_ctx, struct dc_state *display_state, struct dml2_helper_det_policy_scratch *det_scratch);
139 * dml2_initialize_det_scratch - This function will initialize the DET scratch space as per requirements.
140 * @dml2 : Handle for dml2 context
143 void dml2_initialize_det_scratch(struct dml2_context *in_ctx);