summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2014-01-11 04:28:24 +0000
committerEmil Velikov <[email protected]>2014-01-18 18:47:49 +0000
commita0a1c60fb0137804e6abf403898468fe103ec382 (patch)
tree6641798abdce75dde21a0797c3ea3c0c3960945e /src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
parent0e78c3523427190d649b02f586a6554889d74c2f (diff)
pipe-loader: use loader util lib
Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c')
-rw-r--r--src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c88
1 files changed, 8 insertions, 80 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 683d6a63691..2a50236e27c 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -48,9 +48,6 @@
#include "util/u_dl.h"
#include "util/u_debug.h"
-#define DRIVER_MAP_GALLIUM_ONLY
-#include "pci_ids/pci_id_driver_map.h"
-
struct pipe_loader_drm_device {
struct pipe_loader_device base;
struct util_dl_library *lib;
@@ -59,78 +56,6 @@ struct pipe_loader_drm_device {
#define pipe_loader_drm_device(dev) ((struct pipe_loader_drm_device *)dev)
-static boolean
-find_drm_pci_id(struct pipe_loader_drm_device *ddev)
-{
- struct udev *udev = NULL;
- struct udev_device *parent, *device = NULL;
- struct stat stat;
- const char *pci_id;
-
- if (fstat(ddev->fd, &stat) < 0)
- goto fail;
-
- udev = udev_new();
- if (!udev)
- goto fail;
-
- device = udev_device_new_from_devnum(udev, 'c', stat.st_rdev);
- if (!device)
- goto fail;
-
- parent = udev_device_get_parent(device);
- if (!parent)
- goto fail;
-
- pci_id = udev_device_get_property_value(parent, "PCI_ID");
- if (!pci_id ||
- sscanf(pci_id, "%x:%x", &ddev->base.u.pci.vendor_id,
- &ddev->base.u.pci.chip_id) != 2)
- goto fail;
-
- udev_device_unref(device);
- udev_unref(udev);
-
- return TRUE;
-
- fail:
- if (device)
- udev_device_unref(device);
- if (udev)
- udev_unref(udev);
-
- return FALSE;
-}
-
-static boolean
-find_drm_driver_name(struct pipe_loader_drm_device *ddev)
-{
- struct pipe_loader_device *dev = &ddev->base;
- int i, j;
-
- for (i = 0; driver_map[i].driver; i++) {
- if (dev->u.pci.vendor_id != driver_map[i].vendor_id)
- continue;
-
- if (driver_map[i].num_chips_ids == -1) {
- dev->driver_name = driver_map[i].driver;
- goto found;
- }
-
- for (j = 0; j < driver_map[i].num_chips_ids; j++) {
- if (dev->u.pci.chip_id == driver_map[i].chip_ids[j]) {
- dev->driver_name = driver_map[i].driver;
- goto found;
- }
- }
- }
-
- return FALSE;
-
- found:
- return TRUE;
-}
-
static struct pipe_loader_ops pipe_loader_drm_ops;
static void
@@ -190,17 +115,20 @@ boolean
pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
{
struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device);
+ int vendor_id, chip_id;
- ddev->base.type = PIPE_LOADER_DEVICE_PCI;
+ if (loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
+ ddev->base.type = PIPE_LOADER_DEVICE_PCI;
+ ddev->base.u.pci.vendor_id = vendor_id;
+ ddev->base.u.pci.chip_id = chip_id;
+ }
ddev->base.ops = &pipe_loader_drm_ops;
ddev->fd = fd;
pipe_loader_drm_x_auth(fd);
- if (!find_drm_pci_id(ddev))
- goto fail;
-
- if (!find_drm_driver_name(ddev))
+ ddev->base.driver_name = loader_get_driver_for_fd(fd, _LOADER_GALLIUM);
+ if (!ddev->base.driver_name)
goto fail;
*dev = &ddev->base;