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 EnableDisableFBAccessProcPtr SavedEnableDisableFBAccess
;
42 OptionInfoPtr options
;
43 } ExaXorgScreenPrivRec
, *ExaXorgScreenPrivPtr
;
45 static int exaXorgServerGeneration
;
46 static int exaXorgScreenPrivateIndex
;
49 EXAOPT_MIGRATION_HEURISTIC
,
55 static const OptionInfoRec EXAOptions
[] = {
56 { EXAOPT_MIGRATION_HEURISTIC
, "MigrationHeuristic",
57 OPTV_ANYSTR
, {0}, FALSE
},
58 { EXAOPT_NO_COMPOSITE
, "EXANoComposite",
59 OPTV_BOOLEAN
, {0}, FALSE
},
60 { EXAOPT_NO_UTS
, "EXANoUploadToScreen",
61 OPTV_BOOLEAN
, {0}, FALSE
},
62 { EXAOPT_NO_DFS
, "EXANoDownloadFromScreen",
63 OPTV_BOOLEAN
, {0}, FALSE
},
65 OPTV_NONE
, {0}, FALSE
}
69 exaXorgCloseScreen (int i
, ScreenPtr pScreen
)
71 ScrnInfoPtr pScrn
= XF86SCRNINFO(pScreen
);
72 ExaXorgScreenPrivPtr pScreenPriv
=
73 pScreen
->devPrivates
[exaXorgScreenPrivateIndex
].ptr
;
75 pScreen
->CloseScreen
= pScreenPriv
->SavedCloseScreen
;
77 pScrn
->EnableDisableFBAccess
= pScreenPriv
->SavedEnableDisableFBAccess
;
79 xfree (pScreenPriv
->options
);
82 return pScreen
->CloseScreen (i
, pScreen
);
86 exaXorgEnableDisableFBAccess (int index
, Bool enable
)
88 ScreenPtr pScreen
= screenInfo
.screens
[index
];
89 ExaXorgScreenPrivPtr pScreenPriv
=
90 pScreen
->devPrivates
[exaXorgScreenPrivateIndex
].ptr
;
93 exaEnableDisableFBAccess (index
, enable
);
95 if (pScreenPriv
->SavedEnableDisableFBAccess
)
96 pScreenPriv
->SavedEnableDisableFBAccess (index
, enable
);
99 exaEnableDisableFBAccess (index
, enable
);
103 * This will be called during exaDriverInit, giving us the chance to set options
104 * and hook in our EnableDisableFBAccess.
107 exaDDXDriverInit(ScreenPtr pScreen
)
109 ExaScreenPriv(pScreen
);
110 /* Do NOT use XF86SCRNINFO macro here!! */
111 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
112 ExaXorgScreenPrivPtr pScreenPriv
;
114 if (exaXorgServerGeneration
!= serverGeneration
) {
115 exaXorgScreenPrivateIndex
= AllocateScreenPrivateIndex();
116 exaXorgServerGeneration
= serverGeneration
;
119 pScreenPriv
= xcalloc (1, sizeof(ExaXorgScreenPrivRec
));
120 if (pScreenPriv
== NULL
)
123 pScreenPriv
->options
= xnfalloc (sizeof(EXAOptions
));
124 memcpy(pScreenPriv
->options
, EXAOptions
, sizeof(EXAOptions
));
125 xf86ProcessOptions (pScrn
->scrnIndex
, pScrn
->options
, pScreenPriv
->options
);
127 if ((pExaScr
->info
->flags
& EXA_OFFSCREEN_PIXMAPS
) &&
128 pExaScr
->info
->offScreenBase
< pExaScr
->info
->memorySize
)
132 heuristicName
= xf86GetOptValString (pScreenPriv
->options
,
133 EXAOPT_MIGRATION_HEURISTIC
);
134 if (heuristicName
!= NULL
) {
135 if (strcmp(heuristicName
, "greedy") == 0)
136 pExaScr
->migration
= ExaMigrationGreedy
;
137 else if (strcmp(heuristicName
, "always") == 0)
138 pExaScr
->migration
= ExaMigrationAlways
;
139 else if (strcmp(heuristicName
, "smart") == 0)
140 pExaScr
->migration
= ExaMigrationSmart
;
142 xf86DrvMsg (pScreen
->myNum
, X_WARNING
,
143 "EXA: unknown migration heuristic %s\n",
149 if (xf86IsOptionSet(pScreenPriv
->options
, EXAOPT_NO_COMPOSITE
)) {
150 xf86DrvMsg(pScreen
->myNum
, X_INFO
,
151 "EXA: Disabling Composite operation "
152 "(RENDER acceleration)\n");
153 pExaScr
->info
->CheckComposite
= NULL
;
154 pExaScr
->info
->PrepareComposite
= NULL
;
157 if (xf86IsOptionSet(pScreenPriv
->options
, EXAOPT_NO_UTS
)) {
158 xf86DrvMsg(pScreen
->myNum
, X_INFO
,
159 "EXA: Disabling UploadToScreen\n");
160 pExaScr
->info
->UploadToScreen
= NULL
;
163 if (xf86IsOptionSet(pScreenPriv
->options
, EXAOPT_NO_DFS
)) {
164 xf86DrvMsg(pScreen
->myNum
, X_INFO
,
165 "EXA: Disabling DownloadFromScreen\n");
166 pExaScr
->info
->DownloadFromScreen
= NULL
;
169 pScreen
->devPrivates
[exaXorgScreenPrivateIndex
].ptr
= pScreenPriv
;
171 pScreenPriv
->SavedEnableDisableFBAccess
= pScrn
->EnableDisableFBAccess
;
172 pScrn
->EnableDisableFBAccess
= exaXorgEnableDisableFBAccess
;
174 pScreenPriv
->SavedCloseScreen
= pScreen
->CloseScreen
;
175 pScreen
->CloseScreen
= exaXorgCloseScreen
;
179 static MODULESETUPPROTO(exaSetup
);
182 static const OptionInfoRec
*
183 EXAAvailableOptions(void *unused
)
188 static XF86ModuleVersionInfo exaVersRec
=
194 XORG_VERSION_CURRENT
,
195 EXA_VERSION_MAJOR
, EXA_VERSION_MINOR
, EXA_VERSION_RELEASE
,
196 ABI_CLASS_VIDEODRV
, /* requires the video driver ABI */
197 ABI_VIDEODRV_VERSION
,
202 _X_EXPORT XF86ModuleData exaModuleData
= { &exaVersRec
, exaSetup
, NULL
};
204 static ModuleInfoRec EXA
= {
214 exaSetup(pointer Module
, pointer Options
, int *ErrorMajor
, int *ErrorMinor
)
216 static Bool Initialised
= FALSE
;
220 xf86AddModuleInfo(&EXA
, Module
);
223 return (pointer
)TRUE
;