summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-07-22 19:25:07 +0200
committerMarek Olšák <[email protected]>2011-08-16 09:15:10 +0200
commitce12f826927cf2d3ac3fd70d893abfb07adc23db (patch)
tree021390666894835790a38127546ed1a4becd137a /src/gallium/winsys
parent8c409403217cf8c13e1d2dd306ad5e86b566c5c9 (diff)
r600g: first step into winsys/radeon
Reviewed-by: Alex Deucher <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/r600/drm/r600_drm.c50
-rw-r--r--src/gallium/winsys/r600/drm/r600_drm_public.h4
-rw-r--r--src/gallium/winsys/r600/drm/r600_priv.h2
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_winsys.c35
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_winsys.h6
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_winsys.h3
6 files changed, 50 insertions, 50 deletions
diff --git a/src/gallium/winsys/r600/drm/r600_drm.c b/src/gallium/winsys/r600/drm/r600_drm.c
index 8aa8c3df52a..325547ab4ec 100644
--- a/src/gallium/winsys/r600/drm/r600_drm.c
+++ b/src/gallium/winsys/r600/drm/r600_drm.c
@@ -37,6 +37,7 @@
#include "r600_drm_public.h"
#include "xf86drm.h"
#include "radeon_drm.h"
+#include "../../radeon/drm/radeon_winsys.h"
#ifndef RADEON_INFO_TILING_CONFIG
#define RADEON_INFO_TILING_CONFIG 0x6
@@ -98,20 +99,6 @@ unsigned r600_get_minor_version(struct radeon *radeon)
return radeon->minor_version;
}
-
-static int radeon_get_device(struct radeon *radeon)
-{
- struct drm_radeon_info info = {};
- int r;
-
- radeon->device = 0;
- info.request = RADEON_INFO_DEVICE_ID;
- info.value = (uintptr_t)&radeon->device;
- r = drmCommandWriteRead(radeon->fd, DRM_RADEON_INFO, &info,
- sizeof(struct drm_radeon_info));
- return r;
-}
-
static int r600_interpret_tiling(struct radeon *radeon, uint32_t tiling_config)
{
switch ((tiling_config & 0xe) >> 1) {
@@ -320,39 +307,22 @@ static int handle_compare(void *key1, void *key2)
return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
}
-static struct radeon *radeon_new(int fd, unsigned device)
+static struct radeon *radeon_new(struct radeon_winsys *rw)
{
struct radeon *radeon;
int r;
- drmVersionPtr version;
radeon = calloc(1, sizeof(*radeon));
if (radeon == NULL) {
return NULL;
}
- radeon->fd = fd;
- radeon->device = device;
- radeon->refcount = 1;
-
- version = drmGetVersion(radeon->fd);
- if (version->version_major != 2) {
- fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
- "only compatible with 2.x.x\n", __FUNCTION__,
- version->version_major, version->version_minor,
- version->version_patchlevel);
- drmFreeVersion(version);
- exit(1);
- }
-
- radeon->minor_version = version->version_minor;
-
- drmFreeVersion(version);
- r = radeon_get_device(radeon);
- if (r) {
- fprintf(stderr, "Failed to get device id\n");
- return radeon_decref(radeon);
- }
+ rw->query_info(rw, &radeon->info);
+ radeon->fd = radeon->info.fd;
+ radeon->device = radeon->info.pci_id;
+ radeon->num_backends = radeon->info.r600_num_backends;
+ radeon->refcount = 1;
+ radeon->minor_version = radeon->info.drm_minor;
radeon->family = radeon_family_from_device(radeon->device);
if (radeon->family == CHIP_UNKNOWN) {
@@ -436,9 +406,9 @@ static struct radeon *radeon_new(int fd, unsigned device)
return radeon;
}
-struct radeon *r600_drm_winsys_create(int drmfd)
+struct radeon *r600_drm_winsys_create(struct radeon_winsys *rw)
{
- return radeon_new(drmfd, 0);
+ return radeon_new(rw);
}
struct radeon *radeon_decref(struct radeon *radeon)
diff --git a/src/gallium/winsys/r600/drm/r600_drm_public.h b/src/gallium/winsys/r600/drm/r600_drm_public.h
index cfce8df9c2c..1d990f91013 100644
--- a/src/gallium/winsys/r600/drm/r600_drm_public.h
+++ b/src/gallium/winsys/r600/drm/r600_drm_public.h
@@ -26,8 +26,8 @@
#ifndef R600_DRM_PUBLIC_H
#define R600_DRM_PUBLIC_H
-struct radeon;
+struct radeon_winsys;
-struct radeon *r600_drm_winsys_create(int drmFD);
+struct radeon *r600_drm_winsys_create(struct radeon_winsys *rw);
#endif
diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h
index 75115fdaed7..7630b30b5f0 100644
--- a/src/gallium/winsys/r600/drm/r600_priv.h
+++ b/src/gallium/winsys/r600/drm/r600_priv.h
@@ -35,6 +35,7 @@
#include "util/u_hash_table.h"
#include <os/os_thread.h>
#include "r600.h"
+#include "../../radeon/drm/radeon_winsys.h"
#define PKT_COUNT_C 0xC000FFFF
#define PKT_COUNT_S(x) (((x) & 0x3FFF) << 16)
@@ -43,6 +44,7 @@ struct r600_bomgr;
struct r600_bo;
struct radeon {
+ struct radeon_info info;
int fd;
int refcount;
unsigned device;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 5983e86c570..faeb66c8908 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -47,6 +47,9 @@
#ifndef RADEON_INFO_WANT_CMASK
#define RADEON_INFO_WANT_CMASK 8
#endif
+#ifndef RADEON_INFO_NUM_BACKENDS
+#define RADEON_INFO_NUM_BACKENDS 10
+#endif
/* Enable/disable feature access for one command stream.
* If enable == TRUE, return TRUE on success.
@@ -175,6 +178,13 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
#define CHIPSET(pci_id, name, family) case pci_id:
#include "pci_ids/r300_pci_ids.h"
#undef CHIPSET
+ ws->gen = R300;
+ break;
+
+#define CHIPSET(pci_id, name, family) case pci_id:
+#include "pci_ids/r600_pci_ids.h"
+#undef CHIPSET
+ ws->gen = R600;
break;
default:
@@ -196,15 +206,23 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
ws->num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
/* Generation-specific queries. */
- if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_GB_PIPES,
- "GB pipe count",
- &ws->info.r300_num_gb_pipes))
- return FALSE;
+ if (ws->gen == R300) {
+ if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_GB_PIPES,
+ "GB pipe count",
+ &ws->info.r300_num_gb_pipes))
+ return FALSE;
- if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_Z_PIPES,
- "Z pipe count",
- &ws->info.r300_num_z_pipes))
- return FALSE;
+ if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_Z_PIPES,
+ "Z pipe count",
+ &ws->info.r300_num_z_pipes))
+ return FALSE;
+ }
+ else if (ws->gen == R600) {
+ if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_BACKENDS,
+ "num backends",
+ &ws->info.r600_num_backends))
+ return FALSE;
+ }
return TRUE;
}
@@ -263,6 +281,7 @@ struct radeon_winsys *radeon_drm_winsys_create(int fd)
}
ws->fd = fd;
+ ws->info.fd = fd;
if (!do_winsys_init(ws))
goto fail;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 347e1f1d11a..69216448496 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -33,12 +33,18 @@
#include "radeon_winsys.h"
#include "os/os_thread.h"
+enum radeon_generation {
+ R300,
+ R600
+};
+
struct radeon_drm_winsys {
struct radeon_winsys base;
int fd; /* DRM file descriptor */
int num_cs; /* The number of command streams created. */
+ enum radeon_generation gen;
struct radeon_info info;
struct pb_manager *kman;
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index 6d52dc25022..2a49e615981 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -73,6 +73,7 @@ struct radeon_info {
uint32_t pci_id;
uint32_t gart_size;
uint32_t vram_size;
+ uint32_t fd; /* XXX transitional */
uint32_t drm_major; /* version */
uint32_t drm_minor;
@@ -80,6 +81,8 @@ struct radeon_info {
uint32_t r300_num_gb_pipes;
uint32_t r300_num_z_pipes;
+
+ uint32_t r600_num_backends;
};
enum radeon_feature_id {