/*************************************************************** ** ** Broadcom Corp. Confidential ** Copyright 2002 Broadcom Corp. All Rights Reserved. ** ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ** ** Description: sgil platform definitions ** ** Created: 8/22/2002 by Jeffrey P. Fisher ** ** ** ****************************************************************/ /** include files **/ #include "bgfx_defs.h" /** local types, definitions and data **/ static int g_bgfx_debug_level = 1; static bgfx_io_t *g_p_io = NULL; static bgfx_prot_t *g_prot_t = NULL; static bgfx_hw_t *g_hw_t = NULL; /****************************************************************} * INPUTS: none * OUTPUTS: none * RETURNS: debug level * FUNCTION: get the debug level * ****************************************************************/ int bgfx_get_debug_level() { return g_bgfx_debug_level; } /****************************************************************} * INPUTS: debug level * OUTPUTS: none * RETURNS: none * FUNCTION: set the debug level * ****************************************************************/ void bgfx_set_debug_level(int level) { g_bgfx_debug_level = level; } /**************************************************************** * INPUTS: none * OUTPUTS: none * RETURNS: none * FUNCTION: Called to protect internal global structures. Supplied * callback function should function as a mutual exclusion * semaphore. ****************************************************************/ void bgfx_lock(void) { if (g_prot_t) { g_prot_t->lock(); } } /**************************************************************** * INPUTS: none * OUTPUTS: none * RETURNS: none * FUNCTION: Called to release protection of internal global structures. * Supplied callback function should release mutual exclusion * semaphore. ****************************************************************/ void bgfx_unlock(void) { if (g_prot_t) { g_prot_t->unlock(); } } /**************************************************************** * INPUTS: same as standard file IO (see fread) * OUTPUTS: none * RETURNS: none * FUNCTION: Read data from the file stream. Supplied callback function * should load count elements of size bytes into the supplied * buffer and return the number of bytes actualy loaded or * value < 0 when an error occurs. * * ****************************************************************/ long bgfx_read(void *buffer, long size, long count, void *fp ) { if (!g_p_io || !g_p_io->read) return -1; return g_p_io->read(buffer,size,count,fp); } /**************************************************************** * INPUTS: same as standard file IO (see fread) * OUTPUTS: none * RETURNS: none * FUNCTION: Read data from the file stream. Supplied callback function * should load count elements of size bytes into the supplied * buffer and return the number of bytes actualy loaded or * value < 0 when an error occurs. * * ****************************************************************/ unsigned int bgfx_tell(void *fp ) { if (!g_p_io || !g_p_io->tell) return -1; return g_p_io->tell(fp); } /**************************************************************** * INPUTS: same as standard file IO (see fseek) * OUTPUTS: none * RETURNS: none * FUNCTION: Set the current file pointer. (only uses SEEK_SET = 0) * * ****************************************************************/ int bgfx_set( void *fp,int offset, int whence) { if (!g_p_io || !g_p_io->set) return -1; return g_p_io->set(fp, offset, whence); } /****************************************************************} * INPUTS: io and protection function structures * OUTPUTS: none * RETURNS: non-zero on failure * FUNCTION: initialize sgl, primarily for protection of freetype global * structures. * ****************************************************************/ void bgfx_config(bgfx_io_t *io_p,bgfx_prot_t *prot_p,bgfx_hw_t *hw_p) { g_p_io = io_p; g_prot_t = prot_p; g_hw_t = hw_p; } /****************************************************************} * INPUTS: ptr - address to flush * nbytes - number of bytes * OUTPUTS: none * RETURNS: none * FUNCTION: Perform a cache flush for the address and size specified. * ****************************************************************/ void bgfx_cacheflush(void *ptr,int nbytes) { /* not implemented in uclibc cacheflush(ptr,nbytes,DCACHE); BROKEN syscall(__NR_cacheflush,ptr,nbytes,DCACHE); */ } int bgfx_hw_fill( void *surf, bgfx_rect *r, uint32_t pixel ) { if (!g_hw_t || !g_hw_t->fill_cb) { return -1; } return g_hw_t->fill_cb(surf,r,pixel); } int bgfx_hw_blit( void *src_surf, bgfx_rect *src_r, void *dst_surf, bgfx_rect *dst_r, void *out_surf, bgfx_rect *out_r ) { if (!g_hw_t || !g_hw_t->blit_cb) { return -1; } return g_hw_t->blit_cb(src_surf,src_r,dst_surf,dst_r,out_surf,out_r); } int bgfx_hw_surf_create(uint32_t width, uint32_t height, int format, uint8_t **mem, uint32_t *pitch, void **p_settop_surf ) { if (!g_hw_t || !g_hw_t->create_cb) { return -1; } return g_hw_t->create_cb(width, height, format, mem, pitch, p_settop_surf); } void bgfx_hw_surf_destroy(void *p_settop_surf ) { if (!g_hw_t || !g_hw_t->destroy_cb) { return; } g_hw_t->destroy_cb(p_settop_surf); } bgfx_hw_t *bgfx_hw_get_fcn() { return g_hw_t; }