aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_edid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_edid.c')
-rw-r--r--drivers/gpu/drm/drm_edid.c100
1 files changed, 52 insertions, 48 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 801a0d0e081..7d0835226f6 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;