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
27
28
29
30
31
32
33#ifndef __DRM_CRTC_HELPER_H__
34#define __DRM_CRTC_HELPER_H__
35
36#include <linux/spinlock.h>
37#include <linux/types.h>
38#include <linux/idr.h>
39
40#include <linux/fb.h>
41
42#include <drm/drm_crtc.h>
43
44enum mode_set_atomic {
45 LEAVE_ATOMIC_MODE_SET,
46 ENTER_ATOMIC_MODE_SET,
47};
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75struct drm_crtc_helper_funcs {
76
77
78
79
80 void (*dpms)(struct drm_crtc *crtc, int mode);
81 void (*prepare)(struct drm_crtc *crtc);
82 void (*commit)(struct drm_crtc *crtc);
83
84
85 bool (*mode_fixup)(struct drm_crtc *crtc,
86 const struct drm_display_mode *mode,
87 struct drm_display_mode *adjusted_mode);
88
89 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
90 struct drm_display_mode *adjusted_mode, int x, int y,
91 struct drm_framebuffer *old_fb);
92
93 void (*mode_set_nofb)(struct drm_crtc *crtc);
94
95
96 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
97 struct drm_framebuffer *old_fb);
98 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
99 struct drm_framebuffer *fb, int x, int y,
100 enum mode_set_atomic);
101
102
103 void (*load_lut)(struct drm_crtc *crtc);
104
105 void (*disable)(struct drm_crtc *crtc);
106 void (*enable)(struct drm_crtc *crtc);
107
108
109 int (*atomic_check)(struct drm_crtc *crtc,
110 struct drm_crtc_state *state);
111 void (*atomic_begin)(struct drm_crtc *crtc,
112 struct drm_crtc_state *old_crtc_state);
113 void (*atomic_flush)(struct drm_crtc *crtc,
114 struct drm_crtc_state *old_crtc_state);
115};
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141struct drm_encoder_helper_funcs {
142 void (*dpms)(struct drm_encoder *encoder, int mode);
143 void (*save)(struct drm_encoder *encoder);
144 void (*restore)(struct drm_encoder *encoder);
145
146 bool (*mode_fixup)(struct drm_encoder *encoder,
147 const struct drm_display_mode *mode,
148 struct drm_display_mode *adjusted_mode);
149 void (*prepare)(struct drm_encoder *encoder);
150 void (*commit)(struct drm_encoder *encoder);
151 void (*mode_set)(struct drm_encoder *encoder,
152 struct drm_display_mode *mode,
153 struct drm_display_mode *adjusted_mode);
154 struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
155
156 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
157 struct drm_connector *connector);
158 void (*disable)(struct drm_encoder *encoder);
159
160 void (*enable)(struct drm_encoder *encoder);
161
162
163 int (*atomic_check)(struct drm_encoder *encoder,
164 struct drm_crtc_state *crtc_state,
165 struct drm_connector_state *conn_state);
166};
167
168
169
170
171
172
173
174
175
176
177struct drm_connector_helper_funcs {
178 int (*get_modes)(struct drm_connector *connector);
179 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
180 struct drm_display_mode *mode);
181 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
182 struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
183 struct drm_connector_state *connector_state);
184};
185
186extern void drm_helper_disable_unused_functions(struct drm_device *dev);
187extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
188extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
189 struct drm_display_mode *mode,
190 int x, int y,
191 struct drm_framebuffer *old_fb);
192extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
193extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
194
195extern int drm_helper_connector_dpms(struct drm_connector *connector, int mode);
196
197extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
198
199extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
200 struct drm_mode_fb_cmd2 *mode_cmd);
201
202static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
203 const struct drm_crtc_helper_funcs *funcs)
204{
205 crtc->helper_private = funcs;
206}
207
208static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
209 const struct drm_encoder_helper_funcs *funcs)
210{
211 encoder->helper_private = funcs;
212}
213
214static inline void drm_connector_helper_add(struct drm_connector *connector,
215 const struct drm_connector_helper_funcs *funcs)
216{
217 connector->helper_private = funcs;
218}
219
220extern void drm_helper_resume_force_mode(struct drm_device *dev);
221
222int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
223 struct drm_display_mode *adjusted_mode, int x, int y,
224 struct drm_framebuffer *old_fb);
225int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
226 struct drm_framebuffer *old_fb);
227
228
229extern int drm_helper_probe_single_connector_modes(struct drm_connector
230 *connector, uint32_t maxX,
231 uint32_t maxY);
232extern int drm_helper_probe_single_connector_modes_nomerge(struct drm_connector
233 *connector,
234 uint32_t maxX,
235 uint32_t maxY);
236extern void drm_kms_helper_poll_init(struct drm_device *dev);
237extern void drm_kms_helper_poll_fini(struct drm_device *dev);
238extern bool drm_helper_hpd_irq_event(struct drm_device *dev);
239extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
240
241extern void drm_kms_helper_poll_disable(struct drm_device *dev);
242extern void drm_kms_helper_poll_enable(struct drm_device *dev);
243extern void drm_kms_helper_poll_enable_locked(struct drm_device *dev);
244
245#endif
246