aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2009-09-02 21:33:47 -0400
committerDave Airlie <airlied@redhat.com>2009-09-07 02:04:15 -0400
commit559ee21d261a54c42594ef9405d27e9008eedf44 (patch)
tree474be3b0ca2645db1366c03753333b9f5c45a19f
parentaa9eaa1f0962152d0bde821149d82fe7b70a6f92 (diff)
drm/kms: try to find the std mode in DMT table
When we need to add the standard timing mode, we will firstly check whether it can be found in DMT table by comparing the hdisplay/vdisplay/vfresh_rate. If it can't be found, then we will use the cvt/gtf to add the required mode. If it can be found, it will be returned. At the same time the function of drm_mode_vrefresh is also fixed. It will return the result of actual refresh_rate plus 0.5. For example: When the calculated value is 84.9, then the fresh_rate is 85. When the calculated value is 70.02, then the fresh_rate is 70. Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_edid.c40
-rw-r--r--drivers/gpu/drm/drm_modes.c11
2 files changed, 39 insertions, 12 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index e64eb6bbce1a..f84a98f2e373 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -480,6 +480,26 @@ static struct drm_display_mode drm_dmt_modes[] = {
480 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, 480 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
481}; 481};
482 482
483static struct drm_display_mode *drm_find_dmt(struct drm_device *dev,
484 int hsize, int vsize, int fresh)
485{
486 int i, count;
487 struct drm_display_mode *ptr, *mode;
488
489 count = sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode);
490 mode = NULL;
491 for (i = 0; i < count; i++) {
492 ptr = &drm_dmt_modes[i];
493 if (hsize == ptr->hdisplay &&
494 vsize == ptr->vdisplay &&
495 fresh == drm_mode_vrefresh(ptr)) {
496 /* get the expected default mode */
497 mode = drm_mode_duplicate(dev, ptr);
498 break;
499 }
500 }
501 return mode;
502}
483/** 503/**
484 * drm_mode_std - convert standard mode info (width, height, refresh) into mode 504 * drm_mode_std - convert standard mode info (width, height, refresh) into mode
485 * @t: standard timing params 505 * @t: standard timing params
@@ -516,16 +536,22 @@ struct drm_display_mode *drm_mode_std(struct drm_device *dev,
516 vsize = (hsize * 4) / 5; 536 vsize = (hsize * 4) / 5;
517 else 537 else
518 vsize = (hsize * 9) / 16; 538 vsize = (hsize * 9) / 16;
519 539 /* HDTV hack */
540 if (hsize == 1360 && vsize == 765 && vrefresh_rate == 60) {
541 mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0);
542 mode->hdisplay = 1366;
543 mode->vsync_start = mode->vsync_start - 1;
544 mode->vsync_end = mode->vsync_end - 1;
545 return mode;
546 }
520 mode = NULL; 547 mode = NULL;
548 /* check whether it can be found in default mode table */
549 mode = drm_find_dmt(dev, hsize, vsize, vrefresh_rate);
550 if (mode)
551 return mode;
552
521 switch (timing_level) { 553 switch (timing_level) {
522 case LEVEL_DMT: 554 case LEVEL_DMT:
523 mode = drm_mode_create(dev);
524 if (mode) {
525 mode->hdisplay = hsize;
526 mode->vdisplay = vsize;
527 drm_mode_set_name(mode);
528 }
529 break; 555 break;
530 case LEVEL_GTF: 556 case LEVEL_GTF:
531 mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); 557 mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0);
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index ab6e70eadc58..49404ce1666e 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -566,7 +566,9 @@ EXPORT_SYMBOL(drm_mode_height);
566 * FIXME: why is this needed? shouldn't vrefresh be set already? 566 * FIXME: why is this needed? shouldn't vrefresh be set already?
567 * 567 *
568 * RETURNS: 568 * RETURNS:
569 * Vertical refresh rate of @mode x 1000. For precision reasons. 569 * Vertical refresh rate. It will be the result of actual value plus 0.5.
570 * If it is 70.288, it will return 70Hz.
571 * If it is 59.6, it will return 60Hz.
570 */ 572 */
571int drm_mode_vrefresh(struct drm_display_mode *mode) 573int drm_mode_vrefresh(struct drm_display_mode *mode)
572{ 574{
@@ -576,14 +578,13 @@ int drm_mode_vrefresh(struct drm_display_mode *mode)
576 if (mode->vrefresh > 0) 578 if (mode->vrefresh > 0)
577 refresh = mode->vrefresh; 579 refresh = mode->vrefresh;
578 else if (mode->htotal > 0 && mode->vtotal > 0) { 580 else if (mode->htotal > 0 && mode->vtotal > 0) {
581 int vtotal;
582 vtotal = mode->vtotal;
579 /* work out vrefresh the value will be x1000 */ 583 /* work out vrefresh the value will be x1000 */
580 calc_val = (mode->clock * 1000); 584 calc_val = (mode->clock * 1000);
581
582 calc_val /= mode->htotal; 585 calc_val /= mode->htotal;
583 calc_val *= 1000; 586 refresh = (calc_val + vtotal / 2) / vtotal;
584 calc_val /= mode->vtotal;
585 587
586 refresh = calc_val;
587 if (mode->flags & DRM_MODE_FLAG_INTERLACE) 588 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
588 refresh *= 2; 589 refresh *= 2;
589 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 590 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)