Home | History | Annotate | Line # | Download | only in inc
      1 /*	$NetBSD: resource.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2015 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 #ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
     28 #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
     29 
     30 #include "core_types.h"
     31 #include "core_status.h"
     32 #include "dal_asic_id.h"
     33 #include "dm_pp_smu.h"
     34 
     35 #define MEMORY_TYPE_MULTIPLIER_CZ 4
     36 #define MEMORY_TYPE_HBM 2
     37 
     38 
     39 enum dce_version resource_parse_asic_id(
     40 		struct hw_asic_id asic_id);
     41 
     42 struct resource_caps {
     43 	int num_timing_generator;
     44 	int num_opp;
     45 	int num_video_plane;
     46 	int num_audio;
     47 	int num_stream_encoder;
     48 	int num_pll;
     49 	int num_dwb;
     50 	int num_ddc;
     51 	int num_vmid;
     52 	int num_dsc;
     53 };
     54 
     55 struct resource_straps {
     56 	uint32_t hdmi_disable;
     57 	uint32_t dc_pinstraps_audio;
     58 	uint32_t audio_stream_number;
     59 };
     60 
     61 struct resource_create_funcs {
     62 	void (*read_dce_straps)(
     63 			struct dc_context *ctx, struct resource_straps *straps);
     64 
     65 	struct audio *(*create_audio)(
     66 			struct dc_context *ctx, unsigned int inst);
     67 
     68 	struct stream_encoder *(*create_stream_encoder)(
     69 			enum engine_id eng_id, struct dc_context *ctx);
     70 
     71 	struct dce_hwseq *(*create_hwseq)(
     72 			struct dc_context *ctx);
     73 };
     74 
     75 bool resource_construct(
     76 	unsigned int num_virtual_links,
     77 	struct dc *dc,
     78 	struct resource_pool *pool,
     79 	const struct resource_create_funcs *create_funcs);
     80 
     81 struct resource_pool *dc_create_resource_pool(struct dc  *dc,
     82 					      const struct dc_init_data *init_data,
     83 					      enum dce_version dc_version);
     84 
     85 void dc_destroy_resource_pool(struct dc *dc);
     86 
     87 enum dc_status resource_map_pool_resources(
     88 		const struct dc *dc,
     89 		struct dc_state *context,
     90 		struct dc_stream_state *stream);
     91 
     92 bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
     93 
     94 enum dc_status resource_build_scaling_params_for_context(
     95 		const struct dc *dc,
     96 		struct dc_state *context);
     97 
     98 void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
     99 
    100 void resource_unreference_clock_source(
    101 		struct resource_context *res_ctx,
    102 		const struct resource_pool *pool,
    103 		struct clock_source *clock_source);
    104 
    105 void resource_reference_clock_source(
    106 		struct resource_context *res_ctx,
    107 		const struct resource_pool *pool,
    108 		struct clock_source *clock_source);
    109 
    110 int resource_get_clock_source_reference(
    111 		struct resource_context *res_ctx,
    112 		const struct resource_pool *pool,
    113 		struct clock_source *clock_source);
    114 
    115 bool resource_are_streams_timing_synchronizable(
    116 		struct dc_stream_state *stream1,
    117 		struct dc_stream_state *stream2);
    118 
    119 struct clock_source *resource_find_used_clk_src_for_sharing(
    120 		struct resource_context *res_ctx,
    121 		struct pipe_ctx *pipe_ctx);
    122 
    123 struct clock_source *dc_resource_find_first_free_pll(
    124 		struct resource_context *res_ctx,
    125 		const struct resource_pool *pool);
    126 
    127 struct pipe_ctx *resource_get_head_pipe_for_stream(
    128 		struct resource_context *res_ctx,
    129 		struct dc_stream_state *stream);
    130 
    131 bool resource_attach_surfaces_to_context(
    132 		struct dc_plane_state *const *plane_state,
    133 		int surface_count,
    134 		struct dc_stream_state *dc_stream,
    135 		struct dc_state *context,
    136 		const struct resource_pool *pool);
    137 
    138 struct pipe_ctx *find_idle_secondary_pipe(
    139 		struct resource_context *res_ctx,
    140 		const struct resource_pool *pool,
    141 		const struct pipe_ctx *primary_pipe);
    142 
    143 bool resource_is_stream_unchanged(
    144 	struct dc_state *old_context, struct dc_stream_state *stream);
    145 
    146 bool resource_validate_attach_surfaces(
    147 		const struct dc_validation_set set[],
    148 		int set_count,
    149 		const struct dc_state *old_context,
    150 		struct dc_state *context,
    151 		const struct resource_pool *pool);
    152 
    153 void resource_validate_ctx_update_pointer_after_copy(
    154 		const struct dc_state *src_ctx,
    155 		struct dc_state *dst_ctx);
    156 
    157 enum dc_status resource_map_clock_resources(
    158 		const struct dc *dc,
    159 		struct dc_state *context,
    160 		struct dc_stream_state *stream);
    161 
    162 enum dc_status resource_map_phy_clock_resources(
    163 		const struct dc *dc,
    164 		struct dc_state *context,
    165 		struct dc_stream_state *stream);
    166 
    167 bool pipe_need_reprogram(
    168 		struct pipe_ctx *pipe_ctx_old,
    169 		struct pipe_ctx *pipe_ctx);
    170 
    171 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
    172 		struct bit_depth_reduction_params *fmt_bit_depth);
    173 
    174 void update_audio_usage(
    175 		struct resource_context *res_ctx,
    176 		const struct resource_pool *pool,
    177 		struct audio *audio,
    178 		bool acquired);
    179 
    180 unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format);
    181 
    182 void get_audio_check(struct audio_info *aud_modes,
    183 	struct audio_check *aud_chk);
    184 #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
    185