2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/i915_drm.h>
|
2012-01-30 08:06:25 +01:00
|
|
|
#include "i915_drv.h"
|
|
|
|
#include "intel_drv.h"
|
2012-11-13 10:18:58 +01:00
|
|
|
#include "hmm.h"
|
2012-01-30 08:06:25 +01:00
|
|
|
#include "bitmap.h"
|
|
|
|
|
2013-02-13 09:23:54 +01:00
|
|
|
//#define DRIVER_CAPS_0 HW_BIT_BLIT;
|
|
|
|
|
|
|
|
#define DRIVER_CAPS_0 0
|
2012-11-13 10:18:58 +01:00
|
|
|
#define DRIVER_CAPS_1 0
|
2012-02-18 15:32:16 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
struct context *context_map[256];
|
2012-02-18 15:32:16 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
struct hmm bm_mm;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
|
|
|
extern struct drm_device *main_device;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
|
2012-02-03 07:54:20 +01:00
|
|
|
void __attribute__((regparm(1))) destroy_bitmap(bitmap_t *bitmap)
|
|
|
|
{
|
2012-11-14 07:08:43 +01:00
|
|
|
dma_addr_t *pages = bitmap->obj->allocated_pages;
|
2012-11-13 10:18:58 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
free_handle(&bm_mm, bitmap->handle);
|
2012-02-04 14:23:46 +01:00
|
|
|
bitmap->handle = 0;
|
2012-02-16 11:48:38 +01:00
|
|
|
bitmap->obj->base.read_domains = I915_GEM_DOMAIN_GTT;
|
|
|
|
bitmap->obj->base.write_domain = I915_GEM_DOMAIN_CPU;
|
|
|
|
|
|
|
|
mutex_lock(&main_device->struct_mutex);
|
2012-02-04 14:23:46 +01:00
|
|
|
drm_gem_object_unreference(&bitmap->obj->base);
|
2012-02-16 11:48:38 +01:00
|
|
|
mutex_unlock(&main_device->struct_mutex);
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
if(pages != NULL)
|
|
|
|
{
|
|
|
|
for (i = 0; i < bitmap->page_count; i++)
|
|
|
|
FreePage(pages[i]);
|
|
|
|
|
2012-11-15 09:04:26 +01:00
|
|
|
DRM_DEBUG("%s release %d pages\n", __FUNCTION__, bitmap->page_count);
|
2012-11-14 07:08:43 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
free(pages);
|
|
|
|
};
|
|
|
|
UserFree(bitmap->uaddr);
|
2012-02-03 07:54:20 +01:00
|
|
|
__DestroyObject(bitmap);
|
|
|
|
};
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
|
|
|
|
static int bitmap_get_pages_gtt(struct drm_i915_gem_object *obj)
|
2012-01-30 08:06:25 +01:00
|
|
|
{
|
2012-11-13 10:18:58 +01:00
|
|
|
int page_count;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
/* Get the list of pages out of our struct file. They'll be pinned
|
|
|
|
* at this point until we release them.
|
|
|
|
*/
|
2012-11-15 09:04:26 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
page_count = obj->base.size / PAGE_SIZE;
|
|
|
|
BUG_ON(obj->allocated_pages == NULL);
|
|
|
|
BUG_ON(obj->pages.page != NULL);
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
obj->pages.page = obj->allocated_pages;
|
|
|
|
obj->pages.nents = page_count;
|
|
|
|
|
|
|
|
|
|
|
|
// if (obj->tiling_mode != I915_TILING_NONE)
|
|
|
|
// i915_gem_object_do_bit_17_swizzle(obj);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bitmap_put_pages_gtt(struct drm_i915_gem_object *obj)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
BUG_ON(obj->madv == __I915_MADV_PURGED);
|
|
|
|
|
|
|
|
ret = i915_gem_object_set_to_cpu_domain(obj, true);
|
|
|
|
if (ret) {
|
|
|
|
/* In the event of a disaster, abandon all caches and
|
|
|
|
* hope for the best.
|
|
|
|
*/
|
|
|
|
WARN_ON(ret != -EIO);
|
|
|
|
i915_gem_clflush_object(obj);
|
|
|
|
obj->base.read_domains = obj->base.write_domain = I915_GEM_DOMAIN_CPU;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj->madv == I915_MADV_DONTNEED)
|
|
|
|
obj->dirty = 0;
|
|
|
|
|
|
|
|
obj->dirty = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_i915_gem_object_ops bitmap_object_ops = {
|
|
|
|
.get_pages = bitmap_get_pages_gtt,
|
|
|
|
.put_pages = bitmap_put_pages_gtt,
|
2012-01-30 08:06:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
struct io_call_10 /* SRV_CREATE_SURFACE */
|
|
|
|
{
|
|
|
|
u32 handle; // ignored
|
|
|
|
void *data; // ignored
|
|
|
|
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
u32 pitch; // ignored
|
|
|
|
|
|
|
|
u32 max_width;
|
|
|
|
u32 max_height;
|
|
|
|
u32 format; // reserved mbz
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int create_surface(struct drm_device *dev, struct io_call_10 *pbitmap)
|
2012-01-30 08:06:25 +01:00
|
|
|
{
|
|
|
|
struct drm_i915_gem_object *obj;
|
|
|
|
|
|
|
|
bitmap_t *bitmap;
|
|
|
|
u32 handle;
|
2012-02-04 14:23:46 +01:00
|
|
|
u32 width, max_width;
|
|
|
|
u32 height, max_height;
|
|
|
|
u32 size, max_size;
|
|
|
|
u32 pitch, max_pitch;
|
2012-01-30 08:06:25 +01:00
|
|
|
void *uaddr;
|
2012-11-13 10:18:58 +01:00
|
|
|
dma_addr_t *pages;
|
|
|
|
u32 page_count;
|
|
|
|
|
|
|
|
int i;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pbitmap->handle = 0;
|
2012-02-04 14:23:46 +01:00
|
|
|
pbitmap->data = (void*)-1;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-02-04 14:23:46 +01:00
|
|
|
width = pbitmap->width;
|
2012-02-03 07:54:20 +01:00
|
|
|
height = pbitmap->height;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
if((width == 0)||(height == 0)||(width > 4096)||(height > 4096))
|
2012-01-30 08:06:25 +01:00
|
|
|
goto err1;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
/*
|
2012-02-04 14:23:46 +01:00
|
|
|
if( ((pbitmap->max_width !=0 ) &&
|
|
|
|
(pbitmap->max_width < width)) ||
|
|
|
|
(pbitmap->max_width > 4096) )
|
|
|
|
goto err1;
|
|
|
|
|
|
|
|
if( ((pbitmap->max_height !=0 ) &&
|
|
|
|
(pbitmap->max_height < width)) ||
|
|
|
|
(pbitmap->max_height > 4096) )
|
|
|
|
goto err1;
|
|
|
|
|
|
|
|
if( pbitmap->format != 0)
|
|
|
|
goto err1;
|
|
|
|
*/
|
|
|
|
|
|
|
|
max_width = (pbitmap->max_width ==0) ? width : pbitmap->max_width;
|
|
|
|
max_height = (pbitmap->max_height==0) ? height : pbitmap->max_height;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
handle = alloc_handle(&bm_mm);
|
2012-02-03 07:54:20 +01:00
|
|
|
// printf("%s %d\n",__FUNCTION__, handle);
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
if(handle == 0)
|
|
|
|
goto err1;
|
|
|
|
|
|
|
|
bitmap = CreateObject(GetPid(), sizeof(*bitmap));
|
2012-02-21 07:06:51 +01:00
|
|
|
// printf("bitmap %x\n", bitmap);
|
|
|
|
if( bitmap == NULL)
|
2012-11-13 10:18:58 +01:00
|
|
|
goto err2;
|
2012-02-21 07:06:51 +01:00
|
|
|
|
2012-02-03 07:54:20 +01:00
|
|
|
bitmap->handle = handle;
|
|
|
|
bitmap->header.destroy = destroy_bitmap;
|
|
|
|
bitmap->obj = NULL;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
hmm_set_data(&bm_mm, handle, bitmap);
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
pitch = ALIGN(width*4,64);
|
|
|
|
size = roundup(pitch*height, PAGE_SIZE);
|
2012-02-04 14:23:46 +01:00
|
|
|
|
2012-02-03 07:54:20 +01:00
|
|
|
// printf("pitch %d size %d\n", pitch, size);
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-02-04 14:23:46 +01:00
|
|
|
max_pitch = ALIGN(max_width*4,64);
|
|
|
|
max_size = roundup(max_pitch*max_height, PAGE_SIZE);
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
// printf("max_pitch %d max_size %d\n", max_pitch, max_size);
|
|
|
|
|
2012-02-04 14:23:46 +01:00
|
|
|
uaddr = UserAlloc(max_size);
|
2012-01-30 08:06:25 +01:00
|
|
|
if( uaddr == NULL)
|
2012-11-13 10:18:58 +01:00
|
|
|
goto err3;
|
2012-01-30 08:06:25 +01:00
|
|
|
else
|
|
|
|
{
|
2012-11-13 10:18:58 +01:00
|
|
|
u32 max_count;
|
|
|
|
dma_addr_t page;
|
|
|
|
char *vaddr = uaddr;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
page_count = size/PAGE_SIZE;
|
|
|
|
max_count = max_size/PAGE_SIZE;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
pages = kzalloc(max_count*sizeof(dma_addr_t), 0);
|
|
|
|
if( pages == NULL)
|
|
|
|
goto err4;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
for(i = 0; i < page_count; i++, vaddr+= PAGE_SIZE)
|
2012-01-30 08:06:25 +01:00
|
|
|
{
|
2012-11-13 10:18:58 +01:00
|
|
|
page = AllocPage();
|
|
|
|
if ( page == 0 )
|
|
|
|
goto err4;
|
|
|
|
pages[i] = page;
|
|
|
|
|
|
|
|
MapPage(vaddr, page, 0x207); //map as shared page
|
2012-01-30 08:06:25 +01:00
|
|
|
};
|
2012-11-17 07:19:51 +01:00
|
|
|
for(;i < max_count; i++, vaddr+= PAGE_SIZE)
|
|
|
|
{
|
|
|
|
MapPage(vaddr, 0, 0); //map as shared page
|
|
|
|
};
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
bitmap->page_count = page_count;
|
|
|
|
bitmap->max_count = max_count;
|
|
|
|
};
|
|
|
|
|
2012-11-14 07:08:43 +01:00
|
|
|
DRM_DEBUG("%s alloc %d pages\n", __FUNCTION__, page_count);
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
obj = i915_gem_alloc_object(dev, size);
|
|
|
|
if (obj == NULL)
|
|
|
|
goto err4;
|
|
|
|
|
|
|
|
obj->ops = &bitmap_object_ops;
|
|
|
|
obj->allocated_pages = pages;
|
|
|
|
|
|
|
|
ret = i915_gem_object_pin(obj, PAGE_SIZE, true,true);
|
|
|
|
if (ret)
|
|
|
|
goto err5;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2013-02-13 09:23:54 +01:00
|
|
|
obj->mapped = uaddr ;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-01-30 08:06:25 +01:00
|
|
|
bitmap->handle = handle;
|
2012-02-04 14:23:46 +01:00
|
|
|
bitmap->uaddr = uaddr;
|
2012-01-30 08:06:25 +01:00
|
|
|
bitmap->pitch = pitch;
|
|
|
|
bitmap->gaddr = obj->gtt_offset;
|
2012-02-04 14:23:46 +01:00
|
|
|
|
|
|
|
bitmap->width = width;
|
|
|
|
bitmap->height = height;
|
|
|
|
bitmap->max_width = max_width;
|
|
|
|
bitmap->max_height = max_height;
|
|
|
|
|
2012-01-30 08:06:25 +01:00
|
|
|
bitmap->obj = obj;
|
2012-02-03 07:54:20 +01:00
|
|
|
bitmap->header.destroy = destroy_bitmap;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
pbitmap->handle = handle;
|
|
|
|
pbitmap->data = uaddr;
|
2012-02-04 14:23:46 +01:00
|
|
|
pbitmap->pitch = pitch;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-02-04 14:23:46 +01:00
|
|
|
|
2012-11-14 07:08:43 +01:00
|
|
|
DRM_DEBUG("%s handle: %d pitch: %d gpu_addr: %x user_addr: %x\n",
|
2012-02-04 14:23:46 +01:00
|
|
|
__FUNCTION__, handle, pitch, obj->gtt_offset, uaddr);
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
err5:
|
|
|
|
mutex_lock(&dev->struct_mutex);
|
|
|
|
drm_gem_object_unreference(&obj->base);
|
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
|
2012-01-30 08:06:25 +01:00
|
|
|
err4:
|
2012-11-13 10:18:58 +01:00
|
|
|
while (i--)
|
|
|
|
FreePage(pages[i]);
|
|
|
|
free(pages);
|
|
|
|
UserFree(uaddr);
|
|
|
|
|
2012-01-30 08:06:25 +01:00
|
|
|
err3:
|
2012-02-03 07:54:20 +01:00
|
|
|
__DestroyObject(bitmap);
|
2012-11-13 10:18:58 +01:00
|
|
|
err2:
|
|
|
|
free_handle(&bm_mm, handle);
|
2012-01-30 08:06:25 +01:00
|
|
|
err1:
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-02-18 15:32:16 +01:00
|
|
|
int lock_surface(struct io_call_12 *pbitmap)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
bitmap_t *bitmap;
|
|
|
|
|
|
|
|
if(unlikely(pbitmap->handle == 0))
|
|
|
|
return -1;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
bitmap = (bitmap_t*)hmm_get_data(&bm_mm, pbitmap->handle);
|
2012-02-04 14:23:46 +01:00
|
|
|
|
2012-02-18 15:32:16 +01:00
|
|
|
if(unlikely(bitmap==NULL))
|
|
|
|
return -1;
|
|
|
|
|
2012-11-14 07:08:43 +01:00
|
|
|
mutex_lock(&main_device->struct_mutex);
|
2012-11-13 10:18:58 +01:00
|
|
|
ret = i915_gem_object_set_to_cpu_domain(bitmap->obj, true);
|
2012-11-14 07:08:43 +01:00
|
|
|
mutex_unlock(&main_device->struct_mutex);
|
2012-11-13 10:18:58 +01:00
|
|
|
|
|
|
|
if(ret != 0 )
|
2012-02-18 15:32:16 +01:00
|
|
|
{
|
|
|
|
pbitmap->data = NULL;
|
|
|
|
pbitmap->pitch = 0;
|
|
|
|
|
|
|
|
dbgprintf("%s fail\n", __FUNCTION__);
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
pbitmap->data = bitmap->uaddr;
|
|
|
|
pbitmap->pitch = bitmap->pitch;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
};
|
2012-02-04 14:23:46 +01:00
|
|
|
|
2012-02-21 07:06:51 +01:00
|
|
|
|
2012-11-15 09:04:26 +01:00
|
|
|
int resize_surface(struct io_call_14 *pbitmap)
|
|
|
|
{
|
|
|
|
bitmap_t *bitmap;
|
|
|
|
dma_addr_t page, *pages;
|
|
|
|
u32 size, page_count;
|
|
|
|
u32 width, height;
|
|
|
|
u32 pitch;
|
|
|
|
int i;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if(unlikely(pbitmap->handle == 0))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
bitmap = (bitmap_t*)hmm_get_data(&bm_mm, pbitmap->handle);
|
|
|
|
|
|
|
|
if(unlikely(bitmap==NULL))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if( pbitmap->new_width > bitmap->max_width ||
|
|
|
|
pbitmap->new_height > bitmap->max_height)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
width = pbitmap->new_width;
|
|
|
|
height = pbitmap->new_height;
|
|
|
|
|
|
|
|
pitch = ALIGN(width*4,64);
|
|
|
|
size = roundup(pitch * height, PAGE_SIZE);
|
|
|
|
page_count = size/PAGE_SIZE;
|
|
|
|
|
|
|
|
DRM_DEBUG("new width %d height %d pitch %d size %d\n",
|
|
|
|
width, height, pitch, size);
|
|
|
|
|
2012-11-17 07:19:51 +01:00
|
|
|
if(page_count > bitmap->page_count)
|
2012-11-15 09:04:26 +01:00
|
|
|
{
|
|
|
|
char *vaddr = bitmap->uaddr + PAGE_SIZE * bitmap->page_count;
|
|
|
|
|
|
|
|
pages = bitmap->obj->allocated_pages;
|
|
|
|
|
|
|
|
DRM_DEBUG("old pages %d new_pages %d vaddr %x\n",
|
|
|
|
bitmap->page_count, page_count, vaddr);
|
|
|
|
|
|
|
|
for(i = bitmap->page_count; i < page_count; i++, vaddr+= PAGE_SIZE)
|
|
|
|
{
|
|
|
|
page = AllocPage();
|
|
|
|
if ( page == 0 )
|
|
|
|
goto err4;
|
|
|
|
pages[i] = page;
|
|
|
|
MapPage(vaddr, page, 0x207); //map as shared page
|
|
|
|
};
|
|
|
|
|
|
|
|
DRM_DEBUG("%s alloc %d pages\n", __FUNCTION__,
|
|
|
|
page_count - bitmap->page_count);
|
|
|
|
|
|
|
|
i915_gem_object_unpin(bitmap->obj);
|
|
|
|
i915_gem_object_unbind(bitmap->obj);
|
|
|
|
bitmap->obj->base.size = size;
|
|
|
|
bitmap->obj->pages.nents = page_count;
|
|
|
|
|
|
|
|
ret = i915_gem_object_pin(bitmap->obj, PAGE_SIZE, true,true);
|
|
|
|
if (ret)
|
|
|
|
goto err4;
|
|
|
|
|
|
|
|
bitmap->page_count = page_count;
|
|
|
|
bitmap->gaddr = bitmap->obj->gtt_offset;
|
2012-11-17 07:19:51 +01:00
|
|
|
}
|
|
|
|
else if(page_count < bitmap->page_count)
|
|
|
|
{
|
|
|
|
char *vaddr = bitmap->uaddr + PAGE_SIZE * page_count;
|
|
|
|
|
|
|
|
i915_gem_object_unpin(bitmap->obj);
|
|
|
|
i915_gem_object_unbind(bitmap->obj);
|
|
|
|
|
|
|
|
pages = bitmap->obj->allocated_pages;
|
|
|
|
|
|
|
|
DRM_DEBUG("old pages %d new_pages %d vaddr %x\n",
|
|
|
|
bitmap->page_count, page_count, vaddr);
|
|
|
|
|
|
|
|
for(i = page_count; i < bitmap->page_count; i++, vaddr+= PAGE_SIZE)
|
|
|
|
{
|
|
|
|
MapPage(vaddr, 0, 0); //unmap
|
|
|
|
|
|
|
|
FreePage(pages[i]);
|
|
|
|
pages[i] = 0;
|
2013-02-13 09:23:54 +01:00
|
|
|
};
|
2012-11-15 09:04:26 +01:00
|
|
|
|
2012-11-17 07:19:51 +01:00
|
|
|
DRM_DEBUG("%s release %d pages\n", __FUNCTION__,
|
|
|
|
bitmap->page_count - page_count);
|
2012-11-15 09:04:26 +01:00
|
|
|
|
2012-11-17 07:19:51 +01:00
|
|
|
bitmap->obj->base.size = size;
|
|
|
|
bitmap->obj->pages.nents = page_count;
|
|
|
|
|
|
|
|
ret = i915_gem_object_pin(bitmap->obj, PAGE_SIZE, true,true);
|
|
|
|
if (ret)
|
|
|
|
goto err3;
|
|
|
|
|
|
|
|
bitmap->page_count = page_count;
|
|
|
|
bitmap->gaddr = bitmap->obj->gtt_offset;
|
2012-11-15 09:04:26 +01:00
|
|
|
};
|
|
|
|
|
2012-11-17 07:19:51 +01:00
|
|
|
bitmap->width = width;
|
|
|
|
bitmap->height = height;
|
|
|
|
bitmap->pitch = pitch;
|
|
|
|
|
|
|
|
|
2012-11-15 09:04:26 +01:00
|
|
|
pbitmap->data = bitmap->uaddr;
|
|
|
|
pbitmap->pitch = bitmap->pitch;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err4:
|
|
|
|
while (i-- > bitmap->page_count)
|
|
|
|
FreePage(pages[i]);
|
|
|
|
|
2012-11-17 07:19:51 +01:00
|
|
|
err3:
|
2012-11-15 09:04:26 +01:00
|
|
|
return -1;
|
|
|
|
};
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
int init_bitmaps()
|
|
|
|
{
|
|
|
|
int ret;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
ret = init_hmm(&bm_mm, 1024);
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
return ret;
|
2012-01-30 08:06:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
int get_driver_caps(hwcaps_t *caps)
|
2012-01-30 08:06:25 +01:00
|
|
|
{
|
2012-11-13 10:18:58 +01:00
|
|
|
int ret = 0;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
switch(caps->idx)
|
2012-01-30 08:06:25 +01:00
|
|
|
{
|
2012-11-13 10:18:58 +01:00
|
|
|
case 0:
|
|
|
|
caps->opt[0] = DRIVER_CAPS_0;
|
|
|
|
caps->opt[1] = DRIVER_CAPS_1;
|
|
|
|
break;
|
2012-01-30 08:06:25 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
case 1:
|
|
|
|
caps->cap1.max_tex_width = 4096;
|
|
|
|
caps->cap1.max_tex_height = 4096;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = 1;
|
|
|
|
};
|
|
|
|
caps->idx = 1;
|
2012-01-30 08:06:25 +01:00
|
|
|
return ret;
|
2012-11-13 10:18:58 +01:00
|
|
|
}
|
2012-01-30 08:06:25 +01:00
|
|
|
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
void __attribute__((regparm(1))) destroy_context(struct context *context)
|
2012-02-16 11:48:38 +01:00
|
|
|
{
|
2012-11-14 07:08:43 +01:00
|
|
|
DRM_DEBUG("destroy context %x\n", context);
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
context_map[context->slot] = NULL;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-17 07:19:51 +01:00
|
|
|
FreeKernelSpace(context->cmd_buffer);
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
mutex_lock(&main_device->struct_mutex);
|
|
|
|
drm_gem_object_unreference(&context->obj->base);
|
|
|
|
mutex_unlock(&main_device->struct_mutex);
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
__DestroyObject(context);
|
2012-02-16 11:48:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
#define CURRENT_TASK (0x80003000)
|
|
|
|
|
|
|
|
struct context *get_context(struct drm_device *dev)
|
2012-02-16 11:48:38 +01:00
|
|
|
{
|
2012-11-13 10:18:58 +01:00
|
|
|
struct context *context;
|
|
|
|
struct io_call_10 io_10;
|
|
|
|
int slot = *((u8*)CURRENT_TASK);
|
2012-02-16 11:48:38 +01:00
|
|
|
int ret;
|
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
context = context_map[slot];
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
if( context != NULL)
|
|
|
|
return context;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
context = CreateObject(GetPid(), sizeof(*context));
|
2012-11-14 07:08:43 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
if( context != NULL)
|
|
|
|
{
|
|
|
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
|
|
|
struct drm_i915_gem_object *obj;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
obj = i915_gem_alloc_object(dev, 4096);
|
|
|
|
i915_gem_object_pin(obj, 4096, true, true);
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
context->obj = obj;
|
|
|
|
context->cmd_buffer = MapIoMem((addr_t)obj->pages.page[0], 4096, PG_SW|PG_NOCACHE);
|
|
|
|
context->cmd_offset = obj->gtt_offset;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
context->header.destroy = destroy_context;
|
|
|
|
context->mask = NULL;
|
|
|
|
context->seqno = 0;
|
|
|
|
context->slot = slot;
|
2012-02-16 11:48:38 +01:00
|
|
|
|
2012-11-13 10:18:58 +01:00
|
|
|
context_map[slot] = context;
|
2012-02-16 11:48:38 +01:00
|
|
|
};
|
2012-11-13 10:18:58 +01:00
|
|
|
return context;
|
|
|
|
};
|
2012-02-16 11:48:38 +01:00
|
|
|
|