summaryrefslogtreecommitdiff
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
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>
-rw-r--r--configure.ac38
-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
10 files changed, 127 insertions, 28 deletions
diff --git a/configure.ac b/configure.ac
index c031a26f..a025521c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,6 +158,43 @@ if test "x$GLAMOR" != "xno"; then
AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
fi
+AC_ARG_WITH(default-accel,
+ AS_HELP_STRING([--with-default-accel],
+ [Select the default acceleration method [default=sna if enabled, otherwise uxa]]),
+ [accel="$withval"],
+ [accel=auto])
+
+AC_MSG_CHECKING([which acceleration method to use by default])
+if test "x$accel" = xauto; then
+ if test "x$UXA" != "xno"; then
+ accel=uxa
+ else
+ if test "x$SNA" != "xno"; then
+ accel=sna
+ fi
+ fi
+ if test "x$accel" = xauto; then
+ AC_MSG_ERROR([No default acceleration option])
+ fi
+fi
+
+if test "x$accel" = xsna; then
+ if test "x$SNA" != "xno"; then
+ AC_DEFINE(DEFAULT_ACCEL_METHOD, SNA, [Default acceleration method])
+ else
+ AC_MSG_ERROR([SNA requested as default, but is not enabled])
+ fi
+fi
+
+if test "x$accel" = xuxa; then
+ if test "x$UXA" != "xno"; then
+ AC_DEFINE(DEFAULT_ACCEL_METHOD, UXA, [Default acceleration method])
+ else
+ AC_MSG_ERROR([UXA requested as default, but is not enabled])
+ fi
+fi
+AC_MSG_RESULT($accel)
+
AC_ARG_ENABLE(vmap,
AS_HELP_STRING([--enable-vmap],
[Enable use of vmap [default=no]]),
@@ -174,7 +211,6 @@ AC_ARG_ENABLE(debug,
[Enables internal debugging [default=no]]),
[DEBUG="$enableval"],
[DEBUG=no])
-
# Store the list of server defined optional extensions in REQUIRED_MODULES
XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
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);