xref: /linux/drivers/gpu/drm/amd/display/dc/inc/resource.h (revision 20bed0d6ff62d985fe8222958825504b8aad4e88)
1 /*
2  * Copyright 2015 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 DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
26 #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
27 
28 #include "core_types.h"
29 #include "core_status.h"
30 #include "dal_asic_id.h"
31 #include "dm_pp_smu.h"
32 
33 #define MEMORY_TYPE_MULTIPLIER_CZ 4
34 #define MEMORY_TYPE_HBM 2
35 #define MAX_MCACHES 8
36 
37 
38 #define IS_PIPE_SYNCD_VALID(pipe) ((((pipe)->pipe_idx_syncd) & 0x80)?1:0)
39 #define GET_PIPE_SYNCD_FROM_PIPE(pipe) ((pipe)->pipe_idx_syncd & 0x7F)
40 #define SET_PIPE_SYNCD_TO_PIPE(pipe, pipe_syncd) ((pipe)->pipe_idx_syncd = (0x80 | pipe_syncd))
41 
42 enum dce_version resource_parse_asic_id(
43 		struct hw_asic_id asic_id);
44 
45 struct resource_caps {
46 	int num_timing_generator;
47 	int num_opp;
48 	int num_dpp;
49 	int num_video_plane;
50 	int num_audio;
51 	int num_stream_encoder;
52 	int num_analog_stream_encoder;
53 	int num_pll;
54 	int num_dwb;
55 	int num_ddc;
56 	int num_vmid;
57 	int num_dsc;
58 	unsigned int num_dig_link_enc; // Total number of DIGs (digital encoders) in DIO (Display Input/Output).
59 	unsigned int num_usb4_dpia; // Total number of USB4 DPIA (DisplayPort Input Adapters).
60 	int num_hpo_frl;
61 	int num_hpo_dp_stream_encoder;
62 	int num_hpo_dp_link_encoder;
63 	int num_mpc_3dlut;
64 	int num_mpc;
65 	int num_rmcm;
66 	int num_aux;
67 };
68 
69 struct resource_straps {
70 	uint32_t hdmi_disable;
71 	uint32_t dc_pinstraps_audio;
72 	uint32_t audio_stream_number;
73 };
74 
75 struct dc_mcache_allocations {
76 	int global_mcache_ids_plane0[MAX_MCACHES + 1];
77 	int global_mcache_ids_plane1[MAX_MCACHES + 1];
78 	int global_mcache_ids_mall_plane0[MAX_MCACHES + 1];
79 	int global_mcache_ids_mall_plane1[MAX_MCACHES + 1];
80 };
81 
82 struct resource_create_funcs {
83 	void (*read_dce_straps)(
84 			struct dc_context *ctx, struct resource_straps *straps);
85 
86 	struct audio *(*create_audio)(
87 			struct dc_context *ctx, unsigned int inst);
88 
89 	struct stream_encoder *(*create_stream_encoder)(
90 			enum engine_id eng_id, struct dc_context *ctx);
91 
92 	struct hpo_frl_stream_encoder *(*create_hpo_frl_stream_encoder)(
93 			enum engine_id eng_id, struct dc_context *ctx);
94 	struct hpo_frl_link_encoder *(*create_hpo_frl_link_encoder)(
95 			enum engine_id eng_id, struct dc_context *ctx);
96 	struct hpo_dp_stream_encoder *(*create_hpo_dp_stream_encoder)(
97 			enum engine_id eng_id, struct dc_context *ctx);
98 	struct hpo_dp_link_encoder *(*create_hpo_dp_link_encoder)(
99 			uint8_t inst,
100 			struct dc_context *ctx);
101 	struct dce_hwseq *(*create_hwseq)(
102 			struct dc_context *ctx);
103 };
104 
105 bool resource_construct(
106 	unsigned int num_virtual_links,
107 	struct dc *dc,
108 	struct resource_pool *pool,
109 	const struct resource_create_funcs *create_funcs);
110 
111 struct resource_pool *dc_create_resource_pool(struct dc  *dc,
112 					      const struct dc_init_data *init_data,
113 					      enum dce_version dc_version);
114 
115 void dc_destroy_resource_pool(struct dc *dc);
116 
117 enum dc_status resource_map_pool_resources(
118 		const struct dc *dc,
119 		struct dc_state *context,
120 		struct dc_stream_state *stream);
121 
122 void resource_build_test_pattern_params(
123 		struct resource_context *res_ctx,
124 		struct pipe_ctx *pipe_ctx);
125 
126 enum upsp_mode resource_is_upsp_required(enum surface_pixel_format format,
127 		enum dc_scaling_linearity scaling_linearity);
128 
129 bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
130 
131 enum dc_status resource_build_scaling_params_for_context(
132 		const struct dc *dc,
133 		struct dc_state *context);
134 
135 void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
136 
137 void resource_unreference_clock_source(
138 		struct resource_context *res_ctx,
139 		const struct resource_pool *pool,
140 		struct clock_source *clock_source);
141 
142 void resource_reference_clock_source(
143 		struct resource_context *res_ctx,
144 		const struct resource_pool *pool,
145 		struct clock_source *clock_source);
146 
147 int resource_get_clock_source_reference(
148 		struct resource_context *res_ctx,
149 		const struct resource_pool *pool,
150 		struct clock_source *clock_source);
151 
152 bool resource_are_streams_timing_synchronizable(
153 		struct dc_stream_state *stream1,
154 		struct dc_stream_state *stream2);
155 
156 bool resource_are_vblanks_synchronizable(
157 		struct dc_stream_state *stream1,
158 		struct dc_stream_state *stream2);
159 
160 struct clock_source *resource_find_used_clk_src_for_sharing(
161 		struct resource_context *res_ctx,
162 		struct pipe_ctx *pipe_ctx);
163 
164 struct clock_source *dc_resource_find_first_free_pll(
165 		struct resource_context *res_ctx,
166 		const struct resource_pool *pool);
167 
168 bool resource_attach_surfaces_to_context(
169 		struct dc_plane_state *const *plane_state,
170 		int surface_count,
171 		struct dc_stream_state *dc_stream,
172 		struct dc_state *context,
173 		const struct resource_pool *pool);
174 
175 bool resource_can_pipe_disable_cursor(const struct pipe_ctx *pipe_ctx);
176 
177 #define FREE_PIPE_INDEX_NOT_FOUND -1
178 
179 /*
180  * pipe types are identified based on MUXes in DCN front end that are capable
181  * of taking input from one DCN pipeline to another DCN pipeline. The name is
182  * in a form of XXXX_YYYY, where XXXX is the DCN front end hardware block the
183  * pipeline ends with and YYYY is the rendering role that the pipe is in.
184  *
185  * For instance OTG_MASTER is a pipe ending with OTG hardware block in its
186  * pipeline and it is in a role of a master pipe for timing generation.
187  *
188  * For quick reference a diagram of each pipe type's areas of responsibility
189  * for outputting timings on the screen is shown below:
190  *
191  *       Timing Active for Stream 0
192  *        __________________________________________________
193  *       |OTG master 0 (OPP head 0)|OPP head 2 (DPP pipe 2) |
194  *       |             (DPP pipe 0)|                        |
195  *       | Top Plane 0             |                        |
196  *       |           ______________|____                    |
197  *       |          |DPP pipe 1    |DPP |                   |
198  *       |          |              |pipe|                   |
199  *       |          |  Bottom      |3   |                   |
200  *       |          |  Plane 1     |    |                   |
201  *       |          |              |    |                   |
202  *       |          |______________|____|                   |
203  *       |                         |                        |
204  *       |                         |                        |
205  *       | ODM slice 0             | ODM slice 1            |
206  *       |_________________________|________________________|
207  *
208  *       Timing Active for Stream 1
209  *        __________________________________________________
210  *       |OTG master 4 (OPP head 4)                         |
211  *       |                                                  |
212  *       |                                                  |
213  *       |                                                  |
214  *       |                                                  |
215  *       |                                                  |
216  *       |               Blank Pixel Data                   |
217  *       |              (generated by DPG4)                 |
218  *       |                                                  |
219  *       |                                                  |
220  *       |                                                  |
221  *       |                                                  |
222  *       |                                                  |
223  *       |__________________________________________________|
224  *
225  *       Inter-pipe Relation
226  *        __________________________________________________
227  *       |PIPE IDX|   DPP PIPES   | OPP HEADS | OTG MASTER  |
228  *       |        |  plane 0      | slice 0   |             |
229  *       |   0    | -------------MPC---------ODM----------- |
230  *       |        |  plane 1    | |         | |             |
231  *       |   1    | ------------- |         | |             |
232  *       |        |  plane 0      | slice 1 | |             |
233  *       |   2    | -------------MPC--------- |             |
234  *       |        |  plane 1    | |           |             |
235  *       |   3    | ------------- |           |             |
236  *       |        |               | blank     |             |
237  *       |   4    |               | ----------------------- |
238  *       |        |               |           |             |
239  *       |   5    |  (FREE)       |           |             |
240  *       |________|_______________|___________|_____________|
241  *
242  * The following is a quick reference of the class relation:
243  *
244  *	DC state            ---1--------0..N---           streams
245  *
246  *	stream              ---1-----------1---           OTG Master pipe
247  *
248  *	OTG Master pipe     ---1--------1..N---           OPP Head pipes
249  *
250  *	OPP Head pipe       ---1--------0..N---           DPP pipes
251  *
252  *	stream              ---1--------0..N---           Planes
253  *
254  *	Plane               ---1--------1..N---           DPP pipes
255  *
256  */
257 enum pipe_type {
258 	/* free pipe - free pipe is an uninitialized pipe without a stream
259 	 * associated with it. It is a free DCN pipe resource. It can be
260 	 * acquired as any type of pipe.
261 	 */
262 	FREE_PIPE,
263 
264 	/* OTG master pipe - the master pipe of its OPP head pipes with a
265 	 * functional OTG. It merges all its OPP head pipes pixel data in ODM
266 	 * block and output to back end DIG. OTG master pipe is responsible for
267 	 * generating entire CRTC timing to back end DIG. An OTG master pipe may
268 	 * or may not have a plane. If it has a plane it blends it as the left
269 	 * most MPC slice of the top most layer. If it doesn't have a plane it
270 	 * can output pixel data from its OPP head pipes' test pattern
271 	 * generators (DPG) such as solid black pixel data to blank the screen.
272 	 */
273 	OTG_MASTER,
274 
275 	/* OPP head pipe - the head pipe of an MPC blending tree with a
276 	 * functional OPP outputting to an OTG. OPP head pipe is responsible for
277 	 * processing output pixels in its own ODM slice. It may or may not have
278 	 * a plane. If it has a plane it blends it as the top most layer within
279 	 * its own ODM slice. If it doesn't have a plane it can output pixel
280 	 * data from its DPG such as solid black pixel data to blank the pixel
281 	 * data in its own ODM slice. OTG master pipe is also an OPP head pipe
282 	 * but with more responsibility.
283 	 */
284 	OPP_HEAD,
285 
286 	/* DPP pipe - the pipe with a functional DPP outputting to an OPP head
287 	 * pipe's MPC. DPP pipe is responsible for processing pixel data from
288 	 * its own MPC slice of a plane. It must be connected to an OPP head
289 	 * pipe and it must have a plane associated with it.
290 	 */
291 	DPP_PIPE,
292 };
293 
294 /*
295  * Determine if the input pipe_ctx is of a pipe type.
296  * return - true if pipe_ctx is of the input type.
297  */
298 bool resource_is_pipe_type(const struct pipe_ctx *pipe_ctx, enum pipe_type type);
299 
300 /*
301  * Acquire a pipe as OTG master pipe and allocate pipe resources required to
302  * enable stream output.
303  */
304 enum dc_status resource_add_otg_master_for_stream_output(struct dc_state *new_ctx,
305 		const struct resource_pool *pool,
306 		struct dc_stream_state *stream);
307 
308 /*
309  * Release pipe resources and the OTG master pipe associated with the stream
310  * The stream must have all planes removed and ODM/MPC slice counts are reset
311  * to 1 before invoking this interface.
312  */
313 void resource_remove_otg_master_for_stream_output(struct dc_state *new_ctx,
314 		const struct resource_pool *pool,
315 		struct dc_stream_state *stream);
316 
317 /*
318  * Add plane to the bottom most layer in plane composition and allocate DPP pipe
319  * resources as needed.
320  * return - true if plane is added in plane composition, false otherwise.
321  */
322 bool resource_append_dpp_pipes_for_plane_composition(
323 		struct dc_state *new_ctx,
324 		struct dc_state *cur_ctx,
325 		struct resource_pool *pool,
326 		struct pipe_ctx *otg_master_pipe,
327 		struct dc_plane_state *plane_state);
328 
329 /*
330  * Add plane to the bottom most layer in plane composition and allocate DPP pipe
331  * resources as needed.
332  * return - true if plane is added in plane composition, false otherwise.
333  */
334 void resource_remove_dpp_pipes_for_plane_composition(
335 		struct dc_state *context,
336 		const struct resource_pool *pool,
337 		const struct dc_plane_state *plane_state);
338 
339 /*
340  * RMCM resource management. Instances are handed out for a whole context at once so that a
341  * plane that is only now asking cannot evict one that is already using an instance.
342  * Tracking is via res_ctx->rmcm_in_use[].
343  */
344 void resource_assign_rmcm(
345 		struct dc_state *new_ctx,
346 		const struct dc_state *cur_ctx,
347 		const struct resource_pool *pool);
348 
349 void resource_release_rmcm(
350 		struct resource_context *res_ctx,
351 		const struct resource_pool *pool,
352 		struct rmcm **rmcm);
353 
354 /*
355  * Update ODM slice count by acquiring or releasing pipes. If new slices need
356  * to be added, it is going to add them to the last ODM index. If existing
357  * slices need to be removed, it is going to remove them from the last ODM
358  * index.
359  *
360  * return - true if ODM slices are updated and required pipes are acquired. All
361  * affected pipe parameters are updated.
362  *
363  * false if resource fails to complete this update. The function is not designed
364  * to recover the creation of invalid topologies. Returning false is typically
365  * an indication of insufficient validation in caller's stack. new_ctx will be
366  * invalid. Caller may attempt to restore new_ctx by calling this function
367  * again with original slice count.
368  */
369 bool resource_update_pipes_for_stream_with_slice_count(
370 		struct dc_state *new_ctx,
371 		const struct dc_state *cur_ctx,
372 		const struct resource_pool *pool,
373 		const struct dc_stream_state *stream,
374 		int new_slice_count);
375 
376 /*
377  * Update MPC slice count by acquiring or releasing DPP pipes. If new slices
378  * need to be added it is going to add to the last MPC index. If existing
379  * slices need to be removed, it is going to remove them from the last MPC
380  * index.
381  *
382  * @dpp_pipe - top most dpp pipe for MPCC combine.
383  *
384  * return - true if MPC slices are updated and required pipes are acquired. All
385  * affected pipe parameters are updated.
386  *
387  * false if resource fails to complete this update. The function is not designed
388  * to recover the creation of invalid topologies. Returning false is typically
389  * an indication of insufficient validation in caller's stack. new_ctx will be
390  * invalid. Caller may attempt to restore new_ctx by calling this function
391  * again with original slice count.
392  */
393 bool resource_update_pipes_for_plane_with_slice_count(
394 		struct dc_state *new_ctx,
395 		const struct dc_state *cur_ctx,
396 		const struct resource_pool *pool,
397 		const struct dc_plane_state *plane,
398 		int slice_count);
399 
400 /*
401  * Get the OTG master pipe in resource context associated with the stream.
402  * return - NULL if not found. Otherwise the OTG master pipe associated with the
403  * stream.
404  */
405 struct pipe_ctx *resource_get_otg_master_for_stream(
406 		struct resource_context *res_ctx,
407 		const struct dc_stream_state *stream);
408 
409 /*
410  * Get an array of OPP heads in opp_heads ordered with index low to high for OTG
411  * master pipe in res_ctx.
412  * return - number of OPP heads in the array. If otg_master passed in is not
413  * an OTG master, the function returns 0.
414  */
415 int resource_get_opp_heads_for_otg_master(const struct pipe_ctx *otg_master,
416 		struct resource_context *res_ctx,
417 		struct pipe_ctx *opp_heads[MAX_PIPES]);
418 
419 /*
420  * Get an array of DPP pipes in dpp_pipes ordered with index low to high for OPP
421  * head pipe in res_ctx.
422  * return - number of DPP pipes in the array. If opp_head passed in is not
423  * an OPP pipe, the function returns 0.
424  */
425 int resource_get_dpp_pipes_for_opp_head(const struct pipe_ctx *opp_head,
426 		struct resource_context *res_ctx,
427 		struct pipe_ctx *dpp_pipes[MAX_PIPES]);
428 
429 /*
430  * Get an array of DPP pipes in dpp_pipes ordered with index low to high for
431  * plane in res_ctx.
432  * return - number of DPP pipes in the array.
433  */
434 int resource_get_dpp_pipes_for_plane(const struct dc_plane_state *plane,
435 		struct resource_context *res_ctx,
436 		struct pipe_ctx *dpp_pipes[MAX_PIPES]);
437 
438 /*
439  * Get the OTG master pipe for the input pipe context.
440  * return - the OTG master pipe for the input pipe
441  * context.
442  */
443 struct pipe_ctx *resource_get_otg_master(const struct pipe_ctx *pipe_ctx);
444 
445 /*
446  * Get the OPP head pipe for the input pipe context.
447  * return - the OPP head pipe for the input pipe
448  * context.
449  */
450 struct pipe_ctx *resource_get_opp_head(const struct pipe_ctx *pipe_ctx);
451 
452 /*
453  * Get the DPP pipe allocated for MPC slice 0 and ODM slice 0 of the plane
454  * associated with dpp_pipe.
455  */
456 struct pipe_ctx *resource_get_primary_dpp_pipe(const struct pipe_ctx *dpp_pipe);
457 
458 /*
459  * Get the MPC slice index counting from 0 from left most slice
460  * For example, if a DPP pipe is used as a secondary pipe in MPCC combine, MPC
461  * split index is greater than 0.
462  */
463 int resource_get_mpc_slice_index(const struct pipe_ctx *dpp_pipe);
464 
465 /*
466  * Get the number of MPC slices associated with the pipe.
467  * The function returns 0 if the pipe is not associated with an MPC combine
468  * pipe topology.
469  */
470 int resource_get_mpc_slice_count(const struct pipe_ctx *pipe);
471 
472 /*
473  * Get the number of ODM slices associated with the pipe.
474  * The function returns 0 if the pipe is not associated with an ODM combine
475  * pipe topology.
476  */
477 int resource_get_odm_slice_count(const struct pipe_ctx *pipe);
478 
479 /* Get the ODM slice index counting from 0 from left most slice */
480 int resource_get_odm_slice_index(const struct pipe_ctx *opp_head);
481 
482 /* Get ODM slice source rect in timing active as input to OPP block */
483 struct rect resource_get_odm_slice_src_rect(struct pipe_ctx *pipe_ctx);
484 
485 /* Get ODM slice destination rect in timing active as output from OPP block */
486 struct rect resource_get_odm_slice_dst_rect(struct pipe_ctx *pipe_ctx);
487 
488 /* Get ODM slice destination width in timing active as output from OPP block */
489 int resource_get_odm_slice_dst_width(struct pipe_ctx *otg_master,
490 		bool is_last_segment);
491 
492 /* determine if pipe topology is changed between state a and state b */
493 bool resource_is_pipe_topology_changed(const struct dc_state *state_a,
494 		const struct dc_state *state_b);
495 
496 /*
497  * determine if the two OTG master pipes have the same ODM topology
498  * return
499  * false - if pipes passed in are not OTG masters or ODM topology is
500  * changed.
501  * true - otherwise
502  */
503 bool resource_is_odm_topology_changed(const struct pipe_ctx *otg_master_a,
504 		const struct pipe_ctx *otg_master_b);
505 
506 /* log the pipe topology update in state */
507 void resource_log_pipe_topology_update(struct dc *dc, struct dc_state *state);
508 
509 /*
510  * Look for a free pipe in new resource context that is used as a secondary OPP
511  * head by cur_otg_master.
512  *
513  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
514  * pipe idx of the free pipe
515  */
516 int resource_find_free_pipe_used_as_sec_opp_head_by_cur_otg_master(
517 		const struct resource_context *cur_res_ctx,
518 		struct resource_context *new_res_ctx,
519 		const struct pipe_ctx *cur_otg_master);
520 
521 /*
522  * Look for a free pipe in new resource context that is used as a secondary DPP
523  * pipe in MPC blending tree associated with input OPP head pipe.
524  *
525  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
526  * pipe idx of the free pipe
527  */
528 int resource_find_free_pipe_used_in_cur_mpc_blending_tree(
529 		const struct resource_context *cur_res_ctx,
530 		struct resource_context *new_res_ctx,
531 		const struct pipe_ctx *cur_opp_head);
532 
533 /*
534  * Look for a free pipe in new resource context that is not used in current
535  * resource context.
536  *
537  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
538  * pipe idx of the free pipe
539  */
540 int recource_find_free_pipe_not_used_in_cur_res_ctx(
541 		const struct resource_context *cur_res_ctx,
542 		struct resource_context *new_res_ctx,
543 		const struct resource_pool *pool);
544 
545 /*
546  * Look for a free pipe in new resource context that is used in current resource
547  * context as an OTG master pipe.
548  *
549  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
550  * pipe idx of the free pipe
551  */
552 int recource_find_free_pipe_used_as_otg_master_in_cur_res_ctx(
553 		const struct resource_context *cur_res_ctx,
554 		struct resource_context *new_res_ctx,
555 		const struct resource_pool *pool);
556 
557 /*
558  * Look for a free pipe in new resource context that is used as a secondary DPP
559  * pipe in current resource context.
560  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
561  * pipe idx of the free pipe
562  */
563 int resource_find_free_pipe_used_as_cur_sec_dpp(
564 		const struct resource_context *cur_res_ctx,
565 		struct resource_context *new_res_ctx,
566 		const struct resource_pool *pool);
567 
568 /*
569  * Look for a free pipe in new resource context that is used as a secondary DPP
570  * pipe in any MPCC combine in current resource context.
571  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
572  * pipe idx of the free pipe
573  */
574 int resource_find_free_pipe_used_as_cur_sec_dpp_in_mpcc_combine(
575 		const struct resource_context *cur_res_ctx,
576 		struct resource_context *new_res_ctx,
577 		const struct resource_pool *pool);
578 
579 /*
580  * Look for any free pipe in new resource context.
581  * return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
582  * pipe idx of the free pipe
583  */
584 int resource_find_any_free_pipe(struct resource_context *new_res_ctx,
585 		const struct resource_pool *pool);
586 
587 /*
588  * Legacy find free secondary pipe logic deprecated for newer DCNs as it doesn't
589  * find the most optimal free pipe to prevent from time consuming hardware state
590  * transitions.
591  */
592 struct pipe_ctx *resource_find_free_secondary_pipe_legacy(
593 		struct resource_context *res_ctx,
594 		const struct resource_pool *pool,
595 		const struct pipe_ctx *primary_pipe);
596 
597 bool resource_validate_attach_surfaces(
598 		const struct dc_validation_set *set,
599 		const struct dc_state *old_context,
600 		struct dc_state *context,
601 		const struct resource_pool *pool);
602 
603 enum dc_status resource_validate_probe_set(struct dc *dc,
604 		const struct dc_probe_state *probes,
605 		uint8_t probe_count);
606 
607 enum dc_status resource_map_clock_resources(
608 		const struct dc *dc,
609 		struct dc_state *context,
610 		struct dc_stream_state *stream);
611 
612 enum dc_status resource_map_phy_clock_resources(
613 		const struct dc *dc,
614 		struct dc_state *context,
615 		struct dc_stream_state *stream);
616 
617 bool pipe_need_reprogram(
618 		struct pipe_ctx *pipe_ctx_old,
619 		struct pipe_ctx *pipe_ctx);
620 
621 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
622 		struct bit_depth_reduction_params *fmt_bit_depth);
623 
624 void update_audio_usage(
625 		struct resource_context *res_ctx,
626 		const struct resource_pool *pool,
627 		struct audio *audio,
628 		bool acquired);
629 
630 unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format);
631 
632 bool get_temp_dp_link_res(struct dc_link *link,
633 		struct link_resource *link_res,
634 		struct dc_link_settings *link_settings);
635 bool get_temp_frl_link_res(struct dc_link *link,
636 		struct link_resource *link_res);
637 
638 void reset_syncd_pipes_from_disabled_pipes(struct dc *dc,
639 	struct dc_state *context);
640 
641 void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc,
642 	struct dc_state *context,
643 	uint8_t disabled_master_pipe_idx);
644 
645 void reset_sync_context_for_pipe(const struct dc *dc,
646 	struct dc_state *context,
647 	uint8_t pipe_idx);
648 
649 uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter);
650 
651 const struct link_hwss *get_link_hwss(const struct dc_link *link,
652 		const struct link_resource *link_res);
653 
654 bool is_h_timing_divisible_by_2(struct dc_stream_state *stream);
655 
656 bool dc_resource_acquire_secondary_pipe_for_mpc_odm_legacy(
657 		const struct dc *dc,
658 		struct dc_state *state,
659 		struct pipe_ctx *pri_pipe,
660 		struct pipe_ctx *sec_pipe,
661 		bool odm);
662 
663 /* A test harness interface that modifies dp encoder resources in the given dc
664  * state and bypasses the need to revalidate. The interface assumes that the
665  * test harness interface is called with pre-validated link config stored in the
666  * pipe_ctx and updates dp encoder resources according to the link config.
667  */
668 enum dc_status update_dp_encoder_resources_for_test_harness(const struct dc *dc,
669 		struct dc_state *context,
670 		struct pipe_ctx *pipe_ctx);
671 
672 /* Get hw programming parameters container from pipe context
673  * @pipe_ctx: pipe context
674  * @dscl_prog_data: struct to hold programmable hw reg values
675  */
676 struct dscl_prog_data *resource_get_dscl_prog_data(struct pipe_ctx *pipe_ctx);
677 /* Setup dc callbacks for dml2
678  * @dc: the display core structure
679  * @dml2_options: struct to hold callbacks
680  */
681 void resource_init_common_dml2_callbacks(struct dc *dc, struct dml2_configuration_options *dml2_options);
682 
683 /*
684  *Calculate total DET allocated for all pipes for a given OTG_MASTER pipe
685  */
686 int resource_calculate_det_for_stream(struct dc_state *state, struct pipe_ctx *otg_master);
687 
688 bool resource_is_hpo_acquired(struct dc_state *context);
689 
690 struct link_encoder *get_temp_dio_link_enc(
691 		const struct resource_context *res_ctx,
692 		const struct resource_pool *const pool,
693 		const struct dc_link *link);
694 #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
695