From b05a8f4f41e7f4c5405eb8d8342ef3734564ae80 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Thu, 2 Aug 2018 20:04:45 +0200 Subject: [PATCH] tegra: make use loader_open_render_node(..) helper Signed-off-by: Christian Gmeiner Reviewed-by: Emil Velikov --- src/gallium/drivers/tegra/tegra_screen.c | 61 +----------------------- 1 file 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 #include +#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)); -- 2.30.2