]>
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> |
d7d2c48e DH |
34 | #include <uapi/drm/drm_mode.h> |
35 | #include <uapi/drm/drm_fourcc.h> | |
51fd371b | 36 | #include <drm/drm_modeset_lock.h> |
308e5bcb | 37 | |
f453ba04 DA |
38 | struct drm_device; |
39 | struct drm_mode_set; | |
40 | struct drm_framebuffer; | |
7e3bdf4a | 41 | struct drm_object_properties; |
595887eb TR |
42 | struct drm_file; |
43 | struct drm_clip_rect; | |
7e435aad | 44 | struct device_node; |
f453ba04 DA |
45 | |
46 | #define DRM_MODE_OBJECT_CRTC 0xcccccccc | |
47 | #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 | |
48 | #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0 | |
49 | #define DRM_MODE_OBJECT_MODE 0xdededede | |
50 | #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0 | |
51 | #define DRM_MODE_OBJECT_FB 0xfbfbfbfb | |
52 | #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb | |
8cf5c917 | 53 | #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee |
3b336ec4 | 54 | #define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd |
98f75de4 | 55 | #define DRM_MODE_OBJECT_ANY 0 |
f453ba04 DA |
56 | |
57 | struct drm_mode_object { | |
58 | uint32_t id; | |
59 | uint32_t type; | |
7e3bdf4a PZ |
60 | struct drm_object_properties *properties; |
61 | }; | |
62 | ||
fe456168 | 63 | #define DRM_OBJECT_MAX_PROPERTY 24 |
7e3bdf4a | 64 | struct drm_object_properties { |
7f88a9be | 65 | int count; |
7e3bdf4a PZ |
66 | uint32_t ids[DRM_OBJECT_MAX_PROPERTY]; |
67 | uint64_t values[DRM_OBJECT_MAX_PROPERTY]; | |
f453ba04 DA |
68 | }; |
69 | ||
ebc44cf3 RC |
70 | static inline int64_t U642I64(uint64_t val) |
71 | { | |
72 | return (int64_t)*((int64_t *)&val); | |
73 | } | |
74 | static inline uint64_t I642U64(int64_t val) | |
75 | { | |
76 | return (uint64_t)*((uint64_t *)&val); | |
77 | } | |
78 | ||
06596961 VS |
79 | /* rotation property bits */ |
80 | #define DRM_ROTATE_0 0 | |
81 | #define DRM_ROTATE_90 1 | |
82 | #define DRM_ROTATE_180 2 | |
83 | #define DRM_ROTATE_270 3 | |
84 | #define DRM_REFLECT_X 4 | |
85 | #define DRM_REFLECT_Y 5 | |
86 | ||
55310008 DV |
87 | enum drm_connector_force { |
88 | DRM_FORCE_UNSPECIFIED, | |
89 | DRM_FORCE_OFF, | |
90 | DRM_FORCE_ON, /* force on analog part normally */ | |
91 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ | |
f453ba04 DA |
92 | }; |
93 | ||
55310008 | 94 | #include <drm/drm_modes.h> |
4aa17cf0 | 95 | |
f453ba04 DA |
96 | enum drm_connector_status { |
97 | connector_status_connected = 1, | |
98 | connector_status_disconnected = 2, | |
99 | connector_status_unknown = 3, | |
100 | }; | |
101 | ||
102 | enum subpixel_order { | |
103 | SubPixelUnknown = 0, | |
104 | SubPixelHorizontalRGB, | |
105 | SubPixelHorizontalBGR, | |
106 | SubPixelVerticalRGB, | |
107 | SubPixelVerticalBGR, | |
108 | SubPixelNone, | |
109 | }; | |
110 | ||
da05a5a7 JB |
111 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
112 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) | |
113 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) | |
f453ba04 DA |
114 | /* |
115 | * Describes a given display (e.g. CRT or flat panel) and its limitations. | |
116 | */ | |
117 | struct drm_display_info { | |
118 | char name[DRM_DISPLAY_INFO_LEN]; | |
fb439640 | 119 | |
f453ba04 DA |
120 | /* Physical size */ |
121 | unsigned int width_mm; | |
122 | unsigned int height_mm; | |
123 | ||
f453ba04 DA |
124 | /* Clock limits FIXME: storage format */ |
125 | unsigned int min_vfreq, max_vfreq; | |
126 | unsigned int min_hfreq, max_hfreq; | |
127 | unsigned int pixel_clock; | |
3b11228b | 128 | unsigned int bpc; |
f453ba04 | 129 | |
f453ba04 | 130 | enum subpixel_order subpixel_order; |
da05a5a7 | 131 | u32 color_formats; |
f453ba04 | 132 | |
5d02626d MK |
133 | /* Mask of supported hdmi deep color modes */ |
134 | u8 edid_hdmi_dc_modes; | |
135 | ||
ebec9a7b | 136 | u8 cea_rev; |
f453ba04 DA |
137 | }; |
138 | ||
139 | struct drm_framebuffer_funcs { | |
f7eff60e | 140 | /* note: use drm_framebuffer_remove() */ |
f453ba04 DA |
141 | void (*destroy)(struct drm_framebuffer *framebuffer); |
142 | int (*create_handle)(struct drm_framebuffer *fb, | |
143 | struct drm_file *file_priv, | |
144 | unsigned int *handle); | |
3bf0401c DV |
145 | /* |
146 | * Optional callback for the dirty fb ioctl. | |
884840aa JB |
147 | * |
148 | * Userspace can notify the driver via this callback | |
149 | * that a area of the framebuffer has changed and should | |
150 | * be flushed to the display hardware. | |
151 | * | |
152 | * See documentation in drm_mode.h for the struct | |
153 | * drm_mode_fb_dirty_cmd for more information as all | |
154 | * the semantics and arguments have a one to one mapping | |
155 | * on this function. | |
156 | */ | |
02b00162 TH |
157 | int (*dirty)(struct drm_framebuffer *framebuffer, |
158 | struct drm_file *file_priv, unsigned flags, | |
884840aa JB |
159 | unsigned color, struct drm_clip_rect *clips, |
160 | unsigned num_clips); | |
f453ba04 DA |
161 | }; |
162 | ||
163 | struct drm_framebuffer { | |
164 | struct drm_device *dev; | |
f7eff60e RC |
165 | /* |
166 | * Note that the fb is refcounted for the benefit of driver internals, | |
167 | * for example some hw, disabling a CRTC/plane is asynchronous, and | |
168 | * scanout does not actually complete until the next vblank. So some | |
169 | * cleanup (like releasing the reference(s) on the backing GEM bo(s)) | |
170 | * should be deferred. In cases like this, the driver would like to | |
171 | * hold a ref to the fb even though it has already been removed from | |
172 | * userspace perspective. | |
173 | */ | |
174 | struct kref refcount; | |
4b096ac1 DV |
175 | /* |
176 | * Place on the dev->mode_config.fb_list, access protected by | |
177 | * dev->mode_config.fb_lock. | |
178 | */ | |
f453ba04 DA |
179 | struct list_head head; |
180 | struct drm_mode_object base; | |
181 | const struct drm_framebuffer_funcs *funcs; | |
01f2c773 VS |
182 | unsigned int pitches[4]; |
183 | unsigned int offsets[4]; | |
f453ba04 DA |
184 | unsigned int width; |
185 | unsigned int height; | |
186 | /* depth can be 15 or 16 */ | |
187 | unsigned int depth; | |
188 | int bits_per_pixel; | |
189 | int flags; | |
308e5bcb | 190 | uint32_t pixel_format; /* fourcc format */ |
f453ba04 | 191 | struct list_head filp_head; |
785b93ef DA |
192 | /* if you are using the helper */ |
193 | void *helper_private; | |
f453ba04 DA |
194 | }; |
195 | ||
196 | struct drm_property_blob { | |
197 | struct drm_mode_object base; | |
198 | struct list_head head; | |
199 | unsigned int length; | |
d63f5e6b | 200 | unsigned char data[]; |
f453ba04 DA |
201 | }; |
202 | ||
203 | struct drm_property_enum { | |
204 | uint64_t value; | |
205 | struct list_head head; | |
206 | char name[DRM_PROP_NAME_LEN]; | |
207 | }; | |
208 | ||
209 | struct drm_property { | |
210 | struct list_head head; | |
211 | struct drm_mode_object base; | |
212 | uint32_t flags; | |
213 | char name[DRM_PROP_NAME_LEN]; | |
214 | uint32_t num_values; | |
215 | uint64_t *values; | |
98f75de4 | 216 | struct drm_device *dev; |
f453ba04 DA |
217 | |
218 | struct list_head enum_blob_list; | |
219 | }; | |
220 | ||
221 | struct drm_crtc; | |
222 | struct drm_connector; | |
223 | struct drm_encoder; | |
d91d8a3f | 224 | struct drm_pending_vblank_event; |
8cf5c917 | 225 | struct drm_plane; |
3b336ec4 | 226 | struct drm_bridge; |
144ecb97 DV |
227 | struct drm_atomic_state; |
228 | ||
229 | /** | |
cc4ceb48 | 230 | * struct drm_crtc_state - mutable CRTC state |
144ecb97 | 231 | * @enable: whether the CRTC should be enabled, gates all other state |
c2fcd274 | 232 | * @planes_changed: for use by helpers and drivers when computing state updates |
144ecb97 DV |
233 | * @mode: current mode timings |
234 | * @event: optional pointer to a DRM event to signal upon completion of the | |
235 | * state update | |
236 | * @state: backpointer to global drm_atomic_state | |
237 | */ | |
238 | struct drm_crtc_state { | |
cc4ceb48 | 239 | bool enable; |
144ecb97 | 240 | |
c2fcd274 DV |
241 | /* computed state bits used by helpers and drivers */ |
242 | bool planes_changed : 1; | |
243 | ||
144ecb97 DV |
244 | struct drm_display_mode mode; |
245 | ||
246 | struct drm_pending_vblank_event *event; | |
247 | ||
248 | struct drm_atomic_state *state; | |
249 | }; | |
f453ba04 DA |
250 | |
251 | /** | |
3bf0401c | 252 | * struct drm_crtc_funcs - control CRTCs for a given device |
f453ba04 | 253 | * @save: save CRTC state |
3b02ab88 | 254 | * @restore: restore CRTC state |
715f59cc | 255 | * @reset: reset CRTC after state has been invalidated (e.g. resume) |
3b02ab88 | 256 | * @cursor_set: setup the cursor |
2c0c33d4 | 257 | * @cursor_set2: setup the cursor with hotspot, superseeds @cursor_set if set |
3b02ab88 | 258 | * @cursor_move: move the cursor |
f453ba04 | 259 | * @gamma_set: specify color ramp for CRTC |
bffd9de0 PZ |
260 | * @destroy: deinit and free object |
261 | * @set_property: called when a property is changed | |
3b02ab88 LP |
262 | * @set_config: apply a new CRTC configuration |
263 | * @page_flip: initiate a page flip | |
144ecb97 DV |
264 | * @atomic_duplicate_state: duplicate the atomic state for this CRTC |
265 | * @atomic_destroy_state: destroy an atomic state for this CRTC | |
266 | * @atomic_set_property: set a property on an atomic state for this CRTC | |
f453ba04 DA |
267 | * |
268 | * The drm_crtc_funcs structure is the central CRTC management structure | |
269 | * in the DRM. Each CRTC controls one or more connectors (note that the name | |
270 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. | |
271 | * connectors, not just CRTs). | |
272 | * | |
273 | * Each driver is responsible for filling out this structure at startup time, | |
274 | * in addition to providing other modesetting features, like i2c and DDC | |
275 | * bus accessors. | |
276 | */ | |
277 | struct drm_crtc_funcs { | |
278 | /* Save CRTC state */ | |
279 | void (*save)(struct drm_crtc *crtc); /* suspend? */ | |
280 | /* Restore CRTC state */ | |
281 | void (*restore)(struct drm_crtc *crtc); /* resume? */ | |
eb033556 CW |
282 | /* Reset CRTC state */ |
283 | void (*reset)(struct drm_crtc *crtc); | |
f453ba04 DA |
284 | |
285 | /* cursor controls */ | |
286 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, | |
287 | uint32_t handle, uint32_t width, uint32_t height); | |
4c813d4d DA |
288 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
289 | uint32_t handle, uint32_t width, uint32_t height, | |
290 | int32_t hot_x, int32_t hot_y); | |
f453ba04 DA |
291 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
292 | ||
293 | /* Set gamma on the CRTC */ | |
294 | void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, | |
7203425a | 295 | uint32_t start, uint32_t size); |
f453ba04 DA |
296 | /* Object destroy routine */ |
297 | void (*destroy)(struct drm_crtc *crtc); | |
298 | ||
299 | int (*set_config)(struct drm_mode_set *set); | |
d91d8a3f KH |
300 | |
301 | /* | |
302 | * Flip to the given framebuffer. This implements the page | |
25985edc | 303 | * flip ioctl described in drm_mode.h, specifically, the |
d91d8a3f KH |
304 | * implementation must return immediately and block all |
305 | * rendering to the current fb until the flip has completed. | |
306 | * If userspace set the event flag in the ioctl, the event | |
307 | * argument will point to an event to send back when the flip | |
308 | * completes, otherwise it will be NULL. | |
309 | */ | |
310 | int (*page_flip)(struct drm_crtc *crtc, | |
311 | struct drm_framebuffer *fb, | |
ed8d1975 KP |
312 | struct drm_pending_vblank_event *event, |
313 | uint32_t flags); | |
bffd9de0 PZ |
314 | |
315 | int (*set_property)(struct drm_crtc *crtc, | |
316 | struct drm_property *property, uint64_t val); | |
144ecb97 DV |
317 | |
318 | /* atomic update handling */ | |
319 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); | |
320 | void (*atomic_destroy_state)(struct drm_crtc *crtc, | |
cc4ceb48 | 321 | struct drm_crtc_state *state); |
144ecb97 DV |
322 | int (*atomic_set_property)(struct drm_crtc *crtc, |
323 | struct drm_crtc_state *state, | |
324 | struct drm_property *property, | |
325 | uint64_t val); | |
f453ba04 DA |
326 | }; |
327 | ||
328 | /** | |
3bf0401c | 329 | * struct drm_crtc - central CRTC control structure |
7749163e | 330 | * @dev: parent DRM device |
2c0c33d4 | 331 | * @port: OF node used by drm_of_find_possible_crtcs() |
7749163e | 332 | * @head: list management |
51fd371b | 333 | * @mutex: per-CRTC locking |
7749163e | 334 | * @base: base KMS object for ID tracking etc. |
e13161af MR |
335 | * @primary: primary plane for this CRTC |
336 | * @cursor: cursor plane for this CRTC | |
2c0c33d4 DV |
337 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
338 | * @cursor_y: current y position of the cursor, used for universal cursor planes | |
f453ba04 | 339 | * @enabled: is this CRTC enabled? |
7749163e JB |
340 | * @mode: current mode timings |
341 | * @hwmode: mode timings as programmed to hw regs | |
7c80e128 RC |
342 | * @invert_dimensions: for purposes of error checking crtc vs fb sizes, |
343 | * invert the width/height of the crtc. This is used if the driver | |
344 | * is performing 90 or 270 degree rotated scanout | |
f453ba04 DA |
345 | * @x: x position on screen |
346 | * @y: y position on screen | |
f453ba04 | 347 | * @funcs: CRTC control functions |
7749163e JB |
348 | * @gamma_size: size of gamma ramp |
349 | * @gamma_store: gamma ramp values | |
350 | * @framedur_ns: precise frame timing | |
2c0c33d4 | 351 | * @linedur_ns: precise line timing |
7749163e JB |
352 | * @pixeldur_ns: precise pixel timing |
353 | * @helper_private: mid-layer private data | |
bffd9de0 | 354 | * @properties: property tracking for this CRTC |
144ecb97 | 355 | * @state: current atomic state for this CRTC |
2c0c33d4 DV |
356 | * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for |
357 | * legacy ioctls | |
f453ba04 DA |
358 | * |
359 | * Each CRTC may have one or more connectors associated with it. This structure | |
360 | * allows the CRTC to be controlled. | |
361 | */ | |
362 | struct drm_crtc { | |
363 | struct drm_device *dev; | |
7e435aad | 364 | struct device_node *port; |
f453ba04 DA |
365 | struct list_head head; |
366 | ||
3bf0401c | 367 | /* |
29494c17 DV |
368 | * crtc mutex |
369 | * | |
370 | * This provides a read lock for the overall crtc state (mode, dpms | |
371 | * state, ...) and a write lock for everything which can be update | |
372 | * without a full modeset (fb, cursor data, ...) | |
373 | */ | |
51fd371b | 374 | struct drm_modeset_lock mutex; |
29494c17 | 375 | |
f453ba04 DA |
376 | struct drm_mode_object base; |
377 | ||
e13161af MR |
378 | /* primary and cursor planes for CRTC */ |
379 | struct drm_plane *primary; | |
380 | struct drm_plane *cursor; | |
381 | ||
161d0dc1 MR |
382 | /* position of cursor plane on crtc */ |
383 | int cursor_x; | |
384 | int cursor_y; | |
385 | ||
f453ba04 DA |
386 | bool enabled; |
387 | ||
27641c3f | 388 | /* Requested mode from modesetting. */ |
f453ba04 DA |
389 | struct drm_display_mode mode; |
390 | ||
27641c3f MK |
391 | /* Programmed mode in hw, after adjustments for encoders, |
392 | * crtc, panel scaling etc. Needed for timestamping etc. | |
393 | */ | |
394 | struct drm_display_mode hwmode; | |
395 | ||
7c80e128 RC |
396 | bool invert_dimensions; |
397 | ||
f453ba04 | 398 | int x, y; |
f453ba04 DA |
399 | const struct drm_crtc_funcs *funcs; |
400 | ||
401 | /* CRTC gamma size for reporting to userspace */ | |
402 | uint32_t gamma_size; | |
403 | uint16_t *gamma_store; | |
404 | ||
27641c3f | 405 | /* Constants needed for precise vblank and swap timestamping. */ |
3c184f69 | 406 | int framedur_ns, linedur_ns, pixeldur_ns; |
27641c3f | 407 | |
f453ba04 DA |
408 | /* if you are using the helper */ |
409 | void *helper_private; | |
bffd9de0 PZ |
410 | |
411 | struct drm_object_properties properties; | |
d059f652 | 412 | |
144ecb97 DV |
413 | struct drm_crtc_state *state; |
414 | ||
d059f652 DV |
415 | /* |
416 | * For legacy crtc ioctls so that atomic drivers can get at the locking | |
417 | * acquire context. | |
418 | */ | |
419 | struct drm_modeset_acquire_ctx *acquire_ctx; | |
f453ba04 DA |
420 | }; |
421 | ||
144ecb97 DV |
422 | /** |
423 | * struct drm_connector_state - mutable connector state | |
cc4ceb48 | 424 | * @crtc: CRTC to connect connector to, NULL if disabled |
144ecb97 DV |
425 | * @state: backpointer to global drm_atomic_state |
426 | */ | |
427 | struct drm_connector_state { | |
428 | struct drm_crtc *crtc; | |
429 | ||
430 | struct drm_atomic_state *state; | |
431 | }; | |
f453ba04 DA |
432 | |
433 | /** | |
3bf0401c | 434 | * struct drm_connector_funcs - control connectors on a given device |
f453ba04 DA |
435 | * @dpms: set power state (see drm_crtc_funcs above) |
436 | * @save: save connector state | |
437 | * @restore: restore connector state | |
13bcf01b | 438 | * @reset: reset connector after state has been invalidated (e.g. resume) |
f453ba04 | 439 | * @detect: is this connector active? |
3b02ab88 | 440 | * @fill_modes: fill mode list for this connector |
13bcf01b | 441 | * @set_property: property for this connector may need an update |
f453ba04 | 442 | * @destroy: make object go away |
13bcf01b | 443 | * @force: notify the driver that the connector is forced on |
144ecb97 DV |
444 | * @atomic_duplicate_state: duplicate the atomic state for this connector |
445 | * @atomic_destroy_state: destroy an atomic state for this connector | |
446 | * @atomic_set_property: set a property on an atomic state for this connector | |
447 | * | |
f453ba04 DA |
448 | * Each CRTC may have one or more connectors attached to it. The functions |
449 | * below allow the core DRM code to control connectors, enumerate available modes, | |
450 | * etc. | |
451 | */ | |
452 | struct drm_connector_funcs { | |
453 | void (*dpms)(struct drm_connector *connector, int mode); | |
454 | void (*save)(struct drm_connector *connector); | |
455 | void (*restore)(struct drm_connector *connector); | |
eb033556 | 456 | void (*reset)(struct drm_connector *connector); |
930a9e28 CW |
457 | |
458 | /* Check to see if anything is attached to the connector. | |
459 | * @force is set to false whilst polling, true when checking the | |
460 | * connector due to user request. @force can be used by the driver | |
461 | * to avoid expensive, destructive operations during automated | |
462 | * probing. | |
463 | */ | |
7b334fcb | 464 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
930a9e28 | 465 | bool force); |
40a518d9 | 466 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); |
f453ba04 DA |
467 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
468 | uint64_t val); | |
469 | void (*destroy)(struct drm_connector *connector); | |
d50ba256 | 470 | void (*force)(struct drm_connector *connector); |
144ecb97 DV |
471 | |
472 | /* atomic update handling */ | |
473 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); | |
474 | void (*atomic_destroy_state)(struct drm_connector *connector, | |
cc4ceb48 | 475 | struct drm_connector_state *state); |
144ecb97 DV |
476 | int (*atomic_set_property)(struct drm_connector *connector, |
477 | struct drm_connector_state *state, | |
478 | struct drm_property *property, | |
479 | uint64_t val); | |
f453ba04 DA |
480 | }; |
481 | ||
6c3db920 | 482 | /** |
3bf0401c | 483 | * struct drm_encoder_funcs - encoder controls |
6c3db920 JB |
484 | * @reset: reset state (e.g. at init or resume time) |
485 | * @destroy: cleanup and free associated data | |
486 | * | |
487 | * Encoders sit between CRTCs and connectors. | |
488 | */ | |
f453ba04 | 489 | struct drm_encoder_funcs { |
eb033556 | 490 | void (*reset)(struct drm_encoder *encoder); |
f453ba04 DA |
491 | void (*destroy)(struct drm_encoder *encoder); |
492 | }; | |
493 | ||
afe887df | 494 | #define DRM_CONNECTOR_MAX_ENCODER 3 |
f453ba04 DA |
495 | |
496 | /** | |
3bf0401c | 497 | * struct drm_encoder - central DRM encoder structure |
db3e4499 JB |
498 | * @dev: parent DRM device |
499 | * @head: list management | |
500 | * @base: base KMS object | |
e5748946 | 501 | * @name: encoder name |
db3e4499 JB |
502 | * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h |
503 | * @possible_crtcs: bitmask of potential CRTC bindings | |
504 | * @possible_clones: bitmask of potential sibling encoders for cloning | |
505 | * @crtc: currently bound CRTC | |
3b336ec4 | 506 | * @bridge: bridge associated to the encoder |
db3e4499 JB |
507 | * @funcs: control functions |
508 | * @helper_private: mid-layer private data | |
509 | * | |
510 | * CRTCs drive pixels to encoders, which convert them into signals | |
511 | * appropriate for a given connector or set of connectors. | |
f453ba04 DA |
512 | */ |
513 | struct drm_encoder { | |
514 | struct drm_device *dev; | |
515 | struct list_head head; | |
516 | ||
517 | struct drm_mode_object base; | |
e5748946 | 518 | char *name; |
f453ba04 DA |
519 | int encoder_type; |
520 | uint32_t possible_crtcs; | |
521 | uint32_t possible_clones; | |
522 | ||
523 | struct drm_crtc *crtc; | |
3b336ec4 | 524 | struct drm_bridge *bridge; |
f453ba04 DA |
525 | const struct drm_encoder_funcs *funcs; |
526 | void *helper_private; | |
527 | }; | |
528 | ||
eb1f8e4f DA |
529 | /* should we poll this connector for connects and disconnects */ |
530 | /* hot plug detectable */ | |
531 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) | |
532 | /* poll for connections */ | |
533 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) | |
534 | /* can cleanly poll for disconnections without flickering the screen */ | |
535 | /* DACs should rarely do this without a lot of testing */ | |
536 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) | |
537 | ||
76adaa34 WF |
538 | #define MAX_ELD_BYTES 128 |
539 | ||
f453ba04 | 540 | /** |
3bf0401c | 541 | * struct drm_connector - central DRM connector control structure |
72252548 JB |
542 | * @dev: parent DRM device |
543 | * @kdev: kernel device for sysfs attributes | |
544 | * @attr: sysfs attributes | |
545 | * @head: list management | |
546 | * @base: base KMS object | |
2abdd313 | 547 | * @name: connector name |
72252548 JB |
548 | * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h |
549 | * @connector_type_id: index into connector type enum | |
f453ba04 DA |
550 | * @interlace_allowed: can this connector handle interlaced modes? |
551 | * @doublescan_allowed: can this connector handle doublescan? | |
2c0c33d4 | 552 | * @stereo_allowed: can this connector handle stereo modes? |
72252548 JB |
553 | * @modes: modes available on this connector (from fill_modes() + user) |
554 | * @status: one of the drm_connector_status enums (connected, not, or unknown) | |
555 | * @probed_modes: list of modes derived directly from the display | |
556 | * @display_info: information about attached display (e.g. from EDID) | |
f453ba04 | 557 | * @funcs: connector control functions |
72252548 | 558 | * @edid_blob_ptr: DRM property containing EDID if present |
7e3bdf4a | 559 | * @properties: property tracking for this connector |
2c0c33d4 | 560 | * @path_blob_ptr: DRM blob property data for the DP MST path property |
72252548 JB |
561 | * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling |
562 | * @dpms: current dpms state | |
563 | * @helper_private: mid-layer private data | |
2c0c33d4 | 564 | * @cmdline_mode: mode line parsed from the kernel cmdline for this connector |
72252548 | 565 | * @force: a %DRM_FORCE_<foo> state for forced mode sets |
2c0c33d4 | 566 | * @override_edid: has the EDID been overwritten through debugfs for testing? |
72252548 JB |
567 | * @encoder_ids: valid encoders for this connector |
568 | * @encoder: encoder driving this connector, if any | |
569 | * @eld: EDID-like data, if present | |
570 | * @dvi_dual: dual link DVI, if found | |
571 | * @max_tmds_clock: max clock rate, if found | |
572 | * @latency_present: AV delay info from ELD, if found | |
573 | * @video_latency: video latency info from ELD, if found | |
574 | * @audio_latency: audio latency info from ELD, if found | |
575 | * @null_edid_counter: track sinks that give us all zeros for the EDID | |
2c0c33d4 DV |
576 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum |
577 | * @debugfs_entry: debugfs directory for this connector | |
144ecb97 | 578 | * @state: current atomic state for this connector |
f453ba04 DA |
579 | * |
580 | * Each connector may be connected to one or more CRTCs, or may be clonable by | |
581 | * another connector if they can share a CRTC. Each connector also has a specific | |
582 | * position in the broader display (referred to as a 'screen' though it could | |
583 | * span multiple monitors). | |
584 | */ | |
585 | struct drm_connector { | |
586 | struct drm_device *dev; | |
5bdebb18 | 587 | struct device *kdev; |
f453ba04 DA |
588 | struct device_attribute *attr; |
589 | struct list_head head; | |
590 | ||
591 | struct drm_mode_object base; | |
592 | ||
2abdd313 | 593 | char *name; |
f453ba04 DA |
594 | int connector_type; |
595 | int connector_type_id; | |
596 | bool interlace_allowed; | |
597 | bool doublescan_allowed; | |
560a067a | 598 | bool stereo_allowed; |
f453ba04 DA |
599 | struct list_head modes; /* list of modes on this connector */ |
600 | ||
f453ba04 DA |
601 | enum drm_connector_status status; |
602 | ||
603 | /* these are modes added by probing with DDC or the BIOS */ | |
604 | struct list_head probed_modes; | |
605 | ||
606 | struct drm_display_info display_info; | |
607 | const struct drm_connector_funcs *funcs; | |
608 | ||
f453ba04 | 609 | struct drm_property_blob *edid_blob_ptr; |
7e3bdf4a | 610 | struct drm_object_properties properties; |
f453ba04 | 611 | |
43aba7eb DA |
612 | struct drm_property_blob *path_blob_ptr; |
613 | ||
eb1f8e4f DA |
614 | uint8_t polled; /* DRM_CONNECTOR_POLL_* */ |
615 | ||
c9fb15f6 KP |
616 | /* requested DPMS state */ |
617 | int dpms; | |
618 | ||
f453ba04 DA |
619 | void *helper_private; |
620 | ||
d50ba256 | 621 | /* forced on connector */ |
eaf99c74 | 622 | struct drm_cmdline_mode cmdline_mode; |
d50ba256 | 623 | enum drm_connector_force force; |
4cf2b281 | 624 | bool override_edid; |
f453ba04 | 625 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
f453ba04 | 626 | struct drm_encoder *encoder; /* currently active encoder */ |
4a9a8b71 | 627 | |
76adaa34 WF |
628 | /* EDID bits */ |
629 | uint8_t eld[MAX_ELD_BYTES]; | |
630 | bool dvi_dual; | |
631 | int max_tmds_clock; /* in MHz */ | |
632 | bool latency_present[2]; | |
633 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ | |
634 | int audio_latency[2]; | |
4a9a8b71 | 635 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ |
0b2443ed | 636 | unsigned bad_edid_counter; |
30f65707 TW |
637 | |
638 | struct dentry *debugfs_entry; | |
144ecb97 DV |
639 | |
640 | struct drm_connector_state *state; | |
641 | }; | |
642 | ||
643 | /** | |
644 | * struct drm_plane_state - mutable plane state | |
645 | * @crtc: currently bound CRTC, NULL if disabled | |
cc4ceb48 | 646 | * @fb: currently bound framebuffer |
144ecb97 DV |
647 | * @crtc_x: left position of visible portion of plane on crtc |
648 | * @crtc_y: upper position of visible portion of plane on crtc | |
649 | * @crtc_w: width of visible portion of plane on crtc | |
650 | * @crtc_h: height of visible portion of plane on crtc | |
651 | * @src_x: left position of visible portion of plane within | |
652 | * plane (in 16.16) | |
653 | * @src_y: upper position of visible portion of plane within | |
654 | * plane (in 16.16) | |
655 | * @src_w: width of visible portion of plane (in 16.16) | |
656 | * @src_h: height of visible portion of plane (in 16.16) | |
657 | * @state: backpointer to global drm_atomic_state | |
658 | */ | |
659 | struct drm_plane_state { | |
660 | struct drm_crtc *crtc; | |
661 | struct drm_framebuffer *fb; | |
662 | ||
663 | /* Signed dest location allows it to be partially off screen */ | |
664 | int32_t crtc_x, crtc_y; | |
665 | uint32_t crtc_w, crtc_h; | |
666 | ||
667 | /* Source values are 16.16 fixed point */ | |
668 | uint32_t src_x, src_y; | |
669 | uint32_t src_h, src_w; | |
670 | ||
671 | struct drm_atomic_state *state; | |
f453ba04 DA |
672 | }; |
673 | ||
144ecb97 | 674 | |
8cf5c917 | 675 | /** |
3bf0401c | 676 | * struct drm_plane_funcs - driver plane control functions |
8cf5c917 JB |
677 | * @update_plane: update the plane configuration |
678 | * @disable_plane: shut down the plane | |
679 | * @destroy: clean up plane resources | |
2c0c33d4 | 680 | * @reset: reset plane after state has been invalidated (e.g. resume) |
4d93914a | 681 | * @set_property: called when a property is changed |
144ecb97 DV |
682 | * @atomic_duplicate_state: duplicate the atomic state for this plane |
683 | * @atomic_destroy_state: destroy an atomic state for this plane | |
684 | * @atomic_set_property: set a property on an atomic state for this plane | |
8cf5c917 JB |
685 | */ |
686 | struct drm_plane_funcs { | |
687 | int (*update_plane)(struct drm_plane *plane, | |
688 | struct drm_crtc *crtc, struct drm_framebuffer *fb, | |
689 | int crtc_x, int crtc_y, | |
690 | unsigned int crtc_w, unsigned int crtc_h, | |
691 | uint32_t src_x, uint32_t src_y, | |
692 | uint32_t src_w, uint32_t src_h); | |
693 | int (*disable_plane)(struct drm_plane *plane); | |
694 | void (*destroy)(struct drm_plane *plane); | |
2a0d7cfd | 695 | void (*reset)(struct drm_plane *plane); |
4d93914a RC |
696 | |
697 | int (*set_property)(struct drm_plane *plane, | |
698 | struct drm_property *property, uint64_t val); | |
144ecb97 DV |
699 | |
700 | /* atomic update handling */ | |
701 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); | |
702 | void (*atomic_destroy_state)(struct drm_plane *plane, | |
cc4ceb48 | 703 | struct drm_plane_state *state); |
144ecb97 DV |
704 | int (*atomic_set_property)(struct drm_plane *plane, |
705 | struct drm_plane_state *state, | |
706 | struct drm_property *property, | |
707 | uint64_t val); | |
8cf5c917 JB |
708 | }; |
709 | ||
e27dde3e MR |
710 | enum drm_plane_type { |
711 | DRM_PLANE_TYPE_OVERLAY, | |
712 | DRM_PLANE_TYPE_PRIMARY, | |
713 | DRM_PLANE_TYPE_CURSOR, | |
714 | }; | |
715 | ||
8cf5c917 | 716 | /** |
3bf0401c | 717 | * struct drm_plane - central DRM plane control structure |
8cf5c917 JB |
718 | * @dev: DRM device this plane belongs to |
719 | * @head: for list management | |
720 | * @base: base mode object | |
721 | * @possible_crtcs: pipes this plane can be bound to | |
722 | * @format_types: array of formats supported by this plane | |
723 | * @format_count: number of formats supported | |
724 | * @crtc: currently bound CRTC | |
725 | * @fb: currently bound fb | |
2c0c33d4 DV |
726 | * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by |
727 | * drm_mode_set_config_internal() to implement correct refcounting. | |
8cf5c917 | 728 | * @funcs: helper functions |
4d93914a | 729 | * @properties: property tracking for this plane |
e27dde3e | 730 | * @type: type of plane (overlay, primary, cursor) |
144ecb97 | 731 | * @state: current atomic state for this plane |
8cf5c917 JB |
732 | */ |
733 | struct drm_plane { | |
734 | struct drm_device *dev; | |
735 | struct list_head head; | |
736 | ||
737 | struct drm_mode_object base; | |
738 | ||
739 | uint32_t possible_crtcs; | |
740 | uint32_t *format_types; | |
741 | uint32_t format_count; | |
742 | ||
743 | struct drm_crtc *crtc; | |
744 | struct drm_framebuffer *fb; | |
745 | ||
3d30a59b DV |
746 | struct drm_framebuffer *old_fb; |
747 | ||
8cf5c917 | 748 | const struct drm_plane_funcs *funcs; |
4d93914a RC |
749 | |
750 | struct drm_object_properties properties; | |
e27dde3e MR |
751 | |
752 | enum drm_plane_type type; | |
144ecb97 | 753 | |
c2fcd274 DV |
754 | void *helper_private; |
755 | ||
144ecb97 | 756 | struct drm_plane_state *state; |
8cf5c917 JB |
757 | }; |
758 | ||
3b336ec4 | 759 | /** |
3bf0401c | 760 | * struct drm_bridge_funcs - drm_bridge control functions |
3b336ec4 SP |
761 | * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge |
762 | * @disable: Called right before encoder prepare, disables the bridge | |
763 | * @post_disable: Called right after encoder prepare, for lockstepped disable | |
764 | * @mode_set: Set this mode to the bridge | |
765 | * @pre_enable: Called right before encoder commit, for lockstepped commit | |
766 | * @enable: Called right after encoder commit, enables the bridge | |
767 | * @destroy: make object go away | |
768 | */ | |
769 | struct drm_bridge_funcs { | |
770 | bool (*mode_fixup)(struct drm_bridge *bridge, | |
771 | const struct drm_display_mode *mode, | |
772 | struct drm_display_mode *adjusted_mode); | |
773 | void (*disable)(struct drm_bridge *bridge); | |
774 | void (*post_disable)(struct drm_bridge *bridge); | |
775 | void (*mode_set)(struct drm_bridge *bridge, | |
776 | struct drm_display_mode *mode, | |
777 | struct drm_display_mode *adjusted_mode); | |
778 | void (*pre_enable)(struct drm_bridge *bridge); | |
779 | void (*enable)(struct drm_bridge *bridge); | |
780 | void (*destroy)(struct drm_bridge *bridge); | |
781 | }; | |
782 | ||
783 | /** | |
3bf0401c | 784 | * struct drm_bridge - central DRM bridge control structure |
3b336ec4 SP |
785 | * @dev: DRM device this bridge belongs to |
786 | * @head: list management | |
787 | * @base: base mode object | |
788 | * @funcs: control functions | |
789 | * @driver_private: pointer to the bridge driver's internal context | |
790 | */ | |
791 | struct drm_bridge { | |
792 | struct drm_device *dev; | |
793 | struct list_head head; | |
794 | ||
795 | struct drm_mode_object base; | |
796 | ||
797 | const struct drm_bridge_funcs *funcs; | |
798 | void *driver_private; | |
799 | }; | |
800 | ||
cc4ceb48 DV |
801 | /** |
802 | * struct struct drm_atomic_state - the global state object for atomic updates | |
803 | * @dev: parent DRM device | |
804 | * @flags: state flags like async update | |
805 | * @planes: pointer to array of plane pointers | |
806 | * @plane_states: pointer to array of plane states pointers | |
807 | * @crtcs: pointer to array of CRTC pointers | |
808 | * @crtc_states: pointer to array of CRTC states pointers | |
809 | * @connectors: pointer to array of connector pointers | |
810 | * @connector_states: pointer to array of connector states pointers | |
811 | * @acquire_ctx: acquire context for this atomic modeset state update | |
812 | */ | |
813 | struct drm_atomic_state { | |
814 | struct drm_device *dev; | |
815 | uint32_t flags; | |
816 | struct drm_plane **planes; | |
817 | struct drm_plane_state **plane_states; | |
818 | struct drm_crtc **crtcs; | |
819 | struct drm_crtc_state **crtc_states; | |
820 | struct drm_connector **connectors; | |
821 | struct drm_connector_state **connector_states; | |
822 | ||
823 | struct drm_modeset_acquire_ctx *acquire_ctx; | |
824 | }; | |
825 | ||
826 | ||
f453ba04 | 827 | /** |
3bf0401c | 828 | * struct drm_mode_set - new values for a CRTC config change |
ef27351a JB |
829 | * @fb: framebuffer to use for new config |
830 | * @crtc: CRTC whose configuration we're about to change | |
831 | * @mode: mode timings to use | |
832 | * @x: position of this CRTC relative to @fb | |
833 | * @y: position of this CRTC relative to @fb | |
834 | * @connectors: array of connectors to drive with this CRTC if possible | |
835 | * @num_connectors: size of @connectors array | |
f453ba04 DA |
836 | * |
837 | * Represents a single crtc the connectors that it drives with what mode | |
838 | * and from which framebuffer it scans out from. | |
839 | * | |
840 | * This is used to set modes. | |
841 | */ | |
842 | struct drm_mode_set { | |
f453ba04 DA |
843 | struct drm_framebuffer *fb; |
844 | struct drm_crtc *crtc; | |
845 | struct drm_display_mode *mode; | |
846 | ||
847 | uint32_t x; | |
848 | uint32_t y; | |
849 | ||
850 | struct drm_connector **connectors; | |
851 | size_t num_connectors; | |
852 | }; | |
853 | ||
854 | /** | |
550cebcd JB |
855 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
856 | * @fb_create: create a new framebuffer object | |
857 | * @output_poll_changed: function to handle output configuration changes | |
cc4ceb48 DV |
858 | * @atomic_check: check whether a give atomic state update is possible |
859 | * @atomic_commit: commit an atomic state update previously verified with | |
860 | * atomic_check() | |
550cebcd JB |
861 | * |
862 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that | |
863 | * involve drivers. | |
f453ba04 DA |
864 | */ |
865 | struct drm_mode_config_funcs { | |
550cebcd JB |
866 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
867 | struct drm_file *file_priv, | |
868 | struct drm_mode_fb_cmd2 *mode_cmd); | |
eb1f8e4f | 869 | void (*output_poll_changed)(struct drm_device *dev); |
cc4ceb48 DV |
870 | |
871 | int (*atomic_check)(struct drm_device *dev, | |
872 | struct drm_atomic_state *a); | |
873 | int (*atomic_commit)(struct drm_device *dev, | |
874 | struct drm_atomic_state *a, | |
875 | bool async); | |
f453ba04 DA |
876 | }; |
877 | ||
c1aaca23 | 878 | /** |
2c0c33d4 | 879 | * struct drm_mode_group - group of mode setting resources for potential sub-grouping |
c1aaca23 JB |
880 | * @num_crtcs: CRTC count |
881 | * @num_encoders: encoder count | |
882 | * @num_connectors: connector count | |
2c0c33d4 | 883 | * @num_bridges: bridge count |
c1aaca23 JB |
884 | * @id_list: list of KMS object IDs in this group |
885 | * | |
886 | * Currently this simply tracks the global mode setting state. But in the | |
887 | * future it could allow groups of objects to be set aside into independent | |
888 | * control groups for use by different user level processes (e.g. two X servers | |
889 | * running simultaneously on different heads, each with their own mode | |
890 | * configuration and freedom of mode setting). | |
891 | */ | |
f453ba04 DA |
892 | struct drm_mode_group { |
893 | uint32_t num_crtcs; | |
894 | uint32_t num_encoders; | |
895 | uint32_t num_connectors; | |
3b336ec4 | 896 | uint32_t num_bridges; |
f453ba04 DA |
897 | |
898 | /* list of object IDs for this group */ | |
899 | uint32_t *id_list; | |
900 | }; | |
901 | ||
902 | /** | |
2c0c33d4 | 903 | * struct drm_mode_config - Mode configuration control structure |
a62c93d5 | 904 | * @mutex: mutex protecting KMS related lists and structures |
2c0c33d4 DV |
905 | * @connection_mutex: ww mutex protecting connector state and routing |
906 | * @acquire_ctx: global implicit acquire context used by atomic drivers for | |
907 | * legacy ioctls | |
a62c93d5 JB |
908 | * @idr_mutex: mutex for KMS ID allocation and management |
909 | * @crtc_idr: main KMS ID tracking object | |
2c0c33d4 | 910 | * @fb_lock: mutex to protect fb state and lists |
a62c93d5 JB |
911 | * @num_fb: number of fbs available |
912 | * @fb_list: list of framebuffers available | |
913 | * @num_connector: number of connectors on this device | |
914 | * @connector_list: list of connector objects | |
3b336ec4 SP |
915 | * @num_bridge: number of bridges on this device |
916 | * @bridge_list: list of bridge objects | |
a62c93d5 JB |
917 | * @num_encoder: number of encoders on this device |
918 | * @encoder_list: list of encoder objects | |
2c0c33d4 DV |
919 | * @num_overlay_plane: number of overlay planes on this device |
920 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device | |
921 | * @plane_list: list of plane objects | |
a62c93d5 JB |
922 | * @num_crtc: number of CRTCs on this device |
923 | * @crtc_list: list of CRTC objects | |
2c0c33d4 | 924 | * @property_list: list of property objects |
a62c93d5 JB |
925 | * @min_width: minimum pixel width on this device |
926 | * @min_height: minimum pixel height on this device | |
927 | * @max_width: maximum pixel width on this device | |
928 | * @max_height: maximum pixel height on this device | |
929 | * @funcs: core driver provided mode setting functions | |
930 | * @fb_base: base address of the framebuffer | |
2c0c33d4 DV |
931 | * @poll_enabled: track polling support for this device |
932 | * @poll_running: track polling status for this device | |
a62c93d5 | 933 | * @output_poll_work: delayed work for polling in process context |
2c0c33d4 | 934 | * @property_blob_list: list of all the blob property objects |
a62c93d5 | 935 | * @*_property: core property tracking |
2c0c33d4 DV |
936 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
937 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering | |
938 | * @async_page_flip: does this device support async flips on the primary plane? | |
939 | * @cursor_width: hint to userspace for max cursor width | |
940 | * @cursor_height: hint to userspace for max cursor height | |
f453ba04 | 941 | * |
a62c93d5 JB |
942 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
943 | * enumerated by the driver are added here, as are global properties. Some | |
944 | * global restrictions are also here, e.g. dimension restrictions. | |
f453ba04 DA |
945 | */ |
946 | struct drm_mode_config { | |
ad2563c2 | 947 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
51fd371b RC |
948 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
949 | struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */ | |
ad2563c2 | 950 | struct mutex idr_mutex; /* for IDR management */ |
f453ba04 DA |
951 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
952 | /* this is limited to one for now */ | |
4b096ac1 | 953 | |
2c0c33d4 | 954 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
f453ba04 DA |
955 | int num_fb; |
956 | struct list_head fb_list; | |
4b096ac1 | 957 | |
f453ba04 DA |
958 | int num_connector; |
959 | struct list_head connector_list; | |
3b336ec4 SP |
960 | int num_bridge; |
961 | struct list_head bridge_list; | |
f453ba04 DA |
962 | int num_encoder; |
963 | struct list_head encoder_list; | |
e27dde3e MR |
964 | |
965 | /* | |
966 | * Track # of overlay planes separately from # of total planes. By | |
967 | * default we only advertise overlay planes to userspace; if userspace | |
968 | * sets the "universal plane" capability bit, we'll go ahead and | |
969 | * expose all planes. | |
970 | */ | |
971 | int num_overlay_plane; | |
972 | int num_total_plane; | |
8cf5c917 | 973 | struct list_head plane_list; |
f453ba04 DA |
974 | |
975 | int num_crtc; | |
976 | struct list_head crtc_list; | |
977 | ||
978 | struct list_head property_list; | |
979 | ||
f453ba04 DA |
980 | int min_width, min_height; |
981 | int max_width, max_height; | |
e6ecefaa | 982 | const struct drm_mode_config_funcs *funcs; |
d883f7f1 | 983 | resource_size_t fb_base; |
f453ba04 | 984 | |
eb1f8e4f DA |
985 | /* output poll support */ |
986 | bool poll_enabled; | |
905bc9ff | 987 | bool poll_running; |
991ea75c | 988 | struct delayed_work output_poll_work; |
eb1f8e4f | 989 | |
f453ba04 DA |
990 | /* pointers to standard properties */ |
991 | struct list_head property_blob_list; | |
992 | struct drm_property *edid_property; | |
993 | struct drm_property *dpms_property; | |
43aba7eb | 994 | struct drm_property *path_property; |
9922ab5a | 995 | struct drm_property *plane_type_property; |
2a297cce | 996 | struct drm_property *rotation_property; |
f453ba04 DA |
997 | |
998 | /* DVI-I properties */ | |
999 | struct drm_property *dvi_i_subconnector_property; | |
1000 | struct drm_property *dvi_i_select_subconnector_property; | |
1001 | ||
1002 | /* TV properties */ | |
1003 | struct drm_property *tv_subconnector_property; | |
1004 | struct drm_property *tv_select_subconnector_property; | |
1005 | struct drm_property *tv_mode_property; | |
1006 | struct drm_property *tv_left_margin_property; | |
1007 | struct drm_property *tv_right_margin_property; | |
1008 | struct drm_property *tv_top_margin_property; | |
1009 | struct drm_property *tv_bottom_margin_property; | |
b6b7902e FJ |
1010 | struct drm_property *tv_brightness_property; |
1011 | struct drm_property *tv_contrast_property; | |
1012 | struct drm_property *tv_flicker_reduction_property; | |
a75f0236 FJ |
1013 | struct drm_property *tv_overscan_property; |
1014 | struct drm_property *tv_saturation_property; | |
1015 | struct drm_property *tv_hue_property; | |
f453ba04 DA |
1016 | |
1017 | /* Optional properties */ | |
1018 | struct drm_property *scaling_mode_property; | |
ff587e45 | 1019 | struct drm_property *aspect_ratio_property; |
884840aa | 1020 | struct drm_property *dirty_info_property; |
019d96cb DA |
1021 | |
1022 | /* dumb ioctl parameters */ | |
1023 | uint32_t preferred_depth, prefer_shadow; | |
62f2104f KP |
1024 | |
1025 | /* whether async page flip is supported or not */ | |
1026 | bool async_page_flip; | |
8716ed4e AD |
1027 | |
1028 | /* cursor size */ | |
1029 | uint32_t cursor_width, cursor_height; | |
f453ba04 DA |
1030 | }; |
1031 | ||
1032 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) | |
1033 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) | |
1034 | #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) | |
1035 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) | |
1036 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) | |
1037 | #define obj_to_property(x) container_of(x, struct drm_property, base) | |
1038 | #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) | |
8cf5c917 | 1039 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
f453ba04 | 1040 | |
4a67d391 SH |
1041 | struct drm_prop_enum_list { |
1042 | int type; | |
1043 | char *name; | |
1044 | }; | |
f453ba04 | 1045 | |
e13161af MR |
1046 | extern int drm_crtc_init_with_planes(struct drm_device *dev, |
1047 | struct drm_crtc *crtc, | |
1048 | struct drm_plane *primary, | |
fc1d3e44 | 1049 | struct drm_plane *cursor, |
e13161af | 1050 | const struct drm_crtc_funcs *funcs); |
f453ba04 | 1051 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
db5f7a6e RK |
1052 | extern unsigned int drm_crtc_index(struct drm_crtc *crtc); |
1053 | ||
1054 | /** | |
1055 | * drm_crtc_mask - find the mask of a registered CRTC | |
1056 | * @crtc: CRTC to find mask for | |
1057 | * | |
1058 | * Given a registered CRTC, return the mask bit of that CRTC for an | |
1059 | * encoder's possible_crtcs field. | |
1060 | */ | |
1061 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) | |
1062 | { | |
1063 | return 1 << drm_crtc_index(crtc); | |
1064 | } | |
f453ba04 | 1065 | |
b21e3afe IM |
1066 | extern void drm_connector_ida_init(void); |
1067 | extern void drm_connector_ida_destroy(void); | |
6bfc56aa VS |
1068 | extern int drm_connector_init(struct drm_device *dev, |
1069 | struct drm_connector *connector, | |
1070 | const struct drm_connector_funcs *funcs, | |
1071 | int connector_type); | |
34ea3d38 TW |
1072 | int drm_connector_register(struct drm_connector *connector); |
1073 | void drm_connector_unregister(struct drm_connector *connector); | |
f453ba04 DA |
1074 | |
1075 | extern void drm_connector_cleanup(struct drm_connector *connector); | |
10f637bf | 1076 | extern unsigned int drm_connector_index(struct drm_connector *connector); |
cbc7e221 DA |
1077 | /* helper to unplug all connectors from sysfs for device */ |
1078 | extern void drm_connector_unplug_all(struct drm_device *dev); | |
f453ba04 | 1079 | |
3b336ec4 SP |
1080 | extern int drm_bridge_init(struct drm_device *dev, struct drm_bridge *bridge, |
1081 | const struct drm_bridge_funcs *funcs); | |
1082 | extern void drm_bridge_cleanup(struct drm_bridge *bridge); | |
1083 | ||
6bfc56aa VS |
1084 | extern int drm_encoder_init(struct drm_device *dev, |
1085 | struct drm_encoder *encoder, | |
1086 | const struct drm_encoder_funcs *funcs, | |
1087 | int encoder_type); | |
f453ba04 | 1088 | |
3d887368 TR |
1089 | /** |
1090 | * drm_encoder_crtc_ok - can a given crtc drive a given encoder? | |
1091 | * @encoder: encoder to test | |
1092 | * @crtc: crtc to test | |
1093 | * | |
1094 | * Return false if @encoder can't be driven by @crtc, true otherwise. | |
1095 | */ | |
1096 | static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder, | |
1097 | struct drm_crtc *crtc) | |
1098 | { | |
1099 | return !!(encoder->possible_crtcs & drm_crtc_mask(crtc)); | |
1100 | } | |
1101 | ||
dc415ff9 MR |
1102 | extern int drm_universal_plane_init(struct drm_device *dev, |
1103 | struct drm_plane *plane, | |
1104 | unsigned long possible_crtcs, | |
1105 | const struct drm_plane_funcs *funcs, | |
1106 | const uint32_t *formats, | |
1107 | uint32_t format_count, | |
1108 | enum drm_plane_type type); | |
8cf5c917 JB |
1109 | extern int drm_plane_init(struct drm_device *dev, |
1110 | struct drm_plane *plane, | |
1111 | unsigned long possible_crtcs, | |
1112 | const struct drm_plane_funcs *funcs, | |
0a7eb243 | 1113 | const uint32_t *formats, uint32_t format_count, |
dc415ff9 | 1114 | bool is_primary); |
8cf5c917 | 1115 | extern void drm_plane_cleanup(struct drm_plane *plane); |
10f637bf | 1116 | extern unsigned int drm_plane_index(struct drm_plane *plane); |
9125e618 | 1117 | extern void drm_plane_force_disable(struct drm_plane *plane); |
af93629d MR |
1118 | extern int drm_crtc_check_viewport(const struct drm_crtc *crtc, |
1119 | int x, int y, | |
1120 | const struct drm_display_mode *mode, | |
1121 | const struct drm_framebuffer *fb); | |
8cf5c917 | 1122 | |
f453ba04 DA |
1123 | extern void drm_encoder_cleanup(struct drm_encoder *encoder); |
1124 | ||
d20d3174 | 1125 | extern const char *drm_get_connector_status_name(enum drm_connector_status status); |
ac1bb36c | 1126 | extern const char *drm_get_subpixel_order_name(enum subpixel_order order); |
d20d3174 VS |
1127 | extern const char *drm_get_dpms_name(int val); |
1128 | extern const char *drm_get_dvi_i_subconnector_name(int val); | |
1129 | extern const char *drm_get_dvi_i_select_name(int val); | |
1130 | extern const char *drm_get_tv_subconnector_name(int val); | |
1131 | extern const char *drm_get_tv_select_name(int val); | |
ea39f835 | 1132 | extern void drm_fb_release(struct drm_file *file_priv); |
f453ba04 | 1133 | extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group); |
ad222799 | 1134 | extern void drm_mode_group_destroy(struct drm_mode_group *group); |
2390cd11 | 1135 | extern void drm_reinit_primary_mode_group(struct drm_device *dev); |
fbff4690 | 1136 | extern bool drm_probe_ddc(struct i2c_adapter *adapter); |
f453ba04 DA |
1137 | extern struct edid *drm_get_edid(struct drm_connector *connector, |
1138 | struct i2c_adapter *adapter); | |
51f8da59 | 1139 | extern struct edid *drm_edid_duplicate(const struct edid *edid); |
f453ba04 | 1140 | extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
f453ba04 | 1141 | extern void drm_mode_config_init(struct drm_device *dev); |
eb033556 | 1142 | extern void drm_mode_config_reset(struct drm_device *dev); |
f453ba04 | 1143 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
55310008 | 1144 | |
43aba7eb DA |
1145 | extern int drm_mode_connector_set_path_property(struct drm_connector *connector, |
1146 | char *path); | |
f453ba04 DA |
1147 | extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
1148 | struct edid *edid); | |
5ea22f24 RC |
1149 | |
1150 | static inline bool drm_property_type_is(struct drm_property *property, | |
1151 | uint32_t type) | |
1152 | { | |
1153 | /* instanceof for props.. handles extended type vs original types: */ | |
1154 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) | |
1155 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; | |
1156 | return property->flags & type; | |
1157 | } | |
1158 | ||
1159 | static inline bool drm_property_type_valid(struct drm_property *property) | |
1160 | { | |
1161 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) | |
1162 | return !(property->flags & DRM_MODE_PROP_LEGACY_TYPE); | |
1163 | return !!(property->flags & DRM_MODE_PROP_LEGACY_TYPE); | |
1164 | } | |
1165 | ||
c543188a PZ |
1166 | extern int drm_object_property_set_value(struct drm_mode_object *obj, |
1167 | struct drm_property *property, | |
1168 | uint64_t val); | |
1169 | extern int drm_object_property_get_value(struct drm_mode_object *obj, | |
1170 | struct drm_property *property, | |
1171 | uint64_t *value); | |
f453ba04 DA |
1172 | extern int drm_framebuffer_init(struct drm_device *dev, |
1173 | struct drm_framebuffer *fb, | |
1174 | const struct drm_framebuffer_funcs *funcs); | |
786b99ed DV |
1175 | extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
1176 | uint32_t id); | |
f7eff60e RC |
1177 | extern void drm_framebuffer_unreference(struct drm_framebuffer *fb); |
1178 | extern void drm_framebuffer_reference(struct drm_framebuffer *fb); | |
1179 | extern void drm_framebuffer_remove(struct drm_framebuffer *fb); | |
f453ba04 | 1180 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); |
36206361 | 1181 | extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); |
f453ba04 | 1182 | |
c543188a PZ |
1183 | extern void drm_object_attach_property(struct drm_mode_object *obj, |
1184 | struct drm_property *property, | |
1185 | uint64_t init_val); | |
f453ba04 DA |
1186 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
1187 | const char *name, int num_values); | |
4a67d391 SH |
1188 | extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
1189 | const char *name, | |
49e27545 RC |
1190 | const struct drm_prop_enum_list *props, |
1191 | int num_values); | |
1192 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, | |
1193 | int flags, const char *name, | |
4a67d391 | 1194 | const struct drm_prop_enum_list *props, |
7689ffb3 VS |
1195 | int num_props, |
1196 | uint64_t supported_bits); | |
d9bc3c02 SH |
1197 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
1198 | const char *name, | |
1199 | uint64_t min, uint64_t max); | |
ebc44cf3 RC |
1200 | struct drm_property *drm_property_create_signed_range(struct drm_device *dev, |
1201 | int flags, const char *name, | |
1202 | int64_t min, int64_t max); | |
98f75de4 RC |
1203 | struct drm_property *drm_property_create_object(struct drm_device *dev, |
1204 | int flags, const char *name, uint32_t type); | |
f453ba04 DA |
1205 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); |
1206 | extern int drm_property_add_enum(struct drm_property *property, int index, | |
1207 | uint64_t value, const char *name); | |
1208 | extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); | |
1209 | extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats, | |
1210 | char *formats[]); | |
1211 | extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); | |
ff587e45 | 1212 | extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); |
884840aa | 1213 | extern int drm_mode_create_dirty_info_property(struct drm_device *dev); |
f453ba04 DA |
1214 | |
1215 | extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, | |
1216 | struct drm_encoder *encoder); | |
4cae5b84 | 1217 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
f453ba04 | 1218 | int gamma_size); |
7a9c9060 DV |
1219 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
1220 | uint32_t id, uint32_t type); | |
98f75de4 | 1221 | |
f453ba04 DA |
1222 | /* IOCTLs */ |
1223 | extern int drm_mode_getresources(struct drm_device *dev, | |
1224 | void *data, struct drm_file *file_priv); | |
8cf5c917 JB |
1225 | extern int drm_mode_getplane_res(struct drm_device *dev, void *data, |
1226 | struct drm_file *file_priv); | |
f453ba04 DA |
1227 | extern int drm_mode_getcrtc(struct drm_device *dev, |
1228 | void *data, struct drm_file *file_priv); | |
1229 | extern int drm_mode_getconnector(struct drm_device *dev, | |
1230 | void *data, struct drm_file *file_priv); | |
2d13b679 | 1231 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
f453ba04 DA |
1232 | extern int drm_mode_setcrtc(struct drm_device *dev, |
1233 | void *data, struct drm_file *file_priv); | |
8cf5c917 JB |
1234 | extern int drm_mode_getplane(struct drm_device *dev, |
1235 | void *data, struct drm_file *file_priv); | |
1236 | extern int drm_mode_setplane(struct drm_device *dev, | |
1237 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
1238 | extern int drm_mode_cursor_ioctl(struct drm_device *dev, |
1239 | void *data, struct drm_file *file_priv); | |
4c813d4d DA |
1240 | extern int drm_mode_cursor2_ioctl(struct drm_device *dev, |
1241 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
1242 | extern int drm_mode_addfb(struct drm_device *dev, |
1243 | void *data, struct drm_file *file_priv); | |
308e5bcb JB |
1244 | extern int drm_mode_addfb2(struct drm_device *dev, |
1245 | void *data, struct drm_file *file_priv); | |
1246 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); | |
f453ba04 DA |
1247 | extern int drm_mode_rmfb(struct drm_device *dev, |
1248 | void *data, struct drm_file *file_priv); | |
1249 | extern int drm_mode_getfb(struct drm_device *dev, | |
1250 | void *data, struct drm_file *file_priv); | |
884840aa JB |
1251 | extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
1252 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
1253 | |
1254 | extern int drm_mode_getproperty_ioctl(struct drm_device *dev, | |
1255 | void *data, struct drm_file *file_priv); | |
1256 | extern int drm_mode_getblob_ioctl(struct drm_device *dev, | |
1257 | void *data, struct drm_file *file_priv); | |
1258 | extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev, | |
1259 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
1260 | extern int drm_mode_getencoder(struct drm_device *dev, |
1261 | void *data, struct drm_file *file_priv); | |
1262 | extern int drm_mode_gamma_get_ioctl(struct drm_device *dev, | |
1263 | void *data, struct drm_file *file_priv); | |
1264 | extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, | |
1265 | void *data, struct drm_file *file_priv); | |
18316c8c | 1266 | extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match); |
0967e6a5 | 1267 | extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); |
f23c20c8 | 1268 | extern bool drm_detect_hdmi_monitor(struct edid *edid); |
8fe9790d | 1269 | extern bool drm_detect_monitor_audio(struct edid *edid); |
b1edd6a6 | 1270 | extern bool drm_rgb_quant_range_selectable(struct edid *edid); |
d91d8a3f KH |
1271 | extern int drm_mode_page_flip_ioctl(struct drm_device *dev, |
1272 | void *data, struct drm_file *file_priv); | |
f0fda0a4 ZY |
1273 | extern int drm_add_modes_noedid(struct drm_connector *connector, |
1274 | int hdisplay, int vdisplay); | |
3cf70daf GH |
1275 | extern void drm_set_preferred_mode(struct drm_connector *connector, |
1276 | int hpref, int vpref); | |
3c537889 | 1277 | |
051963d4 | 1278 | extern int drm_edid_header_is_valid(const u8 *raw_edid); |
0b2443ed | 1279 | extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid); |
3c537889 | 1280 | extern bool drm_edid_is_valid(struct edid *edid); |
1d42bbc8 | 1281 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
f6e252ba AJ |
1282 | int hsize, int vsize, int fresh, |
1283 | bool rb); | |
ff72145b DA |
1284 | |
1285 | extern int drm_mode_create_dumb_ioctl(struct drm_device *dev, | |
1286 | void *data, struct drm_file *file_priv); | |
1287 | extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev, | |
1288 | void *data, struct drm_file *file_priv); | |
1289 | extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, | |
1290 | void *data, struct drm_file *file_priv); | |
c543188a PZ |
1291 | extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, |
1292 | struct drm_file *file_priv); | |
1293 | extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, | |
1294 | struct drm_file *file_priv); | |
3a5f87c2 TW |
1295 | extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
1296 | struct drm_property *property, | |
1297 | uint64_t value); | |
248dbc23 DA |
1298 | |
1299 | extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, | |
1300 | int *bpp); | |
141670e9 | 1301 | extern int drm_format_num_planes(uint32_t format); |
5a86bd55 | 1302 | extern int drm_format_plane_cpp(uint32_t format, int plane); |
01b68b04 VS |
1303 | extern int drm_format_horz_chroma_subsampling(uint32_t format); |
1304 | extern int drm_format_vert_chroma_subsampling(uint32_t format); | |
d20d3174 | 1305 | extern const char *drm_get_format_name(uint32_t format); |
c1df5f3c VS |
1306 | extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, |
1307 | unsigned int supported_rotations); | |
3c9855f6 VS |
1308 | extern unsigned int drm_rotation_simplify(unsigned int rotation, |
1309 | unsigned int supported_rotations); | |
141670e9 | 1310 | |
96f60e37 | 1311 | /* Helpers */ |
a2b34e22 RC |
1312 | |
1313 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, | |
1314 | uint32_t id) | |
1315 | { | |
1316 | struct drm_mode_object *mo; | |
1317 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE); | |
1318 | return mo ? obj_to_plane(mo) : NULL; | |
1319 | } | |
1320 | ||
96f60e37 RK |
1321 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
1322 | uint32_t id) | |
1323 | { | |
1324 | struct drm_mode_object *mo; | |
1325 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); | |
1326 | return mo ? obj_to_crtc(mo) : NULL; | |
1327 | } | |
1328 | ||
1329 | static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, | |
1330 | uint32_t id) | |
1331 | { | |
1332 | struct drm_mode_object *mo; | |
1333 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER); | |
1334 | return mo ? obj_to_encoder(mo) : NULL; | |
1335 | } | |
1336 | ||
a2b34e22 RC |
1337 | static inline struct drm_connector *drm_connector_find(struct drm_device *dev, |
1338 | uint32_t id) | |
1339 | { | |
1340 | struct drm_mode_object *mo; | |
1341 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); | |
1342 | return mo ? obj_to_connector(mo) : NULL; | |
1343 | } | |
1344 | ||
1345 | static inline struct drm_property *drm_property_find(struct drm_device *dev, | |
1346 | uint32_t id) | |
1347 | { | |
1348 | struct drm_mode_object *mo; | |
1349 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY); | |
1350 | return mo ? obj_to_property(mo) : NULL; | |
1351 | } | |
1352 | ||
1353 | static inline struct drm_property_blob * | |
1354 | drm_property_blob_find(struct drm_device *dev, uint32_t id) | |
1355 | { | |
1356 | struct drm_mode_object *mo; | |
1357 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_BLOB); | |
1358 | return mo ? obj_to_blob(mo) : NULL; | |
1359 | } | |
1360 | ||
e27dde3e MR |
1361 | /* Plane list iterator for legacy (overlay only) planes. */ |
1362 | #define drm_for_each_legacy_plane(plane, planelist) \ | |
1363 | list_for_each_entry(plane, planelist, head) \ | |
1364 | if (plane->type == DRM_PLANE_TYPE_OVERLAY) | |
1365 | ||
f453ba04 | 1366 | #endif /* __DRM_CRTC_H__ */ |