aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Bornecrantz2010-01-07 20:51:04 -0600
committerJakob Bornecrantz2010-01-07 21:05:00 -0600
commit9042d72109d8ae448b8e0f23b93067cc37deff23 (patch)
tree3b23755f0161f3c40531ffee33bfe84afc9bcef8 /libkms/api.c
parent04f90a44709a48fb932ea954011cb551659bf246 (diff)
downloadexternal-libdrm-9042d72109d8ae448b8e0f23b93067cc37deff23.tar.gz
external-libdrm-9042d72109d8ae448b8e0f23b93067cc37deff23.tar.xz
external-libdrm-9042d72109d8ae448b8e0f23b93067cc37deff23.zip
libkms: Pick driver backend via pci id that we get from udev
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 @@
32#include <string.h> 32#include <string.h>
33#include "internal.h" 33#include "internal.h"
34 34
35int kms_create(int fd, struct kms_driver **out) 35struct create_record
36{ 36{
37 unsigned vendor;
38 unsigned chip;
39 int (*func)(int fd, struct kms_driver **out);
40};
41
42static struct create_record table[] = {
37#ifdef HAVE_VMWGFX 43#ifdef HAVE_VMWGFX
38 return vmwgfx_create(fd, out); 44 { 0x15ad, 0x0405, vmwgfx_create }, /* VMware vGPU */
39#else
40 return -ENOSYS;
41#endif 45#endif
46 { 0, 0, NULL },
47};
48
49int kms_create(int fd, struct kms_driver **out)
50{
51 unsigned vendor_id, chip_id;
52 int ret, i;
53
54 ret = linux_get_pciid_from_fd(fd, &vendor_id, &chip_id);
55 if (ret)
56 return ret;
57
58 for (i = 0; table[i].func; i++)
59 if (table[i].vendor == vendor_id && table[i].chip == chip_id)
60 return table[i].func(fd, out);
61
62 return -ENOSYS;
42} 63}
43 64
44int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out) 65int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)