aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-11-07 17:05:41 -0500
committerDave Airlie <airlied@linux.ie>2008-12-29 02:47:23 -0500
commitf453ba0460742ad027ae0c4c7d61e62817b3e7ef (patch)
tree29e6ecacd6e8971aa62e1825d77f2c1876ac3eb2 /include
parentde151cf67ce52ed2d88083daa5e60c7858947329 (diff)
DRM: add mode setting support
Add mode setting support to the DRM layer. This is a fairly big chunk of work that allows DRM drivers to provide full output control and configuration capabilities to userspace. It was motivated by several factors: - the fb layer's APIs aren't suited for anything but simple configurations - coordination between the fb layer, DRM layer, and various userspace drivers is poor to non-existent (radeonfb excepted) - user level mode setting drivers makes displaying panic & oops messages more difficult - suspend/resume of graphics state is possible in many more configurations with kernel level support This commit just adds the core DRM part of the mode setting APIs. Driver specific commits using these new structure and APIs will follow. Co-authors: Jesse Barnes <jbarnes@virtuousgeek.org>, Jakob Bornecrantz <jakob@tungstengraphics.com> Contributors: Alan Hourihane <alanh@tungstengraphics.com>, Maarten Maathuis <madman2003@gmail.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/drm/Kbuild2
-rw-r--r--include/drm/drm.h21
-rw-r--r--include/drm/drmP.h18
-rw-r--r--include/drm/drm_crtc.h737
-rw-r--r--include/drm/drm_crtc_helper.h121
-rw-r--r--include/drm/drm_edid.h202
-rw-r--r--include/drm/drm_mode.h278
-rw-r--r--include/linux/console.h4
8 files changed, 1382 insertions, 1 deletions
diff --git a/include/drm/Kbuild b/include/drm/Kbuild
index 82b6983b7fbb..b940fdfa3b25 100644
--- a/include/drm/Kbuild
+++ b/include/drm/Kbuild
@@ -1,4 +1,4 @@
1unifdef-y += drm.h drm_sarea.h 1unifdef-y += drm.h drm_sarea.h drm_mode.h
2unifdef-y += i810_drm.h 2unifdef-y += i810_drm.h
3unifdef-y += i830_drm.h 3unifdef-y += i830_drm.h
4unifdef-y += i915_drm.h 4unifdef-y += i915_drm.h
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 3a66252456ba..76ce6fe300b7 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -599,6 +599,8 @@ struct drm_gem_open {
599 uint64_t size; 599 uint64_t size;
600}; 600};
601 601
602#include "drm_mode.h"
603
602#define DRM_IOCTL_BASE 'd' 604#define DRM_IOCTL_BASE 'd'
603#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) 605#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
604#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type) 606#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)
@@ -668,6 +670,25 @@ struct drm_gem_open {
668 670
669#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw) 671#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)
670 672
673#define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res)
674#define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc)
675#define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA2, struct drm_mode_crtc)
676#define DRM_IOCTL_MODE_CURSOR DRM_IOWR(0xA3, struct drm_mode_cursor)
677#define DRM_IOCTL_MODE_GETGAMMA DRM_IOWR(0xA4, struct drm_mode_crtc_lut)
678#define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut)
679#define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder)
680#define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector)
681#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd)
682#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd)
683
684#define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property)
685#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property)
686#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob)
687#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
688#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
689#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int)
690#define DRM_IOCTL_MODE_REPLACEFB DRM_IOWR(0xB0, struct drm_mode_fb_cmd)
691
671/** 692/**
672 * Device specific ioctls should only be in their respective headers 693 * Device specific ioctls should only be in their respective headers
673 * The device specific ioctl range is from 0x40 to 0x99. 694 * The device specific ioctl range is from 0x40 to 0x99.
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ae42a6a5c24e..7802c80f2b23 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -105,6 +105,7 @@ struct drm_device;
105#define DRIVER_FB_DMA 0x400 105#define DRIVER_FB_DMA 0x400
106#define DRIVER_IRQ_VBL2 0x800 106#define DRIVER_IRQ_VBL2 0x800
107#define DRIVER_GEM 0x1000 107#define DRIVER_GEM 0x1000
108#define DRIVER_MODESET 0x2000
108 109
109/***********************************************************************/ 110/***********************************************************************/
110/** \name Begin the DRM... */ 111/** \name Begin the DRM... */
@@ -276,6 +277,7 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
276#define DRM_AUTH 0x1 277#define DRM_AUTH 0x1
277#define DRM_MASTER 0x2 278#define DRM_MASTER 0x2
278#define DRM_ROOT_ONLY 0x4 279#define DRM_ROOT_ONLY 0x4
280#define DRM_CONTROL_ALLOW 0x8
279 281
280struct drm_ioctl_desc { 282struct drm_ioctl_desc {
281 unsigned int cmd; 283 unsigned int cmd;
@@ -398,6 +400,7 @@ struct drm_file {
398 int is_master; /* this file private is a master for a minor */ 400 int is_master; /* this file private is a master for a minor */
399 struct drm_master *master; /* master this node is currently associated with 401 struct drm_master *master; /* master this node is currently associated with
400 N.B. not always minor->master */ 402 N.B. not always minor->master */
403 struct list_head fbs;
401}; 404};
402 405
403/** Wait queue */ 406/** Wait queue */
@@ -629,6 +632,8 @@ struct drm_gem_object {
629 void *driver_private; 632 void *driver_private;
630}; 633};
631 634
635#include "drm_crtc.h"
636
632/* per-master structure */ 637/* per-master structure */
633struct drm_master { 638struct drm_master {
634 639
@@ -792,6 +797,8 @@ struct drm_driver {
792 797
793#define DRM_MINOR_UNASSIGNED 0 798#define DRM_MINOR_UNASSIGNED 0
794#define DRM_MINOR_LEGACY 1 799#define DRM_MINOR_LEGACY 1
800#define DRM_MINOR_CONTROL 2
801#define DRM_MINOR_RENDER 3
795 802
796/** 803/**
797 * DRM minor structure. This structure represents a drm minor number. 804 * DRM minor structure. This structure represents a drm minor number.
@@ -805,6 +812,7 @@ struct drm_minor {
805 struct proc_dir_entry *dev_root; /**< proc directory entry */ 812 struct proc_dir_entry *dev_root; /**< proc directory entry */
806 struct drm_master *master; /* currently active master for this node */ 813 struct drm_master *master; /* currently active master for this node */
807 struct list_head master_list; 814 struct list_head master_list;
815 struct drm_mode_group mode_group;
808}; 816};
809 817
810/** 818/**
@@ -855,6 +863,7 @@ struct drm_device {
855 struct idr ctx_idr; 863 struct idr ctx_idr;
856 864
857 struct list_head vmalist; /**< List of vmas (for debugging) */ 865 struct list_head vmalist; /**< List of vmas (for debugging) */
866
858 /*@} */ 867 /*@} */
859 868
860 /** \name DMA queues (contexts) */ 869 /** \name DMA queues (contexts) */
@@ -933,6 +942,7 @@ struct drm_device {
933 struct drm_driver *driver; 942 struct drm_driver *driver;
934 drm_local_map_t *agp_buffer_map; 943 drm_local_map_t *agp_buffer_map;
935 unsigned int agp_buffer_token; 944 unsigned int agp_buffer_token;
945 struct drm_minor *control; /**< Control node for card */
936 struct drm_minor *primary; /**< render type primary screen head */ 946 struct drm_minor *primary; /**< render type primary screen head */
937 947
938 /** \name Drawable information */ 948 /** \name Drawable information */
@@ -941,6 +951,8 @@ struct drm_device {
941 struct idr drw_idr; 951 struct idr drw_idr;
942 /*@} */ 952 /*@} */
943 953
954 struct drm_mode_config mode_config; /**< Current mode config */
955
944 /** \name GEM information */ 956 /** \name GEM information */
945 /*@{ */ 957 /*@{ */
946 spinlock_t object_name_lock; 958 spinlock_t object_name_lock;
@@ -1201,6 +1213,8 @@ extern int drm_vblank_get(struct drm_device *dev, int crtc);
1201extern void drm_vblank_put(struct drm_device *dev, int crtc); 1213extern void drm_vblank_put(struct drm_device *dev, int crtc);
1202extern void drm_vblank_cleanup(struct drm_device *dev); 1214extern void drm_vblank_cleanup(struct drm_device *dev);
1203/* Modesetting support */ 1215/* Modesetting support */
1216extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1217extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1204extern int drm_modeset_ctl(struct drm_device *dev, void *data, 1218extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1205 struct drm_file *file_priv); 1219 struct drm_file *file_priv);
1206 1220
@@ -1286,7 +1300,11 @@ struct drm_sysfs_class;
1286extern struct class *drm_sysfs_create(struct module *owner, char *name); 1300extern struct class *drm_sysfs_create(struct module *owner, char *name);
1287extern void drm_sysfs_destroy(void); 1301extern void drm_sysfs_destroy(void);
1288extern int drm_sysfs_device_add(struct drm_minor *minor); 1302extern int drm_sysfs_device_add(struct drm_minor *minor);
1303extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1289extern void drm_sysfs_device_remove(struct drm_minor *minor); 1304extern void drm_sysfs_device_remove(struct drm_minor *minor);
1305extern char *drm_get_connector_status_name(enum drm_connector_status status);
1306extern int drm_sysfs_connector_add(struct drm_connector *connector);
1307extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1290 1308
1291/* 1309/*
1292 * Basic memory manager support (drm_mm.c) 1310 * Basic memory manager support (drm_mm.c)
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
new file mode 100644
index 000000000000..08a884bea446
--- /dev/null
+++ b/include/drm/drm_crtc.h
@@ -0,0 +1,737 @@
1/*
2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25#ifndef __DRM_CRTC_H__
26#define __DRM_CRTC_H__
27
28#include <linux/i2c.h>
29#include <linux/spinlock.h>
30#include <linux/types.h>
31#include <linux/idr.h>
32
33#include <linux/fb.h>
34
35struct drm_device;
36struct drm_mode_set;
37struct drm_framebuffer;
38
39
40#define DRM_MODE_OBJECT_CRTC 0xcccccccc
41#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
42#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
43#define DRM_MODE_OBJECT_MODE 0xdededede
44#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
45#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
46#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
47
48struct drm_mode_object {
49 uint32_t id;
50 uint32_t type;
51};
52
53/*
54 * Note on terminology: here, for brevity and convenience, we refer to connector
55 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
56 * DVI, etc. And 'screen' refers to the whole of the visible display, which
57 * may span multiple monitors (and therefore multiple CRTC and connector
58 * structures).
59 */
60
61enum drm_mode_status {
62 MODE_OK = 0, /* Mode OK */
63 MODE_HSYNC, /* hsync out of range */
64 MODE_VSYNC, /* vsync out of range */
65 MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
66 MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
67 MODE_BAD_WIDTH, /* requires an unsupported linepitch */
68 MODE_NOMODE, /* no mode with a maching name */
69 MODE_NO_INTERLACE, /* interlaced mode not supported */
70 MODE_NO_DBLESCAN, /* doublescan mode not supported */
71 MODE_NO_VSCAN, /* multiscan mode not supported */
72 MODE_MEM, /* insufficient video memory */
73 MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
74 MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
75 MODE_MEM_VIRT, /* insufficient video memory given virtual size */
76 MODE_NOCLOCK, /* no fixed clock available */
77 MODE_CLOCK_HIGH, /* clock required is too high */
78 MODE_CLOCK_LOW, /* clock required is too low */
79 MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
80 MODE_BAD_HVALUE, /* horizontal timing was out of range */
81 MODE_BAD_VVALUE, /* vertical timing was out of range */
82 MODE_BAD_VSCAN, /* VScan value out of range */
83 MODE_HSYNC_NARROW, /* horizontal sync too narrow */
84 MODE_HSYNC_WIDE, /* horizontal sync too wide */
85 MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
86 MODE_HBLANK_WIDE, /* horizontal blanking too wide */
87 MODE_VSYNC_NARROW, /* vertical sync too narrow */
88 MODE_VSYNC_WIDE, /* vertical sync too wide */
89 MODE_VBLANK_NARROW, /* vertical blanking too narrow */
90 MODE_VBLANK_WIDE, /* vertical blanking too wide */
91 MODE_PANEL, /* exceeds panel dimensions */
92 MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
93 MODE_ONE_WIDTH, /* only one width is supported */
94 MODE_ONE_HEIGHT, /* only one height is supported */
95 MODE_ONE_SIZE, /* only one resolution is supported */
96 MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
97 MODE_UNVERIFIED = -3, /* mode needs to reverified */
98 MODE_BAD = -2, /* unspecified reason */
99 MODE_ERROR = -1 /* error condition */
100};
101
102#define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
103 DRM_MODE_TYPE_CRTC_C)
104
105#define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
106 .name = nm, .status = 0, .type = (t), .clock = (c), \
107 .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
108 .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
109 .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
110 .vscan = (vs), .flags = (f), .vrefresh = 0
111
112#define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
113
114struct drm_display_mode {
115 /* Header */
116 struct list_head head;
117 struct drm_mode_object base;
118
119 char name[DRM_DISPLAY_MODE_LEN];
120
121 int connector_count;
122 enum drm_mode_status status;
123 int type;
124
125 /* Proposed mode values */
126 int clock;
127 int hdisplay;
128 int hsync_start;
129 int hsync_end;
130 int htotal;
131 int hskew;
132 int vdisplay;
133 int vsync_start;
134 int vsync_end;
135 int vtotal;
136 int vscan;
137 unsigned int flags;
138
139 /* Addressable image size (may be 0 for projectors, etc.) */
140 int width_mm;
141 int height_mm;
142
143 /* Actual mode we give to hw */
144 int clock_index;
145 int synth_clock;
146 int crtc_hdisplay;
147 int crtc_hblank_start;
148 int crtc_hblank_end;
149 int crtc_hsync_start;
150 int crtc_hsync_end;
151 int crtc_htotal;
152 int crtc_hskew;
153 int crtc_vdisplay;
154 int crtc_vblank_start;
155 int crtc_vblank_end;
156 int crtc_vsync_start;
157 int crtc_vsync_end;
158 int crtc_vtotal;
159 int crtc_hadjusted;
160 int crtc_vadjusted;
161
162 /* Driver private mode info */
163 int private_size;
164 int *private;
165 int private_flags;
166
167 int vrefresh;
168 float hsync;
169};
170
171enum drm_connector_status {
172 connector_status_connected = 1,
173 connector_status_disconnected = 2,
174 connector_status_unknown = 3,
175};
176
177enum subpixel_order {
178 SubPixelUnknown = 0,
179 SubPixelHorizontalRGB,
180 SubPixelHorizontalBGR,
181 SubPixelVerticalRGB,
182 SubPixelVerticalBGR,
183 SubPixelNone,
184};
185
186
187/*
188 * Describes a given display (e.g. CRT or flat panel) and its limitations.
189 */
190struct drm_display_info {
191 char name[DRM_DISPLAY_INFO_LEN];
192 /* Input info */
193 bool serration_vsync;
194 bool sync_on_green;
195 bool composite_sync;
196 bool separate_syncs;
197 bool blank_to_black;
198 unsigned char video_level;
199 bool digital;
200 /* Physical size */
201 unsigned int width_mm;
202 unsigned int height_mm;
203
204 /* Display parameters */
205 unsigned char gamma; /* FIXME: storage format */
206 bool gtf_supported;
207 bool standard_color;
208 enum {
209 monochrome = 0,
210 rgb,
211 other,
212 unknown,
213 } display_type;
214 bool active_off_supported;
215 bool suspend_supported;
216 bool standby_supported;
217
218 /* Color info FIXME: storage format */
219 unsigned short redx, redy;
220 unsigned short greenx, greeny;
221 unsigned short bluex, bluey;
222 unsigned short whitex, whitey;
223
224 /* Clock limits FIXME: storage format */
225 unsigned int min_vfreq, max_vfreq;
226 unsigned int min_hfreq, max_hfreq;
227 unsigned int pixel_clock;
228
229 /* White point indices FIXME: storage format */
230 unsigned int wpx1, wpy1;
231 unsigned int wpgamma1;
232 unsigned int wpx2, wpy2;
233 unsigned int wpgamma2;
234
235 enum subpixel_order subpixel_order;
236
237 char *raw_edid; /* if any */
238};
239
240struct drm_framebuffer_funcs {
241 void (*destroy)(struct drm_framebuffer *framebuffer);
242 int (*create_handle)(struct drm_framebuffer *fb,
243 struct drm_file *file_priv,
244 unsigned int *handle);
245};
246
247struct drm_framebuffer {
248 struct drm_device *dev;
249 struct list_head head;
250 struct drm_mode_object base;
251 const struct drm_framebuffer_funcs *funcs;
252 unsigned int pitch;
253 unsigned int width;
254 unsigned int height;
255 /* depth can be 15 or 16 */
256 unsigned int depth;
257 int bits_per_pixel;
258 int flags;
259 void *fbdev;
260 u32 pseudo_palette[17];
261 struct list_head filp_head;
262};
263
264struct drm_property_blob {
265 struct drm_mode_object base;
266 struct list_head head;
267 unsigned int length;
268 void *data;
269};
270
271struct drm_property_enum {
272 uint64_t value;
273 struct list_head head;
274 char name[DRM_PROP_NAME_LEN];
275};
276
277struct drm_property {
278 struct list_head head;
279 struct drm_mode_object base;
280 uint32_t flags;
281 char name[DRM_PROP_NAME_LEN];
282 uint32_t num_values;
283 uint64_t *values;
284
285 struct list_head enum_blob_list;
286};
287
288struct drm_crtc;
289struct drm_connector;
290struct drm_encoder;
291
292/**
293 * drm_crtc_funcs - control CRTCs for a given device
294 * @dpms: control display power levels
295 * @save: save CRTC state
296 * @resore: restore CRTC state
297 * @lock: lock the CRTC
298 * @unlock: unlock the CRTC
299 * @shadow_allocate: allocate shadow pixmap
300 * @shadow_create: create shadow pixmap for rotation support
301 * @shadow_destroy: free shadow pixmap
302 * @mode_fixup: fixup proposed mode
303 * @mode_set: set the desired mode on the CRTC
304 * @gamma_set: specify color ramp for CRTC
305 * @destroy: deinit and free object.
306 *
307 * The drm_crtc_funcs structure is the central CRTC management structure
308 * in the DRM. Each CRTC controls one or more connectors (note that the name
309 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
310 * connectors, not just CRTs).
311 *
312 * Each driver is responsible for filling out this structure at startup time,
313 * in addition to providing other modesetting features, like i2c and DDC
314 * bus accessors.
315 */
316struct drm_crtc_funcs {
317 /* Save CRTC state */
318 void (*save)(struct drm_crtc *crtc); /* suspend? */
319 /* Restore CRTC state */
320 void (*restore)(struct drm_crtc *crtc); /* resume? */
321
322 /* cursor controls */
323 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
324 uint32_t handle, uint32_t width, uint32_t height);
325 int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
326
327 /* Set gamma on the CRTC */
328 void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
329 uint32_t size);
330 /* Object destroy routine */
331 void (*destroy)(struct drm_crtc *crtc);
332
333 int (*set_config)(struct drm_mode_set *set);
334};
335
336/**
337 * drm_crtc - central CRTC control structure
338 * @enabled: is this CRTC enabled?
339 * @x: x position on screen
340 * @y: y position on screen
341 * @desired_mode: new desired mode
342 * @desired_x: desired x for desired_mode
343 * @desired_y: desired y for desired_mode
344 * @funcs: CRTC control functions
345 *
346 * Each CRTC may have one or more connectors associated with it. This structure
347 * allows the CRTC to be controlled.
348 */
349struct drm_crtc {
350 struct drm_device *dev;
351 struct list_head head;
352
353 struct drm_mode_object base;
354
355 /* framebuffer the connector is currently bound to */
356 struct drm_framebuffer *fb;
357
358 bool enabled;
359
360 struct drm_display_mode mode;
361
362 int x, y;
363 struct drm_display_mode *desired_mode;
364 int desired_x, desired_y;
365 const struct drm_crtc_funcs *funcs;
366
367 /* CRTC gamma size for reporting to userspace */
368 uint32_t gamma_size;
369 uint16_t *gamma_store;
370
371 /* if you are using the helper */
372 void *helper_private;
373};
374
375
376/**
377 * drm_connector_funcs - control connectors on a given device
378 * @dpms: set power state (see drm_crtc_funcs above)
379 * @save: save connector state
380 * @restore: restore connector state
381 * @mode_valid: is this mode valid on the given connector?
382 * @mode_fixup: try to fixup proposed mode for this connector
383 * @mode_set: set this mode
384 * @detect: is this connector active?
385 * @get_modes: get mode list for this connector
386 * @set_property: property for this connector may need update
387 * @destroy: make object go away
388 *
389 * Each CRTC may have one or more connectors attached to it. The functions
390 * below allow the core DRM code to control connectors, enumerate available modes,
391 * etc.
392 */
393struct drm_connector_funcs {
394 void (*dpms)(struct drm_connector *connector, int mode);
395 void (*save)(struct drm_connector *connector);
396 void (*restore)(struct drm_connector *connector);
397 enum drm_connector_status (*detect)(struct drm_connector *connector);
398 void (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
399 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
400 uint64_t val);
401 void (*destroy)(struct drm_connector *connector);
402};
403
404struct drm_encoder_funcs {
405 void (*destroy)(struct drm_encoder *encoder);
406};
407
408#define DRM_CONNECTOR_MAX_UMODES 16
409#define DRM_CONNECTOR_MAX_PROPERTY 16
410#define DRM_CONNECTOR_LEN 32
411#define DRM_CONNECTOR_MAX_ENCODER 2
412
413/**
414 * drm_encoder - central DRM encoder structure
415 */
416struct drm_encoder {
417 struct drm_device *dev;
418 struct list_head head;
419
420 struct drm_mode_object base;
421 int encoder_type;
422 uint32_t possible_crtcs;
423 uint32_t possible_clones;
424
425 struct drm_crtc *crtc;
426 const struct drm_encoder_funcs *funcs;
427 void *helper_private;
428};
429
430/**
431 * drm_connector - central DRM connector control structure
432 * @crtc: CRTC this connector is currently connected to, NULL if none
433 * @interlace_allowed: can this connector handle interlaced modes?
434 * @doublescan_allowed: can this connector handle doublescan?
435 * @available_modes: modes available on this connector (from get_modes() + user)
436 * @initial_x: initial x position for this connector
437 * @initial_y: initial y position for this connector
438 * @status: connector connected?
439 * @funcs: connector control functions
440 *
441 * Each connector may be connected to one or more CRTCs, or may be clonable by
442 * another connector if they can share a CRTC. Each connector also has a specific
443 * position in the broader display (referred to as a 'screen' though it could
444 * span multiple monitors).
445 */
446struct drm_connector {
447 struct drm_device *dev;
448 struct device kdev;
449 struct device_attribute *attr;
450 struct list_head head;
451
452 struct drm_mode_object base;
453
454 int connector_type;
455 int connector_type_id;
456 bool interlace_allowed;
457 bool doublescan_allowed;
458 struct list_head modes; /* list of modes on this connector */
459
460 int initial_x, initial_y;
461 enum drm_connector_status status;
462
463 /* these are modes added by probing with DDC or the BIOS */
464 struct list_head probed_modes;
465
466 struct drm_display_info display_info;
467 const struct drm_connector_funcs *funcs;
468
469 struct list_head user_modes;
470 struct drm_property_blob *edid_blob_ptr;
471 u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
472 uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
473
474 void *helper_private;
475
476 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
477 uint32_t force_encoder_id;
478 struct drm_encoder *encoder; /* currently active encoder */
479};
480
481/**
482 * struct drm_mode_set
483 *
484 * Represents a single crtc the connectors that it drives with what mode
485 * and from which framebuffer it scans out from.
486 *
487 * This is used to set modes.
488 */
489struct drm_mode_set {
490 struct list_head head;
491
492 struct drm_framebuffer *fb;
493 struct drm_crtc *crtc;
494 struct drm_display_mode *mode;
495
496 uint32_t x;
497 uint32_t y;
498
499 struct drm_connector **connectors;
500 size_t num_connectors;
501};
502
503/**
504 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
505 * @resize: adjust CRTCs as necessary for the proposed layout
506 *
507 * Currently only a resize hook is available. DRM will call back into the
508 * driver with a new screen width and height. If the driver can't support
509 * the proposed size, it can return false. Otherwise it should adjust
510 * the CRTC<->connector mappings as needed and update its view of the screen.
511 */
512struct drm_mode_config_funcs {
513 int (*resize_fb)(struct drm_device *dev, struct drm_file *file_priv, struct drm_framebuffer *fb, struct drm_mode_fb_cmd *mode_cmd);
514 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
515 int (*fb_changed)(struct drm_device *dev);
516};
517
518struct drm_mode_group {
519 uint32_t num_crtcs;
520 uint32_t num_encoders;
521 uint32_t num_connectors;
522
523 /* list of object IDs for this group */
524 uint32_t *id_list;
525};
526
527/**
528 * drm_mode_config - Mode configuration control structure
529 *
530 */
531struct drm_mode_config {
532 struct mutex mutex; /* protects configuration and IDR */
533 struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
534 /* this is limited to one for now */
535 int num_fb;
536 struct list_head fb_list;
537 int num_connector;
538 struct list_head connector_list;
539 int num_encoder;
540 struct list_head encoder_list;
541
542 int num_crtc;
543 struct list_head crtc_list;
544
545 struct list_head property_list;
546
547 /* in-kernel framebuffers - hung of filp_head in drm_framebuffer */
548 struct list_head fb_kernel_list;
549
550 int min_width, min_height;
551 int max_width, max_height;
552 struct drm_mode_config_funcs *funcs;
553 unsigned long fb_base;
554
555 /* pointers to standard properties */
556 struct list_head property_blob_list;
557 struct drm_property *edid_property;
558 struct drm_property *dpms_property;
559
560 /* DVI-I properties */
561 struct drm_property *dvi_i_subconnector_property;
562 struct drm_property *dvi_i_select_subconnector_property;
563
564 /* TV properties */
565 struct drm_property *tv_subconnector_property;
566 struct drm_property *tv_select_subconnector_property;
567 struct drm_property *tv_mode_property;
568 struct drm_property *tv_left_margin_property;
569 struct drm_property *tv_right_margin_property;
570 struct drm_property *tv_top_margin_property;
571 struct drm_property *tv_bottom_margin_property;
572
573 /* Optional properties */
574 struct drm_property *scaling_mode_property;
575 struct drm_property *dithering_mode_property;
576
577 /* hotplug */
578 uint32_t hotplug_counter;
579};
580
581#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
582#define obj_to_connector(x) container_of(x, struct drm_connector, base)
583#define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
584#define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
585#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
586#define obj_to_property(x) container_of(x, struct drm_property, base)
587#define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
588
589
590extern void drm_crtc_init(struct drm_device *dev,
591 struct drm_crtc *crtc,
592 const struct drm_crtc_funcs *funcs);
593extern void drm_crtc_cleanup(struct drm_crtc *crtc);
594
595extern void drm_connector_init(struct drm_device *dev,
596 struct drm_connector *connector,
597 const struct drm_connector_funcs *funcs,
598 int connector_type);
599
600extern void drm_connector_cleanup(struct drm_connector *connector);
601
602extern void drm_encoder_init(struct drm_device *dev,
603 struct drm_encoder *encoder,
604 const struct drm_encoder_funcs *funcs,
605 int encoder_type);
606
607extern void drm_encoder_cleanup(struct drm_encoder *encoder);
608
609extern char *drm_get_connector_name(struct drm_connector *connector);
610extern char *drm_get_dpms_name(int val);
611extern char *drm_get_dvi_i_subconnector_name(int val);
612extern char *drm_get_dvi_i_select_name(int val);
613extern char *drm_get_tv_subconnector_name(int val);
614extern char *drm_get_tv_select_name(int val);
615extern void drm_fb_release(struct file *filp);
616extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
617extern struct edid *drm_get_edid(struct drm_connector *connector,
618 struct i2c_adapter *adapter);
619extern unsigned char *drm_do_probe_ddc_edid(struct i2c_adapter *adapter);
620extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
621extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
622extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
623extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
624 struct drm_display_mode *mode);
625extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
626extern void drm_mode_config_init(struct drm_device *dev);
627extern void drm_mode_config_cleanup(struct drm_device *dev);
628extern void drm_mode_set_name(struct drm_display_mode *mode);
629extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
630extern int drm_mode_width(struct drm_display_mode *mode);
631extern int drm_mode_height(struct drm_display_mode *mode);
632
633/* for us by fb module */
634extern int drm_mode_attachmode_crtc(struct drm_device *dev,
635 struct drm_crtc *crtc,
636 struct drm_display_mode *mode);
637extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
638
639extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
640extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
641extern void drm_mode_list_concat(struct list_head *head,
642 struct list_head *new);
643extern void drm_mode_validate_size(struct drm_device *dev,
644 struct list_head *mode_list,
645 int maxX, int maxY, int maxPitch);
646extern void drm_mode_prune_invalid(struct drm_device *dev,
647 struct list_head *mode_list, bool verbose);
648extern void drm_mode_sort(struct list_head *mode_list);
649extern int drm_mode_vrefresh(struct drm_display_mode *mode);
650extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
651 int adjust_flags);
652extern void drm_mode_connector_list_update(struct drm_connector *connector);
653extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
654 struct edid *edid);
655extern int drm_connector_property_set_value(struct drm_connector *connector,
656 struct drm_property *property,
657 uint64_t value);
658extern int drm_connector_property_get_value(struct drm_connector *connector,
659 struct drm_property *property,
660 uint64_t *value);
661extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
662extern void drm_framebuffer_set_object(struct drm_device *dev,
663 unsigned long handle);
664extern int drm_framebuffer_init(struct drm_device *dev,
665 struct drm_framebuffer *fb,
666 const struct drm_framebuffer_funcs *funcs);
667extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
668extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
669extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
670extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
671extern bool drm_crtc_in_use(struct drm_crtc *crtc);
672
673extern int drm_connector_attach_property(struct drm_connector *connector,
674 struct drm_property *property, uint64_t init_val);
675extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
676 const char *name, int num_values);
677extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
678extern int drm_property_add_enum(struct drm_property *property, int index,
679 uint64_t value, const char *name);
680extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
681extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
682 char *formats[]);
683extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
684extern int drm_mode_create_dithering_property(struct drm_device *dev);
685extern char *drm_get_encoder_name(struct drm_encoder *encoder);
686
687extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
688 struct drm_encoder *encoder);
689extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
690 struct drm_encoder *encoder);
691extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
692 int gamma_size);
693extern void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type);
694/* IOCTLs */
695extern int drm_mode_getresources(struct drm_device *dev,
696 void *data, struct drm_file *file_priv);
697
698extern int drm_mode_getcrtc(struct drm_device *dev,
699 void *data, struct drm_file *file_priv);
700extern int drm_mode_getconnector(struct drm_device *dev,
701 void *data, struct drm_file *file_priv);
702extern int drm_mode_setcrtc(struct drm_device *dev,
703 void *data, struct drm_file *file_priv);
704extern int drm_mode_cursor_ioctl(struct drm_device *dev,
705 void *data, struct drm_file *file_priv);
706extern int drm_mode_addfb(struct drm_device *dev,
707 void *data, struct drm_file *file_priv);
708extern int drm_mode_rmfb(struct drm_device *dev,
709 void *data, struct drm_file *file_priv);
710extern int drm_mode_getfb(struct drm_device *dev,
711 void *data, struct drm_file *file_priv);
712extern int drm_mode_addmode_ioctl(struct drm_device *dev,
713 void *data, struct drm_file *file_priv);
714extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
715 void *data, struct drm_file *file_priv);
716extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
717 void *data, struct drm_file *file_priv);
718extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
719 void *data, struct drm_file *file_priv);
720
721extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
722 void *data, struct drm_file *file_priv);
723extern int drm_mode_getblob_ioctl(struct drm_device *dev,
724 void *data, struct drm_file *file_priv);
725extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
726 void *data, struct drm_file *file_priv);
727extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
728 void *data, struct drm_file *file_priv);
729extern int drm_mode_replacefb(struct drm_device *dev,
730 void *data, struct drm_file *file_priv);
731extern int drm_mode_getencoder(struct drm_device *dev,
732 void *data, struct drm_file *file_priv);
733extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
734 void *data, struct drm_file *file_priv);
735extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
736 void *data, struct drm_file *file_priv);
737#endif /* __DRM_CRTC_H__ */
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
new file mode 100644
index 000000000000..a341828d1d15
--- /dev/null
+++ b/include/drm/drm_crtc_helper.h
@@ -0,0 +1,121 @@
1/*
2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26/*
27 * The DRM mode setting helper functions are common code for drivers to use if
28 * they wish. Drivers are not forced to use this code in their
29 * implementations but it would be useful if they code they do use at least
30 * provides a consistent interface and operation to userspace
31 */
32
33#ifndef __DRM_CRTC_HELPER_H__
34#define __DRM_CRTC_HELPER_H__
35
36#include <linux/i2c.h>
37#include <linux/spinlock.h>
38#include <linux/types.h>
39#include <linux/idr.h>
40
41#include <linux/fb.h>
42
43struct drm_crtc_helper_funcs {
44 /*
45 * Control power levels on the CRTC. If the mode passed in is
46 * unsupported, the provider must use the next lowest power level.
47 */
48 void (*dpms)(struct drm_crtc *crtc, int mode);
49 void (*prepare)(struct drm_crtc *crtc);
50 void (*commit)(struct drm_crtc *crtc);
51
52 /* Provider can fixup or change mode timings before modeset occurs */
53 bool (*mode_fixup)(struct drm_crtc *crtc,
54 struct drm_display_mode *mode,
55 struct drm_display_mode *adjusted_mode);
56 /* Actually set the mode */
57 void (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
58 struct drm_display_mode *adjusted_mode, int x, int y);
59
60 /* Move the crtc on the current fb to the given position *optional* */
61 void (*mode_set_base)(struct drm_crtc *crtc, int x, int y);
62};
63
64struct drm_encoder_helper_funcs {
65 void (*dpms)(struct drm_encoder *encoder, int mode);
66 void (*save)(struct drm_encoder *encoder);
67 void (*restore)(struct drm_encoder *encoder);
68
69 bool (*mode_fixup)(struct drm_encoder *encoder,
70 struct drm_display_mode *mode,
71 struct drm_display_mode *adjusted_mode);
72 void (*prepare)(struct drm_encoder *encoder);
73 void (*commit)(struct drm_encoder *encoder);
74 void (*mode_set)(struct drm_encoder *encoder,
75 struct drm_display_mode *mode,
76 struct drm_display_mode *adjusted_mode);
77 /* detect for DAC style encoders */
78 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
79 struct drm_connector *connector);
80};
81
82struct drm_connector_helper_funcs {
83 int (*get_modes)(struct drm_connector *connector);
84 int (*mode_valid)(struct drm_connector *connector,
85 struct drm_display_mode *mode);
86 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
87};
88
89extern void drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);
90extern void drm_helper_disable_unused_functions(struct drm_device *dev);
91extern int drm_helper_hotplug_stage_two(struct drm_device *dev);
92extern bool drm_helper_initial_config(struct drm_device *dev, bool can_grow);
93extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
94extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
95 struct drm_display_mode *mode,
96 int x, int y);
97extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
98
99extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
100 struct drm_mode_fb_cmd *mode_cmd);
101
102static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
103 const struct drm_crtc_helper_funcs *funcs)
104{
105 crtc->helper_private = (void *)funcs;
106}
107
108static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
109 const struct drm_encoder_helper_funcs *funcs)
110{
111 encoder->helper_private = (void *)funcs;
112}
113
114static inline void drm_connector_helper_add(struct drm_connector *connector,
115 const struct drm_connector_helper_funcs *funcs)
116{
117 connector->helper_private = (void *)funcs;
118}
119
120extern int drm_helper_resume_force_mode(struct drm_device *dev);
121#endif
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
new file mode 100644
index 000000000000..c707c15f5164
--- /dev/null
+++ b/include/drm/drm_edid.h
@@ -0,0 +1,202 @@
1/*
2 * Copyright © 2007-2008 Intel Corporation
3 * Jesse Barnes <jesse.barnes@intel.com>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 */
23#ifndef __DRM_EDID_H__
24#define __DRM_EDID_H__
25
26#include <linux/types.h>
27
28#define EDID_LENGTH 128
29#define DDC_ADDR 0x50
30
31#ifdef BIG_ENDIAN
32#error "EDID structure is little endian, need big endian versions"
33#else
34
35struct est_timings {
36 u8 t1;
37 u8 t2;
38 u8 mfg_rsvd;
39} __attribute__((packed));
40
41struct std_timing {
42 u8 hsize; /* need to multiply by 8 then add 248 */
43 u8 vfreq:6; /* need to add 60 */
44 u8 aspect_ratio:2; /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
45} __attribute__((packed));
46
47/* If detailed data is pixel timing */
48struct detailed_pixel_timing {
49 u8 hactive_lo;
50 u8 hblank_lo;
51 u8 hblank_hi:4;
52 u8 hactive_hi:4;
53 u8 vactive_lo;
54 u8 vblank_lo;
55 u8 vblank_hi:4;
56 u8 vactive_hi:4;
57 u8 hsync_offset_lo;
58 u8 hsync_pulse_width_lo;
59 u8 vsync_pulse_width_lo:4;
60 u8 vsync_offset_lo:4;
61 u8 hsync_pulse_width_hi:2;
62 u8 hsync_offset_hi:2;
63 u8 vsync_pulse_width_hi:2;
64 u8 vsync_offset_hi:2;
65 u8 width_mm_lo;
66 u8 height_mm_lo;
67 u8 height_mm_hi:4;
68 u8 width_mm_hi:4;
69 u8 hborder;
70 u8 vborder;
71 u8 unknown0:1;
72 u8 vsync_positive:1;
73 u8 hsync_positive:1;
74 u8 separate_sync:2;
75 u8 stereo:1;
76 u8 unknown6:1;
77 u8 interlaced:1;
78} __attribute__((packed));
79
80/* If it's not pixel timing, it'll be one of the below */
81struct detailed_data_string {
82 u8 str[13];
83} __attribute__((packed));
84
85struct detailed_data_monitor_range {
86 u8 min_vfreq;
87 u8 max_vfreq;
88 u8 min_hfreq_khz;
89 u8 max_hfreq_khz;
90 u8 pixel_clock_mhz; /* need to multiply by 10 */
91 u16 sec_gtf_toggle; /* A000=use above, 20=use below */ /* FIXME: byte order */
92 u8 hfreq_start_khz; /* need to multiply by 2 */
93 u8 c; /* need to divide by 2 */
94 u16 m; /* FIXME: byte order */
95 u8 k;
96 u8 j; /* need to divide by 2 */
97} __attribute__((packed));
98
99struct detailed_data_wpindex {
100 u8 white_y_lo:2;
101 u8 white_x_lo:2;
102 u8 pad:4;
103 u8 white_x_hi;
104 u8 white_y_hi;
105 u8 gamma; /* need to divide by 100 then add 1 */
106} __attribute__((packed));
107
108struct detailed_data_color_point {
109 u8 windex1;
110 u8 wpindex1[3];
111 u8 windex2;
112 u8 wpindex2[3];
113} __attribute__((packed));
114
115struct detailed_non_pixel {
116 u8 pad1;
117 u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
118 fb=color point data, fa=standard timing data,
119 f9=undefined, f8=mfg. reserved */
120 u8 pad2;
121 union {
122 struct detailed_data_string str;
123 struct detailed_data_monitor_range range;
124 struct detailed_data_wpindex color;
125 struct std_timing timings[5];
126 } data;
127} __attribute__((packed));
128
129#define EDID_DETAIL_STD_MODES 0xfa
130#define EDID_DETAIL_MONITOR_CPDATA 0xfb
131#define EDID_DETAIL_MONITOR_NAME 0xfc
132#define EDID_DETAIL_MONITOR_RANGE 0xfd
133#define EDID_DETAIL_MONITOR_STRING 0xfe
134#define EDID_DETAIL_MONITOR_SERIAL 0xff
135
136struct detailed_timing {
137 u16 pixel_clock; /* need to multiply by 10 KHz */ /* FIXME: byte order */
138 union {
139 struct detailed_pixel_timing pixel_data;
140 struct detailed_non_pixel other_data;
141 } data;
142} __attribute__((packed));
143
144struct edid {
145 u8 header[8];
146 /* Vendor & product info */
147 u8 mfg_id[2];
148 u8 prod_code[2];
149 u32 serial; /* FIXME: byte order */
150 u8 mfg_week;
151 u8 mfg_year;
152 /* EDID version */
153 u8 version;
154 u8 revision;
155 /* Display info: */
156 /* input definition */
157 u8 serration_vsync:1;
158 u8 sync_on_green:1;
159 u8 composite_sync:1;
160 u8 separate_syncs:1;
161 u8 blank_to_black:1;
162 u8 video_level:2;
163 u8 digital:1; /* bits below must be zero if set */
164 u8 width_cm;
165 u8 height_cm;
166 u8 gamma;
167 /* feature support */
168 u8 default_gtf:1;
169 u8 preferred_timing:1;
170 u8 standard_color:1;
171 u8 display_type:2; /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
172 u8 pm_active_off:1;
173 u8 pm_suspend:1;
174 u8 pm_standby:1;
175 /* Color characteristics */
176 u8 red_green_lo;
177 u8 black_white_lo;
178 u8 red_x;
179 u8 red_y;
180 u8 green_x;
181 u8 green_y;
182 u8 blue_x;
183 u8 blue_y;
184 u8 white_x;
185 u8 white_y;
186 /* Est. timings and mfg rsvd timings*/
187 struct est_timings established_timings;
188 /* Standard timings 1-8*/
189 struct std_timing standard_timings[8];
190 /* Detailing timings 1-4 */
191 struct detailed_timing detailed_timings[4];
192 /* Number of 128 byte ext. blocks */
193 u8 extensions;
194 /* Checksum */
195 u8 checksum;
196} __attribute__((packed));
197
198#endif /* little endian structs */
199
200#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
201
202#endif /* __DRM_EDID_H__ */
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
new file mode 100644
index 000000000000..d2e791920aba
--- /dev/null
+++ b/include/drm/drm_mode.h
@@ -0,0 +1,278 @@
1/*
2 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
3 * Copyright (c) 2007 Jakob Bornecrantz <wallbraker@gmail.com>
4 * Copyright (c) 2008 Red Hat Inc.
5 * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
6 * Copyright (c) 2007-2008 Intel Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * IN THE SOFTWARE.
25 */
26
27#ifndef _DRM_MODE_H
28#define _DRM_MODE_H
29
30#if !defined(__KERNEL__) && !defined(_KERNEL)
31#include <stdint.h>
32#else
33#include <linux/kernel.h>
34#endif
35
36#define DRM_DISPLAY_INFO_LEN 32
37#define DRM_CONNECTOR_NAME_LEN 32
38#define DRM_DISPLAY_MODE_LEN 32
39#define DRM_PROP_NAME_LEN 32
40
41#define DRM_MODE_TYPE_BUILTIN (1<<0)
42#define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
43#define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
44#define DRM_MODE_TYPE_PREFERRED (1<<3)
45#define DRM_MODE_TYPE_DEFAULT (1<<4)
46#define DRM_MODE_TYPE_USERDEF (1<<5)
47#define DRM_MODE_TYPE_DRIVER (1<<6)
48
49/* Video mode flags */
50/* bit compatible with the xorg definitions. */
51#define DRM_MODE_FLAG_PHSYNC (1<<0)
52#define DRM_MODE_FLAG_NHSYNC (1<<1)
53#define DRM_MODE_FLAG_PVSYNC (1<<2)
54#define DRM_MODE_FLAG_NVSYNC (1<<3)
55#define DRM_MODE_FLAG_INTERLACE (1<<4)
56#define DRM_MODE_FLAG_DBLSCAN (1<<5)
57#define DRM_MODE_FLAG_CSYNC (1<<6)
58#define DRM_MODE_FLAG_PCSYNC (1<<7)
59#define DRM_MODE_FLAG_NCSYNC (1<<8)
60#define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
61#define DRM_MODE_FLAG_BCAST (1<<10)
62#define DRM_MODE_FLAG_PIXMUX (1<<11)
63#define DRM_MODE_FLAG_DBLCLK (1<<12)
64#define DRM_MODE_FLAG_CLKDIV2 (1<<13)
65
66/* DPMS flags */
67/* bit compatible with the xorg definitions. */
68#define DRM_MODE_DPMS_ON 0
69#define DRM_MODE_DPMS_STANDBY 1
70#define DRM_MODE_DPMS_SUSPEND 2
71#define DRM_MODE_DPMS_OFF 3
72
73/* Scaling mode options */
74#define DRM_MODE_SCALE_NON_GPU 0
75#define DRM_MODE_SCALE_FULLSCREEN 1
76#define DRM_MODE_SCALE_NO_SCALE 2
77#define DRM_MODE_SCALE_ASPECT 3
78
79/* Dithering mode options */
80#define DRM_MODE_DITHERING_OFF 0
81#define DRM_MODE_DITHERING_ON 1
82
83struct drm_mode_modeinfo {
84 unsigned int clock;
85 unsigned short hdisplay, hsync_start, hsync_end, htotal, hskew;
86 unsigned short vdisplay, vsync_start, vsync_end, vtotal, vscan;
87
88 unsigned int vrefresh; /* vertical refresh * 1000 */
89
90 unsigned int flags;
91 unsigned int type;
92 char name[DRM_DISPLAY_MODE_LEN];
93};
94
95struct drm_mode_card_res {
96 uint64_t fb_id_ptr;
97 uint64_t crtc_id_ptr;
98 uint64_t connector_id_ptr;
99 uint64_t encoder_id_ptr;
100 int count_fbs;
101 int count_crtcs;
102 int count_connectors;
103 int count_encoders;
104 int min_width, max_width;
105 int min_height, max_height;
106};
107
108struct drm_mode_crtc {
109 uint64_t set_connectors_ptr;
110 int count_connectors;
111
112 unsigned int crtc_id; /**< Id */
113 unsigned int fb_id; /**< Id of framebuffer */
114
115 int x, y; /**< Position on the frameuffer */
116
117 uint32_t gamma_size;
118 int mode_valid;
119 struct drm_mode_modeinfo mode;
120};
121
122#define DRM_MODE_ENCODER_NONE 0
123#define DRM_MODE_ENCODER_DAC 1
124#define DRM_MODE_ENCODER_TMDS 2
125#define DRM_MODE_ENCODER_LVDS 3
126#define DRM_MODE_ENCODER_TVDAC 4
127
128struct drm_mode_get_encoder {
129 unsigned int encoder_id;
130 unsigned int encoder_type;
131
132 unsigned int crtc_id; /**< Id of crtc */
133
134 uint32_t possible_crtcs;
135 uint32_t possible_clones;
136};
137
138/* This is for connectors with multiple signal types. */
139/* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
140#define DRM_MODE_SUBCONNECTOR_Automatic 0
141#define DRM_MODE_SUBCONNECTOR_Unknown 0
142#define DRM_MODE_SUBCONNECTOR_DVID 3
143#define DRM_MODE_SUBCONNECTOR_DVIA 4
144#define DRM_MODE_SUBCONNECTOR_Composite 5
145#define DRM_MODE_SUBCONNECTOR_SVIDEO 6
146#define DRM_MODE_SUBCONNECTOR_Component 8
147
148#define DRM_MODE_CONNECTOR_Unknown 0
149#define DRM_MODE_CONNECTOR_VGA 1
150#define DRM_MODE_CONNECTOR_DVII 2
151#define DRM_MODE_CONNECTOR_DVID 3
152#define DRM_MODE_CONNECTOR_DVIA 4
153#define DRM_MODE_CONNECTOR_Composite 5
154#define DRM_MODE_CONNECTOR_SVIDEO 6
155#define DRM_MODE_CONNECTOR_LVDS 7
156#define DRM_MODE_CONNECTOR_Component 8
157#define DRM_MODE_CONNECTOR_9PinDIN 9
158#define DRM_MODE_CONNECTOR_DisplayPort 10
159#define DRM_MODE_CONNECTOR_HDMIA 11
160#define DRM_MODE_CONNECTOR_HDMIB 12
161
162struct drm_mode_get_connector {
163
164 uint64_t encoders_ptr;
165 uint64_t modes_ptr;
166 uint64_t props_ptr;
167 uint64_t prop_values_ptr;
168
169 int count_modes;
170 int count_props;
171 int count_encoders;
172
173 unsigned int encoder_id; /**< Current Encoder */
174 unsigned int connector_id; /**< Id */
175 unsigned int connector_type;
176 unsigned int connector_type_id;
177
178 unsigned int connection;
179 unsigned int mm_width, mm_height; /**< HxW in millimeters */
180 unsigned int subpixel;
181};
182
183#define DRM_MODE_PROP_PENDING (1<<0)
184#define DRM_MODE_PROP_RANGE (1<<1)
185#define DRM_MODE_PROP_IMMUTABLE (1<<2)
186#define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
187#define DRM_MODE_PROP_BLOB (1<<4)
188
189struct drm_mode_property_enum {
190 uint64_t value;
191 unsigned char name[DRM_PROP_NAME_LEN];
192};
193
194struct drm_mode_get_property {
195 uint64_t values_ptr; /* values and blob lengths */
196 uint64_t enum_blob_ptr; /* enum and blob id ptrs */
197
198 unsigned int prop_id;
199 unsigned int flags;
200 unsigned char name[DRM_PROP_NAME_LEN];
201
202 int count_values;
203 int count_enum_blobs;
204};
205
206struct drm_mode_connector_set_property {
207 uint64_t value;
208 unsigned int prop_id;
209 unsigned int connector_id;
210};
211
212struct drm_mode_get_blob {
213 uint32_t blob_id;
214 uint32_t length;
215 uint64_t data;
216};
217
218struct drm_mode_fb_cmd {
219 unsigned int buffer_id;
220 unsigned int width, height;
221 unsigned int pitch;
222 unsigned int bpp;
223 unsigned int depth;
224
225 unsigned int handle;
226};
227
228struct drm_mode_mode_cmd {
229 unsigned int connector_id;
230 struct drm_mode_modeinfo mode;
231};
232
233#define DRM_MODE_CURSOR_BO 0x01
234#define DRM_MODE_CURSOR_MOVE 0x02
235
236/*
237 * depending on the value in flags diffrent members are used.
238 *
239 * CURSOR_BO uses
240 * crtc
241 * width
242 * height
243 * handle - if 0 turns the cursor of
244 *
245 * CURSOR_MOVE uses
246 * crtc
247 * x
248 * y
249 */
250struct drm_mode_cursor {
251 unsigned int flags;
252 unsigned int crtc;
253 int x;
254 int y;
255 uint32_t width;
256 uint32_t height;
257 unsigned int handle;
258};
259
260/*
261 * oh so ugly hotplug
262 */
263struct drm_mode_hotplug {
264 uint32_t counter;
265};
266
267struct drm_mode_crtc_lut {
268
269 uint32_t crtc_id;
270 uint32_t gamma_size;
271
272 /* pointers to arrays */
273 uint64_t red;
274 uint64_t green;
275 uint64_t blue;
276};
277
278#endif
diff --git a/include/linux/console.h b/include/linux/console.h
index 248e6e3b9b73..a67a90cf8268 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -153,4 +153,8 @@ void vcs_remove_sysfs(struct tty_struct *tty);
153#define VESA_HSYNC_SUSPEND 2 153#define VESA_HSYNC_SUSPEND 2
154#define VESA_POWERDOWN 3 154#define VESA_POWERDOWN 3
155 155
156#ifdef CONFIG_VGA_CONSOLE
157extern bool vgacon_text_force(void);
158#endif
159
156#endif /* _LINUX_CONSOLE_H */ 160#endif /* _LINUX_CONSOLE_H */