]>
Commit | Line | Data |
---|---|---|
f453ba04 DA |
1 | /* |
2 | * Copyright © 2006 Keith Packard | |
3 | * Copyright © 2007-2008 Dave Airlie | |
4 | * Copyright © 2007-2008 Intel Corporation | |
5 | * Jesse Barnes <jesse.barnes@intel.com> | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a | |
8 | * copy of this software and associated documentation files (the "Software"), | |
9 | * to deal in the Software without restriction, including without limitation | |
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
11 | * and/or sell copies of the Software, and to permit persons to whom the | |
12 | * Software is furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
20 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
23 | * OTHER DEALINGS IN THE SOFTWARE. | |
24 | */ | |
25 | #ifndef __DRM_CRTC_H__ | |
26 | #define __DRM_CRTC_H__ | |
27 | ||
28 | #include <linux/i2c.h> | |
29 | #include <linux/spinlock.h> | |
30 | #include <linux/types.h> | |
31 | #include <linux/idr.h> | |
f453ba04 | 32 | #include <linux/fb.h> |
985e5dc2 | 33 | #include <linux/hdmi.h> |
b5571e9d | 34 | #include <linux/media-bus-format.h> |
d7d2c48e DH |
35 | #include <uapi/drm/drm_mode.h> |
36 | #include <uapi/drm/drm_fourcc.h> | |
51fd371b | 37 | #include <drm/drm_modeset_lock.h> |
308e5bcb | 38 | |
f453ba04 DA |
39 | struct drm_device; |
40 | struct drm_mode_set; | |
41 | struct drm_framebuffer; | |
7e3bdf4a | 42 | struct drm_object_properties; |
595887eb TR |
43 | struct drm_file; |
44 | struct drm_clip_rect; | |
7e435aad | 45 | struct device_node; |
e2330f07 | 46 | struct fence; |
f453ba04 DA |
47 | |
48 | #define DRM_MODE_OBJECT_CRTC 0xcccccccc | |
49 | #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 | |
50 | #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0 | |
51 | #define DRM_MODE_OBJECT_MODE 0xdededede | |
52 | #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0 | |
53 | #define DRM_MODE_OBJECT_FB 0xfbfbfbfb | |
54 | #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb | |
8cf5c917 | 55 | #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee |
98f75de4 | 56 | #define DRM_MODE_OBJECT_ANY 0 |
f453ba04 DA |
57 | |
58 | struct drm_mode_object { | |
59 | uint32_t id; | |
60 | uint32_t type; | |
7e3bdf4a PZ |
61 | struct drm_object_properties *properties; |
62 | }; | |
63 | ||
fe456168 | 64 | #define DRM_OBJECT_MAX_PROPERTY 24 |
7e3bdf4a | 65 | struct drm_object_properties { |
88a48e29 | 66 | int count, atomic_count; |
b17cd757 RC |
67 | /* NOTE: if we ever start dynamically destroying properties (ie. |
68 | * not at drm_mode_config_cleanup() time), then we'd have to do | |
69 | * a better job of detaching property from mode objects to avoid | |
70 | * dangling property pointers: | |
71 | */ | |
72 | struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY]; | |
22b8b13b RC |
73 | /* do not read/write values directly, but use drm_object_property_get_value() |
74 | * and drm_object_property_set_value(): | |
75 | */ | |
7e3bdf4a | 76 | uint64_t values[DRM_OBJECT_MAX_PROPERTY]; |
f453ba04 DA |
77 | }; |
78 | ||
ebc44cf3 RC |
79 | static inline int64_t U642I64(uint64_t val) |
80 | { | |
81 | return (int64_t)*((int64_t *)&val); | |
82 | } | |
83 | static inline uint64_t I642U64(int64_t val) | |
84 | { | |
85 | return (uint64_t)*((uint64_t *)&val); | |
86 | } | |
87 | ||
d9c38242 RF |
88 | /* |
89 | * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the | |
90 | * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and | |
91 | * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation | |
92 | */ | |
62209070 | 93 | #define DRM_ROTATE_MASK 0x0f |
06596961 VS |
94 | #define DRM_ROTATE_0 0 |
95 | #define DRM_ROTATE_90 1 | |
96 | #define DRM_ROTATE_180 2 | |
97 | #define DRM_ROTATE_270 3 | |
62209070 | 98 | #define DRM_REFLECT_MASK (~DRM_ROTATE_MASK) |
06596961 VS |
99 | #define DRM_REFLECT_X 4 |
100 | #define DRM_REFLECT_Y 5 | |
101 | ||
55310008 DV |
102 | enum drm_connector_force { |
103 | DRM_FORCE_UNSPECIFIED, | |
104 | DRM_FORCE_OFF, | |
105 | DRM_FORCE_ON, /* force on analog part normally */ | |
106 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ | |
f453ba04 DA |
107 | }; |
108 | ||
55310008 | 109 | #include <drm/drm_modes.h> |
4aa17cf0 | 110 | |
f453ba04 DA |
111 | enum drm_connector_status { |
112 | connector_status_connected = 1, | |
113 | connector_status_disconnected = 2, | |
114 | connector_status_unknown = 3, | |
115 | }; | |
116 | ||
117 | enum subpixel_order { | |
118 | SubPixelUnknown = 0, | |
119 | SubPixelHorizontalRGB, | |
120 | SubPixelHorizontalBGR, | |
121 | SubPixelVerticalRGB, | |
122 | SubPixelVerticalBGR, | |
123 | SubPixelNone, | |
124 | }; | |
125 | ||
da05a5a7 JB |
126 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
127 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) | |
128 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) | |
f453ba04 DA |
129 | /* |
130 | * Describes a given display (e.g. CRT or flat panel) and its limitations. | |
131 | */ | |
132 | struct drm_display_info { | |
133 | char name[DRM_DISPLAY_INFO_LEN]; | |
fb439640 | 134 | |
f453ba04 DA |
135 | /* Physical size */ |
136 | unsigned int width_mm; | |
137 | unsigned int height_mm; | |
138 | ||
f453ba04 DA |
139 | /* Clock limits FIXME: storage format */ |
140 | unsigned int min_vfreq, max_vfreq; | |
141 | unsigned int min_hfreq, max_hfreq; | |
142 | unsigned int pixel_clock; | |
3b11228b | 143 | unsigned int bpc; |
f453ba04 | 144 | |
f453ba04 | 145 | enum subpixel_order subpixel_order; |
da05a5a7 | 146 | u32 color_formats; |
f453ba04 | 147 | |
b5571e9d BB |
148 | const u32 *bus_formats; |
149 | unsigned int num_bus_formats; | |
150 | ||
5d02626d MK |
151 | /* Mask of supported hdmi deep color modes */ |
152 | u8 edid_hdmi_dc_modes; | |
153 | ||
ebec9a7b | 154 | u8 cea_rev; |
f453ba04 DA |
155 | }; |
156 | ||
138f9ebb DA |
157 | /* data corresponds to displayid vend/prod/serial */ |
158 | struct drm_tile_group { | |
159 | struct kref refcount; | |
160 | struct drm_device *dev; | |
161 | int id; | |
162 | u8 group_data[8]; | |
163 | }; | |
164 | ||
c6b0ca3e DV |
165 | /** |
166 | * struct drm_framebuffer_funcs - framebuffer hooks | |
167 | */ | |
f453ba04 | 168 | struct drm_framebuffer_funcs { |
c6b0ca3e DV |
169 | /** |
170 | * @destroy: | |
171 | * | |
172 | * Clean up framebuffer resources, specifically also unreference the | |
173 | * backing storage. The core guarantees to call this function for every | |
174 | * framebuffer successfully created by ->fb_create() in | |
175 | * &drm_mode_config_funcs. | |
176 | */ | |
f453ba04 | 177 | void (*destroy)(struct drm_framebuffer *framebuffer); |
c6b0ca3e DV |
178 | |
179 | /** | |
180 | * @create_handle: | |
181 | * | |
182 | * Create a buffer handle in the driver-specific buffer manager (either | |
183 | * GEM or TTM) valid for the passed-in struct &drm_file. This is used by | |
184 | * the core to implement the GETFB IOCTL, which returns (for | |
185 | * sufficiently priviledged user) also a native buffer handle. This can | |
186 | * be used for seamless transitions between modesetting clients by | |
187 | * copying the current screen contents to a private buffer and blending | |
188 | * between that and the new contents. | |
189 | * | |
190 | * RETURNS: | |
191 | * | |
192 | * 0 on success or a negative error code on failure. | |
193 | */ | |
f453ba04 DA |
194 | int (*create_handle)(struct drm_framebuffer *fb, |
195 | struct drm_file *file_priv, | |
196 | unsigned int *handle); | |
c6b0ca3e DV |
197 | /** |
198 | * @dirty: | |
884840aa | 199 | * |
c6b0ca3e | 200 | * Optional callback for the dirty fb IOCTL. |
884840aa | 201 | * |
c6b0ca3e DV |
202 | * Userspace can notify the driver via this callback that an area of the |
203 | * framebuffer has changed and should be flushed to the display | |
204 | * hardware. This can also be used internally, e.g. by the fbdev | |
205 | * emulation, though that's not the case currently. | |
206 | * | |
207 | * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd | |
208 | * for more information as all the semantics and arguments have a one to | |
209 | * one mapping on this function. | |
210 | * | |
211 | * RETURNS: | |
212 | * | |
213 | * 0 on success or a negative error code on failure. | |
884840aa | 214 | */ |
02b00162 TH |
215 | int (*dirty)(struct drm_framebuffer *framebuffer, |
216 | struct drm_file *file_priv, unsigned flags, | |
884840aa JB |
217 | unsigned color, struct drm_clip_rect *clips, |
218 | unsigned num_clips); | |
f453ba04 DA |
219 | }; |
220 | ||
221 | struct drm_framebuffer { | |
222 | struct drm_device *dev; | |
f7eff60e RC |
223 | /* |
224 | * Note that the fb is refcounted for the benefit of driver internals, | |
225 | * for example some hw, disabling a CRTC/plane is asynchronous, and | |
226 | * scanout does not actually complete until the next vblank. So some | |
227 | * cleanup (like releasing the reference(s) on the backing GEM bo(s)) | |
228 | * should be deferred. In cases like this, the driver would like to | |
229 | * hold a ref to the fb even though it has already been removed from | |
230 | * userspace perspective. | |
231 | */ | |
232 | struct kref refcount; | |
4b096ac1 DV |
233 | /* |
234 | * Place on the dev->mode_config.fb_list, access protected by | |
235 | * dev->mode_config.fb_lock. | |
236 | */ | |
f453ba04 DA |
237 | struct list_head head; |
238 | struct drm_mode_object base; | |
239 | const struct drm_framebuffer_funcs *funcs; | |
01f2c773 VS |
240 | unsigned int pitches[4]; |
241 | unsigned int offsets[4]; | |
e3eb3250 | 242 | uint64_t modifier[4]; |
f453ba04 DA |
243 | unsigned int width; |
244 | unsigned int height; | |
245 | /* depth can be 15 or 16 */ | |
246 | unsigned int depth; | |
247 | int bits_per_pixel; | |
248 | int flags; | |
308e5bcb | 249 | uint32_t pixel_format; /* fourcc format */ |
f453ba04 DA |
250 | struct list_head filp_head; |
251 | }; | |
252 | ||
253 | struct drm_property_blob { | |
254 | struct drm_mode_object base; | |
6bcacf51 DS |
255 | struct drm_device *dev; |
256 | struct kref refcount; | |
e2f5d2ea DS |
257 | struct list_head head_global; |
258 | struct list_head head_file; | |
ecbbe59b | 259 | size_t length; |
d63f5e6b | 260 | unsigned char data[]; |
f453ba04 DA |
261 | }; |
262 | ||
263 | struct drm_property_enum { | |
264 | uint64_t value; | |
265 | struct list_head head; | |
266 | char name[DRM_PROP_NAME_LEN]; | |
267 | }; | |
268 | ||
269 | struct drm_property { | |
270 | struct list_head head; | |
271 | struct drm_mode_object base; | |
272 | uint32_t flags; | |
273 | char name[DRM_PROP_NAME_LEN]; | |
274 | uint32_t num_values; | |
275 | uint64_t *values; | |
98f75de4 | 276 | struct drm_device *dev; |
f453ba04 | 277 | |
3758b341 | 278 | struct list_head enum_list; |
f453ba04 DA |
279 | }; |
280 | ||
281 | struct drm_crtc; | |
282 | struct drm_connector; | |
283 | struct drm_encoder; | |
d91d8a3f | 284 | struct drm_pending_vblank_event; |
8cf5c917 | 285 | struct drm_plane; |
3b336ec4 | 286 | struct drm_bridge; |
144ecb97 DV |
287 | struct drm_atomic_state; |
288 | ||
4490d4c7 DV |
289 | struct drm_crtc_helper_funcs; |
290 | struct drm_encoder_helper_funcs; | |
291 | struct drm_connector_helper_funcs; | |
292 | struct drm_plane_helper_funcs; | |
293 | ||
144ecb97 | 294 | /** |
cc4ceb48 | 295 | * struct drm_crtc_state - mutable CRTC state |
07cc0ef6 | 296 | * @crtc: backpointer to the CRTC |
144ecb97 | 297 | * @enable: whether the CRTC should be enabled, gates all other state |
d9b13620 | 298 | * @active: whether the CRTC is actively displaying (used for DPMS) |
fc596660 ML |
299 | * @planes_changed: planes on this crtc are updated |
300 | * @mode_changed: crtc_state->mode or crtc_state->enable has been changed | |
301 | * @active_changed: crtc_state->active has been toggled. | |
302 | * @connectors_changed: connectors to this crtc have been updated | |
6ddd388a | 303 | * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes |
623369e5 DV |
304 | * @last_vblank_count: for helpers and drivers to capture the vblank of the |
305 | * update to ensure framebuffer cleanup isn't done too early | |
2f324b42 | 306 | * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings |
144ecb97 DV |
307 | * @mode: current mode timings |
308 | * @event: optional pointer to a DRM event to signal upon completion of the | |
309 | * state update | |
310 | * @state: backpointer to global drm_atomic_state | |
d9b13620 DV |
311 | * |
312 | * Note that the distinction between @enable and @active is rather subtile: | |
313 | * Flipping @active while @enable is set without changing anything else may | |
314 | * never return in a failure from the ->atomic_check callback. Userspace assumes | |
315 | * that a DPMS On will always succeed. In other words: @enable controls resource | |
316 | * assignment, @active controls the actual hardware state. | |
144ecb97 DV |
317 | */ |
318 | struct drm_crtc_state { | |
07cc0ef6 DV |
319 | struct drm_crtc *crtc; |
320 | ||
cc4ceb48 | 321 | bool enable; |
d9b13620 | 322 | bool active; |
144ecb97 | 323 | |
c2fcd274 DV |
324 | /* computed state bits used by helpers and drivers */ |
325 | bool planes_changed : 1; | |
623369e5 | 326 | bool mode_changed : 1; |
eab3bbef | 327 | bool active_changed : 1; |
fc596660 | 328 | bool connectors_changed : 1; |
623369e5 | 329 | |
6ddd388a RC |
330 | /* attached planes bitmask: |
331 | * WARNING: transitional helpers do not maintain plane_mask so | |
332 | * drivers not converted over to atomic helpers should not rely | |
333 | * on plane_mask being accurate! | |
334 | */ | |
335 | u32 plane_mask; | |
336 | ||
623369e5 DV |
337 | /* last_vblank_count: for vblank waits before cleanup */ |
338 | u32 last_vblank_count; | |
c2fcd274 | 339 | |
2f324b42 DV |
340 | /* adjusted_mode: for use by helpers and drivers */ |
341 | struct drm_display_mode adjusted_mode; | |
342 | ||
144ecb97 DV |
343 | struct drm_display_mode mode; |
344 | ||
99cf4a29 DS |
345 | /* blob property to expose current mode to atomic userspace */ |
346 | struct drm_property_blob *mode_blob; | |
347 | ||
144ecb97 DV |
348 | struct drm_pending_vblank_event *event; |
349 | ||
350 | struct drm_atomic_state *state; | |
351 | }; | |
f453ba04 DA |
352 | |
353 | /** | |
3bf0401c | 354 | * struct drm_crtc_funcs - control CRTCs for a given device |
f453ba04 DA |
355 | * |
356 | * The drm_crtc_funcs structure is the central CRTC management structure | |
357 | * in the DRM. Each CRTC controls one or more connectors (note that the name | |
358 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. | |
359 | * connectors, not just CRTs). | |
360 | * | |
361 | * Each driver is responsible for filling out this structure at startup time, | |
362 | * in addition to providing other modesetting features, like i2c and DDC | |
363 | * bus accessors. | |
364 | */ | |
365 | struct drm_crtc_funcs { | |
88548636 DV |
366 | /** |
367 | * @reset: | |
368 | * | |
369 | * Reset CRTC hardware and software state to off. This function isn't | |
370 | * called by the core directly, only through drm_mode_config_reset(). | |
371 | * It's not a helper hook only for historical reasons. | |
372 | * | |
373 | * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset | |
374 | * atomic state using this hook. | |
375 | */ | |
eb033556 | 376 | void (*reset)(struct drm_crtc *crtc); |
f453ba04 | 377 | |
f6da8c6e DV |
378 | /** |
379 | * @cursor_set: | |
380 | * | |
381 | * Update the cursor image. The cursor position is relative to the CRTC | |
382 | * and can be partially or fully outside of the visible area. | |
383 | * | |
384 | * Note that contrary to all other KMS functions the legacy cursor entry | |
385 | * points don't take a framebuffer object, but instead take directly a | |
386 | * raw buffer object id from the driver's buffer manager (which is | |
387 | * either GEM or TTM for current drivers). | |
388 | * | |
389 | * This entry point is deprecated, drivers should instead implement | |
390 | * universal plane support and register a proper cursor plane using | |
391 | * drm_crtc_init_with_planes(). | |
392 | * | |
393 | * This callback is optional | |
394 | * | |
395 | * RETURNS: | |
396 | * | |
397 | * 0 on success or a negative error code on failure. | |
398 | */ | |
f453ba04 DA |
399 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
400 | uint32_t handle, uint32_t width, uint32_t height); | |
f6da8c6e DV |
401 | |
402 | /** | |
403 | * @cursor_set2: | |
404 | * | |
405 | * Update the cursor image, including hotspot information. The hotspot | |
406 | * must not affect the cursor position in CRTC coordinates, but is only | |
407 | * meant as a hint for virtualized display hardware to coordinate the | |
408 | * guests and hosts cursor position. The cursor hotspot is relative to | |
409 | * the cursor image. Otherwise this works exactly like @cursor_set. | |
410 | * | |
411 | * This entry point is deprecated, drivers should instead implement | |
412 | * universal plane support and register a proper cursor plane using | |
413 | * drm_crtc_init_with_planes(). | |
414 | * | |
415 | * This callback is optional. | |
416 | * | |
417 | * RETURNS: | |
418 | * | |
419 | * 0 on success or a negative error code on failure. | |
420 | */ | |
4c813d4d DA |
421 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
422 | uint32_t handle, uint32_t width, uint32_t height, | |
423 | int32_t hot_x, int32_t hot_y); | |
f6da8c6e DV |
424 | |
425 | /** | |
426 | * @cursor_move: | |
427 | * | |
428 | * Update the cursor position. The cursor does not need to be visible | |
429 | * when this hook is called. | |
430 | * | |
431 | * This entry point is deprecated, drivers should instead implement | |
432 | * universal plane support and register a proper cursor plane using | |
433 | * drm_crtc_init_with_planes(). | |
434 | * | |
435 | * This callback is optional. | |
436 | * | |
437 | * RETURNS: | |
438 | * | |
439 | * 0 on success or a negative error code on failure. | |
440 | */ | |
f453ba04 DA |
441 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
442 | ||
f6da8c6e DV |
443 | /** |
444 | * @gamma_set: | |
445 | * | |
446 | * Set gamma on the CRTC. | |
447 | * | |
448 | * This callback is optional. | |
449 | * | |
450 | * NOTE: | |
451 | * | |
452 | * Drivers that support gamma tables and also fbdev emulation through | |
453 | * the provided helper library need to take care to fill out the gamma | |
454 | * hooks for both. Currently there's a bit an unfortunate duplication | |
455 | * going on, which should eventually be unified to just one set of | |
456 | * hooks. | |
457 | */ | |
f453ba04 | 458 | void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
7203425a | 459 | uint32_t start, uint32_t size); |
88548636 DV |
460 | |
461 | /** | |
462 | * @destroy: | |
463 | * | |
464 | * Clean up plane resources. This is only called at driver unload time | |
465 | * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged | |
466 | * in DRM. | |
467 | */ | |
f453ba04 DA |
468 | void (*destroy)(struct drm_crtc *crtc); |
469 | ||
f6da8c6e DV |
470 | /** |
471 | * @set_config: | |
472 | * | |
473 | * This is the main legacy entry point to change the modeset state on a | |
474 | * CRTC. All the details of the desired configuration are passed in a | |
475 | * struct &drm_mode_set - see there for details. | |
476 | * | |
477 | * Drivers implementing atomic modeset should use | |
478 | * drm_atomic_helper_set_config() to implement this hook. | |
479 | * | |
480 | * RETURNS: | |
481 | * | |
482 | * 0 on success or a negative error code on failure. | |
483 | */ | |
f453ba04 | 484 | int (*set_config)(struct drm_mode_set *set); |
d91d8a3f | 485 | |
f6da8c6e DV |
486 | /** |
487 | * @page_flip: | |
488 | * | |
489 | * Legacy entry point to schedule a flip to the given framebuffer. | |
490 | * | |
491 | * Page flipping is a synchronization mechanism that replaces the frame | |
492 | * buffer being scanned out by the CRTC with a new frame buffer during | |
493 | * vertical blanking, avoiding tearing (except when requested otherwise | |
494 | * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application | |
495 | * requests a page flip the DRM core verifies that the new frame buffer | |
496 | * is large enough to be scanned out by the CRTC in the currently | |
497 | * configured mode and then calls the CRTC ->page_flip() operation with a | |
498 | * pointer to the new frame buffer. | |
499 | * | |
500 | * The driver must wait for any pending rendering to the new framebuffer | |
501 | * to complete before executing the flip. It should also wait for any | |
502 | * pending rendering from other drivers if the underlying buffer is a | |
503 | * shared dma-buf. | |
504 | * | |
505 | * An application can request to be notified when the page flip has | |
506 | * completed. The drm core will supply a struct &drm_event in the event | |
507 | * parameter in this case. This can be handled by the | |
508 | * drm_crtc_send_vblank_event() function, which the driver should call on | |
509 | * the provided event upon completion of the flip. Note that if | |
510 | * the driver supports vblank signalling and timestamping the vblank | |
511 | * counters and timestamps must agree with the ones returned from page | |
512 | * flip events. With the current vblank helper infrastructure this can | |
513 | * be achieved by holding a vblank reference while the page flip is | |
514 | * pending, acquired through drm_crtc_vblank_get() and released with | |
515 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank | |
516 | * counter and timestamp tracking though, e.g. if they have accurate | |
517 | * timestamp registers in hardware. | |
518 | * | |
519 | * FIXME: | |
520 | * | |
521 | * Up to that point drivers need to manage events themselves and can use | |
522 | * even->base.list freely for that. Specifically they need to ensure | |
523 | * that they don't send out page flip (or vblank) events for which the | |
524 | * corresponding drm file has been closed already. The drm core | |
525 | * unfortunately does not (yet) take care of that. Therefore drivers | |
526 | * currently must clean up and release pending events in their | |
527 | * ->preclose driver function. | |
528 | * | |
529 | * This callback is optional. | |
530 | * | |
531 | * NOTE: | |
532 | * | |
533 | * Very early versions of the KMS ABI mandated that the driver must | |
534 | * block (but not reject) any rendering to the old framebuffer until the | |
535 | * flip operation has completed and the old framebuffer is no longer | |
536 | * visible. This requirement has been lifted, and userspace is instead | |
537 | * expected to request delivery of an event and wait with recycling old | |
538 | * buffers until such has been received. | |
539 | * | |
540 | * RETURNS: | |
541 | * | |
542 | * 0 on success or a negative error code on failure. Note that if a | |
543 | * ->page_flip() operation is already pending the callback should return | |
544 | * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode | |
545 | * or just runtime disabled through DPMS respectively the new atomic | |
546 | * "ACTIVE" state) should result in an -EINVAL error code. | |
d91d8a3f KH |
547 | */ |
548 | int (*page_flip)(struct drm_crtc *crtc, | |
549 | struct drm_framebuffer *fb, | |
ed8d1975 KP |
550 | struct drm_pending_vblank_event *event, |
551 | uint32_t flags); | |
bffd9de0 | 552 | |
88548636 DV |
553 | /** |
554 | * @set_property: | |
555 | * | |
556 | * This is the legacy entry point to update a property attached to the | |
557 | * CRTC. | |
558 | * | |
559 | * Drivers implementing atomic modeset should use | |
560 | * drm_atomic_helper_crtc_set_property() to implement this hook. | |
561 | * | |
562 | * This callback is optional if the driver does not support any legacy | |
563 | * driver-private properties. | |
564 | * | |
565 | * RETURNS: | |
566 | * | |
567 | * 0 on success or a negative error code on failure. | |
568 | */ | |
bffd9de0 PZ |
569 | int (*set_property)(struct drm_crtc *crtc, |
570 | struct drm_property *property, uint64_t val); | |
144ecb97 | 571 | |
88548636 DV |
572 | /** |
573 | * @atomic_duplicate_state: | |
574 | * | |
575 | * Duplicate the current atomic state for this CRTC and return it. | |
576 | * The core and helpers gurantee that any atomic state duplicated with | |
577 | * this hook and still owned by the caller (i.e. not transferred to the | |
578 | * driver by calling ->atomic_commit() from struct | |
579 | * &drm_mode_config_funcs) will be cleaned up by calling the | |
580 | * @atomic_destroy_state hook in this structure. | |
581 | * | |
582 | * Atomic drivers which don't subclass struct &drm_crtc should use | |
583 | * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the | |
584 | * state structure to extend it with driver-private state should use | |
585 | * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is | |
586 | * duplicated in a consistent fashion across drivers. | |
587 | * | |
588 | * It is an error to call this hook before crtc->state has been | |
589 | * initialized correctly. | |
590 | * | |
591 | * NOTE: | |
592 | * | |
593 | * If the duplicate state references refcounted resources this hook must | |
594 | * acquire a reference for each of them. The driver must release these | |
595 | * references again in @atomic_destroy_state. | |
596 | * | |
597 | * RETURNS: | |
598 | * | |
599 | * Duplicated atomic state or NULL when the allocation failed. | |
600 | */ | |
144ecb97 | 601 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); |
88548636 DV |
602 | |
603 | /** | |
604 | * @atomic_destroy_state: | |
605 | * | |
606 | * Destroy a state duplicated with @atomic_duplicate_state and release | |
607 | * or unreference all resources it references | |
608 | */ | |
144ecb97 | 609 | void (*atomic_destroy_state)(struct drm_crtc *crtc, |
cc4ceb48 | 610 | struct drm_crtc_state *state); |
88548636 DV |
611 | |
612 | /** | |
613 | * @atomic_set_property: | |
614 | * | |
615 | * Decode a driver-private property value and store the decoded value | |
616 | * into the passed-in state structure. Since the atomic core decodes all | |
617 | * standardized properties (even for extensions beyond the core set of | |
618 | * properties which might not be implemented by all drivers) this | |
619 | * requires drivers to subclass the state structure. | |
620 | * | |
621 | * Such driver-private properties should really only be implemented for | |
622 | * truly hardware/vendor specific state. Instead it is preferred to | |
623 | * standardize atomic extension and decode the properties used to expose | |
624 | * such an extension in the core. | |
625 | * | |
626 | * Do not call this function directly, use | |
627 | * drm_atomic_crtc_set_property() instead. | |
628 | * | |
629 | * This callback is optional if the driver does not support any | |
630 | * driver-private atomic properties. | |
631 | * | |
632 | * NOTE: | |
633 | * | |
634 | * This function is called in the state assembly phase of atomic | |
635 | * modesets, which can be aborted for any reason (including on | |
636 | * userspace's request to just check whether a configuration would be | |
637 | * possible). Drivers MUST NOT touch any persistent state (hardware or | |
638 | * software) or data structures except the passed in @state parameter. | |
639 | * | |
640 | * Also since userspace controls in which order properties are set this | |
641 | * function must not do any input validation (since the state update is | |
642 | * incomplete and hence likely inconsistent). Instead any such input | |
643 | * validation must be done in the various atomic_check callbacks. | |
644 | * | |
645 | * RETURNS: | |
646 | * | |
647 | * 0 if the property has been found, -EINVAL if the property isn't | |
648 | * implemented by the driver (which should never happen, the core only | |
649 | * asks for properties attached to this CRTC). No other validation is | |
650 | * allowed by the driver. The core already checks that the property | |
651 | * value is within the range (integer, valid enum value, ...) the driver | |
652 | * set when registering the property. | |
653 | */ | |
144ecb97 DV |
654 | int (*atomic_set_property)(struct drm_crtc *crtc, |
655 | struct drm_crtc_state *state, | |
656 | struct drm_property *property, | |
657 | uint64_t val); | |
88548636 DV |
658 | /** |
659 | * @atomic_get_property: | |
660 | * | |
661 | * Reads out the decoded driver-private property. This is used to | |
c6b0ca3e | 662 | * implement the GETCRTC IOCTL. |
88548636 DV |
663 | * |
664 | * Do not call this function directly, use | |
665 | * drm_atomic_crtc_get_property() instead. | |
666 | * | |
667 | * This callback is optional if the driver does not support any | |
668 | * driver-private atomic properties. | |
669 | * | |
670 | * RETURNS: | |
671 | * | |
672 | * 0 on success, -EINVAL if the property isn't implemented by the | |
673 | * driver (which should never happen, the core only asks for | |
674 | * properties attached to this CRTC). | |
675 | */ | |
ac9c9256 RC |
676 | int (*atomic_get_property)(struct drm_crtc *crtc, |
677 | const struct drm_crtc_state *state, | |
678 | struct drm_property *property, | |
679 | uint64_t *val); | |
f453ba04 DA |
680 | }; |
681 | ||
682 | /** | |
3bf0401c | 683 | * struct drm_crtc - central CRTC control structure |
7749163e | 684 | * @dev: parent DRM device |
2c0c33d4 | 685 | * @port: OF node used by drm_of_find_possible_crtcs() |
7749163e | 686 | * @head: list management |
51fd371b | 687 | * @mutex: per-CRTC locking |
7749163e | 688 | * @base: base KMS object for ID tracking etc. |
e13161af MR |
689 | * @primary: primary plane for this CRTC |
690 | * @cursor: cursor plane for this CRTC | |
2c0c33d4 DV |
691 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
692 | * @cursor_y: current y position of the cursor, used for universal cursor planes | |
f453ba04 | 693 | * @enabled: is this CRTC enabled? |
7749163e JB |
694 | * @mode: current mode timings |
695 | * @hwmode: mode timings as programmed to hw regs | |
f453ba04 DA |
696 | * @x: x position on screen |
697 | * @y: y position on screen | |
f453ba04 | 698 | * @funcs: CRTC control functions |
7749163e JB |
699 | * @gamma_size: size of gamma ramp |
700 | * @gamma_store: gamma ramp values | |
7749163e | 701 | * @helper_private: mid-layer private data |
bffd9de0 | 702 | * @properties: property tracking for this CRTC |
144ecb97 | 703 | * @state: current atomic state for this CRTC |
2c0c33d4 | 704 | * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for |
c6b0ca3e | 705 | * legacy IOCTLs |
f453ba04 DA |
706 | * |
707 | * Each CRTC may have one or more connectors associated with it. This structure | |
708 | * allows the CRTC to be controlled. | |
709 | */ | |
710 | struct drm_crtc { | |
711 | struct drm_device *dev; | |
7e435aad | 712 | struct device_node *port; |
f453ba04 DA |
713 | struct list_head head; |
714 | ||
3bf0401c | 715 | /* |
29494c17 DV |
716 | * crtc mutex |
717 | * | |
718 | * This provides a read lock for the overall crtc state (mode, dpms | |
719 | * state, ...) and a write lock for everything which can be update | |
720 | * without a full modeset (fb, cursor data, ...) | |
721 | */ | |
51fd371b | 722 | struct drm_modeset_lock mutex; |
29494c17 | 723 | |
f453ba04 DA |
724 | struct drm_mode_object base; |
725 | ||
e13161af MR |
726 | /* primary and cursor planes for CRTC */ |
727 | struct drm_plane *primary; | |
728 | struct drm_plane *cursor; | |
729 | ||
161d0dc1 MR |
730 | /* position of cursor plane on crtc */ |
731 | int cursor_x; | |
732 | int cursor_y; | |
733 | ||
f453ba04 DA |
734 | bool enabled; |
735 | ||
27641c3f | 736 | /* Requested mode from modesetting. */ |
f453ba04 DA |
737 | struct drm_display_mode mode; |
738 | ||
27641c3f MK |
739 | /* Programmed mode in hw, after adjustments for encoders, |
740 | * crtc, panel scaling etc. Needed for timestamping etc. | |
741 | */ | |
742 | struct drm_display_mode hwmode; | |
743 | ||
f453ba04 | 744 | int x, y; |
f453ba04 DA |
745 | const struct drm_crtc_funcs *funcs; |
746 | ||
747 | /* CRTC gamma size for reporting to userspace */ | |
748 | uint32_t gamma_size; | |
749 | uint16_t *gamma_store; | |
750 | ||
751 | /* if you are using the helper */ | |
4490d4c7 | 752 | const struct drm_crtc_helper_funcs *helper_private; |
bffd9de0 PZ |
753 | |
754 | struct drm_object_properties properties; | |
d059f652 | 755 | |
144ecb97 DV |
756 | struct drm_crtc_state *state; |
757 | ||
d059f652 | 758 | /* |
c6b0ca3e | 759 | * For legacy crtc IOCTLs so that atomic drivers can get at the locking |
d059f652 DV |
760 | * acquire context. |
761 | */ | |
762 | struct drm_modeset_acquire_ctx *acquire_ctx; | |
f453ba04 DA |
763 | }; |
764 | ||
144ecb97 DV |
765 | /** |
766 | * struct drm_connector_state - mutable connector state | |
07cc0ef6 | 767 | * @connector: backpointer to the connector |
cc4ceb48 | 768 | * @crtc: CRTC to connect connector to, NULL if disabled |
623369e5 | 769 | * @best_encoder: can be used by helpers and drivers to select the encoder |
144ecb97 DV |
770 | * @state: backpointer to global drm_atomic_state |
771 | */ | |
772 | struct drm_connector_state { | |
07cc0ef6 DV |
773 | struct drm_connector *connector; |
774 | ||
6ddd388a | 775 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ |
144ecb97 | 776 | |
623369e5 DV |
777 | struct drm_encoder *best_encoder; |
778 | ||
144ecb97 DV |
779 | struct drm_atomic_state *state; |
780 | }; | |
f453ba04 DA |
781 | |
782 | /** | |
3bf0401c | 783 | * struct drm_connector_funcs - control connectors on a given device |
144ecb97 | 784 | * |
f453ba04 DA |
785 | * Each CRTC may have one or more connectors attached to it. The functions |
786 | * below allow the core DRM code to control connectors, enumerate available modes, | |
787 | * etc. | |
788 | */ | |
789 | struct drm_connector_funcs { | |
6fe14acd DV |
790 | /** |
791 | * @dpms: | |
792 | * | |
793 | * Legacy entry point to set the per-connector DPMS state. Legacy DPMS | |
794 | * is exposed as a standard property on the connector, but diverted to | |
795 | * this callback in the drm core. Note that atomic drivers don't | |
796 | * implement the 4 level DPMS support on the connector any more, but | |
797 | * instead only have an on/off "ACTIVE" property on the CRTC object. | |
798 | * | |
799 | * Drivers implementing atomic modeset should use | |
800 | * drm_atomic_helper_connector_dpms() to implement this hook. | |
801 | * | |
802 | * RETURNS: | |
803 | * | |
804 | * 0 on success or a negative error code on failure. | |
805 | */ | |
9a69a9ac | 806 | int (*dpms)(struct drm_connector *connector, int mode); |
88548636 DV |
807 | |
808 | /** | |
809 | * @reset: | |
810 | * | |
811 | * Reset connector hardware and software state to off. This function isn't | |
812 | * called by the core directly, only through drm_mode_config_reset(). | |
813 | * It's not a helper hook only for historical reasons. | |
814 | * | |
815 | * Atomic drivers can use drm_atomic_helper_connector_reset() to reset | |
816 | * atomic state using this hook. | |
817 | */ | |
eb033556 | 818 | void (*reset)(struct drm_connector *connector); |
930a9e28 | 819 | |
6fe14acd DV |
820 | /** |
821 | * @detect: | |
822 | * | |
823 | * Check to see if anything is attached to the connector. The parameter | |
824 | * force is set to false whilst polling, true when checking the | |
825 | * connector due to a user request. force can be used by the driver to | |
826 | * avoid expensive, destructive operations during automated probing. | |
827 | * | |
828 | * FIXME: | |
829 | * | |
830 | * Note that this hook is only called by the probe helper. It's not in | |
831 | * the helper library vtable purely for historical reasons. The only DRM | |
832 | * core entry point to probe connector state is @fill_modes. | |
833 | * | |
834 | * RETURNS: | |
835 | * | |
836 | * drm_connector_status indicating the connector's status. | |
930a9e28 | 837 | */ |
7b334fcb | 838 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
930a9e28 | 839 | bool force); |
6fe14acd DV |
840 | |
841 | /** | |
842 | * @force: | |
843 | * | |
844 | * This function is called to update internal encoder state when the | |
845 | * connector is forced to a certain state by userspace, either through | |
846 | * the sysfs interfaces or on the kernel cmdline. In that case the | |
847 | * @detect callback isn't called. | |
848 | * | |
849 | * FIXME: | |
850 | * | |
851 | * Note that this hook is only called by the probe helper. It's not in | |
852 | * the helper library vtable purely for historical reasons. The only DRM | |
853 | * core entry point to probe connector state is @fill_modes. | |
854 | */ | |
855 | void (*force)(struct drm_connector *connector); | |
856 | ||
857 | /** | |
858 | * @fill_modes: | |
859 | * | |
860 | * Entry point for output detection and basic mode validation. The | |
861 | * driver should reprobe the output if needed (e.g. when hotplug | |
862 | * handling is unreliable), add all detected modes to connector->modes | |
863 | * and filter out any the device can't support in any configuration. It | |
864 | * also needs to filter out any modes wider or higher than the | |
865 | * parameters max_width and max_height indicate. | |
866 | * | |
867 | * The drivers must also prune any modes no longer valid from | |
868 | * connector->modes. Furthermore it must update connector->status and | |
869 | * connector->edid. If no EDID has been received for this output | |
870 | * connector->edid must be NULL. | |
871 | * | |
872 | * Drivers using the probe helpers should use | |
873 | * drm_helper_probe_single_connector_modes() or | |
874 | * drm_helper_probe_single_connector_modes_nomerge() to implement this | |
875 | * function. | |
876 | * | |
877 | * RETURNS: | |
878 | * | |
879 | * The number of modes detected and filled into connector->modes. | |
880 | */ | |
40a518d9 | 881 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); |
88548636 DV |
882 | |
883 | /** | |
884 | * @set_property: | |
885 | * | |
886 | * This is the legacy entry point to update a property attached to the | |
887 | * connector. | |
888 | * | |
889 | * Drivers implementing atomic modeset should use | |
890 | * drm_atomic_helper_connector_set_property() to implement this hook. | |
891 | * | |
892 | * This callback is optional if the driver does not support any legacy | |
893 | * driver-private properties. | |
894 | * | |
895 | * RETURNS: | |
896 | * | |
897 | * 0 on success or a negative error code on failure. | |
898 | */ | |
f453ba04 DA |
899 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
900 | uint64_t val); | |
88548636 DV |
901 | |
902 | /** | |
903 | * @destroy: | |
904 | * | |
905 | * Clean up connector resources. This is called at driver unload time | |
906 | * through drm_mode_config_cleanup(). It can also be called at runtime | |
907 | * when a connector is being hot-unplugged for drivers that support | |
908 | * connector hotplugging (e.g. DisplayPort MST). | |
909 | */ | |
f453ba04 | 910 | void (*destroy)(struct drm_connector *connector); |
144ecb97 | 911 | |
88548636 DV |
912 | /** |
913 | * @atomic_duplicate_state: | |
914 | * | |
915 | * Duplicate the current atomic state for this connector and return it. | |
916 | * The core and helpers gurantee that any atomic state duplicated with | |
917 | * this hook and still owned by the caller (i.e. not transferred to the | |
918 | * driver by calling ->atomic_commit() from struct | |
919 | * &drm_mode_config_funcs) will be cleaned up by calling the | |
920 | * @atomic_destroy_state hook in this structure. | |
921 | * | |
922 | * Atomic drivers which don't subclass struct &drm_connector_state should use | |
923 | * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the | |
924 | * state structure to extend it with driver-private state should use | |
925 | * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is | |
926 | * duplicated in a consistent fashion across drivers. | |
927 | * | |
928 | * It is an error to call this hook before connector->state has been | |
929 | * initialized correctly. | |
930 | * | |
931 | * NOTE: | |
932 | * | |
933 | * If the duplicate state references refcounted resources this hook must | |
934 | * acquire a reference for each of them. The driver must release these | |
935 | * references again in @atomic_destroy_state. | |
936 | * | |
937 | * RETURNS: | |
938 | * | |
939 | * Duplicated atomic state or NULL when the allocation failed. | |
940 | */ | |
144ecb97 | 941 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); |
88548636 DV |
942 | |
943 | /** | |
944 | * @atomic_destroy_state: | |
945 | * | |
946 | * Destroy a state duplicated with @atomic_duplicate_state and release | |
947 | * or unreference all resources it references | |
948 | */ | |
144ecb97 | 949 | void (*atomic_destroy_state)(struct drm_connector *connector, |
cc4ceb48 | 950 | struct drm_connector_state *state); |
88548636 DV |
951 | |
952 | /** | |
953 | * @atomic_set_property: | |
954 | * | |
955 | * Decode a driver-private property value and store the decoded value | |
956 | * into the passed-in state structure. Since the atomic core decodes all | |
957 | * standardized properties (even for extensions beyond the core set of | |
958 | * properties which might not be implemented by all drivers) this | |
959 | * requires drivers to subclass the state structure. | |
960 | * | |
961 | * Such driver-private properties should really only be implemented for | |
962 | * truly hardware/vendor specific state. Instead it is preferred to | |
963 | * standardize atomic extension and decode the properties used to expose | |
964 | * such an extension in the core. | |
965 | * | |
966 | * Do not call this function directly, use | |
967 | * drm_atomic_connector_set_property() instead. | |
968 | * | |
969 | * This callback is optional if the driver does not support any | |
970 | * driver-private atomic properties. | |
971 | * | |
972 | * NOTE: | |
973 | * | |
974 | * This function is called in the state assembly phase of atomic | |
975 | * modesets, which can be aborted for any reason (including on | |
976 | * userspace's request to just check whether a configuration would be | |
977 | * possible). Drivers MUST NOT touch any persistent state (hardware or | |
978 | * software) or data structures except the passed in @state parameter. | |
979 | * | |
980 | * Also since userspace controls in which order properties are set this | |
981 | * function must not do any input validation (since the state update is | |
982 | * incomplete and hence likely inconsistent). Instead any such input | |
983 | * validation must be done in the various atomic_check callbacks. | |
984 | * | |
985 | * RETURNS: | |
986 | * | |
987 | * 0 if the property has been found, -EINVAL if the property isn't | |
988 | * implemented by the driver (which shouldn't ever happen, the core only | |
989 | * asks for properties attached to this connector). No other validation | |
990 | * is allowed by the driver. The core already checks that the property | |
991 | * value is within the range (integer, valid enum value, ...) the driver | |
992 | * set when registering the property. | |
993 | */ | |
144ecb97 DV |
994 | int (*atomic_set_property)(struct drm_connector *connector, |
995 | struct drm_connector_state *state, | |
996 | struct drm_property *property, | |
997 | uint64_t val); | |
88548636 DV |
998 | |
999 | /** | |
1000 | * @atomic_get_property: | |
1001 | * | |
1002 | * Reads out the decoded driver-private property. This is used to | |
c6b0ca3e | 1003 | * implement the GETCONNECTOR IOCTL. |
88548636 DV |
1004 | * |
1005 | * Do not call this function directly, use | |
1006 | * drm_atomic_connector_get_property() instead. | |
1007 | * | |
1008 | * This callback is optional if the driver does not support any | |
1009 | * driver-private atomic properties. | |
1010 | * | |
1011 | * RETURNS: | |
1012 | * | |
1013 | * 0 on success, -EINVAL if the property isn't implemented by the | |
1014 | * driver (which shouldn't ever happen, the core only asks for | |
1015 | * properties attached to this connector). | |
1016 | */ | |
ac9c9256 RC |
1017 | int (*atomic_get_property)(struct drm_connector *connector, |
1018 | const struct drm_connector_state *state, | |
1019 | struct drm_property *property, | |
1020 | uint64_t *val); | |
f453ba04 DA |
1021 | }; |
1022 | ||
6c3db920 | 1023 | /** |
3bf0401c | 1024 | * struct drm_encoder_funcs - encoder controls |
6c3db920 JB |
1025 | * |
1026 | * Encoders sit between CRTCs and connectors. | |
1027 | */ | |
f453ba04 | 1028 | struct drm_encoder_funcs { |
88548636 DV |
1029 | /** |
1030 | * @reset: | |
1031 | * | |
1032 | * Reset encoder hardware and software state to off. This function isn't | |
1033 | * called by the core directly, only through drm_mode_config_reset(). | |
1034 | * It's not a helper hook only for historical reasons. | |
1035 | */ | |
eb033556 | 1036 | void (*reset)(struct drm_encoder *encoder); |
88548636 DV |
1037 | |
1038 | /** | |
1039 | * @destroy: | |
1040 | * | |
1041 | * Clean up encoder resources. This is only called at driver unload time | |
1042 | * through drm_mode_config_cleanup() since an encoder cannot be | |
1043 | * hotplugged in DRM. | |
1044 | */ | |
f453ba04 DA |
1045 | void (*destroy)(struct drm_encoder *encoder); |
1046 | }; | |
1047 | ||
afe887df | 1048 | #define DRM_CONNECTOR_MAX_ENCODER 3 |
f453ba04 DA |
1049 | |
1050 | /** | |
3bf0401c | 1051 | * struct drm_encoder - central DRM encoder structure |
db3e4499 JB |
1052 | * @dev: parent DRM device |
1053 | * @head: list management | |
1054 | * @base: base KMS object | |
e5748946 | 1055 | * @name: encoder name |
db3e4499 JB |
1056 | * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h |
1057 | * @possible_crtcs: bitmask of potential CRTC bindings | |
1058 | * @possible_clones: bitmask of potential sibling encoders for cloning | |
1059 | * @crtc: currently bound CRTC | |
3b336ec4 | 1060 | * @bridge: bridge associated to the encoder |
db3e4499 JB |
1061 | * @funcs: control functions |
1062 | * @helper_private: mid-layer private data | |
1063 | * | |
1064 | * CRTCs drive pixels to encoders, which convert them into signals | |
1065 | * appropriate for a given connector or set of connectors. | |
f453ba04 DA |
1066 | */ |
1067 | struct drm_encoder { | |
1068 | struct drm_device *dev; | |
1069 | struct list_head head; | |
1070 | ||
1071 | struct drm_mode_object base; | |
e5748946 | 1072 | char *name; |
f453ba04 DA |
1073 | int encoder_type; |
1074 | uint32_t possible_crtcs; | |
1075 | uint32_t possible_clones; | |
1076 | ||
1077 | struct drm_crtc *crtc; | |
3b336ec4 | 1078 | struct drm_bridge *bridge; |
f453ba04 | 1079 | const struct drm_encoder_funcs *funcs; |
4490d4c7 | 1080 | const struct drm_encoder_helper_funcs *helper_private; |
f453ba04 DA |
1081 | }; |
1082 | ||
eb1f8e4f DA |
1083 | /* should we poll this connector for connects and disconnects */ |
1084 | /* hot plug detectable */ | |
1085 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) | |
1086 | /* poll for connections */ | |
1087 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) | |
1088 | /* can cleanly poll for disconnections without flickering the screen */ | |
1089 | /* DACs should rarely do this without a lot of testing */ | |
1090 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) | |
1091 | ||
76adaa34 WF |
1092 | #define MAX_ELD_BYTES 128 |
1093 | ||
f453ba04 | 1094 | /** |
3bf0401c | 1095 | * struct drm_connector - central DRM connector control structure |
72252548 JB |
1096 | * @dev: parent DRM device |
1097 | * @kdev: kernel device for sysfs attributes | |
1098 | * @attr: sysfs attributes | |
1099 | * @head: list management | |
1100 | * @base: base KMS object | |
2abdd313 | 1101 | * @name: connector name |
72252548 JB |
1102 | * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h |
1103 | * @connector_type_id: index into connector type enum | |
f453ba04 DA |
1104 | * @interlace_allowed: can this connector handle interlaced modes? |
1105 | * @doublescan_allowed: can this connector handle doublescan? | |
2c0c33d4 | 1106 | * @stereo_allowed: can this connector handle stereo modes? |
72252548 JB |
1107 | * @modes: modes available on this connector (from fill_modes() + user) |
1108 | * @status: one of the drm_connector_status enums (connected, not, or unknown) | |
1109 | * @probed_modes: list of modes derived directly from the display | |
1110 | * @display_info: information about attached display (e.g. from EDID) | |
f453ba04 | 1111 | * @funcs: connector control functions |
72252548 | 1112 | * @edid_blob_ptr: DRM property containing EDID if present |
7e3bdf4a | 1113 | * @properties: property tracking for this connector |
2c0c33d4 | 1114 | * @path_blob_ptr: DRM blob property data for the DP MST path property |
72252548 JB |
1115 | * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling |
1116 | * @dpms: current dpms state | |
1117 | * @helper_private: mid-layer private data | |
2c0c33d4 | 1118 | * @cmdline_mode: mode line parsed from the kernel cmdline for this connector |
72252548 | 1119 | * @force: a %DRM_FORCE_<foo> state for forced mode sets |
2c0c33d4 | 1120 | * @override_edid: has the EDID been overwritten through debugfs for testing? |
72252548 JB |
1121 | * @encoder_ids: valid encoders for this connector |
1122 | * @encoder: encoder driving this connector, if any | |
1123 | * @eld: EDID-like data, if present | |
1124 | * @dvi_dual: dual link DVI, if found | |
1125 | * @max_tmds_clock: max clock rate, if found | |
1126 | * @latency_present: AV delay info from ELD, if found | |
1127 | * @video_latency: video latency info from ELD, if found | |
1128 | * @audio_latency: audio latency info from ELD, if found | |
1129 | * @null_edid_counter: track sinks that give us all zeros for the EDID | |
2c0c33d4 | 1130 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum |
ac6f2e29 | 1131 | * @edid_corrupt: indicates whether the last read EDID was corrupt |
2c0c33d4 | 1132 | * @debugfs_entry: debugfs directory for this connector |
144ecb97 | 1133 | * @state: current atomic state for this connector |
40d9b043 DA |
1134 | * @has_tile: is this connector connected to a tiled monitor |
1135 | * @tile_group: tile group for the connected monitor | |
1136 | * @tile_is_single_monitor: whether the tile is one monitor housing | |
1137 | * @num_h_tile: number of horizontal tiles in the tile group | |
1138 | * @num_v_tile: number of vertical tiles in the tile group | |
1139 | * @tile_h_loc: horizontal location of this tile | |
1140 | * @tile_v_loc: vertical location of this tile | |
1141 | * @tile_h_size: horizontal size of this tile. | |
1142 | * @tile_v_size: vertical size of this tile. | |
f453ba04 DA |
1143 | * |
1144 | * Each connector may be connected to one or more CRTCs, or may be clonable by | |
1145 | * another connector if they can share a CRTC. Each connector also has a specific | |
1146 | * position in the broader display (referred to as a 'screen' though it could | |
1147 | * span multiple monitors). | |
1148 | */ | |
1149 | struct drm_connector { | |
1150 | struct drm_device *dev; | |
5bdebb18 | 1151 | struct device *kdev; |
f453ba04 DA |
1152 | struct device_attribute *attr; |
1153 | struct list_head head; | |
1154 | ||
1155 | struct drm_mode_object base; | |
1156 | ||
2abdd313 | 1157 | char *name; |
f453ba04 DA |
1158 | int connector_type; |
1159 | int connector_type_id; | |
1160 | bool interlace_allowed; | |
1161 | bool doublescan_allowed; | |
560a067a | 1162 | bool stereo_allowed; |
f453ba04 DA |
1163 | struct list_head modes; /* list of modes on this connector */ |
1164 | ||
f453ba04 DA |
1165 | enum drm_connector_status status; |
1166 | ||
1167 | /* these are modes added by probing with DDC or the BIOS */ | |
1168 | struct list_head probed_modes; | |
1169 | ||
1170 | struct drm_display_info display_info; | |
1171 | const struct drm_connector_funcs *funcs; | |
1172 | ||
f453ba04 | 1173 | struct drm_property_blob *edid_blob_ptr; |
7e3bdf4a | 1174 | struct drm_object_properties properties; |
f453ba04 | 1175 | |
43aba7eb DA |
1176 | struct drm_property_blob *path_blob_ptr; |
1177 | ||
6f134d7b DA |
1178 | struct drm_property_blob *tile_blob_ptr; |
1179 | ||
eb1f8e4f DA |
1180 | uint8_t polled; /* DRM_CONNECTOR_POLL_* */ |
1181 | ||
c9fb15f6 KP |
1182 | /* requested DPMS state */ |
1183 | int dpms; | |
1184 | ||
4490d4c7 | 1185 | const struct drm_connector_helper_funcs *helper_private; |
f453ba04 | 1186 | |
d50ba256 | 1187 | /* forced on connector */ |
eaf99c74 | 1188 | struct drm_cmdline_mode cmdline_mode; |
d50ba256 | 1189 | enum drm_connector_force force; |
4cf2b281 | 1190 | bool override_edid; |
f453ba04 | 1191 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
f453ba04 | 1192 | struct drm_encoder *encoder; /* currently active encoder */ |
4a9a8b71 | 1193 | |
76adaa34 WF |
1194 | /* EDID bits */ |
1195 | uint8_t eld[MAX_ELD_BYTES]; | |
1196 | bool dvi_dual; | |
1197 | int max_tmds_clock; /* in MHz */ | |
1198 | bool latency_present[2]; | |
1199 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ | |
1200 | int audio_latency[2]; | |
4a9a8b71 | 1201 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ |
0b2443ed | 1202 | unsigned bad_edid_counter; |
30f65707 | 1203 | |
6ba2bd3d TP |
1204 | /* Flag for raw EDID header corruption - used in Displayport |
1205 | * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 | |
1206 | */ | |
1207 | bool edid_corrupt; | |
1208 | ||
30f65707 | 1209 | struct dentry *debugfs_entry; |
144ecb97 DV |
1210 | |
1211 | struct drm_connector_state *state; | |
40d9b043 DA |
1212 | |
1213 | /* DisplayID bits */ | |
1214 | bool has_tile; | |
1215 | struct drm_tile_group *tile_group; | |
1216 | bool tile_is_single_monitor; | |
1217 | ||
1218 | uint8_t num_h_tile, num_v_tile; | |
1219 | uint8_t tile_h_loc, tile_v_loc; | |
1220 | uint16_t tile_h_size, tile_v_size; | |
144ecb97 DV |
1221 | }; |
1222 | ||
1223 | /** | |
1224 | * struct drm_plane_state - mutable plane state | |
07cc0ef6 | 1225 | * @plane: backpointer to the plane |
144ecb97 | 1226 | * @crtc: currently bound CRTC, NULL if disabled |
cc4ceb48 | 1227 | * @fb: currently bound framebuffer |
e2330f07 | 1228 | * @fence: optional fence to wait for before scanning out @fb |
144ecb97 DV |
1229 | * @crtc_x: left position of visible portion of plane on crtc |
1230 | * @crtc_y: upper position of visible portion of plane on crtc | |
1231 | * @crtc_w: width of visible portion of plane on crtc | |
1232 | * @crtc_h: height of visible portion of plane on crtc | |
1233 | * @src_x: left position of visible portion of plane within | |
1234 | * plane (in 16.16) | |
1235 | * @src_y: upper position of visible portion of plane within | |
1236 | * plane (in 16.16) | |
1237 | * @src_w: width of visible portion of plane (in 16.16) | |
1238 | * @src_h: height of visible portion of plane (in 16.16) | |
1239 | * @state: backpointer to global drm_atomic_state | |
1240 | */ | |
1241 | struct drm_plane_state { | |
07cc0ef6 DV |
1242 | struct drm_plane *plane; |
1243 | ||
6ddd388a RC |
1244 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ |
1245 | struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ | |
e2330f07 | 1246 | struct fence *fence; |
144ecb97 DV |
1247 | |
1248 | /* Signed dest location allows it to be partially off screen */ | |
1249 | int32_t crtc_x, crtc_y; | |
1250 | uint32_t crtc_w, crtc_h; | |
1251 | ||
1252 | /* Source values are 16.16 fixed point */ | |
1253 | uint32_t src_x, src_y; | |
1254 | uint32_t src_h, src_w; | |
1255 | ||
1da30627 MR |
1256 | /* Plane rotation */ |
1257 | unsigned int rotation; | |
1258 | ||
144ecb97 | 1259 | struct drm_atomic_state *state; |
f453ba04 DA |
1260 | }; |
1261 | ||
144ecb97 | 1262 | |
8cf5c917 | 1263 | /** |
3bf0401c | 1264 | * struct drm_plane_funcs - driver plane control functions |
8cf5c917 JB |
1265 | */ |
1266 | struct drm_plane_funcs { | |
88548636 DV |
1267 | /** |
1268 | * @update_plane: | |
1269 | * | |
1270 | * This is the legacy entry point to enable and configure the plane for | |
1271 | * the given CRTC and framebuffer. It is never called to disable the | |
1272 | * plane, i.e. the passed-in crtc and fb paramters are never NULL. | |
1273 | * | |
1274 | * The source rectangle in frame buffer memory coordinates is given by | |
1275 | * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point | |
1276 | * values). Devices that don't support subpixel plane coordinates can | |
1277 | * ignore the fractional part. | |
1278 | * | |
1279 | * The destination rectangle in CRTC coordinates is given by the | |
1280 | * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values). | |
1281 | * Devices scale the source rectangle to the destination rectangle. If | |
1282 | * scaling is not supported, and the source rectangle size doesn't match | |
1283 | * the destination rectangle size, the driver must return a | |
1284 | * -<errorname>EINVAL</errorname> error. | |
1285 | * | |
1286 | * Drivers implementing atomic modeset should use | |
1287 | * drm_atomic_helper_update_plane() to implement this hook. | |
1288 | * | |
1289 | * RETURNS: | |
1290 | * | |
1291 | * 0 on success or a negative error code on failure. | |
1292 | */ | |
8cf5c917 JB |
1293 | int (*update_plane)(struct drm_plane *plane, |
1294 | struct drm_crtc *crtc, struct drm_framebuffer *fb, | |
1295 | int crtc_x, int crtc_y, | |
1296 | unsigned int crtc_w, unsigned int crtc_h, | |
1297 | uint32_t src_x, uint32_t src_y, | |
1298 | uint32_t src_w, uint32_t src_h); | |
88548636 DV |
1299 | |
1300 | /** | |
1301 | * @disable_plane: | |
1302 | * | |
1303 | * This is the legacy entry point to disable the plane. The DRM core | |
c6b0ca3e | 1304 | * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call |
88548636 DV |
1305 | * with the frame buffer ID set to 0. Disabled planes must not be |
1306 | * processed by the CRTC. | |
1307 | * | |
1308 | * Drivers implementing atomic modeset should use | |
1309 | * drm_atomic_helper_disable_plane() to implement this hook. | |
1310 | * | |
1311 | * RETURNS: | |
1312 | * | |
1313 | * 0 on success or a negative error code on failure. | |
1314 | */ | |
8cf5c917 | 1315 | int (*disable_plane)(struct drm_plane *plane); |
88548636 DV |
1316 | |
1317 | /** | |
1318 | * @destroy: | |
1319 | * | |
1320 | * Clean up plane resources. This is only called at driver unload time | |
1321 | * through drm_mode_config_cleanup() since a plane cannot be hotplugged | |
1322 | * in DRM. | |
1323 | */ | |
8cf5c917 | 1324 | void (*destroy)(struct drm_plane *plane); |
88548636 DV |
1325 | |
1326 | /** | |
1327 | * @reset: | |
1328 | * | |
1329 | * Reset plane hardware and software state to off. This function isn't | |
1330 | * called by the core directly, only through drm_mode_config_reset(). | |
1331 | * It's not a helper hook only for historical reasons. | |
1332 | * | |
1333 | * Atomic drivers can use drm_atomic_helper_plane_reset() to reset | |
1334 | * atomic state using this hook. | |
1335 | */ | |
2a0d7cfd | 1336 | void (*reset)(struct drm_plane *plane); |
4d93914a | 1337 | |
88548636 DV |
1338 | /** |
1339 | * @set_property: | |
1340 | * | |
1341 | * This is the legacy entry point to update a property attached to the | |
1342 | * plane. | |
1343 | * | |
1344 | * Drivers implementing atomic modeset should use | |
1345 | * drm_atomic_helper_plane_set_property() to implement this hook. | |
1346 | * | |
1347 | * This callback is optional if the driver does not support any legacy | |
1348 | * driver-private properties. | |
1349 | * | |
1350 | * RETURNS: | |
1351 | * | |
1352 | * 0 on success or a negative error code on failure. | |
1353 | */ | |
4d93914a RC |
1354 | int (*set_property)(struct drm_plane *plane, |
1355 | struct drm_property *property, uint64_t val); | |
144ecb97 | 1356 | |
88548636 DV |
1357 | /** |
1358 | * @atomic_duplicate_state: | |
1359 | * | |
1360 | * Duplicate the current atomic state for this plane and return it. | |
1361 | * The core and helpers gurantee that any atomic state duplicated with | |
1362 | * this hook and still owned by the caller (i.e. not transferred to the | |
1363 | * driver by calling ->atomic_commit() from struct | |
1364 | * &drm_mode_config_funcs) will be cleaned up by calling the | |
1365 | * @atomic_destroy_state hook in this structure. | |
1366 | * | |
1367 | * Atomic drivers which don't subclass struct &drm_plane_state should use | |
1368 | * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the | |
1369 | * state structure to extend it with driver-private state should use | |
1370 | * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is | |
1371 | * duplicated in a consistent fashion across drivers. | |
1372 | * | |
1373 | * It is an error to call this hook before plane->state has been | |
1374 | * initialized correctly. | |
1375 | * | |
1376 | * NOTE: | |
1377 | * | |
1378 | * If the duplicate state references refcounted resources this hook must | |
1379 | * acquire a reference for each of them. The driver must release these | |
1380 | * references again in @atomic_destroy_state. | |
1381 | * | |
1382 | * RETURNS: | |
1383 | * | |
1384 | * Duplicated atomic state or NULL when the allocation failed. | |
1385 | */ | |
144ecb97 | 1386 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); |
88548636 DV |
1387 | |
1388 | /** | |
1389 | * @atomic_destroy_state: | |
1390 | * | |
1391 | * Destroy a state duplicated with @atomic_duplicate_state and release | |
1392 | * or unreference all resources it references | |
1393 | */ | |
144ecb97 | 1394 | void (*atomic_destroy_state)(struct drm_plane *plane, |
cc4ceb48 | 1395 | struct drm_plane_state *state); |
88548636 DV |
1396 | |
1397 | /** | |
1398 | * @atomic_set_property: | |
1399 | * | |
1400 | * Decode a driver-private property value and store the decoded value | |
1401 | * into the passed-in state structure. Since the atomic core decodes all | |
1402 | * standardized properties (even for extensions beyond the core set of | |
1403 | * properties which might not be implemented by all drivers) this | |
1404 | * requires drivers to subclass the state structure. | |
1405 | * | |
1406 | * Such driver-private properties should really only be implemented for | |
1407 | * truly hardware/vendor specific state. Instead it is preferred to | |
1408 | * standardize atomic extension and decode the properties used to expose | |
1409 | * such an extension in the core. | |
1410 | * | |
1411 | * Do not call this function directly, use | |
1412 | * drm_atomic_plane_set_property() instead. | |
1413 | * | |
1414 | * This callback is optional if the driver does not support any | |
1415 | * driver-private atomic properties. | |
1416 | * | |
1417 | * NOTE: | |
1418 | * | |
1419 | * This function is called in the state assembly phase of atomic | |
1420 | * modesets, which can be aborted for any reason (including on | |
1421 | * userspace's request to just check whether a configuration would be | |
1422 | * possible). Drivers MUST NOT touch any persistent state (hardware or | |
1423 | * software) or data structures except the passed in @state parameter. | |
1424 | * | |
1425 | * Also since userspace controls in which order properties are set this | |
1426 | * function must not do any input validation (since the state update is | |
1427 | * incomplete and hence likely inconsistent). Instead any such input | |
1428 | * validation must be done in the various atomic_check callbacks. | |
1429 | * | |
1430 | * RETURNS: | |
1431 | * | |
1432 | * 0 if the property has been found, -EINVAL if the property isn't | |
1433 | * implemented by the driver (which shouldn't ever happen, the core only | |
1434 | * asks for properties attached to this plane). No other validation is | |
1435 | * allowed by the driver. The core already checks that the property | |
1436 | * value is within the range (integer, valid enum value, ...) the driver | |
1437 | * set when registering the property. | |
1438 | */ | |
144ecb97 DV |
1439 | int (*atomic_set_property)(struct drm_plane *plane, |
1440 | struct drm_plane_state *state, | |
1441 | struct drm_property *property, | |
1442 | uint64_t val); | |
88548636 DV |
1443 | |
1444 | /** | |
1445 | * @atomic_get_property: | |
1446 | * | |
1447 | * Reads out the decoded driver-private property. This is used to | |
c6b0ca3e | 1448 | * implement the GETPLANE IOCTL. |
88548636 DV |
1449 | * |
1450 | * Do not call this function directly, use | |
1451 | * drm_atomic_plane_get_property() instead. | |
1452 | * | |
1453 | * This callback is optional if the driver does not support any | |
1454 | * driver-private atomic properties. | |
1455 | * | |
1456 | * RETURNS: | |
1457 | * | |
1458 | * 0 on success, -EINVAL if the property isn't implemented by the | |
1459 | * driver (which should never happen, the core only asks for | |
1460 | * properties attached to this plane). | |
1461 | */ | |
ac9c9256 RC |
1462 | int (*atomic_get_property)(struct drm_plane *plane, |
1463 | const struct drm_plane_state *state, | |
1464 | struct drm_property *property, | |
1465 | uint64_t *val); | |
8cf5c917 JB |
1466 | }; |
1467 | ||
e27dde3e MR |
1468 | enum drm_plane_type { |
1469 | DRM_PLANE_TYPE_OVERLAY, | |
1470 | DRM_PLANE_TYPE_PRIMARY, | |
1471 | DRM_PLANE_TYPE_CURSOR, | |
1472 | }; | |
1473 | ||
88548636 | 1474 | |
8cf5c917 | 1475 | /** |
3bf0401c | 1476 | * struct drm_plane - central DRM plane control structure |
8cf5c917 JB |
1477 | * @dev: DRM device this plane belongs to |
1478 | * @head: for list management | |
1479 | * @base: base mode object | |
1480 | * @possible_crtcs: pipes this plane can be bound to | |
1481 | * @format_types: array of formats supported by this plane | |
1482 | * @format_count: number of formats supported | |
7eb5f302 | 1483 | * @format_default: driver hasn't supplied supported formats for the plane |
8cf5c917 JB |
1484 | * @crtc: currently bound CRTC |
1485 | * @fb: currently bound fb | |
2c0c33d4 DV |
1486 | * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by |
1487 | * drm_mode_set_config_internal() to implement correct refcounting. | |
8cf5c917 | 1488 | * @funcs: helper functions |
4d93914a | 1489 | * @properties: property tracking for this plane |
e27dde3e | 1490 | * @type: type of plane (overlay, primary, cursor) |
144ecb97 | 1491 | * @state: current atomic state for this plane |
8cf5c917 JB |
1492 | */ |
1493 | struct drm_plane { | |
1494 | struct drm_device *dev; | |
1495 | struct list_head head; | |
1496 | ||
4d02e2de DV |
1497 | struct drm_modeset_lock mutex; |
1498 | ||
8cf5c917 JB |
1499 | struct drm_mode_object base; |
1500 | ||
1501 | uint32_t possible_crtcs; | |
1502 | uint32_t *format_types; | |
45e3743a | 1503 | unsigned int format_count; |
7eb5f302 | 1504 | bool format_default; |
8cf5c917 JB |
1505 | |
1506 | struct drm_crtc *crtc; | |
1507 | struct drm_framebuffer *fb; | |
1508 | ||
3d30a59b DV |
1509 | struct drm_framebuffer *old_fb; |
1510 | ||
8cf5c917 | 1511 | const struct drm_plane_funcs *funcs; |
4d93914a RC |
1512 | |
1513 | struct drm_object_properties properties; | |
e27dde3e MR |
1514 | |
1515 | enum drm_plane_type type; | |
144ecb97 | 1516 | |
4490d4c7 | 1517 | const struct drm_plane_helper_funcs *helper_private; |
c2fcd274 | 1518 | |
144ecb97 | 1519 | struct drm_plane_state *state; |
8cf5c917 JB |
1520 | }; |
1521 | ||
3b336ec4 | 1522 | /** |
3bf0401c | 1523 | * struct drm_bridge_funcs - drm_bridge control functions |
3d3f8b1f | 1524 | * @attach: Called during drm_bridge_attach |
3b336ec4 SP |
1525 | */ |
1526 | struct drm_bridge_funcs { | |
3d3f8b1f | 1527 | int (*attach)(struct drm_bridge *bridge); |
da024fe5 DV |
1528 | |
1529 | /** | |
1530 | * @mode_fixup: | |
1531 | * | |
1532 | * This callback is used to validate and adjust a mode. The paramater | |
1533 | * mode is the display mode that should be fed to the next element in | |
1534 | * the display chain, either the final &drm_connector or the next | |
1535 | * &drm_bridge. The parameter adjusted_mode is the input mode the bridge | |
1536 | * requires. It can be modified by this callback and does not need to | |
1537 | * match mode. | |
1538 | * | |
1539 | * This is the only hook that allows a bridge to reject a modeset. If | |
1540 | * this function passes all other callbacks must succeed for this | |
1541 | * configuration. | |
1542 | * | |
1543 | * NOTE: | |
1544 | * | |
1545 | * This function is called in the check phase of atomic modesets, which | |
1546 | * can be aborted for any reason (including on userspace's request to | |
1547 | * just check whether a configuration would be possible). Drivers MUST | |
1548 | * NOT touch any persistent state (hardware or software) or data | |
88548636 | 1549 | * structures except the passed in @state parameter. |
da024fe5 DV |
1550 | * |
1551 | * RETURNS: | |
1552 | * | |
1553 | * True if an acceptable configuration is possible, false if the modeset | |
1554 | * operation should be rejected. | |
1555 | */ | |
3b336ec4 SP |
1556 | bool (*mode_fixup)(struct drm_bridge *bridge, |
1557 | const struct drm_display_mode *mode, | |
1558 | struct drm_display_mode *adjusted_mode); | |
da024fe5 DV |
1559 | /** |
1560 | * @disable: | |
1561 | * | |
1562 | * This callback should disable the bridge. It is called right before | |
1563 | * the preceding element in the display pipe is disabled. If the | |
1564 | * preceding element is a bridge this means it's called before that | |
1565 | * bridge's ->disable() function. If the preceding element is a | |
1566 | * &drm_encoder it's called right before the encoder's ->disable(), | |
1567 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. | |
1568 | * | |
1569 | * The bridge can assume that the display pipe (i.e. clocks and timing | |
1570 | * signals) feeding it is still running when this callback is called. | |
1571 | */ | |
3b336ec4 | 1572 | void (*disable)(struct drm_bridge *bridge); |
da024fe5 DV |
1573 | |
1574 | /** | |
1575 | * @post_disable: | |
1576 | * | |
1577 | * This callback should disable the bridge. It is called right after | |
1578 | * the preceding element in the display pipe is disabled. If the | |
1579 | * preceding element is a bridge this means it's called after that | |
1580 | * bridge's ->post_disable() function. If the preceding element is a | |
1581 | * &drm_encoder it's called right after the encoder's ->disable(), | |
1582 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. | |
1583 | * | |
1584 | * The bridge must assume that the display pipe (i.e. clocks and timing | |
1585 | * singals) feeding it is no longer running when this callback is | |
1586 | * called. | |
1587 | */ | |
3b336ec4 | 1588 | void (*post_disable)(struct drm_bridge *bridge); |
da024fe5 DV |
1589 | |
1590 | /** | |
1591 | * @mode_set: | |
1592 | * | |
1593 | * This callback should set the given mode on the bridge. It is called | |
1594 | * after the ->mode_set() callback for the preceding element in the | |
1595 | * display pipeline has been called already. The display pipe (i.e. | |
1596 | * clocks and timing signals) is off when this function is called. | |
1597 | */ | |
3b336ec4 SP |
1598 | void (*mode_set)(struct drm_bridge *bridge, |
1599 | struct drm_display_mode *mode, | |
1600 | struct drm_display_mode *adjusted_mode); | |
da024fe5 DV |
1601 | /** |
1602 | * @pre_enable: | |
1603 | * | |
1604 | * This callback should enable the bridge. It is called right before | |
1605 | * the preceding element in the display pipe is enabled. If the | |
1606 | * preceding element is a bridge this means it's called before that | |
1607 | * bridge's ->pre_enable() function. If the preceding element is a | |
1608 | * &drm_encoder it's called right before the encoder's ->enable(), | |
1609 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. | |
1610 | * | |
1611 | * The display pipe (i.e. clocks and timing signals) feeding this bridge | |
1612 | * will not yet be running when this callback is called. The bridge must | |
1613 | * not enable the display link feeding the next bridge in the chain (if | |
1614 | * there is one) when this callback is called. | |
1615 | */ | |
3b336ec4 | 1616 | void (*pre_enable)(struct drm_bridge *bridge); |
da024fe5 DV |
1617 | |
1618 | /** | |
1619 | * @enable: | |
1620 | * | |
1621 | * This callback should enable the bridge. It is called right after | |
1622 | * the preceding element in the display pipe is enabled. If the | |
1623 | * preceding element is a bridge this means it's called after that | |
1624 | * bridge's ->enable() function. If the preceding element is a | |
1625 | * &drm_encoder it's called right after the encoder's ->enable(), | |
1626 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. | |
1627 | * | |
1628 | * The bridge can assume that the display pipe (i.e. clocks and timing | |
1629 | * signals) feeding it is running when this callback is called. This | |
1630 | * callback must enable the display link feeding the next bridge in the | |
1631 | * chain if there is one. | |
1632 | */ | |
3b336ec4 | 1633 | void (*enable)(struct drm_bridge *bridge); |
3b336ec4 SP |
1634 | }; |
1635 | ||
1636 | /** | |
3bf0401c | 1637 | * struct drm_bridge - central DRM bridge control structure |
3b336ec4 | 1638 | * @dev: DRM device this bridge belongs to |
862e686c AT |
1639 | * @encoder: encoder to which this bridge is connected |
1640 | * @next: the next bridge in the encoder chain | |
3d3f8b1f AK |
1641 | * @of_node: device node pointer to the bridge |
1642 | * @list: to keep track of all added bridges | |
3b336ec4 SP |
1643 | * @funcs: control functions |
1644 | * @driver_private: pointer to the bridge driver's internal context | |
1645 | */ | |
1646 | struct drm_bridge { | |
1647 | struct drm_device *dev; | |
3d3f8b1f | 1648 | struct drm_encoder *encoder; |
862e686c | 1649 | struct drm_bridge *next; |
3d3f8b1f AK |
1650 | #ifdef CONFIG_OF |
1651 | struct device_node *of_node; | |
1652 | #endif | |
1653 | struct list_head list; | |
3b336ec4 SP |
1654 | |
1655 | const struct drm_bridge_funcs *funcs; | |
1656 | void *driver_private; | |
1657 | }; | |
1658 | ||
cc4ceb48 | 1659 | /** |
08855fae | 1660 | * struct drm_atomic_state - the global state object for atomic updates |
cc4ceb48 | 1661 | * @dev: parent DRM device |
d34f20d6 | 1662 | * @allow_modeset: allow full modeset |
c6b0ca3e | 1663 | * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics |
cc4ceb48 DV |
1664 | * @planes: pointer to array of plane pointers |
1665 | * @plane_states: pointer to array of plane states pointers | |
1666 | * @crtcs: pointer to array of CRTC pointers | |
1667 | * @crtc_states: pointer to array of CRTC states pointers | |
f52b69f1 | 1668 | * @num_connector: size of the @connectors and @connector_states arrays |
cc4ceb48 DV |
1669 | * @connectors: pointer to array of connector pointers |
1670 | * @connector_states: pointer to array of connector states pointers | |
1671 | * @acquire_ctx: acquire context for this atomic modeset state update | |
1672 | */ | |
1673 | struct drm_atomic_state { | |
1674 | struct drm_device *dev; | |
d34f20d6 | 1675 | bool allow_modeset : 1; |
f02ad907 | 1676 | bool legacy_cursor_update : 1; |
cc4ceb48 DV |
1677 | struct drm_plane **planes; |
1678 | struct drm_plane_state **plane_states; | |
1679 | struct drm_crtc **crtcs; | |
1680 | struct drm_crtc_state **crtc_states; | |
f52b69f1 | 1681 | int num_connector; |
cc4ceb48 DV |
1682 | struct drm_connector **connectors; |
1683 | struct drm_connector_state **connector_states; | |
1684 | ||
1685 | struct drm_modeset_acquire_ctx *acquire_ctx; | |
1686 | }; | |
1687 | ||
1688 | ||
f453ba04 | 1689 | /** |
3bf0401c | 1690 | * struct drm_mode_set - new values for a CRTC config change |
ef27351a JB |
1691 | * @fb: framebuffer to use for new config |
1692 | * @crtc: CRTC whose configuration we're about to change | |
1693 | * @mode: mode timings to use | |
1694 | * @x: position of this CRTC relative to @fb | |
1695 | * @y: position of this CRTC relative to @fb | |
1696 | * @connectors: array of connectors to drive with this CRTC if possible | |
1697 | * @num_connectors: size of @connectors array | |
f453ba04 DA |
1698 | * |
1699 | * Represents a single crtc the connectors that it drives with what mode | |
1700 | * and from which framebuffer it scans out from. | |
1701 | * | |
1702 | * This is used to set modes. | |
1703 | */ | |
1704 | struct drm_mode_set { | |
f453ba04 DA |
1705 | struct drm_framebuffer *fb; |
1706 | struct drm_crtc *crtc; | |
1707 | struct drm_display_mode *mode; | |
1708 | ||
1709 | uint32_t x; | |
1710 | uint32_t y; | |
1711 | ||
1712 | struct drm_connector **connectors; | |
1713 | size_t num_connectors; | |
1714 | }; | |
1715 | ||
1716 | /** | |
550cebcd JB |
1717 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
1718 | * @fb_create: create a new framebuffer object | |
1719 | * @output_poll_changed: function to handle output configuration changes | |
2b1193d5 | 1720 | * @atomic_check: check whether a given atomic state update is possible |
cc4ceb48 DV |
1721 | * @atomic_commit: commit an atomic state update previously verified with |
1722 | * atomic_check() | |
036ef573 ML |
1723 | * @atomic_state_alloc: allocate a new atomic state |
1724 | * @atomic_state_clear: clear the atomic state | |
1725 | * @atomic_state_free: free the atomic state | |
550cebcd JB |
1726 | * |
1727 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that | |
1728 | * involve drivers. | |
f453ba04 DA |
1729 | */ |
1730 | struct drm_mode_config_funcs { | |
550cebcd JB |
1731 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
1732 | struct drm_file *file_priv, | |
1eb83451 | 1733 | const struct drm_mode_fb_cmd2 *mode_cmd); |
eb1f8e4f | 1734 | void (*output_poll_changed)(struct drm_device *dev); |
cc4ceb48 DV |
1735 | |
1736 | int (*atomic_check)(struct drm_device *dev, | |
1737 | struct drm_atomic_state *a); | |
1738 | int (*atomic_commit)(struct drm_device *dev, | |
1739 | struct drm_atomic_state *a, | |
1740 | bool async); | |
036ef573 ML |
1741 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
1742 | void (*atomic_state_clear)(struct drm_atomic_state *state); | |
1743 | void (*atomic_state_free)(struct drm_atomic_state *state); | |
f453ba04 DA |
1744 | }; |
1745 | ||
f453ba04 | 1746 | /** |
2c0c33d4 | 1747 | * struct drm_mode_config - Mode configuration control structure |
a62c93d5 | 1748 | * @mutex: mutex protecting KMS related lists and structures |
2c0c33d4 DV |
1749 | * @connection_mutex: ww mutex protecting connector state and routing |
1750 | * @acquire_ctx: global implicit acquire context used by atomic drivers for | |
c6b0ca3e | 1751 | * legacy IOCTLs |
a62c93d5 JB |
1752 | * @idr_mutex: mutex for KMS ID allocation and management |
1753 | * @crtc_idr: main KMS ID tracking object | |
2c0c33d4 | 1754 | * @fb_lock: mutex to protect fb state and lists |
a62c93d5 JB |
1755 | * @num_fb: number of fbs available |
1756 | * @fb_list: list of framebuffers available | |
1757 | * @num_connector: number of connectors on this device | |
1758 | * @connector_list: list of connector objects | |
1759 | * @num_encoder: number of encoders on this device | |
1760 | * @encoder_list: list of encoder objects | |
2c0c33d4 DV |
1761 | * @num_overlay_plane: number of overlay planes on this device |
1762 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device | |
1763 | * @plane_list: list of plane objects | |
a62c93d5 JB |
1764 | * @num_crtc: number of CRTCs on this device |
1765 | * @crtc_list: list of CRTC objects | |
2c0c33d4 | 1766 | * @property_list: list of property objects |
a62c93d5 JB |
1767 | * @min_width: minimum pixel width on this device |
1768 | * @min_height: minimum pixel height on this device | |
1769 | * @max_width: maximum pixel width on this device | |
1770 | * @max_height: maximum pixel height on this device | |
1771 | * @funcs: core driver provided mode setting functions | |
1772 | * @fb_base: base address of the framebuffer | |
2c0c33d4 DV |
1773 | * @poll_enabled: track polling support for this device |
1774 | * @poll_running: track polling status for this device | |
a62c93d5 | 1775 | * @output_poll_work: delayed work for polling in process context |
2c0c33d4 | 1776 | * @property_blob_list: list of all the blob property objects |
8fb6e7a5 | 1777 | * @blob_lock: mutex for blob property allocation and management |
a62c93d5 | 1778 | * @*_property: core property tracking |
2c0c33d4 DV |
1779 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
1780 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering | |
1781 | * @async_page_flip: does this device support async flips on the primary plane? | |
1782 | * @cursor_width: hint to userspace for max cursor width | |
1783 | * @cursor_height: hint to userspace for max cursor height | |
f453ba04 | 1784 | * |
a62c93d5 JB |
1785 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
1786 | * enumerated by the driver are added here, as are global properties. Some | |
1787 | * global restrictions are also here, e.g. dimension restrictions. | |
f453ba04 DA |
1788 | */ |
1789 | struct drm_mode_config { | |
ad2563c2 | 1790 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
51fd371b RC |
1791 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
1792 | struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */ | |
ad2563c2 | 1793 | struct mutex idr_mutex; /* for IDR management */ |
f453ba04 | 1794 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
138f9ebb | 1795 | struct idr tile_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
f453ba04 | 1796 | /* this is limited to one for now */ |
4b096ac1 | 1797 | |
2c0c33d4 | 1798 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
f453ba04 DA |
1799 | int num_fb; |
1800 | struct list_head fb_list; | |
4b096ac1 | 1801 | |
f453ba04 DA |
1802 | int num_connector; |
1803 | struct list_head connector_list; | |
1804 | int num_encoder; | |
1805 | struct list_head encoder_list; | |
e27dde3e MR |
1806 | |
1807 | /* | |
1808 | * Track # of overlay planes separately from # of total planes. By | |
1809 | * default we only advertise overlay planes to userspace; if userspace | |
1810 | * sets the "universal plane" capability bit, we'll go ahead and | |
1811 | * expose all planes. | |
1812 | */ | |
1813 | int num_overlay_plane; | |
1814 | int num_total_plane; | |
8cf5c917 | 1815 | struct list_head plane_list; |
f453ba04 DA |
1816 | |
1817 | int num_crtc; | |
1818 | struct list_head crtc_list; | |
1819 | ||
1820 | struct list_head property_list; | |
1821 | ||
f453ba04 DA |
1822 | int min_width, min_height; |
1823 | int max_width, max_height; | |
e6ecefaa | 1824 | const struct drm_mode_config_funcs *funcs; |
d883f7f1 | 1825 | resource_size_t fb_base; |
f453ba04 | 1826 | |
eb1f8e4f DA |
1827 | /* output poll support */ |
1828 | bool poll_enabled; | |
905bc9ff | 1829 | bool poll_running; |
162b6a57 | 1830 | bool delayed_event; |
991ea75c | 1831 | struct delayed_work output_poll_work; |
eb1f8e4f | 1832 | |
8fb6e7a5 DS |
1833 | struct mutex blob_lock; |
1834 | ||
f453ba04 DA |
1835 | /* pointers to standard properties */ |
1836 | struct list_head property_blob_list; | |
1837 | struct drm_property *edid_property; | |
1838 | struct drm_property *dpms_property; | |
43aba7eb | 1839 | struct drm_property *path_property; |
6f134d7b | 1840 | struct drm_property *tile_property; |
9922ab5a | 1841 | struct drm_property *plane_type_property; |
2a297cce | 1842 | struct drm_property *rotation_property; |
6b4959f4 RC |
1843 | struct drm_property *prop_src_x; |
1844 | struct drm_property *prop_src_y; | |
1845 | struct drm_property *prop_src_w; | |
1846 | struct drm_property *prop_src_h; | |
1847 | struct drm_property *prop_crtc_x; | |
1848 | struct drm_property *prop_crtc_y; | |
1849 | struct drm_property *prop_crtc_w; | |
1850 | struct drm_property *prop_crtc_h; | |
1851 | struct drm_property *prop_fb_id; | |
1852 | struct drm_property *prop_crtc_id; | |
eab3bbef | 1853 | struct drm_property *prop_active; |
955f3c33 | 1854 | struct drm_property *prop_mode_id; |
f453ba04 DA |
1855 | |
1856 | /* DVI-I properties */ | |
1857 | struct drm_property *dvi_i_subconnector_property; | |
1858 | struct drm_property *dvi_i_select_subconnector_property; | |
1859 | ||
1860 | /* TV properties */ | |
1861 | struct drm_property *tv_subconnector_property; | |
1862 | struct drm_property *tv_select_subconnector_property; | |
1863 | struct drm_property *tv_mode_property; | |
1864 | struct drm_property *tv_left_margin_property; | |
1865 | struct drm_property *tv_right_margin_property; | |
1866 | struct drm_property *tv_top_margin_property; | |
1867 | struct drm_property *tv_bottom_margin_property; | |
b6b7902e FJ |
1868 | struct drm_property *tv_brightness_property; |
1869 | struct drm_property *tv_contrast_property; | |
1870 | struct drm_property *tv_flicker_reduction_property; | |
a75f0236 FJ |
1871 | struct drm_property *tv_overscan_property; |
1872 | struct drm_property *tv_saturation_property; | |
1873 | struct drm_property *tv_hue_property; | |
f453ba04 DA |
1874 | |
1875 | /* Optional properties */ | |
1876 | struct drm_property *scaling_mode_property; | |
ff587e45 | 1877 | struct drm_property *aspect_ratio_property; |
884840aa | 1878 | struct drm_property *dirty_info_property; |
019d96cb | 1879 | |
5bb2bbf5 DA |
1880 | /* properties for virtual machine layout */ |
1881 | struct drm_property *suggested_x_property; | |
1882 | struct drm_property *suggested_y_property; | |
1883 | ||
019d96cb DA |
1884 | /* dumb ioctl parameters */ |
1885 | uint32_t preferred_depth, prefer_shadow; | |
62f2104f KP |
1886 | |
1887 | /* whether async page flip is supported or not */ | |
1888 | bool async_page_flip; | |
8716ed4e | 1889 | |
e3eb3250 RC |
1890 | /* whether the driver supports fb modifiers */ |
1891 | bool allow_fb_modifiers; | |
1892 | ||
8716ed4e AD |
1893 | /* cursor size */ |
1894 | uint32_t cursor_width, cursor_height; | |
f453ba04 DA |
1895 | }; |
1896 | ||
dd275956 RC |
1897 | /** |
1898 | * drm_for_each_plane_mask - iterate over planes specified by bitmask | |
1899 | * @plane: the loop cursor | |
1900 | * @dev: the DRM device | |
1901 | * @plane_mask: bitmask of plane indices | |
1902 | * | |
1903 | * Iterate over all planes specified by bitmask. | |
1904 | */ | |
1905 | #define drm_for_each_plane_mask(plane, dev, plane_mask) \ | |
1906 | list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ | |
373701b1 | 1907 | for_each_if ((plane_mask) & (1 << drm_plane_index(plane))) |
dd275956 RC |
1908 | |
1909 | ||
f453ba04 DA |
1910 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
1911 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) | |
1912 | #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) | |
1913 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) | |
1914 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) | |
1915 | #define obj_to_property(x) container_of(x, struct drm_property, base) | |
1916 | #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) | |
8cf5c917 | 1917 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
f453ba04 | 1918 | |
4a67d391 SH |
1919 | struct drm_prop_enum_list { |
1920 | int type; | |
1921 | char *name; | |
1922 | }; | |
f453ba04 | 1923 | |
e13161af MR |
1924 | extern int drm_crtc_init_with_planes(struct drm_device *dev, |
1925 | struct drm_crtc *crtc, | |
1926 | struct drm_plane *primary, | |
fc1d3e44 | 1927 | struct drm_plane *cursor, |
e13161af | 1928 | const struct drm_crtc_funcs *funcs); |
f453ba04 | 1929 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
db5f7a6e RK |
1930 | extern unsigned int drm_crtc_index(struct drm_crtc *crtc); |
1931 | ||
1932 | /** | |
1933 | * drm_crtc_mask - find the mask of a registered CRTC | |
1934 | * @crtc: CRTC to find mask for | |
1935 | * | |
1936 | * Given a registered CRTC, return the mask bit of that CRTC for an | |
1937 | * encoder's possible_crtcs field. | |
1938 | */ | |
1939 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) | |
1940 | { | |
1941 | return 1 << drm_crtc_index(crtc); | |
1942 | } | |
f453ba04 | 1943 | |
b21e3afe IM |
1944 | extern void drm_connector_ida_init(void); |
1945 | extern void drm_connector_ida_destroy(void); | |
6bfc56aa VS |
1946 | extern int drm_connector_init(struct drm_device *dev, |
1947 | struct drm_connector *connector, | |
1948 | const struct drm_connector_funcs *funcs, | |
1949 | int connector_type); | |
34ea3d38 TW |
1950 | int drm_connector_register(struct drm_connector *connector); |
1951 | void drm_connector_unregister(struct drm_connector *connector); | |
f453ba04 DA |
1952 | |
1953 | extern void drm_connector_cleanup(struct drm_connector *connector); | |
10f637bf | 1954 | extern unsigned int drm_connector_index(struct drm_connector *connector); |
cbc7e221 DA |
1955 | /* helper to unplug all connectors from sysfs for device */ |
1956 | extern void drm_connector_unplug_all(struct drm_device *dev); | |
f453ba04 | 1957 | |
3d3f8b1f AK |
1958 | extern int drm_bridge_add(struct drm_bridge *bridge); |
1959 | extern void drm_bridge_remove(struct drm_bridge *bridge); | |
1960 | extern struct drm_bridge *of_drm_find_bridge(struct device_node *np); | |
1961 | extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); | |
3b336ec4 | 1962 | |
862e686c AT |
1963 | bool drm_bridge_mode_fixup(struct drm_bridge *bridge, |
1964 | const struct drm_display_mode *mode, | |
1965 | struct drm_display_mode *adjusted_mode); | |
1966 | void drm_bridge_disable(struct drm_bridge *bridge); | |
1967 | void drm_bridge_post_disable(struct drm_bridge *bridge); | |
1968 | void drm_bridge_mode_set(struct drm_bridge *bridge, | |
1969 | struct drm_display_mode *mode, | |
1970 | struct drm_display_mode *adjusted_mode); | |
1971 | void drm_bridge_pre_enable(struct drm_bridge *bridge); | |
1972 | void drm_bridge_enable(struct drm_bridge *bridge); | |
1973 | ||
6bfc56aa VS |
1974 | extern int drm_encoder_init(struct drm_device *dev, |
1975 | struct drm_encoder *encoder, | |
1976 | const struct drm_encoder_funcs *funcs, | |
1977 | int encoder_type); | |
f453ba04 | 1978 | |
3d887368 TR |
1979 | /** |
1980 | * drm_encoder_crtc_ok - can a given crtc drive a given encoder? | |
1981 | * @encoder: encoder to test | |
1982 | * @crtc: crtc to test | |
1983 | * | |
1984 | * Return false if @encoder can't be driven by @crtc, true otherwise. | |
1985 | */ | |
1986 | static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder, | |
1987 | struct drm_crtc *crtc) | |
1988 | { | |
1989 | return !!(encoder->possible_crtcs & drm_crtc_mask(crtc)); | |
1990 | } | |
1991 | ||
dc415ff9 MR |
1992 | extern int drm_universal_plane_init(struct drm_device *dev, |
1993 | struct drm_plane *plane, | |
1994 | unsigned long possible_crtcs, | |
1995 | const struct drm_plane_funcs *funcs, | |
1996 | const uint32_t *formats, | |
45e3743a | 1997 | unsigned int format_count, |
dc415ff9 | 1998 | enum drm_plane_type type); |
8cf5c917 JB |
1999 | extern int drm_plane_init(struct drm_device *dev, |
2000 | struct drm_plane *plane, | |
2001 | unsigned long possible_crtcs, | |
2002 | const struct drm_plane_funcs *funcs, | |
45e3743a | 2003 | const uint32_t *formats, unsigned int format_count, |
dc415ff9 | 2004 | bool is_primary); |
8cf5c917 | 2005 | extern void drm_plane_cleanup(struct drm_plane *plane); |
10f637bf | 2006 | extern unsigned int drm_plane_index(struct drm_plane *plane); |
f81338a5 | 2007 | extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx); |
9125e618 | 2008 | extern void drm_plane_force_disable(struct drm_plane *plane); |
ead8610d LP |
2009 | extern int drm_plane_check_pixel_format(const struct drm_plane *plane, |
2010 | u32 format); | |
ecb7e16b GP |
2011 | extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, |
2012 | int *hdisplay, int *vdisplay); | |
af93629d MR |
2013 | extern int drm_crtc_check_viewport(const struct drm_crtc *crtc, |
2014 | int x, int y, | |
2015 | const struct drm_display_mode *mode, | |
2016 | const struct drm_framebuffer *fb); | |
8cf5c917 | 2017 | |
f453ba04 DA |
2018 | extern void drm_encoder_cleanup(struct drm_encoder *encoder); |
2019 | ||
d20d3174 | 2020 | extern const char *drm_get_connector_status_name(enum drm_connector_status status); |
ac1bb36c | 2021 | extern const char *drm_get_subpixel_order_name(enum subpixel_order order); |
d20d3174 VS |
2022 | extern const char *drm_get_dpms_name(int val); |
2023 | extern const char *drm_get_dvi_i_subconnector_name(int val); | |
2024 | extern const char *drm_get_dvi_i_select_name(int val); | |
2025 | extern const char *drm_get_tv_subconnector_name(int val); | |
2026 | extern const char *drm_get_tv_select_name(int val); | |
ea39f835 | 2027 | extern void drm_fb_release(struct drm_file *file_priv); |
e2f5d2ea DS |
2028 | extern void drm_property_destroy_user_blobs(struct drm_device *dev, |
2029 | struct drm_file *file_priv); | |
fbff4690 | 2030 | extern bool drm_probe_ddc(struct i2c_adapter *adapter); |
f453ba04 DA |
2031 | extern struct edid *drm_get_edid(struct drm_connector *connector, |
2032 | struct i2c_adapter *adapter); | |
51f8da59 | 2033 | extern struct edid *drm_edid_duplicate(const struct edid *edid); |
f453ba04 | 2034 | extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
f453ba04 | 2035 | extern void drm_mode_config_init(struct drm_device *dev); |
eb033556 | 2036 | extern void drm_mode_config_reset(struct drm_device *dev); |
f453ba04 | 2037 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
55310008 | 2038 | |
43aba7eb | 2039 | extern int drm_mode_connector_set_path_property(struct drm_connector *connector, |
12e6cecd | 2040 | const char *path); |
6f134d7b | 2041 | int drm_mode_connector_set_tile_property(struct drm_connector *connector); |
f453ba04 | 2042 | extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
12e6cecd | 2043 | const struct edid *edid); |
5ea22f24 | 2044 | |
b5571e9d BB |
2045 | extern int drm_display_info_set_bus_formats(struct drm_display_info *info, |
2046 | const u32 *formats, | |
2047 | unsigned int num_formats); | |
2048 | ||
5ea22f24 RC |
2049 | static inline bool drm_property_type_is(struct drm_property *property, |
2050 | uint32_t type) | |
2051 | { | |
2052 | /* instanceof for props.. handles extended type vs original types: */ | |
2053 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) | |
2054 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; | |
2055 | return property->flags & type; | |
2056 | } | |
2057 | ||
2058 | static inline bool drm_property_type_valid(struct drm_property *property) | |
2059 | { | |
2060 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) | |
2061 | return !(property->flags & DRM_MODE_PROP_LEGACY_TYPE); | |
2062 | return !!(property->flags & DRM_MODE_PROP_LEGACY_TYPE); | |
2063 | } | |
2064 | ||
c543188a PZ |
2065 | extern int drm_object_property_set_value(struct drm_mode_object *obj, |
2066 | struct drm_property *property, | |
2067 | uint64_t val); | |
2068 | extern int drm_object_property_get_value(struct drm_mode_object *obj, | |
2069 | struct drm_property *property, | |
2070 | uint64_t *value); | |
f453ba04 DA |
2071 | extern int drm_framebuffer_init(struct drm_device *dev, |
2072 | struct drm_framebuffer *fb, | |
2073 | const struct drm_framebuffer_funcs *funcs); | |
786b99ed DV |
2074 | extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
2075 | uint32_t id); | |
f7eff60e RC |
2076 | extern void drm_framebuffer_unreference(struct drm_framebuffer *fb); |
2077 | extern void drm_framebuffer_reference(struct drm_framebuffer *fb); | |
2078 | extern void drm_framebuffer_remove(struct drm_framebuffer *fb); | |
f453ba04 | 2079 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); |
36206361 | 2080 | extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); |
f453ba04 | 2081 | |
c543188a PZ |
2082 | extern void drm_object_attach_property(struct drm_mode_object *obj, |
2083 | struct drm_property *property, | |
2084 | uint64_t init_val); | |
f453ba04 DA |
2085 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
2086 | const char *name, int num_values); | |
4a67d391 SH |
2087 | extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
2088 | const char *name, | |
49e27545 RC |
2089 | const struct drm_prop_enum_list *props, |
2090 | int num_values); | |
2091 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, | |
2092 | int flags, const char *name, | |
4a67d391 | 2093 | const struct drm_prop_enum_list *props, |
7689ffb3 VS |
2094 | int num_props, |
2095 | uint64_t supported_bits); | |
d9bc3c02 SH |
2096 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
2097 | const char *name, | |
2098 | uint64_t min, uint64_t max); | |
ebc44cf3 RC |
2099 | struct drm_property *drm_property_create_signed_range(struct drm_device *dev, |
2100 | int flags, const char *name, | |
2101 | int64_t min, int64_t max); | |
98f75de4 RC |
2102 | struct drm_property *drm_property_create_object(struct drm_device *dev, |
2103 | int flags, const char *name, uint32_t type); | |
960cd9d4 DV |
2104 | struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags, |
2105 | const char *name); | |
6bcacf51 DS |
2106 | struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, |
2107 | size_t length, | |
2108 | const void *data); | |
2109 | struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev, | |
2110 | uint32_t id); | |
2111 | struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob); | |
2112 | void drm_property_unreference_blob(struct drm_property_blob *blob); | |
f453ba04 DA |
2113 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); |
2114 | extern int drm_property_add_enum(struct drm_property *property, int index, | |
2115 | uint64_t value, const char *name); | |
2116 | extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); | |
2f763312 TR |
2117 | extern int drm_mode_create_tv_properties(struct drm_device *dev, |
2118 | unsigned int num_modes, | |
b7c914b3 | 2119 | const char * const modes[]); |
f453ba04 | 2120 | extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); |
ff587e45 | 2121 | extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); |
884840aa | 2122 | extern int drm_mode_create_dirty_info_property(struct drm_device *dev); |
5bb2bbf5 | 2123 | extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev); |
d34f20d6 RC |
2124 | extern bool drm_property_change_valid_get(struct drm_property *property, |
2125 | uint64_t value, struct drm_mode_object **ref); | |
2126 | extern void drm_property_change_valid_put(struct drm_property *property, | |
2127 | struct drm_mode_object *ref); | |
f453ba04 DA |
2128 | |
2129 | extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, | |
2130 | struct drm_encoder *encoder); | |
4cae5b84 | 2131 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
f453ba04 | 2132 | int gamma_size); |
7a9c9060 DV |
2133 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
2134 | uint32_t id, uint32_t type); | |
98f75de4 | 2135 | |
f453ba04 DA |
2136 | /* IOCTLs */ |
2137 | extern int drm_mode_getresources(struct drm_device *dev, | |
2138 | void *data, struct drm_file *file_priv); | |
8cf5c917 JB |
2139 | extern int drm_mode_getplane_res(struct drm_device *dev, void *data, |
2140 | struct drm_file *file_priv); | |
f453ba04 DA |
2141 | extern int drm_mode_getcrtc(struct drm_device *dev, |
2142 | void *data, struct drm_file *file_priv); | |
2143 | extern int drm_mode_getconnector(struct drm_device *dev, | |
2144 | void *data, struct drm_file *file_priv); | |
2d13b679 | 2145 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
f453ba04 DA |
2146 | extern int drm_mode_setcrtc(struct drm_device *dev, |
2147 | void *data, struct drm_file *file_priv); | |
8cf5c917 JB |
2148 | extern int drm_mode_getplane(struct drm_device *dev, |
2149 | void *data, struct drm_file *file_priv); | |
2150 | extern int drm_mode_setplane(struct drm_device *dev, | |
2151 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
2152 | extern int drm_mode_cursor_ioctl(struct drm_device *dev, |
2153 | void *data, struct drm_file *file_priv); | |
4c813d4d DA |
2154 | extern int drm_mode_cursor2_ioctl(struct drm_device *dev, |
2155 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
2156 | extern int drm_mode_addfb(struct drm_device *dev, |
2157 | void *data, struct drm_file *file_priv); | |
308e5bcb JB |
2158 | extern int drm_mode_addfb2(struct drm_device *dev, |
2159 | void *data, struct drm_file *file_priv); | |
2160 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); | |
f453ba04 DA |
2161 | extern int drm_mode_rmfb(struct drm_device *dev, |
2162 | void *data, struct drm_file *file_priv); | |
2163 | extern int drm_mode_getfb(struct drm_device *dev, | |
2164 | void *data, struct drm_file *file_priv); | |
884840aa JB |
2165 | extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
2166 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
2167 | |
2168 | extern int drm_mode_getproperty_ioctl(struct drm_device *dev, | |
2169 | void *data, struct drm_file *file_priv); | |
2170 | extern int drm_mode_getblob_ioctl(struct drm_device *dev, | |
2171 | void *data, struct drm_file *file_priv); | |
e2f5d2ea DS |
2172 | extern int drm_mode_createblob_ioctl(struct drm_device *dev, |
2173 | void *data, struct drm_file *file_priv); | |
2174 | extern int drm_mode_destroyblob_ioctl(struct drm_device *dev, | |
2175 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
2176 | extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev, |
2177 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
2178 | extern int drm_mode_getencoder(struct drm_device *dev, |
2179 | void *data, struct drm_file *file_priv); | |
2180 | extern int drm_mode_gamma_get_ioctl(struct drm_device *dev, | |
2181 | void *data, struct drm_file *file_priv); | |
2182 | extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, | |
2183 | void *data, struct drm_file *file_priv); | |
18316c8c | 2184 | extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match); |
0967e6a5 | 2185 | extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); |
f23c20c8 | 2186 | extern bool drm_detect_hdmi_monitor(struct edid *edid); |
8fe9790d | 2187 | extern bool drm_detect_monitor_audio(struct edid *edid); |
b1edd6a6 | 2188 | extern bool drm_rgb_quant_range_selectable(struct edid *edid); |
d91d8a3f KH |
2189 | extern int drm_mode_page_flip_ioctl(struct drm_device *dev, |
2190 | void *data, struct drm_file *file_priv); | |
f0fda0a4 ZY |
2191 | extern int drm_add_modes_noedid(struct drm_connector *connector, |
2192 | int hdisplay, int vdisplay); | |
3cf70daf GH |
2193 | extern void drm_set_preferred_mode(struct drm_connector *connector, |
2194 | int hpref, int vpref); | |
3c537889 | 2195 | |
051963d4 | 2196 | extern int drm_edid_header_is_valid(const u8 *raw_edid); |
6ba2bd3d TP |
2197 | extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, |
2198 | bool *edid_corrupt); | |
3c537889 | 2199 | extern bool drm_edid_is_valid(struct edid *edid); |
138f9ebb DA |
2200 | |
2201 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, | |
2202 | char topology[8]); | |
2203 | extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, | |
2204 | char topology[8]); | |
2205 | extern void drm_mode_put_tile_group(struct drm_device *dev, | |
2206 | struct drm_tile_group *tg); | |
1d42bbc8 | 2207 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
f6e252ba AJ |
2208 | int hsize, int vsize, int fresh, |
2209 | bool rb); | |
ff72145b DA |
2210 | |
2211 | extern int drm_mode_create_dumb_ioctl(struct drm_device *dev, | |
2212 | void *data, struct drm_file *file_priv); | |
2213 | extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev, | |
2214 | void *data, struct drm_file *file_priv); | |
2215 | extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, | |
2216 | void *data, struct drm_file *file_priv); | |
c543188a PZ |
2217 | extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, |
2218 | struct drm_file *file_priv); | |
2219 | extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, | |
2220 | struct drm_file *file_priv); | |
3a5f87c2 TW |
2221 | extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
2222 | struct drm_property *property, | |
2223 | uint64_t value); | |
d34f20d6 RC |
2224 | extern int drm_mode_atomic_ioctl(struct drm_device *dev, |
2225 | void *data, struct drm_file *file_priv); | |
248dbc23 DA |
2226 | |
2227 | extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, | |
2228 | int *bpp); | |
141670e9 | 2229 | extern int drm_format_num_planes(uint32_t format); |
5a86bd55 | 2230 | extern int drm_format_plane_cpp(uint32_t format, int plane); |
01b68b04 VS |
2231 | extern int drm_format_horz_chroma_subsampling(uint32_t format); |
2232 | extern int drm_format_vert_chroma_subsampling(uint32_t format); | |
d20d3174 | 2233 | extern const char *drm_get_format_name(uint32_t format); |
c1df5f3c VS |
2234 | extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, |
2235 | unsigned int supported_rotations); | |
3c9855f6 VS |
2236 | extern unsigned int drm_rotation_simplify(unsigned int rotation, |
2237 | unsigned int supported_rotations); | |
141670e9 | 2238 | |
96f60e37 | 2239 | /* Helpers */ |
a2b34e22 RC |
2240 | |
2241 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, | |
2242 | uint32_t id) | |
2243 | { | |
2244 | struct drm_mode_object *mo; | |
2245 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE); | |
2246 | return mo ? obj_to_plane(mo) : NULL; | |
2247 | } | |
2248 | ||
96f60e37 RK |
2249 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
2250 | uint32_t id) | |
2251 | { | |
2252 | struct drm_mode_object *mo; | |
2253 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); | |
2254 | return mo ? obj_to_crtc(mo) : NULL; | |
2255 | } | |
2256 | ||
2257 | static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, | |
2258 | uint32_t id) | |
2259 | { | |
2260 | struct drm_mode_object *mo; | |
2261 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER); | |
2262 | return mo ? obj_to_encoder(mo) : NULL; | |
2263 | } | |
2264 | ||
a2b34e22 RC |
2265 | static inline struct drm_connector *drm_connector_find(struct drm_device *dev, |
2266 | uint32_t id) | |
2267 | { | |
2268 | struct drm_mode_object *mo; | |
2269 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); | |
2270 | return mo ? obj_to_connector(mo) : NULL; | |
2271 | } | |
2272 | ||
2273 | static inline struct drm_property *drm_property_find(struct drm_device *dev, | |
2274 | uint32_t id) | |
2275 | { | |
2276 | struct drm_mode_object *mo; | |
2277 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY); | |
2278 | return mo ? obj_to_property(mo) : NULL; | |
2279 | } | |
2280 | ||
e27dde3e | 2281 | /* Plane list iterator for legacy (overlay only) planes. */ |
4ea50e99 DV |
2282 | #define drm_for_each_legacy_plane(plane, dev) \ |
2283 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \ | |
373701b1 | 2284 | for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
e27dde3e | 2285 | |
6295d607 DV |
2286 | #define drm_for_each_plane(plane, dev) \ |
2287 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) | |
2288 | ||
2289 | #define drm_for_each_crtc(crtc, dev) \ | |
2290 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) | |
2291 | ||
7a3f3d66 DV |
2292 | static inline void |
2293 | assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) | |
2294 | { | |
cff20ba2 DV |
2295 | /* |
2296 | * The connector hotadd/remove code currently grabs both locks when | |
2297 | * updating lists. Hence readers need only hold either of them to be | |
2298 | * safe and the check amounts to | |
2299 | * | |
2300 | * WARN_ON(not_holding(A) && not_holding(B)). | |
2301 | */ | |
2302 | WARN_ON(!mutex_is_locked(&mode_config->mutex) && | |
2303 | !drm_modeset_is_locked(&mode_config->connection_mutex)); | |
7a3f3d66 DV |
2304 | } |
2305 | ||
6295d607 | 2306 | #define drm_for_each_connector(connector, dev) \ |
7a3f3d66 DV |
2307 | for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ |
2308 | connector = list_first_entry(&(dev)->mode_config.connector_list, \ | |
2309 | struct drm_connector, head); \ | |
2310 | &connector->head != (&(dev)->mode_config.connector_list); \ | |
2311 | connector = list_next_entry(connector, head)) | |
6295d607 DV |
2312 | |
2313 | #define drm_for_each_encoder(encoder, dev) \ | |
2314 | list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head) | |
2315 | ||
2316 | #define drm_for_each_fb(fb, dev) \ | |
4676ba0b DV |
2317 | for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \ |
2318 | fb = list_first_entry(&(dev)->mode_config.fb_list, \ | |
2319 | struct drm_framebuffer, head); \ | |
2320 | &fb->head != (&(dev)->mode_config.fb_list); \ | |
2321 | fb = list_next_entry(fb, head)) | |
6295d607 | 2322 | |
f453ba04 | 2323 | #endif /* __DRM_CRTC_H__ */ |