st/egl: Fix r300/r600 support in KMS backend.
authorChia-I Wu <olv@lunarg.com>
Mon, 23 Aug 2010 17:05:12 +0000 (01:05 +0800)
committerChia-I Wu <olv@lunarg.com>
Tue, 24 Aug 2010 03:50:37 +0000 (11:50 +0800)
When the kernel driver name is radeon, ask the loader for r300 or r600
depending on the PCI ID.

src/gallium/state_trackers/egl/Makefile
src/gallium/state_trackers/egl/kms/native_kms.c

index 9e9e479e7e0a1484a60986c2cdff8f4b702b10c1..4199d7c6baab82737233152486fbe9568e112eb9 100644 (file)
@@ -24,7 +24,7 @@ x11_SOURCES = $(wildcard x11/*.c) \
 x11_OBJECTS = $(x11_SOURCES:.c=.o)
 
 
-kms_INCLUDES = $(shell pkg-config --cflags-only-I libdrm)
+kms_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm)
 kms_SOURCES = $(wildcard kms/*.c)
 kms_OBJECTS = $(kms_SOURCES:.c=.o)
 
index d4e8fbc9131fffa86553ff9dfb2c9a4291de5b06..0a69919328f0d4d54a5cde059fe4e325c0cd1894 100644 (file)
 
 #include "native_kms.h"
 
+/* see get_drm_screen_name */
+#include <radeon_drm.h>
+#include "radeon/drm/radeon_drm.h"
+
 static boolean
 kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
                      unsigned int *seq_num, struct pipe_resource **textures,
@@ -664,6 +668,27 @@ kms_display_destroy(struct native_display *ndpy)
    FREE(kdpy);
 }
 
+static const char *
+get_drm_screen_name(int fd, drmVersionPtr version)
+{
+   const char *name = version->name;
+
+   if (name && !strcmp(name, "radeon")) {
+      int chip_id;
+      struct drm_radeon_info info;
+
+      memset(&info, 0, sizeof(info));
+      info.request = RADEON_INFO_DEVICE_ID;
+      info.value = pointer_to_intptr(&chip_id);
+      if (drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)) != 0)
+         return NULL;
+
+      name = is_r3xx(chip_id) ? "r300" : "r600";
+   }
+
+   return name;
+}
+
 /**
  * Initialize KMS and pipe screen.
  */
@@ -672,6 +697,7 @@ kms_display_init_screen(struct native_display *ndpy)
 {
    struct kms_display *kdpy = kms_display(ndpy);
    drmVersionPtr version;
+   const char *name;
 
    version = drmGetVersion(kdpy->fd);
    if (!version) {
@@ -679,8 +705,11 @@ kms_display_init_screen(struct native_display *ndpy)
       return FALSE;
    }
 
-   kdpy->base.screen = kdpy->event_handler->new_drm_screen(&kdpy->base,
-         version->name, kdpy->fd);;
+   name = get_drm_screen_name(kdpy->fd, version);
+   if (name) {
+      kdpy->base.screen =
+         kdpy->event_handler->new_drm_screen(&kdpy->base, name, kdpy->fd);
+   }
    drmFreeVersion(version);
 
    if (!kdpy->base.screen) {