xref: /linux/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
1 /*
2  * Copyright 2017 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 #ifndef __DISPLAY_MODE_LIB_H__
26 #define __DISPLAY_MODE_LIB_H__
27 
28 #include "dm_services.h"
29 #include "dc_features.h"
30 #include "display_mode_structs.h"
31 #include "display_mode_enums.h"
32 #include "display_mode_vba.h"
33 
34 enum dml_project {
35 	DML_PROJECT_UNDEFINED,
36 	DML_PROJECT_RAVEN1,
37 	DML_PROJECT_NAVI10,
38 	DML_PROJECT_NAVI10v2,
39 	DML_PROJECT_DCN201,
40 	DML_PROJECT_DCN21,
41 	DML_PROJECT_DCN30,
42 	DML_PROJECT_DCN31,
43 	DML_PROJECT_DCN315,
44 	DML_PROJECT_DCN314,
45 	DML_PROJECT_DCN32,
46 };
47 
48 struct display_mode_lib;
49 
50 struct dml_funcs {
51 	void (*rq_dlg_get_dlg_reg)(
52 			struct display_mode_lib *mode_lib,
53 			display_dlg_regs_st *dlg_regs,
54 			display_ttu_regs_st *ttu_regs,
55 			const display_e2e_pipe_params_st *e2e_pipe_param,
56 			const unsigned int num_pipes,
57 			const unsigned int pipe_idx,
58 			const bool cstate_en,
59 			const bool pstate_en,
60 			const bool vm_en,
61 			const bool ignore_viewport_pos,
62 			const bool immediate_flip_support);
63 	void (*rq_dlg_get_rq_reg)(
64 		struct display_mode_lib *mode_lib,
65 		display_rq_regs_st *rq_regs,
66 		const display_pipe_params_st *pipe_param);
67 	// DLG interfaces have different function parameters in DCN32.
68 	// Create new function pointers to address the changes
69 	void (*rq_dlg_get_dlg_reg_v2)(
70 			struct display_mode_lib *mode_lib,
71 			display_dlg_regs_st *dlg_regs,
72 			display_ttu_regs_st *ttu_regs,
73 			display_e2e_pipe_params_st *e2e_pipe_param,
74 			const unsigned int num_pipes,
75 			const unsigned int pipe_idx);
76 	void (*rq_dlg_get_rq_reg_v2)(display_rq_regs_st *rq_regs,
77 			struct display_mode_lib *mode_lib,
78 			const display_e2e_pipe_params_st *e2e_pipe_param,
79 			const unsigned int num_pipes,
80 			const unsigned int pipe_idx);
81 	void (*recalculate)(struct display_mode_lib *mode_lib);
82 	void (*validate)(struct display_mode_lib *mode_lib);
83 };
84 
85 struct display_mode_lib {
86 	struct _vcs_dpi_ip_params_st ip;
87 	struct _vcs_dpi_soc_bounding_box_st soc;
88 	enum dml_project project;
89 	struct vba_vars_st vba;
90 	struct dal_logger *logger;
91 	struct dml_funcs funcs;
92 	struct _vcs_dpi_display_e2e_pipe_params_st dml_pipe_state[6];
93 	bool validate_max_state;
94 };
95 
96 void dml_init_instance(struct display_mode_lib *lib,
97 		const struct _vcs_dpi_soc_bounding_box_st *soc_bb,
98 		const struct _vcs_dpi_ip_params_st *ip_params,
99 		enum dml_project project);
100 
101 const char *dml_get_status_message(enum dm_validation_status status);
102 
103 void dml_log_pipe_params(
104 		struct display_mode_lib *mode_lib,
105 		display_e2e_pipe_params_st *pipes,
106 		int pipe_cnt);
107 
108 void dml_log_mode_support_params(struct display_mode_lib *mode_lib);
109 #endif
110