i915 hw blitter: Back in the game
git-svn-id: svn://kolibrios.org@3033 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b4394bfc2f
commit
88dd19b554
@ -1,26 +1,29 @@
|
||||
|
||||
#include <drmP.h>
|
||||
#include <drm.h>
|
||||
#include "i915_drm.h"
|
||||
#include <drm/drmP.h>
|
||||
#include <drm/i915_drm.h>
|
||||
#include "i915_drv.h"
|
||||
#include "intel_drv.h"
|
||||
#include "hmm.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
#define memmove __builtin_memmove
|
||||
|
||||
int gem_object_lock(struct drm_i915_gem_object *obj);
|
||||
|
||||
#define DRIVER_CAPS_0 HW_BIT_BLIT | HW_TEX_BLIT;
|
||||
#define DRIVER_CAPS_0 HW_BIT_BLIT;
|
||||
#define DRIVER_CAPS_1 0
|
||||
|
||||
struct context *context_map[256];
|
||||
|
||||
struct hmm bm_mm;
|
||||
|
||||
extern struct drm_device *main_device;
|
||||
|
||||
struct hman bm_man;
|
||||
|
||||
|
||||
void __attribute__((regparm(1))) destroy_bitmap(bitmap_t *bitmap)
|
||||
{
|
||||
dma_addr_t *pages = bitmap->obj->allocated_pages;;
|
||||
int i;
|
||||
|
||||
printf("destroy bitmap %d\n", bitmap->handle);
|
||||
free_handle(&bm_man, bitmap->handle);
|
||||
free_handle(&bm_mm, bitmap->handle);
|
||||
bitmap->handle = 0;
|
||||
bitmap->obj->base.read_domains = I915_GEM_DOMAIN_GTT;
|
||||
bitmap->obj->base.write_domain = I915_GEM_DOMAIN_CPU;
|
||||
@ -29,20 +32,86 @@ void __attribute__((regparm(1))) destroy_bitmap(bitmap_t *bitmap)
|
||||
drm_gem_object_unreference(&bitmap->obj->base);
|
||||
mutex_unlock(&main_device->struct_mutex);
|
||||
|
||||
if(pages != NULL)
|
||||
{
|
||||
for (i = 0; i < bitmap->page_count; i++)
|
||||
FreePage(pages[i]);
|
||||
|
||||
free(pages);
|
||||
};
|
||||
UserFree(bitmap->uaddr);
|
||||
__DestroyObject(bitmap);
|
||||
};
|
||||
|
||||
int init_bitmaps()
|
||||
|
||||
static int bitmap_get_pages_gtt(struct drm_i915_gem_object *obj)
|
||||
{
|
||||
int ret;
|
||||
int page_count;
|
||||
|
||||
ret = init_hman(&bm_man, 1024);
|
||||
/* Get the list of pages out of our struct file. They'll be pinned
|
||||
* at this point until we release them.
|
||||
*/
|
||||
page_count = obj->base.size / PAGE_SIZE;
|
||||
BUG_ON(obj->allocated_pages == NULL);
|
||||
BUG_ON(obj->pages.page != NULL);
|
||||
|
||||
return ret;
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
int create_surface(struct io_call_10 *pbitmap)
|
||||
|
||||
#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)
|
||||
{
|
||||
struct drm_i915_gem_object *obj;
|
||||
|
||||
@ -53,6 +122,10 @@ int create_surface(struct io_call_10 *pbitmap)
|
||||
u32 size, max_size;
|
||||
u32 pitch, max_pitch;
|
||||
void *uaddr;
|
||||
dma_addr_t *pages;
|
||||
u32 page_count;
|
||||
|
||||
int i;
|
||||
|
||||
int ret;
|
||||
|
||||
@ -62,10 +135,10 @@ int create_surface(struct io_call_10 *pbitmap)
|
||||
width = pbitmap->width;
|
||||
height = pbitmap->height;
|
||||
|
||||
/*
|
||||
if((width==0)||(height==0)||(width>4096)||(height>4096))
|
||||
if((width == 0)||(height == 0)||(width > 4096)||(height > 4096))
|
||||
goto err1;
|
||||
|
||||
/*
|
||||
if( ((pbitmap->max_width !=0 ) &&
|
||||
(pbitmap->max_width < width)) ||
|
||||
(pbitmap->max_width > 4096) )
|
||||
@ -83,7 +156,7 @@ int create_surface(struct io_call_10 *pbitmap)
|
||||
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);
|
||||
handle = alloc_handle(&bm_mm);
|
||||
// printf("%s %d\n",__FUNCTION__, handle);
|
||||
|
||||
if(handle == 0)
|
||||
@ -92,54 +165,63 @@ int create_surface(struct io_call_10 *pbitmap)
|
||||
bitmap = CreateObject(GetPid(), sizeof(*bitmap));
|
||||
// printf("bitmap %x\n", bitmap);
|
||||
if( bitmap == NULL)
|
||||
goto err1;
|
||||
goto err2;
|
||||
|
||||
bitmap->handle = handle;
|
||||
bitmap->header.destroy = destroy_bitmap;
|
||||
bitmap->obj = NULL;
|
||||
|
||||
|
||||
hman_set_data(&bm_man, handle, bitmap);
|
||||
hmm_set_data(&bm_mm, handle, bitmap);
|
||||
|
||||
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);
|
||||
if (obj == NULL)
|
||||
goto err2;
|
||||
|
||||
ret = i915_gem_object_pin(obj, 4096, true);
|
||||
if (ret)
|
||||
goto err3;
|
||||
|
||||
max_pitch = ALIGN(max_width*4,64);
|
||||
max_size = roundup(max_pitch*max_height, PAGE_SIZE);
|
||||
|
||||
// printf("max_pitch %d max_size %d\n", max_pitch, max_size);
|
||||
|
||||
uaddr = UserAlloc(max_size);
|
||||
if( uaddr == NULL)
|
||||
goto err4;
|
||||
goto err3;
|
||||
else
|
||||
{
|
||||
u32_t *src, *dst;
|
||||
u32 count, max_count;
|
||||
u32 max_count;
|
||||
dma_addr_t page;
|
||||
char *vaddr = uaddr;
|
||||
|
||||
#define page_tabs 0xFDC00000 /* really dirty hack */
|
||||
page_count = size/PAGE_SIZE;
|
||||
max_count = max_size/PAGE_SIZE;
|
||||
|
||||
src = (u32_t*)obj->pages;
|
||||
dst = &((u32_t*)page_tabs)[(u32_t)uaddr >> 12];
|
||||
count = size/4096;
|
||||
max_count = max_size/4096 - count;
|
||||
pages = kzalloc(max_count*sizeof(dma_addr_t), 0);
|
||||
if( pages == NULL)
|
||||
goto err4;
|
||||
|
||||
while(count--)
|
||||
for(i = 0; i < page_count; i++, vaddr+= PAGE_SIZE)
|
||||
{
|
||||
*dst++ = (0xFFFFF000 & *src++) | 0x207 ; // map as shared page
|
||||
page = AllocPage();
|
||||
if ( page == 0 )
|
||||
goto err4;
|
||||
pages[i] = page;
|
||||
|
||||
MapPage(vaddr, page, 0x207); //map as shared page
|
||||
};
|
||||
while(max_count--)
|
||||
*dst++ = 0; // cleanup unused space
|
||||
}
|
||||
bitmap->page_count = page_count;
|
||||
bitmap->max_count = max_count;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
obj->mapped = uaddr ;
|
||||
|
||||
@ -166,16 +248,23 @@ int create_surface(struct io_call_10 *pbitmap)
|
||||
|
||||
return 0;
|
||||
|
||||
err4:
|
||||
i915_gem_object_unpin(obj);
|
||||
err3:
|
||||
err5:
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
drm_gem_object_unreference(&obj->base);
|
||||
err2:
|
||||
free_handle(&bm_man, handle);
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
|
||||
err4:
|
||||
while (i--)
|
||||
FreePage(pages[i]);
|
||||
free(pages);
|
||||
UserFree(uaddr);
|
||||
|
||||
err3:
|
||||
__DestroyObject(bitmap);
|
||||
err2:
|
||||
free_handle(&bm_mm, handle);
|
||||
err1:
|
||||
return -1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -183,20 +272,19 @@ int lock_surface(struct io_call_12 *pbitmap)
|
||||
{
|
||||
int ret;
|
||||
|
||||
drm_i915_private_t *dev_priv = main_device->dev_private;
|
||||
|
||||
bitmap_t *bitmap;
|
||||
|
||||
if(unlikely(pbitmap->handle == 0))
|
||||
return -1;
|
||||
|
||||
bitmap = (bitmap_t*)hman_get_data(&bm_man, pbitmap->handle);
|
||||
bitmap = (bitmap_t*)hmm_get_data(&bm_mm, pbitmap->handle);
|
||||
|
||||
if(unlikely(bitmap==NULL))
|
||||
return -1;
|
||||
|
||||
ret = gem_object_lock(bitmap->obj);
|
||||
if(ret !=0 )
|
||||
ret = i915_gem_object_set_to_cpu_domain(bitmap->obj, true);
|
||||
|
||||
if(ret != 0 )
|
||||
{
|
||||
pbitmap->data = NULL;
|
||||
pbitmap->pitch = 0;
|
||||
@ -212,120 +300,22 @@ int lock_surface(struct io_call_12 *pbitmap)
|
||||
};
|
||||
|
||||
|
||||
int init_hman(struct hman *man, u32 count)
|
||||
|
||||
|
||||
int init_bitmaps()
|
||||
{
|
||||
u32* data;
|
||||
int ret;
|
||||
|
||||
data = malloc(count*sizeof(u32*));
|
||||
if(data)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i < count-1;)
|
||||
data[i] = ++i;
|
||||
data[i] = 0;
|
||||
|
||||
man->table = data;
|
||||
man->next = 0;
|
||||
man->avail = count;
|
||||
man->count = count;
|
||||
|
||||
return 0;
|
||||
};
|
||||
return -ENOMEM;
|
||||
};
|
||||
|
||||
u32 alloc_handle(struct hman *man)
|
||||
{
|
||||
u32 handle = 0;
|
||||
|
||||
if(man->avail)
|
||||
{
|
||||
handle = man->next;
|
||||
man->next = man->table[handle];
|
||||
man->avail--;
|
||||
handle++;
|
||||
}
|
||||
return handle;
|
||||
};
|
||||
|
||||
int free_handle(struct hman *man, u32 handle)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
handle--;
|
||||
|
||||
if(handle < man->count)
|
||||
{
|
||||
man->table[handle] = man->next;
|
||||
man->next = handle;
|
||||
man->avail++;
|
||||
ret = 0;
|
||||
};
|
||||
ret = init_hmm(&bm_mm, 1024);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
void *drm_intel_bo_map(struct drm_i915_gem_object *obj, int write_enable)
|
||||
{
|
||||
u8 *kaddr;
|
||||
|
||||
kaddr = AllocKernelSpace(obj->base.size);
|
||||
if( kaddr != NULL)
|
||||
{
|
||||
u32_t *src = (u32_t*)obj->pages;
|
||||
u32_t *dst = &((u32_t*)page_tabs)[(u32_t)kaddr >> 12];
|
||||
|
||||
u32 count = obj->base.size/4096;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
*dst++ = (0xFFFFF000 & *src++) | 0x003 ;
|
||||
};
|
||||
return kaddr;
|
||||
};
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void destroy_gem_object(uint32_t handle)
|
||||
{
|
||||
struct drm_i915_gem_object *obj = (void*)handle;
|
||||
drm_gem_object_unreference(&obj->base);
|
||||
|
||||
};
|
||||
|
||||
|
||||
void write_gem_object(uint32_t handle, u32 offset, u32 size, u8* src)
|
||||
{
|
||||
struct drm_i915_gem_object *obj = (void*)handle;
|
||||
u8 *dst;
|
||||
int ret;
|
||||
|
||||
ret = i915_gem_object_pin(obj, 4096, true);
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
dst = drm_intel_bo_map(obj, true);
|
||||
if( dst != NULL )
|
||||
{
|
||||
memmove(dst+offset, src, size);
|
||||
FreeKernelSpace(dst);
|
||||
};
|
||||
};
|
||||
|
||||
u32 get_buffer_offset(uint32_t handle)
|
||||
{
|
||||
struct drm_i915_gem_object *obj = (void*)handle;
|
||||
|
||||
return obj->gtt_offset;
|
||||
};
|
||||
|
||||
|
||||
int get_driver_caps(hwcaps_t *caps)
|
||||
{
|
||||
int ret = 0;
|
||||
ENTER();
|
||||
|
||||
switch(caps->idx)
|
||||
{
|
||||
@ -345,3 +335,56 @@ int get_driver_caps(hwcaps_t *caps)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void __attribute__((regparm(1))) destroy_context(struct context *context)
|
||||
{
|
||||
printf("destroy context %x\n", context);
|
||||
|
||||
context_map[context->slot] = NULL;
|
||||
|
||||
mutex_lock(&main_device->struct_mutex);
|
||||
drm_gem_object_unreference(&context->obj->base);
|
||||
mutex_unlock(&main_device->struct_mutex);
|
||||
|
||||
__DestroyObject(context);
|
||||
};
|
||||
|
||||
|
||||
#define CURRENT_TASK (0x80003000)
|
||||
|
||||
struct context *get_context(struct drm_device *dev)
|
||||
{
|
||||
struct context *context;
|
||||
struct io_call_10 io_10;
|
||||
int slot = *((u8*)CURRENT_TASK);
|
||||
int ret;
|
||||
|
||||
context = context_map[slot];
|
||||
|
||||
if( context != NULL)
|
||||
return context;
|
||||
|
||||
context = CreateObject(GetPid(), sizeof(*context));
|
||||
printf("context %x\n", context);
|
||||
if( context != NULL)
|
||||
{
|
||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||
struct drm_i915_gem_object *obj;
|
||||
|
||||
obj = i915_gem_alloc_object(dev, 4096);
|
||||
i915_gem_object_pin(obj, 4096, true, true);
|
||||
|
||||
context->obj = obj;
|
||||
context->cmd_buffer = MapIoMem((addr_t)obj->pages.page[0], 4096, PG_SW|PG_NOCACHE);
|
||||
context->cmd_offset = obj->gtt_offset;
|
||||
|
||||
context->header.destroy = destroy_context;
|
||||
context->mask = NULL;
|
||||
context->seqno = 0;
|
||||
context->slot = slot;
|
||||
|
||||
context_map[slot] = context;
|
||||
};
|
||||
return context;
|
||||
};
|
||||
|
||||
|
@ -2,26 +2,6 @@
|
||||
typedef struct tag_object kobj_t;
|
||||
typedef struct tag_display display_t;
|
||||
|
||||
struct hman
|
||||
{
|
||||
u32 *table;
|
||||
u32 next;
|
||||
u32 avail;
|
||||
u32 count;
|
||||
};
|
||||
|
||||
extern struct hman bm_man;
|
||||
|
||||
int init_hman(struct hman *man, u32 count);
|
||||
u32 alloc_handle(struct hman *man);
|
||||
int free_handle(struct hman *man, u32 handle);
|
||||
|
||||
#define hman_get_data(man, handle) \
|
||||
((man)->table[(handle)-1])
|
||||
|
||||
#define hman_set_data(man, handle, val) \
|
||||
((man)->table[(handle)-1]) = (u32)(val)
|
||||
|
||||
|
||||
struct tag_object
|
||||
{
|
||||
@ -46,6 +26,8 @@ typedef struct
|
||||
u32 height;
|
||||
u32 max_width;
|
||||
u32 max_height;
|
||||
u32 page_count;
|
||||
u32 max_count;
|
||||
|
||||
u32 format;
|
||||
struct drm_i915_gem_object *obj;
|
||||
@ -94,19 +76,25 @@ typedef struct
|
||||
#define HW_TEX_BLIT (1<<1) /* stretch blit */
|
||||
#define HW_VID_BLIT (1<<2) /* planar and packed video */
|
||||
/* 3 - 63 reserved */
|
||||
|
||||
struct context
|
||||
{
|
||||
kobj_t header;
|
||||
|
||||
struct drm_i915_gem_object *obj;
|
||||
u32 cmd_buffer;
|
||||
u32 cmd_offset;
|
||||
|
||||
bitmap_t *mask;
|
||||
u32 seqno;
|
||||
int slot;
|
||||
|
||||
};
|
||||
|
||||
int get_driver_caps(hwcaps_t *caps);
|
||||
int create_surface(struct io_call_10 *pbitmap);
|
||||
int create_surface(struct drm_device *dev, struct io_call_10 *pbitmap);
|
||||
int lock_surface(struct io_call_12 *pbitmap);
|
||||
|
||||
struct context *get_context(struct drm_device *dev);
|
||||
|
||||
int init_bitmaps();
|
||||
|
||||
|
71
drivers/video/drm/i915/hmm.c
Normal file
71
drivers/video/drm/i915/hmm.c
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <syscall.h>
|
||||
#include "hmm.h"
|
||||
|
||||
int init_hmm(struct hmm *mm, u32 count)
|
||||
{
|
||||
u32* data;
|
||||
|
||||
if( mm == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
data = malloc(count*sizeof(u32*));
|
||||
if( data )
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < count-1; )
|
||||
data[i] = ++i;
|
||||
data[i] = 0;
|
||||
|
||||
mm->table = data;
|
||||
mm->next = 0;
|
||||
mm->avail = count;
|
||||
mm->count = count;
|
||||
|
||||
return 0;
|
||||
};
|
||||
return -ENOMEM;
|
||||
};
|
||||
|
||||
u32 alloc_handle(struct hmm *mm)
|
||||
{
|
||||
u32 handle = 0;
|
||||
u32 ifl;
|
||||
|
||||
ifl = safe_cli();
|
||||
if(mm->avail)
|
||||
{
|
||||
handle = mm->next;
|
||||
mm->next = mm->table[handle];
|
||||
mm->avail--;
|
||||
handle++;
|
||||
}
|
||||
safe_sti(ifl);
|
||||
|
||||
return handle;
|
||||
};
|
||||
|
||||
int free_handle(struct hmm *mm, u32 handle)
|
||||
{
|
||||
int ret = -1;
|
||||
u32 ifl;
|
||||
|
||||
handle--;
|
||||
|
||||
ifl = safe_cli();
|
||||
if(handle < mm->count)
|
||||
{
|
||||
mm->table[handle] = mm->next;
|
||||
mm->next = handle;
|
||||
mm->avail++;
|
||||
ret = 0;
|
||||
};
|
||||
safe_sti(ifl);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
24
drivers/video/drm/i915/hmm.h
Normal file
24
drivers/video/drm/i915/hmm.h
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef __HMM_H__
|
||||
#define __HMM_H__
|
||||
|
||||
struct hmm
|
||||
{
|
||||
u32 *table;
|
||||
u32 next;
|
||||
u32 avail;
|
||||
u32 count;
|
||||
};
|
||||
|
||||
int init_hmm(struct hmm *mm, u32 count);
|
||||
u32 alloc_handle(struct hmm *mm);
|
||||
int free_handle(struct hmm *mm, u32 handle);
|
||||
|
||||
#define hmm_get_data(mm, handle) \
|
||||
((mm)->table[(handle)-1])
|
||||
|
||||
#define hmm_set_data(mm, handle, val) \
|
||||
((mm)->table[(handle)-1]) = (u32)(val)
|
||||
|
||||
|
||||
#endif /* __HMM_H__ */
|
@ -1012,6 +1012,7 @@ struct drm_i915_gem_object {
|
||||
unsigned int has_global_gtt_mapping:1;
|
||||
unsigned int has_dma_mapping:1;
|
||||
|
||||
dma_addr_t *allocated_pages;
|
||||
struct pagelist pages;
|
||||
int pages_pin_count;
|
||||
|
||||
|
@ -309,14 +309,6 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
|
||||
|
||||
int i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj)
|
||||
{
|
||||
if (obj->has_dma_mapping)
|
||||
return 0;
|
||||
|
||||
// if (!dma_map_sg(&obj->base.dev->pdev->dev,
|
||||
// obj->pages->sgl, obj->pages->nents,
|
||||
// PCI_DMA_BIDIRECTIONAL))
|
||||
// return -ENOSPC;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2518,7 +2518,7 @@ static struct drm_device *irq_device;
|
||||
|
||||
void irq_handler_kms()
|
||||
{
|
||||
// printf("%s\n",__FUNCTION__);
|
||||
printf("%s\n",__FUNCTION__);
|
||||
ironlake_irq_handler(irq_device);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <syscall.h>
|
||||
|
||||
#include "hmm.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
extern struct drm_device *main_device;
|
||||
@ -275,6 +276,7 @@ int init_display_kms(struct drm_device *dev)
|
||||
|
||||
cursor_t *cursor;
|
||||
u32_t ifl;
|
||||
int err;
|
||||
|
||||
// ENTER();
|
||||
|
||||
@ -366,39 +368,14 @@ int init_display_kms(struct drm_device *dev)
|
||||
};
|
||||
safe_sti(ifl);
|
||||
|
||||
#define XY_COLOR_BLT ((2<<29)|(0x50<<22)|(0x4))
|
||||
#define BLT_WRITE_ALPHA (1<<21)
|
||||
#define BLT_WRITE_RGB (1<<20)
|
||||
|
||||
#if 0
|
||||
|
||||
#if 1
|
||||
{
|
||||
|
||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||
struct drm_i915_gem_object *obj;
|
||||
struct intel_ring_buffer *ring;
|
||||
|
||||
obj = i915_gem_alloc_object(dev, 4096);
|
||||
i915_gem_object_pin(obj, 4096, true, true);
|
||||
|
||||
cmd_buffer = MapIoMem((addr_t)obj->pages.page[0], 4096, PG_SW|PG_NOCACHE);
|
||||
cmd_offset = obj->gtt_offset;
|
||||
};
|
||||
#endif
|
||||
|
||||
main_device = dev;
|
||||
|
||||
int err;
|
||||
|
||||
err = init_bitmaps();
|
||||
if( !err )
|
||||
{
|
||||
printf("Initialize bitmap manager\n");
|
||||
};
|
||||
|
||||
sna_init();
|
||||
#endif
|
||||
|
||||
// LEAVE();
|
||||
|
||||
@ -657,9 +634,11 @@ cursor_t* __stdcall select_cursor_kms(cursor_t *cursor)
|
||||
return old;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
|
||||
|
||||
|
||||
|
||||
extern struct hmm bm_mm;
|
||||
|
||||
|
||||
typedef struct
|
||||
@ -686,18 +665,57 @@ static u32_t get_display_map()
|
||||
return *(u32_t*)addr;
|
||||
}
|
||||
|
||||
#define XY_COLOR_BLT ((2<<29)|(0x50<<22)|(0x4))
|
||||
#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
|
||||
#define XY_SRC_COPY_CHROMA_CMD ((2<<29)|(0x73<<22)|8)
|
||||
#define ROP_COPY_SRC 0xCC
|
||||
#define FORMAT8888 3
|
||||
|
||||
#define BLT_WRITE_ALPHA (1<<21)
|
||||
#define BLT_WRITE_RGB (1<<20)
|
||||
|
||||
|
||||
|
||||
typedef int v4si __attribute__ ((vector_size (16)));
|
||||
|
||||
|
||||
static void
|
||||
i915_gem_execbuffer_retire_commands(struct drm_device *dev,
|
||||
struct intel_ring_buffer *ring)
|
||||
{
|
||||
struct drm_i915_gem_request *request;
|
||||
u32 invalidate;
|
||||
u32 req;
|
||||
/*
|
||||
* Ensure that the commands in the batch buffer are
|
||||
* finished before the interrupt fires.
|
||||
*
|
||||
* The sampler always gets flushed on i965 (sigh).
|
||||
*/
|
||||
invalidate = I915_GEM_DOMAIN_COMMAND;
|
||||
if (INTEL_INFO(dev)->gen >= 4)
|
||||
invalidate |= I915_GEM_DOMAIN_SAMPLER;
|
||||
if (ring->flush(ring, invalidate, 0)) {
|
||||
i915_gem_next_request_seqno(ring);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add a breadcrumb for the completion of the batch buffer */
|
||||
if (request == NULL || i915_add_request(ring, NULL, &req)) {
|
||||
i915_gem_next_request_seqno(ring);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int blit_video(u32 hbitmap, int dst_x, int dst_y,
|
||||
int src_x, int src_y, u32 w, u32 h)
|
||||
{
|
||||
drm_i915_private_t *dev_priv = main_device->dev_private;
|
||||
struct intel_ring_buffer *ring;
|
||||
struct context *context;
|
||||
|
||||
bitmap_t *bitmap;
|
||||
rect_t winrc;
|
||||
@ -714,11 +732,14 @@ int blit_video(u32 hbitmap, int dst_x, int dst_y,
|
||||
if(unlikely(hbitmap==0))
|
||||
return -1;
|
||||
|
||||
bitmap = (bitmap_t*)hman_get_data(&bm_man, hbitmap);
|
||||
bitmap = (bitmap_t*)hmm_get_data(&bm_mm, hbitmap);
|
||||
|
||||
if(unlikely(bitmap==NULL))
|
||||
return -1;
|
||||
|
||||
context = get_context(main_device);
|
||||
if(unlikely(context == NULL))
|
||||
return -1;
|
||||
|
||||
GetWindowRect(&winrc);
|
||||
|
||||
@ -860,12 +881,12 @@ int blit_video(u32 hbitmap, int dst_x, int dst_y,
|
||||
}
|
||||
#endif
|
||||
|
||||
if((cmd_buffer & 0xFC0)==0xFC0)
|
||||
cmd_buffer&= 0xFFFFF000;
|
||||
if((context->cmd_buffer & 0xFC0)==0xFC0)
|
||||
context->cmd_buffer&= 0xFFFFF000;
|
||||
|
||||
b = (u32_t*)ALIGN(cmd_buffer,16);
|
||||
b = (u32_t*)ALIGN(context->cmd_buffer,16);
|
||||
|
||||
offset = cmd_offset + ((u32_t)b & 0xFFF);
|
||||
offset = context->cmd_offset + ((u32_t)b & 0xFFF);
|
||||
|
||||
cmd = XY_SRC_COPY_CHROMA_CMD | BLT_WRITE_RGB | BLT_WRITE_ALPHA;
|
||||
cmd |= 3 << 17;
|
||||
@ -890,29 +911,26 @@ int blit_video(u32 hbitmap, int dst_x, int dst_y,
|
||||
if( n & 1)
|
||||
b[n++] = MI_NOOP;
|
||||
|
||||
i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
|
||||
context->cmd_buffer+= n*4;
|
||||
|
||||
// i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
|
||||
|
||||
if (HAS_BLT(main_device))
|
||||
{
|
||||
int ret;
|
||||
|
||||
ring = &dev_priv->ring[BCS];
|
||||
ring->dispatch_execbuffer(ring, cmd_offset, n*4);
|
||||
// printf("dispatch... ");
|
||||
ring->dispatch_execbuffer(ring, offset, n*4);
|
||||
// printf("done\n");
|
||||
|
||||
ret = intel_ring_begin(ring, 4);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
intel_ring_emit(ring, MI_FLUSH_DW);
|
||||
intel_ring_emit(ring, 0);
|
||||
intel_ring_emit(ring, 0);
|
||||
intel_ring_emit(ring, MI_NOOP);
|
||||
intel_ring_advance(ring);
|
||||
i915_gem_execbuffer_retire_commands(main_device, ring);
|
||||
// printf("retire\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ring = &dev_priv->ring[RCS];
|
||||
ring->dispatch_execbuffer(ring, cmd_offset, n*4);
|
||||
ring->dispatch_execbuffer(ring, offset, n*4);
|
||||
ring->flush(ring, 0, I915_GEM_DOMAIN_RENDER);
|
||||
};
|
||||
|
||||
@ -925,6 +943,9 @@ fail:
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
i915_gem_execbuffer_retire_commands(dev, ring);
|
||||
/* For display hotplug interrupt */
|
||||
static void
|
||||
ironlake_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
|
||||
@ -1082,8 +1103,6 @@ int sna_blit_tex(bitmap_t *dst_bitmap, int dst_x, int dst_y,
|
||||
int w, int h, bitmap_t *src_bitmap, int src_x, int src_y,
|
||||
bitmap_t *mask_bitmap);
|
||||
|
||||
int create_context();
|
||||
struct context *get_context();
|
||||
|
||||
int blit_tex(u32 hbitmap, int dst_x, int dst_y,
|
||||
int src_x, int src_y, u32 w, u32 h)
|
||||
@ -1257,75 +1276,6 @@ int blit_tex(u32 hbitmap, int dst_x, int dst_y,
|
||||
};
|
||||
|
||||
|
||||
struct context *context_map[256];
|
||||
|
||||
void __attribute__((regparm(1))) destroy_context(struct context *context)
|
||||
{
|
||||
printf("destroy context %x\n", context);
|
||||
|
||||
context_map[context->slot] = NULL;
|
||||
__DestroyObject(context);
|
||||
};
|
||||
|
||||
|
||||
int create_context()
|
||||
{
|
||||
struct context *context;
|
||||
|
||||
bitmap_t *mask;
|
||||
int slot;
|
||||
|
||||
struct io_call_10 io_10;
|
||||
int ret;
|
||||
|
||||
slot = *((u8*)CURRENT_TASK);
|
||||
|
||||
if(context_map[slot] != NULL)
|
||||
return 0;
|
||||
|
||||
context = CreateObject(GetPid(), sizeof(*context));
|
||||
// printf("context %x\n", coontext);
|
||||
if( context == NULL)
|
||||
goto err1;
|
||||
context->header.destroy = destroy_context;
|
||||
|
||||
dbgprintf("Create mask surface\n");
|
||||
|
||||
io_10.width = os_display->width/4; /* need bitmap format here */
|
||||
io_10.height = os_display->height+1;
|
||||
io_10.max_width = os_display->width/4;
|
||||
io_10.max_height = os_display->height+1;
|
||||
|
||||
ret = create_surface(&io_10);
|
||||
if(ret)
|
||||
goto err2;
|
||||
|
||||
mask= (bitmap_t*)hman_get_data(&bm_man, io_10.handle);
|
||||
if(unlikely(mask == NULL)) /* something really terrible happend */
|
||||
goto err2;
|
||||
dbgprintf("done\n");
|
||||
|
||||
context->mask = mask;
|
||||
context->seqno = os_display->mask_seqno-1;
|
||||
context->slot = slot;
|
||||
|
||||
context_map[slot] = context;
|
||||
return 0;
|
||||
|
||||
err2:
|
||||
__DestroyObject(context);
|
||||
err1:
|
||||
return -1;
|
||||
};
|
||||
|
||||
struct context *get_context()
|
||||
{
|
||||
|
||||
int slot = *((u8*)CURRENT_TASK);
|
||||
|
||||
return context_map[slot];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#include "bitmap.h"
|
||||
|
||||
extern struct drm_device *main_device;
|
||||
|
||||
void cpu_detect();
|
||||
|
||||
void parse_cmdline(char *cmdline, char *log);
|
||||
@ -142,14 +144,14 @@ int _stdcall display_handler(ioctl_t *io)
|
||||
if( i915_modeset )
|
||||
retval = set_user_mode((videomode_t*)inp);
|
||||
break;
|
||||
#if 0
|
||||
|
||||
case SRV_GET_CAPS:
|
||||
retval = get_driver_caps((hwcaps_t*)inp);
|
||||
break;
|
||||
|
||||
case SRV_CREATE_SURFACE:
|
||||
// check_input(8);
|
||||
retval = create_surface((struct io_call_10*)inp);
|
||||
retval = create_surface(main_device, (struct io_call_10*)inp);
|
||||
break;
|
||||
|
||||
case SRV_LOCK_SURFACE:
|
||||
@ -157,16 +159,15 @@ int _stdcall display_handler(ioctl_t *io)
|
||||
break;
|
||||
|
||||
case SRV_BLIT_VIDEO:
|
||||
// blit_video( inp[0], inp[1], inp[2],
|
||||
// inp[3], inp[4], inp[5], inp[6]);
|
||||
blit_video( inp[0], inp[1], inp[2],
|
||||
inp[3], inp[4], inp[5], inp[6]);
|
||||
|
||||
blit_tex( inp[0], inp[1], inp[2],
|
||||
inp[3], inp[4], inp[5], inp[6]);
|
||||
// blit_tex( inp[0], inp[1], inp[2],
|
||||
// inp[3], inp[4], inp[5], inp[6]);
|
||||
|
||||
|
||||
retval = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user