summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarico Xu <marico.xu@arm.com>2015-07-24 14:14:43 +0800
committerMarico Xu <marico.xu@arm.com>2015-07-24 10:46:11 +0100
commit29ed4f28030b580ef05a0b24bdd2c435b5af6cfe (patch)
tree0852c37805876c568a17e9c6b6faabc0744e30c9
parent25f588e2c4addb74ef0f730485878610073b6470 (diff)
Dynamically detect drmmode driver
By querying the DRM driver name from the kernel, we can dynamically select the right backend. No need to enforce a specific backend at compile time. Change-Id: I6c27103233e2cbb4283a22089720b5ffd1a10bb6
-rw-r--r--configure.ac9
-rw-r--r--src/Makefile.am4
-rw-r--r--src/armsoc_driver.c33
-rw-r--r--src/drmmode_driver.h7
-rw-r--r--src/drmmode_exynos/drmmode_exynos.c6
-rw-r--r--src/drmmode_pl111/drmmode_pl111.c6
-rw-r--r--src/drmmode_template/drmmode_template.c7
7 files changed, 44 insertions, 28 deletions
diff --git a/configure.ac b/configure.ac
index d5536a6..cbfaaa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,15 +58,6 @@ AC_ARG_WITH(xorg-module-dir,
[moduledir="$withval"],
[moduledir="$libdir/xorg/modules"])
-AC_MSG_CHECKING([which DRM driver to use])
-AC_ARG_WITH(drmmode,
- AS_HELP_STRING([--with-drmmode],
- [Which DRM driver to use (see README)]),
- [drmmode=$withval],
- AC_MSG_FAILURE([You must specify which DRM driver to build for - see README]))
-AC_MSG_RESULT([$drmmode])
-AC_SUBST(drmmode)
-
# Checks for extensions
XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
diff --git a/src/Makefile.am b/src/Makefile.am
index e9fe871..e5bfe8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,7 +40,9 @@ armsoc_drv_la_LTLIBRARIES = armsoc_drv.la
armsoc_drv_la_LDFLAGS = -module -avoid-version -no-undefined
armsoc_drv_la_LIBADD = @XORG_LIBS@
armsoc_drv_ladir = @moduledir@/drivers
-DRMMODE_SRCS = drmmode_@drmmode@/drmmode_@drmmode@.c
+DRMMODE_SRCS = drmmode_exynos/drmmode_exynos.c \
+ drmmode_pl111/drmmode_pl111.c
+
armsoc_drv_la_SOURCES = \
drmmode_display.c \
diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c
index 972922c..f21d8ef 100644
--- a/src/armsoc_driver.c
+++ b/src/armsoc_driver.c
@@ -725,6 +725,37 @@ out:
}
/**
+ * Find a drmmode driver with the same name as the underlying
+ * drm kernel driver
+*/
+static struct drmmode_interface *get_drmmode_implementation(int drm_fd)
+{
+ drmVersionPtr version;
+ struct drmmode_interface *ret = NULL;
+ struct drmmode_interface *ifaces[] = {
+ &exynos_interface,
+ &pl111_interface,
+ };
+ int i;
+
+ version = drmGetVersion(drm_fd);
+ if (!version)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(ifaces); i++) {
+ struct drmmode_interface *iface = ifaces[i];
+ if (strcmp(version->name, iface->driver_name) == 0) {
+ ret = iface;
+ break;
+ }
+ }
+
+ drmFreeVersion(version);
+ return ret;
+}
+
+
+/**
* The driver's PreInit() function. Additional hardware probing is allowed
* now, including display configuration.
*/
@@ -807,7 +838,7 @@ ARMSOCPreInit(ScrnInfoPtr pScrn, int flags)
goto fail;
pARMSOC->drmmode_interface =
- drmmode_interface_get_implementation(pARMSOC->drmFD);
+ get_drmmode_implementation(pARMSOC->drmFD);
if (!pARMSOC->drmmode_interface)
goto fail2;
diff --git a/src/drmmode_driver.h b/src/drmmode_driver.h
index aa31d2b..55c8b8a 100644
--- a/src/drmmode_driver.h
+++ b/src/drmmode_driver.h
@@ -38,6 +38,9 @@ enum hwcursor_api {
};
struct drmmode_interface {
+ /* Must match name used in the kernel driver */
+ const char *driver_name;
+
/* Boolean value indicating whether DRM page flip events should
* be requested and waited for during DRM_IOCTL_MODE_PAGE_FLIP.
*/
@@ -99,6 +102,8 @@ struct drmmode_interface {
int (*create_custom_gem)(int fd, struct armsoc_create_gem *create_gem);
};
-struct drmmode_interface *drmmode_interface_get_implementation(int drm_fd);
+extern struct drmmode_interface exynos_interface;
+extern struct drmmode_interface pl111_interface;
+
#endif
diff --git a/src/drmmode_exynos/drmmode_exynos.c b/src/drmmode_exynos/drmmode_exynos.c
index 5985cfd..6b79522 100644
--- a/src/drmmode_exynos/drmmode_exynos.c
+++ b/src/drmmode_exynos/drmmode_exynos.c
@@ -145,6 +145,7 @@ static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem)
}
struct drmmode_interface exynos_interface = {
+ "exynos" /* name of drm driver */,
1 /* use_page_flip_events */,
1 /* use_early_display */,
CURSORW /* cursor width */,
@@ -155,8 +156,3 @@ struct drmmode_interface exynos_interface = {
0 /* vblank_query_supported */,
create_custom_gem /* create_custom_gem */,
};
-
-struct drmmode_interface *drmmode_interface_get_implementation(int drm_fd)
-{
- return &exynos_interface;
-}
diff --git a/src/drmmode_pl111/drmmode_pl111.c b/src/drmmode_pl111/drmmode_pl111.c
index 7b52168..a36c748 100644
--- a/src/drmmode_pl111/drmmode_pl111.c
+++ b/src/drmmode_pl111/drmmode_pl111.c
@@ -106,6 +106,7 @@ static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem)
}
struct drmmode_interface pl111_interface = {
+ "pl111" /* name of drm driver */,
1 /* use_page_flip_events */,
1 /* use_early_display */,
CURSORW /* cursor width */,
@@ -116,8 +117,3 @@ struct drmmode_interface pl111_interface = {
0 /* vblank_query_supported */,
create_custom_gem /* create_custom_gem */,
};
-
-struct drmmode_interface *drmmode_interface_get_implementation(int drm_fd)
-{
- return &pl111_interface;
-}
diff --git a/src/drmmode_template/drmmode_template.c b/src/drmmode_template/drmmode_template.c
index 3330a58..8c4a6b4 100644
--- a/src/drmmode_template/drmmode_template.c
+++ b/src/drmmode_template/drmmode_template.c
@@ -53,6 +53,7 @@ static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem)
}
struct drmmode_interface template_interface = {
+ "template" /* name of drm driver*/
1 /* use_page_flip_events */,
1 /* use_early_display */,
CURSORW /* cursor width */,
@@ -63,9 +64,3 @@ struct drmmode_interface template_interface = {
0 /* vblank_query_supported */,
create_custom_gem /* create_custom_gem */,
};
-
-struct drmmode_interface *drmmode_interface_get_implementation(int drm_fd)
-{
- return &template_interface;
-}
-