summaryrefslogtreecommitdiff
path: root/libkms/api.c
diff options
context:
space:
mode:
Diffstat (limited to 'libkms/api.c')
-rw-r--r--libkms/api.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/libkms/api.c b/libkms/api.c
index 478fa38c..6cec4b96 100644
--- a/libkms/api.c
+++ b/libkms/api.c
@@ -32,13 +32,34 @@
#include <string.h>
#include "internal.h"
-int kms_create(int fd, struct kms_driver **out)
+struct create_record
{
+ unsigned vendor;
+ unsigned chip;
+ int (*func)(int fd, struct kms_driver **out);
+};
+
+static struct create_record table[] = {
#ifdef HAVE_VMWGFX
- return vmwgfx_create(fd, out);
-#else
- return -ENOSYS;
+ { 0x15ad, 0x0405, vmwgfx_create }, /* VMware vGPU */
#endif
+ { 0, 0, NULL },
+};
+
+int kms_create(int fd, struct kms_driver **out)
+{
+ unsigned vendor_id, chip_id;
+ int ret, i;
+
+ ret = linux_get_pciid_from_fd(fd, &vendor_id, &chip_id);
+ if (ret)
+ return ret;
+
+ for (i = 0; table[i].func; i++)
+ if (table[i].vendor == vendor_id && table[i].chip == chip_id)
+ return table[i].func(fd, out);
+
+ return -ENOSYS;
}
int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)