From 91235829b272dd88a0ada67f48a43b3dfc22dab0 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Fri, 6 May 2011 20:50:05 +0000 Subject: [PATCH] start a const list of common mode timings (mostly vesa); verify refresh rate is sane by calculating it using pixel clock and horizontal/vertical totals git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41354 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/accelerants/radeon_hd/mode.cpp | 27 +++++++++++++++------- src/add-ons/accelerants/radeon_hd/mode.h | 22 ++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/add-ons/accelerants/radeon_hd/mode.cpp b/src/add-ons/accelerants/radeon_hd/mode.cpp index 97897baad3..7732dfc4ba 100644 --- a/src/add-ons/accelerants/radeon_hd/mode.cpp +++ b/src/add-ons/accelerants/radeon_hd/mode.cpp @@ -349,15 +349,15 @@ mode_sanity_check(display_mode *mode) // horizontal timing // validate h_sync_start is less then h_sync_end if (mode->timing.h_sync_start > mode->timing.h_sync_end) { - TRACE("%s: ERROR: " - "(%dx%d) received h_sync_start greater then h_sync_end!\n", + TRACE("%s: ERROR: (%dx%d) " + "received h_sync_start greater then h_sync_end!\n", __func__, mode->timing.h_display, mode->timing.v_display); return B_ERROR; } // validate h_total is greater then h_display if (mode->timing.h_total < mode->timing.h_display) { - TRACE("%s: ERROR: " - "(%dx%d) received h_total greater then h_display!\n", + TRACE("%s: ERROR: (%dx%d) " + "received h_total greater then h_display!\n", __func__, mode->timing.h_display, mode->timing.v_display); return B_ERROR; } @@ -365,19 +365,30 @@ mode_sanity_check(display_mode *mode) // vertical timing // validate v_start is less then v_end if (mode->timing.v_sync_start > mode->timing.v_sync_end) { - TRACE("%s: ERROR: " - "(%dx%d) received v_sync_start greater then v_sync_end!\n", + TRACE("%s: ERROR: (%dx%d) " + "received v_sync_start greater then v_sync_end!\n", __func__, mode->timing.h_display, mode->timing.v_display); return B_ERROR; } // validate v_total is greater then v_display if (mode->timing.v_total < mode->timing.v_display) { - TRACE("%s: ERROR: " - "(%dx%d) received v_total greater then v_display!\n", + TRACE("%s: ERROR: (%dx%d) " + "received v_total greater then v_display!\n", __func__, mode->timing.h_display, mode->timing.v_display); return B_ERROR; } + // calculate refresh rate for given timings to whole int (in Hz) + int refresh = mode->timing.pixel_clock * 1000 + / (mode->timing.h_total * mode->timing.v_total); + + if (refresh < 30 || refresh > 250) { + TRACE("%s: ERROR: (%dx%d) " + "refresh rate of %dHz is unlikely for any kind of monitor!\n", + __func__, mode->timing.h_display, mode->timing.v_display, refresh); + return B_ERROR; + } + return B_OK; } diff --git a/src/add-ons/accelerants/radeon_hd/mode.h b/src/add-ons/accelerants/radeon_hd/mode.h index ac4515f415..c010f666c0 100644 --- a/src/add-ons/accelerants/radeon_hd/mode.h +++ b/src/add-ons/accelerants/radeon_hd/mode.h @@ -14,6 +14,9 @@ #include +#define T_POSITIVE_SYNC (B_POSITIVE_HSYNC | B_POSITIVE_VSYNC) + + status_t create_mode_list(void); status_t mode_sanity_check(display_mode *mode); @@ -80,4 +83,23 @@ enum { }; +// A collection of the more common timings +const display_timing kStdModeTimings[] = { + {25180, 640, 656, 752, 800, 480, 490, 492, 525, 0}, + // 640x480@60 + {40000, 800, 840, 968, 1056, 600, 601, 605, 628, T_POSITIVE_SYNC}, + // 800x600@60 + {50000, 800, 856, 976, 1040, 600, 637, 643, 666, T_POSITIVE_SYNC}, + // 800x600@72 + {65000, 1024, 1048, 1184, 1344, 768, 771, 777, 806, 0}, + // 1024x768@60 + {75000, 1024, 1048, 1184, 1328, 768, 771, 777, 806, 0}, + // 1024x768@70 + {108000, 1280, 1328, 1440, 1688, 1024, 1025, 1028, 1066, T_POSITIVE_SYNC}, + // 1280x1024@60 + {135000, 1280, 1296, 1440, 1688, 1024, 1025, 1028, 1066, T_POSITIVE_SYNC} + // 1280x1024@75 +}; + + #endif /*RADEON_HD_MODE_H*/