diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index ed2ae7a..a3a3859 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -379,6 +379,7 @@ extern XF86ConfigPtr xf86configptr; typedef enum { OPTION_PREFERRED_MODE, + OPTION_USER_MODES, OPTION_POSITION, OPTION_BELOW, OPTION_RIGHT_OF, @@ -394,6 +395,7 @@ typedef enum { static OptionInfoRec xf86OutputOptions[] = { {OPTION_PREFERRED_MODE, "PreferredMode", OPTV_STRING, {0}, FALSE }, + {OPTION_USER_MODES, "UserModes", OPTV_STRING, {0}, FALSE }, {OPTION_POSITION, "Position", OPTV_STRING, {0}, FALSE }, {OPTION_BELOW, "Below", OPTV_STRING, {0}, FALSE }, {OPTION_RIGHT_OF, "RightOf", OPTV_STRING, {0}, FALSE }, @@ -1348,6 +1350,44 @@ preferredMode(ScrnInfoPtr pScrn, xf86Out return preferred_mode; } +static char * +processUserModes(ScrnInfoPtr pScrn, xf86OutputPtr output) +{ + char *user_modes; + + /* Check for a configured user zoom mode list + * e.g. Option "UserModes" "1600x1200 1280x1024 1280x1024 640x480" + */ + user_modes = xf86GetOptValString (output->options, OPTION_USER_MODES); + + if (user_modes) { + DisplayModePtr lastmode = NULL; + int len = strlen(user_modes)+1; + char buf[len]; + int i; + + for(i=0; user_modes[i]; ) { + DisplayModePtr mode; + int l = 0; + + for(; user_modes[i] && user_modes[i] != ' '; i++) + buf[l++] = user_modes[i]; + + buf[l++] = '\0'; + if(user_modes[i]) i++; + + for (mode = output->probed_modes; mode; mode = mode->next) + if (mode != lastmode && !strcmp (buf, mode->name)) { + lastmode = mode; + mode->type |= M_T_USERDEF; + break; + } + } + } + + return user_modes; +} + static void GuessRangeFromModes(MonPtr mon, DisplayModePtr mode) { @@ -1588,7 +1628,6 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, /* Check for a configured preference for a particular mode */ preferred_mode = preferredMode(scrn, output); - if (preferred_mode) { for (mode = output->probed_modes; mode; mode = mode->next) @@ -1606,12 +1645,15 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, mode->prev = NULL; output->probed_modes = mode; } - mode->type |= (M_T_PREFERRED|M_T_USERPREF); + mode->type |= M_T_USERPREF|M_T_USERDEF|M_T_PREFERRED; break; } } } - + + /* Ctrl+Alt+Keypad-{Plus,Minus} zoom */ + processUserModes(scrn, output); + output->initial_rotation = xf86OutputInitialRotation (output); if (config->debug_modes) {