diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index ff2e053..2ce469b 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -747,10 +747,15 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height) int target_diff = 0; int target_preferred = 0; int mm_height; + int mm_width; mm_height = output->mm_height; + mm_width = output->mm_width; if (!mm_height) + { mm_height = (768 * 25.4) / DEFAULT_DPI; + mm_width = (1024 * 25.4) / DEFAULT_DPI; + } /* * Pick a mode closest to DEFAULT_DPI */ @@ -760,6 +765,7 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height) int preferred = (((mode->type & M_T_PREFERRED) != 0) + ((mode->type & M_T_USERPREF) != 0)); int diff; + int xdiff; if (xf86ModeWidth (mode, output->initial_rotation) > width || xf86ModeHeight (mode, output->initial_rotation) > height) @@ -769,6 +775,9 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height) dpi = (mode->VDisplay * 254) / (mm_height * 10); diff = dpi - DEFAULT_DPI; diff = diff < 0 ? -diff : diff; + dpi = (mode->HDisplay * 254) / (mm_width * 10); + xdiff = (dpi - DEFAULT_DPI) * 2 / 3; + diff += xdiff < 0 ? -xdiff : xdiff; if (target_mode == NULL || (preferred > target_preferred) || (preferred == target_preferred && diff < target_diff)) {