diff options
author | Ben Skeggs <[email protected]> | 2007-12-14 01:14:23 +1100 |
---|---|---|
committer | Ben Skeggs <[email protected]> | 2007-12-14 01:14:23 +1100 |
commit | 00f0f0d0a4b474757becb99109cb2dd6574178f8 (patch) | |
tree | daa8cd0551b28c31ea803c2c2789c8ddbc2270ef /src/mesa/drivers | |
parent | 72d47f1949f99231f18cc5144b1c45c58b35f890 (diff) |
nouveau: mass renaming for consistency, no functional changes
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_bo.c | 194 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_channel.c | 105 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_device.c | 68 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.c | 85 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.h | 72 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_grobj.c | 84 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_notifier.c | 79 |
7 files changed, 342 insertions, 345 deletions
diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_bo.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_bo.c index d684ab4d7c4..d31026b52d5 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_bo.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_bo.c @@ -29,62 +29,62 @@ #include "nouveau_local.h" int -nouveau_bo_init(struct nouveau_device *userdev) +nouveau_bo_init(struct nouveau_device *dev) { return 0; } void -nouveau_bo_takedown(struct nouveau_device *userdev) +nouveau_bo_takedown(struct nouveau_device *dev) { } static int -nouveau_bo_realloc_gpu(struct nouveau_bo_priv *bo, uint32_t flags, int size) +nouveau_bo_realloc_gpu(struct nouveau_bo_priv *nvbo, uint32_t flags, int size) { - struct nouveau_device_priv *nv = nouveau_device(bo->base.device); + struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device); int ret; - if (bo->drm.size && bo->drm.size != size) { + if (nvbo->drm.size && nvbo->drm.size != size) { struct drm_nouveau_mem_free f; - if (bo->map) { - drmUnmap(bo->map, bo->drm.size); - bo->map = NULL; + if (nvbo->map) { + drmUnmap(nvbo->map, nvbo->drm.size); + nvbo->map = NULL; } - f.flags = bo->drm.flags; - f.offset = bo->drm.offset; - drmCommandWrite(nv->fd, DRM_NOUVEAU_MEM_FREE, &f, sizeof(f)); + f.flags = nvbo->drm.flags; + f.offset = nvbo->drm.offset; + drmCommandWrite(nvdev->fd, DRM_NOUVEAU_MEM_FREE, &f, sizeof(f)); - bo->drm.size = 0; + nvbo->drm.size = 0; } - if (size && !bo->drm.size) { + if (size && !nvbo->drm.size) { if (flags) { - bo->drm.flags = 0; + nvbo->drm.flags = 0; if (flags & NOUVEAU_BO_VRAM) - bo->drm.flags |= NOUVEAU_MEM_FB; + nvbo->drm.flags |= NOUVEAU_MEM_FB; if (flags & NOUVEAU_BO_GART) - bo->drm.flags |= (NOUVEAU_MEM_AGP | - NOUVEAU_MEM_PCI); - bo->drm.flags |= NOUVEAU_MEM_MAPPED; + nvbo->drm.flags |= (NOUVEAU_MEM_AGP | + NOUVEAU_MEM_PCI); + nvbo->drm.flags |= NOUVEAU_MEM_MAPPED; } - bo->drm.size = size; + nvbo->drm.size = size; - ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_MEM_ALLOC, - &bo->drm, sizeof(bo->drm)); + ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_MEM_ALLOC, + &nvbo->drm, sizeof(nvbo->drm)); if (ret) { - free(bo); + free(nvbo); return ret; } - ret = drmMap(nv->fd, bo->drm.map_handle, bo->drm.size, - &bo->map); + ret = drmMap(nvdev->fd, nvbo->drm.map_handle, nvbo->drm.size, + &nvbo->map); if (ret) { - bo->map = NULL; - nouveau_bo_del((void *)&bo); + nvbo->map = NULL; + nouveau_bo_del((void *)&nvbo); return ret; } } @@ -93,154 +93,154 @@ nouveau_bo_realloc_gpu(struct nouveau_bo_priv *bo, uint32_t flags, int size) } int -nouveau_bo_new(struct nouveau_device *userdev, uint32_t flags, int align, - int size, struct nouveau_bo **userbo) +nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, int align, + int size, struct nouveau_bo **bo) { - struct nouveau_bo_priv *bo; + struct nouveau_bo_priv *nvbo; int ret; - if (!userdev || !userbo || *userbo) + if (!dev || !bo || *bo) return -EINVAL; - bo = calloc(1, sizeof(*bo)); - if (!bo) + nvbo = calloc(1, sizeof(struct nouveau_bo_priv)); + if (!nvbo) return -ENOMEM; - bo->base.device = userdev; - bo->drm.alignment = align; + nvbo->base.device = dev; + nvbo->drm.alignment = align; if (flags & NOUVEAU_BO_PIN) { - ret = nouveau_bo_realloc_gpu(bo, flags, size); + ret = nouveau_bo_realloc_gpu(nvbo, flags, size); if (ret) { - free(bo); + free(nvbo); return ret; } } else { - bo->sysmem = malloc(size); - if (!bo->sysmem) { - free(bo); + nvbo->sysmem = malloc(size); + if (!nvbo->sysmem) { + free(nvbo); return -ENOMEM; } } - bo->base.size = size; - bo->base.offset = bo->drm.offset; - bo->base.handle = (unsigned long)bo; - bo->refcount = 1; - *userbo = &bo->base; + nvbo->base.size = size; + nvbo->base.offset = nvbo->drm.offset; + nvbo->base.handle = bo_to_ptr(nvbo); + nvbo->refcount = 1; + *bo = &nvbo->base; return 0; } int -nouveau_bo_user(struct nouveau_device *userdev, void *ptr, int size, - struct nouveau_bo **userbo) +nouveau_bo_user(struct nouveau_device *dev, void *ptr, int size, + struct nouveau_bo **bo) { - struct nouveau_bo_priv *bo; + struct nouveau_bo_priv *nvbo; - if (!userdev || !userbo || *userbo) + if (!dev || !bo || *bo) return -EINVAL; - bo = calloc(1, sizeof(*bo)); - if (!bo) + nvbo = calloc(1, sizeof(*nvbo)); + if (!nvbo) return -ENOMEM; - bo->base.device = userdev; + nvbo->base.device = dev; - bo->sysmem = ptr; - bo->user = 1; - - bo->base.size = size; - bo->base.offset = bo->drm.offset; - bo->base.handle = (unsigned long)bo; - bo->refcount = 1; - *userbo = &bo->base; + nvbo->sysmem = ptr; + nvbo->user = 1; + + nvbo->base.size = size; + nvbo->base.offset = nvbo->drm.offset; + nvbo->base.handle = bo_to_ptr(nvbo); + nvbo->refcount = 1; + *bo = &nvbo->base; return 0; } int -nouveau_bo_ref(struct nouveau_device *userdev, uint64_t handle, - struct nouveau_bo **userbo) +nouveau_bo_ref(struct nouveau_device *dev, uint64_t handle, + struct nouveau_bo **bo) { - struct nouveau_bo_priv *bo = (void *)(unsigned long)handle; + struct nouveau_bo_priv *nvbo = ptr_to_bo(handle); - if (!userdev || !userbo || *userbo) + if (!dev || !bo || *bo) return -EINVAL; - bo->refcount++; - *userbo = &bo->base; + nvbo->refcount++; + *bo = &nvbo->base; return 0; } int -nouveau_bo_resize(struct nouveau_bo *userbo, int size) +nouveau_bo_resize(struct nouveau_bo *bo, int size) { - struct nouveau_bo_priv *bo = nouveau_bo(userbo); + struct nouveau_bo_priv *nvbo = nouveau_bo(bo); int ret; - if (!bo || bo->user) + if (!nvbo || nvbo->user) return -EINVAL; - if (bo->sysmem) { - bo->sysmem = realloc(bo->sysmem, size); - if (!bo->sysmem) + if (nvbo->sysmem) { + nvbo->sysmem = realloc(nvbo->sysmem, size); + if (!nvbo->sysmem) return -ENOMEM; } else { - ret = nouveau_bo_realloc_gpu(bo, 0, size); + ret = nouveau_bo_realloc_gpu(nvbo, 0, size); if (ret) return ret; } - bo->base.size = size; + nvbo->base.size = size; return 0; } void -nouveau_bo_del(struct nouveau_bo **userbo) +nouveau_bo_del(struct nouveau_bo **bo) { - struct nouveau_bo_priv *bo; + struct nouveau_bo_priv *nvbo; - if (!userbo || !*userbo) + if (!bo || !*bo) return; - bo = nouveau_bo(*userbo); - *userbo = NULL; + nvbo = nouveau_bo(*bo); + *bo = NULL; - if (--bo->refcount) + if (--nvbo->refcount) return; - if (bo->fence) - nouveau_fence_wait(&bo->fence); + if (nvbo->fence) + nouveau_fence_wait(&nvbo->fence); - nouveau_bo_realloc_gpu(bo, 0, 0); - if (bo->sysmem && !bo->user) - free(bo->sysmem); - free(bo); + nouveau_bo_realloc_gpu(nvbo, 0, 0); + if (nvbo->sysmem && !nvbo->user) + free(nvbo->sysmem); + free(nvbo); } int -nouveau_bo_map(struct nouveau_bo *userbo, uint32_t flags) +nouveau_bo_map(struct nouveau_bo *bo, uint32_t flags) { - struct nouveau_bo_priv *bo = nouveau_bo(userbo); + struct nouveau_bo_priv *nvbo = nouveau_bo(bo); - if (!bo) + if (!nvbo) return -EINVAL; - if (bo->sysmem) - userbo->map = bo->sysmem; + if (nvbo->sysmem) + bo->map = nvbo->sysmem; else - userbo->map = bo->map; + bo->map = nvbo->map; return 0; } void -nouveau_bo_unmap(struct nouveau_bo *userbo) +nouveau_bo_unmap(struct nouveau_bo *bo) { - userbo->map = NULL; + bo->map = NULL; } static int -nouveau_bo_upload(struct nouveau_bo_priv *bo) +nouveau_bo_upload(struct nouveau_bo_priv *nvbo) { - if (bo->fence) - nouveau_fence_wait(&bo->fence); - memcpy(bo->map, bo->sysmem, bo->drm.size); + if (nvbo->fence) + nouveau_fence_wait(&nvbo->fence); + memcpy(nvbo->map, nvbo->sysmem, nvbo->drm.size); return 0; } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_channel.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_channel.c index c4558e5573a..df80d04add5 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_channel.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_channel.c @@ -28,96 +28,91 @@ #include "nouveau_dma.h" int -nouveau_channel_alloc(struct nouveau_device *userdev, uint32_t fb_ctxdma, - uint32_t tt_ctxdma, struct nouveau_channel **userchan) +nouveau_channel_alloc(struct nouveau_device *dev, uint32_t fb_ctxdma, + uint32_t tt_ctxdma, struct nouveau_channel **chan) { - struct nouveau_device_priv *nv = nouveau_device(userdev); - struct nouveau_channel_priv *chan; + struct nouveau_device_priv *nvdev = nouveau_device(dev); + struct nouveau_channel_priv *nvchan; int ret; - if (!nv || !userchan || *userchan) + if (!nvdev || !chan || *chan) return -EINVAL; - chan = calloc(1, sizeof(*chan)); - if (!chan) + nvchan = calloc(1, sizeof(struct nouveau_channel_priv)); + if (!nvchan) return -ENOMEM; - chan->base.device = userdev; + nvchan->base.device = dev; - chan->drm.fb_ctxdma_handle = fb_ctxdma; - chan->drm.tt_ctxdma_handle = tt_ctxdma; - ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_CHANNEL_ALLOC, - &chan->drm, sizeof(chan->drm)); + nvchan->drm.fb_ctxdma_handle = fb_ctxdma; + nvchan->drm.tt_ctxdma_handle = tt_ctxdma; + ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_CHANNEL_ALLOC, + &nvchan->drm, sizeof(nvchan->drm)); if (ret) { - free(chan); + free(nvchan); return ret; } - chan->base.id = chan->drm.channel; - if (nouveau_grobj_ref(&chan->base, chan->drm.fb_ctxdma_handle, - &chan->base.vram) || - nouveau_grobj_ref(&chan->base, chan->drm.tt_ctxdma_handle, - &chan->base.gart)) { - nouveau_channel_free((void *)&chan); + nvchan->base.id = nvchan->drm.channel; + if (nouveau_grobj_ref(&nvchan->base, nvchan->drm.fb_ctxdma_handle, + &nvchan->base.vram) || + nouveau_grobj_ref(&nvchan->base, nvchan->drm.tt_ctxdma_handle, + &nvchan->base.gart)) { + nouveau_channel_free((void *)&nvchan); return -EINVAL; } - ret = drmMap(nv->fd, chan->drm.ctrl, chan->drm.ctrl_size, - (void*)&chan->user); + ret = drmMap(nvdev->fd, nvchan->drm.ctrl, nvchan->drm.ctrl_size, + (void*)&nvchan->user); if (ret) { - nouveau_channel_free((void *)&chan); + nouveau_channel_free((void *)&nvchan); return ret; } - chan->put = &chan->user[0x40/4]; - chan->get = &chan->user[0x44/4]; - chan->ref_cnt = &chan->user[0x48/4]; + nvchan->put = &nvchan->user[0x40/4]; + nvchan->get = &nvchan->user[0x44/4]; + nvchan->ref_cnt = &nvchan->user[0x48/4]; - ret = drmMap(nv->fd, chan->drm.notifier, chan->drm.notifier_size, - (drmAddressPtr)&chan->notifier_block); + ret = drmMap(nvdev->fd, nvchan->drm.notifier, nvchan->drm.notifier_size, + (drmAddressPtr)&nvchan->notifier_block); if (ret) { - nouveau_channel_free((void *)&chan); + nouveau_channel_free((void *)&nvchan); return ret; } - ret = drmMap(nv->fd, chan->drm.cmdbuf, chan->drm.cmdbuf_size, - (void*)&chan->pushbuf); + ret = drmMap(nvdev->fd, nvchan->drm.cmdbuf, nvchan->drm.cmdbuf_size, + (void*)&nvchan->pushbuf); if (ret) { - nouveau_channel_free((void *)&chan); + nouveau_channel_free((void *)&nvchan); return ret; } - nouveau_dma_channel_init(&chan->base); - nouveau_pushbuf_init(&chan->base); + nouveau_dma_channel_init(&nvchan->base); + nouveau_pushbuf_init(&nvchan->base); - *userchan = &chan->base; + *chan = &nvchan->base; return 0; } void -nouveau_channel_free(struct nouveau_channel **userchan) +nouveau_channel_free(struct nouveau_channel **chan) { - struct nouveau_channel_priv *chan; - - if (!userchan) - return; - chan = nouveau_channel(*userchan); - - if (chan) { - struct nouveau_device_priv *nv; - struct drm_nouveau_channel_free cf; - - nv = nouveau_device((*userchan)->device); - *userchan = NULL; + struct nouveau_channel_priv *nvchan; + struct nouveau_device_priv *nvdev; + struct drm_nouveau_channel_free cf; - FIRE_RING_CH(&chan->base); + if (!chan || !*chan) + return; + nvchan = nouveau_channel(*chan); + *chan = NULL; + nvdev = nouveau_device(nvchan->base.device); + + FIRE_RING_CH(&nvchan->base); - nouveau_grobj_free(&chan->base.vram); - nouveau_grobj_free(&chan->base.gart); + nouveau_grobj_free(&nvchan->base.vram); + nouveau_grobj_free(&nvchan->base.gart); - cf.channel = chan->drm.channel; - drmCommandWrite(nv->fd, DRM_NOUVEAU_CHANNEL_FREE, - &cf, sizeof(cf)); - free(chan); - } + cf.channel = nvchan->drm.channel; + drmCommandWrite(nvdev->fd, DRM_NOUVEAU_CHANNEL_FREE, &cf, sizeof(cf)); + free(nvchan); } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_device.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_device.c index a3f55135504..409e4415f76 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_device.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_device.c @@ -27,40 +27,40 @@ #include "nouveau_drmif.h" int -nouveau_device_open_existing(struct nouveau_device **userdev, int close, +nouveau_device_open_existing(struct nouveau_device **dev, int close, int fd, drm_context_t ctx) { - struct nouveau_device_priv *nv; + struct nouveau_device_priv *nvdev; int ret; - if (!userdev || *userdev) + if (!dev || *dev) return -EINVAL; - nv = calloc(1, sizeof(*nv)); - if (!nv) + nvdev = calloc(1, sizeof(*nvdev)); + if (!nvdev) return -ENOMEM; - nv->fd = fd; - nv->ctx = ctx; - nv->needs_close = close; + nvdev->fd = fd; + nvdev->ctx = ctx; + nvdev->needs_close = close; - drmCommandNone(nv->fd, DRM_NOUVEAU_CARD_INIT); + drmCommandNone(nvdev->fd, DRM_NOUVEAU_CARD_INIT); - if ((ret = nouveau_bo_init(&nv->base))) { - nouveau_device_close((void *)&nv); + if ((ret = nouveau_bo_init(&nvdev->base))) { + nouveau_device_close((void *)&nvdev); return ret; } - *userdev = &nv->base; + *dev = &nvdev->base; return 0; } int -nouveau_device_open(struct nouveau_device **userdev, const char *busid) +nouveau_device_open(struct nouveau_device **dev, const char *busid) { drm_context_t ctx; int fd, ret; - if (!userdev || *userdev) + if (!dev || *dev) return -EINVAL; fd = drmOpen("nouveau", busid); @@ -73,7 +73,7 @@ nouveau_device_open(struct nouveau_device **userdev, const char *busid) return ret; } - ret = nouveau_device_open_existing(userdev, 1, fd, ctx); + ret = nouveau_device_open_existing(dev, 1, fd, ctx); if (ret) { drmDestroyContext(fd, ctx); drmClose(fd); @@ -84,37 +84,38 @@ nouveau_device_open(struct nouveau_device **userdev, const char *busid) } void -nouveau_device_close(struct nouveau_device **userdev) +nouveau_device_close(struct nouveau_device **dev) { - struct nouveau_device_priv *nv; + struct nouveau_device_priv *nvdev; - if (userdev || !*userdev) + if (dev || !*dev) return; - nv = (struct nouveau_device_priv *)*userdev; - *userdev = NULL; + nvdev = nouveau_device(*dev); + *dev = NULL; - nouveau_bo_takedown(&nv->base); + nouveau_bo_takedown(&nvdev->base); - if (nv->needs_close) { - drmDestroyContext(nv->fd, nv->ctx); - drmClose(nv->fd); + if (nvdev->needs_close) { + drmDestroyContext(nvdev->fd, nvdev->ctx); + drmClose(nvdev->fd); } - free(nv); + free(nvdev); } int -nouveau_device_get_param(struct nouveau_device *userdev, +nouveau_device_get_param(struct nouveau_device *dev, uint64_t param, uint64_t *value) { - struct nouveau_device_priv *nv = (struct nouveau_device_priv *)userdev; + struct nouveau_device_priv *nvdev = nouveau_device(dev); struct drm_nouveau_getparam g; int ret; - if (!nv || !value) + if (!nvdev || !value) return -EINVAL; g.param = param; - ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_GETPARAM, &g, sizeof(g)); + ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GETPARAM, + &g, sizeof(g)); if (ret) return ret; @@ -123,19 +124,20 @@ nouveau_device_get_param(struct nouveau_device *userdev, } int -nouveau_device_set_param(struct nouveau_device *userdev, +nouveau_device_set_param(struct nouveau_device *dev, uint64_t param, uint64_t value) { - struct nouveau_device_priv *nv = (struct nouveau_device_priv *)userdev; + struct nouveau_device_priv *nvdev = nouveau_device(dev); struct drm_nouveau_setparam s; int ret; - if (!nv) + if (!nvdev) return -EINVAL; s.param = param; s.value = value; - ret = drmCommandWriteRead(nv->fd, DRM_NOUVEAU_SETPARAM, &s, sizeof(s)); + ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_SETPARAM, + &s, sizeof(s)); if (ret) return ret; diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.c index 0c04a59c744..b89f1b5cf5f 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.c @@ -53,18 +53,18 @@ WRITE_PUT(struct nouveau_channel_priv *nvchan, uint32_t val) } void -nouveau_dma_channel_init(struct nouveau_channel *userchan) +nouveau_dma_channel_init(struct nouveau_channel *chan) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); int i; - chan->dma.base = chan->drm.put_base; - chan->dma.cur = chan->dma.put = RING_SKIPS; - chan->dma.max = (chan->drm.cmdbuf_size >> 2) - 2; - chan->dma.free = chan->dma.max - chan->dma.cur; + nvchan->dma.base = nvchan->drm.put_base; + nvchan->dma.cur = nvchan->dma.put = RING_SKIPS; + nvchan->dma.max = (nvchan->drm.cmdbuf_size >> 2) - 2; + nvchan->dma.free = nvchan->dma.max - nvchan->dma.cur; for (i = 0; i < RING_SKIPS; i++) - chan->pushbuf[i] = 0x00000000; + nvchan->pushbuf[i] = 0x00000000; } #define CHECK_TIMEOUT() do { \ @@ -75,49 +75,51 @@ nouveau_dma_channel_init(struct nouveau_channel *userchan) #define IN_MASTER_RING(chan, ptr) ((ptr) <= (chan)->dma.max) int -nouveau_dma_wait(struct nouveau_channel *userchan, int size) +nouveau_dma_wait(struct nouveau_channel *chan, int size) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); uint32_t get, t_start; - FIRE_RING_CH(userchan); + FIRE_RING_CH(chan); t_start = NOUVEAU_TIME_MSEC(); - while (chan->dma.free < size) { + while (nvchan->dma.free < size) { CHECK_TIMEOUT(); - get = READ_GET(chan); - if (!IN_MASTER_RING(chan, get)) + get = READ_GET(nvchan); + if (!IN_MASTER_RING(nvchan, get)) continue; - if (chan->dma.put >= get) { - chan->dma.free = chan->dma.max - chan->dma.cur; + if (nvchan->dma.put >= get) { + nvchan->dma.free = nvchan->dma.max - nvchan->dma.cur; - if (chan->dma.free < size) { + if (nvchan->dma.free < size) { #ifdef NOUVEAU_DMA_DEBUG - chan->dma.push_free = 1; + nvchan->dma.push_free = 1; #endif - OUT_RING_CH(userchan, - 0x20000000 | chan->dma.base); + OUT_RING_CH(chan, + 0x20000000 | nvchan->dma.base); if (get <= RING_SKIPS) { /*corner case - will be idle*/ - if (chan->dma.put <= RING_SKIPS) - WRITE_PUT(chan, RING_SKIPS + 1); + if (nvchan->dma.put <= RING_SKIPS) + WRITE_PUT(nvchan, + RING_SKIPS + 1); do { CHECK_TIMEOUT(); - get = READ_GET(chan); - if (!IN_MASTER_RING(chan, get)) + get = READ_GET(nvchan); + if (!IN_MASTER_RING(nvchan, + get)) continue; } while (get <= RING_SKIPS); } - WRITE_PUT(chan, RING_SKIPS); - chan->dma.cur = chan->dma.put = RING_SKIPS; - chan->dma.free = get - (RING_SKIPS + 1); + WRITE_PUT(nvchan, RING_SKIPS); + nvchan->dma.cur = nvchan->dma.put = RING_SKIPS; + nvchan->dma.free = get - (RING_SKIPS + 1); } } else { - chan->dma.free = get - chan->dma.cur - 1; + nvchan->dma.free = get - nvchan->dma.cur - 1; } } @@ -128,22 +130,22 @@ nouveau_dma_wait(struct nouveau_channel *userchan, int size) void nouveau_dma_subc_bind(struct nouveau_grobj *grobj) { - struct nouveau_channel_priv *chan = nouveau_channel(grobj->channel); + struct nouveau_channel_priv *nvchan = nouveau_channel(grobj->channel); int subc = -1, i; for (i = 0; i < 8; i++) { - if (chan->subchannel[i].grobj && - chan->subchannel[i].grobj->bound == + if (nvchan->subchannel[i].grobj && + nvchan->subchannel[i].grobj->bound == NOUVEAU_GROBJ_EXPLICIT_BIND) continue; - if (chan->subchannel[i].seq < chan->subchannel[subc].seq) + if (nvchan->subchannel[i].seq < nvchan->subchannel[subc].seq) subc = i; } assert(subc >= 0); - if (chan->subchannel[subc].grobj) - chan->subchannel[subc].grobj->bound = 0; - chan->subchannel[subc].grobj = grobj; + if (nvchan->subchannel[subc].grobj) + nvchan->subchannel[subc].grobj->bound = 0; + nvchan->subchannel[subc].grobj = grobj; grobj->subc = subc; grobj->bound = NOUVEAU_GROBJ_BOUND; @@ -210,23 +212,24 @@ nouveau_dma_parse_pushbuf(struct nouveau_channel *chan, int get, int put) #endif void -nouveau_dma_kickoff(struct nouveau_channel *userchan) +nouveau_dma_kickoff(struct nouveau_channel *chan) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); - if (chan->dma.cur == chan->dma.put) + if (nvchan->dma.cur == nvchan->dma.put) return; #ifdef NOUVEAU_DMA_DEBUG - if (chan->dma.push_free) { - NOUVEAU_ERR("Packet incomplete: %d left\n", chan->dma.push_free); + if (nvchan->dma.push_free) { + NOUVEAU_ERR("Packet incomplete: %d left\n", + nvchan->dma.push_free); return; } #endif #ifdef NOUVEAU_DMA_DUMP_POSTRELOC_PUSHBUF - nouveau_dma_parse_pushbuf(userchan, chan->dma.put, chan->dma.cur); + nouveau_dma_parse_pushbuf(chan, nvchan->dma.put, nvchan->dma.cur); #endif - WRITE_PUT(chan, chan->dma.cur); + WRITE_PUT(nvchan, nvchan->dma.cur); } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.h b/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.h index 927841c4eb4..d4dd3054f3d 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.h +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_dma.h @@ -39,112 +39,112 @@ static char faulty[1024]; #endif static inline void -nouveau_dma_out(struct nouveau_channel *userchan, uint32_t data) +nouveau_dma_out(struct nouveau_channel *chan, uint32_t data) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); #ifdef NOUVEAU_DMA_DEBUG - if (chan->dma.push_free == 0) { + if (nvchan->dma.push_free == 0) { NOUVEAU_ERR("No space left in packet. Error at %s\n",faulty); return; } - chan->dma.push_free--; + nvchan->dma.push_free--; #endif #ifdef NOUVEAU_DMA_TRACE { - uint32_t offset = (chan->dma.cur << 2) + chan->dma.base; + uint32_t offset = (nvchan->dma.cur << 2) + nvchan->dma.base; NOUVEAU_MSG("\tOUT_RING %d/0x%08x -> 0x%08x\n", - chan->drm.channel, offset, data); + nvchan->drm.channel, offset, data); } #endif - chan->pushbuf[chan->dma.cur++] = data; + nvchan->pushbuf[nvchan->dma.cur++] = data; } static inline void -nouveau_dma_outp(struct nouveau_channel *userchan, uint32_t *ptr, int size) +nouveau_dma_outp(struct nouveau_channel *chan, uint32_t *ptr, int size) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); (void)chan; #ifdef NOUVEAU_DMA_DEBUG - if (chan->dma.push_free < size) { + if (nvchan->dma.push_free < size) { NOUVEAU_ERR("Packet too small. Free=%d, Need=%d\n", - chan->dma.push_free, size); + nvchan->dma.push_free, size); return; } #endif #ifdef NOUVEAU_DMA_TRACE while (size--) { - nouveau_dma_out(userchan, *ptr); + nouveau_dma_out(chan, *ptr); ptr++; } #else - memcpy(&chan->pushbuf[chan->dma.cur], ptr, size << 2); + memcpy(&nvchan->pushbuf[nvchan->dma.cur], ptr, size << 2); #ifdef NOUVEAU_DMA_DEBUG - chan->dma.push_free -= size; + nvchan->dma.push_free -= size; #endif - chan->dma.cur += size; + nvchan->dma.cur += size; #endif } static inline void -nouveau_dma_begin(struct nouveau_channel *userchan, struct nouveau_grobj *grobj, +nouveau_dma_begin(struct nouveau_channel *chan, struct nouveau_grobj *grobj, int method, int size, const char* file, int line) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); int push_size = size + 1; #ifdef NOUVEAU_DMA_SUBCHAN_LRU if (grobj->bound == NOUVEAU_GROBJ_UNBOUND) nouveau_dma_subc_bind(grobj); - chan->subchannel[grobj->subc].seq = chan->subc_sequence++; + nvchan->subchannel[grobj->subc].seq = nvchan->subc_sequence++; #endif #ifdef NOUVEAU_DMA_TRACE - NOUVEAU_MSG("BEGIN_RING %d/%08x/%d/0x%04x/%d\n", chan->drm.channel, + NOUVEAU_MSG("BEGIN_RING %d/%08x/%d/0x%04x/%d\n", nvchan->drm.channel, grobj->handle, grobj->subc, method, size); #endif #ifdef NOUVEAU_DMA_DEBUG - if (chan->dma.push_free) { + if (nvchan->dma.push_free) { NOUVEAU_ERR("Previous packet incomplete: %d left. Error at %s\n", - chan->dma.push_free,faulty); + nvchan->dma.push_free,faulty); return; } sprintf(faulty,"%s:%d",file,line); #endif - if (chan->dma.free < push_size) { - if (nouveau_dma_wait(userchan, push_size) && - userchan->hang_notify) { - userchan->hang_notify(userchan); + if (nvchan->dma.free < push_size) { + if (nouveau_dma_wait(chan, push_size) && + chan->hang_notify) { + chan->hang_notify(chan); } } - chan->dma.free -= push_size; + nvchan->dma.free -= push_size; #ifdef NOUVEAU_DMA_DEBUG - chan->dma.push_free = push_size; + nvchan->dma.push_free = push_size; #endif - nouveau_dma_out(userchan, (size << 18) | (grobj->subc << 13) | method); + nouveau_dma_out(chan, (size << 18) | (grobj->subc << 13) | method); } static inline void -nouveau_dma_bind(struct nouveau_channel *userchan, struct nouveau_grobj *grobj, +nouveau_dma_bind(struct nouveau_channel *chan, struct nouveau_grobj *grobj, int subc) { - struct nouveau_channel_priv *chan = nouveau_channel(userchan); + struct nouveau_channel_priv *nvchan = nouveau_channel(chan); - if (chan->subchannel[subc].grobj == grobj) + if (nvchan->subchannel[subc].grobj == grobj) return; - if (chan->subchannel[subc].grobj) - chan->subchannel[subc].grobj->bound = NOUVEAU_GROBJ_UNBOUND; - chan->subchannel[subc].grobj = grobj; + if (nvchan->subchannel[subc].grobj) + nvchan->subchannel[subc].grobj->bound = NOUVEAU_GROBJ_UNBOUND; + nvchan->subchannel[subc].grobj = grobj; grobj->subc = subc; grobj->bound = NOUVEAU_GROBJ_EXPLICIT_BIND; - nouveau_dma_begin(userchan, grobj, 0x0000, 1, __FUNCTION__, __LINE__); - nouveau_dma_out (userchan, grobj->handle); + nouveau_dma_begin(chan, grobj, 0x0000, 1, __FUNCTION__, __LINE__); + nouveau_dma_out (chan, grobj->handle); } #define BIND_RING_CH(ch,gr,sc) nouveau_dma_bind((ch), (gr), (sc)) diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_grobj.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_grobj.c index 8dab2023956..55dfeb99aa7 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_grobj.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_grobj.c @@ -26,82 +26,82 @@ #include "nouveau_drmif.h" int -nouveau_grobj_alloc(struct nouveau_channel *userchan, uint32_t handle, - int class, struct nouveau_grobj **usergrobj) +nouveau_grobj_alloc(struct nouveau_channel *chan, uint32_t handle, + int class, struct nouveau_grobj **grobj) { - struct nouveau_device_priv *nv = nouveau_device(userchan->device); - struct nouveau_grobj_priv *gr; + struct nouveau_device_priv *nvdev = nouveau_device(chan->device); + struct nouveau_grobj_priv *nvgrobj; struct drm_nouveau_grobj_alloc g; int ret; - if (!nv || !usergrobj || *usergrobj) + if (!nvdev || !grobj || *grobj) return -EINVAL; - gr = calloc(1, sizeof(*gr)); - if (!gr) + nvgrobj = calloc(1, sizeof(*nvgrobj)); + if (!nvgrobj) return -ENOMEM; - gr->base.channel = userchan; - gr->base.handle = handle; - gr->base.grclass = class; + nvgrobj->base.channel = chan; + nvgrobj->base.handle = handle; + nvgrobj->base.grclass = class; - g.channel = userchan->id; + g.channel = chan->id; g.handle = handle; g.class = class; - ret = drmCommandWrite(nv->fd, DRM_NOUVEAU_GROBJ_ALLOC, &g, sizeof(g)); + ret = drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GROBJ_ALLOC, + &g, sizeof(g)); if (ret) { - nouveau_grobj_free((void *)&gr); + nouveau_grobj_free((void *)&grobj); return ret; } - *usergrobj = &gr->base; + *grobj = &nvgrobj->base; return 0; } int -nouveau_grobj_ref(struct nouveau_channel *userchan, uint32_t handle, - struct nouveau_grobj **usergr) +nouveau_grobj_ref(struct nouveau_channel *chan, uint32_t handle, + struct nouveau_grobj **grobj) { - struct nouveau_grobj_priv *gr; + struct nouveau_grobj_priv *nvgrobj; - if (!userchan || !usergr || *usergr) + if (!chan || !grobj || *grobj) return -EINVAL; - gr = calloc(1, sizeof(*gr)); - if (!gr) + nvgrobj = calloc(1, sizeof(struct nouveau_grobj_priv)); + if (!nvgrobj) return -ENOMEM; - gr->base.channel = userchan; - gr->base.handle = handle; - gr->base.grclass = 0; + nvgrobj->base.channel = chan; + nvgrobj->base.handle = handle; + nvgrobj->base.grclass = 0; - *usergr = &gr->base; + *grobj = &nvgrobj->base; return 0; } void -nouveau_grobj_free(struct nouveau_grobj **usergrobj) +nouveau_grobj_free(struct nouveau_grobj **grobj) { - struct nouveau_grobj_priv *gr; + struct nouveau_device_priv *nvdev; + struct nouveau_channel_priv *chan; + struct nouveau_grobj_priv *nvgrobj; - if (!usergrobj) + if (!grobj || !*grobj) return; - gr = nouveau_grobj(*usergrobj); - *usergrobj = NULL; + nvgrobj = nouveau_grobj(*grobj); + *grobj = NULL; - if (gr) { - struct nouveau_channel_priv *chan; - struct nouveau_device_priv *nv; - struct drm_nouveau_gpuobj_free f; - chan = nouveau_channel(gr->base.channel); - nv = nouveau_device(chan->base.device); + chan = nouveau_channel(nvgrobj->base.channel); + nvdev = nouveau_device(chan->base.device); + + if (nvgrobj->base.grclass) { + struct drm_nouveau_gpuobj_free f; - if (gr->base.grclass) { - f.channel = chan->drm.channel; - f.handle = gr->base.handle; - drmCommandWrite(nv->fd, DRM_NOUVEAU_GPUOBJ_FREE, - &f, sizeof(f)); - } - free(gr); + f.channel = chan->drm.channel; + f.handle = nvgrobj->base.handle; + drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GPUOBJ_FREE, + &f, sizeof(f)); } + free(nvgrobj); } diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_notifier.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_notifier.c index e423d59b1df..01e8f38440e 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_notifier.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_notifier.c @@ -27,70 +27,67 @@ #include "nouveau_local.h" #define NOTIFIER(__v) \ - struct nouveau_notifier_priv *notifier = nouveau_notifier(user); \ - volatile uint32_t *n = (void*)notifier->map + (id * 32) + struct nouveau_notifier_priv *nvnotify = nouveau_notifier(notifier); \ + volatile uint32_t *__v = (void*)nvnotify->map + (id * 32) int -nouveau_notifier_alloc(struct nouveau_channel *userchan, uint32_t handle, - int count, struct nouveau_notifier **usernotifier) +nouveau_notifier_alloc(struct nouveau_channel *chan, uint32_t handle, + int count, struct nouveau_notifier **notifier) { - struct nouveau_notifier_priv *notifier; + struct nouveau_notifier_priv *nvnotify; int ret; - if (!userchan || !usernotifier || *usernotifier) + if (!chan || !notifier || *notifier) return -EINVAL; - notifier = calloc(1, sizeof(*notifier)); - if (!notifier) + nvnotify = calloc(1, sizeof(struct nouveau_notifier_priv)); + if (!nvnotify) return -ENOMEM; - notifier->base.channel = userchan; - notifier->base.handle = handle; + nvnotify->base.channel = chan; + nvnotify->base.handle = handle; - notifier->drm.channel = userchan->id; - notifier->drm.handle = handle; - notifier->drm.count = count; - if ((ret = drmCommandWriteRead(nouveau_device(userchan->device)->fd, + nvnotify->drm.channel = chan->id; + nvnotify->drm.handle = handle; + nvnotify->drm.count = count; + if ((ret = drmCommandWriteRead(nouveau_device(chan->device)->fd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC, - ¬ifier->drm, - sizeof(notifier->drm)))) { - nouveau_notifier_free((void *)¬ifier); + &nvnotify->drm, + sizeof(nvnotify->drm)))) { + nouveau_notifier_free((void *)&nvnotify); return ret; } - notifier->map = (void *)nouveau_channel(userchan)->notifier_block + - notifier->drm.offset; - *usernotifier = ¬ifier->base; + nvnotify->map = (void *)nouveau_channel(chan)->notifier_block + + nvnotify->drm.offset; + *notifier = &nvnotify->base; return 0; } void -nouveau_notifier_free(struct nouveau_notifier **usernotifier) +nouveau_notifier_free(struct nouveau_notifier **notifier) { - struct nouveau_notifier_priv *notifier; + struct nouveau_notifier_priv *nvnotify; + struct nouveau_channel_priv *nvchan; + struct nouveau_device_priv *nvdev; + struct drm_nouveau_gpuobj_free f; - if (!usernotifier) + if (!notifier || !*notifier) return; - notifier = nouveau_notifier(*usernotifier); - *usernotifier = NULL; + nvnotify = nouveau_notifier(*notifier); + *notifier = NULL; - if (notifier) { - struct nouveau_channel_priv *chan; - struct nouveau_device_priv *nv; - struct drm_nouveau_gpuobj_free f; + nvchan = nouveau_channel(nvnotify->base.channel); + nvdev = nouveau_device(nvchan->base.device); - chan = nouveau_channel(notifier->base.channel); - nv = nouveau_device(chan->base.device); - - f.channel = chan->drm.channel; - f.handle = notifier->base.handle; - drmCommandWrite(nv->fd, DRM_NOUVEAU_GPUOBJ_FREE, &f, sizeof(f)); - free(notifier); - } + f.channel = nvchan->drm.channel; + f.handle = nvnotify->base.handle; + drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GPUOBJ_FREE, &f, sizeof(f)); + free(nvnotify); } void -nouveau_notifier_reset(struct nouveau_notifier *user, int id) +nouveau_notifier_reset(struct nouveau_notifier *notifier, int id) { NOTIFIER(n); @@ -102,7 +99,7 @@ nouveau_notifier_reset(struct nouveau_notifier *user, int id) } uint32_t -nouveau_notifier_status(struct nouveau_notifier *user, int id) +nouveau_notifier_status(struct nouveau_notifier *notifier, int id) { NOTIFIER(n); @@ -110,7 +107,7 @@ nouveau_notifier_status(struct nouveau_notifier *user, int id) } uint32_t -nouveau_notifier_return_val(struct nouveau_notifier *user, int id) +nouveau_notifier_return_val(struct nouveau_notifier *notifier, int id) { NOTIFIER(n); @@ -118,7 +115,7 @@ nouveau_notifier_return_val(struct nouveau_notifier *user, int id) } int -nouveau_notifier_wait_status(struct nouveau_notifier *user, int id, +nouveau_notifier_wait_status(struct nouveau_notifier *notifier, int id, int status, int timeout) { NOTIFIER(n); |