xref: /openbmc/linux/drivers/gpu/drm/amd/display/dc/inc/resource.h (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
14562236bSHarry Wentland /*
24562236bSHarry Wentland  * Copyright 2015 Advanced Micro Devices, Inc.
34562236bSHarry Wentland  *
44562236bSHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
54562236bSHarry Wentland  * copy of this software and associated documentation files (the "Software"),
64562236bSHarry Wentland  * to deal in the Software without restriction, including without limitation
74562236bSHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84562236bSHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
94562236bSHarry Wentland  * Software is furnished to do so, subject to the following conditions:
104562236bSHarry Wentland  *
114562236bSHarry Wentland  * The above copyright notice and this permission notice shall be included in
124562236bSHarry Wentland  * all copies or substantial portions of the Software.
134562236bSHarry Wentland  *
144562236bSHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154562236bSHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164562236bSHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
174562236bSHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
184562236bSHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
194562236bSHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
204562236bSHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
214562236bSHarry Wentland  *
224562236bSHarry Wentland  * Authors: AMD
234562236bSHarry Wentland  */
244562236bSHarry Wentland 
254562236bSHarry Wentland #ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
264562236bSHarry Wentland #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
274562236bSHarry Wentland 
284562236bSHarry Wentland #include "core_types.h"
294562236bSHarry Wentland #include "core_status.h"
304562236bSHarry Wentland #include "dal_asic_id.h"
31a185048cSTony Cheng #include "dm_pp_smu.h"
324562236bSHarry Wentland 
33dc88b4a6SEric Yang #define MEMORY_TYPE_MULTIPLIER_CZ 4
34c46e5df4SCharlene Liu #define MEMORY_TYPE_HBM 2
35c46e5df4SCharlene Liu 
36dc88b4a6SEric Yang 
375f0c7491SMeenakshikumar Somasundaram #define IS_PIPE_SYNCD_VALID(pipe) ((((pipe)->pipe_idx_syncd) & 0x80)?1:0)
385f0c7491SMeenakshikumar Somasundaram #define GET_PIPE_SYNCD_FROM_PIPE(pipe) ((pipe)->pipe_idx_syncd & 0x7F)
395f0c7491SMeenakshikumar Somasundaram #define SET_PIPE_SYNCD_TO_PIPE(pipe, pipe_syncd) ((pipe)->pipe_idx_syncd = (0x80 | pipe_syncd))
405f0c7491SMeenakshikumar Somasundaram 
414562236bSHarry Wentland enum dce_version resource_parse_asic_id(
424562236bSHarry Wentland 		struct hw_asic_id asic_id);
434562236bSHarry Wentland 
444562236bSHarry Wentland struct resource_caps {
454562236bSHarry Wentland 	int num_timing_generator;
46e9522309SEric Bernstein 	int num_opp;
474562236bSHarry Wentland 	int num_video_plane;
484562236bSHarry Wentland 	int num_audio;
494562236bSHarry Wentland 	int num_stream_encoder;
504562236bSHarry Wentland 	int num_pll;
51b1a4eb99SDmytro Laktyushkin 	int num_dwb;
520e8e4fbfSHersen Wu 	int num_ddc;
537ed4e635SHarry Wentland 	int num_vmid;
5497bda032SHarry Wentland 	int num_dsc;
55e1f4328fSJimmy Kizito 	unsigned int num_dig_link_enc; // Total number of DIGs (digital encoders) in DIO (Display Input/Output).
56eabf2019SJimmy Kizito 	unsigned int num_usb4_dpia; // Total number of USB4 DPIA (DisplayPort Input Adapters).
5783228ebbSFangzhi Zuo 	int num_hpo_dp_stream_encoder;
583bc8d921SFangzhi Zuo 	int num_hpo_dp_link_encoder;
595dba4991SBhawanpreet Lakha 	int num_mpc_3dlut;
604562236bSHarry Wentland };
614562236bSHarry Wentland 
624562236bSHarry Wentland struct resource_straps {
634562236bSHarry Wentland 	uint32_t hdmi_disable;
644562236bSHarry Wentland 	uint32_t dc_pinstraps_audio;
654562236bSHarry Wentland 	uint32_t audio_stream_number;
664562236bSHarry Wentland };
674562236bSHarry Wentland 
684562236bSHarry Wentland struct resource_create_funcs {
694562236bSHarry Wentland 	void (*read_dce_straps)(
704562236bSHarry Wentland 			struct dc_context *ctx, struct resource_straps *straps);
714562236bSHarry Wentland 
724562236bSHarry Wentland 	struct audio *(*create_audio)(
734562236bSHarry Wentland 			struct dc_context *ctx, unsigned int inst);
744562236bSHarry Wentland 
754562236bSHarry Wentland 	struct stream_encoder *(*create_stream_encoder)(
764562236bSHarry Wentland 			enum engine_id eng_id, struct dc_context *ctx);
774562236bSHarry Wentland 
7883228ebbSFangzhi Zuo 	struct hpo_dp_stream_encoder *(*create_hpo_dp_stream_encoder)(
7983228ebbSFangzhi Zuo 			enum engine_id eng_id, struct dc_context *ctx);
803bc8d921SFangzhi Zuo 
813bc8d921SFangzhi Zuo 	struct hpo_dp_link_encoder *(*create_hpo_dp_link_encoder)(
823bc8d921SFangzhi Zuo 			uint8_t inst,
833bc8d921SFangzhi Zuo 			struct dc_context *ctx);
8483228ebbSFangzhi Zuo 
854562236bSHarry Wentland 	struct dce_hwseq *(*create_hwseq)(
864562236bSHarry Wentland 			struct dc_context *ctx);
874562236bSHarry Wentland };
884562236bSHarry Wentland 
894562236bSHarry Wentland bool resource_construct(
904562236bSHarry Wentland 	unsigned int num_virtual_links,
91fb3466a4SBhawanpreet Lakha 	struct dc *dc,
924562236bSHarry Wentland 	struct resource_pool *pool,
934562236bSHarry Wentland 	const struct resource_create_funcs *create_funcs);
944562236bSHarry Wentland 
95d9673c92SHarry Wentland struct resource_pool *dc_create_resource_pool(struct dc  *dc,
96d9673c92SHarry Wentland 					      const struct dc_init_data *init_data,
97d9673c92SHarry Wentland 					      enum dce_version dc_version);
984562236bSHarry Wentland 
99fb3466a4SBhawanpreet Lakha void dc_destroy_resource_pool(struct dc *dc);
1004562236bSHarry Wentland 
1014562236bSHarry Wentland enum dc_status resource_map_pool_resources(
102fb3466a4SBhawanpreet Lakha 		const struct dc *dc,
103608ac7bbSJerry Zuo 		struct dc_state *context,
1041dc90497SAndrey Grodzovsky 		struct dc_stream_state *stream);
1054562236bSHarry Wentland 
106b2d0a103SDmytro Laktyushkin bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
1074562236bSHarry Wentland 
1084562236bSHarry Wentland enum dc_status resource_build_scaling_params_for_context(
109fb3466a4SBhawanpreet Lakha 		const struct dc *dc,
110608ac7bbSJerry Zuo 		struct dc_state *context);
1114562236bSHarry Wentland 
1124562236bSHarry Wentland void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
1134562236bSHarry Wentland 
11421e67d4dSHarry Wentland void resource_unreference_clock_source(
1154562236bSHarry Wentland 		struct resource_context *res_ctx,
116a2b8659dSTony Cheng 		const struct resource_pool *pool,
1174a629536SHarry Wentland 		struct clock_source *clock_source);
1184562236bSHarry Wentland 
1194562236bSHarry Wentland void resource_reference_clock_source(
1204562236bSHarry Wentland 		struct resource_context *res_ctx,
121a2b8659dSTony Cheng 		const struct resource_pool *pool,
1224562236bSHarry Wentland 		struct clock_source *clock_source);
1234562236bSHarry Wentland 
124ad8960a6SMikita Lipski int resource_get_clock_source_reference(
125ad8960a6SMikita Lipski 		struct resource_context *res_ctx,
126ad8960a6SMikita Lipski 		const struct resource_pool *pool,
127ad8960a6SMikita Lipski 		struct clock_source *clock_source);
128ad8960a6SMikita Lipski 
1294562236bSHarry Wentland bool resource_are_streams_timing_synchronizable(
1300971c40eSHarry Wentland 		struct dc_stream_state *stream1,
1310971c40eSHarry Wentland 		struct dc_stream_state *stream2);
1324562236bSHarry Wentland 
13377a2b726SVladimir Stempen bool resource_are_vblanks_synchronizable(
13477a2b726SVladimir Stempen 		struct dc_stream_state *stream1,
13577a2b726SVladimir Stempen 		struct dc_stream_state *stream2);
13677a2b726SVladimir Stempen 
1374562236bSHarry Wentland struct clock_source *resource_find_used_clk_src_for_sharing(
1384562236bSHarry Wentland 		struct resource_context *res_ctx,
1394562236bSHarry Wentland 		struct pipe_ctx *pipe_ctx);
1404562236bSHarry Wentland 
1414562236bSHarry Wentland struct clock_source *dc_resource_find_first_free_pll(
142a2b8659dSTony Cheng 		struct resource_context *res_ctx,
143a2b8659dSTony Cheng 		const struct resource_pool *pool);
1444562236bSHarry Wentland 
1454562236bSHarry Wentland bool resource_attach_surfaces_to_context(
1463be5262eSHarry Wentland 		struct dc_plane_state *const *plane_state,
1474562236bSHarry Wentland 		int surface_count,
1480971c40eSHarry Wentland 		struct dc_stream_state *dc_stream,
149608ac7bbSJerry Zuo 		struct dc_state *context,
150a2b8659dSTony Cheng 		const struct resource_pool *pool);
1514562236bSHarry Wentland 
152*53f32880SWenjing Liu #define FREE_PIPE_INDEX_NOT_FOUND -1
1534562236bSHarry Wentland 
154*53f32880SWenjing Liu /*
155*53f32880SWenjing Liu  * pipe types are identified based on MUXes in DCN front end that are capable
156*53f32880SWenjing Liu  * of taking input from one DCN pipeline to another DCN pipeline. The name is
157*53f32880SWenjing Liu  * in a form of XXXX_YYYY, where XXXX is the DCN front end hardware block the
158*53f32880SWenjing Liu  * pipeline ends with and YYYY is the rendering role that the pipe is in.
159*53f32880SWenjing Liu  *
160*53f32880SWenjing Liu  * For instance OTG_MASTER is a pipe ending with OTG hardware block in its
161*53f32880SWenjing Liu  * pipeline and it is in a role of a master pipe for timing generation.
162*53f32880SWenjing Liu  *
163*53f32880SWenjing Liu  * For quick reference a diagram of each pipe type's areas of responsibility
164*53f32880SWenjing Liu  * for outputting timings on the screen is shown below:
165*53f32880SWenjing Liu  *
166*53f32880SWenjing Liu  *       Timing Active for Stream 0
167*53f32880SWenjing Liu  *        __________________________________________________
168*53f32880SWenjing Liu  *       |OTG master 0 (OPP head 0)|OPP head 2 (DPP pipe 2) |
169*53f32880SWenjing Liu  *       |             (DPP pipe 0)|                        |
170*53f32880SWenjing Liu  *       | Top Plane 0             |                        |
171*53f32880SWenjing Liu  *       |           ______________|____                    |
172*53f32880SWenjing Liu  *       |          |DPP pipe 1    |DPP |                   |
173*53f32880SWenjing Liu  *       |          |              |pipe|                   |
174*53f32880SWenjing Liu  *       |          |  Bottom      |3   |                   |
175*53f32880SWenjing Liu  *       |          |  Plane 1     |    |                   |
176*53f32880SWenjing Liu  *       |          |              |    |                   |
177*53f32880SWenjing Liu  *       |          |______________|____|                   |
178*53f32880SWenjing Liu  *       |                         |                        |
179*53f32880SWenjing Liu  *       |                         |                        |
180*53f32880SWenjing Liu  *       | ODM slice 0             | ODM slice 1            |
181*53f32880SWenjing Liu  *       |_________________________|________________________|
182*53f32880SWenjing Liu  *
183*53f32880SWenjing Liu  *       Timing Active for Stream 1
184*53f32880SWenjing Liu  *        __________________________________________________
185*53f32880SWenjing Liu  *       |OTG master 4 (OPP head 4)                         |
186*53f32880SWenjing Liu  *       |                                                  |
187*53f32880SWenjing Liu  *       |                                                  |
188*53f32880SWenjing Liu  *       |                                                  |
189*53f32880SWenjing Liu  *       |                                                  |
190*53f32880SWenjing Liu  *       |                                                  |
191*53f32880SWenjing Liu  *       |               Blank Pixel Data                   |
192*53f32880SWenjing Liu  *       |              (generated by DPG4)                 |
193*53f32880SWenjing Liu  *       |                                                  |
194*53f32880SWenjing Liu  *       |                                                  |
195*53f32880SWenjing Liu  *       |                                                  |
196*53f32880SWenjing Liu  *       |                                                  |
197*53f32880SWenjing Liu  *       |                                                  |
198*53f32880SWenjing Liu  *       |__________________________________________________|
199*53f32880SWenjing Liu  *
200*53f32880SWenjing Liu  *       Inter-pipe Relation
201*53f32880SWenjing Liu  *        __________________________________________________
202*53f32880SWenjing Liu  *       |PIPE IDX|   DPP PIPES   | OPP HEADS | OTG MASTER  |
203*53f32880SWenjing Liu  *       |        |  plane 0      | slice 0   |             |
204*53f32880SWenjing Liu  *       |   0    | -------------MPC---------ODM----------- |
205*53f32880SWenjing Liu  *       |        |  plane 1    | |         | |             |
206*53f32880SWenjing Liu  *       |   1    | ------------- |         | |             |
207*53f32880SWenjing Liu  *       |        |  plane 0      | slice 1 | |             |
208*53f32880SWenjing Liu  *       |   2    | -------------MPC--------- |             |
209*53f32880SWenjing Liu  *       |        |  plane 1    | |           |             |
210*53f32880SWenjing Liu  *       |   3    | ------------- |           |             |
211*53f32880SWenjing Liu  *       |        |               | blank     |             |
212*53f32880SWenjing Liu  *       |   4    |               | ----------------------- |
213*53f32880SWenjing Liu  *       |        |               |           |             |
214*53f32880SWenjing Liu  *       |   5    |  (FREE)       |           |             |
215*53f32880SWenjing Liu  *       |________|_______________|___________|_____________|
216*53f32880SWenjing Liu  */
217*53f32880SWenjing Liu enum pipe_type {
218*53f32880SWenjing Liu 	/* free pipe - free pipe is an uninitialized pipe without a stream
219*53f32880SWenjing Liu 	 * associated with it. It is a free DCN pipe resource. It can be
220*53f32880SWenjing Liu 	 * acquired as any type of pipe.
221*53f32880SWenjing Liu 	 */
222*53f32880SWenjing Liu 	FREE_PIPE,
223*53f32880SWenjing Liu 
224*53f32880SWenjing Liu 	/* OTG master pipe - the master pipe of its OPP head pipes with a
225*53f32880SWenjing Liu 	 * functional OTG. It merges all its OPP head pipes pixel data in ODM
226*53f32880SWenjing Liu 	 * block and output to backend DIG. OTG master pipe is responsible for
227*53f32880SWenjing Liu 	 * generating entire crtc timing to backend DIG. An OTG master pipe may
228*53f32880SWenjing Liu 	 * or may not have a plane. If it has a plane it blends it as the left
229*53f32880SWenjing Liu 	 * most MPC slice of the top most layer. If it doesn't have a plane it
230*53f32880SWenjing Liu 	 * can output pixel data from its OPP head pipes' test pattern
231*53f32880SWenjing Liu 	 * generators (DPG) such as solid black pixel data to blank the screen.
232*53f32880SWenjing Liu 	 */
233*53f32880SWenjing Liu 	OTG_MASTER,
234*53f32880SWenjing Liu 
235*53f32880SWenjing Liu 	/* OPP head pipe - the head pipe of an MPC blending tree with a
236*53f32880SWenjing Liu 	 * functional OPP outputting to an OTG. OPP head pipe is responsible for
237*53f32880SWenjing Liu 	 * processing output pixels in its own ODM slice. It may or may not have
238*53f32880SWenjing Liu 	 * a plane. If it has a plane it blends it as the top most layer within
239*53f32880SWenjing Liu 	 * its own ODM slice. If it doesn't have a plane it can output pixel
240*53f32880SWenjing Liu 	 * data from its DPG such as solid black pixel data to blank the pixel
241*53f32880SWenjing Liu 	 * data in its own ODM slice. OTG master pipe is also an OPP head pipe
242*53f32880SWenjing Liu 	 * but with more responsibility.
243*53f32880SWenjing Liu 	 */
244*53f32880SWenjing Liu 	OPP_HEAD,
245*53f32880SWenjing Liu 
246*53f32880SWenjing Liu 	/* DPP pipe - the pipe with a functional DPP outputting to an OPP head
247*53f32880SWenjing Liu 	 * pipe's MPC. DPP pipe is responsible for processing pixel data from
248*53f32880SWenjing Liu 	 * its own MPC slice of a plane. It must be connected to an OPP head
249*53f32880SWenjing Liu 	 * pipe and it must have a plane associated with it.
250*53f32880SWenjing Liu 	 */
251*53f32880SWenjing Liu 	DPP_PIPE,
252*53f32880SWenjing Liu };
253*53f32880SWenjing Liu 
254*53f32880SWenjing Liu /*
255*53f32880SWenjing Liu  * Determine if the input pipe ctx is of a pipe type.
256*53f32880SWenjing Liu  * return - true if pipe ctx is of the input type.
257*53f32880SWenjing Liu  */
258*53f32880SWenjing Liu bool resource_is_pipe_type(const struct pipe_ctx *pipe_ctx, enum pipe_type type);
259*53f32880SWenjing Liu 
260*53f32880SWenjing Liu /*
261*53f32880SWenjing Liu  * Determine if the input pipe ctx is used for rendering a plane with MPCC
262*53f32880SWenjing Liu  * combine. MPCC combine is a hardware feature to combine multiple DPP pipes
263*53f32880SWenjing Liu  * into a single plane. It is typically used for bypassing pipe bandwidth
264*53f32880SWenjing Liu  * limitation for rendering a very large plane or saving power by reducing UCLK
265*53f32880SWenjing Liu  * and DPPCLK speeds.
266*53f32880SWenjing Liu  *
267*53f32880SWenjing Liu  * For instance in the Inter-pipe Relation diagram shown below, both PIPE 0 and
268*53f32880SWenjing Liu  * 1 are for MPCC combine for plane 0
269*53f32880SWenjing Liu  *
270*53f32880SWenjing Liu  *       Inter-pipe Relation
271*53f32880SWenjing Liu  *        __________________________________________________
272*53f32880SWenjing Liu  *       |PIPE IDX|   DPP PIPES   | OPP HEADS | OTG MASTER  |
273*53f32880SWenjing Liu  *       |        |  plane 0      |           |             |
274*53f32880SWenjing Liu  *       |   0    | -------------MPC----------------------- |
275*53f32880SWenjing Liu  *       |        |  plane 0    | |           |             |
276*53f32880SWenjing Liu  *       |   1    | ------------- |           |             |
277*53f32880SWenjing Liu  *       |________|_______________|___________|_____________|
278*53f32880SWenjing Liu  *
279*53f32880SWenjing Liu  * return - true if pipe ctx is used for mpcc combine.
280*53f32880SWenjing Liu  */
281*53f32880SWenjing Liu bool resource_is_for_mpcc_combine(const struct pipe_ctx *pipe_ctx);
282*53f32880SWenjing Liu 
283*53f32880SWenjing Liu /*
284*53f32880SWenjing Liu  * Look for a free pipe in new resource context that is used as a secondary DPP
285*53f32880SWenjing Liu  * pipe in MPC blending tree associated with input OPP head pipe.
286*53f32880SWenjing Liu  *
287*53f32880SWenjing Liu  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
288*53f32880SWenjing Liu  * pipe idx of the free pipe
289*53f32880SWenjing Liu  */
290198f0e89SWenjing Liu int resource_find_free_pipe_used_in_cur_mpc_blending_tree(
291460ea898SWenjing Liu 		const struct resource_context *cur_res_ctx,
292460ea898SWenjing Liu 		struct resource_context *new_res_ctx,
293d8e3fcd3SWenjing Liu 		const struct pipe_ctx *cur_opp_head);
294d8e3fcd3SWenjing Liu 
295*53f32880SWenjing Liu /*
296*53f32880SWenjing Liu  * Look for a free pipe in new resource context that is not used in current
297*53f32880SWenjing Liu  * resource context.
298*53f32880SWenjing Liu  *
299*53f32880SWenjing Liu  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
300*53f32880SWenjing Liu  * pipe idx of the free pipe
301*53f32880SWenjing Liu  */
302198f0e89SWenjing Liu int recource_find_free_pipe_not_used_in_cur_res_ctx(
303d8e3fcd3SWenjing Liu 		const struct resource_context *cur_res_ctx,
304d8e3fcd3SWenjing Liu 		struct resource_context *new_res_ctx,
305d8e3fcd3SWenjing Liu 		const struct resource_pool *pool);
306d8e3fcd3SWenjing Liu 
307*53f32880SWenjing Liu /*
308*53f32880SWenjing Liu  * Look for a free pipe in new resource context that is used as a secondary DPP
309*53f32880SWenjing Liu  * pipe in any MPCC combine in current resource context.
310*53f32880SWenjing Liu  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
311*53f32880SWenjing Liu  * pipe idx of the free pipe
312*53f32880SWenjing Liu  */
313198f0e89SWenjing Liu int resource_find_free_pipe_used_as_cur_sec_dpp_in_mpcc_combine(
314d8e3fcd3SWenjing Liu 		const struct resource_context *cur_res_ctx,
315d8e3fcd3SWenjing Liu 		struct resource_context *new_res_ctx,
316d8e3fcd3SWenjing Liu 		const struct resource_pool *pool);
317d8e3fcd3SWenjing Liu 
318*53f32880SWenjing Liu /*
319*53f32880SWenjing Liu  * Look for any free pipe in new resource context.
320*53f32880SWenjing Liu  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
321*53f32880SWenjing Liu  * pipe idx of the free pipe
322*53f32880SWenjing Liu  */
323198f0e89SWenjing Liu int resource_find_any_free_pipe(struct resource_context *new_res_ctx,
324d8e3fcd3SWenjing Liu 		const struct resource_pool *pool);
325460ea898SWenjing Liu 
326*53f32880SWenjing Liu /*
327*53f32880SWenjing Liu  * Legacy find free secondary pipe logic deprecated for newer DCNs as it doesn't
328*53f32880SWenjing Liu  * find the most optimal free pipe to prevent from time consuming hardware state
329*53f32880SWenjing Liu  * transitions.
330*53f32880SWenjing Liu  */
331*53f32880SWenjing Liu struct pipe_ctx *resource_find_free_secondary_pipe_legacy(
332*53f32880SWenjing Liu 		struct resource_context *res_ctx,
333*53f32880SWenjing Liu 		const struct resource_pool *pool,
334*53f32880SWenjing Liu 		const struct pipe_ctx *primary_pipe);
335*53f32880SWenjing Liu 
336*53f32880SWenjing Liu /*
337*53f32880SWenjing Liu  * Get number of MPC "cuts" of the plane associated with the pipe. MPC slice
338*53f32880SWenjing Liu  * count is equal to MPC splits + 1. For example if a plane is cut 3 times, it
339*53f32880SWenjing Liu  * will have 4 pieces of slice.
340*53f32880SWenjing Liu  * return - 0 if pipe is not used for a plane with MPCC combine. otherwise
341*53f32880SWenjing Liu  * the number of MPC "cuts" for the plane.
342*53f32880SWenjing Liu  */
343*53f32880SWenjing Liu int resource_get_num_mpc_splits(const struct pipe_ctx *pipe);
344*53f32880SWenjing Liu 
345*53f32880SWenjing Liu /*
346*53f32880SWenjing Liu  * Get number of ODM "cuts" of the timing associated with the pipe. ODM slice
347*53f32880SWenjing Liu  * count is equal to ODM splits + 1. For example if a timing is cut 3 times, it
348*53f32880SWenjing Liu  * will have 4 pieces of slice.
349*53f32880SWenjing Liu  * return - 0 if pipe is not used for ODM combine. otherwise
350*53f32880SWenjing Liu  * the number of ODM "cuts" for the timing.
351*53f32880SWenjing Liu  */
352*53f32880SWenjing Liu int resource_get_num_odm_splits(const struct pipe_ctx *pipe);
353*53f32880SWenjing Liu 
354*53f32880SWenjing Liu /*
355*53f32880SWenjing Liu  * Get the OTG master pipe in resource context associated with the stream.
356*53f32880SWenjing Liu  * return - NULL if not found. Otherwise the OTG master pipe associated with the
357*53f32880SWenjing Liu  * stream.
358*53f32880SWenjing Liu  */
359*53f32880SWenjing Liu struct pipe_ctx *resource_get_otg_master_for_stream(
360*53f32880SWenjing Liu 		struct resource_context *res_ctx,
361*53f32880SWenjing Liu 		struct dc_stream_state *stream);
362*53f32880SWenjing Liu 
363*53f32880SWenjing Liu /*
364*53f32880SWenjing Liu  * Get the OTG master pipe for the input pipe context.
365*53f32880SWenjing Liu  * return - the OTG master pipe for the input pipe
366*53f32880SWenjing Liu  * context.
367*53f32880SWenjing Liu  */
368*53f32880SWenjing Liu struct pipe_ctx *resource_get_otg_master(const struct pipe_ctx *pipe_ctx);
369*53f32880SWenjing Liu 
370*53f32880SWenjing Liu /*
371*53f32880SWenjing Liu  * Get the OPP head pipe for the input pipe context.
372*53f32880SWenjing Liu  * return - the OPP head pipe for the input pipe
373*53f32880SWenjing Liu  * context.
374*53f32880SWenjing Liu  */
375*53f32880SWenjing Liu struct pipe_ctx *resource_get_opp_head(const struct pipe_ctx *pipe_ctx);
376*53f32880SWenjing Liu 
377*53f32880SWenjing Liu 
3784562236bSHarry Wentland bool resource_validate_attach_surfaces(
3794562236bSHarry Wentland 		const struct dc_validation_set set[],
3804562236bSHarry Wentland 		int set_count,
381608ac7bbSJerry Zuo 		const struct dc_state *old_context,
382608ac7bbSJerry Zuo 		struct dc_state *context,
383a2b8659dSTony Cheng 		const struct resource_pool *pool);
3844562236bSHarry Wentland 
3854562236bSHarry Wentland enum dc_status resource_map_clock_resources(
386fb3466a4SBhawanpreet Lakha 		const struct dc *dc,
387608ac7bbSJerry Zuo 		struct dc_state *context,
3881dc90497SAndrey Grodzovsky 		struct dc_stream_state *stream);
3894562236bSHarry Wentland 
3904562236bSHarry Wentland enum dc_status resource_map_phy_clock_resources(
391fb3466a4SBhawanpreet Lakha 		const struct dc *dc,
392608ac7bbSJerry Zuo 		struct dc_state *context,
3931dc90497SAndrey Grodzovsky 		struct dc_stream_state *stream);
3944562236bSHarry Wentland 
3954562236bSHarry Wentland bool pipe_need_reprogram(
3964562236bSHarry Wentland 		struct pipe_ctx *pipe_ctx_old,
3974562236bSHarry Wentland 		struct pipe_ctx *pipe_ctx);
3984562236bSHarry Wentland 
3990971c40eSHarry Wentland void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
400529cad0fSDing Wang 		struct bit_depth_reduction_params *fmt_bit_depth);
4014562236bSHarry Wentland 
4024176664bSCharlene Liu void update_audio_usage(
4034176664bSCharlene Liu 		struct resource_context *res_ctx,
4044176664bSCharlene Liu 		const struct resource_pool *pool,
4054176664bSCharlene Liu 		struct audio *audio,
4064176664bSCharlene Liu 		bool acquired);
40774eac5f3SSu Sung Chung 
40874eac5f3SSu Sung Chung unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format);
40974eac5f3SSu Sung Chung 
4103ab4cc65SCharlene Liu void get_audio_check(struct audio_info *aud_modes,
4113ab4cc65SCharlene Liu 	struct audio_check *aud_chk);
412228a10d4SAlex Deucher 
4132426d71cSWenjing Liu bool get_temp_dp_link_res(struct dc_link *link,
4142426d71cSWenjing Liu 		struct link_resource *link_res,
4152426d71cSWenjing Liu 		struct dc_link_settings *link_settings);
416f01ee019SFangzhi Zuo 
4174652ae7aSHarry Wentland #if defined(CONFIG_DRM_AMD_DC_FP)
418d3dfceb5SAurabindo Pillai struct hpo_dp_link_encoder *resource_get_hpo_dp_link_enc_for_det_lt(
419d3dfceb5SAurabindo Pillai 		const struct resource_context *res_ctx,
420d3dfceb5SAurabindo Pillai 		const struct resource_pool *pool,
421d3dfceb5SAurabindo Pillai 		const struct dc_link *link);
422d3dfceb5SAurabindo Pillai #endif
423d3dfceb5SAurabindo Pillai 
4245f0c7491SMeenakshikumar Somasundaram void reset_syncd_pipes_from_disabled_pipes(struct dc *dc,
4255f0c7491SMeenakshikumar Somasundaram 	struct dc_state *context);
4265f0c7491SMeenakshikumar Somasundaram 
4275f0c7491SMeenakshikumar Somasundaram void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc,
4285f0c7491SMeenakshikumar Somasundaram 	struct dc_state *context,
4295f0c7491SMeenakshikumar Somasundaram 	uint8_t disabled_master_pipe_idx);
4305f0c7491SMeenakshikumar Somasundaram 
431abffd871SMeenakshikumar Somasundaram void reset_sync_context_for_pipe(const struct dc *dc,
432abffd871SMeenakshikumar Somasundaram 	struct dc_state *context,
433abffd871SMeenakshikumar Somasundaram 	uint8_t pipe_idx);
434abffd871SMeenakshikumar Somasundaram 
435580013b2SWenjing Liu uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter);
436a896f870SMeenakshikumar Somasundaram 
4372750caffSWenjing Liu const struct link_hwss *get_link_hwss(const struct dc_link *link,
4382750caffSWenjing Liu 		const struct link_resource *link_res);
4392750caffSWenjing Liu 
4406349c738SAlvin Lee bool is_h_timing_divisible_by_2(struct dc_stream_state *stream);
4416349c738SAlvin Lee 
44220dad381SJun Lei bool dc_resource_acquire_secondary_pipe_for_mpc_odm(
44320dad381SJun Lei 		const struct dc *dc,
44420dad381SJun Lei 		struct dc_state *state,
44520dad381SJun Lei 		struct pipe_ctx *pri_pipe,
44620dad381SJun Lei 		struct pipe_ctx *sec_pipe,
44720dad381SJun Lei 		bool odm);
4480e8cf83aSWenjing Liu 
4490e8cf83aSWenjing Liu /* A test harness interface that modifies dp encoder resources in the given dc
4500e8cf83aSWenjing Liu  * state and bypasses the need to revalidate. The interface assumes that the
4510e8cf83aSWenjing Liu  * test harness interface is called with pre-validated link config stored in the
4520e8cf83aSWenjing Liu  * pipe_ctx and updates dp encoder resources according to the link config.
4530e8cf83aSWenjing Liu  */
4540e8cf83aSWenjing Liu enum dc_status update_dp_encoder_resources_for_test_harness(const struct dc *dc,
4550e8cf83aSWenjing Liu 		struct dc_state *context,
4560e8cf83aSWenjing Liu 		struct pipe_ctx *pipe_ctx);
4574562236bSHarry Wentland #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
458