Skip to content

Commit 79e5394

Browse files
jbarnes993airlied
authored andcommitted
DRM: i915: add mode setting support
This commit adds i915 driver support for the DRM mode setting APIs. Currently, VGA, LVDS, SDVO DVI & VGA, TV and DVO LVDS outputs are supported. HDMI, DisplayPort and additional SDVO output support will follow. Support for the mode setting code is controlled by the new 'modeset' module option. A new config option, CONFIG_DRM_I915_KMS controls the default behavior, and whether a PCI ID list is built into the module for use by user level module utilities. Note that if mode setting is enabled, user level drivers that access display registers directly or that don't use the kernel graphics memory manager will likely corrupt kernel graphics memory, disrupt output configuration (possibly leading to hangs and/or blank displays), and prevent panic/oops messages from appearing. So use caution when enabling this code; be sure your user level code supports the new interfaces. A new SysRq key, 'g', provides emergency support for switching back to the kernel's framebuffer console; which is useful for testing. Co-authors: Dave Airlie <airlied@linux.ie>, Hong Liu <hong.liu@intel.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>
1 parent f453ba0 commit 79e5394

27 files changed

+10567
-51
lines changed

drivers/gpu/drm/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ config DRM_I915
7676

7777
endchoice
7878

79+
config DRM_I915_KMS
80+
bool "Enable modesetting on intel by default"
81+
depends on DRM_I915
82+
help
83+
Choose this option if you want kernel modesetting enabled by default,
84+
and you have a new enough userspace to support this. Running old
85+
userspaces with this enabled will cause pain. Note that this causes
86+
the driver to bind to PCI devices, which precludes loading things
87+
like intelfb.
88+
89+
7990
config DRM_MGA
8091
tristate "Matrox g200/g400"
8192
depends on DRM

drivers/gpu/drm/i915/Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
88
i915_gem.o \
99
i915_gem_debug.o \
1010
i915_gem_proc.o \
11-
i915_gem_tiling.o
11+
i915_gem_tiling.o \
12+
intel_display.o \
13+
intel_crt.o \
14+
intel_lvds.o \
15+
intel_bios.o \
16+
intel_sdvo.o \
17+
intel_modes.o \
18+
intel_i2c.o \
19+
intel_fb.o \
20+
intel_tv.o \
21+
intel_dvo.o \
22+
dvo_ch7xxx.o \
23+
dvo_ch7017.o \
24+
dvo_ivch.o \
25+
dvo_tfp410.o \
26+
dvo_sil164.o
1227

1328
i915-$(CONFIG_ACPI) += i915_opregion.o
1429
i915-$(CONFIG_COMPAT) += i915_ioc32.o

