OSDN Git Service

radeon/drm: fixup ref counting in on fb objs
[android-x86/external-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 #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
94
95 struct drm_display_mode {
96         /* Header */
97         struct list_head head;
98         struct drm_mode_object base;
99
100         char name[DRM_DISPLAY_MODE_LEN];
101
102         int connector_count;
103         enum drm_mode_status status;
104         int type;
105
106         /* Proposed mode values */
107         int clock;
108         int hdisplay;
109         int hsync_start;
110         int hsync_end;
111         int htotal;
112         int hskew;
113         int vdisplay;
114         int vsync_start;
115         int vsync_end;
116         int vtotal;
117         int vscan;
118         unsigned int flags;
119
120         /* Addressable image size (may be 0 for projectors, etc.) */
121         int width_mm;
122         int height_mm;
123
124         /* Actual mode we give to hw */
125         int clock_index;
126         int synth_clock;
127         int crtc_hdisplay;
128         int crtc_hblank_start;
129         int crtc_hblank_end;
130         int crtc_hsync_start;
131         int crtc_hsync_end;
132         int crtc_htotal;
133         int crtc_hskew;
134         int crtc_vdisplay;
135         int crtc_vblank_start;
136         int crtc_vblank_end;
137         int crtc_vsync_start;
138         int crtc_vsync_end;
139         int crtc_vtotal;
140         int crtc_hadjusted;
141         int crtc_vadjusted;
142
143         /* Driver private mode info */
144         int private_size;
145         int *private;
146         int private_flags;
147
148         int vrefresh;
149         float hsync;
150 };
151
152 enum drm_connector_status {
153         connector_status_connected = 1,
154         connector_status_disconnected = 2,
155         connector_status_unknown = 3,
156 };
157
158 enum subpixel_order {
159         SubPixelUnknown = 0,
160         SubPixelHorizontalRGB,
161         SubPixelHorizontalBGR,
162         SubPixelVerticalRGB,
163         SubPixelVerticalBGR,
164         SubPixelNone,
165 };
166
167
168 /*
169  * Describes a given display (e.g. CRT or flat panel) and its limitations.
170  */
171 struct drm_display_info {
172         char name[DRM_DISPLAY_INFO_LEN];
173         /* Input info */
174         bool serration_vsync;
175         bool sync_on_green;
176         bool composite_sync;
177         bool separate_syncs;
178         bool blank_to_black;
179         unsigned char video_level;
180         bool digital;
181         /* Physical size */
182         unsigned int width_mm;
183         unsigned int height_mm;
184
185         /* Display parameters */
186         unsigned char gamma; /* FIXME: storage format */
187         bool gtf_supported;
188         bool standard_color;
189         enum {
190                 monochrome = 0,
191                 rgb,
192                 other,
193                 unknown,
194         } display_type;
195         bool active_off_supported;
196         bool suspend_supported;
197         bool standby_supported;
198
199         /* Color info FIXME: storage format */
200         unsigned short redx, redy;
201         unsigned short greenx, greeny;
202         unsigned short bluex, bluey;
203         unsigned short whitex, whitey;
204
205         /* Clock limits FIXME: storage format */
206         unsigned int min_vfreq, max_vfreq;
207         unsigned int min_hfreq, max_hfreq;
208         unsigned int pixel_clock;
209
210         /* White point indices FIXME: storage format */
211         unsigned int wpx1, wpy1;
212         unsigned int wpgamma1;
213         unsigned int wpx2, wpy2;
214         unsigned int wpgamma2;
215
216         enum subpixel_order subpixel_order;
217
218         char *raw_edid; /* if any */
219 };
220
221 struct drm_framebuffer_funcs {
222         void (*destroy)(struct drm_framebuffer *framebuffer);
223         int (*create_handle)(struct drm_framebuffer *fb,
224                              struct drm_file *file_priv,
225                              unsigned int *handle);
226 };
227
228 struct drm_framebuffer {
229         struct drm_device *dev;
230         struct list_head head;
231         struct drm_mode_object base;
232         const struct drm_framebuffer_funcs *funcs;
233         unsigned int pitch;
234         unsigned int width;
235         unsigned int height;
236         /* depth can be 15 or 16 */
237         unsigned int depth;
238         int bits_per_pixel;
239         int flags;
240         void *fbdev;
241         u32 pseudo_palette[17];
242         struct list_head filp_head;
243 };
244
245 struct drm_property_blob {
246         struct drm_mode_object base;
247         struct list_head head;
248         unsigned int length;
249         void *data;
250 };
251
252 struct drm_property_enum {
253         uint64_t value;
254         struct list_head head;
255         char name[DRM_PROP_NAME_LEN];
256 };
257
258 struct drm_property {
259         struct list_head head;
260         struct drm_mode_object base;
261         uint32_t flags;
262         char name[DRM_PROP_NAME_LEN];
263         uint32_t num_values;
264         uint64_t *values;
265
266         struct list_head enum_blob_list;
267 };
268
269 struct drm_crtc;
270 struct drm_connector;
271 struct drm_encoder;
272
273 /**
274  * drm_crtc_funcs - control CRTCs for a given device
275  * @dpms: control display power levels
276  * @save: save CRTC state
277  * @resore: restore CRTC state
278  * @lock: lock the CRTC
279  * @unlock: unlock the CRTC
280  * @shadow_allocate: allocate shadow pixmap
281  * @shadow_create: create shadow pixmap for rotation support
282  * @shadow_destroy: free shadow pixmap
283  * @mode_fixup: fixup proposed mode
284  * @mode_set: set the desired mode on the CRTC
285  * @gamma_set: specify color ramp for CRTC
286  * @destroy: deinit and free object.
287  *
288  * The drm_crtc_funcs structure is the central CRTC management structure
289  * in the DRM.  Each CRTC controls one or more connectors (note that the name
290  * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
291  * connectors, not just CRTs).
292  *
293  * Each driver is responsible for filling out this structure at startup time,
294  * in addition to providing other modesetting features, like i2c and DDC
295  * bus accessors.
296  */
297 struct drm_crtc_funcs {
298         /* Save CRTC state */
299         void (*save)(struct drm_crtc *crtc); /* suspend? */
300         /* Restore CRTC state */
301         void (*restore)(struct drm_crtc *crtc); /* resume? */
302
303         /* cursor controls */
304         int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
305                           uint32_t handle, uint32_t width, uint32_t height);
306         int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
307
308         /* Set gamma on the CRTC */
309         void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
310                           uint32_t size);
311         /* Object destroy routine */
312         void (*destroy)(struct drm_crtc *crtc);
313
314         int (*set_config)(struct drm_mode_set *set);
315 };
316
317 /**
318  * drm_crtc - central CRTC control structure
319  * @enabled: is this CRTC enabled?
320  * @x: x position on screen
321  * @y: y position on screen
322  * @desired_mode: new desired mode
323  * @desired_x: desired x for desired_mode
324  * @desired_y: desired y for desired_mode
325  * @funcs: CRTC control functions
326  *
327  * Each CRTC may have one or more connectors associated with it.  This structure
328  * allows the CRTC to be controlled.
329  */
330 struct drm_crtc {
331         struct drm_device *dev;
332         struct list_head head;
333
334         struct drm_mode_object base;
335
336         /* framebuffer the connector is currently bound to */
337         struct drm_framebuffer *fb;
338
339         bool enabled;
340
341         struct drm_display_mode mode;
342
343         int x, y;
344         struct drm_display_mode *desired_mode;
345         int desired_x, desired_y;
346         const struct drm_crtc_funcs *funcs;
347
348         /* CRTC gamma size for reporting to userspace */
349         uint32_t gamma_size;
350         uint16_t *gamma_store;
351
352         /* if you are using the helper */
353         void *helper_private;
354 };
355
356
357 /**
358  * drm_connector_funcs - control connectors on a given device
359  * @dpms: set power state (see drm_crtc_funcs above)
360  * @save: save connector state
361  * @restore: restore connector state
362  * @mode_valid: is this mode valid on the given connector?
363  * @mode_fixup: try to fixup proposed mode for this connector
364  * @mode_set: set this mode
365  * @detect: is this connector active?
366  * @get_modes: get mode list for this connector
367  * @set_property: property for this connector may need update
368  * @destroy: make object go away
369  *
370  * Each CRTC may have one or more connectors attached to it.  The functions
371  * below allow the core DRM code to control connectors, enumerate available modes,
372  * etc.
373  */
374 struct drm_connector_funcs {
375         void (*dpms)(struct drm_connector *connector, int mode);
376         void (*save)(struct drm_connector *connector);
377         void (*restore)(struct drm_connector *connector);
378         enum drm_connector_status (*detect)(struct drm_connector *connector);
379         void (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
380         int (*set_property)(struct drm_connector *connector, struct drm_property *property,
381                              uint64_t val);
382         void (*destroy)(struct drm_connector *connector);
383 };
384
385 struct drm_encoder_funcs {
386         void (*destroy)(struct drm_encoder *encoder);
387 };
388
389 #define DRM_CONNECTOR_MAX_UMODES 16
390 #define DRM_CONNECTOR_MAX_PROPERTY 16
391 #define DRM_CONNECTOR_LEN 32
392 #define DRM_CONNECTOR_MAX_ENCODER 2
393
394 /**
395  * drm_encoder - central DRM encoder structure 
396  */
397 struct drm_encoder {
398         struct drm_device *dev;
399         struct list_head head;
400
401         struct drm_mode_object base;
402         int encoder_type;
403         uint32_t possible_crtcs;
404         uint32_t possible_clones;
405
406         struct drm_crtc *crtc;
407         const struct drm_encoder_funcs *funcs;
408         void *helper_private;
409 };
410
411 /**
412  * drm_connector - central DRM connector control structure
413  * @crtc: CRTC this connector is currently connected to, NULL if none
414  * @interlace_allowed: can this connector handle interlaced modes?
415  * @doublescan_allowed: can this connector handle doublescan?
416  * @available_modes: modes available on this connector (from get_modes() + user)
417  * @initial_x: initial x position for this connector
418  * @initial_y: initial y position for this connector
419  * @status: connector connected?
420  * @funcs: connector control functions
421  *
422  * Each connector may be connected to one or more CRTCs, or may be clonable by
423  * another connector if they can share a CRTC.  Each connector also has a specific
424  * position in the broader display (referred to as a 'screen' though it could
425  * span multiple monitors).
426  */
427 struct drm_connector {
428         struct drm_device *dev;
429         struct device kdev;
430         struct device_attribute *attr;
431         struct list_head head;
432
433         struct drm_mode_object base;
434
435         int connector_type;
436         int connector_type_id;
437         bool interlace_allowed;
438         bool doublescan_allowed;
439         struct list_head modes; /* list of modes on this connector */
440
441         int initial_x, initial_y;
442         enum drm_connector_status status;
443
444         /* these are modes added by probing with DDC or the BIOS */
445         struct list_head probed_modes;
446         
447         struct drm_display_info display_info;
448         const struct drm_connector_funcs *funcs;
449
450         struct list_head user_modes;
451         struct drm_property_blob *edid_blob_ptr;
452         u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
453         uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
454
455         void *helper_private;
456
457         uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
458         uint32_t force_encoder_id;
459         struct drm_encoder *encoder; /* currently active encoder */
460 };
461
462 /**
463  * struct drm_mode_set
464  *
465  * Represents a single crtc the connectors that it drives with what mode
466  * and from which framebuffer it scans out from.
467  *
468  * This is used to set modes.
469  */
470 struct drm_mode_set {
471         struct list_head head;
472
473         struct drm_framebuffer *fb;
474         struct drm_crtc *crtc;
475         struct drm_display_mode *mode;
476
477         uint32_t x;
478         uint32_t y;
479
480         struct drm_connector **connectors;
481         size_t num_connectors;
482 };
483
484 /**
485  * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
486  * @resize: adjust CRTCs as necessary for the proposed layout
487  *
488  * Currently only a resize hook is available.  DRM will call back into the
489  * driver with a new screen width and height.  If the driver can't support
490  * the proposed size, it can return false.  Otherwise it should adjust
491  * the CRTC<->connector mappings as needed and update its view of the screen.
492  */
493 struct drm_mode_config_funcs {
494         int (*resize_fb)(struct drm_device *dev, struct drm_file *file_priv, struct drm_framebuffer *fb, struct drm_mode_fb_cmd *mode_cmd);
495         struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
496         int (*fb_changed)(struct drm_device *dev);
497 };
498
499 struct drm_mode_group {
500         uint32_t num_crtcs;
501         uint32_t num_encoders;
502         uint32_t num_connectors;
503
504         /* list of object IDs for this group */
505         uint32_t *id_list;
506 };
507
508 /**
509  * drm_mode_config - Mode configuration control structure
510  *
511  */
512 struct drm_mode_config {
513         struct mutex mutex; /* protects configuration and IDR */
514         struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
515         /* this is limited to one for now */
516         int num_fb;
517         struct list_head fb_list;
518         int num_connector;
519         struct list_head connector_list;
520         int num_encoder;
521         struct list_head encoder_list;
522
523         int num_crtc;
524         struct list_head crtc_list;
525
526         struct list_head property_list;
527
528         /* in-kernel framebuffers - hung of filp_head in drm_framebuffer */
529         struct list_head fb_kernel_list;
530
531         int min_width, min_height;
532         int max_width, max_height;
533         struct drm_mode_config_funcs *funcs;
534         unsigned long fb_base;
535
536         /* pointers to standard properties */
537         struct list_head property_blob_list;
538         struct drm_property *edid_property;
539         struct drm_property *dpms_property;
540
541         /* DVI-I properties */
542         struct drm_property *dvi_i_subconnector_property;
543         struct drm_property *dvi_i_select_subconnector_property;
544
545         /* TV properties */
546         struct drm_property *tv_subconnector_property;
547         struct drm_property *tv_select_subconnector_property;
548         struct drm_property *tv_mode_property;
549         struct drm_property *tv_left_margin_property;
550         struct drm_property *tv_right_margin_property;
551         struct drm_property *tv_top_margin_property;
552         struct drm_property *tv_bottom_margin_property;
553
554         /* Optional properties */
555         struct drm_property *scaling_mode_property;
556         struct drm_property *dithering_mode_property;
557
558         /* hotplug */
559         uint32_t hotplug_counter;
560 };
561
562 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
563 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
564 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
565 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
566 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
567 #define obj_to_property(x) container_of(x, struct drm_property, base)
568 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
569
570
571 extern void drm_crtc_init(struct drm_device *dev,
572                           struct drm_crtc *crtc,
573                           const struct drm_crtc_funcs *funcs);
574 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
575
576 extern void drm_connector_init(struct drm_device *dev,
577                             struct drm_connector *connector,
578                             const struct drm_connector_funcs *funcs,
579                             int connector_type);
580
581 extern void drm_connector_cleanup(struct drm_connector *connector);
582
583 extern void drm_encoder_init(struct drm_device *dev,
584                              struct drm_encoder *encoder,
585                              const struct drm_encoder_funcs *funcs,
586                              int encoder_type);
587
588 extern void drm_encoder_cleanup(struct drm_encoder *encoder);
589
590 extern char *drm_get_connector_name(struct drm_connector *connector);
591 extern char *drm_get_dpms_name(int val);
592 extern char *drm_get_select_subconnector_name(int val);
593 extern char *drm_get_subconnector_name(int val);
594 extern void drm_fb_release(struct file *filp);
595 extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
596 extern struct edid *drm_get_edid(struct drm_connector *connector,
597                                  struct i2c_adapter *adapter);
598 extern unsigned char *drm_do_probe_ddc_edid(struct i2c_adapter *adapter);
599 extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
600 extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
601 extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
602 extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
603                                                    struct drm_display_mode *mode);
604 extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
605 extern void drm_mode_config_init(struct drm_device *dev);
606 extern void drm_mode_config_cleanup(struct drm_device *dev);
607 extern void drm_mode_set_name(struct drm_display_mode *mode);
608 extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
609 extern int drm_mode_width(struct drm_display_mode *mode);
610 extern int drm_mode_height(struct drm_display_mode *mode);
611
612 /* for us by fb module */
613 extern int drm_mode_attachmode_crtc(struct drm_device *dev,
614                                     struct drm_crtc *crtc,
615                                     struct drm_display_mode *mode);
616 extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
617
618 extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
619 extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
620 extern void drm_mode_list_concat(struct list_head *head,
621                                  struct list_head *new);
622 extern void drm_mode_validate_size(struct drm_device *dev,
623                                    struct list_head *mode_list,
624                                    int maxX, int maxY, int maxPitch);
625 extern void drm_mode_prune_invalid(struct drm_device *dev,
626                                    struct list_head *mode_list, bool verbose);
627 extern void drm_mode_sort(struct list_head *mode_list);
628 extern int drm_mode_vrefresh(struct drm_display_mode *mode);
629 extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
630                                   int adjust_flags);
631 extern void drm_mode_connector_list_update(struct drm_connector *connector);
632 extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
633                                                 struct edid *edid);
634 extern int drm_connector_property_set_value(struct drm_connector *connector,
635                                          struct drm_property *property,
636                                          uint64_t value);
637 extern int drm_connector_property_get_value(struct drm_connector *connector,
638                                          struct drm_property *property,
639                                          uint64_t *value);
640 extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
641 extern void drm_framebuffer_set_object(struct drm_device *dev,
642                                        unsigned long handle);
643 extern struct drm_framebuffer *drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
644                                                     const struct drm_framebuffer_funcs *funcs);
645 extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
646 extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
647 extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
648 extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
649 extern bool drm_crtc_in_use(struct drm_crtc *crtc);
650
651 extern int drm_connector_attach_property(struct drm_connector *connector,
652                                       struct drm_property *property, uint64_t init_val);
653 extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
654                                                 const char *name, int num_values);
655 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
656 extern int drm_property_add_enum(struct drm_property *property, int index, 
657                                  uint64_t value, const char *name);
658 extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
659 extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
660                                      char *formats[]);
661 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
662 extern int drm_mode_create_dithering_property(struct drm_device *dev);
663 extern char *drm_get_encoder_name(struct drm_encoder *encoder);
664
665 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
666                                              struct drm_encoder *encoder);
667 extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
668                                            struct drm_encoder *encoder);
669 extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
670                                          int gamma_size);
671 extern void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type);
672 /* IOCTLs */
673 extern int drm_mode_getresources(struct drm_device *dev,
674                                  void *data, struct drm_file *file_priv);
675
676 extern int drm_mode_getcrtc(struct drm_device *dev,
677                             void *data, struct drm_file *file_priv);
678 extern int drm_mode_getconnector(struct drm_device *dev,
679                               void *data, struct drm_file *file_priv);
680 extern int drm_mode_setcrtc(struct drm_device *dev,
681                             void *data, struct drm_file *file_priv);
682 extern int drm_mode_cursor_ioctl(struct drm_device *dev,
683                                 void *data, struct drm_file *file_priv);
684 extern int drm_mode_addfb(struct drm_device *dev,
685                           void *data, struct drm_file *file_priv);
686 extern int drm_mode_rmfb(struct drm_device *dev,
687                          void *data, struct drm_file *file_priv);
688 extern int drm_mode_getfb(struct drm_device *dev,
689                           void *data, struct drm_file *file_priv);
690 extern int drm_mode_addmode_ioctl(struct drm_device *dev,
691                                   void *data, struct drm_file *file_priv);
692 extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
693                                  void *data, struct drm_file *file_priv);
694 extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
695                                      void *data, struct drm_file *file_priv);
696 extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
697                                      void *data, struct drm_file *file_priv);
698
699 extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
700                                       void *data, struct drm_file *file_priv);
701 extern int drm_mode_getblob_ioctl(struct drm_device *dev,
702                                   void *data, struct drm_file *file_priv);
703 extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
704                                               void *data, struct drm_file *file_priv);
705 extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
706                                   void *data, struct drm_file *file_priv);
707 extern int drm_mode_replacefb(struct drm_device *dev,
708                               void *data, struct drm_file *file_priv);
709 extern int drm_mode_getencoder(struct drm_device *dev,
710                                void *data, struct drm_file *file_priv);
711 extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
712                                     void *data, struct drm_file *file_priv);
713 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
714                                     void *data, struct drm_file *file_priv);
715 #endif /* __DRM_CRTC_H__ */
716