8,11 → 8,11 |
|
void __attribute__((regparm(1))) destroy_bitmap(bitmap_t *bitmap) |
{ |
/* |
* |
* |
* |
*/ |
printf("destroy bitmap %d\n", bitmap->handle); |
free_handle(&bm_man, bitmap->handle); |
bitmap->handle = 0; |
i915_gem_object_unpin(bitmap->obj); |
drm_gem_object_unreference(&bitmap->obj->base); |
__DestroyObject(bitmap); |
}; |
|
30,29 → 30,47 |
}; |
|
|
int create_bitmap(struct ubitmap *pbitmap) |
int create_surface(struct io_call_10 *pbitmap) |
{ |
struct drm_i915_gem_object *obj; |
|
bitmap_t *bitmap; |
u32 handle; |
u32 width; |
u32 height; |
u32 size; |
u32 pitch; |
u32 width, max_width; |
u32 height, max_height; |
u32 size, max_size; |
u32 pitch, max_pitch; |
void *uaddr; |
|
int ret; |
|
pbitmap->handle = 0; |
pbitmap->data = NULL; |
pbitmap->data = (void*)-1; |
|
width = pbitmap->width; |
height = pbitmap->height; |
|
/* |
if((width==0)||(height==0)||(width>4096)||(height>4096)) |
goto err1; |
|
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; |
|
handle = alloc_handle(&bm_man); |
// printf("%s %d\n",__FUNCTION__, handle); |
|
73,6 → 91,7 |
pitch = ALIGN(width*4,64); |
|
size = roundup(pitch*height, PAGE_SIZE); |
|
// printf("pitch %d size %d\n", pitch, size); |
|
obj = i915_gem_alloc_object(main_device, size); |
83,13 → 102,16 |
if (ret) |
goto err3; |
|
uaddr = UserAlloc(size); |
max_pitch = ALIGN(max_width*4,64); |
max_size = roundup(max_pitch*max_height, PAGE_SIZE); |
|
uaddr = UserAlloc(max_size); |
if( uaddr == NULL) |
goto err4; |
else |
{ |
u32_t *src, *dst; |
int count; |
u32 count, max_count; |
|
#define page_tabs 0xFDC00000 /* really dirty hack */ |
|
96,35 → 118,43 |
src = (u32_t*)obj->pages; |
dst = &((u32_t*)page_tabs)[(u32_t)uaddr >> 12]; |
count = size/4096; |
max_count = max_size/4096 - count; |
|
while(count--) |
{ |
*dst++ = (0xFFFFF000 & *src++) | 0x207 ; // map as shared page |
}; |
// while(max_count--) |
// *dst++ = 0; // cleanup unused space |
} |
|
bitmap->handle = handle; |
bitmap->uaddr = uaddr; |
bitmap->pitch = pitch; |
bitmap->gaddr = obj->gtt_offset; |
|
bitmap->width = width; |
bitmap->height = height; |
bitmap->pitch = pitch; |
bitmap->gaddr = obj->gtt_offset; |
bitmap->uaddr = uaddr; |
bitmap->max_width = max_width; |
bitmap->max_height = max_height; |
|
bitmap->obj = obj; |
bitmap->header.destroy = destroy_bitmap; |
|
pbitmap->pitch = pitch; |
pbitmap->handle = handle; |
pbitmap->data = uaddr; |
pbitmap->pitch = pitch; |
|
// printf("%s handle %d pitch %d gpu %x user %x\n", |
// __FUNCTION__, handle, pitch, obj->gtt_offset, uaddr); |
|
printf("%s handle: %d pitch: %d gpu_addr: %x user_addr: %x\n", |
__FUNCTION__, handle, pitch, obj->gtt_offset, uaddr); |
|
return 0; |
|
err4: |
// drm_gem_object_unpin; |
i915_gem_object_unpin(obj); |
err3: |
// drm_gem_object_unreference(&obj->base); |
drm_gem_object_unreference(&obj->base); |
err2: |
free_handle(&bm_man, handle); |
__DestroyObject(bitmap); |
134,6 → 164,8 |
}; |
|
|
|
|
int init_hman(struct hman *man, u32 count) |
{ |
u32* data; |