summaryrefslogtreecommitdiff
path: root/src/radeon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/radeon.c')
-rw-r--r--src/radeon.c107
1 files changed, 16 insertions, 91 deletions
diff --git a/src/radeon.c b/src/radeon.c
index 2873fa2..090910f 100644
--- a/src/radeon.c
+++ b/src/radeon.c
@@ -22,9 +22,8 @@
#include <string.h>
#include <errno.h>
#include "xf86drm.h"
-#include "radeon_bo_gem.h"
-#include "radeon_cs_gem.h"
#include "radeon_priv.h"
+#include "radeon_drm.h"
#include "r600d.h"
int radeon_get_device(struct radeon *radeon)
@@ -68,16 +67,6 @@ struct radeon *radeon_new(int fd, unsigned device)
fprintf(stderr, "Unknown chipset 0x%04X\n", radeon->device);
return radeon_decref(radeon);
}
- radeon->csm = radeon_cs_manager_gem_ctor(radeon->fd);
- if (radeon->csm == NULL) {
- fprintf(stderr, "Failed to create CS manager\n");
- return radeon_decref(radeon);
- }
- radeon->bom = radeon_bo_manager_gem_ctor(radeon->fd);
- if (radeon->bom == NULL) {
- fprintf(stderr, "Failed to create BO manager\n");
- return radeon_decref(radeon);
- }
switch (radeon->family) {
case CHIP_R600:
case CHIP_RV610:
@@ -160,53 +149,16 @@ struct radeon *radeon_decref(struct radeon *radeon)
if (radeon->mmio)
pci_device_unmap_range(radeon->dev, radeon->mmio, radeon->mmio_size);
radeon_mode_cleanup(radeon);
- radeon_bo_manager_gem_dtor(radeon->bom);
- radeon_cs_manager_gem_dtor(radeon->csm);
drmClose(radeon->fd);
free(radeon);
return NULL;
}
-void memset_bo(struct radeon_bo *bo, u32 value)
-{
- u32 *ptr;
- int r;
-
- r = radeon_bo_map(bo, 1);
- if (r) {
- fprintf(stderr, "Failed to map buffer\n");
- perror(NULL);
- return;
- }
- ptr = (u32*)bo->ptr;
- for (r = 0; r < (bo->size / 4); r++)
- ptr[r] = value;
- radeon_bo_unmap(bo);
-}
-
-void memcpy_bo(struct radeon_bo *bo, u32 *src, u32 size)
-{
- u32 *ptr, tmp;
- int r;
-
- r = radeon_bo_map(bo, 1);
- if (r) {
- fprintf(stderr, "Failed to map buffer\n");
- perror(NULL);
- return;
- }
- ptr = (u32*)bo->ptr;
- for (r = 0; r < size; r++)
- ptr[r] = src[r];
- for (r = 0; r < size; r++)
- ptr[r] = src[r];
- for (r = 0, tmp = 0; r < size; r++)
- tmp += ptr[r];
- radeon_bo_unmap(bo);
-}
-
-void radeon_blit(struct radeon_surface *dst, struct radeon_surface *src,
- unsigned sx, unsigned sy, unsigned dx, unsigned dy,
+void radeon_blit(struct radeon *radeon,
+ struct radeon_surface *dst,
+ struct radeon_surface *src,
+ unsigned sx, unsigned sy,
+ unsigned dx, unsigned dy,
unsigned w, unsigned h)
{
unsigned y;
@@ -226,12 +178,12 @@ void radeon_blit(struct radeon_surface *dst, struct radeon_surface *src,
h = dst->height - dy;
if (!w || !h)
return;
- if (radeon_bo_map(dst->bo, 1))
+ if (radeon_bo_map(radeon, dst->bo))
return;
- if (radeon_bo_map(src->bo, 0))
+ if (radeon_bo_map(radeon, src->bo))
return;
- sptr = src->bo->ptr;
- dptr = dst->bo->ptr;
+ sptr = src->bo->data;
+ dptr = dst->bo->data;
sptr = &sptr[(sy * src->pitch + sx) * src->bpe];
dptr = &dptr[(dy * dst->pitch + dx) * dst->bpe];
for (y = 0; y < h; y++) {
@@ -239,34 +191,8 @@ void radeon_blit(struct radeon_surface *dst, struct radeon_surface *src,
dptr += dst->pitch * dst->bpe;
sptr += src->pitch * src->bpe;
}
- radeon_bo_unmap(dst->bo);
- radeon_bo_unmap(src->bo);
-}
-
-int radeon_flush(struct radeon *radeon)
-{
- struct radeon_ctx *ctx = radeon->ctx;
- unsigned i;
- int r;
-
- free(ctx->pm4);
- ctx->pm4 = malloc(ctx->cpm4 * 4);
- if (ctx->pm4 == NULL)
- return -EINVAL;
- for (i = 0, ctx->id = 0; i < ctx->nstate; i++) {
- r = radeon_ctx_state_schedule(ctx, ctx->state[i]);
- if (r)
- return r;
- }
- if (ctx->id != ctx->cpm4) {
- fprintf(stderr, "%s miss predicted pm4 size %d for %d\n",
- __func__, ctx->cpm4, ctx->id);
- return -EINVAL;
- }
- r = radeon_ctx_submit(ctx);
- radeon_ctx_destroy(ctx);
- radeon->ctx = radeon_ctx(radeon, 0);
- return r;
+ radeon_bo_unmap(radeon, dst->bo);
+ radeon_bo_unmap(radeon, src->bo);
}
int radeon_reg_id(struct radeon *radeon, unsigned offset, unsigned *typeid, unsigned *stateid, unsigned *id)
@@ -313,6 +239,7 @@ unsigned radeon_type_from_id(struct radeon *radeon, unsigned id)
return -1;
}
+#if 0
int radeon_schedule_draw(struct radeon *radeon, struct radeon_draw *draw)
{
struct radeon_ctx *ctx = radeon->ctx;
@@ -323,7 +250,7 @@ int radeon_schedule_draw(struct radeon *radeon, struct radeon_draw *draw)
int r = 0;
if (ctx == NULL) {
- ctx = radeon_ctx(radeon, 0);
+ ctx = radeon_ctx(radeon);
if (ctx == NULL)
return -ENOMEM;
radeon->ctx = ctx;
@@ -347,10 +274,7 @@ reprocess:
if (nstate) {
if (pdraw && pdraw->state[i]) {
ostate = pdraw->state[i];
- if (ostate->pm4_crc == nstate->pm4_crc) {
-// ctx->state[cstate++] = nstate;
-// cpm4 += nstate->cpm4;
- } else {
+ if (ostate->pm4_crc != nstate->pm4_crc) {
ctx->state[cstate++] = nstate;
cpm4 += nstate->cpm4;
}
@@ -382,3 +306,4 @@ reprocess:
out_err:
return r;
}
+#endif