summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-10-17 21:51:45 +0100
committerEmil Velikov <[email protected]>2015-11-21 12:52:19 +0000
commit3ca12ee976e44a1126775a8e801889d42dd06980 (patch)
tree158acb1581a19d81f31eebf54fbe3c4ca8dceeba /src/gallium/auxiliary
parente465de5a51dbb1af50da1a44353867adc45d57c7 (diff)
pipe-loader: dlopen/dlsym the pipe-driver at probe time
Rather than giving false hopes that things might work, just check at probe time. This allows us to remove the duplication and consolidate the code wrt the upcomming static pipe-loader. Cc: Tom Stellard <[email protected]> Cc: Francisco Jerez <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Acked-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index d4cb317447a..33274deeec5 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -50,6 +50,7 @@
struct pipe_loader_drm_device {
struct pipe_loader_device base;
+ const struct drm_driver_descriptor *dd;
struct util_dl_library *lib;
int fd;
};
@@ -81,10 +82,23 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
if (!ddev->base.driver_name)
goto fail;
+ ddev->lib = pipe_loader_find_module(dev, PIPE_SEARCH_DIR);
+ if (!ddev->lib)
+ return fail;
+
+ ddev->dd = (const struct drm_driver_descriptor *)
+ util_dl_get_proc_address(ddev->lib, "driver_descriptor");
+
+ /* sanity check on the name */
+ if (!ddev->dd || strcmp(ddev->dd->name, ddev->base.driver_name) != 0)
+ goto fail;
+
*dev = &ddev->base;
return true;
fail:
+ if (ddev->lib)
+ util_dl_close(ddev->lib);
FREE(ddev);
return false;
}
@@ -146,43 +160,19 @@ pipe_loader_drm_configuration(struct pipe_loader_device *dev,
enum drm_conf conf)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
- const struct drm_driver_descriptor *dd;
-
- if (!ddev->lib)
- return NULL;
-
- dd = (const struct drm_driver_descriptor *)
- util_dl_get_proc_address(ddev->lib, "driver_descriptor");
-
- /* sanity check on the name */
- if (!dd || strcmp(dd->name, ddev->base.driver_name) != 0)
- return NULL;
- if (!dd->configuration)
+ if (!ddev->dd->configuration)
return NULL;
- return dd->configuration(conf);
+ return ddev->dd->configuration(conf);
}
static struct pipe_screen *
pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
- const struct drm_driver_descriptor *dd;
-
- if (!ddev->lib)
- ddev->lib = pipe_loader_find_module(&ddev->base, PIPE_SEARCH_DIR);
- if (!ddev->lib)
- return NULL;
-
- dd = (const struct drm_driver_descriptor *)
- util_dl_get_proc_address(ddev->lib, "driver_descriptor");
-
- /* sanity check on the name */
- if (!dd || strcmp(dd->name, ddev->base.driver_name) != 0)
- return NULL;
- return dd->create_screen(ddev->fd);
+ return ddev->dd->create_screen(ddev->fd);
}
static const struct pipe_loader_ops pipe_loader_drm_ops = {