#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
+#include "util/u_format_s3tc.h"
+#include "util/u_string.h"
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
#include "nouveau/nouveau_bo.h"
+#include "nouveau/nouveau_mm.h"
#include "nouveau_winsys.h"
#include "nouveau_screen.h"
+#include "nouveau_fence.h"
/* XXX this should go away */
-#include "state_tracker/drm_api.h"
+#include "state_tracker/drm_driver.h"
#include "util/u_simple_screen.h"
+#include "nouveau_drmif.h"
+
+int nouveau_mesa_debug = 0;
+
static const char *
nouveau_screen_get_name(struct pipe_screen *pscreen)
{
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
static char buffer[128];
- snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
+ util_snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
return buffer;
}
if (bind & (PIPE_BIND_RENDER_TARGET |
PIPE_BIND_DEPTH_STENCIL |
- PIPE_BIND_BLIT_SOURCE |
- PIPE_BIND_BLIT_DESTINATION |
PIPE_BIND_SCANOUT |
PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SAMPLER_VIEW))
return bo;
}
-struct nouveau_bo *
-nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes)
-{
- struct nouveau_device *dev = nouveau_screen(pscreen)->device;
- struct nouveau_bo *bo = NULL;
- int ret;
-
- ret = nouveau_bo_user(dev, ptr, bytes, &bo);
- if (ret)
- return NULL;
-
- return bo;
-}
-
void *
nouveau_screen_bo_map(struct pipe_screen *pscreen,
struct nouveau_bo *bo,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *pfence)
{
- *ptr = pfence;
+ nouveau_fence_ref(nouveau_fence(pfence), (struct nouveau_fence **)ptr);
}
-static int
+static boolean
nouveau_screen_fence_signalled(struct pipe_screen *screen,
- struct pipe_fence_handle *pfence,
- unsigned flags)
+ struct pipe_fence_handle *pfence)
{
- return 0;
+ return nouveau_fence_signalled(nouveau_fence(pfence));
}
-static int
+static boolean
nouveau_screen_fence_finish(struct pipe_screen *screen,
struct pipe_fence_handle *pfence,
- unsigned flags)
+ uint64_t timeout)
{
- return 0;
+ return nouveau_fence_wait(nouveau_fence(pfence));
}
ret = nouveau_bo_handle_ref(dev, whandle->handle, &bo);
if (ret) {
debug_printf("%s: ref name 0x%08x failed with %d\n",
- __func__, whandle->handle, ret);
+ __FUNCTION__, whandle->handle, ret);
return NULL;
}
}
}
-
-unsigned int
-nouveau_reference_flags(struct nouveau_bo *bo)
-{
- uint32_t bo_flags;
- int flags = 0;
-
- bo_flags = nouveau_bo_pending(bo);
- if (bo_flags & NOUVEAU_BO_RD)
- flags |= PIPE_REFERENCED_FOR_READ;
- if (bo_flags & NOUVEAU_BO_WR)
- flags |= PIPE_REFERENCED_FOR_WRITE;
-
- return flags;
-}
-
-
-
-
-
int
nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
{
struct pipe_screen *pscreen = &screen->base;
int ret;
+ char *nv_dbg = getenv("NOUVEAU_MESA_DEBUG");
+ if (nv_dbg)
+ nouveau_mesa_debug = atoi(nv_dbg);
+
ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
- &screen->channel);
+ 512*1024, &screen->channel);
if (ret)
return ret;
screen->device = dev;
pscreen->fence_signalled = nouveau_screen_fence_signalled;
pscreen->fence_finish = nouveau_screen_fence_finish;
+ util_format_s3tc_init();
+
+ screen->mm_GART = nouveau_mm_create(dev,
+ NOUVEAU_BO_GART | NOUVEAU_BO_MAP,
+ 0x000);
+ screen->mm_VRAM = nouveau_mm_create(dev, NOUVEAU_BO_VRAM, 0x000);
return 0;
}
void
nouveau_screen_fini(struct nouveau_screen *screen)
{
- struct pipe_winsys *ws = screen->base.winsys;
+ nouveau_mm_destroy(screen->mm_GART);
+ nouveau_mm_destroy(screen->mm_VRAM);
+
nouveau_channel_free(&screen->channel);
- ws->destroy(ws);
+
+ nouveau_device_close(&screen->device);
}