aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_edid.c100
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c2
-rw-r--r--include/drm/drm_edid.h92
3 files changed, 96 insertions, 98 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 801a0d0e0810..7d0835226f6e 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -252,16 +252,18 @@ struct drm_display_mode *drm_mode_std(struct drm_device *dev,
252{ 252{
253 struct drm_display_mode *mode; 253 struct drm_display_mode *mode;
254 int hsize = t->hsize * 8 + 248, vsize; 254 int hsize = t->hsize * 8 + 248, vsize;
255 unsigned aspect_ratio = (t->vfreq_aspect & EDID_TIMING_ASPECT_MASK)
256 >> EDID_TIMING_ASPECT_SHIFT;
255 257
256 mode = drm_mode_create(dev); 258 mode = drm_mode_create(dev);
257 if (!mode) 259 if (!mode)
258 return NULL; 260 return NULL;
259 261
260 if (t->aspect_ratio == 0) 262 if (aspect_ratio == 0)
261 vsize = (hsize * 10) / 16; 263 vsize = (hsize * 10) / 16;
262 else if (t->aspect_ratio == 1) 264 else if (aspect_ratio == 1)
263 vsize = (hsize * 3) / 4; 265 vsize = (hsize * 3) / 4;
264 else if (t->aspect_ratio == 2) 266 else if (aspect_ratio == 2)
265 vsize = (hsize * 4) / 5; 267 vsize = (hsize * 4) / 5;
266 else 268 else
267 vsize = (hsize * 9) / 16; 269 vsize = (hsize * 9) / 16;
@@ -288,17 +290,24 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
288{ 290{
289 struct drm_display_mode *mode; 291 struct drm_display_mode *mode;
290 struct detailed_pixel_timing *pt = &timing->data.pixel_data; 292 struct detailed_pixel_timing *pt = &timing->data.pixel_data;
293 unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
294 unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
295 unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
296 unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo;
297 unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 8 | pt->hsync_offset_lo;
298 unsigned hsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) << 6 | pt->hsync_pulse_width_lo;
299 unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0x30) | (pt->vsync_offset_pulse_width_lo & 0xf);
300 unsigned vsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) >> 2 | pt->vsync_offset_pulse_width_lo >> 4;
291 301
292 /* ignore tiny modes */ 302 /* ignore tiny modes */
293 if (((pt->hactive_hi << 8) | pt->hactive_lo) < 64 || 303 if (hactive < 64 || vactive < 64)
294 ((pt->vactive_hi << 8) | pt->hactive_lo) < 64)
295 return NULL; 304 return NULL;
296 305
297 if (pt->stereo) { 306 if (pt->misc & DRM_EDID_PT_STEREO) {
298 printk(KERN_WARNING "stereo mode not supported\n"); 307 printk(KERN_WARNING "stereo mode not supported\n");
299 return NULL; 308 return NULL;
300 } 309 }
301 if (!pt->separate_sync) { 310 if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) {
302 printk(KERN_WARNING "integrated sync not supported\n"); 311 printk(KERN_WARNING "integrated sync not supported\n");
303 return NULL; 312 return NULL;
304 } 313 }
@@ -310,41 +319,36 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
310 mode->type = DRM_MODE_TYPE_DRIVER; 319 mode->type = DRM_MODE_TYPE_DRIVER;
311 320
312 if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH) 321 if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
313 timing->pixel_clock = 1088; 322 timing->pixel_clock = cpu_to_le16(1088);
314 323
315 mode->clock = timing->pixel_clock * 10; 324 mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
316 325
317 mode->hdisplay = (pt->hactive_hi << 8) | pt->hactive_lo; 326 mode->hdisplay = hactive;
318 mode->hsync_start = mode->hdisplay + ((pt->hsync_offset_hi << 8) | 327 mode->hsync_start = mode->hdisplay + hsync_offset;
319 pt->hsync_offset_lo); 328 mode->hsync_end = mode->hsync_start + hsync_pulse_width;
320 mode->hsync_end = mode->hsync_start + 329 mode->htotal = mode->hdisplay + hblank;
321 ((pt->hsync_pulse_width_hi << 8) | 330
322 pt->hsync_pulse_width_lo); 331 mode->vdisplay = vactive;
323 mode->htotal = mode->hdisplay + ((pt->hblank_hi << 8) | pt->hblank_lo); 332 mode->vsync_start = mode->vdisplay + vsync_offset;
324 333 mode->vsync_end = mode->vsync_start + vsync_pulse_width;
325 mode->vdisplay = (pt->vactive_hi << 8) | pt->vactive_lo; 334 mode->vtotal = mode->vdisplay + vblank;
326 mode->vsync_start = mode->vdisplay + ((pt->vsync_offset_hi << 4) |
327 pt->vsync_offset_lo);
328 mode->vsync_end = mode->vsync_start +
329 ((pt->vsync_pulse_width_hi << 4) |
330 pt->vsync_pulse_width_lo);
331 mode->vtotal = mode->vdisplay + ((pt->vblank_hi << 8) | pt->vblank_lo);
332 335
333 drm_mode_set_name(mode); 336 drm_mode_set_name(mode);
334 337
335 if (pt->interlaced) 338 if (pt->misc & DRM_EDID_PT_INTERLACED)
336 mode->flags |= DRM_MODE_FLAG_INTERLACE; 339 mode->flags |= DRM_MODE_FLAG_INTERLACE;
337 340
338 if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) { 341 if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
339 pt->hsync_positive = 1; 342 pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
340 pt->vsync_positive = 1;
341 } 343 }
342 344
343 mode->flags |= pt->hsync_positive ? DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; 345 mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
344 mode->flags |= pt->vsync_positive ? DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; 346 DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
347 mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
348 DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
345 349
346 mode->width_mm = pt->width_mm_lo | (pt->width_mm_hi << 8); 350 mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
347 mode->height_mm = pt->height_mm_lo | (pt->height_mm_hi << 8); 351 mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
348 352
349 if (quirks & EDID_QUIRK_DETAILED_IN_CM) { 353 if (quirks & EDID_QUIRK_DETAILED_IN_CM) {
350 mode->width_mm *= 10; 354 mode->width_mm *= 10;
@@ -465,7 +469,7 @@ static int add_standard_modes(struct drm_connector *connector, struct edid *edid
465 struct drm_display_mode *newmode; 469 struct drm_display_mode *newmode;
466 470
467 /* If std timings bytes are 1, 1 it's empty */ 471 /* If std timings bytes are 1, 1 it's empty */
468 if (t->hsize == 1 && (t->aspect_ratio | t->vfreq) == 1) 472 if (t->hsize == 1 && t->vfreq_aspect == 1)
469 continue; 473 continue;
470 474
471 newmode = drm_mode_std(dev, &edid->standard_timings[i]); 475 newmode = drm_mode_std(dev, &edid->standard_timings[i]);
@@ -509,7 +513,7 @@ static int add_detailed_info(struct drm_connector *connector,
509 continue; 513 continue;
510 514
511 /* First detailed mode is preferred */ 515 /* First detailed mode is preferred */
512 if (i == 0 && edid->preferred_timing) 516 if (i == 0 && (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING))
513 newmode->type |= DRM_MODE_TYPE_PREFERRED; 517 newmode->type |= DRM_MODE_TYPE_PREFERRED;
514 drm_mode_probed_add(connector, newmode); 518 drm_mode_probed_add(connector, newmode);
515 519
@@ -767,22 +771,22 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
767 if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75)) 771 if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
768 edid_fixup_preferred(connector, quirks); 772 edid_fixup_preferred(connector, quirks);
769 773
770 connector->display_info.serration_vsync = edid->serration_vsync; 774 connector->display_info.serration_vsync = (edid->input & DRM_EDID_INPUT_SERRATION_VSYNC) ? 1 : 0;
771 connector->display_info.sync_on_green = edid->sync_on_green; 775 connector->display_info.sync_on_green = (edid->input & DRM_EDID_INPUT_SYNC_ON_GREEN) ? 1 : 0;
772 connector->display_info.composite_sync = edid->composite_sync; 776 connector->display_info.composite_sync = (edid->input & DRM_EDID_INPUT_COMPOSITE_SYNC) ? 1 : 0;
773 connector->display_info.separate_syncs = edid->separate_syncs; 777 connector->display_info.separate_syncs = (edid->input & DRM_EDID_INPUT_SEPARATE_SYNCS) ? 1 : 0;
774 connector->display_info.blank_to_black = edid->blank_to_black; 778 connector->display_info.blank_to_black = (edid->input & DRM_EDID_INPUT_BLANK_TO_BLACK) ? 1 : 0;
775 connector->display_info.video_level = edid->video_level; 779 connector->display_info.video_level = (edid->input & DRM_EDID_INPUT_VIDEO_LEVEL) >> 5;
776 connector->display_info.digital = edid->digital; 780 connector->display_info.digital = (edid->input & DRM_EDID_INPUT_DIGITAL) ? 1 : 0;
777 connector->display_info.width_mm = edid->width_cm * 10; 781 connector->display_info.width_mm = edid->width_cm * 10;
778 connector->display_info.height_mm = edid->height_cm * 10; 782 connector->display_info.height_mm = edid->height_cm * 10;
779 connector->display_info.gamma = edid->gamma; 783 connector->display_info.gamma = edid->gamma;
780 connector->display_info.gtf_supported = edid->default_gtf; 784 connector->display_info.gtf_supported = (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) ? 1 : 0;
781 connector->display_info.standard_color = edid->standard_color; 785 connector->display_info.standard_color = (edid->features & DRM_EDID_FEATURE_STANDARD_COLOR) ? 1 : 0;
782 connector->display_info.display_type = edid->display_type; 786 connector->display_info.display_type = (edid->features & DRM_EDID_FEATURE_DISPLAY_TYPE) >> 3;
783 connector->display_info.active_off_supported = edid->pm_active_off; 787 connector->display_info.active_off_supported = (edid->features & DRM_EDID_FEATURE_PM_ACTIVE_OFF) ? 1 : 0;
784 connector->display_info.suspend_supported = edid->pm_suspend; 788 connector->display_info.suspend_supported = (edid->features & DRM_EDID_FEATURE_PM_SUSPEND) ? 1 : 0;
785 connector->display_info.standby_supported = edid->pm_standby; 789 connector->display_info.standby_supported = (edid->features & DRM_EDID_FEATURE_PM_STANDBY) ? 1 : 0;
786 connector->display_info.gamma = edid->gamma; 790 connector->display_info.gamma = edid->gamma;
787 791
788 return num_modes; 792 return num_modes;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 5452bb9d925e..3efcf1a526be 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -351,7 +351,7 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector)
351 radeon_i2c_do_lock(radeon_connector, 0); 351 radeon_i2c_do_lock(radeon_connector, 0);
352 if (edid) { 352 if (edid) {
353 /* update digital bits here */ 353 /* update digital bits here */
354 if (edid->digital) 354 if (edid->input & DRM_EDID_INPUT_DIGITAL)
355 radeon_connector->use_digital = 1; 355 radeon_connector->use_digital = 1;
356 else 356 else
357 radeon_connector->use_digital = 0; 357 radeon_connector->use_digital = 0;
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index a11cc9d32591..c263e4d71754 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -28,53 +28,49 @@
28#define EDID_LENGTH 128 28#define EDID_LENGTH 128
29#define DDC_ADDR 0x50 29#define DDC_ADDR 0x50
30 30
31#ifdef BIG_ENDIAN
32#error "EDID structure is little endian, need big endian versions"
33#else
34
35struct est_timings { 31struct est_timings {
36 u8 t1; 32 u8 t1;
37 u8 t2; 33 u8 t2;
38 u8 mfg_rsvd; 34 u8 mfg_rsvd;
39} __attribute__((packed)); 35} __attribute__((packed));
40 36
37/* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
38#define EDID_TIMING_ASPECT_SHIFT 0
39#define EDID_TIMING_ASPECT_MASK (0x3 << EDID_TIMING_ASPECT_SHIFT)
40
41/* need to add 60 */
42#define EDID_TIMING_VFREQ_SHIFT 2
43#define EDID_TIMING_VFREQ_MASK (0x3f << EDID_TIMING_VFREQ_SHIFT)
44
41struct std_timing { 45struct std_timing {
42 u8 hsize; /* need to multiply by 8 then add 248 */ 46 u8 hsize; /* need to multiply by 8 then add 248 */
43 u8 vfreq:6; /* need to add 60 */ 47 u8 vfreq_aspect;
44 u8 aspect_ratio:2; /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
45} __attribute__((packed)); 48} __attribute__((packed));
46 49
50#define DRM_EDID_PT_HSYNC_POSITIVE (1 << 6)
51#define DRM_EDID_PT_VSYNC_POSITIVE (1 << 5)
52#define DRM_EDID_PT_SEPARATE_SYNC (3 << 3)
53#define DRM_EDID_PT_STEREO (1 << 2)
54#define DRM_EDID_PT_INTERLACED (1 << 1)
55
47/* If detailed data is pixel timing */ 56/* If detailed data is pixel timing */
48struct detailed_pixel_timing { 57struct detailed_pixel_timing {
49 u8 hactive_lo; 58 u8 hactive_lo;
50 u8 hblank_lo; 59 u8 hblank_lo;
51 u8 hblank_hi:4; 60 u8 hactive_hblank_hi;
52 u8 hactive_hi:4;
53 u8 vactive_lo; 61 u8 vactive_lo;
54 u8 vblank_lo; 62 u8 vblank_lo;
55 u8 vblank_hi:4; 63 u8 vactive_vblank_hi;
56 u8 vactive_hi:4;
57 u8 hsync_offset_lo; 64 u8 hsync_offset_lo;
58 u8 hsync_pulse_width_lo; 65 u8 hsync_pulse_width_lo;
59 u8 vsync_pulse_width_lo:4; 66 u8 vsync_offset_pulse_width_lo;
60 u8 vsync_offset_lo:4; 67 u8 hsync_vsync_offset_pulse_width_hi;
61 u8 vsync_pulse_width_hi:2;
62 u8 vsync_offset_hi:2;
63 u8 hsync_pulse_width_hi:2;
64 u8 hsync_offset_hi:2;
65 u8 width_mm_lo; 68 u8 width_mm_lo;
66 u8 height_mm_lo; 69 u8 height_mm_lo;
67 u8 height_mm_hi:4; 70 u8 width_height_mm_hi;
68 u8 width_mm_hi:4;
69 u8 hborder; 71 u8 hborder;
70 u8 vborder; 72 u8 vborder;
71 u8 unknown0:1; 73 u8 misc;
72 u8 hsync_positive:1;
73 u8 vsync_positive:1;
74 u8 separate_sync:2;
75 u8 stereo:1;
76 u8 unknown6:1;
77 u8 interlaced:1;
78} __attribute__((packed)); 74} __attribute__((packed));
79 75
80/* If it's not pixel timing, it'll be one of the below */ 76/* If it's not pixel timing, it'll be one of the below */
@@ -88,18 +84,16 @@ struct detailed_data_monitor_range {
88 u8 min_hfreq_khz; 84 u8 min_hfreq_khz;
89 u8 max_hfreq_khz; 85 u8 max_hfreq_khz;
90 u8 pixel_clock_mhz; /* need to multiply by 10 */ 86 u8 pixel_clock_mhz; /* need to multiply by 10 */
91 u16 sec_gtf_toggle; /* A000=use above, 20=use below */ /* FIXME: byte order */ 87 __le16 sec_gtf_toggle; /* A000=use above, 20=use below */
92 u8 hfreq_start_khz; /* need to multiply by 2 */ 88 u8 hfreq_start_khz; /* need to multiply by 2 */
93 u8 c; /* need to divide by 2 */ 89 u8 c; /* need to divide by 2 */
94 u16 m; /* FIXME: byte order */ 90 __le16 m;
95 u8 k; 91 u8 k;
96 u8 j; /* need to divide by 2 */ 92 u8 j; /* need to divide by 2 */
97} __attribute__((packed)); 93} __attribute__((packed));
98 94
99struct detailed_data_wpindex { 95struct detailed_data_wpindex {
100 u8 white_y_lo:2; 96 u8 white_xy_lo; /* Upper 2 bits each */
101 u8 white_x_lo:2;
102 u8 pad:4;
103 u8 white_x_hi; 97 u8 white_x_hi;
104 u8 white_y_hi; 98 u8 white_y_hi;
105 u8 gamma; /* need to divide by 100 then add 1 */ 99 u8 gamma; /* need to divide by 100 then add 1 */
@@ -134,13 +128,29 @@ struct detailed_non_pixel {
134#define EDID_DETAIL_MONITOR_SERIAL 0xff 128#define EDID_DETAIL_MONITOR_SERIAL 0xff
135 129
136struct detailed_timing { 130struct detailed_timing {
137 u16 pixel_clock; /* need to multiply by 10 KHz */ /* FIXME: byte order */ 131 __le16 pixel_clock; /* need to multiply by 10 KHz */
138 union { 132 union {
139 struct detailed_pixel_timing pixel_data; 133 struct detailed_pixel_timing pixel_data;
140 struct detailed_non_pixel other_data; 134 struct detailed_non_pixel other_data;
141 } data; 135 } data;
142} __attribute__((packed)); 136} __attribute__((packed));
143 137
138#define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 7)
139#define DRM_EDID_INPUT_SYNC_ON_GREEN (1 << 5)
140#define DRM_EDID_INPUT_COMPOSITE_SYNC (1 << 4)
141#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3)
142#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 2)
143#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 1)
144#define DRM_EDID_INPUT_DIGITAL (1 << 0) /* bits above must be zero if set */
145
146#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 7)
147#define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 6)
148#define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 5)
149#define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
150#define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 2)
151#define DRM_EDID_FEATURE_PM_SUSPEND (1 << 1)
152#define DRM_EDID_FEATURE_PM_STANDBY (1 << 0)
153
144struct edid { 154struct edid {
145 u8 header[8]; 155 u8 header[8];
146 /* Vendor & product info */ 156 /* Vendor & product info */
@@ -153,25 +163,11 @@ struct edid {
153 u8 version; 163 u8 version;
154 u8 revision; 164 u8 revision;
155 /* Display info: */ 165 /* Display info: */
156 /* input definition */ 166 u8 input;
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; 167 u8 width_cm;
165 u8 height_cm; 168 u8 height_cm;
166 u8 gamma; 169 u8 gamma;
167 /* feature support */ 170 u8 features;
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 */ 171 /* Color characteristics */
176 u8 red_green_lo; 172 u8 red_green_lo;
177 u8 black_white_lo; 173 u8 black_white_lo;
@@ -195,8 +191,6 @@ struct edid {
195 u8 checksum; 191 u8 checksum;
196} __attribute__((packed)); 192} __attribute__((packed));
197 193
198#endif /* little endian structs */
199
200#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) 194#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
201 195
202#endif /* __DRM_EDID_H__ */ 196#endif /* __DRM_EDID_H__ */