aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/EDID/1024x768.S44
-rw-r--r--Documentation/EDID/1280x1024.S44
-rw-r--r--Documentation/EDID/1680x1050.S44
-rw-r--r--Documentation/EDID/1920x1080.S44
-rw-r--r--Documentation/EDID/HOWTO.txt39
-rw-r--r--Documentation/EDID/Makefile26
-rw-r--r--Documentation/EDID/edid.S261
-rw-r--r--Documentation/EDID/hex1
-rw-r--r--Documentation/kernel-parameters.txt15
-rw-r--r--drivers/gpu/drm/Kconfig12
-rw-r--r--drivers/gpu/drm/Makefile1
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c8
-rw-r--r--drivers/gpu/drm/drm_edid.c4
-rw-r--r--drivers/gpu/drm/drm_edid_load.c250
-rw-r--r--include/drm/drm_crtc.h1
-rw-r--r--include/drm/drm_edid.h1
16 files changed, 792 insertions, 3 deletions
diff --git a/Documentation/EDID/1024x768.S b/Documentation/EDID/1024x768.S
new file mode 100644
index 000000000000..4b486fe31b32
--- /dev/null
+++ b/Documentation/EDID/1024x768.S
@@ -0,0 +1,44 @@
1/*
2 1024x768.S: EDID data set for standard 1024x768 60 Hz monitor
3
4 Copyright (C) 2011 Carsten Emde <C.Emde@osadl.org>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21/* EDID */
22#define VERSION 1
23#define REVISION 3
24
25/* Display */
26#define CLOCK 65000 /* kHz */
27#define XPIX 1024
28#define YPIX 768
29#define XY_RATIO XY_RATIO_4_3
30#define XBLANK 320
31#define YBLANK 38
32#define XOFFSET 8
33#define XPULSE 144
34#define YOFFSET (63+3)
35#define YPULSE (63+6)
36#define DPI 72
37#define VFREQ 60 /* Hz */
38#define TIMING_NAME "Linux XGA"
39#define ESTABLISHED_TIMINGS_BITS 0x08 /* Bit 3 -> 1024x768 @60 Hz */
40#define HSYNC_POL 0
41#define VSYNC_POL 0
42#define CRC 0x55
43
44#include "edid.S"
diff --git a/Documentation/EDID/1280x1024.S b/Documentation/EDID/1280x1024.S
new file mode 100644
index 000000000000..a2799fe33a4d
--- /dev/null
+++ b/Documentation/EDID/1280x1024.S
@@ -0,0 +1,44 @@
1/*
2 1280x1024.S: EDID data set for standard 1280x1024 60 Hz monitor
3
4 Copyright (C) 2011 Carsten Emde <C.Emde@osadl.org>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21/* EDID */
22#define VERSION 1
23#define REVISION 3
24
25/* Display */
26#define CLOCK 108000 /* kHz */
27#define XPIX 1280
28#define YPIX 1024
29#define XY_RATIO XY_RATIO_5_4
30#define XBLANK 408
31#define YBLANK 42
32#define XOFFSET 48
33#define XPULSE 112
34#define YOFFSET (63+1)
35#define YPULSE (63+3)
36#define DPI 72
37#define VFREQ 60 /* Hz */
38#define TIMING_NAME "Linux SXGA"
39#define ESTABLISHED_TIMINGS_BITS 0x00 /* none */
40#define HSYNC_POL 1
41#define VSYNC_POL 1
42#define CRC 0xa0
43
44#include "edid.S"
diff --git a/Documentation/EDID/1680x1050.S b/Documentation/EDID/1680x1050.S
new file mode 100644
index 000000000000..96f67cafcf2e
--- /dev/null
+++ b/Documentation/EDID/1680x1050.S
@@ -0,0 +1,44 @@
1/*
2 1680x1050.S: EDID data set for standard 1680x1050 60 Hz monitor
3
4 Copyright (C) 2012 Carsten Emde <C.Emde@osadl.org>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21/* EDID */
22#define VERSION 1
23#define REVISION 3
24
25/* Display */
26#define CLOCK 146250 /* kHz */
27#define XPIX 1680
28#define YPIX 1050
29#define XY_RATIO XY_RATIO_16_10
30#define XBLANK 560
31#define YBLANK 39
32#define XOFFSET 104
33#define XPULSE 176
34#define YOFFSET (63+3)
35#define YPULSE (63+6)
36#define DPI 96
37#define VFREQ 60 /* Hz */
38#define TIMING_NAME "Linux WSXGA"
39#define ESTABLISHED_TIMINGS_BITS 0x00 /* none */
40#define HSYNC_POL 1
41#define VSYNC_POL 1
42#define CRC 0x26
43
44#include "edid.S"
diff --git a/Documentation/EDID/1920x1080.S b/Documentation/EDID/1920x1080.S
new file mode 100644
index 000000000000..36ed5d571d0a
--- /dev/null
+++ b/Documentation/EDID/1920x1080.S
@@ -0,0 +1,44 @@
1/*
2 1920x1080.S: EDID data set for standard 1920x1080 60 Hz monitor
3
4 Copyright (C) 2012 Carsten Emde <C.Emde@osadl.org>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21/* EDID */
22#define VERSION 1
23#define REVISION 3
24
25/* Display */
26#define CLOCK 148500 /* kHz */
27#define XPIX 1920
28#define YPIX 1080
29#define XY_RATIO XY_RATIO_16_9
30#define XBLANK 280
31#define YBLANK 45
32#define XOFFSET 88
33#define XPULSE 44
34#define YOFFSET (63+4)
35#define YPULSE (63+5)
36#define DPI 96
37#define VFREQ 60 /* Hz */
38#define TIMING_NAME "Linux FHD"
39#define ESTABLISHED_TIMINGS_BITS 0x00 /* none */
40#define HSYNC_POL 1
41#define VSYNC_POL 1
42#define CRC 0x05
43
44#include "edid.S"
diff --git a/Documentation/EDID/HOWTO.txt b/Documentation/EDID/HOWTO.txt
new file mode 100644
index 000000000000..75a9f2a0c43d
--- /dev/null
+++ b/Documentation/EDID/HOWTO.txt
@@ -0,0 +1,39 @@
1In the good old days when graphics parameters were configured explicitly
2in a file called xorg.conf, even broken hardware could be managed.
3
4Today, with the advent of Kernel Mode Setting, a graphics board is
5either correctly working because all components follow the standards -
6or the computer is unusable, because the screen remains dark after
7booting or it displays the wrong area. Cases when this happens are:
8- The graphics board does not recognize the monitor.
9- The graphics board is unable to detect any EDID data.
10- The graphics board incorrectly forwards EDID data to the driver.
11- The monitor sends no or bogus EDID data.
12- A KVM sends its own EDID data instead of querying the connected monitor.
13Adding the kernel parameter "nomodeset" helps in most cases, but causes
14restrictions later on.
15
16As a remedy for such situations, the kernel configuration item
17CONFIG_DRM_LOAD_EDID_FIRMWARE was introduced. It allows to provide an
18individually prepared or corrected EDID data set in the /lib/firmware
19directory from where it is loaded via the firmware interface. The code
20(see drivers/gpu/drm/drm_edid_load.c) contains built-in data sets for
21commonly used screen resolutions (1024x768, 1280x1024, 1680x1050,
221920x1080) as binary blobs, but the kernel source tree does not contain
23code to create these data. In order to elucidate the origin of the
24built-in binary EDID blobs and to facilitate the creation of individual
25data for a specific misbehaving monitor, commented sources and a
26Makefile environment are given here.
27
28To create binary EDID and C source code files from the existing data
29material, simply type "make".
30
31If you want to create your own EDID file, copy the file 1024x768.S and
32replace the settings with your own data. The CRC value in the last line
33 #define CRC 0x55
34is a bit tricky. After a first version of the binary data set is
35created, it must be be checked with the "edid-decode" utility which will
36most probably complain about a wrong CRC. Fortunately, the utility also
37displays the correct CRC which must then be inserted into the source
38file. After the make procedure is repeated, the EDID data set is ready
39to be used.
diff --git a/Documentation/EDID/Makefile b/Documentation/EDID/Makefile
new file mode 100644
index 000000000000..17763ca3f12b
--- /dev/null
+++ b/Documentation/EDID/Makefile
@@ -0,0 +1,26 @@
1
2SOURCES := $(wildcard [0-9]*x[0-9]*.S)
3
4BIN := $(patsubst %.S, %.bin, $(SOURCES))
5
6IHEX := $(patsubst %.S, %.bin.ihex, $(SOURCES))
7
8CODE := $(patsubst %.S, %.c, $(SOURCES))
9
10all: $(BIN) $(IHEX) $(CODE)
11
12clean:
13 @rm -f *.o *.bin.ihex *.bin *.c
14
15%.o: %.S
16 @cc -c $^
17
18%.bin: %.o
19 @objcopy -Obinary $^ $@
20
21%.bin.ihex: %.o
22 @objcopy -Oihex $^ $@
23 @dos2unix $@ 2>/dev/null
24
25%.c: %.bin
26 @echo "{" >$@; hexdump -f hex $^ >>$@; echo "};" >>$@
diff --git a/Documentation/EDID/edid.S b/Documentation/EDID/edid.S
new file mode 100644
index 000000000000..ea97ae275fca
--- /dev/null
+++ b/Documentation/EDID/edid.S
@@ -0,0 +1,261 @@
1/*
2 edid.S: EDID data template
3
4 Copyright (C) 2012 Carsten Emde <C.Emde@osadl.org>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21
22/* Manufacturer */
23#define MFG_LNX1 'L'
24#define MFG_LNX2 'N'
25#define MFG_LNX3 'X'
26#define SERIAL 0
27#define YEAR 2012
28#define WEEK 5
29
30/* EDID 1.3 standard definitions */
31#define XY_RATIO_16_10 0b00
32#define XY_RATIO_4_3 0b01
33#define XY_RATIO_5_4 0b10
34#define XY_RATIO_16_9 0b11
35
36#define mfgname2id(v1,v2,v3) \
37 ((((v1-'@')&0x1f)<<10)+(((v2-'@')&0x1f)<<5)+((v3-'@')&0x1f))
38#define swap16(v1) ((v1>>8)+((v1&0xff)<<8))
39#define msbs2(v1,v2) ((((v1>>8)&0x0f)<<4)+((v2>>8)&0x0f))
40#define msbs4(v1,v2,v3,v4) \
41 (((v1&0x03)>>2)+((v2&0x03)>>4)+((v3&0x03)>>6)+((v4&0x03)>>8))
42#define pixdpi2mm(pix,dpi) ((pix*25)/dpi)
43#define xsize pixdpi2mm(XPIX,DPI)
44#define ysize pixdpi2mm(YPIX,DPI)
45
46 .data
47
48/* Fixed header pattern */
49header: .byte 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00
50
51mfg_id: .word swap16(mfgname2id(MFG_LNX1, MFG_LNX2, MFG_LNX3))
52
53prod_code: .word 0
54
55/* Serial number. 32 bits, little endian. */
56serial_number: .long SERIAL
57
58/* Week of manufacture */
59week: .byte WEEK
60
61/* Year of manufacture, less 1990. (1990-2245)
62 If week=255, it is the model year instead */
63year: .byte YEAR-1990
64
65version: .byte VERSION /* EDID version, usually 1 (for 1.3) */
66revision: .byte REVISION /* EDID revision, usually 3 (for 1.3) */
67
68/* If Bit 7=1 Digital input. If set, the following bit definitions apply:
69 Bits 6-1 Reserved, must be 0
70 Bit 0 Signal is compatible with VESA DFP 1.x TMDS CRGB,
71 1 pixel per clock, up to 8 bits per color, MSB aligned,
72 If Bit 7=0 Analog input. If clear, the following bit definitions apply:
73 Bits 6-5 Video white and sync levels, relative to blank
74 00=+0.7/-0.3 V; 01=+0.714/-0.286 V;
75 10=+1.0/-0.4 V; 11=+0.7/0 V
76 Bit 4 Blank-to-black setup (pedestal) expected
77 Bit 3 Separate sync supported
78 Bit 2 Composite sync (on HSync) supported
79 Bit 1 Sync on green supported
80 Bit 0 VSync pulse must be serrated when somposite or
81 sync-on-green is used. */
82video_parms: .byte 0x6d
83
84/* Maximum horizontal image size, in centimetres
85 (max 292 cm/115 in at 16:9 aspect ratio) */
86max_hor_size: .byte xsize/10
87
88/* Maximum vertical image size, in centimetres.
89 If either byte is 0, undefined (e.g. projector) */
90max_vert_size: .byte ysize/10
91
92/* Display gamma, minus 1, times 100 (range 1.00-3.5 */
93gamma: .byte 120
94
95/* Bit 7 DPMS standby supported
96 Bit 6 DPMS suspend supported
97 Bit 5 DPMS active-off supported
98 Bits 4-3 Display type: 00=monochrome; 01=RGB colour;
99 10=non-RGB multicolour; 11=undefined
100 Bit 2 Standard sRGB colour space. Bytes 25-34 must contain
101 sRGB standard values.
102 Bit 1 Preferred timing mode specified in descriptor block 1.
103 Bit 0 GTF supported with default parameter values. */
104dsp_features: .byte 0xea
105
106/* Chromaticity coordinates. */
107/* Red and green least-significant bits
108 Bits 7-6 Red x value least-significant 2 bits
109 Bits 5-4 Red y value least-significant 2 bits
110 Bits 3-2 Green x value lst-significant 2 bits
111 Bits 1-0 Green y value least-significant 2 bits */
112red_green_lsb: .byte 0x5e
113
114/* Blue and white least-significant 2 bits */
115blue_white_lsb: .byte 0xc0
116
117/* Red x value most significant 8 bits.
118 0-255 encodes 0-0.996 (255/256); 0-0.999 (1023/1024) with lsbits */
119red_x_msb: .byte 0xa4
120
121/* Red y value most significant 8 bits */
122red_y_msb: .byte 0x59
123
124/* Green x and y value most significant 8 bits */
125green_x_y_msb: .byte 0x4a,0x98
126
127/* Blue x and y value most significant 8 bits */
128blue_x_y_msb: .byte 0x25,0x20
129
130/* Default white point x and y value most significant 8 bits */
131white_x_y_msb: .byte 0x50,0x54
132
133/* Established timings */
134/* Bit 7 720x400 @ 70 Hz
135 Bit 6 720x400 @ 88 Hz
136 Bit 5 640x480 @ 60 Hz
137 Bit 4 640x480 @ 67 Hz
138 Bit 3 640x480 @ 72 Hz
139 Bit 2 640x480 @ 75 Hz
140 Bit 1 800x600 @ 56 Hz
141 Bit 0 800x600 @ 60 Hz */
142estbl_timing1: .byte 0x00
143
144/* Bit 7 800x600 @ 72 Hz
145 Bit 6 800x600 @ 75 Hz
146 Bit 5 832x624 @ 75 Hz
147 Bit 4 1024x768 @ 87 Hz, interlaced (1024x768)
148 Bit 3 1024x768 @ 60 Hz
149 Bit 2 1024x768 @ 72 Hz
150 Bit 1 1024x768 @ 75 Hz
151 Bit 0 1280x1024 @ 75 Hz */
152estbl_timing2: .byte ESTABLISHED_TIMINGS_BITS
153
154/* Bit 7 1152x870 @ 75 Hz (Apple Macintosh II)
155 Bits 6-0 Other manufacturer-specific display mod */
156estbl_timing3: .byte 0x00
157
158/* Standard timing */
159/* X resolution, less 31, divided by 8 (256-2288 pixels) */
160std_xres: .byte (XPIX/8)-31
161/* Y resolution, X:Y pixel ratio
162 Bits 7-6 X:Y pixel ratio: 00=16:10; 01=4:3; 10=5:4; 11=16:9.
163 Bits 5-0 Vertical frequency, less 60 (60-123 Hz) */
164std_vres: .byte (XY_RATIO<<6)+VFREQ-60
165 .fill 7,2,0x0101 /* Unused */
166
167descriptor1:
168/* Pixel clock in 10 kHz units. (0.-655.35 MHz, little-endian) */
169clock: .word CLOCK/10
170
171/* Horizontal active pixels 8 lsbits (0-4095) */
172x_act_lsb: .byte XPIX&0xff
173/* Horizontal blanking pixels 8 lsbits (0-4095)
174 End of active to start of next active. */
175x_blk_lsb: .byte XBLANK&0xff
176/* Bits 7-4 Horizontal active pixels 4 msbits
177 Bits 3-0 Horizontal blanking pixels 4 msbits */
178x_msbs: .byte msbs2(XPIX,XBLANK)
179
180/* Vertical active lines 8 lsbits (0-4095) */
181y_act_lsb: .byte YPIX&0xff
182/* Vertical blanking lines 8 lsbits (0-4095) */
183y_blk_lsb: .byte YBLANK&0xff
184/* Bits 7-4 Vertical active lines 4 msbits
185 Bits 3-0 Vertical blanking lines 4 msbits */
186y_msbs: .byte msbs2(YPIX,YBLANK)
187
188/* Horizontal sync offset pixels 8 lsbits (0-1023) From blanking start */
189x_snc_off_lsb: .byte XOFFSET&0xff
190/* Horizontal sync pulse width pixels 8 lsbits (0-1023) */
191x_snc_pls_lsb: .byte XPULSE&0xff
192/* Bits 7-4 Vertical sync offset lines 4 lsbits -63)
193 Bits 3-0 Vertical sync pulse width lines 4 lsbits -63) */
194y_snc_lsb: .byte ((YOFFSET-63)<<4)+(YPULSE-63)
195/* Bits 7-6 Horizontal sync offset pixels 2 msbits
196 Bits 5-4 Horizontal sync pulse width pixels 2 msbits
197 Bits 3-2 Vertical sync offset lines 2 msbits
198 Bits 1-0 Vertical sync pulse width lines 2 msbits */
199xy_snc_msbs: .byte msbs4(XOFFSET,XPULSE,YOFFSET,YPULSE)
200
201/* Horizontal display size, mm, 8 lsbits (0-4095 mm, 161 in) */
202x_dsp_size: .byte xsize&0xff
203
204/* Vertical display size, mm, 8 lsbits (0-4095 mm, 161 in) */
205y_dsp_size: .byte ysize&0xff
206
207/* Bits 7-4 Horizontal display size, mm, 4 msbits
208 Bits 3-0 Vertical display size, mm, 4 msbits */
209dsp_size_mbsb: .byte msbs2(xsize,ysize)
210
211/* Horizontal border pixels (each side; total is twice this) */
212x_border: .byte 0
213/* Vertical border lines (each side; total is twice this) */
214y_border: .byte 0
215
216/* Bit 7 Interlaced
217 Bits 6-5 Stereo mode: 00=No stereo; other values depend on bit 0:
218 Bit 0=0: 01=Field sequential, sync=1 during right; 10=similar,
219 sync=1 during left; 11=4-way interleaved stereo
220 Bit 0=1 2-way interleaved stereo: 01=Right image on even lines;
221 10=Left image on even lines; 11=side-by-side
222 Bits 4-3 Sync type: 00=Analog composite; 01=Bipolar analog composite;
223 10=Digital composite (on HSync); 11=Digital separate
224 Bit 2 If digital separate: Vertical sync polarity (1=positive)
225 Other types: VSync serrated (HSync during VSync)
226 Bit 1 If analog sync: Sync on all 3 RGB lines (else green only)
227 Digital: HSync polarity (1=positive)
228 Bit 0 2-way line-interleaved stereo, if bits 4-3 are not 00. */
229features: .byte 0x18+(VSYNC_POL<<2)+(HSYNC_POL<<1)
230
231descriptor2: .byte 0,0 /* Not a detailed timing descriptor */
232 .byte 0 /* Must be zero */
233 .byte 0xff /* Descriptor is monitor serial number (text) */
234 .byte 0 /* Must be zero */
235start1: .ascii "Linux #0"
236end1: .byte 0x0a /* End marker */
237 .fill 12-(end1-start1), 1, 0x20 /* Padded spaces */
238descriptor3: .byte 0,0 /* Not a detailed timing descriptor */
239 .byte 0 /* Must be zero */
240 .byte 0xfd /* Descriptor is monitor range limits */
241 .byte 0 /* Must be zero */
242start2: .byte VFREQ-1 /* Minimum vertical field rate (1-255 Hz) */
243 .byte VFREQ+1 /* Maximum vertical field rate (1-255 Hz) */
244 .byte (CLOCK/(XPIX+XBLANK))-1 /* Minimum horizontal line rate
245 (1-255 kHz) */
246 .byte (CLOCK/(XPIX+XBLANK))+1 /* Maximum horizontal line rate
247 (1-255 kHz) */
248 .byte (CLOCK/10000)+1 /* Maximum pixel clock rate, rounded up
249 to 10 MHz multiple (10-2550 MHz) */
250 .byte 0 /* No extended timing information type */
251end2: .byte 0x0a /* End marker */
252 .fill 12-(end2-start2), 1, 0x20 /* Padded spaces */
253descriptor4: .byte 0,0 /* Not a detailed timing descriptor */
254 .byte 0 /* Must be zero */
255 .byte 0xfc /* Descriptor is text */
256 .byte 0 /* Must be zero */
257start3: .ascii TIMING_NAME
258end3: .byte 0x0a /* End marker */
259 .fill 12-(end3-start3), 1, 0x20 /* Padded spaces */
260extensions: .byte 0 /* Number of extensions to follow */
261checksum: .byte CRC /* Sum of all bytes must be 0 */
diff --git a/Documentation/EDID/hex b/Documentation/EDID/hex
new file mode 100644
index 000000000000..8873ebb618af
--- /dev/null
+++ b/Documentation/EDID/hex
@@ -0,0 +1 @@
"\t" 8/1 "0x%02x, " "\n"
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index d99fd9c0ec0e..7f084b764fb9 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -713,6 +713,21 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
713 The filter can be disabled or changed to another 713 The filter can be disabled or changed to another
714 driver later using sysfs. 714 driver later using sysfs.
715 715
716 drm_kms_helper.edid_firmware=[<connector>:]<file>
717 Broken monitors, graphic adapters and KVMs may
718 send no or incorrect EDID data sets. This parameter
719 allows to specify an EDID data set in the
720 /lib/firmware directory that is used instead.
721 Generic built-in EDID data sets are used, if one of
722 edid/1024x768.bin, edid/1280x1024.bin,
723 edid/1680x1050.bin, or edid/1920x1080.bin is given
724 and no file with the same name exists. Details and
725 instructions how to build your own EDID data are
726 available in Documentation/EDID/HOWTO.txt. An EDID
727 data set will only be used for a particular connector,
728 if its name and a colon are prepended to the EDID
729 name.
730
716 dscc4.setup= [NET] 731 dscc4.setup= [NET]
717 732
718 earlycon= [KNL] Output early console device and options. 733 earlycon= [KNL] Output early console device and options.
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 6b358d1dfb24..87ca18b82e15 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -32,6 +32,18 @@ config DRM_KMS_HELPER
32 help 32 help
33 FB and CRTC helpers for KMS drivers. 33 FB and CRTC helpers for KMS drivers.
34 34
35config DRM_LOAD_EDID_FIRMWARE
36 bool "Allow to specify an EDID data set instead of probing for it"
37 depends on DRM_KMS_HELPER
38 help
39 Say Y here, if you want to use EDID data to be loaded from the
40 /lib/firmware directory or one of the provided built-in
41 data sets. This may be necessary, if the graphics adapter or
42 monitor are unable to provide appropriate EDID data. Since this
43 feature is provided as a workaround for broken hardware, the
44 default case is N. Details and instructions how to build your own
45 EDID data are given in Documentation/EDID/HOWTO.txt.
46
35config DRM_TTM 47config DRM_TTM
36 tristate 48 tristate
37 depends on DRM 49 depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 3b8be8939bb6..a858532806ae 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -19,6 +19,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o
19drm-usb-y := drm_usb.o 19drm-usb-y := drm_usb.o
20 20
21drm_kms_helper-y := drm_fb_helper.o drm_crtc_helper.o drm_dp_i2c_helper.o 21drm_kms_helper-y := drm_fb_helper.o drm_crtc_helper.o drm_dp_i2c_helper.o
22drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
22 23
23obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o 24obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
24 25
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index d9d66846c610..81118893264c 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -37,6 +37,7 @@
37#include "drm_fourcc.h" 37#include "drm_fourcc.h"
38#include "drm_crtc_helper.h" 38#include "drm_crtc_helper.h"
39#include "drm_fb_helper.h" 39#include "drm_fb_helper.h"
40#include "drm_edid.h"
40 41
41static bool drm_kms_helper_poll = true; 42static bool drm_kms_helper_poll = true;
42module_param_named(poll, drm_kms_helper_poll, bool, 0600); 43module_param_named(poll, drm_kms_helper_poll, bool, 0600);
@@ -118,7 +119,12 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
118 goto prune; 119 goto prune;
119 } 120 }
120 121
121 count = (*connector_funcs->get_modes)(connector); 122#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
123 count = drm_load_edid_firmware(connector);
124 if (count == 0)
125#endif
126 count = (*connector_funcs->get_modes)(connector);
127
122 if (count == 0 && connector->status == connector_status_connected) 128 if (count == 0 && connector->status == connector_status_connected)
123 count = drm_add_modes_noedid(connector, 1024, 768); 129 count = drm_add_modes_noedid(connector, 1024, 768);
124 if (count == 0) 130 if (count == 0)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7ee7be1e5ce6..7a1434aeffc4 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -149,8 +149,7 @@ EXPORT_SYMBOL(drm_edid_header_is_valid);
149 * Sanity check the EDID block (base or extension). Return 0 if the block 149 * Sanity check the EDID block (base or extension). Return 0 if the block
150 * doesn't check out, or 1 if it's valid. 150 * doesn't check out, or 1 if it's valid.
151 */ 151 */
152static bool 152bool drm_edid_block_valid(u8 *raw_edid)
153drm_edid_block_valid(u8 *raw_edid)
154{ 153{
155 int i; 154 int i;
156 u8 csum = 0; 155 u8 csum = 0;
@@ -203,6 +202,7 @@ bad:
203 } 202 }
204 return 0; 203 return 0;
205} 204}
205EXPORT_SYMBOL(drm_edid_block_valid);
206 206
207/** 207/**
208 * drm_edid_is_valid - sanity check EDID data 208 * drm_edid_is_valid - sanity check EDID data
diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
new file mode 100644
index 000000000000..da9acba2dd6c
--- /dev/null
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -0,0 +1,250 @@
1/*
2 drm_edid_load.c: use a built-in EDID data set or load it via the firmware
3 interface
4
5 Copyright (C) 2012 Carsten Emde <C.Emde@osadl.org>
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20*/
21
22#include <linux/module.h>
23#include <linux/firmware.h>
24#include "drmP.h"
25#include "drm_crtc.h"
26#include "drm_crtc_helper.h"
27#include "drm_edid.h"
28
29static char edid_firmware[PATH_MAX];
30module_param_string(edid_firmware, edid_firmware, sizeof(edid_firmware), 0644);
31MODULE_PARM_DESC(edid_firmware, "Do not probe monitor, use specified EDID blob "
32 "from built-in data or /lib/firmware instead. ");
33
34#define GENERIC_EDIDS 4
35static char *generic_edid_name[GENERIC_EDIDS] = {
36 "edid/1024x768.bin",
37 "edid/1280x1024.bin",
38 "edid/1680x1050.bin",
39 "edid/1920x1080.bin",
40};
41
42static u8 generic_edid[GENERIC_EDIDS][128] = {
43 {
44 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
45 0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x05, 0x16, 0x01, 0x03, 0x6d, 0x23, 0x1a, 0x78,
47 0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
48 0x20, 0x50, 0x54, 0x00, 0x08, 0x00, 0x61, 0x40,
49 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
50 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x64, 0x19,
51 0x00, 0x40, 0x41, 0x00, 0x26, 0x30, 0x08, 0x90,
52 0x36, 0x00, 0x63, 0x0a, 0x11, 0x00, 0x00, 0x18,
53 0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
54 0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
55 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
56 0x3d, 0x2f, 0x31, 0x07, 0x00, 0x0a, 0x20, 0x20,
57 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
58 0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x58,
59 0x47, 0x41, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x55,
60 },
61 {
62 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
63 0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x05, 0x16, 0x01, 0x03, 0x6d, 0x2c, 0x23, 0x78,
65 0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
66 0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0x81, 0x80,
67 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
68 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x30, 0x2a,
69 0x00, 0x98, 0x51, 0x00, 0x2a, 0x40, 0x30, 0x70,
70 0x13, 0x00, 0xbc, 0x63, 0x11, 0x00, 0x00, 0x1e,
71 0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
72 0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
73 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
74 0x3d, 0x3e, 0x40, 0x0b, 0x00, 0x0a, 0x20, 0x20,
75 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
76 0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x53,
77 0x58, 0x47, 0x41, 0x0a, 0x20, 0x20, 0x00, 0xa0,
78 },
79 {
80 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
81 0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
82 0x05, 0x16, 0x01, 0x03, 0x6d, 0x2b, 0x1b, 0x78,
83 0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
84 0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0xb3, 0x00,
85 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
86 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x21, 0x39,
87 0x90, 0x30, 0x62, 0x1a, 0x27, 0x40, 0x68, 0xb0,
88 0x36, 0x00, 0xb5, 0x11, 0x11, 0x00, 0x00, 0x1e,
89 0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
90 0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
91 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
92 0x3d, 0x40, 0x42, 0x0f, 0x00, 0x0a, 0x20, 0x20,
93 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
94 0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x57,
95 0x53, 0x58, 0x47, 0x41, 0x0a, 0x20, 0x00, 0x26,
96 },
97 {
98 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
99 0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 0x05, 0x16, 0x01, 0x03, 0x6d, 0x32, 0x1c, 0x78,
101 0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
102 0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0xd1, 0xc0,
103 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
104 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a,
105 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
106 0x45, 0x00, 0xf4, 0x19, 0x11, 0x00, 0x00, 0x1e,
107 0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
108 0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
109 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
110 0x3d, 0x42, 0x44, 0x0f, 0x00, 0x0a, 0x20, 0x20,
111 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
112 0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x46,
113 0x48, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x05,
114 },
115};
116
117static int edid_load(struct drm_connector *connector, char *name,
118 char *connector_name)
119{
120 const struct firmware *fw;
121 struct platform_device *pdev;
122 u8 *fwdata = NULL, *edid;
123 int fwsize, expected;
124 int builtin = 0, err = 0;
125 int i, valid_extensions = 0;
126
127 pdev = platform_device_register_simple(connector_name, -1, NULL, 0);
128 if (IS_ERR(pdev)) {
129 DRM_ERROR("Failed to register EDID firmware platform device "
130 "for connector \"%s\"\n", connector_name);
131 err = -EINVAL;
132 goto out;
133 }
134
135 err = request_firmware(&fw, name, &pdev->dev);
136 platform_device_unregister(pdev);
137
138 if (err) {
139 i = 0;
140 while (i < GENERIC_EDIDS && strcmp(name, generic_edid_name[i]))
141 i++;
142 if (i < GENERIC_EDIDS) {
143 err = 0;
144 builtin = 1;
145 fwdata = generic_edid[i];
146 fwsize = sizeof(generic_edid[i]);
147 }
148 }
149
150 if (err) {
151 DRM_ERROR("Requesting EDID firmware \"%s\" failed (err=%d)\n",
152 name, err);
153 goto out;
154 }
155
156 if (fwdata == NULL) {
157 fwdata = (u8 *) fw->data;
158 fwsize = fw->size;
159 }
160
161 expected = (fwdata[0x7e] + 1) * EDID_LENGTH;
162 if (expected != fwsize) {
163 DRM_ERROR("Size of EDID firmware \"%s\" is invalid "
164 "(expected %d, got %d)\n", name, expected, (int) fwsize);
165 err = -EINVAL;
166 goto relfw_out;
167 }
168
169 edid = kmalloc(fwsize, GFP_KERNEL);
170 if (edid == NULL) {
171 err = -ENOMEM;
172 goto relfw_out;
173 }
174 memcpy(edid, fwdata, fwsize);
175
176 if (!drm_edid_block_valid(edid)) {
177 DRM_ERROR("Base block of EDID firmware \"%s\" is invalid ",
178 name);
179 kfree(edid);
180 err = -EINVAL;
181 goto relfw_out;
182 }
183
184 for (i = 1; i <= edid[0x7e]; i++) {
185 if (i != valid_extensions + 1)
186 memcpy(edid + (valid_extensions + 1) * EDID_LENGTH,
187 edid + i * EDID_LENGTH, EDID_LENGTH);
188 if (drm_edid_block_valid(edid + i * EDID_LENGTH))
189 valid_extensions++;
190 }
191
192 if (valid_extensions != edid[0x7e]) {
193 edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
194 DRM_INFO("Found %d valid extensions instead of %d in EDID data "
195 "\"%s\" for connector \"%s\"\n", valid_extensions,
196 edid[0x7e], name, connector_name);
197 edid[0x7e] = valid_extensions;
198 edid = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH,
199 GFP_KERNEL);
200 if (edid == NULL) {
201 err = -ENOMEM;
202 goto relfw_out;
203 }
204 }
205
206 connector->display_info.raw_edid = edid;
207 DRM_INFO("Got %s EDID base block and %d extension%s from "
208 "\"%s\" for connector \"%s\"\n", builtin ? "built-in" :
209 "external", valid_extensions, valid_extensions == 1 ? "" : "s",
210 name, connector_name);
211
212relfw_out:
213 release_firmware(fw);
214
215out:
216 return err;
217}
218
219int drm_load_edid_firmware(struct drm_connector *connector)
220{
221 char *connector_name = drm_get_connector_name(connector);
222 char *edidname = edid_firmware, *last, *colon;
223 int ret = 0;
224
225 if (*edidname == '\0')
226 return ret;
227
228 colon = strchr(edidname, ':');
229 if (colon != NULL) {
230 if (strncmp(connector_name, edidname, colon - edidname))
231 return ret;
232 edidname = colon + 1;
233 if (*edidname == '\0')
234 return ret;
235 }
236
237 last = edidname + strlen(edidname) - 1;
238 if (*last == '\n')
239 *last = '\0';
240
241 ret = edid_load(connector, edidname, connector_name);
242 if (ret)
243 return 0;
244
245 drm_mode_connector_update_edid_property(connector,
246 (struct edid *) connector->display_info.raw_edid);
247
248 return drm_add_edid_modes(connector, (struct edid *)
249 connector->display_info.raw_edid);
250}
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 3401761d6391..e250eda4e3a8 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1012,6 +1012,7 @@ extern int drm_add_modes_noedid(struct drm_connector *connector,
1012 int hdisplay, int vdisplay); 1012 int hdisplay, int vdisplay);
1013 1013
1014extern int drm_edid_header_is_valid(const u8 *raw_edid); 1014extern int drm_edid_header_is_valid(const u8 *raw_edid);
1015extern bool drm_edid_block_valid(u8 *raw_edid);
1015extern bool drm_edid_is_valid(struct edid *edid); 1016extern bool drm_edid_is_valid(struct edid *edid);
1016struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, 1017struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
1017 int hsize, int vsize, int fresh); 1018 int hsize, int vsize, int fresh);
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 74ce91684629..bcb9a66baa8c 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -238,5 +238,6 @@ int drm_av_sync_delay(struct drm_connector *connector,
238 struct drm_display_mode *mode); 238 struct drm_display_mode *mode);
239struct drm_connector *drm_select_eld(struct drm_encoder *encoder, 239struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
240 struct drm_display_mode *mode); 240 struct drm_display_mode *mode);
241int drm_load_edid_firmware(struct drm_connector *connector);
241 242
242#endif /* __DRM_EDID_H__ */ 243#endif /* __DRM_EDID_H__ */