all: include config.h only when available and use its defines
[platform/upstream/libdrm.git] / libkms / api.c
index 6cec4b9..b512c42 100644 (file)
  **************************************************************************/
 
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include "internal.h"
 
-struct create_record
-{
-       unsigned vendor;
-       unsigned chip;
-       int (*func)(int fd, struct kms_driver **out);
-};
-
-static struct create_record table[] = {
-#ifdef HAVE_VMWGFX
-       { 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;
+       return linux_create(fd, out);
 }
 
 int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)
 {
        switch (key) {
-       case KMS_MAX_SCANOUT_WIDTH:
-       case KMS_MAX_SCANOUT_HEIGHT:
-       case KMS_MIN_SCANOUT_WIDTH:
-       case KMS_MIN_SCANOUT_HEIGHT:
-       case KMS_MAX_CURSOR_WIDTH:
-       case KMS_MAX_CURSOR_HEIGHT:
-       case KMS_MIN_CURSOR_WIDTH:
-       case KMS_MIN_CURSOR_HEIGHT:
+       case KMS_BO_TYPE:
                break;
        default:
                return -EINVAL;
@@ -94,7 +64,7 @@ int kms_bo_create(struct kms_driver *kms, const unsigned *attr, struct kms_bo **
 {
        unsigned width = 0;
        unsigned height = 0;
-       enum kms_bo_type type = KMS_BO_TYPE_SCANOUT;
+       enum kms_bo_type type = KMS_BO_TYPE_SCANOUT_X8R8G8B8;
        int i;
 
        for (i = 0; attr[i];) {
@@ -112,13 +82,19 @@ int kms_bo_create(struct kms_driver *kms, const unsigned *attr, struct kms_bo **
                        type = value;
                        break;
                default:
-                       return EINVAL;
+                       return -EINVAL;
                }
        }
 
        if (width == 0 || height == 0)
                return -EINVAL;
 
+       /* XXX sanity check type */
+
+       if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 &&
+           (width != 64 || height != 64))
+               return -EINVAL;
+
        return kms->bo_create(kms, width, height, type, attr, out);
 }