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.
27 #ifndef __DRM_CRTC_H__
28 #define __DRM_CRTC_H__
30 #include <dev/drm2/drm_gem_names.h>
31 #include <dev/drm2/drm_fourcc.h>
35 struct drm_framebuffer;
38 #define DRM_MODE_OBJECT_CRTC 0xcccccccc
39 #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
40 #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
41 #define DRM_MODE_OBJECT_MODE 0xdededede
42 #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
43 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
44 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
45 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
47 struct drm_mode_object {
53 * Note on terminology: here, for brevity and convenience, we refer to connector
54 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
55 * DVI, etc. And 'screen' refers to the whole of the visible display, which
56 * may span multiple monitors (and therefore multiple CRTC and connector
60 enum drm_mode_status {
61 MODE_OK = 0, /* Mode OK */
62 MODE_HSYNC, /* hsync out of range */
63 MODE_VSYNC, /* vsync out of range */
64 MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
65 MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
66 MODE_BAD_WIDTH, /* requires an unsupported linepitch */
67 MODE_NOMODE, /* no mode with a maching name */
68 MODE_NO_INTERLACE, /* interlaced mode not supported */
69 MODE_NO_DBLESCAN, /* doublescan mode not supported */
70 MODE_NO_VSCAN, /* multiscan mode not supported */
71 MODE_MEM, /* insufficient video memory */
72 MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
73 MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
74 MODE_MEM_VIRT, /* insufficient video memory given virtual size */
75 MODE_NOCLOCK, /* no fixed clock available */
76 MODE_CLOCK_HIGH, /* clock required is too high */
77 MODE_CLOCK_LOW, /* clock required is too low */
78 MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
79 MODE_BAD_HVALUE, /* horizontal timing was out of range */
80 MODE_BAD_VVALUE, /* vertical timing was out of range */
81 MODE_BAD_VSCAN, /* VScan value out of range */
82 MODE_HSYNC_NARROW, /* horizontal sync too narrow */
83 MODE_HSYNC_WIDE, /* horizontal sync too wide */
84 MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
85 MODE_HBLANK_WIDE, /* horizontal blanking too wide */
86 MODE_VSYNC_NARROW, /* vertical sync too narrow */
87 MODE_VSYNC_WIDE, /* vertical sync too wide */
88 MODE_VBLANK_NARROW, /* vertical blanking too narrow */
89 MODE_VBLANK_WIDE, /* vertical blanking too wide */
90 MODE_PANEL, /* exceeds panel dimensions */
91 MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
92 MODE_ONE_WIDTH, /* only one width is supported */
93 MODE_ONE_HEIGHT, /* only one height is supported */
94 MODE_ONE_SIZE, /* only one resolution is supported */
95 MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
96 MODE_UNVERIFIED = -3, /* mode needs to reverified */
97 MODE_BAD = -2, /* unspecified reason */
98 MODE_ERROR = -1 /* error condition */
101 #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
102 DRM_MODE_TYPE_CRTC_C)
104 #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
105 .name = nm, .status = 0, .type = (t), .clock = (c), \
106 .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
107 .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
108 .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
109 .vscan = (vs), .flags = (f), .vrefresh = 0
111 #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
113 struct drm_display_mode {
115 struct list_head head;
116 struct drm_mode_object base;
118 char name[DRM_DISPLAY_MODE_LEN];
121 enum drm_mode_status status;
124 /* Proposed mode values */
125 int clock; /* in kHz */
138 /* Addressable image size (may be 0 for projectors, etc.) */
142 /* Actual mode we give to hw */
146 int crtc_hblank_start;
148 int crtc_hsync_start;
153 int crtc_vblank_start;
155 int crtc_vsync_start;
161 /* Driver private mode info */
166 int vrefresh; /* in Hz */
167 int hsync; /* in kHz */
170 enum drm_connector_status {
171 connector_status_connected = 1,
172 connector_status_disconnected = 2,
173 connector_status_unknown = 3,
176 enum subpixel_order {
178 SubPixelHorizontalRGB,
179 SubPixelHorizontalBGR,
185 #define DRM_COLOR_FORMAT_RGB444 (1<<0)
186 #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
187 #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
189 * Describes a given display (e.g. CRT or flat panel) and its limitations.
191 struct drm_display_info {
192 char name[DRM_DISPLAY_INFO_LEN];
195 unsigned int width_mm;
196 unsigned int height_mm;
198 /* Clock limits FIXME: storage format */
199 unsigned int min_vfreq, max_vfreq;
200 unsigned int min_hfreq, max_hfreq;
201 unsigned int pixel_clock;
204 enum subpixel_order subpixel_order;
209 char *raw_edid; /* if any */
212 struct drm_framebuffer_funcs {
213 void (*destroy)(struct drm_framebuffer *framebuffer);
214 int (*create_handle)(struct drm_framebuffer *fb,
215 struct drm_file *file_priv,
216 unsigned int *handle);
218 * Optinal callback for the dirty fb ioctl.
220 * Userspace can notify the driver via this callback
221 * that a area of the framebuffer has changed and should
222 * be flushed to the display hardware.
224 * See documentation in drm_mode.h for the struct
225 * drm_mode_fb_dirty_cmd for more information as all
226 * the semantics and arguments have a one to one mapping
229 int (*dirty)(struct drm_framebuffer *framebuffer,
230 struct drm_file *file_priv, unsigned flags,
231 unsigned color, struct drm_clip_rect *clips,
235 struct drm_framebuffer {
236 struct drm_device *dev;
237 struct list_head head;
238 struct drm_mode_object base;
239 const struct drm_framebuffer_funcs *funcs;
240 unsigned int pitches[4];
241 unsigned int offsets[4];
244 /* depth can be 15 or 16 */
248 uint32_t pixel_format; /* fourcc format */
249 struct list_head filp_head;
250 /* if you are using the helper */
251 void *helper_private;
254 struct drm_property_blob {
255 struct drm_mode_object base;
256 struct list_head head;
258 unsigned char data[];
261 struct drm_property_enum {
263 struct list_head head;
264 char name[DRM_PROP_NAME_LEN];
267 struct drm_property {
268 struct list_head head;
269 struct drm_mode_object base;
271 char name[DRM_PROP_NAME_LEN];
275 struct list_head enum_blob_list;
279 struct drm_connector;
281 struct drm_pending_vblank_event;
285 * drm_crtc_funcs - control CRTCs for a given device
286 * @reset: reset CRTC after state has been invalidate (e.g. resume)
287 * @dpms: control display power levels
288 * @save: save CRTC state
289 * @resore: restore CRTC state
290 * @lock: lock the CRTC
291 * @unlock: unlock the CRTC
292 * @shadow_allocate: allocate shadow pixmap
293 * @shadow_create: create shadow pixmap for rotation support
294 * @shadow_destroy: free shadow pixmap
295 * @mode_fixup: fixup proposed mode
296 * @mode_set: set the desired mode on the CRTC
297 * @gamma_set: specify color ramp for CRTC
298 * @destroy: deinit and free object.
300 * The drm_crtc_funcs structure is the central CRTC management structure
301 * in the DRM. Each CRTC controls one or more connectors (note that the name
302 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
303 * connectors, not just CRTs).
305 * Each driver is responsible for filling out this structure at startup time,
306 * in addition to providing other modesetting features, like i2c and DDC
309 struct drm_crtc_funcs {
310 /* Save CRTC state */
311 void (*save)(struct drm_crtc *crtc); /* suspend? */
312 /* Restore CRTC state */
313 void (*restore)(struct drm_crtc *crtc); /* resume? */
314 /* Reset CRTC state */
315 void (*reset)(struct drm_crtc *crtc);
317 /* cursor controls */
318 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
319 uint32_t handle, uint32_t width, uint32_t height);
320 int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
322 /* Set gamma on the CRTC */
323 void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
324 uint32_t start, uint32_t size);
325 /* Object destroy routine */
326 void (*destroy)(struct drm_crtc *crtc);
328 int (*set_config)(struct drm_mode_set *set);
331 * Flip to the given framebuffer. This implements the page
332 * flip ioctl descibed in drm_mode.h, specifically, the
333 * implementation must return immediately and block all
334 * rendering to the current fb until the flip has completed.
335 * If userspace set the event flag in the ioctl, the event
336 * argument will point to an event to send back when the flip
337 * completes, otherwise it will be NULL.
339 int (*page_flip)(struct drm_crtc *crtc,
340 struct drm_framebuffer *fb,
341 struct drm_pending_vblank_event *event);
345 * drm_crtc - central CRTC control structure
346 * @enabled: is this CRTC enabled?
347 * @x: x position on screen
348 * @y: y position on screen
349 * @funcs: CRTC control functions
351 * Each CRTC may have one or more connectors associated with it. This structure
352 * allows the CRTC to be controlled.
355 struct drm_device *dev;
356 struct list_head head;
358 struct drm_mode_object base;
360 /* framebuffer the connector is currently bound to */
361 struct drm_framebuffer *fb;
365 /* Requested mode from modesetting. */
366 struct drm_display_mode mode;
368 /* Programmed mode in hw, after adjustments for encoders,
369 * crtc, panel scaling etc. Needed for timestamping etc.
371 struct drm_display_mode hwmode;
374 const struct drm_crtc_funcs *funcs;
376 /* CRTC gamma size for reporting to userspace */
378 uint16_t *gamma_store;
380 /* Constants needed for precise vblank and swap timestamping. */
381 int64_t framedur_ns, linedur_ns, pixeldur_ns;
383 /* if you are using the helper */
384 void *helper_private;
389 * drm_connector_funcs - control connectors on a given device
390 * @dpms: set power state (see drm_crtc_funcs above)
391 * @save: save connector state
392 * @restore: restore connector state
393 * @reset: reset connector after state has been invalidate (e.g. resume)
394 * @mode_valid: is this mode valid on the given connector?
395 * @mode_fixup: try to fixup proposed mode for this connector
396 * @mode_set: set this mode
397 * @detect: is this connector active?
398 * @get_modes: get mode list for this connector
399 * @set_property: property for this connector may need update
400 * @destroy: make object go away
401 * @force: notify the driver the connector is forced on
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,
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 void (*reset)(struct drm_connector *connector);
413 /* Check to see if anything is attached to the connector.
414 * @force is set to false whilst polling, true when checking the
415 * connector due to user request. @force can be used by the driver
416 * to avoid expensive, destructive operations during automated
419 enum drm_connector_status (*detect)(struct drm_connector *connector,
421 int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
422 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
424 void (*destroy)(struct drm_connector *connector);
425 void (*force)(struct drm_connector *connector);
428 struct drm_encoder_funcs {
429 void (*reset)(struct drm_encoder *encoder);
430 void (*destroy)(struct drm_encoder *encoder);
433 #define DRM_CONNECTOR_MAX_UMODES 16
434 #define DRM_CONNECTOR_MAX_PROPERTY 16
435 #define DRM_CONNECTOR_LEN 32
436 #define DRM_CONNECTOR_MAX_ENCODER 2
439 * drm_encoder - central DRM encoder structure
442 struct drm_device *dev;
443 struct list_head head;
445 struct drm_mode_object base;
447 uint32_t possible_crtcs;
448 uint32_t possible_clones;
450 struct drm_crtc *crtc;
451 const struct drm_encoder_funcs *funcs;
452 void *helper_private;
455 enum drm_connector_force {
456 DRM_FORCE_UNSPECIFIED,
458 DRM_FORCE_ON, /* force on analog part normally */
459 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
462 /* should we poll this connector for connects and disconnects */
463 /* hot plug detectable */
464 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
465 /* poll for connections */
466 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
467 /* can cleanly poll for disconnections without flickering the screen */
468 /* DACs should rarely do this without a lot of testing */
469 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
471 #define MAX_ELD_BYTES 128
474 * drm_connector - central DRM connector control structure
475 * @crtc: CRTC this connector is currently connected to, NULL if none
476 * @interlace_allowed: can this connector handle interlaced modes?
477 * @doublescan_allowed: can this connector handle doublescan?
478 * @available_modes: modes available on this connector (from get_modes() + user)
479 * @initial_x: initial x position for this connector
480 * @initial_y: initial y position for this connector
481 * @status: connector connected?
482 * @funcs: connector control functions
484 * Each connector may be connected to one or more CRTCs, or may be clonable by
485 * another connector if they can share a CRTC. Each connector also has a specific
486 * position in the broader display (referred to as a 'screen' though it could
487 * span multiple monitors).
489 struct drm_connector {
490 struct drm_device *dev;
491 /* struct device kdev; XXXKIB */
492 struct device_attribute *attr;
493 struct list_head head;
495 struct drm_mode_object base;
498 int connector_type_id;
499 bool interlace_allowed;
500 bool doublescan_allowed;
501 struct list_head modes; /* list of modes on this connector */
503 int initial_x, initial_y;
504 enum drm_connector_status status;
506 /* these are modes added by probing with DDC or the BIOS */
507 struct list_head probed_modes;
509 struct drm_display_info display_info;
510 const struct drm_connector_funcs *funcs;
512 struct list_head user_modes;
513 struct drm_property_blob *edid_blob_ptr;
514 u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
515 uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
517 uint8_t polled; /* DRM_CONNECTOR_POLL_* */
519 /* requested DPMS state */
522 void *helper_private;
524 /* forced on connector */
525 enum drm_connector_force force;
526 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
527 uint32_t force_encoder_id;
528 struct drm_encoder *encoder; /* currently active encoder */
531 uint8_t eld[MAX_ELD_BYTES];
533 int max_tmds_clock; /* in MHz */
534 bool latency_present[2];
535 int video_latency[2]; /* [0]: progressive, [1]: interlaced */
536 int audio_latency[2];
538 int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
542 * drm_plane_funcs - driver plane control functions
543 * @update_plane: update the plane configuration
544 * @disable_plane: shut down the plane
545 * @destroy: clean up plane resources
547 struct drm_plane_funcs {
548 int (*update_plane)(struct drm_plane *plane,
549 struct drm_crtc *crtc, struct drm_framebuffer *fb,
550 int crtc_x, int crtc_y,
551 unsigned int crtc_w, unsigned int crtc_h,
552 uint32_t src_x, uint32_t src_y,
553 uint32_t src_w, uint32_t src_h);
554 int (*disable_plane)(struct drm_plane *plane);
555 void (*destroy)(struct drm_plane *plane);
559 * drm_plane - central DRM plane control structure
560 * @dev: DRM device this plane belongs to
561 * @head: for list management
562 * @base: base mode object
563 * @possible_crtcs: pipes this plane can be bound to
564 * @format_types: array of formats supported by this plane
565 * @format_count: number of formats supported
566 * @crtc: currently bound CRTC
567 * @fb: currently bound fb
568 * @gamma_size: size of gamma table
569 * @gamma_store: gamma correction table
570 * @enabled: enabled flag
571 * @funcs: helper functions
572 * @helper_private: storage for drver layer
575 struct drm_device *dev;
576 struct list_head head;
578 struct drm_mode_object base;
580 uint32_t possible_crtcs;
581 uint32_t *format_types;
582 uint32_t format_count;
584 struct drm_crtc *crtc;
585 struct drm_framebuffer *fb;
587 /* CRTC gamma size for reporting to userspace */
589 uint16_t *gamma_store;
593 const struct drm_plane_funcs *funcs;
594 void *helper_private;
598 * struct drm_mode_set
600 * Represents a single crtc the connectors that it drives with what mode
601 * and from which framebuffer it scans out from.
603 * This is used to set modes.
605 struct drm_mode_set {
606 struct list_head head;
608 struct drm_framebuffer *fb;
609 struct drm_crtc *crtc;
610 struct drm_display_mode *mode;
615 struct drm_connector **connectors;
616 size_t num_connectors;
620 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
622 struct drm_mode_config_funcs {
623 int (*fb_create)(struct drm_device *dev,
624 struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd,
625 struct drm_framebuffer **res);
626 void (*output_poll_changed)(struct drm_device *dev);
629 struct drm_mode_group {
631 uint32_t num_encoders;
632 uint32_t num_connectors;
634 /* list of object IDs for this group */
639 * drm_mode_config - Mode configuration control structure
642 struct drm_mode_config {
643 struct sx mutex; /* protects configuration (mode lists etc.) */
644 struct drm_gem_names crtc_names; /* use this idr for all IDs, fb, crtc, connector, modes */
645 /* this is limited to one for now */
647 struct list_head fb_list;
649 struct list_head connector_list;
651 struct list_head encoder_list;
653 struct list_head plane_list;
656 struct list_head crtc_list;
658 struct list_head property_list;
660 int min_width, min_height;
661 int max_width, max_height;
662 struct drm_mode_config_funcs *funcs;
663 resource_size_t fb_base;
665 /* output poll support */
667 struct timeout_task output_poll_task;
669 /* pointers to standard properties */
670 struct list_head property_blob_list;
671 struct drm_property *edid_property;
672 struct drm_property *dpms_property;
674 /* DVI-I properties */
675 struct drm_property *dvi_i_subconnector_property;
676 struct drm_property *dvi_i_select_subconnector_property;
679 struct drm_property *tv_subconnector_property;
680 struct drm_property *tv_select_subconnector_property;
681 struct drm_property *tv_mode_property;
682 struct drm_property *tv_left_margin_property;
683 struct drm_property *tv_right_margin_property;
684 struct drm_property *tv_top_margin_property;
685 struct drm_property *tv_bottom_margin_property;
686 struct drm_property *tv_brightness_property;
687 struct drm_property *tv_contrast_property;
688 struct drm_property *tv_flicker_reduction_property;
689 struct drm_property *tv_overscan_property;
690 struct drm_property *tv_saturation_property;
691 struct drm_property *tv_hue_property;
693 /* Optional properties */
694 struct drm_property *scaling_mode_property;
695 struct drm_property *dithering_mode_property;
696 struct drm_property *dirty_info_property;
698 /* dumb ioctl parameters */
699 uint32_t preferred_depth, prefer_shadow;
702 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
703 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
704 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
705 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
706 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
707 #define obj_to_property(x) container_of(x, struct drm_property, base)
708 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
709 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
711 struct drm_prop_enum_list {
716 #if defined(MODE_SETTING_LOCKING_IS_NOT_BROKEN)
717 #define DRM_MODE_CONFIG_ASSERT_LOCKED(dev) \
718 sx_assert(&dev->mode_config.mutex, SA_XLOCKED)
720 #define DRM_MODE_CONFIG_ASSERT_LOCKED(dev)
723 extern char *drm_get_dirty_info_name(int val);
724 extern char *drm_get_connector_status_name(enum drm_connector_status status);
726 extern int drm_crtc_init(struct drm_device *dev,
727 struct drm_crtc *crtc,
728 const struct drm_crtc_funcs *funcs);
729 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
731 extern int drm_connector_init(struct drm_device *dev,
732 struct drm_connector *connector,
733 const struct drm_connector_funcs *funcs,
736 extern void drm_connector_cleanup(struct drm_connector *connector);
738 extern int drm_encoder_init(struct drm_device *dev,
739 struct drm_encoder *encoder,
740 const struct drm_encoder_funcs *funcs,
743 extern int drm_plane_init(struct drm_device *dev,
744 struct drm_plane *plane,
745 unsigned long possible_crtcs,
746 const struct drm_plane_funcs *funcs,
747 const uint32_t *formats, uint32_t format_count,
749 extern void drm_plane_cleanup(struct drm_plane *plane);
751 extern void drm_encoder_cleanup(struct drm_encoder *encoder);
753 extern char *drm_get_connector_name(struct drm_connector *connector);
754 extern char *drm_get_dpms_name(int val);
755 extern char *drm_get_dvi_i_subconnector_name(int val);
756 extern char *drm_get_dvi_i_select_name(int val);
757 extern char *drm_get_tv_subconnector_name(int val);
758 extern char *drm_get_tv_select_name(int val);
759 extern void drm_fb_release(struct drm_file *file_priv);
760 extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
761 extern struct edid *drm_get_edid(struct drm_connector *connector,
763 extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
764 extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
765 extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
766 extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
767 const struct drm_display_mode *mode);
768 extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
769 extern void drm_mode_config_init(struct drm_device *dev);
770 extern void drm_mode_config_reset(struct drm_device *dev);
771 extern void drm_mode_config_cleanup(struct drm_device *dev);
772 extern void drm_mode_set_name(struct drm_display_mode *mode);
773 extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
774 extern int drm_mode_width(struct drm_display_mode *mode);
775 extern int drm_mode_height(struct drm_display_mode *mode);
777 /* for us by fb module */
778 extern int drm_mode_attachmode_crtc(struct drm_device *dev,
779 struct drm_crtc *crtc,
780 const struct drm_display_mode *mode);
781 extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
783 extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
784 extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
785 extern void drm_mode_list_concat(struct list_head *head,
786 struct list_head *new);
787 extern void drm_mode_validate_size(struct drm_device *dev,
788 struct list_head *mode_list,
789 int maxX, int maxY, int maxPitch);
790 extern void drm_mode_validate_clocks(struct drm_device *dev,
791 struct list_head *mode_list,
792 int *min, int *max, int n_ranges);
793 extern void drm_mode_prune_invalid(struct drm_device *dev,
794 struct list_head *mode_list, bool verbose);
795 extern void drm_mode_sort(struct list_head *mode_list);
796 extern int drm_mode_hsync(const struct drm_display_mode *mode);
797 extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
798 extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
800 extern void drm_mode_connector_list_update(struct drm_connector *connector);
801 extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
803 extern int drm_connector_property_set_value(struct drm_connector *connector,
804 struct drm_property *property,
806 extern int drm_connector_property_get_value(struct drm_connector *connector,
807 struct drm_property *property,
809 extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
810 extern void drm_framebuffer_set_object(struct drm_device *dev,
811 unsigned long handle);
812 extern int drm_framebuffer_init(struct drm_device *dev,
813 struct drm_framebuffer *fb,
814 const struct drm_framebuffer_funcs *funcs);
815 extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
816 extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
817 extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
818 extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
819 extern bool drm_crtc_in_use(struct drm_crtc *crtc);
821 extern int drm_connector_attach_property(struct drm_connector *connector,
822 struct drm_property *property, uint64_t init_val);
823 extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
824 const char *name, int num_values);
825 extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
827 const struct drm_prop_enum_list *props,
829 struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
831 uint64_t min, uint64_t max);
832 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
833 extern int drm_property_add_enum(struct drm_property *property, int index,
834 uint64_t value, const char *name);
835 extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
836 extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
838 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
839 extern int drm_mode_create_dithering_property(struct drm_device *dev);
840 extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
841 extern char *drm_get_encoder_name(struct drm_encoder *encoder);
843 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
844 struct drm_encoder *encoder);
845 extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
846 struct drm_encoder *encoder);
847 extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
849 extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
850 uint32_t id, uint32_t type);
852 extern int drm_mode_getresources(struct drm_device *dev,
853 void *data, struct drm_file *file_priv);
854 extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
855 struct drm_file *file_priv);
856 extern int drm_mode_getcrtc(struct drm_device *dev,
857 void *data, struct drm_file *file_priv);
858 extern int drm_mode_getconnector(struct drm_device *dev,
859 void *data, struct drm_file *file_priv);
860 extern int drm_mode_setcrtc(struct drm_device *dev,
861 void *data, struct drm_file *file_priv);
862 extern int drm_mode_getplane(struct drm_device *dev,
863 void *data, struct drm_file *file_priv);
864 extern int drm_mode_setplane(struct drm_device *dev,
865 void *data, struct drm_file *file_priv);
866 extern int drm_mode_cursor_ioctl(struct drm_device *dev,
867 void *data, struct drm_file *file_priv);
868 extern int drm_mode_addfb(struct drm_device *dev,
869 void *data, struct drm_file *file_priv);
870 extern int drm_mode_addfb2(struct drm_device *dev,
871 void *data, struct drm_file *file_priv);
872 extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
873 extern int drm_mode_rmfb(struct drm_device *dev,
874 void *data, struct drm_file *file_priv);
875 extern int drm_mode_getfb(struct drm_device *dev,
876 void *data, struct drm_file *file_priv);
877 extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
878 void *data, struct drm_file *file_priv);
879 extern int drm_mode_addmode_ioctl(struct drm_device *dev,
880 void *data, struct drm_file *file_priv);
881 extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
882 void *data, struct drm_file *file_priv);
883 extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
884 void *data, struct drm_file *file_priv);
885 extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
886 void *data, struct drm_file *file_priv);
888 extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
889 void *data, struct drm_file *file_priv);
890 extern int drm_mode_getblob_ioctl(struct drm_device *dev,
891 void *data, struct drm_file *file_priv);
892 extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
893 void *data, struct drm_file *file_priv);
894 extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
895 void *data, struct drm_file *file_priv);
896 extern int drm_mode_replacefb(struct drm_device *dev,
897 void *data, struct drm_file *file_priv);
898 extern int drm_mode_getencoder(struct drm_device *dev,
899 void *data, struct drm_file *file_priv);
900 extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
901 void *data, struct drm_file *file_priv);
902 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
903 void *data, struct drm_file *file_priv);
904 extern bool drm_detect_hdmi_monitor(struct edid *edid);
905 extern bool drm_detect_monitor_audio(struct edid *edid);
906 extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
907 void *data, struct drm_file *file_priv);
908 extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
909 int hdisplay, int vdisplay, int vrefresh,
910 bool reduced, bool interlaced, bool margins);
911 extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
912 int hdisplay, int vdisplay, int vrefresh,
913 bool interlaced, int margins);
914 extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
915 int hdisplay, int vdisplay, int vrefresh,
916 bool interlaced, int margins, int GTF_M,
917 int GTF_2C, int GTF_K, int GTF_2J);
918 extern int drm_add_modes_noedid(struct drm_connector *connector,
919 int hdisplay, int vdisplay);
921 extern int drm_edid_header_is_valid(const u8 *raw_edid);
922 extern bool drm_edid_is_valid(struct edid *edid);
923 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
924 int hsize, int vsize, int fresh);
926 extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
927 void *data, struct drm_file *file_priv);
928 extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
929 void *data, struct drm_file *file_priv);
930 extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
931 void *data, struct drm_file *file_priv);
933 extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
935 #endif /* __DRM_CRTC_H__ */