summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nouveau/nouveau_screen.c
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2012-04-06 15:41:55 +0200
committerBen Skeggs <[email protected]>2012-04-14 02:56:33 +1000
commit6d1cdec3ba151168bfc3aef222fba6265dfb41fb (patch)
treec8c013eaa14e1b7463b6b3f39221524d901370f6 /src/gallium/drivers/nouveau/nouveau_screen.c
parent3c7872f35f4ae439082d413ab31333cf99be7e91 (diff)
nouveau: switch to libdrm_nouveau-2.0
Diffstat (limited to 'src/gallium/drivers/nouveau/nouveau_screen.c')
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.c149
1 files changed, 38 insertions, 111 deletions
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index 8ebae8e27dc..74377799977 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -12,17 +12,15 @@
#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"
+#include "nouveau_mm.h"
+#include "nouveau_buffer.h"
/* XXX this should go away */
#include "state_tracker/drm_driver.h"
-#include "nouveau_drmif.h"
-
int nouveau_mesa_debug = 0;
static const char *
@@ -41,102 +39,6 @@ nouveau_screen_get_vendor(struct pipe_screen *pscreen)
return "nouveau";
}
-
-
-struct nouveau_bo *
-nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
- unsigned usage, unsigned bind, unsigned size)
-{
- struct nouveau_device *dev = nouveau_screen(pscreen)->device;
- struct nouveau_bo *bo = NULL;
- uint32_t flags = NOUVEAU_BO_MAP, tile_mode = 0, tile_flags = 0;
- int ret;
-
- if (bind & PIPE_BIND_VERTEX_BUFFER)
- flags |= nouveau_screen(pscreen)->vertex_buffer_flags;
- else if (bind & PIPE_BIND_INDEX_BUFFER)
- flags |= nouveau_screen(pscreen)->index_buffer_flags;
-
- if (bind & (PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_DEPTH_STENCIL |
- PIPE_BIND_SCANOUT |
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SAMPLER_VIEW))
- {
- /* TODO: this may be incorrect or suboptimal */
- if (!(bind & PIPE_BIND_SCANOUT))
- flags |= NOUVEAU_BO_GART;
- if (usage != PIPE_USAGE_DYNAMIC)
- flags |= NOUVEAU_BO_VRAM;
-
- if (dev->chipset == 0x50 || dev->chipset >= 0x80) {
- if (bind & PIPE_BIND_DEPTH_STENCIL)
- tile_flags = 0x2800;
- else
- tile_flags = 0x7000;
- }
- }
-
- ret = nouveau_bo_new_tile(dev, flags, alignment, size,
- tile_mode, tile_flags, &bo);
- if (ret)
- return NULL;
-
- return bo;
-}
-
-void *
-nouveau_screen_bo_map(struct pipe_screen *pscreen,
- struct nouveau_bo *bo,
- unsigned map_flags)
-{
- int ret;
-
- ret = nouveau_bo_map(bo, map_flags);
- if (ret) {
- debug_printf("map failed: %d\n", ret);
- return NULL;
- }
-
- return bo->map;
-}
-
-void *
-nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct nouveau_bo *bo,
- unsigned offset, unsigned length, unsigned flags)
-{
- int ret;
-
- ret = nouveau_bo_map_range(bo, offset, length, flags);
- if (ret) {
- nouveau_bo_unmap(bo);
- if (!(flags & NOUVEAU_BO_NOWAIT) || ret != -EBUSY)
- debug_printf("map_range failed: %d\n", ret);
- return NULL;
- }
-
- return (char *)bo->map - offset; /* why gallium? why? */
-}
-
-void
-nouveau_screen_bo_map_flush_range(struct pipe_screen *pscreen, struct nouveau_bo *bo,
- unsigned offset, unsigned length)
-{
- nouveau_bo_map_flush(bo, offset, length);
-}
-
-void
-nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct nouveau_bo *bo)
-{
- nouveau_bo_unmap(bo);
-}
-
-void
-nouveau_screen_bo_release(struct pipe_screen *pscreen, struct nouveau_bo *bo)
-{
- nouveau_bo_ref(NULL, &bo);
-}
-
static void
nouveau_screen_fence_ref(struct pipe_screen *pscreen,
struct pipe_fence_handle **ptr,
@@ -157,7 +59,7 @@ nouveau_screen_fence_finish(struct pipe_screen *screen,
struct pipe_fence_handle *pfence,
uint64_t timeout)
{
- return nouveau_fence_wait(nouveau_fence(pfence));
+ return nouveau_fence_wait(nouveau_fence(pfence));
}
@@ -170,7 +72,7 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
struct nouveau_bo *bo = 0;
int ret;
- ret = nouveau_bo_handle_ref(dev, whandle->handle, &bo);
+ ret = nouveau_bo_name_ref(dev, whandle->handle, &bo);
if (ret) {
debug_printf("%s: ref name 0x%08x failed with %d\n",
__FUNCTION__, whandle->handle, ret);
@@ -191,7 +93,7 @@ nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
whandle->stride = stride;
if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
- return nouveau_bo_handle_get(bo, &whandle->handle) == 0;
+ return nouveau_bo_name_get(bo, &whandle->handle) == 0;
} else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
whandle->handle = bo->handle;
return TRUE;
@@ -204,18 +106,39 @@ int
nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
{
struct pipe_screen *pscreen = &screen->base;
- int ret;
+ struct nv04_fifo nv04_data = { .vram = 0xbeef0201, .gart = 0xbeef0202 };
+ struct nvc0_fifo nvc0_data = { };
+ int size, ret;
+ void *data;
+ union nouveau_bo_config mm_config;
char *nv_dbg = getenv("NOUVEAU_MESA_DEBUG");
if (nv_dbg)
nouveau_mesa_debug = atoi(nv_dbg);
- ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
- 512*1024, &screen->channel);
+ if (dev->chipset < 0xc0) {
+ data = &nv04_data;
+ size = sizeof(nv04_data);
+ } else {
+ data = &nvc0_data;
+ size = sizeof(nvc0_data);
+ }
+
+ ret = nouveau_object_new(&dev->object, 0, NOUVEAU_FIFO_CHANNEL_CLASS,
+ data, size, &screen->channel);
if (ret)
return ret;
screen->device = dev;
+ ret = nouveau_client_new(screen->device, &screen->client);
+ if (ret)
+ return ret;
+ ret = nouveau_pushbuf_new(screen->client, screen->channel,
+ 4, 512 * 1024, 1,
+ &screen->pushbuf);
+ if (ret)
+ return ret;
+
pscreen->get_name = nouveau_screen_get_name;
pscreen->get_vendor = nouveau_screen_get_vendor;
@@ -225,10 +148,12 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
util_format_s3tc_init();
+ memset(&mm_config, 0, sizeof(mm_config));
+
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);
+ &mm_config);
+ screen->mm_VRAM = nouveau_mm_create(dev, NOUVEAU_BO_VRAM, &mm_config);
return 0;
}
@@ -238,8 +163,10 @@ nouveau_screen_fini(struct nouveau_screen *screen)
nouveau_mm_destroy(screen->mm_GART);
nouveau_mm_destroy(screen->mm_VRAM);
- nouveau_channel_free(&screen->channel);
+ nouveau_pushbuf_del(&screen->pushbuf);
- nouveau_device_close(&screen->device);
-}
+ nouveau_client_del(&screen->client);
+ nouveau_object_del(&screen->channel);
+ nouveau_device_del(&screen->device);
+}