2 * Copyright 2015 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
25 #ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
26 #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
28 #include "core_types.h"
29 #include "core_status.h"
30 #include "dal_asic_id.h"
31 #include "dm_pp_smu.h"
33 /* TODO unhardcode, 4 for CZ*/
34 #define MEMORY_TYPE_MULTIPLIER 4
36 enum dce_version resource_parse_asic_id(
37 struct hw_asic_id asic_id);
39 struct resource_caps {
40 int num_timing_generator;
43 int num_stream_encoder;
48 struct resource_straps {
49 uint32_t hdmi_disable;
50 uint32_t dc_pinstraps_audio;
51 uint32_t audio_stream_number;
54 struct resource_create_funcs {
55 void (*read_dce_straps)(
56 struct dc_context *ctx, struct resource_straps *straps);
58 struct audio *(*create_audio)(
59 struct dc_context *ctx, unsigned int inst);
61 struct stream_encoder *(*create_stream_encoder)(
62 enum engine_id eng_id, struct dc_context *ctx);
64 struct dce_hwseq *(*create_hwseq)(
65 struct dc_context *ctx);
68 bool resource_construct(
69 unsigned int num_virtual_links,
71 struct resource_pool *pool,
72 const struct resource_create_funcs *create_funcs);
74 struct resource_pool *dc_create_resource_pool(
76 int num_virtual_links,
77 enum dce_version dc_version,
78 struct hw_asic_id asic_id);
80 void dc_destroy_resource_pool(struct dc *dc);
82 enum dc_status resource_map_pool_resources(
84 struct dc_state *context,
85 struct dc_stream_state *stream);
87 bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
89 enum dc_status resource_build_scaling_params_for_context(
91 struct dc_state *context);
93 void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
95 void resource_unreference_clock_source(
96 struct resource_context *res_ctx,
97 const struct resource_pool *pool,
98 struct clock_source *clock_source);
100 void resource_reference_clock_source(
101 struct resource_context *res_ctx,
102 const struct resource_pool *pool,
103 struct clock_source *clock_source);
105 bool resource_are_streams_timing_synchronizable(
106 struct dc_stream_state *stream1,
107 struct dc_stream_state *stream2);
109 struct clock_source *resource_find_used_clk_src_for_sharing(
110 struct resource_context *res_ctx,
111 struct pipe_ctx *pipe_ctx);
113 struct clock_source *dc_resource_find_first_free_pll(
114 struct resource_context *res_ctx,
115 const struct resource_pool *pool);
117 struct pipe_ctx *resource_get_head_pipe_for_stream(
118 struct resource_context *res_ctx,
119 struct dc_stream_state *stream);
121 bool resource_attach_surfaces_to_context(
122 struct dc_plane_state *const *plane_state,
124 struct dc_stream_state *dc_stream,
125 struct dc_state *context,
126 const struct resource_pool *pool);
128 struct pipe_ctx *find_idle_secondary_pipe(
129 struct resource_context *res_ctx,
130 const struct resource_pool *pool);
132 bool resource_is_stream_unchanged(
133 struct dc_state *old_context, struct dc_stream_state *stream);
135 bool resource_validate_attach_surfaces(
136 const struct dc_validation_set set[],
138 const struct dc_state *old_context,
139 struct dc_state *context,
140 const struct resource_pool *pool);
142 void resource_validate_ctx_update_pointer_after_copy(
143 const struct dc_state *src_ctx,
144 struct dc_state *dst_ctx);
146 enum dc_status resource_map_clock_resources(
148 struct dc_state *context,
149 struct dc_stream_state *stream);
151 enum dc_status resource_map_phy_clock_resources(
153 struct dc_state *context,
154 struct dc_stream_state *stream);
156 bool pipe_need_reprogram(
157 struct pipe_ctx *pipe_ctx_old,
158 struct pipe_ctx *pipe_ctx);
160 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
161 struct bit_depth_reduction_params *fmt_bit_depth);
163 void update_audio_usage(
164 struct resource_context *res_ctx,
165 const struct resource_pool *pool,
168 #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */