diff options
Diffstat (limited to 'screen.c')
-rw-r--r-- | screen.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -92,3 +92,30 @@ static uint64_t get_param(unsigned int param) drmCommandWriteRead(drm_fd, DRM_NOUVEAU_GETPARAM, &getp, sizeof(getp)); return getp.value; } + +void *screen_allocmem(int agp, int size, uint64_t *ofs) +{ + struct drm_nouveau_mem_alloc mema; + void *map; + int ret; + + mema.flags = NOUVEAU_MEM_MAPPED; + mema.flags |= (agp ? NOUVEAU_MEM_AGP : NOUVEAU_MEM_FB); + + mema.alignment = 0x1000; + mema.size = size; + ret = drmCommandWriteRead(drm_fd, DRM_NOUVEAU_MEM_ALLOC, &mema, sizeof(mema)); + if (ret) { + fprintf(stderr, "Failed to alloc memory\n"); + return NULL; + } + *ofs = mema.offset; + + /* instead of mema.map_handle, originally we were passing in ofs */ + if (drmMap(drm_fd, mema.map_handle, mema.size, &map)) { + fprintf(stderr, "Failed to map memory\n"); + return NULL; + } + + return map; +} |