NV50: basic fbcon + misc fixes
[platform/upstream/libdrm.git] / linux-core / drm_crtc.h
1 /*
2  * Copyright © 2006 Keith Packard
3  * Copyright © 2007 Intel Corporation
4  *   Jesse Barnes <jesse.barnes@intel.com>
5  */
6 #ifndef __DRM_CRTC_H__
7 #define __DRM_CRTC_H__
8
9 #include <linux/i2c.h>
10 #include <linux/spinlock.h>
11 #include <linux/types.h>
12 #include <linux/idr.h>
13
14 #include <linux/fb.h>
15
16 struct drm_device;
17 struct drm_mode_set;
18 struct drm_framebuffer;
19
20
21 #define DRM_MODE_OBJECT_CRTC 0xcccccccc
22 #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
23 #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
24 #define DRM_MODE_OBJECT_MODE 0xdededede
25 #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
26 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
27 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
28
29 struct drm_mode_object {
30         uint32_t id;
31         uint32_t type;
32 };
33
34 /*
35  * Note on terminology:  here, for brevity and convenience, we refer to connector
36  * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
37  * DVI, etc.  And 'screen' refers to the whole of the visible display, which
38  * may span multiple monitors (and therefore multiple CRTC and connector
39  * structures).
40  */
41
42 enum drm_mode_status {
43     MODE_OK     = 0,    /* Mode OK */
44     MODE_HSYNC,         /* hsync out of range */
45     MODE_VSYNC,         /* vsync out of range */
46     MODE_H_ILLEGAL,     /* mode has illegal horizontal timings */
47     MODE_V_ILLEGAL,     /* mode has illegal horizontal timings */
48     MODE_BAD_WIDTH,     /* requires an unsupported linepitch */
49     MODE_NOMODE,        /* no mode with a maching name */
50     MODE_NO_INTERLACE,  /* interlaced mode not supported */
51     MODE_NO_DBLESCAN,   /* doublescan mode not supported */
52     MODE_NO_VSCAN,      /* multiscan mode not supported */
53     MODE_MEM,           /* insufficient video memory */
54     MODE_VIRTUAL_X,     /* mode width too large for specified virtual size */
55     MODE_VIRTUAL_Y,     /* mode height too large for specified virtual size */
56     MODE_MEM_VIRT,      /* insufficient video memory given virtual size */
57     MODE_NOCLOCK,       /* no fixed clock available */
58     MODE_CLOCK_HIGH,    /* clock required is too high */
59     MODE_CLOCK_LOW,     /* clock required is too low */
60     MODE_CLOCK_RANGE,   /* clock/mode isn't in a ClockRange */
61     MODE_BAD_HVALUE,    /* horizontal timing was out of range */
62     MODE_BAD_VVALUE,    /* vertical timing was out of range */
63     MODE_BAD_VSCAN,     /* VScan value out of range */
64     MODE_HSYNC_NARROW,  /* horizontal sync too narrow */
65     MODE_HSYNC_WIDE,    /* horizontal sync too wide */
66     MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
67     MODE_HBLANK_WIDE,   /* horizontal blanking too wide */
68     MODE_VSYNC_NARROW,  /* vertical sync too narrow */
69     MODE_VSYNC_WIDE,    /* vertical sync too wide */
70     MODE_VBLANK_NARROW, /* vertical blanking too narrow */
71     MODE_VBLANK_WIDE,   /* vertical blanking too wide */
72     MODE_PANEL,         /* exceeds panel dimensions */
73     MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
74     MODE_ONE_WIDTH,     /* only one width is supported */
75     MODE_ONE_HEIGHT,    /* only one height is supported */
76     MODE_ONE_SIZE,      /* only one resolution is supported */
77     MODE_NO_REDUCED,    /* monitor doesn't accept reduced blanking */
78     MODE_UNVERIFIED = -3, /* mode needs to reverified */
79     MODE_BAD = -2,      /* unspecified reason */
80     MODE_ERROR  = -1    /* error condition */
81 };
82
83 #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
84                                     DRM_MODE_TYPE_CRTC_C)
85
86 #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
87         .name = nm, .status = 0, .type = (t), .clock = (c), \
88         .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
89         .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
90         .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
91         .vscan = (vs), .flags = (f), .vrefresh = 0
92
93 struct drm_display_mode {
94         /* Header */
95         struct list_head head;
96         struct drm_mode_object base;
97
98         char name[DRM_DISPLAY_MODE_LEN];
99
100         int connector_count;
101         enum drm_mode_status status;
102         int type;
103
104         /* Proposed mode values */
105         int clock;
106         int hdisplay;
107         int hsync_start;
108         int hsync_end;
109         int htotal;
110         int hskew;
111         int vdisplay;
112         int vsync_start;
113         int vsync_end;
114         int vtotal;
115         int vscan;
116         unsigned int flags;
117
118         /* Addressable image size (may be 0 for projectors, etc.) */
119         int width_mm;
120         int height_mm;
121
122         /* Actual mode we give to hw */
123         int clock_index;
124         int synth_clock;
125         int crtc_hdisplay;
126         int crtc_hblank_start;
127         int crtc_hblank_end;
128         int crtc_hsync_start;
129         int crtc_hsync_end;
130         int crtc_htotal;
131         int crtc_hskew;
132         int crtc_vdisplay;
133         int crtc_vblank_start;
134         int crtc_vblank_end;
135         int crtc_vsync_start;
136         int crtc_vsync_end;
137         int crtc_vtotal;
138         int crtc_hadjusted;
139         int crtc_vadjusted;
140
141         /* Driver private mode info */
142         int private_size;
143         int *private;
144         int private_flags;
145
146         int vrefresh;
147         float hsync;
148 };
149
150 /* Video mode flags */
151 #define V_PHSYNC        (1<<0)
152 #define V_NHSYNC        (1<<1)
153 #define V_PVSYNC        (1<<2)
154 #define V_NVSYNC        (1<<3)
155 #define V_INTERLACE     (1<<4)
156 #define V_DBLSCAN       (1<<5)
157 #define V_CSYNC         (1<<6)
158 #define V_PCSYNC        (1<<7)
159 #define V_NCSYNC        (1<<8)
160 #define V_HSKEW         (1<<9) /* hskew provided */
161 #define V_BCAST         (1<<10)
162 #define V_PIXMUX        (1<<11)
163 #define V_DBLCLK        (1<<12)
164 #define V_CLKDIV2       (1<<13)
165
166 #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
167
168 #define DPMSModeOn 0
169 #define DPMSModeStandby 1
170 #define DPMSModeSuspend 2
171 #define DPMSModeOff 3
172
173 #define DRM_MODE_CONNECTOR_Unknown 0
174 #define DRM_MODE_CONNECTOR_VGA 1
175 #define DRM_MODE_CONNECTOR_DVII 2
176 #define DRM_MODE_CONNECTOR_DVID 3
177 #define DRM_MODE_CONNECTOR_DVIA 4
178 #define DRM_MODE_CONNECTOR_Composite 5
179 #define DRM_MODE_CONNECTOR_SVIDEO 6
180 #define DRM_MODE_CONNECTOR_LVDS 7
181 #define DRM_MODE_CONNECTOR_Component 8
182 #define DRM_MODE_CONNECTOR_9PinDIN 9
183 #define DRM_MODE_CONNECTOR_DisplayPort 10
184 #define DRM_MODE_CONNECTOR_HDMIA 11
185 #define DRM_MODE_CONNECTOR_HDMIB 12
186
187 enum drm_connector_status {
188         connector_status_connected = 1,
189         connector_status_disconnected = 2,
190         connector_status_unknown = 3,
191 };
192
193 enum subpixel_order {
194         SubPixelUnknown = 0,
195         SubPixelHorizontalRGB,
196         SubPixelHorizontalBGR,
197         SubPixelVerticalRGB,
198         SubPixelVerticalBGR,
199         SubPixelNone,
200 };
201
202
203 /*
204  * Describes a given display (e.g. CRT or flat panel) and its limitations.
205  */
206 struct drm_display_info {
207         char name[DRM_DISPLAY_INFO_LEN];
208         /* Input info */
209         bool serration_vsync;
210         bool sync_on_green;
211         bool composite_sync;
212         bool separate_syncs;
213         bool blank_to_black;
214         unsigned char video_level;
215         bool digital;
216         /* Physical size */
217         unsigned int width_mm;
218         unsigned int height_mm;
219
220         /* Display parameters */
221         unsigned char gamma; /* FIXME: storage format */
222         bool gtf_supported;
223         bool standard_color;
224         enum {
225                 monochrome = 0,
226                 rgb,
227                 other,
228                 unknown,
229         } display_type;
230         bool active_off_supported;
231         bool suspend_supported;
232         bool standby_supported;
233
234         /* Color info FIXME: storage format */
235         unsigned short redx, redy;
236         unsigned short greenx, greeny;
237         unsigned short bluex, bluey;
238         unsigned short whitex, whitey;
239
240         /* Clock limits FIXME: storage format */
241         unsigned int min_vfreq, max_vfreq;
242         unsigned int min_hfreq, max_hfreq;
243         unsigned int pixel_clock;
244
245         /* White point indices FIXME: storage format */
246         unsigned int wpx1, wpy1;
247         unsigned int wpgamma1;
248         unsigned int wpx2, wpy2;
249         unsigned int wpgamma2;
250
251         enum subpixel_order subpixel_order;
252
253         char *raw_edid; /* if any */
254 };
255
256 struct drm_framebuffer_funcs {
257         void (*destroy)(struct drm_framebuffer *framebuffer);
258 };
259
260 struct drm_framebuffer {
261         struct drm_device *dev;
262         struct list_head head;
263         struct drm_mode_object base;
264         const struct drm_framebuffer_funcs *funcs;
265         unsigned int pitch;
266         unsigned int width;
267         unsigned int height;
268         /* depth can be 15 or 16 */
269         unsigned int depth;
270         int bits_per_pixel;
271         int flags;
272         void *fbdev;
273         u32 pseudo_palette[17];
274         struct list_head filp_head;
275         uint32_t mm_handle;
276 };
277
278 struct drm_property_blob {
279         struct drm_mode_object base;
280         struct list_head head;
281         unsigned int length;
282         void *data;
283 };
284
285 struct drm_property_enum {
286         uint64_t value;
287         struct list_head head;
288         char name[DRM_PROP_NAME_LEN];
289 };
290
291 struct drm_property {
292         struct list_head head;
293         struct drm_mode_object base;
294         uint32_t flags;
295         char name[DRM_PROP_NAME_LEN];
296         uint32_t num_values;
297         uint64_t *values;
298
299         struct list_head enum_blob_list;
300 };
301
302 struct drm_crtc;
303 struct drm_connector;
304 struct drm_encoder;
305
306 /**
307  * drm_crtc_funcs - control CRTCs for a given device
308  * @dpms: control display power levels
309  * @save: save CRTC state
310  * @resore: restore CRTC state
311  * @lock: lock the CRTC
312  * @unlock: unlock the CRTC
313  * @shadow_allocate: allocate shadow pixmap
314  * @shadow_create: create shadow pixmap for rotation support
315  * @shadow_destroy: free shadow pixmap
316  * @mode_fixup: fixup proposed mode
317  * @mode_set: set the desired mode on the CRTC
318  * @gamma_set: specify color ramp for CRTC
319  * @destroy: deinit and free object.
320  *
321  * The drm_crtc_funcs structure is the central CRTC management structure
322  * in the DRM.  Each CRTC controls one or more connectors (note that the name
323  * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
324  * connectors, not just CRTs).
325  *
326  * Each driver is responsible for filling out this structure at startup time,
327  * in addition to providing other modesetting features, like i2c and DDC
328  * bus accessors.
329  */
330 struct drm_crtc_funcs {
331         /* Save CRTC state */
332         void (*save)(struct drm_crtc *crtc); /* suspend? */
333         /* Restore CRTC state */
334         void (*restore)(struct drm_crtc *crtc); /* resume? */
335
336         /* cursor controls */
337         int (*cursor_set)(struct drm_crtc *crtc, uint32_t buffer_handle,
338                           uint32_t width, uint32_t height);
339         int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
340
341         /* Set gamma on the CRTC */
342         void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
343                           uint32_t size);
344         /* Object destroy routine */
345         void (*destroy)(struct drm_crtc *crtc);
346
347         int (*set_config)(struct drm_mode_set *set);
348 };
349
350 /**
351  * drm_crtc - central CRTC control structure
352  * @enabled: is this CRTC enabled?
353  * @x: x position on screen
354  * @y: y position on screen
355  * @desired_mode: new desired mode
356  * @desired_x: desired x for desired_mode
357  * @desired_y: desired y for desired_mode
358  * @funcs: CRTC control functions
359  *
360  * Each CRTC may have one or more connectors associated with it.  This structure
361  * allows the CRTC to be controlled.
362  */
363 struct drm_crtc {
364         struct drm_device *dev;
365         struct list_head head;
366
367         struct drm_mode_object base;
368
369         /* framebuffer the connector is currently bound to */
370         struct drm_framebuffer *fb;
371
372         bool enabled;
373
374         struct drm_display_mode mode;
375
376         int x, y;
377         struct drm_display_mode *desired_mode;
378         int desired_x, desired_y;
379         const struct drm_crtc_funcs *funcs;
380
381         /* CRTC gamma size for reporting to userspace */
382         uint32_t gamma_size;
383         uint16_t *gamma_store;
384
385         /* if you are using the helper */
386         void *helper_private;
387 };
388
389
390 /**
391  * drm_connector_funcs - control connectors on a given device
392  * @dpms: set power state (see drm_crtc_funcs above)
393  * @save: save connector state
394  * @restore: restore connector state
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
402  *
403  * Each CRTC may have one or more connectors attached to it.  The functions
404  * below allow the core DRM code to control connectors, enumerate available modes,
405  * etc.
406  */
407 struct drm_connector_funcs {
408         void (*dpms)(struct drm_connector *connector, int mode);
409         void (*save)(struct drm_connector *connector);
410         void (*restore)(struct drm_connector *connector);
411         enum drm_connector_status (*detect)(struct drm_connector *connector);
412         void (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
413         bool (*set_property)(struct drm_connector *connector, struct drm_property *property,
414                              uint64_t val);
415         void (*destroy)(struct drm_connector *connector);
416 };
417
418 struct drm_encoder_funcs {
419         void (*destroy)(struct drm_encoder *encoder);
420 };
421
422 #define DRM_CONNECTOR_MAX_UMODES 16
423 #define DRM_CONNECTOR_MAX_PROPERTY 16
424 #define DRM_CONNECTOR_LEN 32
425 #define DRM_CONNECTOR_MAX_ENCODER 2
426
427 /**
428  * drm_encoder - central DRM encoder structure 
429  */
430 struct drm_encoder {
431         struct drm_device *dev;
432         struct list_head head;
433
434         struct drm_mode_object base;
435         int encoder_type;
436         uint32_t possible_crtcs;
437         uint32_t possible_clones;
438
439         struct drm_crtc *crtc;
440         const struct drm_encoder_funcs *funcs;
441         void *helper_private;
442 };
443
444 /**
445  * drm_connector - central DRM connector control structure
446  * @crtc: CRTC this connector is currently connected to, NULL if none
447  * @interlace_allowed: can this connector handle interlaced modes?
448  * @doublescan_allowed: can this connector handle doublescan?
449  * @available_modes: modes available on this connector (from get_modes() + user)
450  * @initial_x: initial x position for this connector
451  * @initial_y: initial y position for this connector
452  * @status: connector connected?
453  * @funcs: connector control functions
454  *
455  * Each connector may be connected to one or more CRTCs, or may be clonable by
456  * another connector if they can share a CRTC.  Each connector also has a specific
457  * position in the broader display (referred to as a 'screen' though it could
458  * span multiple monitors).
459  */
460 struct drm_connector {
461         struct drm_device *dev;
462         struct device kdev;
463         struct device_attribute *attr;
464         struct list_head head;
465
466         struct drm_mode_object base;
467
468         int connector_type;
469         int connector_type_id;
470         bool interlace_allowed;
471         bool doublescan_allowed;
472         struct list_head modes; /* list of modes on this connector */
473
474         int initial_x, initial_y;
475         enum drm_connector_status status;
476
477         /* these are modes added by probing with DDC or the BIOS */
478         struct list_head probed_modes;
479         
480         struct drm_display_info display_info;
481         const struct drm_connector_funcs *funcs;
482
483         struct list_head user_modes;
484         struct drm_property_blob *edid_blob_ptr;
485         u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
486         uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
487
488         void *helper_private;
489
490         uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
491         uint32_t force_encoder_id;
492         struct drm_encoder *encoder; /* currently active encoder */
493 };
494
495 /**
496  * struct drm_mode_set
497  *
498  * Represents a single crtc the connectors that it drives with what mode
499  * and from which framebuffer it scans out from.
500  *
501  * This is used to set modes.
502  */
503 struct drm_mode_set {
504         struct list_head head;
505
506         struct drm_framebuffer *fb;
507         struct drm_crtc *crtc;
508         struct drm_display_mode *mode;
509
510         uint32_t x;
511         uint32_t y;
512
513         struct drm_connector **connectors;
514         size_t num_connectors;
515 };
516
517 /**
518  * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
519  * @resize: adjust CRTCs as necessary for the proposed layout
520  *
521  * Currently only a resize hook is available.  DRM will call back into the
522  * driver with a new screen width and height.  If the driver can't support
523  * the proposed size, it can return false.  Otherwise it should adjust
524  * the CRTC<->connector mappings as needed and update its view of the screen.
525  */
526 struct drm_mode_config_funcs {
527         int (*resize_fb)(struct drm_device *dev, struct drm_file *file_priv, struct drm_framebuffer *fb, struct drm_mode_fb_cmd *mode_cmd);
528         struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
529         int (*fb_changed)(struct drm_device *dev);
530 };
531
532 struct drm_mode_group {
533         uint32_t num_crtcs;
534         uint32_t num_encoders;
535         uint32_t num_connectors;
536
537         /* list of object IDs for this group */
538         uint32_t *id_list;
539 };
540
541 /**
542  * drm_mode_config - Mode configuration control structure
543  *
544  */
545 struct drm_mode_config {
546         struct mutex mutex; /* protects configuration and IDR */
547         struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
548         /* this is limited to one for now */
549         int num_fb;
550         struct list_head fb_list;
551         int num_connector;
552         struct list_head connector_list;
553         int num_encoder;
554         struct list_head encoder_list;
555
556         int num_crtc;
557         struct list_head crtc_list;
558
559         struct list_head property_list;
560
561         /* in-kernel framebuffers - hung of filp_head in drm_framebuffer */
562         struct list_head fb_kernel_list;
563
564         /* currently in use generation id */
565         int current_generation;
566
567         int min_width, min_height;
568         int max_width, max_height;
569         struct drm_mode_config_funcs *funcs;
570         unsigned long fb_base;
571
572         /* pointers to standard properties */
573         struct list_head property_blob_list;
574         struct drm_property *edid_property;
575         struct drm_property *dpms_property;
576
577         /* TV properties */
578         struct drm_property *tv_mode_property;
579         struct drm_property *tv_left_margin_property;
580         struct drm_property *tv_right_margin_property;
581         struct drm_property *tv_top_margin_property;
582         struct drm_property *tv_bottom_margin_property;
583
584         /* hotplug */
585         uint32_t hotplug_counter;
586 };
587
588 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
589 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
590 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
591 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
592 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
593 #define obj_to_property(x) container_of(x, struct drm_property, base)
594 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
595
596
597 extern void drm_crtc_init(struct drm_device *dev,
598                           struct drm_crtc *crtc,
599                           const struct drm_crtc_funcs *funcs);
600 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
601
602 extern void drm_connector_init(struct drm_device *dev,
603                             struct drm_connector *connector,
604                             const struct drm_connector_funcs *funcs,
605                             int connector_type);
606
607 extern void drm_connector_cleanup(struct drm_connector *connector);
608
609 extern void drm_encoder_init(struct drm_device *dev,
610                              struct drm_encoder *encoder,
611                              const struct drm_encoder_funcs *funcs,
612                              int encoder_type);
613
614 extern void drm_encoder_cleanup(struct drm_encoder *encoder);
615
616 extern char *drm_get_connector_name(struct drm_connector *connector);
617 extern char *drm_get_dpms_name(int val);
618 extern void drm_fb_release(struct file *filp);
619 extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
620 extern struct edid *drm_get_edid(struct drm_connector *connector,
621                                  struct i2c_adapter *adapter);
622 extern unsigned char *drm_do_probe_ddc_edid(struct i2c_adapter *adapter);
623 extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
624 extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
625 extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
626 extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
627                                                    struct drm_display_mode *mode);
628 extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
629 extern void drm_mode_config_init(struct drm_device *dev);
630 extern void drm_mode_config_cleanup(struct drm_device *dev);
631 extern void drm_mode_set_name(struct drm_display_mode *mode);
632 extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
633
634 /* for us by fb module */
635 extern int drm_mode_attachmode_crtc(struct drm_device *dev,
636                                     struct drm_crtc *crtc,
637                                     struct drm_display_mode *mode);
638 extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
639
640 extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
641 extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
642 extern void drm_mode_list_concat(struct list_head *head,
643                                  struct list_head *new);
644 extern void drm_mode_validate_size(struct drm_device *dev,
645                                    struct list_head *mode_list,
646                                    int maxX, int maxY, int maxPitch);
647 extern void drm_mode_prune_invalid(struct drm_device *dev,
648                                    struct list_head *mode_list, bool verbose);
649 extern void drm_mode_sort(struct list_head *mode_list);
650 extern int drm_mode_vrefresh(struct drm_display_mode *mode);
651 extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
652                                   int adjust_flags);
653 extern void drm_mode_connector_list_update(struct drm_connector *connector);
654 extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
655                                                 struct edid *edid);
656 extern int drm_connector_property_set_value(struct drm_connector *connector,
657                                          struct drm_property *property,
658                                          uint64_t value);
659 extern int drm_connector_property_get_value(struct drm_connector *connector,
660                                          struct drm_property *property,
661                                          uint64_t *value);
662 extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
663 extern void drm_framebuffer_set_object(struct drm_device *dev,
664                                        unsigned long handle);
665 extern struct drm_framebuffer *drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
666                                                     const struct drm_framebuffer_funcs *funcs);
667 extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
668 extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
669 extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
670 extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
671 extern bool drm_crtc_in_use(struct drm_crtc *crtc);
672
673 extern int drm_connector_attach_property(struct drm_connector *connector,
674                                       struct drm_property *property, uint64_t init_val);
675 extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
676                                                 const char *name, int num_values);
677 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
678 extern int drm_property_add_enum(struct drm_property *property, int index, 
679                                  uint64_t value, const char *name);
680 extern bool drm_create_tv_properties(struct drm_device *dev, int num_formats,
681                                      char *formats[]);
682 extern char *drm_get_encoder_name(struct drm_encoder *encoder);
683
684 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
685                                              struct drm_encoder *encoder);
686 extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
687                                            struct drm_encoder *encoder);
688 extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
689                                          int gamma_size);
690 /* IOCTLs */
691 extern int drm_mode_getresources(struct drm_device *dev,
692                                  void *data, struct drm_file *file_priv);
693
694 extern int drm_mode_getcrtc(struct drm_device *dev,
695                             void *data, struct drm_file *file_priv);
696 extern int drm_mode_getconnector(struct drm_device *dev,
697                               void *data, struct drm_file *file_priv);
698 extern int drm_mode_setcrtc(struct drm_device *dev,
699                             void *data, struct drm_file *file_priv);
700 extern int drm_mode_cursor_ioctl(struct drm_device *dev,
701                                 void *data, struct drm_file *file_priv);
702 extern int drm_mode_addfb(struct drm_device *dev,
703                           void *data, struct drm_file *file_priv);
704 extern int drm_mode_rmfb(struct drm_device *dev,
705                          void *data, struct drm_file *file_priv);
706 extern int drm_mode_getfb(struct drm_device *dev,
707                           void *data, struct drm_file *file_priv);
708 extern int drm_mode_addmode_ioctl(struct drm_device *dev,
709                                   void *data, struct drm_file *file_priv);
710 extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
711                                  void *data, struct drm_file *file_priv);
712 extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
713                                      void *data, struct drm_file *file_priv);
714 extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
715                                      void *data, struct drm_file *file_priv);
716
717 extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
718                                       void *data, struct drm_file *file_priv);
719 extern int drm_mode_getblob_ioctl(struct drm_device *dev,
720                                   void *data, struct drm_file *file_priv);
721 extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
722                                               void *data, struct drm_file *file_priv);
723 extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
724                                   void *data, struct drm_file *file_priv);
725 extern int drm_mode_replacefb(struct drm_device *dev,
726                               void *data, struct drm_file *file_priv);
727 extern int drm_mode_getencoder(struct drm_device *dev,
728                                void *data, struct drm_file *file_priv);
729 extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
730                                     void *data, struct drm_file *file_priv);
731 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
732                                     void *data, struct drm_file *file_priv);
733 #endif /* __DRM_CRTC_H__ */
734