diff options
author | Christian Gmeiner <[email protected]> | 2018-08-02 20:04:45 +0200 |
---|---|---|
committer | Christian Gmeiner <[email protected]> | 2018-08-31 21:46:32 +0200 |
commit | b05a8f4f41e7f4c5405eb8d8342ef3734564ae80 (patch) | |
tree | 0dc04aa827520fe05fe5727610b2cc6f592f959b /src/gallium/drivers/tegra | |
parent | ab348885ebbc669f5dec032851147bd64a2d5e26 (diff) |
tegra: make use loader_open_render_node(..) helper
Signed-off-by: Christian Gmeiner <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/drivers/tegra')
-rw-r--r-- | src/gallium/drivers/tegra/tegra_screen.c | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c index 73fdc632933..243bdde8d2c 100644 --- a/src/gallium/drivers/tegra/tegra_screen.c +++ b/src/gallium/drivers/tegra/tegra_screen.c @@ -32,6 +32,7 @@ #include <tegra_drm.h> #include <xf86drm.h> +#include "loader/loader.h" #include "pipe/p_state.h" #include "util/u_debug.h" #include "util/u_inlines.h" @@ -163,64 +164,6 @@ tegra_screen_can_create_resource(struct pipe_screen *pscreen, return screen->gpu->can_create_resource(screen->gpu, template); } -static int tegra_open_render_node(void) -{ - drmDevicePtr *devices, device; - int err, render = -ENOENT, fd; - unsigned int num, i; - - err = drmGetDevices2(0, NULL, 0); - if (err < 0) - return err; - - num = err; - - devices = calloc(num, sizeof(*devices)); - if (!devices) - return -ENOMEM; - - err = drmGetDevices2(0, devices, num); - if (err < 0) { - render = err; - goto free; - } - - for (i = 0; i < num; i++) { - device = devices[i]; - - if ((device->available_nodes & (1 << DRM_NODE_RENDER)) && - (device->bustype == DRM_BUS_PLATFORM)) { - drmVersionPtr version; - - fd = open(device->nodes[DRM_NODE_RENDER], O_RDWR | O_CLOEXEC); - if (fd < 0) - continue; - - version = drmGetVersion(fd); - if (!version) { - close(fd); - continue; - } - - if (strcmp(version->name, "nouveau") != 0) { - drmFreeVersion(version); - close(fd); - continue; - } - - drmFreeVersion(version); - render = fd; - break; - } - } - - drmFreeDevices(devices, num); - -free: - free(devices); - return render; -} - static int tegra_screen_import_resource(struct tegra_screen *screen, struct tegra_resource *resource) { @@ -594,7 +537,7 @@ tegra_screen_create(int fd) screen->fd = fd; - screen->gpu_fd = tegra_open_render_node(); + screen->gpu_fd = loader_open_render_node("nouveau"); if (screen->gpu_fd < 0) { if (errno != ENOENT) fprintf(stderr, "failed to open GPU device: %s\n", strerror(errno)); |