Linux Audio

Check our new training course

Loading...
v6.9.4
  1/* SPDX-License-Identifier: MIT */
  2/*
  3 * Copyright 2023 Advanced Micro Devices, Inc.
  4 *
  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:
 11 *
 12 * The above copyright notice and this permission notice shall be included in
 13 * all copies or substantial portions of the Software.
 14 *
 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.
 22 *
 23 */
 24
 25#ifndef _DML2_UTILS_H_
 26#define _DML2_UTILS_H_
 27
 28#include "os_types.h"
 29#include "dml2_dc_types.h"
 30
 31struct dc;
 32struct dml_timing_cfg_st;
 33struct dml2_dcn_clocks;
 34struct dc_state;
 35
 36void dml2_util_copy_dml_timing(struct dml_timing_cfg_st *dml_timing_array, unsigned int dst_index, unsigned int src_index);
 37void dml2_util_copy_dml_plane(struct dml_plane_cfg_st *dml_plane_array, unsigned int dst_index, unsigned int src_index);
 38void dml2_util_copy_dml_surface(struct dml_surface_cfg_st *dml_surface_array, unsigned int dst_index, unsigned int src_index);
 39void dml2_util_copy_dml_output(struct dml_output_cfg_st *dml_output_array, unsigned int dst_index, unsigned int src_index);
 40unsigned int dml2_util_get_maximum_odm_combine_for_output(bool force_odm_4to1, enum dml_output_encoder_class encoder, bool dsc_enabled);
 41void dml2_copy_clocks_to_dc_state(struct dml2_dcn_clocks *out_clks, struct dc_state *context);
 42void dml2_extract_watermark_set(struct dcn_watermarks *watermark, struct display_mode_lib_st *dml_core_ctx);
 
 43int dml2_helper_find_dml_pipe_idx_by_stream_id(struct dml2_context *ctx, unsigned int stream_id);
 44bool is_dtbclk_required(const struct dc *dc, struct dc_state *context);
 45bool dml2_is_stereo_timing(const struct dc_stream_state *stream);
 
 
 
 
 46
 47/*
 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 :
 51 * {
 52 *   ...
 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);
 56 * ...
 57 * }
 58 *
 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.
 62 *
 63 *
 64 * Return: None.
 65 */
 66void 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);
 68
 69/*
 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
 75 *
 76 *
 77 * Return: Returns the result in boolean.
 78 */
 79bool dml2_predict_pipe_split(struct dc_state *context, display_pipe_params_st pipe, int index);
 80
 81/*
 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.
 84 * @dc : struct dc
 85 * @context : struct dc_state.
 86 * @stream : stream whoose corresponding pipe params need to be modified.
 87 *
 88 *
 89 * Return: Returns DC_OK if successful.
 90 */
 91enum dc_status dml2_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
 92
 93/*
 94 * dml2_extract_rq_regs - This function will extract information needed for struct _vcs_dpi_display_rq_regs_st
 95 * and populate it.
 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.
 98 *
 99 *
100 * Return: None.
101 */
102
103 /*
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.
106  * @dc : struct dc
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.
113  *
114  *
115  * Return: None.
116  */
117void 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);
118
119/*
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
124 * Return : None.
125 */
126void dml2_apply_det_buffer_allocation_policy(struct dml2_context *in_ctx, struct dml_display_cfg_st *dml_dispcfg);
127
128/*
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.
135 */
136bool dml2_verify_det_buffer_configuration(struct dml2_context *in_ctx, struct dc_state *display_state, struct dml2_helper_det_policy_scratch *det_scratch);
137
138/*
139 * dml2_initialize_det_scratch - This function will initialize the DET scratch space as per requirements.
140 * @dml2 : Handle for dml2 context
141 * Return : None
142 */
143void dml2_initialize_det_scratch(struct dml2_context *in_ctx);
144#endif
v6.13.7
  1/* SPDX-License-Identifier: MIT */
  2/*
  3 * Copyright 2023 Advanced Micro Devices, Inc.
  4 *
  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:
 11 *
 12 * The above copyright notice and this permission notice shall be included in
 13 * all copies or substantial portions of the Software.
 14 *
 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.
 22 *
 23 */
 24
 25#ifndef _DML2_UTILS_H_
 26#define _DML2_UTILS_H_
 27
 28#include "os_types.h"
 29#include "dml2_dc_types.h"
 30
 31struct dc;
 32struct dml_timing_cfg_st;
 33struct dml2_dcn_clocks;
 34struct dc_state;
 35
 36void dml2_util_copy_dml_timing(struct dml_timing_cfg_st *dml_timing_array, unsigned int dst_index, unsigned int src_index);
 37void dml2_util_copy_dml_plane(struct dml_plane_cfg_st *dml_plane_array, unsigned int dst_index, unsigned int src_index);
 38void dml2_util_copy_dml_surface(struct dml_surface_cfg_st *dml_surface_array, unsigned int dst_index, unsigned int src_index);
 39void dml2_util_copy_dml_output(struct dml_output_cfg_st *dml_output_array, unsigned int dst_index, unsigned int src_index);
 40unsigned int dml2_util_get_maximum_odm_combine_for_output(bool force_odm_4to1, enum dml_output_encoder_class encoder, bool dsc_enabled);
 41void dml2_copy_clocks_to_dc_state(struct dml2_dcn_clocks *out_clks, struct dc_state *context);
 42void dml2_extract_watermark_set(struct dcn_watermarks *watermark, struct display_mode_lib_st *dml_core_ctx);
 43void dml2_extract_writeback_wm(struct dc_state *context, struct display_mode_lib_st *dml_core_ctx);
 44int dml2_helper_find_dml_pipe_idx_by_stream_id(struct dml2_context *ctx, unsigned int stream_id);
 45bool is_dtbclk_required(const struct dc *dc, struct dc_state *context);
 46bool dml2_is_stereo_timing(const struct dc_stream_state *stream);
 47unsigned int dml2_calc_max_scaled_time(
 48		unsigned int time_per_pixel,
 49		enum mmhubbub_wbif_mode mode,
 50		unsigned int urgent_watermark);
 51
 52/*
 53 * dml2_dc_construct_pipes - This function will determine if we need additional pipes based
 54 * on the DML calculated outputs for MPC, ODM and allocate them as necessary. This function
 55 * could be called after in dml_validate_build_resource after dml_mode_pragramming like :
 56 * {
 57 *   ...
 58 * map_hw_resources(&s->cur_display_config, &s->mode_support_info);
 59 * result = dml_mode_programming(&in_ctx->dml_core_ctx, s->mode_support_params.out_lowest_state_idx, &s->cur_display_config, true);
 60 * dml2_dc_construct_pipes(in_display_state, s->mode_support_info, out_hw_context);
 61 * ...
 62 * }
 63 *
 64 * @context: To obtain res_ctx and read other information like stream ID etc.
 65 * @dml_mode_support_st : To get the ODM, MPC outputs as determined by the DML.
 66 * @out_hw_context : Handle to the new hardware context.
 67 *
 68 *
 69 * Return: None.
 70 */
 71void dml2_dc_construct_pipes(struct dc_state *context, struct dml_mode_support_info_st *dml_mode_support_st,
 72		struct resource_context *out_hw_context);
 73
 74/*
 75 * dml2_predict_pipe_split - This function is the dml2 version of predict split pipe. It predicts a
 76 * if pipe split is required or not and returns the output as a bool.
 77 * @context : dc_state.
 78 * @pipe : old_index is the index of the pipe as derived from pipe_idx.
 79 * @index : index of the pipe
 80 *
 81 *
 82 * Return: Returns the result in boolean.
 83 */
 84bool dml2_predict_pipe_split(struct dc_state *context, display_pipe_params_st pipe, int index);
 85
 86/*
 87 * dml2_build_mapped_resource - This function is the dml2 version of build_mapped_resource.
 88 * In case of ODM, we need to build pipe hardware params again as done in dcn20_build_mapped_resource.
 89 * @dc : struct dc
 90 * @context : struct dc_state.
 91 * @stream : stream whoose corresponding pipe params need to be modified.
 92 *
 93 *
 94 * Return: Returns DC_OK if successful.
 95 */
 96enum dc_status dml2_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
 97
 98/*
 99 * dml2_extract_rq_regs - This function will extract information needed for struct _vcs_dpi_display_rq_regs_st
100 * and populate it.
101 * @context: To obtain and populate the res_ctx->pipe_ctx->rq_regs with DML outputs.
102 * @support : This structure has the DML intermediate outputs required to populate rq_regs.
103 *
104 *
105 * Return: None.
106 */
107
108 /*
109  * dml2_calculate_rq_and_dlg_params - This function will call into DML2 functions needed
110  * for populating rq, ttu and dlg param structures and populate it.
111  * @dc : struct dc
112  * @context : dc_state provides a handle to selectively populate pipe_ctx
113  * @out_new_hw_state: To obtain and populate the rq, dlg and ttu regs in
114  *                    out_new_hw_state->pipe_ctx with DML outputs.
115  * @in_ctx : This structure has the pointer to display_mode_lib_st.
116  * @pipe_cnt : DML functions to obtain RQ, TTu and DLG params need a pipe_index.
117  *				This helps provide pipe_index in the pipe_cnt loop.
118  *
119  *
120  * Return: None.
121  */
122void 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);
123
124/*
125 * dml2_apply_det_buffer_allocation_policy - This function will determine the DET Buffer size
126 * and return the number of streams.
127 * @dml2 : Handle for dml2 context
128 * @dml_dispcfg : dml_dispcfg is the DML2 struct representing the current display config
129 * Return : None.
130 */
131void dml2_apply_det_buffer_allocation_policy(struct dml2_context *in_ctx, struct dml_display_cfg_st *dml_dispcfg);
132
133/*
134 * dml2_verify_det_buffer_configuration - This function will verify if the allocated DET buffer exceeds
135 * the total available DET size available and outputs a boolean to indicate if recalulation is needed.
136 * @dml2 : Handle for dml2 context
137 * @dml_dispcfg : dml_dispcfg is the DML2 struct representing the current display config
138 * @struct dml2_helper_det_policy_scratch : Pointer to DET helper scratch
139 * Return : returns true if recalculation is required, false otherwise.
140 */
141bool dml2_verify_det_buffer_configuration(struct dml2_context *in_ctx, struct dc_state *display_state, struct dml2_helper_det_policy_scratch *det_scratch);
142
143/*
144 * dml2_initialize_det_scratch - This function will initialize the DET scratch space as per requirements.
145 * @dml2 : Handle for dml2 context
146 * Return : None
147 */
148void dml2_initialize_det_scratch(struct dml2_context *in_ctx);
149#endif