105b261ecSmrg/*
205b261ecSmrg * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
305b261ecSmrg *
405b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining a
505b261ecSmrg * copy of this software and associated documentation files (the "Software"),
605b261ecSmrg * to deal in the Software without restriction, including without limitation
705b261ecSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
805b261ecSmrg * and/or sell copies of the Software, and to permit persons to whom the
905b261ecSmrg * Software is furnished to do so, subject to the following conditions:
1005b261ecSmrg *
1105b261ecSmrg * The above copyright notice and this permission notice shall be included in
1205b261ecSmrg * all copies or substantial portions of the Software.
1305b261ecSmrg *
1405b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1505b261ecSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1605b261ecSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1705b261ecSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1805b261ecSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1905b261ecSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2005b261ecSmrg * OTHER DEALINGS IN THE SOFTWARE.
2105b261ecSmrg *
2205b261ecSmrg * Except as contained in this notice, the name of the copyright holder(s)
2305b261ecSmrg * and author(s) shall not be used in advertising or otherwise to promote
2405b261ecSmrg * the sale, use or other dealings in this Software without prior written
2505b261ecSmrg * authorization from the copyright holder(s) and author(s).
2605b261ecSmrg */
2705b261ecSmrg
2805b261ecSmrg/*
2905b261ecSmrg * This file contains the VidMode functions required by the extension.
3005b261ecSmrg * These have been added to avoid the need for the higher level extension
3105b261ecSmrg * code to access the private XFree86 data structures directly. Wherever
3205b261ecSmrg * possible this code uses the functions in xf86Mode.c to do the work,
3305b261ecSmrg * so that two version of code that do similar things don't have to be
3405b261ecSmrg * maintained.
3505b261ecSmrg */
3605b261ecSmrg
3705b261ecSmrg#ifdef HAVE_XORG_CONFIG_H
3805b261ecSmrg#include <xorg-config.h>
3905b261ecSmrg#endif
4005b261ecSmrg
4105b261ecSmrg#include <X11/X.h>
4205b261ecSmrg#include "os.h"
4305b261ecSmrg#include "xf86.h"
4405b261ecSmrg#include "xf86Priv.h"
4535c4bbdfSmrg#include "extinit.h"
4605b261ecSmrg
4705b261ecSmrg#ifdef XF86VIDMODE
4835c4bbdfSmrg#include "vidmodestr.h"
4935c4bbdfSmrg#include "xf86Privstr.h"
5035c4bbdfSmrg#include "xf86Extensions.h"
5105b261ecSmrg#include "xf86cmap.h"
5205b261ecSmrg
5335c4bbdfSmrgstatic vidMonitorValue
5435c4bbdfSmrgxf86VidModeGetMonitorValue(ScreenPtr pScreen, int valtyp, int indx)
5505b261ecSmrg{
5635c4bbdfSmrg    vidMonitorValue ret = { NULL, };
5735c4bbdfSmrg    MonPtr monitor;
5805b261ecSmrg    ScrnInfoPtr pScrn;
5905b261ecSmrg
6035c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
6135c4bbdfSmrg    monitor = pScrn->monitor;
6235c4bbdfSmrg
6335c4bbdfSmrg    switch (valtyp) {
6435c4bbdfSmrg    case VIDMODE_MON_VENDOR:
6535c4bbdfSmrg        ret.ptr = monitor->vendor;
6635c4bbdfSmrg        break;
6735c4bbdfSmrg    case VIDMODE_MON_MODEL:
6835c4bbdfSmrg        ret.ptr = monitor->model;
6935c4bbdfSmrg        break;
7035c4bbdfSmrg    case VIDMODE_MON_NHSYNC:
7135c4bbdfSmrg        ret.i = monitor->nHsync;
7235c4bbdfSmrg        break;
7335c4bbdfSmrg    case VIDMODE_MON_NVREFRESH:
7435c4bbdfSmrg        ret.i = monitor->nVrefresh;
7535c4bbdfSmrg        break;
7635c4bbdfSmrg    case VIDMODE_MON_HSYNC_LO:
7735c4bbdfSmrg        ret.f = (100.0 * monitor->hsync[indx].lo);
7835c4bbdfSmrg        break;
7935c4bbdfSmrg    case VIDMODE_MON_HSYNC_HI:
8035c4bbdfSmrg        ret.f = (100.0 * monitor->hsync[indx].hi);
8135c4bbdfSmrg        break;
8235c4bbdfSmrg    case VIDMODE_MON_VREFRESH_LO:
8335c4bbdfSmrg        ret.f = (100.0 * monitor->vrefresh[indx].lo);
8435c4bbdfSmrg        break;
8535c4bbdfSmrg    case VIDMODE_MON_VREFRESH_HI:
8635c4bbdfSmrg        ret.f = (100.0 * monitor->vrefresh[indx].hi);
8735c4bbdfSmrg        break;
8805b261ecSmrg    }
8935c4bbdfSmrg    return ret;
9005b261ecSmrg}
9105b261ecSmrg
9235c4bbdfSmrgstatic Bool
9335c4bbdfSmrgxf86VidModeGetCurrentModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
9405b261ecSmrg{
9505b261ecSmrg    ScrnInfoPtr pScrn;
9605b261ecSmrg
9735c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
9805b261ecSmrg
994642e01fSmrg    if (pScrn->currentMode) {
10035c4bbdfSmrg        *mode = pScrn->currentMode;
10135c4bbdfSmrg        *dotClock = pScrn->currentMode->Clock;
1024642e01fSmrg
10335c4bbdfSmrg        return TRUE;
1044642e01fSmrg    }
1054642e01fSmrg    return FALSE;
10605b261ecSmrg}
10705b261ecSmrg
10835c4bbdfSmrgstatic int
10935c4bbdfSmrgxf86VidModeGetDotClock(ScreenPtr pScreen, int Clock)
11005b261ecSmrg{
11105b261ecSmrg    ScrnInfoPtr pScrn;
11205b261ecSmrg
11335c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
11405b261ecSmrg    if ((pScrn->progClock) || (Clock >= MAXCLOCKS))
11535c4bbdfSmrg        return Clock;
11635c4bbdfSmrg    else
11735c4bbdfSmrg        return pScrn->clock[Clock];
11805b261ecSmrg}
11905b261ecSmrg
12035c4bbdfSmrgstatic int
12135c4bbdfSmrgxf86VidModeGetNumOfClocks(ScreenPtr pScreen, Bool *progClock)
12205b261ecSmrg{
12305b261ecSmrg    ScrnInfoPtr pScrn;
12405b261ecSmrg
12535c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
12635c4bbdfSmrg    if (pScrn->progClock) {
12735c4bbdfSmrg        *progClock = TRUE;
12835c4bbdfSmrg        return 0;
12935c4bbdfSmrg    }
13035c4bbdfSmrg    else {
13135c4bbdfSmrg        *progClock = FALSE;
13235c4bbdfSmrg        return pScrn->numClocks;
13305b261ecSmrg    }
13405b261ecSmrg}
13505b261ecSmrg
13635c4bbdfSmrgstatic Bool
13735c4bbdfSmrgxf86VidModeGetClocks(ScreenPtr pScreen, int *Clocks)
13805b261ecSmrg{
13905b261ecSmrg    ScrnInfoPtr pScrn;
14005b261ecSmrg    int i;
14105b261ecSmrg
14235c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
14305b261ecSmrg
14405b261ecSmrg    if (pScrn->progClock)
14535c4bbdfSmrg        return FALSE;
14605b261ecSmrg
14735c4bbdfSmrg    for (i = 0; i < pScrn->numClocks; i++)
14835c4bbdfSmrg        *Clocks++ = pScrn->clock[i];
14905b261ecSmrg
15005b261ecSmrg    return TRUE;
15105b261ecSmrg}
15205b261ecSmrg
15335c4bbdfSmrgstatic Bool
15435c4bbdfSmrgxf86VidModeGetNextModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
15505b261ecSmrg{
15605b261ecSmrg    VidModePtr pVidMode;
15735c4bbdfSmrg    DisplayModePtr p;
15805b261ecSmrg
15935c4bbdfSmrg    pVidMode = VidModeGetPtr(pScreen);
16005b261ecSmrg
16135c4bbdfSmrg    for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) {
16235c4bbdfSmrg        if (p->status == MODE_OK) {
16335c4bbdfSmrg            pVidMode->Next = p->next;
16435c4bbdfSmrg            *mode = p;
16535c4bbdfSmrg            *dotClock = xf86VidModeGetDotClock(pScreen, p->Clock);
16635c4bbdfSmrg            return TRUE;
16735c4bbdfSmrg        }
16805b261ecSmrg    }
16905b261ecSmrg
17035c4bbdfSmrg    return FALSE;
17105b261ecSmrg}
17205b261ecSmrg
17335c4bbdfSmrgstatic Bool
17435c4bbdfSmrgxf86VidModeGetFirstModeline(ScreenPtr pScreen, DisplayModePtr *mode, int *dotClock)
17505b261ecSmrg{
17605b261ecSmrg    ScrnInfoPtr pScrn;
17705b261ecSmrg    VidModePtr pVidMode;
17805b261ecSmrg
17935c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
18035c4bbdfSmrg    if (pScrn->modes == NULL)
18135c4bbdfSmrg        return FALSE;
18205b261ecSmrg
18335c4bbdfSmrg    pVidMode = VidModeGetPtr(pScreen);
18435c4bbdfSmrg    pVidMode->First = pScrn->modes;
18535c4bbdfSmrg    pVidMode->Next = pVidMode->First->next;
18605b261ecSmrg
18735c4bbdfSmrg    if (pVidMode->First->status == MODE_OK) {
18835c4bbdfSmrg        *mode = pVidMode->First;
18935c4bbdfSmrg        *dotClock = xf86VidModeGetDotClock(pScreen, pVidMode->First->Clock);
19035c4bbdfSmrg        return TRUE;
19105b261ecSmrg    }
19235c4bbdfSmrg
19335c4bbdfSmrg    return xf86VidModeGetNextModeline(pScreen, mode, dotClock);
19405b261ecSmrg}
19505b261ecSmrg
19635c4bbdfSmrgstatic Bool
19735c4bbdfSmrgxf86VidModeDeleteModeline(ScreenPtr pScreen, DisplayModePtr mode)
19805b261ecSmrg{
19905b261ecSmrg    ScrnInfoPtr pScrn;
20005b261ecSmrg
20135c4bbdfSmrg    if (mode == NULL)
20235c4bbdfSmrg        return FALSE;
20305b261ecSmrg
20435c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
20535c4bbdfSmrg    xf86DeleteMode(&(pScrn->modes), mode);
20605b261ecSmrg    return TRUE;
20705b261ecSmrg}
20805b261ecSmrg
20935c4bbdfSmrgstatic Bool
21035c4bbdfSmrgxf86VidModeZoomViewport(ScreenPtr pScreen, int zoom)
21105b261ecSmrg{
21235c4bbdfSmrg    xf86ZoomViewport(pScreen, zoom);
21305b261ecSmrg    return TRUE;
21405b261ecSmrg}
21505b261ecSmrg
21635c4bbdfSmrgstatic Bool
21735c4bbdfSmrgxf86VidModeSetViewPort(ScreenPtr pScreen, int x, int y)
21805b261ecSmrg{
21905b261ecSmrg    ScrnInfoPtr pScrn;
22005b261ecSmrg
22135c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
22235c4bbdfSmrg    pScrn->frameX0 = min(max(x, 0),
22335c4bbdfSmrg                         pScrn->virtualX - pScrn->currentMode->HDisplay);
22405b261ecSmrg    pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1;
22535c4bbdfSmrg    pScrn->frameY0 = min(max(y, 0),
22635c4bbdfSmrg                         pScrn->virtualY - pScrn->currentMode->VDisplay);
22705b261ecSmrg    pScrn->frameY1 = pScrn->frameY0 + pScrn->currentMode->VDisplay - 1;
22805b261ecSmrg    if (pScrn->AdjustFrame != NULL)
22935c4bbdfSmrg        (pScrn->AdjustFrame) (pScrn, pScrn->frameX0, pScrn->frameY0);
23005b261ecSmrg
23105b261ecSmrg    return TRUE;
23205b261ecSmrg}
23305b261ecSmrg
23435c4bbdfSmrgstatic Bool
23535c4bbdfSmrgxf86VidModeGetViewPort(ScreenPtr pScreen, int *x, int *y)
23605b261ecSmrg{
23705b261ecSmrg    ScrnInfoPtr pScrn;
23805b261ecSmrg
23935c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
24005b261ecSmrg    *x = pScrn->frameX0;
24105b261ecSmrg    *y = pScrn->frameY0;
24205b261ecSmrg    return TRUE;
24305b261ecSmrg}
24405b261ecSmrg
24535c4bbdfSmrgstatic Bool
24635c4bbdfSmrgxf86VidModeSwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
24705b261ecSmrg{
24805b261ecSmrg    ScrnInfoPtr pScrn;
24905b261ecSmrg    DisplayModePtr pTmpMode;
25005b261ecSmrg    Bool retval;
25105b261ecSmrg
25235c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
25305b261ecSmrg    /* save in case we fail */
25405b261ecSmrg    pTmpMode = pScrn->currentMode;
25505b261ecSmrg    /* Force a mode switch */
25605b261ecSmrg    pScrn->currentMode = NULL;
25705b261ecSmrg    retval = xf86SwitchMode(pScrn->pScreen, mode);
25805b261ecSmrg    /* we failed: restore it */
25905b261ecSmrg    if (retval == FALSE)
26035c4bbdfSmrg        pScrn->currentMode = pTmpMode;
26105b261ecSmrg    return retval;
26205b261ecSmrg}
26305b261ecSmrg
26435c4bbdfSmrgstatic Bool
26535c4bbdfSmrgxf86VidModeLockZoom(ScreenPtr pScreen, Bool lock)
26605b261ecSmrg{
26705b261ecSmrg    if (xf86Info.dontZoom)
26835c4bbdfSmrg        return FALSE;
26905b261ecSmrg
27035c4bbdfSmrg    xf86LockZoom(pScreen, lock);
27105b261ecSmrg    return TRUE;
27205b261ecSmrg}
27305b261ecSmrg
27435c4bbdfSmrgstatic ModeStatus
27535c4bbdfSmrgxf86VidModeCheckModeForMonitor(ScreenPtr pScreen, DisplayModePtr mode)
27605b261ecSmrg{
27705b261ecSmrg    ScrnInfoPtr pScrn;
27805b261ecSmrg
27935c4bbdfSmrg    if (mode == NULL)
28035c4bbdfSmrg        return MODE_ERROR;
28105b261ecSmrg
28235c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
28305b261ecSmrg
28435c4bbdfSmrg    return xf86CheckModeForMonitor(mode, pScrn->monitor);
28505b261ecSmrg}
28605b261ecSmrg
28735c4bbdfSmrgstatic ModeStatus
28835c4bbdfSmrgxf86VidModeCheckModeForDriver(ScreenPtr pScreen, DisplayModePtr mode)
28905b261ecSmrg{
29005b261ecSmrg    ScrnInfoPtr pScrn;
29105b261ecSmrg
29235c4bbdfSmrg    if (mode == NULL)
29335c4bbdfSmrg        return MODE_ERROR;
29405b261ecSmrg
29535c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
29605b261ecSmrg
29735c4bbdfSmrg    return xf86CheckModeForDriver(pScrn, mode, 0);
29805b261ecSmrg}
29905b261ecSmrg
30035c4bbdfSmrgstatic void
30135c4bbdfSmrgxf86VidModeSetCrtcForMode(ScreenPtr pScreen, DisplayModePtr mode)
30205b261ecSmrg{
30305b261ecSmrg    ScrnInfoPtr pScrn;
30405b261ecSmrg    DisplayModePtr ScreenModes;
30535c4bbdfSmrg
30635c4bbdfSmrg    if (mode == NULL)
30735c4bbdfSmrg        return;
30805b261ecSmrg
30905b261ecSmrg    /* Ugly hack so that the xf86Mode.c function can be used without change */
31035c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
31105b261ecSmrg    ScreenModes = pScrn->modes;
31235c4bbdfSmrg    pScrn->modes = mode;
31335c4bbdfSmrg
31405b261ecSmrg    xf86SetCrtcForModes(pScrn, pScrn->adjustFlags);
31505b261ecSmrg    pScrn->modes = ScreenModes;
31605b261ecSmrg    return;
31705b261ecSmrg}
31805b261ecSmrg
31935c4bbdfSmrgstatic Bool
32035c4bbdfSmrgxf86VidModeAddModeline(ScreenPtr pScreen, DisplayModePtr mode)
32105b261ecSmrg{
32205b261ecSmrg    ScrnInfoPtr pScrn;
32305b261ecSmrg
32435c4bbdfSmrg    if (mode == NULL)
32535c4bbdfSmrg        return FALSE;
32635c4bbdfSmrg
32735c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
32805b261ecSmrg
32935c4bbdfSmrg    mode->name = strdup(""); /* freed by deletemode */
33035c4bbdfSmrg    mode->status = MODE_OK;
33135c4bbdfSmrg    mode->next = pScrn->modes->next;
33235c4bbdfSmrg    mode->prev = pScrn->modes;
33335c4bbdfSmrg    pScrn->modes->next = mode;
33435c4bbdfSmrg    if (mode->next != NULL)
33535c4bbdfSmrg        mode->next->prev = mode;
33605b261ecSmrg
33705b261ecSmrg    return TRUE;
33805b261ecSmrg}
33905b261ecSmrg
34035c4bbdfSmrgstatic int
34135c4bbdfSmrgxf86VidModeGetNumOfModes(ScreenPtr pScreen)
34205b261ecSmrg{
34335c4bbdfSmrg    DisplayModePtr mode = NULL;
34435c4bbdfSmrg    int dotClock = 0, nummodes = 0;
34535c4bbdfSmrg
34635c4bbdfSmrg    if (!xf86VidModeGetFirstModeline(pScreen, &mode, &dotClock))
34735c4bbdfSmrg        return nummodes;
34805b261ecSmrg
34905b261ecSmrg    do {
35035c4bbdfSmrg        nummodes++;
35135c4bbdfSmrg        if (!xf86VidModeGetNextModeline(pScreen, &mode, &dotClock))
35235c4bbdfSmrg            return nummodes;
35305b261ecSmrg    } while (TRUE);
35405b261ecSmrg}
35505b261ecSmrg
35635c4bbdfSmrgstatic Bool
35735c4bbdfSmrgxf86VidModeSetGamma(ScreenPtr pScreen, float red, float green, float blue)
35805b261ecSmrg{
35905b261ecSmrg    Gamma gamma;
36005b261ecSmrg
36105b261ecSmrg    gamma.red = red;
36205b261ecSmrg    gamma.green = green;
36305b261ecSmrg    gamma.blue = blue;
36435c4bbdfSmrg    if (xf86ChangeGamma(pScreen, gamma) != Success)
36535c4bbdfSmrg        return FALSE;
36605b261ecSmrg    else
36735c4bbdfSmrg        return TRUE;
36805b261ecSmrg}
36905b261ecSmrg
37035c4bbdfSmrgstatic Bool
37135c4bbdfSmrgxf86VidModeGetGamma(ScreenPtr pScreen, float *red, float *green, float *blue)
37205b261ecSmrg{
37305b261ecSmrg    ScrnInfoPtr pScrn;
37405b261ecSmrg
37535c4bbdfSmrg    pScrn = xf86ScreenToScrn(pScreen);
37605b261ecSmrg    *red = pScrn->gamma.red;
37705b261ecSmrg    *green = pScrn->gamma.green;
37805b261ecSmrg    *blue = pScrn->gamma.blue;
37905b261ecSmrg    return TRUE;
38005b261ecSmrg}
38105b261ecSmrg
38235c4bbdfSmrgstatic Bool
38335c4bbdfSmrgxf86VidModeSetGammaRamp(ScreenPtr pScreen, int size, CARD16 *r, CARD16 *g, CARD16 *b)
38405b261ecSmrg{
38535c4bbdfSmrg    xf86ChangeGammaRamp(pScreen, size, r, g, b);
38635c4bbdfSmrg    return TRUE;
38735c4bbdfSmrg}
38805b261ecSmrg
38935c4bbdfSmrgstatic Bool
39035c4bbdfSmrgxf86VidModeGetGammaRamp(ScreenPtr pScreen, int size, CARD16 *r, CARD16 *g, CARD16 *b)
39135c4bbdfSmrg{
39235c4bbdfSmrg    xf86GetGammaRamp(pScreen, size, r, g, b);
39305b261ecSmrg    return TRUE;
39405b261ecSmrg}
39505b261ecSmrg
39635c4bbdfSmrgstatic Bool
39735c4bbdfSmrgxf86VidModeInit(ScreenPtr pScreen)
39805b261ecSmrg{
39935c4bbdfSmrg    VidModePtr pVidMode;
40005b261ecSmrg
40135c4bbdfSmrg    if (!xf86GetVidModeEnabled()) {
40235c4bbdfSmrg        DebugF("!xf86GetVidModeEnabled()\n");
40305b261ecSmrg        return FALSE;
40435c4bbdfSmrg    }
40505b261ecSmrg
40635c4bbdfSmrg    pVidMode = VidModeInit(pScreen);
40735c4bbdfSmrg    if (!pVidMode)
40835c4bbdfSmrg        return FALSE;
40905b261ecSmrg
41035c4bbdfSmrg    pVidMode->Flags = 0;
41135c4bbdfSmrg    pVidMode->Next = NULL;
41205b261ecSmrg
41335c4bbdfSmrg    pVidMode->GetMonitorValue = xf86VidModeGetMonitorValue;
41435c4bbdfSmrg    pVidMode->GetCurrentModeline = xf86VidModeGetCurrentModeline;
41535c4bbdfSmrg    pVidMode->GetFirstModeline = xf86VidModeGetFirstModeline;
41635c4bbdfSmrg    pVidMode->GetNextModeline = xf86VidModeGetNextModeline;
41735c4bbdfSmrg    pVidMode->DeleteModeline = xf86VidModeDeleteModeline;
41835c4bbdfSmrg    pVidMode->ZoomViewport = xf86VidModeZoomViewport;
41935c4bbdfSmrg    pVidMode->GetViewPort = xf86VidModeGetViewPort;
42035c4bbdfSmrg    pVidMode->SetViewPort = xf86VidModeSetViewPort;
42135c4bbdfSmrg    pVidMode->SwitchMode = xf86VidModeSwitchMode;
42235c4bbdfSmrg    pVidMode->LockZoom = xf86VidModeLockZoom;
42335c4bbdfSmrg    pVidMode->GetNumOfClocks = xf86VidModeGetNumOfClocks;
42435c4bbdfSmrg    pVidMode->GetClocks = xf86VidModeGetClocks;
42535c4bbdfSmrg    pVidMode->CheckModeForMonitor = xf86VidModeCheckModeForMonitor;
42635c4bbdfSmrg    pVidMode->CheckModeForDriver = xf86VidModeCheckModeForDriver;
42735c4bbdfSmrg    pVidMode->SetCrtcForMode = xf86VidModeSetCrtcForMode;
42835c4bbdfSmrg    pVidMode->AddModeline = xf86VidModeAddModeline;
42935c4bbdfSmrg    pVidMode->GetDotClock = xf86VidModeGetDotClock;
43035c4bbdfSmrg    pVidMode->GetNumOfModes = xf86VidModeGetNumOfModes;
43135c4bbdfSmrg    pVidMode->SetGamma = xf86VidModeSetGamma;
43235c4bbdfSmrg    pVidMode->GetGamma = xf86VidModeGetGamma;
43335c4bbdfSmrg    pVidMode->SetGammaRamp = xf86VidModeSetGammaRamp;
43435c4bbdfSmrg    pVidMode->GetGammaRamp = xf86VidModeGetGammaRamp;
43535c4bbdfSmrg    pVidMode->GetGammaRampSize = xf86GetGammaRampSize; /* use xf86cmap API directly */
43605b261ecSmrg
43735c4bbdfSmrg    return TRUE;
43805b261ecSmrg}
43905b261ecSmrg
4406747b715Smrgvoid
44135c4bbdfSmrgXFree86VidModeExtensionInit(void)
44205b261ecSmrg{
44335c4bbdfSmrg    int i;
44435c4bbdfSmrg    Bool enabled = FALSE;
44505b261ecSmrg
44635c4bbdfSmrg    DebugF("XFree86VidModeExtensionInit");
44705b261ecSmrg
44835c4bbdfSmrg    /* This means that the DDX doesn't want the vidmode extension enabled */
44935c4bbdfSmrg    if (!xf86GetVidModeEnabled())
45035c4bbdfSmrg        return;
45105b261ecSmrg
45235c4bbdfSmrg    for (i = 0; i < screenInfo.numScreens; i++) {
45335c4bbdfSmrg        if (xf86VidModeInit (screenInfo.screens[i]))
45435c4bbdfSmrg            enabled = TRUE;
45535c4bbdfSmrg    }
45635c4bbdfSmrg    /* This means that the DDX doesn't want the vidmode extension enabled */
45735c4bbdfSmrg    if (!enabled)
45835c4bbdfSmrg        return;
45905b261ecSmrg
46035c4bbdfSmrg   VidModeAddExtension(xf86GetVidModeAllowNonLocal());
46105b261ecSmrg}
46205b261ecSmrg
46335c4bbdfSmrg#endif                          /* XF86VIDMODE */
464