xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/display/dc/inc/compressor.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: compressor.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2012-15 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 
28 #ifndef __DAL_COMPRESSOR_H__
29 #define __DAL_COMPRESSOR_H__
30 
31 #include "include/grph_object_id.h"
32 #include "bios_parser_interface.h"
33 
34 enum fbc_compress_ratio {
35 	FBC_COMPRESS_RATIO_INVALID = 0,
36 	FBC_COMPRESS_RATIO_1TO1 = 1,
37 	FBC_COMPRESS_RATIO_2TO1 = 2,
38 	FBC_COMPRESS_RATIO_4TO1 = 4,
39 	FBC_COMPRESS_RATIO_8TO1 = 8,
40 };
41 
42 union fbc_physical_address {
43 	struct {
44 		uint32_t low_part;
45 		int32_t high_part;
46 	} addr;
47 	uint64_t quad_part;
48 };
49 
50 struct compr_addr_and_pitch_params {
51 	/* enum controller_id controller_id; */
52 	uint32_t inst;
53 	uint32_t source_view_width;
54 	uint32_t source_view_height;
55 };
56 
57 enum fbc_hw_max_resolution_supported {
58 	FBC_MAX_X = 3840,
59 	FBC_MAX_Y = 2400,
60 	FBC_MAX_X_SG = 1920,
61 	FBC_MAX_Y_SG = 1080,
62 };
63 
64 struct compressor;
65 
66 struct compressor_funcs {
67 
68 	void (*power_up_fbc)(struct compressor *cp);
69 	void (*enable_fbc)(struct compressor *cp,
70 		struct compr_addr_and_pitch_params *params);
71 	void (*disable_fbc)(struct compressor *cp);
72 	void (*set_fbc_invalidation_triggers)(struct compressor *cp,
73 		uint32_t fbc_trigger);
74 	void (*surface_address_and_pitch)(
75 		struct compressor *cp,
76 		struct compr_addr_and_pitch_params *params);
77 	bool (*is_fbc_enabled_in_hw)(struct compressor *cp,
78 		uint32_t *fbc_mapped_crtc_id);
79 };
80 struct compressor {
81 	struct dc_context *ctx;
82 	/* CONTROLLER_ID_D0 + instance, CONTROLLER_ID_UNDEFINED = 0 */
83 	uint32_t attached_inst;
84 	bool is_enabled;
85 	const struct compressor_funcs *funcs;
86 	union {
87 		uint32_t raw;
88 		struct {
89 			uint32_t FBC_SUPPORT:1;
90 			uint32_t FB_POOL:1;
91 			uint32_t DYNAMIC_ALLOC:1;
92 			uint32_t LPT_SUPPORT:1;
93 			uint32_t LPT_MC_CONFIG:1;
94 			uint32_t DUMMY_BACKEND:1;
95 			uint32_t CLK_GATING_DISABLED:1;
96 
97 		} bits;
98 	} options;
99 
100 	union fbc_physical_address compr_surface_address;
101 
102 	uint32_t embedded_panel_h_size;
103 	uint32_t embedded_panel_v_size;
104 	uint32_t memory_bus_width;
105 	uint32_t banks_num;
106 	uint32_t raw_size;
107 	uint32_t channel_interleave_size;
108 	uint32_t dram_channels_num;
109 
110 	uint32_t allocated_size;
111 	uint32_t preferred_requested_size;
112 	uint32_t lpt_channels_num;
113 	enum fbc_compress_ratio min_compress_ratio;
114 };
115 
116 struct fbc_input_info {
117 	bool           dynamic_fbc_buffer_alloc;
118 	unsigned int   source_view_width;
119 	unsigned int   source_view_height;
120 	unsigned int   num_of_active_targets;
121 };
122 
123 
124 struct fbc_requested_compressed_size {
125 	unsigned int   preferred_size;
126 	unsigned int   preferred_size_alignment;
127 	unsigned int   min_size;
128 	unsigned int   min_size_alignment;
129 	union {
130 		struct {
131 			/* Above preferedSize must be allocated in FB pool */
132 			unsigned int preferred_must_be_framebuffer_pool : 1;
133 			/* Above minSize must be allocated in FB pool */
134 			unsigned int min_must_be_framebuffer_pool : 1;
135 		} bits;
136 		unsigned int flags;
137 	};
138 };
139 #endif
140