drivers/gpu/drm/i915/dvo.h

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*
2+
* Copyright © 2006 Eric Anholt
3+
*
4+
* Permission to use, copy, modify, distribute, and sell this software and its
5+
* documentation for any purpose is hereby granted without fee, provided that
6+
* the above copyright notice appear in all copies and that both that copyright
7+
* notice and this permission notice appear in supporting documentation, and
8+
* that the name of the copyright holders not be used in advertising or
9+
* publicity pertaining to distribution of the software without specific,
10+
* written prior permission. The copyright holders make no representations
11+
* about the suitability of this software for any purpose. It is provided "as
12+
* is" without express or implied warranty.
13+
*
14+
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15+
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16+
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17+
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18+
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19+
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20+
* OF THIS SOFTWARE.
21+
*/
22+
23+
#ifndef _INTEL_DVO_H
24+
#define _INTEL_DVO_H
25+
26+
#include <linux/i2c.h>
27+
#include "drmP.h"
28+
#include "drm.h"
29+
#include "drm_crtc.h"
30+
#include "intel_drv.h"
31+
32+
struct intel_dvo_device {
33+
char *name;
34+
int type;
35+
/* DVOA/B/C output register */
36+
u32 dvo_reg;
37+
/* GPIO register used for i2c bus to control this device */
38+
u32 gpio;
39+
int slave_addr;
40+
struct intel_i2c_chan *i2c_bus;
41+
42+
const struct intel_dvo_dev_ops *dev_ops;
43+
void *dev_priv;
44+
45+
struct drm_display_mode *panel_fixed_mode;
46+
bool panel_wants_dither;
47+
};
48+
49+
struct intel_dvo_dev_ops {
50+
/*
51+
* Initialize the device at startup time.
52+
* Returns NULL if the device does not exist.
53+
*/
54+
bool (*init)(struct intel_dvo_device *dvo,
55+
struct intel_i2c_chan *i2cbus);
56+
57+
/*
58+
* Called to allow the output a chance to create properties after the
59+
* RandR objects have been created.
60+
*/
61+
void (*create_resources)(struct intel_dvo_device *dvo);
62+
63+
/*
64+
* Turn on/off output or set intermediate power levels if available.
65+
*
66+
* Unsupported intermediate modes drop to the lower power setting.
67+
* If the mode is DPMSModeOff, the output must be disabled,
68+
* as the DPLL may be disabled afterwards.
69+
*/
70+
void (*dpms)(struct intel_dvo_device *dvo, int mode);
71+
72+
/*
73+
* Saves the output's state for restoration on VT switch.
74+
*/
75+
void (*save)(struct intel_dvo_device *dvo);
76+
77+
/*
78+
* Restore's the output's state at VT switch.
79+
*/
80+
void (*restore)(struct intel_dvo_device *dvo);
81+
82+
/*
83+
* Callback for testing a video mode for a given output.
84+
*
85+
* This function should only check for cases where a mode can't
86+
* be supported on the output specifically, and not represent
87+
* generic CRTC limitations.
88+
*
89+
* \return MODE_OK if the mode is valid, or another MODE_* otherwise.
90+
*/
91+
int (*mode_valid)(struct intel_dvo_device *dvo,
92+
struct drm_display_mode *mode);
93+
94+
/*
95+
* Callback to adjust the mode to be set in the CRTC.
96+
*
97+
* This allows an output to adjust the clock or even the entire set of
98+
* timings, which is used for panels with fixed timings or for
99+
* buses with clock limitations.
100+
*/
101+
bool (*mode_fixup)(struct intel_dvo_device *dvo,
102+
struct drm_display_mode *mode,
103+
struct drm_display_mode *adjusted_mode);
104+
105+
/*
106+
* Callback for preparing mode changes on an output
107+
*/
108+
void (*prepare)(struct intel_dvo_device *dvo);
109+
110+
/*
111+
* Callback for committing mode changes on an output
112+
*/
113+
void (*commit)(struct intel_dvo_device *dvo);
114+
115+
/*
116+
* Callback for setting up a video mode after fixups have been made.
117+
*
118+
* This is only called while the output is disabled. The dpms callback
119+
* must be all that's necessary for the output, to turn the output on
120+
* after this function is called.
121+
*/
122+
void (*mode_set)(struct intel_dvo_device *dvo,
123+
struct drm_display_mode *mode,
124+
struct drm_display_mode *adjusted_mode);
125+
126+
/*
127+
* Probe for a connected output, and return detect_status.
128+
*/
129+
enum drm_connector_status (*detect)(struct intel_dvo_device *dvo);
130+
131+
/**
132+
* Query the device for the modes it provides.
133+
*
134+
* This function may also update MonInfo, mm_width, and mm_height.
135+
*
136+
* \return singly-linked list of modes or NULL if no modes found.
137+
*/
138+
struct drm_display_mode *(*get_modes)(struct intel_dvo_device *dvo);
139+
140+
/**
141+
* Clean up driver-specific bits of the output
142+
*/
143+
void (*destroy) (struct intel_dvo_device *dvo);
144+
145+
/**
146+
* Debugging hook to dump device registers to log file
147+
*/
148+
void (*dump_regs)(struct intel_dvo_device *dvo);
149+
};
150+
151+
#endif /* _INTEL_DVO_H */

0 commit comments

Comments
 (0)