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