2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
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:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
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.
25 #ifndef __DRM_CRTC_H__
26 #define __DRM_CRTC_H__
28 #include <linux/i2c.h>
29 #include <linux/spinlock.h>
30 #include <linux/types.h>
31 #include <linux/idr.h>
34 #include <drm/drm_fourcc.h>
38 struct drm_framebuffer;
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
48 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
50 struct drm_mode_object {
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
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 */
70 MODE_NOMODE, /* no mode with a matching name */
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 */
104 #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
105 DRM_MODE_TYPE_CRTC_C)
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
114 #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
116 struct drm_display_mode {
118 struct list_head head;
119 struct drm_mode_object base;
121 char name[DRM_DISPLAY_MODE_LEN];
123 enum drm_mode_status status;
126 /* Proposed mode values */
127 int clock; /* in kHz */
140 /* Addressable image size (may be 0 for projectors, etc.) */
144 /* Actual mode we give to hw */
148 int crtc_hblank_start;
150 int crtc_hsync_start;
155 int crtc_vblank_start;
157 int crtc_vsync_start;
163 /* Driver private mode info */
168 int vrefresh; /* in Hz */
169 int hsync; /* in kHz */
172 enum drm_connector_status {
173 connector_status_connected = 1,
174 connector_status_disconnected = 2,
175 connector_status_unknown = 3,
178 enum subpixel_order {
180 SubPixelHorizontalRGB,
181 SubPixelHorizontalBGR,
187 #define DRM_COLOR_FORMAT_RGB444 (1<<0)
188 #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
189 #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
191 * Describes a given display (e.g. CRT or flat panel) and its limitations.
193 struct drm_display_info {
194 char name[DRM_DISPLAY_INFO_LEN];
197 unsigned int width_mm;
198 unsigned int height_mm;
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;
206 enum subpixel_order subpixel_order;
211 char *raw_edid; /* if any */
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);
220 * Optinal callback for the dirty fb ioctl.
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.
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
231 int (*dirty)(struct drm_framebuffer *framebuffer,
232 struct drm_file *file_priv, unsigned flags,
233 unsigned color, struct drm_clip_rect *clips,
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;
245 /* depth can be 15 or 16 */
249 uint32_t pixel_format; /* fourcc format */
250 struct list_head filp_head;
251 /* if you are using the helper */
252 void *helper_private;
255 struct drm_property_blob {
256 struct drm_mode_object base;
257 struct list_head head;
262 struct drm_property_enum {
264 struct list_head head;
265 char name[DRM_PROP_NAME_LEN];
268 struct drm_property {
269 struct list_head head;
270 struct drm_mode_object base;
272 char name[DRM_PROP_NAME_LEN];
276 struct list_head enum_blob_list;
280 struct drm_connector;
282 struct drm_pending_vblank_event;
286 * drm_crtc_funcs - control CRTCs for a given device
287 * @reset: reset CRTC after state has been invalidate (e.g. resume)
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.
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).
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
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? */
315 /* Reset CRTC state */
316 void (*reset)(struct drm_crtc *crtc);
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);
323 /* Set gamma on the CRTC */
324 void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
325 uint32_t start, uint32_t size);
326 /* Object destroy routine */
327 void (*destroy)(struct drm_crtc *crtc);
329 int (*set_config)(struct drm_mode_set *set);
332 * Flip to the given framebuffer. This implements the page
333 * flip ioctl described in drm_mode.h, specifically, the
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.
340 int (*page_flip)(struct drm_crtc *crtc,
341 struct drm_framebuffer *fb,
342 struct drm_pending_vblank_event *event);
346 * drm_crtc - central CRTC control structure
347 * @dev: parent DRM device
348 * @head: list management
349 * @base: base KMS object for ID tracking etc.
350 * @enabled: is this CRTC enabled?
351 * @mode: current mode timings
352 * @hwmode: mode timings as programmed to hw regs
353 * @x: x position on screen
354 * @y: y position on screen
355 * @funcs: CRTC control functions
356 * @gamma_size: size of gamma ramp
357 * @gamma_store: gamma ramp values
358 * @framedur_ns: precise frame timing
359 * @framedur_ns: precise line timing
360 * @pixeldur_ns: precise pixel timing
361 * @helper_private: mid-layer private data
363 * Each CRTC may have one or more connectors associated with it. This structure
364 * allows the CRTC to be controlled.
367 struct drm_device *dev;
368 struct list_head head;
370 struct drm_mode_object base;
372 /* framebuffer the connector is currently bound to */
373 struct drm_framebuffer *fb;
377 /* Requested mode from modesetting. */
378 struct drm_display_mode mode;
380 /* Programmed mode in hw, after adjustments for encoders,
381 * crtc, panel scaling etc. Needed for timestamping etc.
383 struct drm_display_mode hwmode;
386 const struct drm_crtc_funcs *funcs;
388 /* CRTC gamma size for reporting to userspace */
390 uint16_t *gamma_store;
392 /* Constants needed for precise vblank and swap timestamping. */
393 s64 framedur_ns, linedur_ns, pixeldur_ns;
395 /* if you are using the helper */
396 void *helper_private;
401 * drm_connector_funcs - control connectors on a given device
402 * @dpms: set power state (see drm_crtc_funcs above)
403 * @save: save connector state
404 * @restore: restore connector state
405 * @reset: reset connector after state has been invalidate (e.g. resume)
406 * @mode_valid: is this mode valid on the given connector?
407 * @mode_fixup: try to fixup proposed mode for this connector
408 * @mode_set: set this mode
409 * @detect: is this connector active?
410 * @get_modes: get mode list for this connector
411 * @set_property: property for this connector may need update
412 * @destroy: make object go away
413 * @force: notify the driver the connector is forced on
415 * Each CRTC may have one or more connectors attached to it. The functions
416 * below allow the core DRM code to control connectors, enumerate available modes,
419 struct drm_connector_funcs {
420 void (*dpms)(struct drm_connector *connector, int mode);
421 void (*save)(struct drm_connector *connector);
422 void (*restore)(struct drm_connector *connector);
423 void (*reset)(struct drm_connector *connector);
425 /* Check to see if anything is attached to the connector.
426 * @force is set to false whilst polling, true when checking the
427 * connector due to user request. @force can be used by the driver
428 * to avoid expensive, destructive operations during automated
431 enum drm_connector_status (*detect)(struct drm_connector *connector,
433 int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
434 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
436 void (*destroy)(struct drm_connector *connector);
437 void (*force)(struct drm_connector *connector);
440 struct drm_encoder_funcs {
441 void (*reset)(struct drm_encoder *encoder);
442 void (*destroy)(struct drm_encoder *encoder);
445 #define DRM_CONNECTOR_MAX_UMODES 16
446 #define DRM_CONNECTOR_MAX_PROPERTY 16
447 #define DRM_CONNECTOR_LEN 32
448 #define DRM_CONNECTOR_MAX_ENCODER 2
451 * drm_encoder - central DRM encoder structure
454 struct drm_device *dev;
455 struct list_head head;
457 struct drm_mode_object base;
459 uint32_t possible_crtcs;
460 uint32_t possible_clones;
462 struct drm_crtc *crtc;
463 const struct drm_encoder_funcs *funcs;
464 void *helper_private;
467 enum drm_connector_force {
468 DRM_FORCE_UNSPECIFIED,
470 DRM_FORCE_ON, /* force on analog part normally */
471 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
474 /* should we poll this connector for connects and disconnects */
475 /* hot plug detectable */
476 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
477 /* poll for connections */
478 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
479 /* can cleanly poll for disconnections without flickering the screen */
480 /* DACs should rarely do this without a lot of testing */
481 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
483 #define MAX_ELD_BYTES 128
486 * drm_connector - central DRM connector control structure
487 * @crtc: CRTC this connector is currently connected to, NULL if none
488 * @interlace_allowed: can this connector handle interlaced modes?
489 * @doublescan_allowed: can this connector handle doublescan?
490 * @available_modes: modes available on this connector (from get_modes() + user)
491 * @initial_x: initial x position for this connector
492 * @initial_y: initial y position for this connector
493 * @status: connector connected?
494 * @funcs: connector control functions
496 * Each connector may be connected to one or more CRTCs, or may be clonable by
497 * another connector if they can share a CRTC. Each connector also has a specific
498 * position in the broader display (referred to as a 'screen' though it could
499 * span multiple monitors).
501 struct drm_connector {
502 struct drm_device *dev;
504 struct device_attribute *attr;
505 struct list_head head;
507 struct drm_mode_object base;
510 int connector_type_id;
511 bool interlace_allowed;
512 bool doublescan_allowed;
513 struct list_head modes; /* list of modes on this connector */
515 int initial_x, initial_y;
516 enum drm_connector_status status;
518 /* these are modes added by probing with DDC or the BIOS */
519 struct list_head probed_modes;
521 struct drm_display_info display_info;
522 const struct drm_connector_funcs *funcs;
524 struct list_head user_modes;
525 struct drm_property_blob *edid_blob_ptr;
526 u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
527 uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
529 uint8_t polled; /* DRM_CONNECTOR_POLL_* */
531 /* requested DPMS state */
534 void *helper_private;
536 /* forced on connector */
537 enum drm_connector_force force;
538 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
539 uint32_t force_encoder_id;
540 struct drm_encoder *encoder; /* currently active encoder */
543 uint8_t eld[MAX_ELD_BYTES];
545 int max_tmds_clock; /* in MHz */
546 bool latency_present[2];
547 int video_latency[2]; /* [0]: progressive, [1]: interlaced */
548 int audio_latency[2];
549 int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
553 * drm_plane_funcs - driver plane control functions
554 * @update_plane: update the plane configuration
555 * @disable_plane: shut down the plane
556 * @destroy: clean up plane resources
558 struct drm_plane_funcs {
559 int (*update_plane)(struct drm_plane *plane,
560 struct drm_crtc *crtc, struct drm_framebuffer *fb,
561 int crtc_x, int crtc_y,
562 unsigned int crtc_w, unsigned int crtc_h,
563 uint32_t src_x, uint32_t src_y,
564 uint32_t src_w, uint32_t src_h);
565 int (*disable_plane)(struct drm_plane *plane);
566 void (*destroy)(struct drm_plane *plane);
570 * drm_plane - central DRM plane control structure
571 * @dev: DRM device this plane belongs to
572 * @head: for list management
573 * @base: base mode object
574 * @possible_crtcs: pipes this plane can be bound to
575 * @format_types: array of formats supported by this plane
576 * @format_count: number of formats supported
577 * @crtc: currently bound CRTC
578 * @fb: currently bound fb
579 * @gamma_size: size of gamma table
580 * @gamma_store: gamma correction table
581 * @enabled: enabled flag
582 * @funcs: helper functions
583 * @helper_private: storage for drver layer
586 struct drm_device *dev;
587 struct list_head head;
589 struct drm_mode_object base;
591 uint32_t possible_crtcs;
592 uint32_t *format_types;
593 uint32_t format_count;
595 struct drm_crtc *crtc;
596 struct drm_framebuffer *fb;
598 /* CRTC gamma size for reporting to userspace */
600 uint16_t *gamma_store;
604 const struct drm_plane_funcs *funcs;
605 void *helper_private;
609 * struct drm_mode_set
611 * Represents a single crtc the connectors that it drives with what mode
612 * and from which framebuffer it scans out from.
614 * This is used to set modes.
616 struct drm_mode_set {
617 struct list_head head;
619 struct drm_framebuffer *fb;
620 struct drm_crtc *crtc;
621 struct drm_display_mode *mode;
626 struct drm_connector **connectors;
627 size_t num_connectors;
631 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
633 struct drm_mode_config_funcs {
634 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd);
635 void (*output_poll_changed)(struct drm_device *dev);
638 struct drm_mode_group {
640 uint32_t num_encoders;
641 uint32_t num_connectors;
643 /* list of object IDs for this group */
648 * drm_mode_config - Mode configuration control structure
651 struct drm_mode_config {
652 struct mutex mutex; /* protects configuration (mode lists etc.) */
653 struct mutex idr_mutex; /* for IDR management */
654 struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
655 /* this is limited to one for now */
657 struct list_head fb_list;
659 struct list_head connector_list;
661 struct list_head encoder_list;
663 struct list_head plane_list;
666 struct list_head crtc_list;
668 struct list_head property_list;
670 int min_width, min_height;
671 int max_width, max_height;
672 struct drm_mode_config_funcs *funcs;
673 resource_size_t fb_base;
675 /* output poll support */
677 struct delayed_work output_poll_work;
679 /* pointers to standard properties */
680 struct list_head property_blob_list;
681 struct drm_property *edid_property;
682 struct drm_property *dpms_property;
684 /* DVI-I properties */
685 struct drm_property *dvi_i_subconnector_property;
686 struct drm_property *dvi_i_select_subconnector_property;
689 struct drm_property *tv_subconnector_property;
690 struct drm_property *tv_select_subconnector_property;
691 struct drm_property *tv_mode_property;
692 struct drm_property *tv_left_margin_property;
693 struct drm_property *tv_right_margin_property;
694 struct drm_property *tv_top_margin_property;
695 struct drm_property *tv_bottom_margin_property;
696 struct drm_property *tv_brightness_property;
697 struct drm_property *tv_contrast_property;
698 struct drm_property *tv_flicker_reduction_property;
699 struct drm_property *tv_overscan_property;
700 struct drm_property *tv_saturation_property;
701 struct drm_property *tv_hue_property;
703 /* Optional properties */
704 struct drm_property *scaling_mode_property;
705 struct drm_property *dithering_mode_property;
706 struct drm_property *dirty_info_property;
709 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
710 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
711 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
712 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
713 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
714 #define obj_to_property(x) container_of(x, struct drm_property, base)
715 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
716 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
719 extern void drm_crtc_init(struct drm_device *dev,
720 struct drm_crtc *crtc,
721 const struct drm_crtc_funcs *funcs);
722 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
724 extern void drm_connector_init(struct drm_device *dev,
725 struct drm_connector *connector,
726 const struct drm_connector_funcs *funcs,
729 extern void drm_connector_cleanup(struct drm_connector *connector);
731 extern void drm_encoder_init(struct drm_device *dev,
732 struct drm_encoder *encoder,
733 const struct drm_encoder_funcs *funcs,
736 extern int drm_plane_init(struct drm_device *dev,
737 struct drm_plane *plane,
738 unsigned long possible_crtcs,
739 const struct drm_plane_funcs *funcs,
740 uint32_t *formats, uint32_t format_count);
741 extern void drm_plane_cleanup(struct drm_plane *plane);
743 extern void drm_encoder_cleanup(struct drm_encoder *encoder);
745 extern char *drm_get_connector_name(struct drm_connector *connector);
746 extern char *drm_get_dpms_name(int val);
747 extern char *drm_get_dvi_i_subconnector_name(int val);
748 extern char *drm_get_dvi_i_select_name(int val);
749 extern char *drm_get_tv_subconnector_name(int val);
750 extern char *drm_get_tv_select_name(int val);
751 extern void drm_fb_release(struct drm_file *file_priv);
752 extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
753 extern struct edid *drm_get_edid(struct drm_connector *connector,
754 struct i2c_adapter *adapter);
755 extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
756 extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
757 extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
758 extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
759 const struct drm_display_mode *mode);
760 extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
761 extern void drm_mode_config_init(struct drm_device *dev);
762 extern void drm_mode_config_reset(struct drm_device *dev);
763 extern void drm_mode_config_cleanup(struct drm_device *dev);
764 extern void drm_mode_set_name(struct drm_display_mode *mode);
765 extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
766 extern int drm_mode_width(struct drm_display_mode *mode);
767 extern int drm_mode_height(struct drm_display_mode *mode);
769 /* for us by fb module */
770 extern int drm_mode_attachmode_crtc(struct drm_device *dev,
771 struct drm_crtc *crtc,
772 struct drm_display_mode *mode);
773 extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
775 extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
776 extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
777 extern void drm_mode_list_concat(struct list_head *head,
778 struct list_head *new);
779 extern void drm_mode_validate_size(struct drm_device *dev,
780 struct list_head *mode_list,
781 int maxX, int maxY, int maxPitch);
782 extern void drm_mode_prune_invalid(struct drm_device *dev,
783 struct list_head *mode_list, bool verbose);
784 extern void drm_mode_sort(struct list_head *mode_list);
785 extern int drm_mode_hsync(const struct drm_display_mode *mode);
786 extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
787 extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
789 extern void drm_mode_connector_list_update(struct drm_connector *connector);
790 extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
792 extern int drm_connector_property_set_value(struct drm_connector *connector,
793 struct drm_property *property,
795 extern int drm_connector_property_get_value(struct drm_connector *connector,
796 struct drm_property *property,
798 extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
799 extern void drm_framebuffer_set_object(struct drm_device *dev,
800 unsigned long handle);
801 extern int drm_framebuffer_init(struct drm_device *dev,
802 struct drm_framebuffer *fb,
803 const struct drm_framebuffer_funcs *funcs);
804 extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
805 extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
806 extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
807 extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
808 extern bool drm_crtc_in_use(struct drm_crtc *crtc);
810 extern int drm_connector_attach_property(struct drm_connector *connector,
811 struct drm_property *property, uint64_t init_val);
812 extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
813 const char *name, int num_values);
814 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
815 extern int drm_property_add_enum(struct drm_property *property, int index,
816 uint64_t value, const char *name);
817 extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
818 extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
820 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
821 extern int drm_mode_create_dithering_property(struct drm_device *dev);
822 extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
823 extern char *drm_get_encoder_name(struct drm_encoder *encoder);
825 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
826 struct drm_encoder *encoder);
827 extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
828 struct drm_encoder *encoder);
829 extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
831 extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
832 uint32_t id, uint32_t type);
834 extern int drm_mode_getresources(struct drm_device *dev,
835 void *data, struct drm_file *file_priv);
836 extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
837 struct drm_file *file_priv);
838 extern int drm_mode_getcrtc(struct drm_device *dev,
839 void *data, struct drm_file *file_priv);
840 extern int drm_mode_getconnector(struct drm_device *dev,
841 void *data, struct drm_file *file_priv);
842 extern int drm_mode_setcrtc(struct drm_device *dev,
843 void *data, struct drm_file *file_priv);
844 extern int drm_mode_getplane(struct drm_device *dev,
845 void *data, struct drm_file *file_priv);
846 extern int drm_mode_setplane(struct drm_device *dev,
847 void *data, struct drm_file *file_priv);
848 extern int drm_mode_cursor_ioctl(struct drm_device *dev,
849 void *data, struct drm_file *file_priv);
850 extern int drm_mode_addfb(struct drm_device *dev,
851 void *data, struct drm_file *file_priv);
852 extern int drm_mode_addfb2(struct drm_device *dev,
853 void *data, struct drm_file *file_priv);
854 extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
855 extern int drm_mode_rmfb(struct drm_device *dev,
856 void *data, struct drm_file *file_priv);
857 extern int drm_mode_getfb(struct drm_device *dev,
858 void *data, struct drm_file *file_priv);
859 extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
860 void *data, struct drm_file *file_priv);
861 extern int drm_mode_addmode_ioctl(struct drm_device *dev,
862 void *data, struct drm_file *file_priv);
863 extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
864 void *data, struct drm_file *file_priv);
865 extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
866 void *data, struct drm_file *file_priv);
867 extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
868 void *data, struct drm_file *file_priv);
870 extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
871 void *data, struct drm_file *file_priv);
872 extern int drm_mode_getblob_ioctl(struct drm_device *dev,
873 void *data, struct drm_file *file_priv);
874 extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
875 void *data, struct drm_file *file_priv);
876 extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
877 void *data, struct drm_file *file_priv);
878 extern int drm_mode_replacefb(struct drm_device *dev,
879 void *data, struct drm_file *file_priv);
880 extern int drm_mode_getencoder(struct drm_device *dev,
881 void *data, struct drm_file *file_priv);
882 extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
883 void *data, struct drm_file *file_priv);
884 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
885 void *data, struct drm_file *file_priv);
886 extern u8 *drm_find_cea_extension(struct edid *edid);
887 extern bool drm_detect_hdmi_monitor(struct edid *edid);
888 extern bool drm_detect_monitor_audio(struct edid *edid);
889 extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
890 void *data, struct drm_file *file_priv);
891 extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
892 int hdisplay, int vdisplay, int vrefresh,
893 bool reduced, bool interlaced, bool margins);
894 extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
895 int hdisplay, int vdisplay, int vrefresh,
896 bool interlaced, int margins);
897 extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
898 int hdisplay, int vdisplay, int vrefresh,
899 bool interlaced, int margins, int GTF_M,
900 int GTF_2C, int GTF_K, int GTF_2J);
901 extern int drm_add_modes_noedid(struct drm_connector *connector,
902 int hdisplay, int vdisplay);
904 extern int drm_edid_header_is_valid(const u8 *raw_edid);
905 extern bool drm_edid_is_valid(struct edid *edid);
906 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
907 int hsize, int vsize, int fresh);
909 extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
910 void *data, struct drm_file *file_priv);
911 extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
912 void *data, struct drm_file *file_priv);
913 extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
914 void *data, struct drm_file *file_priv);
916 extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
918 #endif /* __DRM_CRTC_H__ */