2 * Copyright © 2006 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Eric Anholt <anholt@FreeBSD.org>
29 #include <xorg-config.h>
39 typedef struct _ExaXorgScreenPrivRec
{
40 CloseScreenProcPtr SavedCloseScreen
;
41 xf86EnableDisableFBAccessProc
*SavedEnableDisableFBAccess
;
42 OptionInfoPtr options
;
43 } ExaXorgScreenPrivRec
, *ExaXorgScreenPrivPtr
;
45 static DevPrivateKeyRec exaXorgScreenPrivateKeyRec
;
47 #define exaXorgScreenPrivateKey (&exaXorgScreenPrivateKeyRec)
50 EXAOPT_MIGRATION_HEURISTIC
,
54 EXAOPT_OPTIMIZE_MIGRATION
57 static const OptionInfoRec EXAOptions
[] = {
58 {EXAOPT_MIGRATION_HEURISTIC
, "MigrationHeuristic",
59 OPTV_ANYSTR
, {0}, FALSE
},
60 {EXAOPT_NO_COMPOSITE
, "EXANoComposite",
61 OPTV_BOOLEAN
, {0}, FALSE
},
62 {EXAOPT_NO_UTS
, "EXANoUploadToScreen",
63 OPTV_BOOLEAN
, {0}, FALSE
},
64 {EXAOPT_NO_DFS
, "EXANoDownloadFromScreen",
65 OPTV_BOOLEAN
, {0}, FALSE
},
66 {EXAOPT_OPTIMIZE_MIGRATION
, "EXAOptimizeMigration",
67 OPTV_BOOLEAN
, {0}, FALSE
},
69 OPTV_NONE
, {0}, FALSE
}
73 exaXorgCloseScreen(ScreenPtr pScreen
)
75 ScrnInfoPtr pScrn
= xf86ScreenToScrn(pScreen
);
76 ExaXorgScreenPrivPtr pScreenPriv
= (ExaXorgScreenPrivPtr
)
77 dixLookupPrivate(&pScreen
->devPrivates
, exaXorgScreenPrivateKey
);
79 pScreen
->CloseScreen
= pScreenPriv
->SavedCloseScreen
;
81 pScrn
->EnableDisableFBAccess
= pScreenPriv
->SavedEnableDisableFBAccess
;
83 free(pScreenPriv
->options
);
86 return pScreen
->CloseScreen(pScreen
);
90 exaXorgEnableDisableFBAccess(ScrnInfoPtr pScrn
, Bool enable
)
92 ScreenPtr pScreen
= xf86ScrnToScreen(pScrn
);
93 ExaXorgScreenPrivPtr pScreenPriv
= (ExaXorgScreenPrivPtr
)
94 dixLookupPrivate(&pScreen
->devPrivates
, exaXorgScreenPrivateKey
);
97 exaEnableDisableFBAccess(pScreen
, enable
);
99 if (pScreenPriv
->SavedEnableDisableFBAccess
)
100 pScreenPriv
->SavedEnableDisableFBAccess(pScrn
, enable
);
103 exaEnableDisableFBAccess(pScreen
, enable
);
107 * This will be called during exaDriverInit, giving us the chance to set options
108 * and hook in our EnableDisableFBAccess.
111 exaDDXDriverInit(ScreenPtr pScreen
)
113 ExaScreenPriv(pScreen
);
114 ScrnInfoPtr pScrn
= xf86ScreenToScrn(pScreen
);
115 ExaXorgScreenPrivPtr pScreenPriv
;
117 if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec
, PRIVATE_SCREEN
, 0))
120 pScreenPriv
= calloc(1, sizeof(ExaXorgScreenPrivRec
));
121 if (pScreenPriv
== NULL
)
124 pScreenPriv
->options
= xnfalloc(sizeof(EXAOptions
));
125 memcpy(pScreenPriv
->options
, EXAOptions
, sizeof(EXAOptions
));
126 xf86ProcessOptions(pScrn
->scrnIndex
, pScrn
->options
, pScreenPriv
->options
);
128 if (pExaScr
->info
->flags
& EXA_OFFSCREEN_PIXMAPS
) {
129 if (!(pExaScr
->info
->flags
& EXA_HANDLES_PIXMAPS
) &&
130 pExaScr
->info
->offScreenBase
< pExaScr
->info
->memorySize
) {
133 heuristicName
= xf86GetOptValString(pScreenPriv
->options
,
134 EXAOPT_MIGRATION_HEURISTIC
);
135 if (heuristicName
!= NULL
) {
136 if (strcmp(heuristicName
, "greedy") == 0)
137 pExaScr
->migration
= ExaMigrationGreedy
;
138 else if (strcmp(heuristicName
, "always") == 0)
139 pExaScr
->migration
= ExaMigrationAlways
;
140 else if (strcmp(heuristicName
, "smart") == 0)
141 pExaScr
->migration
= ExaMigrationSmart
;
143 xf86DrvMsg(pScreen
->myNum
, X_WARNING
,
144 "EXA: unknown migration heuristic %s\n",
150 pExaScr
->optimize_migration
=
151 xf86ReturnOptValBool(pScreenPriv
->options
,
152 EXAOPT_OPTIMIZE_MIGRATION
, TRUE
);
155 if (xf86ReturnOptValBool(pScreenPriv
->options
, EXAOPT_NO_COMPOSITE
, FALSE
)) {
156 xf86DrvMsg(pScreen
->myNum
, X_CONFIG
,
157 "EXA: Disabling Composite operation "
158 "(RENDER acceleration)\n");
159 pExaScr
->info
->CheckComposite
= NULL
;
160 pExaScr
->info
->PrepareComposite
= NULL
;
163 if (xf86ReturnOptValBool(pScreenPriv
->options
, EXAOPT_NO_UTS
, FALSE
)) {
164 xf86DrvMsg(pScreen
->myNum
, X_CONFIG
, "EXA: Disabling UploadToScreen\n");
165 pExaScr
->info
->UploadToScreen
= NULL
;
168 if (xf86ReturnOptValBool(pScreenPriv
->options
, EXAOPT_NO_DFS
, FALSE
)) {
169 xf86DrvMsg(pScreen
->myNum
, X_CONFIG
,
170 "EXA: Disabling DownloadFromScreen\n");
171 pExaScr
->info
->DownloadFromScreen
= NULL
;
174 dixSetPrivate(&pScreen
->devPrivates
, exaXorgScreenPrivateKey
, pScreenPriv
);
176 pScreenPriv
->SavedEnableDisableFBAccess
= pScrn
->EnableDisableFBAccess
;
177 pScrn
->EnableDisableFBAccess
= exaXorgEnableDisableFBAccess
;
179 pScreenPriv
->SavedCloseScreen
= pScreen
->CloseScreen
;
180 pScreen
->CloseScreen
= exaXorgCloseScreen
;
184 static XF86ModuleVersionInfo exaVersRec
= {
189 XORG_VERSION_CURRENT
,
190 EXA_VERSION_MAJOR
, EXA_VERSION_MINOR
, EXA_VERSION_RELEASE
,
191 ABI_CLASS_VIDEODRV
, /* requires the video driver ABI */
192 ABI_VIDEODRV_VERSION
,
197 _X_EXPORT XF86ModuleData exaModuleData
= { &exaVersRec
, NULL
, NULL
};