1 // SPDX-License-Identifier: MIT
2 //
3 // Copyright 2024 Advanced Micro Devices, Inc.
4 
5 
6 #ifndef _DML21_UTILS_H_
7 #define _DML21_UTILS_H_
8 
9 struct dc_state;
10 struct dc_plane_state;
11 struct pipe_ctx;
12 
13 struct dml2_context;
14 struct dml2_display_rq_regs;
15 struct dml2_display_dlg_regs;
16 struct dml2_display_ttu_regs;
17 
18 int dml21_helper_find_dml_pipe_idx_by_stream_id(struct dml2_context *ctx, unsigned int stream_id);
19 int dml21_find_dml_pipe_idx_by_plane_id(struct dml2_context *ctx, unsigned int plane_id);
20 bool dml21_get_plane_id(const struct dc_state *state, const struct dc_plane_state *plane, unsigned int *plane_id);
21 void dml21_update_pipe_ctx_dchub_regs(struct dml2_display_rq_regs *rq_regs,
22 	struct dml2_display_dlg_regs *disp_dlg_regs,
23 	struct dml2_display_ttu_regs *disp_ttu_regs,
24 	struct pipe_ctx *out);
25 void dml21_populate_mall_allocation_size(struct dc_state *context,
26 		struct dml2_context *in_ctx,
27 		struct dml2_per_plane_programming *pln_prog,
28 		struct pipe_ctx *dc_pipe);
29 bool check_dp2p0_output_encoder(const struct pipe_ctx *pipe_ctx);
30 void find_valid_pipe_idx_for_stream_index(const struct dml2_context *dml_ctx, unsigned int *dml_pipe_idx, unsigned int stream_index);
31 void find_pipe_regs_idx(const struct dml2_context *dml_ctx,
32 		struct pipe_ctx *pipe, unsigned int *pipe_regs_idx);
33 int dml21_find_dc_pipes_for_plane(const struct dc *in_dc,
34 		struct dc_state *context,
35 		struct dml2_context *dml_ctx,
36 		struct pipe_ctx *dc_main_pipes[__DML2_WRAPPER_MAX_STREAMS_PLANES__],
37 		struct pipe_ctx *dc_phantom_pipes[__DML2_WRAPPER_MAX_STREAMS_PLANES__],
38 		int dml_plane_idx);
39 void dml21_program_dc_pipe(struct dml2_context *dml_ctx,
40 		struct dc_state *context,
41 		struct pipe_ctx *pipe_ctx,
42 		struct dml2_per_plane_programming *pln_prog,
43 		struct dml2_per_stream_programming *stream_prog);
44 void dml21_handle_phantom_streams_planes(const struct dc *in_dc, struct dc_state *context, struct dml2_context *dml_ctx);
45 unsigned int dml21_get_dc_plane_idx_from_plane_id(unsigned int plane_id);
46 void dml21_build_fams2_programming(const struct dc *dc,
47 		struct dc_state *context,
48 		struct dml2_context *dml_ctx);
49 bool dml21_is_plane1_enabled(enum dml2_source_format_class source_format);
50 #endif
51