]>
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 DA |
32 | #include <linux/fb.h> |
33 | ||
308e5bcb JB |
34 | #include <drm/drm_fourcc.h> |
35 | ||
f453ba04 DA |
36 | struct drm_device; |
37 | struct drm_mode_set; | |
38 | struct drm_framebuffer; | |
39 | ||
40 | ||
41 | #define DRM_MODE_OBJECT_CRTC 0xcccccccc | |
42 | #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 | |
43 | #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0 | |
44 | #define DRM_MODE_OBJECT_MODE 0xdededede | |
45 | #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0 | |
46 | #define DRM_MODE_OBJECT_FB 0xfbfbfbfb | |
47 | #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb | |
8cf5c917 | 48 | #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee |
f453ba04 DA |
49 | |
50 | struct drm_mode_object { | |
51 | uint32_t id; | |
52 | uint32_t type; | |
53 | }; | |
54 | ||
55 | /* | |
56 | * Note on terminology: here, for brevity and convenience, we refer to connector | |
57 | * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, | |
58 | * DVI, etc. And 'screen' refers to the whole of the visible display, which | |
59 | * may span multiple monitors (and therefore multiple CRTC and connector | |
60 | * structures). | |
61 | */ | |
62 | ||
63 | enum drm_mode_status { | |
64 | MODE_OK = 0, /* Mode OK */ | |
65 | MODE_HSYNC, /* hsync out of range */ | |
66 | MODE_VSYNC, /* vsync out of range */ | |
67 | MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ | |
68 | MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ | |
69 | MODE_BAD_WIDTH, /* requires an unsupported linepitch */ | |
25985edc | 70 | MODE_NOMODE, /* no mode with a matching name */ |
f453ba04 DA |
71 | MODE_NO_INTERLACE, /* interlaced mode not supported */ |
72 | MODE_NO_DBLESCAN, /* doublescan mode not supported */ | |
73 | MODE_NO_VSCAN, /* multiscan mode not supported */ | |
74 | MODE_MEM, /* insufficient video memory */ | |
75 | MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ | |
76 | MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ | |
77 | MODE_MEM_VIRT, /* insufficient video memory given virtual size */ | |
78 | MODE_NOCLOCK, /* no fixed clock available */ | |
79 | MODE_CLOCK_HIGH, /* clock required is too high */ | |
80 | MODE_CLOCK_LOW, /* clock required is too low */ | |
81 | MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ | |
82 | MODE_BAD_HVALUE, /* horizontal timing was out of range */ | |
83 | MODE_BAD_VVALUE, /* vertical timing was out of range */ | |
84 | MODE_BAD_VSCAN, /* VScan value out of range */ | |
85 | MODE_HSYNC_NARROW, /* horizontal sync too narrow */ | |
86 | MODE_HSYNC_WIDE, /* horizontal sync too wide */ | |
87 | MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ | |
88 | MODE_HBLANK_WIDE, /* horizontal blanking too wide */ | |
89 | MODE_VSYNC_NARROW, /* vertical sync too narrow */ | |
90 | MODE_VSYNC_WIDE, /* vertical sync too wide */ | |
91 | MODE_VBLANK_NARROW, /* vertical blanking too narrow */ | |
92 | MODE_VBLANK_WIDE, /* vertical blanking too wide */ | |
93 | MODE_PANEL, /* exceeds panel dimensions */ | |
94 | MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ | |
95 | MODE_ONE_WIDTH, /* only one width is supported */ | |
96 | MODE_ONE_HEIGHT, /* only one height is supported */ | |
97 | MODE_ONE_SIZE, /* only one resolution is supported */ | |
98 | MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ | |
99 | MODE_UNVERIFIED = -3, /* mode needs to reverified */ | |
100 | MODE_BAD = -2, /* unspecified reason */ | |
101 | MODE_ERROR = -1 /* error condition */ | |
102 | }; | |
103 | ||
104 | #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \ | |
105 | DRM_MODE_TYPE_CRTC_C) | |
106 | ||
107 | #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \ | |
108 | .name = nm, .status = 0, .type = (t), .clock = (c), \ | |
109 | .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \ | |
110 | .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \ | |
111 | .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \ | |
112 | .vscan = (vs), .flags = (f), .vrefresh = 0 | |
113 | ||
114 | #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */ | |
115 | ||
116 | struct drm_display_mode { | |
117 | /* Header */ | |
118 | struct list_head head; | |
119 | struct drm_mode_object base; | |
120 | ||
121 | char name[DRM_DISPLAY_MODE_LEN]; | |
122 | ||
f453ba04 DA |
123 | enum drm_mode_status status; |
124 | int type; | |
125 | ||
126 | /* Proposed mode values */ | |
7ac96a9c | 127 | int clock; /* in kHz */ |
f453ba04 DA |
128 | int hdisplay; |
129 | int hsync_start; | |
130 | int hsync_end; | |
131 | int htotal; | |
132 | int hskew; | |
133 | int vdisplay; | |
134 | int vsync_start; | |
135 | int vsync_end; | |
136 | int vtotal; | |
137 | int vscan; | |
138 | unsigned int flags; | |
139 | ||
140 | /* Addressable image size (may be 0 for projectors, etc.) */ | |
141 | int width_mm; | |
142 | int height_mm; | |
143 | ||
144 | /* Actual mode we give to hw */ | |
145 | int clock_index; | |
146 | int synth_clock; | |
147 | int crtc_hdisplay; | |
148 | int crtc_hblank_start; | |
149 | int crtc_hblank_end; | |
150 | int crtc_hsync_start; | |
151 | int crtc_hsync_end; | |
152 | int crtc_htotal; | |
153 | int crtc_hskew; | |
154 | int crtc_vdisplay; | |
155 | int crtc_vblank_start; | |
156 | int crtc_vblank_end; | |
157 | int crtc_vsync_start; | |
158 | int crtc_vsync_end; | |
159 | int crtc_vtotal; | |
160 | int crtc_hadjusted; | |
161 | int crtc_vadjusted; | |
162 | ||
163 | /* Driver private mode info */ | |
164 | int private_size; | |
165 | int *private; | |
166 | int private_flags; | |
167 | ||
7ac96a9c AJ |
168 | int vrefresh; /* in Hz */ |
169 | int hsync; /* in kHz */ | |
f453ba04 DA |
170 | }; |
171 | ||
172 | enum drm_connector_status { | |
173 | connector_status_connected = 1, | |
174 | connector_status_disconnected = 2, | |
175 | connector_status_unknown = 3, | |
176 | }; | |
177 | ||
178 | enum subpixel_order { | |
179 | SubPixelUnknown = 0, | |
180 | SubPixelHorizontalRGB, | |
181 | SubPixelHorizontalBGR, | |
182 | SubPixelVerticalRGB, | |
183 | SubPixelVerticalBGR, | |
184 | SubPixelNone, | |
185 | }; | |
186 | ||
da05a5a7 JB |
187 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
188 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) | |
189 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) | |
f453ba04 DA |
190 | /* |
191 | * Describes a given display (e.g. CRT or flat panel) and its limitations. | |
192 | */ | |
193 | struct drm_display_info { | |
194 | char name[DRM_DISPLAY_INFO_LEN]; | |
fb439640 | 195 | |
f453ba04 DA |
196 | /* Physical size */ |
197 | unsigned int width_mm; | |
198 | unsigned int height_mm; | |
199 | ||
f453ba04 DA |
200 | /* Clock limits FIXME: storage format */ |
201 | unsigned int min_vfreq, max_vfreq; | |
202 | unsigned int min_hfreq, max_hfreq; | |
203 | unsigned int pixel_clock; | |
3b11228b | 204 | unsigned int bpc; |
f453ba04 | 205 | |
f453ba04 | 206 | enum subpixel_order subpixel_order; |
da05a5a7 | 207 | u32 color_formats; |
f453ba04 | 208 | |
ebec9a7b JB |
209 | u8 cea_rev; |
210 | ||
f453ba04 DA |
211 | char *raw_edid; /* if any */ |
212 | }; | |
213 | ||
214 | struct drm_framebuffer_funcs { | |
215 | void (*destroy)(struct drm_framebuffer *framebuffer); | |
216 | int (*create_handle)(struct drm_framebuffer *fb, | |
217 | struct drm_file *file_priv, | |
218 | unsigned int *handle); | |
884840aa JB |
219 | /** |
220 | * Optinal callback for the dirty fb ioctl. | |
221 | * | |
222 | * Userspace can notify the driver via this callback | |
223 | * that a area of the framebuffer has changed and should | |
224 | * be flushed to the display hardware. | |
225 | * | |
226 | * See documentation in drm_mode.h for the struct | |
227 | * drm_mode_fb_dirty_cmd for more information as all | |
228 | * the semantics and arguments have a one to one mapping | |
229 | * on this function. | |
230 | */ | |
02b00162 TH |
231 | int (*dirty)(struct drm_framebuffer *framebuffer, |
232 | struct drm_file *file_priv, unsigned flags, | |
884840aa JB |
233 | unsigned color, struct drm_clip_rect *clips, |
234 | unsigned num_clips); | |
f453ba04 DA |
235 | }; |
236 | ||
237 | struct drm_framebuffer { | |
238 | struct drm_device *dev; | |
239 | struct list_head head; | |
240 | struct drm_mode_object base; | |
241 | const struct drm_framebuffer_funcs *funcs; | |
242 | unsigned int pitch; | |
243 | unsigned int width; | |
244 | unsigned int height; | |
245 | /* depth can be 15 or 16 */ | |
246 | unsigned int depth; | |
247 | int bits_per_pixel; | |
248 | int flags; | |
308e5bcb | 249 | uint32_t pixel_format; /* fourcc format */ |
f453ba04 | 250 | struct list_head filp_head; |
785b93ef DA |
251 | /* if you are using the helper */ |
252 | void *helper_private; | |
f453ba04 DA |
253 | }; |
254 | ||
255 | struct drm_property_blob { | |
256 | struct drm_mode_object base; | |
257 | struct list_head head; | |
258 | unsigned int length; | |
259 | void *data; | |
260 | }; | |
261 | ||
262 | struct drm_property_enum { | |
263 | uint64_t value; | |
264 | struct list_head head; | |
265 | char name[DRM_PROP_NAME_LEN]; | |
266 | }; | |
267 | ||
268 | struct drm_property { | |
269 | struct list_head head; | |
270 | struct drm_mode_object base; | |
271 | uint32_t flags; | |
272 | char name[DRM_PROP_NAME_LEN]; | |
273 | uint32_t num_values; | |
274 | uint64_t *values; | |
275 | ||
276 | struct list_head enum_blob_list; | |
277 | }; | |
278 | ||
279 | struct drm_crtc; | |
280 | struct drm_connector; | |
281 | struct drm_encoder; | |
d91d8a3f | 282 | struct drm_pending_vblank_event; |
8cf5c917 | 283 | struct drm_plane; |
f453ba04 DA |
284 | |
285 | /** | |
286 | * drm_crtc_funcs - control CRTCs for a given device | |
eb033556 | 287 | * @reset: reset CRTC after state has been invalidate (e.g. resume) |
f453ba04 DA |
288 | * @dpms: control display power levels |
289 | * @save: save CRTC state | |
290 | * @resore: restore CRTC state | |
291 | * @lock: lock the CRTC | |
292 | * @unlock: unlock the CRTC | |
293 | * @shadow_allocate: allocate shadow pixmap | |
294 | * @shadow_create: create shadow pixmap for rotation support | |
295 | * @shadow_destroy: free shadow pixmap | |
296 | * @mode_fixup: fixup proposed mode | |
297 | * @mode_set: set the desired mode on the CRTC | |
298 | * @gamma_set: specify color ramp for CRTC | |
299 | * @destroy: deinit and free object. | |
300 | * | |
301 | * The drm_crtc_funcs structure is the central CRTC management structure | |
302 | * in the DRM. Each CRTC controls one or more connectors (note that the name | |
303 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. | |
304 | * connectors, not just CRTs). | |
305 | * | |
306 | * Each driver is responsible for filling out this structure at startup time, | |
307 | * in addition to providing other modesetting features, like i2c and DDC | |
308 | * bus accessors. | |
309 | */ | |
310 | struct drm_crtc_funcs { | |
311 | /* Save CRTC state */ | |
312 | void (*save)(struct drm_crtc *crtc); /* suspend? */ | |
313 | /* Restore CRTC state */ | |
314 | void (*restore)(struct drm_crtc *crtc); /* resume? */ | |
eb033556 CW |
315 | /* Reset CRTC state */ |
316 | void (*reset)(struct drm_crtc *crtc); | |
f453ba04 DA |
317 | |
318 | /* cursor controls */ | |
319 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, | |
320 | uint32_t handle, uint32_t width, uint32_t height); | |
321 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); | |
322 | ||
323 | /* Set gamma on the CRTC */ | |
324 | void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, | |
7203425a | 325 | uint32_t start, uint32_t size); |
f453ba04 DA |
326 | /* Object destroy routine */ |
327 | void (*destroy)(struct drm_crtc *crtc); | |
328 | ||
329 | int (*set_config)(struct drm_mode_set *set); | |
d91d8a3f KH |
330 | |
331 | /* | |
332 | * Flip to the given framebuffer. This implements the page | |
25985edc | 333 | * flip ioctl described in drm_mode.h, specifically, the |
d91d8a3f KH |
334 | * implementation must return immediately and block all |
335 | * rendering to the current fb until the flip has completed. | |
336 | * If userspace set the event flag in the ioctl, the event | |
337 | * argument will point to an event to send back when the flip | |
338 | * completes, otherwise it will be NULL. | |
339 | */ | |
340 | int (*page_flip)(struct drm_crtc *crtc, | |
341 | struct drm_framebuffer *fb, | |
342 | struct drm_pending_vblank_event *event); | |
f453ba04 DA |
343 | }; |
344 | ||
345 | /** | |
346 | * drm_crtc - central CRTC control structure | |
347 | * @enabled: is this CRTC enabled? | |
348 | * @x: x position on screen | |
349 | * @y: y position on screen | |
f453ba04 DA |
350 | * @funcs: CRTC control functions |
351 | * | |
352 | * Each CRTC may have one or more connectors associated with it. This structure | |
353 | * allows the CRTC to be controlled. | |
354 | */ | |
355 | struct drm_crtc { | |
356 | struct drm_device *dev; | |
357 | struct list_head head; | |
358 | ||
359 | struct drm_mode_object base; | |
360 | ||
361 | /* framebuffer the connector is currently bound to */ | |
362 | struct drm_framebuffer *fb; | |
363 | ||
364 | bool enabled; | |
365 | ||
27641c3f | 366 | /* Requested mode from modesetting. */ |
f453ba04 DA |
367 | struct drm_display_mode mode; |
368 | ||
27641c3f MK |
369 | /* Programmed mode in hw, after adjustments for encoders, |
370 | * crtc, panel scaling etc. Needed for timestamping etc. | |
371 | */ | |
372 | struct drm_display_mode hwmode; | |
373 | ||
f453ba04 | 374 | int x, y; |
f453ba04 DA |
375 | const struct drm_crtc_funcs *funcs; |
376 | ||
377 | /* CRTC gamma size for reporting to userspace */ | |
378 | uint32_t gamma_size; | |
379 | uint16_t *gamma_store; | |
380 | ||
27641c3f MK |
381 | /* Constants needed for precise vblank and swap timestamping. */ |
382 | s64 framedur_ns, linedur_ns, pixeldur_ns; | |
383 | ||
f453ba04 DA |
384 | /* if you are using the helper */ |
385 | void *helper_private; | |
386 | }; | |
387 | ||
388 | ||
389 | /** | |
390 | * drm_connector_funcs - control connectors on a given device | |
391 | * @dpms: set power state (see drm_crtc_funcs above) | |
392 | * @save: save connector state | |
393 | * @restore: restore connector state | |
eb033556 | 394 | * @reset: reset connector after state has been invalidate (e.g. resume) |
f453ba04 DA |
395 | * @mode_valid: is this mode valid on the given connector? |
396 | * @mode_fixup: try to fixup proposed mode for this connector | |
397 | * @mode_set: set this mode | |
398 | * @detect: is this connector active? | |
399 | * @get_modes: get mode list for this connector | |
400 | * @set_property: property for this connector may need update | |
401 | * @destroy: make object go away | |
d50ba256 | 402 | * @force: notify the driver the connector is forced on |
f453ba04 DA |
403 | * |
404 | * Each CRTC may have one or more connectors attached to it. The functions | |
405 | * below allow the core DRM code to control connectors, enumerate available modes, | |
406 | * etc. | |
407 | */ | |
408 | struct drm_connector_funcs { | |
409 | void (*dpms)(struct drm_connector *connector, int mode); | |
410 | void (*save)(struct drm_connector *connector); | |
411 | void (*restore)(struct drm_connector *connector); | |
eb033556 | 412 | void (*reset)(struct drm_connector *connector); |
930a9e28 CW |
413 | |
414 | /* Check to see if anything is attached to the connector. | |
415 | * @force is set to false whilst polling, true when checking the | |
416 | * connector due to user request. @force can be used by the driver | |
417 | * to avoid expensive, destructive operations during automated | |
418 | * probing. | |
419 | */ | |
7b334fcb | 420 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
930a9e28 | 421 | bool force); |
40a518d9 | 422 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); |
f453ba04 DA |
423 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
424 | uint64_t val); | |
425 | void (*destroy)(struct drm_connector *connector); | |
d50ba256 | 426 | void (*force)(struct drm_connector *connector); |
f453ba04 DA |
427 | }; |
428 | ||
429 | struct drm_encoder_funcs { | |
eb033556 | 430 | void (*reset)(struct drm_encoder *encoder); |
f453ba04 DA |
431 | void (*destroy)(struct drm_encoder *encoder); |
432 | }; | |
433 | ||
434 | #define DRM_CONNECTOR_MAX_UMODES 16 | |
435 | #define DRM_CONNECTOR_MAX_PROPERTY 16 | |
436 | #define DRM_CONNECTOR_LEN 32 | |
437 | #define DRM_CONNECTOR_MAX_ENCODER 2 | |
438 | ||
439 | /** | |
440 | * drm_encoder - central DRM encoder structure | |
441 | */ | |
442 | struct drm_encoder { | |
443 | struct drm_device *dev; | |
444 | struct list_head head; | |
445 | ||
446 | struct drm_mode_object base; | |
447 | int encoder_type; | |
448 | uint32_t possible_crtcs; | |
449 | uint32_t possible_clones; | |
450 | ||
451 | struct drm_crtc *crtc; | |
452 | const struct drm_encoder_funcs *funcs; | |
453 | void *helper_private; | |
454 | }; | |
455 | ||
d50ba256 DA |
456 | enum drm_connector_force { |
457 | DRM_FORCE_UNSPECIFIED, | |
458 | DRM_FORCE_OFF, | |
459 | DRM_FORCE_ON, /* force on analog part normally */ | |
460 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ | |
461 | }; | |
462 | ||
eb1f8e4f DA |
463 | /* should we poll this connector for connects and disconnects */ |
464 | /* hot plug detectable */ | |
465 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) | |
466 | /* poll for connections */ | |
467 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) | |
468 | /* can cleanly poll for disconnections without flickering the screen */ | |
469 | /* DACs should rarely do this without a lot of testing */ | |
470 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) | |
471 | ||
76adaa34 WF |
472 | #define MAX_ELD_BYTES 128 |
473 | ||
f453ba04 DA |
474 | /** |
475 | * drm_connector - central DRM connector control structure | |
476 | * @crtc: CRTC this connector is currently connected to, NULL if none | |
477 | * @interlace_allowed: can this connector handle interlaced modes? | |
478 | * @doublescan_allowed: can this connector handle doublescan? | |
479 | * @available_modes: modes available on this connector (from get_modes() + user) | |
480 | * @initial_x: initial x position for this connector | |
481 | * @initial_y: initial y position for this connector | |
482 | * @status: connector connected? | |
483 | * @funcs: connector control functions | |
484 | * | |
485 | * Each connector may be connected to one or more CRTCs, or may be clonable by | |
486 | * another connector if they can share a CRTC. Each connector also has a specific | |
487 | * position in the broader display (referred to as a 'screen' though it could | |
488 | * span multiple monitors). | |
489 | */ | |
490 | struct drm_connector { | |
491 | struct drm_device *dev; | |
492 | struct device kdev; | |
493 | struct device_attribute *attr; | |
494 | struct list_head head; | |
495 | ||
496 | struct drm_mode_object base; | |
497 | ||
498 | int connector_type; | |
499 | int connector_type_id; | |
500 | bool interlace_allowed; | |
501 | bool doublescan_allowed; | |
502 | struct list_head modes; /* list of modes on this connector */ | |
503 | ||
504 | int initial_x, initial_y; | |
505 | enum drm_connector_status status; | |
506 | ||
507 | /* these are modes added by probing with DDC or the BIOS */ | |
508 | struct list_head probed_modes; | |
509 | ||
510 | struct drm_display_info display_info; | |
511 | const struct drm_connector_funcs *funcs; | |
512 | ||
513 | struct list_head user_modes; | |
514 | struct drm_property_blob *edid_blob_ptr; | |
515 | u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY]; | |
516 | uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY]; | |
517 | ||
eb1f8e4f DA |
518 | uint8_t polled; /* DRM_CONNECTOR_POLL_* */ |
519 | ||
c9fb15f6 KP |
520 | /* requested DPMS state */ |
521 | int dpms; | |
522 | ||
f453ba04 DA |
523 | void *helper_private; |
524 | ||
d50ba256 DA |
525 | /* forced on connector */ |
526 | enum drm_connector_force force; | |
f453ba04 DA |
527 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
528 | uint32_t force_encoder_id; | |
529 | struct drm_encoder *encoder; /* currently active encoder */ | |
4a9a8b71 | 530 | |
76adaa34 WF |
531 | /* EDID bits */ |
532 | uint8_t eld[MAX_ELD_BYTES]; | |
533 | bool dvi_dual; | |
534 | int max_tmds_clock; /* in MHz */ | |
535 | bool latency_present[2]; | |
536 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ | |
537 | int audio_latency[2]; | |
4a9a8b71 | 538 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ |
f453ba04 DA |
539 | }; |
540 | ||
8cf5c917 JB |
541 | /** |
542 | * drm_plane_funcs - driver plane control functions | |
543 | * @update_plane: update the plane configuration | |
544 | * @disable_plane: shut down the plane | |
545 | * @destroy: clean up plane resources | |
546 | */ | |
547 | struct drm_plane_funcs { | |
548 | int (*update_plane)(struct drm_plane *plane, | |
549 | struct drm_crtc *crtc, struct drm_framebuffer *fb, | |
550 | int crtc_x, int crtc_y, | |
551 | unsigned int crtc_w, unsigned int crtc_h, | |
552 | uint32_t src_x, uint32_t src_y, | |
553 | uint32_t src_w, uint32_t src_h); | |
554 | int (*disable_plane)(struct drm_plane *plane); | |
555 | void (*destroy)(struct drm_plane *plane); | |
556 | }; | |
557 | ||
558 | /** | |
559 | * drm_plane - central DRM plane control structure | |
560 | * @dev: DRM device this plane belongs to | |
561 | * @head: for list management | |
562 | * @base: base mode object | |
563 | * @possible_crtcs: pipes this plane can be bound to | |
564 | * @format_types: array of formats supported by this plane | |
565 | * @format_count: number of formats supported | |
566 | * @crtc: currently bound CRTC | |
567 | * @fb: currently bound fb | |
568 | * @gamma_size: size of gamma table | |
569 | * @gamma_store: gamma correction table | |
570 | * @enabled: enabled flag | |
571 | * @funcs: helper functions | |
572 | * @helper_private: storage for drver layer | |
573 | */ | |
574 | struct drm_plane { | |
575 | struct drm_device *dev; | |
576 | struct list_head head; | |
577 | ||
578 | struct drm_mode_object base; | |
579 | ||
580 | uint32_t possible_crtcs; | |
581 | uint32_t *format_types; | |
582 | uint32_t format_count; | |
583 | ||
584 | struct drm_crtc *crtc; | |
585 | struct drm_framebuffer *fb; | |
586 | ||
587 | /* CRTC gamma size for reporting to userspace */ | |
588 | uint32_t gamma_size; | |
589 | uint16_t *gamma_store; | |
590 | ||
591 | bool enabled; | |
592 | ||
593 | const struct drm_plane_funcs *funcs; | |
594 | void *helper_private; | |
595 | }; | |
596 | ||
f453ba04 DA |
597 | /** |
598 | * struct drm_mode_set | |
599 | * | |
600 | * Represents a single crtc the connectors that it drives with what mode | |
601 | * and from which framebuffer it scans out from. | |
602 | * | |
603 | * This is used to set modes. | |
604 | */ | |
605 | struct drm_mode_set { | |
606 | struct list_head head; | |
607 | ||
608 | struct drm_framebuffer *fb; | |
609 | struct drm_crtc *crtc; | |
610 | struct drm_display_mode *mode; | |
611 | ||
612 | uint32_t x; | |
613 | uint32_t y; | |
614 | ||
615 | struct drm_connector **connectors; | |
616 | size_t num_connectors; | |
617 | }; | |
618 | ||
619 | /** | |
620 | * struct drm_mode_config_funcs - configure CRTCs for a given screen layout | |
f453ba04 DA |
621 | */ |
622 | struct drm_mode_config_funcs { | |
308e5bcb | 623 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd); |
eb1f8e4f | 624 | void (*output_poll_changed)(struct drm_device *dev); |
f453ba04 DA |
625 | }; |
626 | ||
627 | struct drm_mode_group { | |
628 | uint32_t num_crtcs; | |
629 | uint32_t num_encoders; | |
630 | uint32_t num_connectors; | |
631 | ||
632 | /* list of object IDs for this group */ | |
633 | uint32_t *id_list; | |
634 | }; | |
635 | ||
636 | /** | |
637 | * drm_mode_config - Mode configuration control structure | |
638 | * | |
639 | */ | |
640 | struct drm_mode_config { | |
ad2563c2 JB |
641 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
642 | struct mutex idr_mutex; /* for IDR management */ | |
f453ba04 DA |
643 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
644 | /* this is limited to one for now */ | |
645 | int num_fb; | |
646 | struct list_head fb_list; | |
647 | int num_connector; | |
648 | struct list_head connector_list; | |
649 | int num_encoder; | |
650 | struct list_head encoder_list; | |
8cf5c917 JB |
651 | int num_plane; |
652 | struct list_head plane_list; | |
f453ba04 DA |
653 | |
654 | int num_crtc; | |
655 | struct list_head crtc_list; | |
656 | ||
657 | struct list_head property_list; | |
658 | ||
f453ba04 DA |
659 | int min_width, min_height; |
660 | int max_width, max_height; | |
661 | struct drm_mode_config_funcs *funcs; | |
d883f7f1 | 662 | resource_size_t fb_base; |
f453ba04 | 663 | |
eb1f8e4f DA |
664 | /* output poll support */ |
665 | bool poll_enabled; | |
991ea75c | 666 | struct delayed_work output_poll_work; |
eb1f8e4f | 667 | |
f453ba04 DA |
668 | /* pointers to standard properties */ |
669 | struct list_head property_blob_list; | |
670 | struct drm_property *edid_property; | |
671 | struct drm_property *dpms_property; | |
672 | ||
673 | /* DVI-I properties */ | |
674 | struct drm_property *dvi_i_subconnector_property; | |
675 | struct drm_property *dvi_i_select_subconnector_property; | |
676 | ||
677 | /* TV properties */ | |
678 | struct drm_property *tv_subconnector_property; | |
679 | struct drm_property *tv_select_subconnector_property; | |
680 | struct drm_property *tv_mode_property; | |
681 | struct drm_property *tv_left_margin_property; | |
682 | struct drm_property *tv_right_margin_property; | |
683 | struct drm_property *tv_top_margin_property; | |
684 | struct drm_property *tv_bottom_margin_property; | |
b6b7902e FJ |
685 | struct drm_property *tv_brightness_property; |
686 | struct drm_property *tv_contrast_property; | |
687 | struct drm_property *tv_flicker_reduction_property; | |
a75f0236 FJ |
688 | struct drm_property *tv_overscan_property; |
689 | struct drm_property *tv_saturation_property; | |
690 | struct drm_property *tv_hue_property; | |
f453ba04 DA |
691 | |
692 | /* Optional properties */ | |
693 | struct drm_property *scaling_mode_property; | |
694 | struct drm_property *dithering_mode_property; | |
884840aa | 695 | struct drm_property *dirty_info_property; |
f453ba04 DA |
696 | }; |
697 | ||
698 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) | |
699 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) | |
700 | #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) | |
701 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) | |
702 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) | |
703 | #define obj_to_property(x) container_of(x, struct drm_property, base) | |
704 | #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) | |
8cf5c917 | 705 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
f453ba04 DA |
706 | |
707 | ||
708 | extern void drm_crtc_init(struct drm_device *dev, | |
709 | struct drm_crtc *crtc, | |
710 | const struct drm_crtc_funcs *funcs); | |
711 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); | |
712 | ||
713 | extern void drm_connector_init(struct drm_device *dev, | |
714 | struct drm_connector *connector, | |
715 | const struct drm_connector_funcs *funcs, | |
716 | int connector_type); | |
717 | ||
718 | extern void drm_connector_cleanup(struct drm_connector *connector); | |
719 | ||
720 | extern void drm_encoder_init(struct drm_device *dev, | |
721 | struct drm_encoder *encoder, | |
722 | const struct drm_encoder_funcs *funcs, | |
723 | int encoder_type); | |
724 | ||
8cf5c917 JB |
725 | extern int drm_plane_init(struct drm_device *dev, |
726 | struct drm_plane *plane, | |
727 | unsigned long possible_crtcs, | |
728 | const struct drm_plane_funcs *funcs, | |
729 | uint32_t *formats, uint32_t format_count); | |
730 | extern void drm_plane_cleanup(struct drm_plane *plane); | |
731 | ||
f453ba04 DA |
732 | extern void drm_encoder_cleanup(struct drm_encoder *encoder); |
733 | ||
734 | extern char *drm_get_connector_name(struct drm_connector *connector); | |
735 | extern char *drm_get_dpms_name(int val); | |
736 | extern char *drm_get_dvi_i_subconnector_name(int val); | |
737 | extern char *drm_get_dvi_i_select_name(int val); | |
738 | extern char *drm_get_tv_subconnector_name(int val); | |
739 | extern char *drm_get_tv_select_name(int val); | |
ea39f835 | 740 | extern void drm_fb_release(struct drm_file *file_priv); |
f453ba04 DA |
741 | extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group); |
742 | extern struct edid *drm_get_edid(struct drm_connector *connector, | |
743 | struct i2c_adapter *adapter); | |
f453ba04 DA |
744 | extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
745 | extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); | |
746 | extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode); | |
747 | extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, | |
b1f559ec | 748 | const struct drm_display_mode *mode); |
f453ba04 DA |
749 | extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode); |
750 | extern void drm_mode_config_init(struct drm_device *dev); | |
eb033556 | 751 | extern void drm_mode_config_reset(struct drm_device *dev); |
f453ba04 DA |
752 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
753 | extern void drm_mode_set_name(struct drm_display_mode *mode); | |
754 | extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2); | |
755 | extern int drm_mode_width(struct drm_display_mode *mode); | |
756 | extern int drm_mode_height(struct drm_display_mode *mode); | |
757 | ||
758 | /* for us by fb module */ | |
759 | extern int drm_mode_attachmode_crtc(struct drm_device *dev, | |
760 | struct drm_crtc *crtc, | |
761 | struct drm_display_mode *mode); | |
762 | extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode); | |
763 | ||
764 | extern struct drm_display_mode *drm_mode_create(struct drm_device *dev); | |
765 | extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode); | |
766 | extern void drm_mode_list_concat(struct list_head *head, | |
767 | struct list_head *new); | |
768 | extern void drm_mode_validate_size(struct drm_device *dev, | |
769 | struct list_head *mode_list, | |
770 | int maxX, int maxY, int maxPitch); | |
771 | extern void drm_mode_prune_invalid(struct drm_device *dev, | |
772 | struct list_head *mode_list, bool verbose); | |
773 | extern void drm_mode_sort(struct list_head *mode_list); | |
b1f559ec CW |
774 | extern int drm_mode_hsync(const struct drm_display_mode *mode); |
775 | extern int drm_mode_vrefresh(const struct drm_display_mode *mode); | |
f453ba04 DA |
776 | extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, |
777 | int adjust_flags); | |
778 | extern void drm_mode_connector_list_update(struct drm_connector *connector); | |
779 | extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, | |
780 | struct edid *edid); | |
781 | extern int drm_connector_property_set_value(struct drm_connector *connector, | |
782 | struct drm_property *property, | |
783 | uint64_t value); | |
784 | extern int drm_connector_property_get_value(struct drm_connector *connector, | |
785 | struct drm_property *property, | |
786 | uint64_t *value); | |
787 | extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev); | |
788 | extern void drm_framebuffer_set_object(struct drm_device *dev, | |
789 | unsigned long handle); | |
790 | extern int drm_framebuffer_init(struct drm_device *dev, | |
791 | struct drm_framebuffer *fb, | |
792 | const struct drm_framebuffer_funcs *funcs); | |
793 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); | |
794 | extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc); | |
795 | extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); | |
796 | extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY); | |
797 | extern bool drm_crtc_in_use(struct drm_crtc *crtc); | |
798 | ||
799 | extern int drm_connector_attach_property(struct drm_connector *connector, | |
800 | struct drm_property *property, uint64_t init_val); | |
801 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, | |
802 | const char *name, int num_values); | |
803 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); | |
804 | extern int drm_property_add_enum(struct drm_property *property, int index, | |
805 | uint64_t value, const char *name); | |
806 | extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); | |
807 | extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats, | |
808 | char *formats[]); | |
809 | extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); | |
810 | extern int drm_mode_create_dithering_property(struct drm_device *dev); | |
884840aa | 811 | extern int drm_mode_create_dirty_info_property(struct drm_device *dev); |
f453ba04 DA |
812 | extern char *drm_get_encoder_name(struct drm_encoder *encoder); |
813 | ||
814 | extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, | |
815 | struct drm_encoder *encoder); | |
816 | extern void drm_mode_connector_detach_encoder(struct drm_connector *connector, | |
817 | struct drm_encoder *encoder); | |
818 | extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, | |
819 | int gamma_size); | |
7a9c9060 DV |
820 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
821 | uint32_t id, uint32_t type); | |
f453ba04 DA |
822 | /* IOCTLs */ |
823 | extern int drm_mode_getresources(struct drm_device *dev, | |
824 | void *data, struct drm_file *file_priv); | |
8cf5c917 JB |
825 | extern int drm_mode_getplane_res(struct drm_device *dev, void *data, |
826 | struct drm_file *file_priv); | |
f453ba04 DA |
827 | extern int drm_mode_getcrtc(struct drm_device *dev, |
828 | void *data, struct drm_file *file_priv); | |
829 | extern int drm_mode_getconnector(struct drm_device *dev, | |
830 | void *data, struct drm_file *file_priv); | |
831 | extern int drm_mode_setcrtc(struct drm_device *dev, | |
832 | void *data, struct drm_file *file_priv); | |
8cf5c917 JB |
833 | extern int drm_mode_getplane(struct drm_device *dev, |
834 | void *data, struct drm_file *file_priv); | |
835 | extern int drm_mode_setplane(struct drm_device *dev, | |
836 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
837 | extern int drm_mode_cursor_ioctl(struct drm_device *dev, |
838 | void *data, struct drm_file *file_priv); | |
839 | extern int drm_mode_addfb(struct drm_device *dev, | |
840 | void *data, struct drm_file *file_priv); | |
308e5bcb JB |
841 | extern int drm_mode_addfb2(struct drm_device *dev, |
842 | void *data, struct drm_file *file_priv); | |
843 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); | |
f453ba04 DA |
844 | extern int drm_mode_rmfb(struct drm_device *dev, |
845 | void *data, struct drm_file *file_priv); | |
846 | extern int drm_mode_getfb(struct drm_device *dev, | |
847 | void *data, struct drm_file *file_priv); | |
884840aa JB |
848 | extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
849 | void *data, struct drm_file *file_priv); | |
f453ba04 DA |
850 | extern int drm_mode_addmode_ioctl(struct drm_device *dev, |
851 | void *data, struct drm_file *file_priv); | |
852 | extern int drm_mode_rmmode_ioctl(struct drm_device *dev, | |
853 | void *data, struct drm_file *file_priv); | |
854 | extern int drm_mode_attachmode_ioctl(struct drm_device *dev, | |
855 | void *data, struct drm_file *file_priv); | |
856 | extern int drm_mode_detachmode_ioctl(struct drm_device *dev, | |
857 | void *data, struct drm_file *file_priv); | |
858 | ||
859 | extern int drm_mode_getproperty_ioctl(struct drm_device *dev, | |
860 | void *data, struct drm_file *file_priv); | |
861 | extern int drm_mode_getblob_ioctl(struct drm_device *dev, | |
862 | void *data, struct drm_file *file_priv); | |
863 | extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev, | |
864 | void *data, struct drm_file *file_priv); | |
865 | extern int drm_mode_hotplug_ioctl(struct drm_device *dev, | |
866 | void *data, struct drm_file *file_priv); | |
867 | extern int drm_mode_replacefb(struct drm_device *dev, | |
868 | void *data, struct drm_file *file_priv); | |
869 | extern int drm_mode_getencoder(struct drm_device *dev, | |
870 | void *data, struct drm_file *file_priv); | |
871 | extern int drm_mode_gamma_get_ioctl(struct drm_device *dev, | |
872 | void *data, struct drm_file *file_priv); | |
873 | extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, | |
874 | void *data, struct drm_file *file_priv); | |
eccaca28 | 875 | extern u8 *drm_find_cea_extension(struct edid *edid); |
f23c20c8 | 876 | extern bool drm_detect_hdmi_monitor(struct edid *edid); |
8fe9790d | 877 | extern bool drm_detect_monitor_audio(struct edid *edid); |
d91d8a3f KH |
878 | extern int drm_mode_page_flip_ioctl(struct drm_device *dev, |
879 | void *data, struct drm_file *file_priv); | |
d782c3f9 ZY |
880 | extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, |
881 | int hdisplay, int vdisplay, int vrefresh, | |
d50ba256 | 882 | bool reduced, bool interlaced, bool margins); |
26bbdada ZY |
883 | extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev, |
884 | int hdisplay, int vdisplay, int vrefresh, | |
885 | bool interlaced, int margins); | |
7a374350 AJ |
886 | extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev, |
887 | int hdisplay, int vdisplay, int vrefresh, | |
888 | bool interlaced, int margins, int GTF_M, | |
889 | int GTF_2C, int GTF_K, int GTF_2J); | |
f0fda0a4 ZY |
890 | extern int drm_add_modes_noedid(struct drm_connector *connector, |
891 | int hdisplay, int vdisplay); | |
3c537889 | 892 | |
051963d4 | 893 | extern int drm_edid_header_is_valid(const u8 *raw_edid); |
3c537889 | 894 | extern bool drm_edid_is_valid(struct edid *edid); |
1d42bbc8 DA |
895 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
896 | int hsize, int vsize, int fresh); | |
ff72145b DA |
897 | |
898 | extern int drm_mode_create_dumb_ioctl(struct drm_device *dev, | |
899 | void *data, struct drm_file *file_priv); | |
900 | extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev, | |
901 | void *data, struct drm_file *file_priv); | |
902 | extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, | |
903 | void *data, struct drm_file *file_priv); | |
248dbc23 DA |
904 | |
905 | extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, | |
906 | int *bpp); | |
f453ba04 | 907 | #endif /* __DRM_CRTC_H__ */ |