1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef __AMDGPU_DM_H__
27#define __AMDGPU_DM_H__
28
29#include <drm/drmP.h>
30#include <drm/drm_atomic.h>
31
32
33
34
35
36
37
38
39
40
41
42#define AMDGPU_DM_MAX_DISPLAY_INDEX 31
43
44
45
46
47
48#include "irq_types.h"
49#include "signal_types.h"
50
51
52struct amdgpu_device;
53struct drm_device;
54struct amdgpu_dm_irq_handler_data;
55struct dc;
56
57struct common_irq_params {
58 struct amdgpu_device *adev;
59 enum dc_irq_source irq_src;
60};
61
62struct irq_list_head {
63 struct list_head head;
64
65 struct work_struct work;
66};
67
68struct dm_comressor_info {
69 void *cpu_addr;
70 struct amdgpu_bo *bo_ptr;
71 uint64_t gpu_addr;
72};
73
74struct amdgpu_display_manager {
75 struct dc *dc;
76 struct cgs_device *cgs_device;
77
78 struct amdgpu_device *adev;
79 struct drm_device *ddev;
80 u16 display_indexes_num;
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 struct irq_list_head irq_handler_list_low_tab[DAL_IRQ_SOURCES_NUMBER];
96 struct list_head irq_handler_list_high_tab[DAL_IRQ_SOURCES_NUMBER];
97
98 struct common_irq_params
99 pflip_params[DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1];
100
101 struct common_irq_params
102 vblank_params[DC_IRQ_SOURCE_VBLANK6 - DC_IRQ_SOURCE_VBLANK1 + 1];
103
104
105 spinlock_t irq_handler_list_table_lock;
106
107 struct backlight_device *backlight_dev;
108
109 const struct dc_link *backlight_link;
110
111 struct mod_freesync *freesync_module;
112
113
114
115
116 struct drm_atomic_state *cached_state;
117
118 struct dm_comressor_info compressor;
119
120 const struct firmware *fw_dmcu;
121 uint32_t dmcu_fw_version;
122};
123
124struct amdgpu_dm_connector {
125
126 struct drm_connector base;
127 uint32_t connector_id;
128
129
130
131 struct edid *edid;
132
133
134 struct amdgpu_hpd hpd;
135
136
137 int num_modes;
138
139
140
141 struct dc_sink *dc_sink;
142 struct dc_link *dc_link;
143 struct dc_sink *dc_em_sink;
144
145
146 struct drm_dp_mst_topology_mgr mst_mgr;
147 struct amdgpu_dm_dp_aux dm_dp_aux;
148 struct drm_dp_mst_port *port;
149 struct amdgpu_dm_connector *mst_port;
150 struct amdgpu_encoder *mst_encoder;
151
152
153 struct amdgpu_i2c_adapter *i2c;
154
155
156 int min_vfreq ;
157 int max_vfreq ;
158 int pixel_clock_mhz;
159
160 struct mutex hpd_lock;
161
162 bool fake_enable;
163};
164
165#define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
166
167extern const struct amdgpu_ip_block_version dm_ip_block;
168
169struct amdgpu_framebuffer;
170struct amdgpu_display_manager;
171struct dc_validation_set;
172struct dc_plane_state;
173
174struct dm_plane_state {
175 struct drm_plane_state base;
176 struct dc_plane_state *dc_state;
177};
178
179struct dm_crtc_state {
180 struct drm_crtc_state base;
181 struct dc_stream_state *stream;
182
183 int crc_skip_count;
184 bool crc_enabled;
185
186 bool freesync_enabled;
187 struct dc_crtc_timing_adjust adjust;
188 struct dc_info_packet vrr_infopacket;
189};
190
191#define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
192
193struct dm_atomic_state {
194 struct drm_atomic_state base;
195
196 struct dc_state *context;
197};
198
199#define to_dm_atomic_state(x) container_of(x, struct dm_atomic_state, base)
200
201struct dm_connector_state {
202 struct drm_connector_state base;
203
204 enum amdgpu_rmx_type scaling;
205 uint8_t underscan_vborder;
206 uint8_t underscan_hborder;
207 uint8_t max_bpc;
208 bool underscan_enable;
209 bool freesync_enable;
210 bool freesync_capable;
211};
212
213#define to_dm_connector_state(x)\
214 container_of((x), struct dm_connector_state, base)
215
216void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector);
217struct drm_connector_state *
218amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector);
219int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
220 struct drm_connector_state *state,
221 struct drm_property *property,
222 uint64_t val);
223
224int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
225 const struct drm_connector_state *state,
226 struct drm_property *property,
227 uint64_t *val);
228
229int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
230
231void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
232 struct amdgpu_dm_connector *aconnector,
233 int connector_type,
234 struct dc_link *link,
235 int link_index);
236
237enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connector,
238 struct drm_display_mode *mode);
239
240void dm_restore_drm_connector_state(struct drm_device *dev,
241 struct drm_connector *connector);
242
243void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
244 struct edid *edid);
245
246
247#ifdef CONFIG_DEBUG_FS
248int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name);
249int amdgpu_dm_crtc_verify_crc_source(struct drm_crtc *crtc,
250 const char *src_name,
251 size_t *values_cnt);
252void amdgpu_dm_crtc_handle_crc_irq(struct drm_crtc *crtc);
253#else
254#define amdgpu_dm_crtc_set_crc_source NULL
255#define amdgpu_dm_crtc_verify_crc_source NULL
256#define amdgpu_dm_crtc_handle_crc_irq(x)
257#endif
258
259#define MAX_COLOR_LUT_ENTRIES 4096
260
261#define MAX_COLOR_LEGACY_LUT_ENTRIES 256
262
263void amdgpu_dm_init_color_mod(void);
264int amdgpu_dm_set_degamma_lut(struct drm_crtc_state *crtc_state,
265 struct dc_plane_state *dc_plane_state);
266void amdgpu_dm_set_ctm(struct dm_crtc_state *crtc);
267int amdgpu_dm_set_regamma_lut(struct dm_crtc_state *crtc);
268
269extern const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs;
270
271#endif
272