[Mesa-dev] [PATCH 3/6] gallium: pipe-loader: make aware of platform DRM devices
Lucas Stach
l.stach at pengutronix.de
Wed Nov 6 08:22:53 PST 2013
Allows to load gallium pipes for ARM DRM drivers.
Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
include/platform_ids/platform_driver_map.h | 18 ++++++++
src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 +
.../auxiliary/pipe-loader/pipe_loader_drm.c | 53 ++++++++++++++++++----
3 files changed, 62 insertions(+), 10 deletions(-)
create mode 100644 include/platform_ids/platform_driver_map.h
diff --git a/include/platform_ids/platform_driver_map.h b/include/platform_ids/platform_driver_map.h
new file mode 100644
index 000000000000..c428b81349e6
--- /dev/null
+++ b/include/platform_ids/platform_driver_map.h
@@ -0,0 +1,18 @@
+#ifndef _PLATFORM_DRIVER_MAP_H_
+#define _PLATFORM_DRIVER_MAP_H_
+
+#include <stddef.h>
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+static const struct {
+ const char *driver;
+ const char **platform_ids;
+ int num_platform_ids;
+} platform_driver_map[] = {
+ { NULL, NULL, 0 }
+};
+
+#endif /* _PLATFORM_DRIVER_MAP_H_ */
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 444bdf1751f9..e915c6380185 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -44,6 +44,7 @@ struct pipe_screen;
enum pipe_loader_device_type {
PIPE_LOADER_DEVICE_SOFTWARE,
PIPE_LOADER_DEVICE_PCI,
+ PIPE_LOADER_DEVICE_PLATFORM,
NUM_PIPE_LOADER_DEVICE_TYPES
};
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 339d7bf10b67..908beac24cb4 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 @@
#define DRIVER_MAP_GALLIUM_ONLY
#include "pci_ids/pci_id_driver_map.h"
+#include "platform_ids/platform_driver_map.h"
struct pipe_loader_drm_device {
struct pipe_loader_device base;
@@ -88,6 +89,7 @@ find_drm_pci_id(struct pipe_loader_drm_device *ddev)
&ddev->base.u.pci.chip_id) != 2)
goto fail;
+ ddev->base.type = PIPE_LOADER_DEVICE_PCI;
return TRUE;
fail:
@@ -100,7 +102,7 @@ find_drm_pci_id(struct pipe_loader_drm_device *ddev)
}
static boolean
-find_drm_driver_name(struct pipe_loader_drm_device *ddev)
+find_drm_pci_driver_name(struct pipe_loader_drm_device *ddev)
{
struct pipe_loader_device *dev = &ddev->base;
int i, j;
@@ -128,6 +130,36 @@ find_drm_driver_name(struct pipe_loader_drm_device *ddev)
return TRUE;
}
+static boolean
+find_drm_platform_driver(struct pipe_loader_drm_device *ddev)
+{
+ char *driver = NULL;
+ drmVersionPtr version;
+ int i, j;
+
+ version = drmGetVersion(ddev->fd);
+ if (!version)
+ return FALSE;
+
+ driver = strndup(version->name, version->name_len);
+ drmFreeVersion(version);
+
+ for (i = 0; platform_driver_map[i].driver; i++) {
+ for (j = 0; j < platform_driver_map[i].num_platform_ids; j++) {
+ if (strcmp(driver, platform_driver_map[i].platform_ids[j]) == 0) {
+ ddev->base.driver_name = platform_driver_map[i].driver;
+ ddev->base.type = PIPE_LOADER_DEVICE_PLATFORM;
+
+ free(driver);
+ return TRUE;
+ }
+ }
+ }
+
+ free(driver);
+ return FALSE;
+}
+
static struct pipe_loader_ops pipe_loader_drm_ops;
static void
@@ -188,22 +220,23 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
{
struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device);
- ddev->base.type = PIPE_LOADER_DEVICE_PCI;
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))
- goto fail;
+ if (find_drm_pci_id(ddev)) {
+ if (find_drm_pci_driver_name(ddev)) {
+ *dev = &ddev->base;
+ return TRUE;
+ }
+ }
- *dev = &ddev->base;
- return TRUE;
+ if (find_drm_platform_driver(ddev)) {
+ *dev = &ddev->base;
+ return TRUE;
+ }
- fail:
FREE(ddev);
return FALSE;
}
--
1.8.4.rc3
More information about the mesa-dev
mailing list