1/*	$NetBSD: hubp.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
2
3/*
4 * Copyright 2012-15 Advanced Micro Devices, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: AMD
25 *
26 */
27
28#ifndef __DAL_HUBP_H__
29#define __DAL_HUBP_H__
30
31#include "mem_input.h"
32
33#define OPP_ID_INVALID 0xf
34
35
36enum cursor_pitch {
37	CURSOR_PITCH_64_PIXELS = 0,
38	CURSOR_PITCH_128_PIXELS,
39	CURSOR_PITCH_256_PIXELS
40};
41
42enum cursor_lines_per_chunk {
43	CURSOR_LINE_PER_CHUNK_1 = 0, /* new for DCN2 */
44	CURSOR_LINE_PER_CHUNK_2 = 1,
45	CURSOR_LINE_PER_CHUNK_4,
46	CURSOR_LINE_PER_CHUNK_8,
47	CURSOR_LINE_PER_CHUNK_16
48};
49
50enum hubp_ind_block_size {
51	hubp_ind_block_unconstrained = 0,
52	hubp_ind_block_64b,
53};
54
55struct hubp {
56	const struct hubp_funcs *funcs;
57	struct dc_context *ctx;
58	struct dc_plane_address request_address;
59	int inst;
60
61	/* run time states */
62	int opp_id;
63	int mpcc_id;
64	struct dc_cursor_attributes curs_attr;
65	bool power_gated;
66};
67
68struct surface_flip_registers {
69	uint32_t DCSURF_SURFACE_CONTROL;
70	uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH;
71	uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS;
72	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH;
73	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS;
74	uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH_C;
75	uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_C;
76	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C;
77	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C;
78	uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS_HIGH;
79	uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS;
80	uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS_HIGH;
81	uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS;
82	bool tmz_surface;
83	bool immediate;
84	uint8_t vmid;
85	bool grph_stereo;
86};
87
88struct hubp_funcs {
89	void (*hubp_setup)(
90			struct hubp *hubp,
91			struct _vcs_dpi_display_dlg_regs_st *dlg_regs,
92			struct _vcs_dpi_display_ttu_regs_st *ttu_regs,
93			struct _vcs_dpi_display_rq_regs_st *rq_regs,
94			struct _vcs_dpi_display_pipe_dest_params_st *pipe_dest);
95
96	void (*hubp_setup_interdependent)(
97			struct hubp *hubp,
98			struct _vcs_dpi_display_dlg_regs_st *dlg_regs,
99			struct _vcs_dpi_display_ttu_regs_st *ttu_regs);
100
101	void (*dcc_control)(struct hubp *hubp, bool enable,
102			enum hubp_ind_block_size blk_size);
103
104	void (*mem_program_viewport)(
105			struct hubp *hubp,
106			const struct rect *viewport,
107			const struct rect *viewport_c);
108
109	void (*apply_PLAT_54186_wa)(struct hubp *hubp,
110			const struct dc_plane_address *address);
111
112	bool (*hubp_program_surface_flip_and_addr)(
113		struct hubp *hubp,
114		const struct dc_plane_address *address,
115		bool flip_immediate);
116
117	void (*hubp_program_pte_vm)(
118		struct hubp *hubp,
119		enum surface_pixel_format format,
120		union dc_tiling_info *tiling_info,
121		enum dc_rotation_angle rotation);
122
123	void (*hubp_set_vm_system_aperture_settings)(
124			struct hubp *hubp,
125			struct vm_system_aperture_param *apt);
126
127	void (*hubp_set_vm_context0_settings)(
128			struct hubp *hubp,
129			const struct vm_context0_param *vm0);
130
131	void (*hubp_program_surface_config)(
132		struct hubp *hubp,
133		enum surface_pixel_format format,
134		union dc_tiling_info *tiling_info,
135		struct plane_size *plane_size,
136		enum dc_rotation_angle rotation,
137		struct dc_plane_dcc_param *dcc,
138		bool horizontal_mirror,
139		unsigned int compa_level);
140
141	bool (*hubp_is_flip_pending)(struct hubp *hubp);
142
143	void (*set_blank)(struct hubp *hubp, bool blank);
144	void (*set_hubp_blank_en)(struct hubp *hubp, bool blank);
145
146	void (*set_cursor_attributes)(
147			struct hubp *hubp,
148			const struct dc_cursor_attributes *attr);
149
150	void (*set_cursor_position)(
151			struct hubp *hubp,
152			const struct dc_cursor_position *pos,
153			const struct dc_cursor_mi_param *param);
154
155	void (*hubp_disconnect)(struct hubp *hubp);
156
157	void (*hubp_clk_cntl)(struct hubp *hubp, bool enable);
158	void (*hubp_vtg_sel)(struct hubp *hubp, uint32_t otg_inst);
159	void (*hubp_read_state)(struct hubp *hubp);
160	void (*hubp_clear_underflow)(struct hubp *hubp);
161	void (*hubp_disable_control)(struct hubp *hubp, bool disable_hubp);
162	unsigned int (*hubp_get_underflow_status)(struct hubp *hubp);
163	void (*hubp_init)(struct hubp *hubp);
164
165	void (*dmdata_set_attributes)(
166			struct hubp *hubp,
167			const struct dc_dmdata_attributes *attr);
168
169	void (*dmdata_load)(
170			struct hubp *hubp,
171			uint32_t dmdata_sw_size,
172			const uint32_t *dmdata_sw_data);
173	bool (*dmdata_status_done)(struct hubp *hubp);
174	void (*hubp_enable_tripleBuffer)(
175		struct hubp *hubp,
176		bool enable);
177
178	bool (*hubp_is_triplebuffer_enabled)(
179		struct hubp *hubp);
180
181	void (*hubp_set_flip_control_surface_gsl)(
182		struct hubp *hubp,
183		bool enable);
184
185	void (*validate_dml_output)(
186			struct hubp *hubp,
187			struct dc_context *ctx,
188			struct _vcs_dpi_display_rq_regs_st *dml_rq_regs,
189			struct _vcs_dpi_display_dlg_regs_st *dml_dlg_attr,
190			struct _vcs_dpi_display_ttu_regs_st *dml_ttu_attr);
191
192};
193
194#endif
195