dri: add dri_dlopen and dri_dlclose

They will be used for preloading.

BUG=b:269664560
TEST="grep radeonsi /proc/$(pidof zygote)/maps" on grunt

Change-Id: I6134e00bf9e046889aea7e471b7f7bcf3972604c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4262033
Reviewed-by: Yiwei Zhang <[email protected]>
Commit-Queue: Chia-I Wu <[email protected]>
Tested-by: Chia-I Wu <[email protected]>
diff --git a/dri.c b/dri.c
index 5a37c46..5a30a77 100644
--- a/dri.c
+++ b/dri.c
@@ -190,6 +190,16 @@
 	.base = { __DRI_USE_INVALIDATE, 1 },
 };
 
+void *dri_dlopen(const char *dri_so_path)
+{
+	return dlopen(dri_so_path, RTLD_NOW | RTLD_GLOBAL);
+}
+
+void dri_dlclose(void *dri_so_handle)
+{
+	dlclose(dri_so_handle);
+}
+
 /*
  * The caller is responsible for setting drv->priv to a structure that derives from dri_driver.
  */
@@ -209,7 +219,7 @@
 	if (dri->fd < 0)
 		return -ENODEV;
 
-	dri->driver_handle = dlopen(dri_so_path, RTLD_NOW | RTLD_GLOBAL);
+	dri->driver_handle = dri_dlopen(dri_so_path);
 	if (!dri->driver_handle)
 		goto close_dri_fd;
 
@@ -257,7 +267,7 @@
 free_screen:
 	dri->core_extension->destroyScreen(dri->device);
 free_handle:
-	dlclose(dri->driver_handle);
+	dri_dlclose(dri->driver_handle);
 	dri->driver_handle = NULL;
 close_dri_fd:
 	close(dri->fd);
@@ -273,7 +283,7 @@
 
 	dri->core_extension->destroyContext(dri->context);
 	dri->core_extension->destroyScreen(dri->device);
-	dlclose(dri->driver_handle);
+	dri_dlclose(dri->driver_handle);
 	dri->driver_handle = NULL;
 	close(dri->fd);
 }
diff --git a/dri.h b/dri.h
index daadf30..8136f5c 100644
--- a/dri.h
+++ b/dri.h
@@ -26,6 +26,9 @@
 	const __DRIconfig **configs;
 };
 
+void *dri_dlopen(const char *dri_so_path);
+void dri_dlclose(void *dri_so_handle);
+
 int dri_init(struct driver *drv, const char *dri_so_path, const char *driver_suffix);
 void dri_close(struct driver *drv);
 int dri_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,