xref: /openbsd-src/sys/dev/pci/drm/amd/display/dc/inc/resource.h (revision f005ef32267c16bdb134f0e9fa4477dbe07c263a)
1fb4d8502Sjsg /*
2fb4d8502Sjsg  * Copyright 2015 Advanced Micro Devices, Inc.
3fb4d8502Sjsg  *
4fb4d8502Sjsg  * Permission is hereby granted, free of charge, to any person obtaining a
5fb4d8502Sjsg  * copy of this software and associated documentation files (the "Software"),
6fb4d8502Sjsg  * to deal in the Software without restriction, including without limitation
7fb4d8502Sjsg  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8fb4d8502Sjsg  * and/or sell copies of the Software, and to permit persons to whom the
9fb4d8502Sjsg  * Software is furnished to do so, subject to the following conditions:
10fb4d8502Sjsg  *
11fb4d8502Sjsg  * The above copyright notice and this permission notice shall be included in
12fb4d8502Sjsg  * all copies or substantial portions of the Software.
13fb4d8502Sjsg  *
14fb4d8502Sjsg  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15fb4d8502Sjsg  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16fb4d8502Sjsg  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17fb4d8502Sjsg  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18fb4d8502Sjsg  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19fb4d8502Sjsg  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20fb4d8502Sjsg  * OTHER DEALINGS IN THE SOFTWARE.
21fb4d8502Sjsg  *
22fb4d8502Sjsg  * Authors: AMD
23fb4d8502Sjsg  */
24fb4d8502Sjsg 
25fb4d8502Sjsg #ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
26fb4d8502Sjsg #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
27fb4d8502Sjsg 
28fb4d8502Sjsg #include "core_types.h"
29fb4d8502Sjsg #include "core_status.h"
30fb4d8502Sjsg #include "dal_asic_id.h"
31fb4d8502Sjsg #include "dm_pp_smu.h"
32fb4d8502Sjsg 
33c349dbc7Sjsg #define MEMORY_TYPE_MULTIPLIER_CZ 4
34c349dbc7Sjsg #define MEMORY_TYPE_HBM 2
35c349dbc7Sjsg 
36fb4d8502Sjsg 
371bb76ff1Sjsg #define IS_PIPE_SYNCD_VALID(pipe) ((((pipe)->pipe_idx_syncd) & 0x80)?1:0)
381bb76ff1Sjsg #define GET_PIPE_SYNCD_FROM_PIPE(pipe) ((pipe)->pipe_idx_syncd & 0x7F)
391bb76ff1Sjsg #define SET_PIPE_SYNCD_TO_PIPE(pipe, pipe_syncd) ((pipe)->pipe_idx_syncd = (0x80 | pipe_syncd))
401bb76ff1Sjsg 
41fb4d8502Sjsg enum dce_version resource_parse_asic_id(
42fb4d8502Sjsg 		struct hw_asic_id asic_id);
43fb4d8502Sjsg 
44fb4d8502Sjsg struct resource_caps {
45fb4d8502Sjsg 	int num_timing_generator;
46fb4d8502Sjsg 	int num_opp;
47fb4d8502Sjsg 	int num_video_plane;
48fb4d8502Sjsg 	int num_audio;
49fb4d8502Sjsg 	int num_stream_encoder;
50fb4d8502Sjsg 	int num_pll;
51fb4d8502Sjsg 	int num_dwb;
5253d3d132Sjsg 	int num_ddc;
53c349dbc7Sjsg 	int num_vmid;
54c349dbc7Sjsg 	int num_dsc;
555ca02815Sjsg 	unsigned int num_dig_link_enc; // Total number of DIGs (digital encoders) in DIO (Display Input/Output).
561bb76ff1Sjsg 	unsigned int num_usb4_dpia; // Total number of USB4 DPIA (DisplayPort Input Adapters).
571bb76ff1Sjsg 	int num_hpo_dp_stream_encoder;
581bb76ff1Sjsg 	int num_hpo_dp_link_encoder;
59ad8b1aafSjsg 	int num_mpc_3dlut;
60fb4d8502Sjsg };
61fb4d8502Sjsg 
62fb4d8502Sjsg struct resource_straps {
63fb4d8502Sjsg 	uint32_t hdmi_disable;
64fb4d8502Sjsg 	uint32_t dc_pinstraps_audio;
65fb4d8502Sjsg 	uint32_t audio_stream_number;
66fb4d8502Sjsg };
67fb4d8502Sjsg 
68fb4d8502Sjsg struct resource_create_funcs {
69fb4d8502Sjsg 	void (*read_dce_straps)(
70fb4d8502Sjsg 			struct dc_context *ctx, struct resource_straps *straps);
71fb4d8502Sjsg 
72fb4d8502Sjsg 	struct audio *(*create_audio)(
73fb4d8502Sjsg 			struct dc_context *ctx, unsigned int inst);
74fb4d8502Sjsg 
75fb4d8502Sjsg 	struct stream_encoder *(*create_stream_encoder)(
76fb4d8502Sjsg 			enum engine_id eng_id, struct dc_context *ctx);
77fb4d8502Sjsg 
781bb76ff1Sjsg 	struct hpo_dp_stream_encoder *(*create_hpo_dp_stream_encoder)(
791bb76ff1Sjsg 			enum engine_id eng_id, struct dc_context *ctx);
801bb76ff1Sjsg 
811bb76ff1Sjsg 	struct hpo_dp_link_encoder *(*create_hpo_dp_link_encoder)(
821bb76ff1Sjsg 			uint8_t inst,
831bb76ff1Sjsg 			struct dc_context *ctx);
841bb76ff1Sjsg 
85fb4d8502Sjsg 	struct dce_hwseq *(*create_hwseq)(
86fb4d8502Sjsg 			struct dc_context *ctx);
87fb4d8502Sjsg };
88fb4d8502Sjsg 
89fb4d8502Sjsg bool resource_construct(
90fb4d8502Sjsg 	unsigned int num_virtual_links,
91fb4d8502Sjsg 	struct dc *dc,
92fb4d8502Sjsg 	struct resource_pool *pool,
93fb4d8502Sjsg 	const struct resource_create_funcs *create_funcs);
94fb4d8502Sjsg 
95c349dbc7Sjsg struct resource_pool *dc_create_resource_pool(struct dc  *dc,
96c349dbc7Sjsg 					      const struct dc_init_data *init_data,
97c349dbc7Sjsg 					      enum dce_version dc_version);
98fb4d8502Sjsg 
99fb4d8502Sjsg void dc_destroy_resource_pool(struct dc *dc);
100fb4d8502Sjsg 
101fb4d8502Sjsg enum dc_status resource_map_pool_resources(
102fb4d8502Sjsg 		const struct dc *dc,
103fb4d8502Sjsg 		struct dc_state *context,
104fb4d8502Sjsg 		struct dc_stream_state *stream);
105fb4d8502Sjsg 
106fb4d8502Sjsg bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
107fb4d8502Sjsg 
108fb4d8502Sjsg enum dc_status resource_build_scaling_params_for_context(
109fb4d8502Sjsg 		const struct dc *dc,
110fb4d8502Sjsg 		struct dc_state *context);
111fb4d8502Sjsg 
112fb4d8502Sjsg void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
113fb4d8502Sjsg 
114fb4d8502Sjsg void resource_unreference_clock_source(
115fb4d8502Sjsg 		struct resource_context *res_ctx,
116fb4d8502Sjsg 		const struct resource_pool *pool,
117fb4d8502Sjsg 		struct clock_source *clock_source);
118fb4d8502Sjsg 
119fb4d8502Sjsg void resource_reference_clock_source(
120fb4d8502Sjsg 		struct resource_context *res_ctx,
121fb4d8502Sjsg 		const struct resource_pool *pool,
122fb4d8502Sjsg 		struct clock_source *clock_source);
123fb4d8502Sjsg 
124fb4d8502Sjsg int resource_get_clock_source_reference(
125fb4d8502Sjsg 		struct resource_context *res_ctx,
126fb4d8502Sjsg 		const struct resource_pool *pool,
127fb4d8502Sjsg 		struct clock_source *clock_source);
128fb4d8502Sjsg 
129fb4d8502Sjsg bool resource_are_streams_timing_synchronizable(
130fb4d8502Sjsg 		struct dc_stream_state *stream1,
131fb4d8502Sjsg 		struct dc_stream_state *stream2);
132fb4d8502Sjsg 
1335ca02815Sjsg bool resource_are_vblanks_synchronizable(
1345ca02815Sjsg 		struct dc_stream_state *stream1,
1355ca02815Sjsg 		struct dc_stream_state *stream2);
1365ca02815Sjsg 
137fb4d8502Sjsg struct clock_source *resource_find_used_clk_src_for_sharing(
138fb4d8502Sjsg 		struct resource_context *res_ctx,
139fb4d8502Sjsg 		struct pipe_ctx *pipe_ctx);
140fb4d8502Sjsg 
141fb4d8502Sjsg struct clock_source *dc_resource_find_first_free_pll(
142fb4d8502Sjsg 		struct resource_context *res_ctx,
143fb4d8502Sjsg 		const struct resource_pool *pool);
144fb4d8502Sjsg 
145fb4d8502Sjsg bool resource_attach_surfaces_to_context(
146fb4d8502Sjsg 		struct dc_plane_state *const *plane_state,
147fb4d8502Sjsg 		int surface_count,
148fb4d8502Sjsg 		struct dc_stream_state *dc_stream,
149fb4d8502Sjsg 		struct dc_state *context,
150fb4d8502Sjsg 		const struct resource_pool *pool);
151fb4d8502Sjsg 
152*f005ef32Sjsg #define FREE_PIPE_INDEX_NOT_FOUND -1
153*f005ef32Sjsg 
154*f005ef32Sjsg /*
155*f005ef32Sjsg  * pipe types are identified based on MUXes in DCN front end that are capable
156*f005ef32Sjsg  * of taking input from one DCN pipeline to another DCN pipeline. The name is
157*f005ef32Sjsg  * in a form of XXXX_YYYY, where XXXX is the DCN front end hardware block the
158*f005ef32Sjsg  * pipeline ends with and YYYY is the rendering role that the pipe is in.
159*f005ef32Sjsg  *
160*f005ef32Sjsg  * For instance OTG_MASTER is a pipe ending with OTG hardware block in its
161*f005ef32Sjsg  * pipeline and it is in a role of a master pipe for timing generation.
162*f005ef32Sjsg  *
163*f005ef32Sjsg  * For quick reference a diagram of each pipe type's areas of responsibility
164*f005ef32Sjsg  * for outputting timings on the screen is shown below:
165*f005ef32Sjsg  *
166*f005ef32Sjsg  *       Timing Active for Stream 0
167*f005ef32Sjsg  *        __________________________________________________
168*f005ef32Sjsg  *       |OTG master 0 (OPP head 0)|OPP head 2 (DPP pipe 2) |
169*f005ef32Sjsg  *       |             (DPP pipe 0)|                        |
170*f005ef32Sjsg  *       | Top Plane 0             |                        |
171*f005ef32Sjsg  *       |           ______________|____                    |
172*f005ef32Sjsg  *       |          |DPP pipe 1    |DPP |                   |
173*f005ef32Sjsg  *       |          |              |pipe|                   |
174*f005ef32Sjsg  *       |          |  Bottom      |3   |                   |
175*f005ef32Sjsg  *       |          |  Plane 1     |    |                   |
176*f005ef32Sjsg  *       |          |              |    |                   |
177*f005ef32Sjsg  *       |          |______________|____|                   |
178*f005ef32Sjsg  *       |                         |                        |
179*f005ef32Sjsg  *       |                         |                        |
180*f005ef32Sjsg  *       | ODM slice 0             | ODM slice 1            |
181*f005ef32Sjsg  *       |_________________________|________________________|
182*f005ef32Sjsg  *
183*f005ef32Sjsg  *       Timing Active for Stream 1
184*f005ef32Sjsg  *        __________________________________________________
185*f005ef32Sjsg  *       |OTG master 4 (OPP head 4)                         |
186*f005ef32Sjsg  *       |                                                  |
187*f005ef32Sjsg  *       |                                                  |
188*f005ef32Sjsg  *       |                                                  |
189*f005ef32Sjsg  *       |                                                  |
190*f005ef32Sjsg  *       |                                                  |
191*f005ef32Sjsg  *       |               Blank Pixel Data                   |
192*f005ef32Sjsg  *       |              (generated by DPG4)                 |
193*f005ef32Sjsg  *       |                                                  |
194*f005ef32Sjsg  *       |                                                  |
195*f005ef32Sjsg  *       |                                                  |
196*f005ef32Sjsg  *       |                                                  |
197*f005ef32Sjsg  *       |                                                  |
198*f005ef32Sjsg  *       |__________________________________________________|
199*f005ef32Sjsg  *
200*f005ef32Sjsg  *       Inter-pipe Relation
201*f005ef32Sjsg  *        __________________________________________________
202*f005ef32Sjsg  *       |PIPE IDX|   DPP PIPES   | OPP HEADS | OTG MASTER  |
203*f005ef32Sjsg  *       |        |  plane 0      | slice 0   |             |
204*f005ef32Sjsg  *       |   0    | -------------MPC---------ODM----------- |
205*f005ef32Sjsg  *       |        |  plane 1    | |         | |             |
206*f005ef32Sjsg  *       |   1    | ------------- |         | |             |
207*f005ef32Sjsg  *       |        |  plane 0      | slice 1 | |             |
208*f005ef32Sjsg  *       |   2    | -------------MPC--------- |             |
209*f005ef32Sjsg  *       |        |  plane 1    | |           |             |
210*f005ef32Sjsg  *       |   3    | ------------- |           |             |
211*f005ef32Sjsg  *       |        |               | blank     |             |
212*f005ef32Sjsg  *       |   4    |               | ----------------------- |
213*f005ef32Sjsg  *       |        |               |           |             |
214*f005ef32Sjsg  *       |   5    |  (FREE)       |           |             |
215*f005ef32Sjsg  *       |________|_______________|___________|_____________|
216*f005ef32Sjsg  */
217*f005ef32Sjsg enum pipe_type {
218*f005ef32Sjsg 	/* free pipe - free pipe is an uninitialized pipe without a stream
219*f005ef32Sjsg 	 * associated with it. It is a free DCN pipe resource. It can be
220*f005ef32Sjsg 	 * acquired as any type of pipe.
221*f005ef32Sjsg 	 */
222*f005ef32Sjsg 	FREE_PIPE,
223*f005ef32Sjsg 
224*f005ef32Sjsg 	/* OTG master pipe - the master pipe of its OPP head pipes with a
225*f005ef32Sjsg 	 * functional OTG. It merges all its OPP head pipes pixel data in ODM
226*f005ef32Sjsg 	 * block and output to backend DIG. OTG master pipe is responsible for
227*f005ef32Sjsg 	 * generating entire crtc timing to backend DIG. An OTG master pipe may
228*f005ef32Sjsg 	 * or may not have a plane. If it has a plane it blends it as the left
229*f005ef32Sjsg 	 * most MPC slice of the top most layer. If it doesn't have a plane it
230*f005ef32Sjsg 	 * can output pixel data from its OPP head pipes' test pattern
231*f005ef32Sjsg 	 * generators (DPG) such as solid black pixel data to blank the screen.
232*f005ef32Sjsg 	 */
233*f005ef32Sjsg 	OTG_MASTER,
234*f005ef32Sjsg 
235*f005ef32Sjsg 	/* OPP head pipe - the head pipe of an MPC blending tree with a
236*f005ef32Sjsg 	 * functional OPP outputting to an OTG. OPP head pipe is responsible for
237*f005ef32Sjsg 	 * processing output pixels in its own ODM slice. It may or may not have
238*f005ef32Sjsg 	 * a plane. If it has a plane it blends it as the top most layer within
239*f005ef32Sjsg 	 * its own ODM slice. If it doesn't have a plane it can output pixel
240*f005ef32Sjsg 	 * data from its DPG such as solid black pixel data to blank the pixel
241*f005ef32Sjsg 	 * data in its own ODM slice. OTG master pipe is also an OPP head pipe
242*f005ef32Sjsg 	 * but with more responsibility.
243*f005ef32Sjsg 	 */
244*f005ef32Sjsg 	OPP_HEAD,
245*f005ef32Sjsg 
246*f005ef32Sjsg 	/* DPP pipe - the pipe with a functional DPP outputting to an OPP head
247*f005ef32Sjsg 	 * pipe's MPC. DPP pipe is responsible for processing pixel data from
248*f005ef32Sjsg 	 * its own MPC slice of a plane. It must be connected to an OPP head
249*f005ef32Sjsg 	 * pipe and it must have a plane associated with it.
250*f005ef32Sjsg 	 */
251*f005ef32Sjsg 	DPP_PIPE,
252*f005ef32Sjsg };
253*f005ef32Sjsg 
254*f005ef32Sjsg /*
255*f005ef32Sjsg  * Determine if the input pipe ctx is of a pipe type.
256*f005ef32Sjsg  * return - true if pipe ctx is of the input type.
257*f005ef32Sjsg  */
258*f005ef32Sjsg bool resource_is_pipe_type(const struct pipe_ctx *pipe_ctx, enum pipe_type type);
259*f005ef32Sjsg 
260*f005ef32Sjsg /*
261*f005ef32Sjsg  * Determine if the input pipe ctx is used for rendering a plane with MPCC
262*f005ef32Sjsg  * combine. MPCC combine is a hardware feature to combine multiple DPP pipes
263*f005ef32Sjsg  * into a single plane. It is typically used for bypassing pipe bandwidth
264*f005ef32Sjsg  * limitation for rendering a very large plane or saving power by reducing UCLK
265*f005ef32Sjsg  * and DPPCLK speeds.
266*f005ef32Sjsg  *
267*f005ef32Sjsg  * For instance in the Inter-pipe Relation diagram shown below, both PIPE 0 and
268*f005ef32Sjsg  * 1 are for MPCC combine for plane 0
269*f005ef32Sjsg  *
270*f005ef32Sjsg  *       Inter-pipe Relation
271*f005ef32Sjsg  *        __________________________________________________
272*f005ef32Sjsg  *       |PIPE IDX|   DPP PIPES   | OPP HEADS | OTG MASTER  |
273*f005ef32Sjsg  *       |        |  plane 0      |           |             |
274*f005ef32Sjsg  *       |   0    | -------------MPC----------------------- |
275*f005ef32Sjsg  *       |        |  plane 0    | |           |             |
276*f005ef32Sjsg  *       |   1    | ------------- |           |             |
277*f005ef32Sjsg  *       |________|_______________|___________|_____________|
278*f005ef32Sjsg  *
279*f005ef32Sjsg  * return - true if pipe ctx is used for mpcc combine.
280*f005ef32Sjsg  */
281*f005ef32Sjsg bool resource_is_for_mpcc_combine(const struct pipe_ctx *pipe_ctx);
282*f005ef32Sjsg 
283*f005ef32Sjsg /*
284*f005ef32Sjsg  * Look for a free pipe in new resource context that is used as a secondary DPP
285*f005ef32Sjsg  * pipe in MPC blending tree associated with input OPP head pipe.
286*f005ef32Sjsg  *
287*f005ef32Sjsg  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
288*f005ef32Sjsg  * pipe idx of the free pipe
289*f005ef32Sjsg  */
290*f005ef32Sjsg int resource_find_free_pipe_used_in_cur_mpc_blending_tree(
291*f005ef32Sjsg 		const struct resource_context *cur_res_ctx,
292*f005ef32Sjsg 		struct resource_context *new_res_ctx,
293*f005ef32Sjsg 		const struct pipe_ctx *cur_opp_head);
294*f005ef32Sjsg 
295*f005ef32Sjsg /*
296*f005ef32Sjsg  * Look for a free pipe in new resource context that is not used in current
297*f005ef32Sjsg  * resource context.
298*f005ef32Sjsg  *
299*f005ef32Sjsg  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
300*f005ef32Sjsg  * pipe idx of the free pipe
301*f005ef32Sjsg  */
302*f005ef32Sjsg int recource_find_free_pipe_not_used_in_cur_res_ctx(
303*f005ef32Sjsg 		const struct resource_context *cur_res_ctx,
304*f005ef32Sjsg 		struct resource_context *new_res_ctx,
305*f005ef32Sjsg 		const struct resource_pool *pool);
306*f005ef32Sjsg 
307*f005ef32Sjsg /*
308*f005ef32Sjsg  * Look for a free pipe in new resource context that is used as a secondary DPP
309*f005ef32Sjsg  * pipe in any MPCC combine in current resource context.
310*f005ef32Sjsg  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
311*f005ef32Sjsg  * pipe idx of the free pipe
312*f005ef32Sjsg  */
313*f005ef32Sjsg int resource_find_free_pipe_used_as_cur_sec_dpp_in_mpcc_combine(
314*f005ef32Sjsg 		const struct resource_context *cur_res_ctx,
315*f005ef32Sjsg 		struct resource_context *new_res_ctx,
316*f005ef32Sjsg 		const struct resource_pool *pool);
317*f005ef32Sjsg 
318*f005ef32Sjsg /*
319*f005ef32Sjsg  * Look for any free pipe in new resource context.
320*f005ef32Sjsg  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
321*f005ef32Sjsg  * pipe idx of the free pipe
322*f005ef32Sjsg  */
323*f005ef32Sjsg int resource_find_any_free_pipe(struct resource_context *new_res_ctx,
324*f005ef32Sjsg 		const struct resource_pool *pool);
325*f005ef32Sjsg 
326*f005ef32Sjsg /*
327*f005ef32Sjsg  * Legacy find free secondary pipe logic deprecated for newer DCNs as it doesn't
328*f005ef32Sjsg  * find the most optimal free pipe to prevent from time consuming hardware state
329*f005ef32Sjsg  * transitions.
330*f005ef32Sjsg  */
331*f005ef32Sjsg struct pipe_ctx *resource_find_free_secondary_pipe_legacy(
332fb4d8502Sjsg 		struct resource_context *res_ctx,
333c349dbc7Sjsg 		const struct resource_pool *pool,
334c349dbc7Sjsg 		const struct pipe_ctx *primary_pipe);
335fb4d8502Sjsg 
336*f005ef32Sjsg /*
337*f005ef32Sjsg  * Get number of MPC "cuts" of the plane associated with the pipe. MPC slice
338*f005ef32Sjsg  * count is equal to MPC splits + 1. For example if a plane is cut 3 times, it
339*f005ef32Sjsg  * will have 4 pieces of slice.
340*f005ef32Sjsg  * return - 0 if pipe is not used for a plane with MPCC combine. otherwise
341*f005ef32Sjsg  * the number of MPC "cuts" for the plane.
342*f005ef32Sjsg  */
343*f005ef32Sjsg int resource_get_num_mpc_splits(const struct pipe_ctx *pipe);
344*f005ef32Sjsg 
345*f005ef32Sjsg /*
346*f005ef32Sjsg  * Get number of ODM "cuts" of the timing associated with the pipe. ODM slice
347*f005ef32Sjsg  * count is equal to ODM splits + 1. For example if a timing is cut 3 times, it
348*f005ef32Sjsg  * will have 4 pieces of slice.
349*f005ef32Sjsg  * return - 0 if pipe is not used for ODM combine. otherwise
350*f005ef32Sjsg  * the number of ODM "cuts" for the timing.
351*f005ef32Sjsg  */
352*f005ef32Sjsg int resource_get_num_odm_splits(const struct pipe_ctx *pipe);
353*f005ef32Sjsg 
354*f005ef32Sjsg /*
355*f005ef32Sjsg  * Get the OTG master pipe in resource context associated with the stream.
356*f005ef32Sjsg  * return - NULL if not found. Otherwise the OTG master pipe associated with the
357*f005ef32Sjsg  * stream.
358*f005ef32Sjsg  */
359*f005ef32Sjsg struct pipe_ctx *resource_get_otg_master_for_stream(
360*f005ef32Sjsg 		struct resource_context *res_ctx,
361*f005ef32Sjsg 		struct dc_stream_state *stream);
362*f005ef32Sjsg 
363*f005ef32Sjsg /*
364*f005ef32Sjsg  * Get the OTG master pipe for the input pipe context.
365*f005ef32Sjsg  * return - the OTG master pipe for the input pipe
366*f005ef32Sjsg  * context.
367*f005ef32Sjsg  */
368*f005ef32Sjsg struct pipe_ctx *resource_get_otg_master(const struct pipe_ctx *pipe_ctx);
369*f005ef32Sjsg 
370*f005ef32Sjsg /*
371*f005ef32Sjsg  * Get the OPP head pipe for the input pipe context.
372*f005ef32Sjsg  * return - the OPP head pipe for the input pipe
373*f005ef32Sjsg  * context.
374*f005ef32Sjsg  */
375*f005ef32Sjsg struct pipe_ctx *resource_get_opp_head(const struct pipe_ctx *pipe_ctx);
376*f005ef32Sjsg 
377*f005ef32Sjsg 
378fb4d8502Sjsg bool resource_validate_attach_surfaces(
379fb4d8502Sjsg 		const struct dc_validation_set set[],
380fb4d8502Sjsg 		int set_count,
381fb4d8502Sjsg 		const struct dc_state *old_context,
382fb4d8502Sjsg 		struct dc_state *context,
383fb4d8502Sjsg 		const struct resource_pool *pool);
384fb4d8502Sjsg 
385fb4d8502Sjsg enum dc_status resource_map_clock_resources(
386fb4d8502Sjsg 		const struct dc *dc,
387fb4d8502Sjsg 		struct dc_state *context,
388fb4d8502Sjsg 		struct dc_stream_state *stream);
389fb4d8502Sjsg 
390fb4d8502Sjsg enum dc_status resource_map_phy_clock_resources(
391fb4d8502Sjsg 		const struct dc *dc,
392fb4d8502Sjsg 		struct dc_state *context,
393fb4d8502Sjsg 		struct dc_stream_state *stream);
394fb4d8502Sjsg 
395fb4d8502Sjsg bool pipe_need_reprogram(
396fb4d8502Sjsg 		struct pipe_ctx *pipe_ctx_old,
397fb4d8502Sjsg 		struct pipe_ctx *pipe_ctx);
398fb4d8502Sjsg 
399fb4d8502Sjsg void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
400fb4d8502Sjsg 		struct bit_depth_reduction_params *fmt_bit_depth);
401fb4d8502Sjsg 
402fb4d8502Sjsg void update_audio_usage(
403fb4d8502Sjsg 		struct resource_context *res_ctx,
404fb4d8502Sjsg 		const struct resource_pool *pool,
405fb4d8502Sjsg 		struct audio *audio,
406fb4d8502Sjsg 		bool acquired);
407c349dbc7Sjsg 
408c349dbc7Sjsg unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format);
409c349dbc7Sjsg 
410c349dbc7Sjsg void get_audio_check(struct audio_info *aud_modes,
411c349dbc7Sjsg 	struct audio_check *aud_chk);
412c349dbc7Sjsg 
4131bb76ff1Sjsg bool get_temp_dp_link_res(struct dc_link *link,
4141bb76ff1Sjsg 		struct link_resource *link_res,
4151bb76ff1Sjsg 		struct dc_link_settings *link_settings);
4161bb76ff1Sjsg 
417*f005ef32Sjsg #if defined(CONFIG_DRM_AMD_DC_FP)
4181bb76ff1Sjsg struct hpo_dp_link_encoder *resource_get_hpo_dp_link_enc_for_det_lt(
4191bb76ff1Sjsg 		const struct resource_context *res_ctx,
4201bb76ff1Sjsg 		const struct resource_pool *pool,
4211bb76ff1Sjsg 		const struct dc_link *link);
4221bb76ff1Sjsg #endif
4231bb76ff1Sjsg 
4241bb76ff1Sjsg void reset_syncd_pipes_from_disabled_pipes(struct dc *dc,
4251bb76ff1Sjsg 	struct dc_state *context);
4261bb76ff1Sjsg 
4271bb76ff1Sjsg void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc,
4281bb76ff1Sjsg 	struct dc_state *context,
4291bb76ff1Sjsg 	uint8_t disabled_master_pipe_idx);
4301bb76ff1Sjsg 
4311bb76ff1Sjsg void reset_sync_context_for_pipe(const struct dc *dc,
4321bb76ff1Sjsg 	struct dc_state *context,
4331bb76ff1Sjsg 	uint8_t pipe_idx);
4341bb76ff1Sjsg 
4351bb76ff1Sjsg uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter);
4361bb76ff1Sjsg 
4371bb76ff1Sjsg const struct link_hwss *get_link_hwss(const struct dc_link *link,
4381bb76ff1Sjsg 		const struct link_resource *link_res);
4391bb76ff1Sjsg 
4401bb76ff1Sjsg bool is_h_timing_divisible_by_2(struct dc_stream_state *stream);
4411bb76ff1Sjsg 
4421bb76ff1Sjsg bool dc_resource_acquire_secondary_pipe_for_mpc_odm(
4431bb76ff1Sjsg 		const struct dc *dc,
4441bb76ff1Sjsg 		struct dc_state *state,
4451bb76ff1Sjsg 		struct pipe_ctx *pri_pipe,
4461bb76ff1Sjsg 		struct pipe_ctx *sec_pipe,
4471bb76ff1Sjsg 		bool odm);
448*f005ef32Sjsg 
449*f005ef32Sjsg /* A test harness interface that modifies dp encoder resources in the given dc
450*f005ef32Sjsg  * state and bypasses the need to revalidate. The interface assumes that the
451*f005ef32Sjsg  * test harness interface is called with pre-validated link config stored in the
452*f005ef32Sjsg  * pipe_ctx and updates dp encoder resources according to the link config.
453*f005ef32Sjsg  */
454*f005ef32Sjsg enum dc_status update_dp_encoder_resources_for_test_harness(const struct dc *dc,
455*f005ef32Sjsg 		struct dc_state *context,
456*f005ef32Sjsg 		struct pipe_ctx *pipe_ctx);
457fb4d8502Sjsg #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
458