summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-05-24 18:22:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-05-24 19:01:22 +0100
commite45629135065d0cc73c285f8df35ab4e1d07c6dc (patch)
tree7677db32ced6e3114ca4cf7822dabd6871d1a177 /src
parentdf6ab02c3690eea8393ecc8c113e2f2891856cc6 (diff)
Allow runtime switching of AccelMethod between uxa/sna and even glamor
Section "Device" Option "AccelMethod" "uxa/glamor/sna" EndSection The appropriate backend must also be enabled at compile time for the runtime option to be available (i.e. --enable-uxa (default) --enable-sna --enable-glamor) Demanded-by: Adam Jackson <ajax@redhat.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50290 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/common.h2
-rw-r--r--src/intel_driver.c3
-rw-r--r--src/intel_glamor.c15
-rw-r--r--src/intel_module.c81
-rw-r--r--src/intel_options.h2
-rw-r--r--src/legacy/i810/i810_driver.c3
-rw-r--r--src/legacy/legacy.h2
-rw-r--r--src/sna/sna_driver.c7
-rw-r--r--src/sna/sna_module.h2
9 files changed, 90 insertions, 27 deletions
diff --git a/src/common.h b/src/common.h
index 06b2192a..e3ab1f22 100644
--- a/src/common.h
+++ b/src/common.h
@@ -63,7 +63,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* I830 hooks for the I810 driver setup/probe. */
extern const OptionInfoRec *I830AvailableOptions(int chipid, int busid);
-extern void intel_init_scrn(ScrnInfoPtr scrn);
+extern Bool intel_init_scrn(ScrnInfoPtr scrn);
/* Symbol lists shared by the i810 and i830 parts. */
extern int I830EntityIndex;
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 6b2ab803..60f43bb8 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -1236,7 +1236,7 @@ static Bool I830PMEvent(int scrnIndex, pmEvent event, Bool undo)
return TRUE;
}
-void intel_init_scrn(ScrnInfoPtr scrn)
+Bool intel_init_scrn(ScrnInfoPtr scrn)
{
scrn->PreInit = I830PreInit;
scrn->ScreenInit = I830ScreenInit;
@@ -1247,4 +1247,5 @@ void intel_init_scrn(ScrnInfoPtr scrn)
scrn->FreeScreen = I830FreeScreen;
scrn->ValidMode = I830ValidMode;
scrn->PMEvent = I830PMEvent;
+ return TRUE;
}
diff --git a/src/intel_glamor.c b/src/intel_glamor.c
index 4741d58f..5c0186ea 100644
--- a/src/intel_glamor.c
+++ b/src/intel_glamor.c
@@ -172,6 +172,18 @@ intel_glamor_finish_access(PixmapPtr pixmap, uxa_access_t access)
return;
}
+static Bool
+intel_glamor_enabled(intel_screen_private *intel)
+{
+ const char *s;
+
+ s = xf86GetOptString(intel->Options, ACCEL_METHOD);
+ if (s == NULL)
+ return FALSE;
+
+ return strcasecmp(s, "glamor") == 0;
+}
+
Bool
intel_glamor_init(ScreenPtr screen)
{
@@ -181,6 +193,9 @@ intel_glamor_init(ScreenPtr screen)
if ((intel->uxa_flags & UXA_GLAMOR_EGL_INITIALIZED) == 0)
goto fail;
+ if (!intel_glamor_enabled(intel))
+ goto fail;
+
if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS | GLAMOR_USE_EGL_SCREEN)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"Failed to initialize glamor.\n");
diff --git a/src/intel_module.c b/src/intel_module.c
index ac6dae11..4430ac6a 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -31,6 +31,7 @@
#include <xf86.h>
#include <xf86_OSproc.h>
#include <xf86cmap.h>
+#include <xf86Parser.h>
#include <xf86drmMode.h>
#include <xorgVersion.h>
@@ -292,6 +293,43 @@ static Bool has_kernel_mode_setting(struct pci_device *dev)
return ret == 0;
}
+extern XF86ConfigPtr xf86configptr;
+
+static XF86ConfDevicePtr
+_xf86findDriver(const char *ident, XF86ConfDevicePtr p)
+{
+ while (p) {
+ if (xf86nameCompare(ident, p->dev_driver) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+static enum accel_method { UXA, SNA } get_accel_method(void)
+{
+ enum accel_method accel_method = DEFAULT_ACCEL_METHOD;
+ XF86ConfDevicePtr dev;
+
+ dev = _xf86findDriver("intel", xf86configptr->conf_device_lst);
+ if (dev && dev->dev_option_lst) {
+ const char *s;
+
+ s = xf86FindOptionValue(dev->dev_option_lst, "AccelMethod");
+ if (s ) {
+ if (strcasecmp(s, "sna") == 0)
+ accel_method = SNA;
+ else if (strcasecmp(s, "uxa") == 0)
+ accel_method = UXA;
+ else if (strcasecmp(s, "glamor") == 0)
+ accel_method = UXA;
+ }
+ }
+
+ return accel_method;
+}
+
/*
* intel_pci_probe --
*
@@ -338,34 +376,35 @@ static Bool intel_pci_probe(DriverPtr driver,
scrn = xf86ConfigPciEntity(NULL, 0, entity_num, intel_pci_chipsets,
NULL, NULL, NULL, NULL, NULL);
- if (scrn != NULL) {
- scrn->driverVersion = INTEL_VERSION;
- scrn->driverName = INTEL_DRIVER_NAME;
- scrn->name = INTEL_NAME;
- scrn->Probe = NULL;
+ if (scrn == NULL)
+ return FALSE;
+
+ scrn->driverVersion = INTEL_VERSION;
+ scrn->driverName = INTEL_DRIVER_NAME;
+ scrn->name = INTEL_NAME;
+ scrn->Probe = NULL;
- switch (DEVICE_ID(device)) {
#if !KMS_ONLY
- case PCI_CHIP_I810:
- case PCI_CHIP_I810_DC100:
- case PCI_CHIP_I810_E:
- case PCI_CHIP_I815:
- lg_i810_init(scrn);
- break;
+ switch (DEVICE_ID(device)) {
+ case PCI_CHIP_I810:
+ case PCI_CHIP_I810_DC100:
+ case PCI_CHIP_I810_E:
+ case PCI_CHIP_I815:
+ return lg_i810_init(scrn);
+ }
#endif
- default:
+ switch (get_accel_method()) {
#if USE_SNA
- sna_init_scrn(scrn, entity_num);
-#elif USE_UXA
- intel_init_scrn(scrn);
-#else
- scrn = NULL;
+ case SNA: return sna_init_scrn(scrn, entity_num);
#endif
- break;
- }
+
+#if USE_UXA
+ case UXA: return intel_init_scrn(scrn);
+#endif
+
+ default: return FALSE;
}
- return scrn != NULL;
}
#ifdef XFree86LOADER
diff --git a/src/intel_options.h b/src/intel_options.h
index 93677511..8863878a 100644
--- a/src/intel_options.h
+++ b/src/intel_options.h
@@ -8,6 +8,7 @@
*/
enum intel_options {
+ OPTION_ACCEL_METHOD,
OPTION_DRI,
OPTION_VIDEO_KEY,
OPTION_COLOR_KEY,
@@ -40,6 +41,7 @@ enum intel_options {
};
static OptionInfoRec intel_options[] = {
+ {OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, 0},
{OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, TRUE},
{OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE},
{OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE},
diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c
index 09d52c5a..6ead393a 100644
--- a/src/legacy/i810/i810_driver.c
+++ b/src/legacy/i810/i810_driver.c
@@ -2102,7 +2102,7 @@ lg_i810_available_options(int chipid, int busid)
}
-void lg_i810_init(ScrnInfoPtr scrn)
+Bool lg_i810_init(ScrnInfoPtr scrn)
{
scrn->PreInit = I810PreInit;
scrn->ScreenInit = I810ScreenInit;
@@ -2112,4 +2112,5 @@ void lg_i810_init(ScrnInfoPtr scrn)
scrn->LeaveVT = I810LeaveVT;
scrn->FreeScreen = I810FreeScreen;
scrn->ValidMode = I810ValidMode;
+ return TRUE;
}
diff --git a/src/legacy/legacy.h b/src/legacy/legacy.h
index 7bdd1729..0ff32990 100644
--- a/src/legacy/legacy.h
+++ b/src/legacy/legacy.h
@@ -1,3 +1,3 @@
/* The old i810 (only) driver. */
const OptionInfoRec *lg_i810_available_options(int chipid, int busid);
-void lg_i810_init(ScrnInfoPtr scrn);
+Bool lg_i810_init(ScrnInfoPtr scrn);
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 5d42e69c..fb54a24c 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -1047,7 +1047,7 @@ static Bool sna_pm_event(int scrnIndex, pmEvent event, Bool undo)
return TRUE;
}
-void sna_init_scrn(ScrnInfoPtr scrn, int entity_num)
+Bool sna_init_scrn(ScrnInfoPtr scrn, int entity_num)
{
EntityInfoPtr entity;
@@ -1081,8 +1081,13 @@ void sna_init_scrn(ScrnInfoPtr scrn, int entity_num)
xf86SetEntitySharable(scrn->entityList[0]);
entity = xf86GetEntityInfo(entity_num);
+ if (!entity)
+ return FALSE;
+
xf86SetEntityInstanceForScreen(scrn,
entity->index,
xf86GetNumEntityInstances(entity->index)-1);
free(entity);
+
+ return TRUE;
}
diff --git a/src/sna/sna_module.h b/src/sna/sna_module.h
index aa1ae0d3..1b46cb74 100644
--- a/src/sna/sna_module.h
+++ b/src/sna/sna_module.h
@@ -1 +1 @@
-void sna_init_scrn(ScrnInfoPtr scrn, int entity_num);
+Bool sna_init_scrn(ScrnInfoPtr scrn, int entity_num);