Commit 29ed4f28 authored by Marico Xu's avatar Marico Xu

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
parent 25f588e2
......@@ -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)
......
......@@ -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 \
......
......@@ -724,6 +724,37 @@ out:
return foundScreen;
}
/**
* 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;
......
......@@ -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
......@@ -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;
}
......@@ -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;
}
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment