/contrib/sdk/sources/Intel-2D/pixlib-sna.c |
---|
File deleted |
/contrib/sdk/sources/Intel-2D/pixlib-uxa.c |
---|
File deleted |
/contrib/sdk/sources/Intel-2D/pixlib_sna.c |
---|
0,0 → 1,282 |
// -kr -i4 -ts4 -bls -bl -bli0 |
#include <stdio.h> |
#include <malloc.h> |
#include <stdbool.h> |
#include <pixlib2.h> |
#include <kos32sys.h> |
#define DISPLAY_VERSION 0x0200 /* 2.00 */ |
#define SRV_GETVERSION 0 |
#define SRV_GET_CAPS 3 |
#define BUFFER_SIZE(n) ((n)*sizeof(uint32_t)) |
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
#define to_surface(x) (surface_t*)((x)->handle) |
typedef struct |
{ |
uint32_t width; |
uint32_t height; |
void *data; |
uint32_t pitch; |
uint32_t bo; |
uint32_t bo_size; |
uint32_t flags; |
} surface_t; |
int sna_init(uint32_t service); |
void sna_fini(); |
int sna_create_bitmap(bitmap_t * bitmap); |
int sna_destroy_bitmap(bitmap_t * bitmap); |
int sna_lock_bitmap(bitmap_t * bitmap); |
int sna_resize_bitmap(bitmap_t *bitmap); |
//int sna_blit_copy(bitmap_t * src_bitmap, int dst_x, int dst_y, |
// int w, int h, int src_x, int src_y); |
int sna_blit_tex(bitmap_t * src_bitmap, bool scale, int dst_x, int dst_y, |
int w, int h, int src_x, int src_y); |
static uint32_t service; |
static uint32_t hw_caps; |
uint32_t init_pixlib(uint32_t caps) |
{ |
uint32_t api_version; |
ioctl_t io; |
if (service != 0) |
return caps & hw_caps; |
service = get_service("DISPLAY"); |
if (service == 0) |
goto fail; |
io.handle = service; |
io.io_code = SRV_GETVERSION; |
io.input = NULL; |
io.inp_size = 0; |
io.output = &api_version; |
io.out_size = BUFFER_SIZE(1); |
if (call_service(&io) != 0) |
goto fail; |
if ((DISPLAY_VERSION > (api_version & 0xFFFF)) || |
(DISPLAY_VERSION < (api_version >> 16))) |
goto fail; |
hw_caps = sna_init(service); |
if (hw_caps) |
printf("2D caps %s%s%s\n", |
(hw_caps & HW_BIT_BLIT) != 0 ? "HW_BIT_BLIT " : "", |
(hw_caps & HW_TEX_BLIT) != 0 ? "HW_TEX_BLIT " : "", |
(hw_caps & HW_VID_BLIT) != 0 ? "HW_VID_BLIT " : ""); |
return caps & hw_caps; |
fail: |
service = 0; |
return 0; |
}; |
void done_pixlib() |
{ |
if (hw_caps != 0) |
sna_fini(); |
}; |
int create_bitmap(bitmap_t * bitmap) |
{ |
uint32_t size, bo_size; |
uint32_t pitch, max_pitch; |
void *buffer; |
surface_t *sf; |
bitmap->handle = -1; |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
if (bitmap->flags &= hw_caps) |
return sna_create_bitmap(bitmap); |
pitch = ALIGN(bitmap->width * 4, 16); |
max_pitch = ALIGN(bitmap->max_width * 4, 16); |
size = ALIGN(pitch * bitmap->height, 4096); |
bo_size = ALIGN(max_pitch * bitmap->max_height, 4096); |
if (bo_size < size) |
bo_size = size; |
sf = malloc(sizeof(*sf)); |
if (sf == NULL) |
return -1; |
buffer = user_alloc(bo_size); |
if (buffer == NULL) |
{ |
free(sf); |
return -1; |
}; |
sf->width = bitmap->width; |
sf->height = bitmap->height; |
sf->data = buffer; |
sf->pitch = pitch; |
sf->bo = 0; |
sf->bo_size = bo_size; |
sf->flags = bitmap->flags; |
bitmap->handle = (uint32_t) sf; |
// printf("create bitmap %p handle %p data %p w %d h%d\n", |
// bitmap, bitmap->handle, bitmap->data, bitmap->width, bitmap->height); |
return 0; |
}; |
int destroy_bitmap(bitmap_t * bitmap) |
{ |
surface_t *sf = to_surface(bitmap); |
if (sf->flags & hw_caps) |
return sna_destroy_bitmap(bitmap); |
user_free(sf->data); |
free(sf); |
bitmap->handle = -1; |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
return 0; |
}; |
int lock_bitmap(bitmap_t * bitmap) |
{ |
surface_t *sf = to_surface(bitmap); |
if (bitmap->data != (void *) -1) |
return 0; |
if (sf->flags & hw_caps) |
return sna_lock_bitmap(bitmap); |
bitmap->data = sf->data; |
bitmap->pitch = sf->pitch; |
return 0; |
}; |
int blit_bitmap(bitmap_t * bitmap, int dst_x, int dst_y, |
int w, int h, int src_x, int src_y) |
{ |
struct blit_call bc; |
int ret; |
surface_t *sf = to_surface(bitmap); |
if (sf->flags & hw_caps & HW_BIT_BLIT) |
return sna_blit_tex(bitmap, false, dst_x, dst_y, w, h, src_x, src_y); |
bc.dstx = dst_x; |
bc.dsty = dst_y; |
bc.w = w; |
bc.h = h; |
bc.srcx = 0; |
bc.srcy = 0; |
bc.srcw = w; |
bc.srch = h; |
bc.stride = sf->pitch; |
bc.bitmap = sf->data; |
__asm__ __volatile__( |
"int $0x40":"=a"(ret):"a"(73), "b"(0x00), |
"c"(&bc):"memory"); |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
return ret; |
}; |
int fplay_blit_bitmap(bitmap_t * bitmap, int dst_x, int dst_y, int w, int h) |
{ |
struct blit_call bc; |
int ret; |
surface_t *sf = to_surface(bitmap); |
if (sf->flags & hw_caps & HW_TEX_BLIT) |
return sna_blit_tex(bitmap, true, dst_x, dst_y, w, h, 0, 0); |
bc.dstx = dst_x; |
bc.dsty = dst_y; |
bc.w = w; |
bc.h = h; |
bc.srcx = 0; |
bc.srcy = 0; |
bc.srcw = w; |
bc.srch = h; |
bc.stride = sf->pitch; |
bc.bitmap = sf->data; |
__asm__ __volatile__( |
"int $0x40":"=a"(ret):"a"(73), "b"(0x00), |
"c"(&bc):"memory"); |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
return ret; |
}; |
int resize_bitmap(bitmap_t * bitmap) |
{ |
uint32_t size; |
uint32_t pitch; |
// printf("%s\n", __FUNCTION__); |
surface_t *sf = to_surface(bitmap); |
if (sf->flags & hw_caps) |
{ |
return sna_resize_bitmap(bitmap); |
}; |
pitch = ALIGN(bitmap->width * 4, 16); |
size = ALIGN(pitch * bitmap->height, 4096); |
bitmap->pitch = -1; |
bitmap->data = (void *) -1; |
if (size > sf->bo_size) |
{ |
sf->data = user_realloc(sf->data, size); /* grow buffer */ |
if (sf->data == NULL) |
return -1; |
sf->bo_size = size; |
} else if (size < sf->bo_size) |
user_unmap(sf->data, size, sf->bo_size - size); /* unmap unused pages */ |
sf->width = bitmap->width; |
sf->height = bitmap->height; |
sf->pitch = pitch; |
return 0; |
}; |
/contrib/sdk/sources/Intel-2D/pixlib_uxa.c |
---|
0,0 → 1,289 |
// -kr -i4 -ts4 -bls -bl -bli0 |
#include <stdio.h> |
#include <malloc.h> |
#include <stdbool.h> |
#include <pixlib2.h> |
#include <kos32sys.h> |
#define DISPLAY_VERSION 0x0200 /* 2.00 */ |
#define SRV_GETVERSION 0 |
#define SRV_GET_CAPS 3 |
#define BUFFER_SIZE(n) ((n)*sizeof(uint32_t)) |
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
#define to_surface(x) (surface_t*)((x)->handle) |
typedef struct |
{ |
uint32_t width; |
uint32_t height; |
void *data; |
uint32_t pitch; |
uint32_t bo; |
uint32_t bo_size; |
uint32_t flags; |
} surface_t; |
int uxa_init(uint32_t service); |
void uxa_fini(); |
int sna_create_bitmap(bitmap_t * bitmap); |
int sna_destroy_bitmap(bitmap_t * bitmap); |
int sna_lock_bitmap(bitmap_t * bitmap); |
int sna_resize_bitmap(bitmap_t *bitmap); |
//int sna_blit_copy(bitmap_t * src_bitmap, int dst_x, int dst_y, |
// int w, int h, int src_x, int src_y); |
int sna_blit_tex(bitmap_t * src_bitmap, bool scale, int dst_x, int dst_y, |
int w, int h, int src_x, int src_y); |
static uint32_t service; |
static uint32_t hw_caps; |
uint32_t init_pixlib(uint32_t caps) |
{ |
uint32_t api_version; |
ioctl_t io; |
if (service != 0) |
return caps & hw_caps; |
#ifndef BUILD_EBOX |
service = get_service("DISPLAY"); |
if (service == 0) |
goto fail; |
io.handle = service; |
io.io_code = SRV_GETVERSION; |
io.input = NULL; |
io.inp_size = 0; |
io.output = &api_version; |
io.out_size = BUFFER_SIZE(1); |
if (call_service(&io) != 0) |
goto fail; |
if ((DISPLAY_VERSION > (api_version & 0xFFFF)) || |
(DISPLAY_VERSION < (api_version >> 16))) |
goto fail; |
hw_caps = uxa_init(service); |
if (hw_caps) |
printf("2D caps %s%s%s\n", |
(hw_caps & HW_BIT_BLIT) != 0 ? "HW_BIT_BLIT " : "", |
(hw_caps & HW_TEX_BLIT) != 0 ? "HW_TEX_BLIT " : "", |
(hw_caps & HW_VID_BLIT) != 0 ? "HW_VID_BLIT " : ""); |
return caps & hw_caps; |
#endif |
fail: |
service = 0; |
return 0; |
}; |
void done_pixlib() |
{ |
// if (hw_caps != 0) |
// uxa_fini(); |
}; |
int create_bitmap(bitmap_t * bitmap) |
{ |
uint32_t size, bo_size; |
uint32_t pitch, max_pitch; |
void *buffer; |
surface_t *sf; |
bitmap->handle = -1; |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
// if (bitmap->flags &= hw_caps) |
// return sna_create_bitmap(bitmap); |
pitch = ALIGN(bitmap->width * 4, 16); |
max_pitch = ALIGN(bitmap->max_width * 4, 16); |
size = ALIGN(pitch * bitmap->height, 4096); |
bo_size = ALIGN(max_pitch * bitmap->max_height, 4096); |
if (bo_size < size) |
bo_size = size; |
sf = malloc(sizeof(*sf)); |
if (sf == NULL) |
return -1; |
buffer = user_alloc(bo_size); |
if (buffer == NULL) |
{ |
free(sf); |
return -1; |
}; |
sf->width = bitmap->width; |
sf->height = bitmap->height; |
sf->data = buffer; |
sf->pitch = pitch; |
sf->bo = 0; |
sf->bo_size = bo_size; |
sf->flags = bitmap->flags; |
bitmap->handle = (uint32_t) sf; |
// printf("create bitmap %p handle %p data %p w %d h%d\n", |
// bitmap, bitmap->handle, bitmap->data, bitmap->width, bitmap->height); |
return 0; |
}; |
int destroy_bitmap(bitmap_t * bitmap) |
{ |
surface_t *sf = to_surface(bitmap); |
// if (sf->flags & hw_caps) |
// return sna_destroy_bitmap(bitmap); |
user_free(sf->data); |
free(sf); |
bitmap->handle = -1; |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
return 0; |
}; |
int lock_bitmap(bitmap_t * bitmap) |
{ |
surface_t *sf = to_surface(bitmap); |
if (bitmap->data != (void *) -1) |
return 0; |
// if (sf->flags & hw_caps) |
// return sna_lock_bitmap(bitmap); |
bitmap->data = sf->data; |
bitmap->pitch = sf->pitch; |
return 0; |
}; |
int blit_bitmap(bitmap_t * bitmap, int dst_x, int dst_y, |
int w, int h, int src_x, int src_y) |
{ |
struct blit_call bc; |
int ret; |
surface_t *sf = to_surface(bitmap); |
// if (sf->flags & hw_caps & HW_BIT_BLIT) |
// return sna_blit_tex(bitmap, false, dst_x, dst_y, w, h, src_x, src_y); |
bc.dstx = dst_x; |
bc.dsty = dst_y; |
bc.w = w; |
bc.h = h; |
bc.srcx = 0; |
bc.srcy = 0; |
bc.srcw = w; |
bc.srch = h; |
bc.stride = sf->pitch; |
bc.bitmap = sf->data; |
__asm__ __volatile__( |
"int $0x40":"=a"(ret):"a"(73), "b"(0x00), |
"c"(&bc):"memory"); |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
return ret; |
}; |
int fplay_blit_bitmap(bitmap_t * bitmap, int dst_x, int dst_y, int w, int h) |
{ |
struct blit_call bc; |
int ret; |
surface_t *sf = to_surface(bitmap); |
// if (sf->flags & hw_caps & HW_TEX_BLIT) |
// return sna_blit_tex(bitmap, true, dst_x, dst_y, w, h, 0, 0); |
bc.dstx = dst_x; |
bc.dsty = dst_y; |
bc.w = w; |
bc.h = h; |
bc.srcx = 0; |
bc.srcy = 0; |
bc.srcw = w; |
bc.srch = h; |
bc.stride = sf->pitch; |
bc.bitmap = sf->data; |
__asm__ __volatile__( |
"int $0x40":"=a"(ret):"a"(73), "b"(0x00), |
"c"(&bc):"memory"); |
bitmap->data = (void *) -1; |
bitmap->pitch = -1; |
return ret; |
}; |
int resize_bitmap(bitmap_t * bitmap) |
{ |
uint32_t size; |
uint32_t pitch; |
// printf("%s\n", __FUNCTION__); |
surface_t *sf = to_surface(bitmap); |
// if (sf->flags & hw_caps) |
// { |
// return sna_resize_bitmap(bitmap); |
// }; |
pitch = ALIGN(bitmap->width * 4, 16); |
size = ALIGN(pitch * bitmap->height, 4096); |
bitmap->pitch = -1; |
bitmap->data = (void *) -1; |
if (size > sf->bo_size) |
{ |
sf->data = user_realloc(sf->data, size); /* grow buffer */ |
if (sf->data == NULL) |
return -1; |
sf->bo_size = size; |
} else if (size < sf->bo_size) |
user_unmap(sf->data, size, sf->bo_size - size); /* unmap unused pages */ |
sf->width = bitmap->width; |
sf->height = bitmap->height; |
sf->pitch = pitch; |
return 0; |
}; |
int sna_create_mask() |
{ |
return 0; |
}; |
/contrib/sdk/sources/Intel-2D/sna/gen6_render.c |
---|
3327,7 → 3327,9 |
static void gen6_render_fini(struct sna *sna) |
{ |
ENTER(); |
kgem_bo_destroy(&sna->kgem, sna->render_state.gen6.general_bo); |
LEAVE(); |
} |
static bool is_gt2(struct sna *sna) |
/contrib/sdk/sources/Intel-2D/sna/kgem.c |
---|
47,6 → 47,7 |
#include "sna_cpuid.h" |
static struct kgem_bo * |
search_linear_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags); |
2936,6 → 2937,8 |
unsigned int i; |
int n; |
ENTER(); |
/* sync to the most recent request */ |
for (n = 0; n < ARRAY_SIZE(kgem->requests); n++) { |
if (!list_is_empty(&kgem->requests[n])) { |
2983,6 → 2986,8 |
kgem->need_purge = false; |
kgem->need_expire = false; |
LEAVE(); |
} |
static struct kgem_bo * |
5388,14 → 5393,18 |
void kgem_close_batches(struct kgem *kgem) |
{ |
int n; |
ENTER(); |
for (n = 0; n < ARRAY_SIZE(kgem->pinned_batches); n++) { |
while (!list_is_empty(&kgem->pinned_batches[n])) { |
kgem_bo_destroy(kgem, |
while (!list_is_empty(&kgem->pinned_batches[n])) |
{ |
struct kgem_bo *bo = |
list_first_entry(&kgem->pinned_batches[n], |
struct kgem_bo, list)); |
struct kgem_bo, list); |
list_del(&bo->list); |
kgem_bo_destroy(kgem,bo); |
} |
} |
LEAVE(); |
}; |
struct kgem_bo *kgem_bo_from_handle(struct kgem *kgem, int handle, |
/contrib/sdk/sources/Intel-2D/sna/sna.c |
---|
49,6 → 49,13 |
#define to_surface(x) (surface_t*)((x)->handle) |
typedef struct { |
int l; |
int t; |
int r; |
int b; |
} rect_t; |
static struct sna_fb sna_fb; |
static int tls_mask; |
268,6 → 275,8 |
void sna_fini() |
{ |
ENTER(); |
if( sna_device ) |
{ |
struct kgem_bo *mask; |
279,12 → 288,13 |
sna_device->render.fini(sna_device); |
if(mask) |
kgem_bo_destroy(&sna_device->kgem, mask); |
kgem_close_batches(&sna_device->kgem); |
// kgem_close_batches(&sna_device->kgem); |
kgem_cleanup_cache(&sna_device->kgem); |
sna_device = NULL; |
__lock_release_recursive(__sna_lock); |
}; |
LEAVE(); |
} |
#if 0 |
697,8 → 707,106 |
return -1; |
}; |
#define MI_LOAD_REGISTER_IMM (0x22<<23) |
#define MI_WAIT_FOR_EVENT (0x03<<23) |
static bool sna_emit_wait_for_scanline_gen6(struct sna *sna, |
rect_t *crtc, |
int pipe, int y1, int y2, |
bool full_height) |
{ |
uint32_t *b; |
uint32_t event; |
// if (!sna->kgem.has_secure_batches) |
// return false; |
assert(y1 >= 0); |
assert(y2 > y1); |
assert(sna->kgem.mode == KGEM_RENDER); |
/* Always program one less than the desired value */ |
if (--y1 < 0) |
y1 = crtc->b; |
y2--; |
/* The scanline granularity is 3 bits */ |
y1 &= ~7; |
y2 &= ~7; |
if (y2 == y1) |
return false; |
event = 1 << (3*full_height + pipe*8); |
b = kgem_get_batch(&sna->kgem); |
sna->kgem.nbatch += 10; |
b[0] = MI_LOAD_REGISTER_IMM | 1; |
b[1] = 0x44050; /* DERRMR */ |
b[2] = ~event; |
b[3] = MI_LOAD_REGISTER_IMM | 1; |
b[4] = 0x4f100; /* magic */ |
b[5] = (1 << 31) | (1 << 30) | pipe << 29 | (y1 << 16) | y2; |
b[6] = MI_WAIT_FOR_EVENT | event; |
b[7] = MI_LOAD_REGISTER_IMM | 1; |
b[8] = 0x44050; /* DERRMR */ |
b[9] = ~0; |
sna->kgem.batch_flags |= I915_EXEC_SECURE; |
return true; |
} |
bool |
sna_wait_for_scanline(struct sna *sna, |
rect_t *crtc, |
rect_t *clip) |
{ |
bool full_height; |
int y1, y2, pipe; |
bool ret; |
// if (sna->flags & SNA_NO_VSYNC) |
// return false; |
/* |
* Make sure we don't wait for a scanline that will |
* never occur |
*/ |
y1 = clip->t - crtc->t; |
if (y1 < 0) |
y1 = 0; |
y2 = clip->b - crtc->t; |
if (y2 > crtc->b - crtc->t) |
y2 = crtc->b - crtc->t; |
// DBG(("%s: clipped range = %d, %d\n", __FUNCTION__, y1, y2)); |
// printf("%s: clipped range = %d, %d\n", __FUNCTION__, y1, y2); |
if (y2 <= y1 + 4) |
return false; |
full_height = y1 == 0 && y2 == crtc->b - crtc->t; |
pipe = 0; |
DBG(("%s: pipe=%d, y1=%d, y2=%d, full_height?=%d\n", |
__FUNCTION__, pipe, y1, y2, full_height)); |
if (sna->kgem.gen >= 0100) |
ret = false; |
// else if (sna->kgem.gen >= 075) |
// ret = sna_emit_wait_for_scanline_hsw(sna, crtc, pipe, y1, y2, full_height); |
// else if (sna->kgem.gen >= 070) |
// ret = sna_emit_wait_for_scanline_ivb(sna, crtc, pipe, y1, y2, full_height); |
else if (sna->kgem.gen >= 060) |
ret =sna_emit_wait_for_scanline_gen6(sna, crtc, pipe, y1, y2, full_height); |
// else if (sna->kgem.gen >= 040) |
// ret = sna_emit_wait_for_scanline_gen4(sna, crtc, pipe, y1, y2, full_height); |
return ret; |
} |
bool |
gen6_composite(struct sna *sna, |
uint8_t op, |
PixmapPtr src, struct kgem_bo *src_bo, |
786,7 → 894,23 |
__lock_acquire_recursive(__sna_lock); |
{ |
rect_t crtc, clip; |
crtc.l = 0; |
crtc.t = 0; |
crtc.r = sna_fb.width-1; |
crtc.b = sna_fb.height-1; |
clip.l = winx+dst_x; |
clip.t = winy+dst_y; |
clip.r = clip.l+w-1; |
clip.b = clip.t+h-1; |
kgem_set_mode(&sna_device->kgem, KGEM_RENDER, sna_fb.fb_bo); |
sna_wait_for_scanline(sna_device, &crtc, &clip); |
} |
if( sna_device->render.blit_tex(sna_device, PictOpSrc,scale, |
&src, src_bo, |
&mask, mask_bo, |
/contrib/sdk/sources/Intel-2D/sna/sna.h |
---|
98,6 → 98,10 |
#define DBG(x) |
#endif |
# define ENTER() printf("ENTER %s\n", __FUNCTION__) |
# define LEAVE() printf("LEAVE %s\n", __FUNCTION__) |
# define FAIL() printf("FAIL %s\n", __FUNCTION__) |
#define DEBUG_NO_BLT 0 |
#define DEBUG_FLUSH_BATCH 0 |