static DFBResult osdUnlock( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceAllocation *allocation, void *alloc_data, CoreSurfaceBufferLock *lock ) { OSDAllocationData *alloc = alloc_data; D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); D_MAGIC_ASSERT( alloc, OSDAllocationData ); D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); D_DEBUG_AT( OSD_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); (void) alloc; return DFB_OK; }
DFBResult ILayerContext_Real::FindWindowByResourceID( u64 resource_id, CoreWindow **ret_window ) { DFBResult ret; CoreLayerContext *context = obj; CoreWindowStack *stack; FindWindowByResourceID_Context ctx; D_DEBUG_AT( DirectFB_CoreLayerContext, "ILayerContext_Real::%s()\n", __FUNCTION__ ); D_ASSERT( ret_window != NULL ); stack = context->stack; D_ASSERT( stack != NULL ); ctx.resource_id = resource_id; ctx.window = NULL; ret = (DFBResult) dfb_layer_context_lock( context ); if (ret) return ret; ret = dfb_wm_enum_windows( stack, FindWindowByResourceID_WindowCallback, &ctx ); if (ret == DFB_OK) { if (ctx.window) { ret = (DFBResult) dfb_window_ref( ctx.window ); if (ret == DFB_OK) *ret_window = ctx.window; } else ret = DFB_IDNOTFOUND; } dfb_layer_context_unlock( context ); return ret; }
static DFBResult driver_init_device(CoreGraphicsDevice *device, GraphicsDeviceInfo *device_info, void *driver_data, void *device_data) { const char *renderer; DFBResult status; D_DEBUG_AT(GLES2__2D, "%s()\n", __FUNCTION__); // Now that we have a connection and can query GLES. renderer = (const char*)glGetString(GL_RENDERER); // Fill device info. snprintf(device_info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "%s", "GLES2 Acceleration -"); snprintf(device_info->name, DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "%s", renderer ?: "Unknown"); // Initialize shader program objects, shared across all EGL contexts. status = gles2_init_shader_programs((GLES2DeviceData *)device_data); if (status != DFB_OK) { D_ERROR("GLES2/Driver: Could not create shader program objects!\n"); return status; } /* device limitations */ device_info->limits.surface_byteoffset_alignment = 8; device_info->limits.surface_bytepitch_alignment = 8; device_info->caps.flags = CCF_CLIPPING | CCF_RENDEROPTS; device_info->caps.accel = GLES2_SUPPORTED_DRAWINGFUNCTIONS | GLES2_SUPPORTED_BLITTINGFUNCTIONS; device_info->caps.drawing = GLES2_SUPPORTED_DRAWINGFLAGS; device_info->caps.blitting = GLES2_SUPPORTED_BLITTINGFLAGS; return DFB_OK; }
static void surface_destructor( FusionObject *object, bool zombie, void *ctx ) { int i; CoreSurface *surface = (CoreSurface*) object; D_MAGIC_ASSERT( surface, CoreSurface ); D_DEBUG_AT( Core_Surface, "destroying %p (%dx%d%s)\n", surface, surface->config.size.w, surface->config.size.h, zombie ? " ZOMBIE" : ""); dfb_surface_lock( surface ); surface->state |= CSSF_DESTROYED; /* announce surface destruction */ dfb_surface_notify( surface, CSNF_DESTROY ); /* unlink palette */ if (surface->palette) { dfb_palette_detach_global( surface->palette, &surface->palette_reaction ); dfb_palette_unlink( &surface->palette ); } /* destroy buffers */ for (i=0; i<MAX_SURFACE_BUFFERS; i++) { if (surface->buffers[i]) dfb_surface_buffer_destroy( surface->buffers[i] ); } direct_serial_deinit( &surface->serial ); dfb_surface_unlock( surface ); fusion_skirmish_destroy( &surface->lock ); D_MAGIC_CLEAR( surface ); fusion_object_destroy( object ); }
static DFBResult drmkmsInitLayer( CoreLayer *layer, void *driver_data, void *layer_data, DFBDisplayLayerDescription *description, DFBDisplayLayerConfig *config, DFBColorAdjustment *adjustment ) { DRMKMSData *drmkms = driver_data; DRMKMSDataShared *shared = drmkms->shared; DRMKMSLayerData *data = layer_data; D_DEBUG_AT( DRMKMS_Layer, "%s()\n", __FUNCTION__ ); data->index = shared->layerplane_index_count++; data->layer_index = shared->layer_index_count++; data->level = 0; description->type = DLTF_GRAPHICS; description->caps = DLCAPS_SURFACE; description->surface_caps = DSCAPS_NONE; description->surface_accessor = CSAID_LAYER0; direct_snputs( description->name, "DRMKMS Layer", DFB_DISPLAY_LAYER_DESC_NAME_LENGTH ); config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; config->width = dfb_config->mode.width ?: shared->mode[data->layer_index].hdisplay; config->height = dfb_config->mode.height ?: shared->mode[data->layer_index].vdisplay; config->pixelformat = dfb_config->mode.format ?: DSPF_ARGB; config->buffermode = DLBM_FRONTONLY; direct_mutex_init( &data->lock ); direct_waitqueue_init( &data->wq_event ); return DFB_OK; }
static DirectResult Construct( void *interface, ... ) { DFBResult ret = DFB_INVARG; ICoreResourceManager *thiz = interface; CoreDFB *core; DIRECT_ALLOCATE_INTERFACE_DATA(thiz, ICoreResourceManager_test) D_DEBUG_AT( ICoreResourceManager_test, "%s( %p )\n", __FUNCTION__, thiz ); va_list tag; va_start(tag, interface); core = va_arg(tag, CoreDFB *); va_end( tag ); /* Check arguments. */ if (!thiz) goto error; /* Initialize interface data. */ data->ref = 1; data->core = core; /* Initialize function pointer table. */ thiz->AddRef = ICoreResourceManager_test_AddRef; thiz->Release = ICoreResourceManager_test_Release; thiz->CreateClient = ICoreResourceManager_test_CreateClient; return DFB_OK; error: DIRECT_DEALLOCATE_INTERFACE(thiz); return ret; }
static inline void validate_clip( CardState *state, int xmax, int ymax, bool warn ) { D_DEBUG_AT( Core_GfxState, "%s( %p, %d, %d, %d )\n", __FUNCTION__, state, xmax, ymax, warn ); D_MAGIC_ASSERT( state, CardState ); DFB_REGION_ASSERT( &state->clip ); D_ASSERT( xmax >= 0 ); D_ASSERT( ymax >= 0 ); D_ASSERT( state->clip.x1 <= state->clip.x2 ); D_ASSERT( state->clip.y1 <= state->clip.y2 ); if (state->clip.x1 <= xmax && state->clip.y1 <= ymax && state->clip.x2 <= xmax && state->clip.y2 <= ymax) return; if (warn) D_WARN( "Clip %d,%d-%dx%d invalid, adjusting to fit %dx%d", DFB_RECTANGLE_VALS_FROM_REGION( &state->clip ), xmax+1, ymax+1 ); if (state->clip.x1 > xmax) state->clip.x1 = xmax; if (state->clip.y1 > ymax) state->clip.y1 = ymax; if (state->clip.x2 > xmax) state->clip.x2 = xmax; if (state->clip.y2 > ymax) state->clip.y2 = ymax; state->modified |= SMF_CLIP; }
DFBResult lite_load_cursor_from_desc(LiteCursor *cursor, DFBSurfaceDescription *dsc) { DFBResult res; LITE_NULL_PARAMETER_CHECK(cursor); LITE_NULL_PARAMETER_CHECK(dsc); D_DEBUG_AT(LiteCursorDomain, "Load cursor from surface descriptor: %p\n", dsc); res = lite_util_load_image_desc(&cursor->surface, dsc); if (res != DFB_OK) return res; cursor->width = dsc->width; cursor->height = dsc->height; cursor->hot_x = 0; cursor->hot_y = 0; return res; }
static void keyboard_process_event( UniqueDevice *device, void *data, void *ctx, const DFBInputEvent *event ) { UniqueInputEvent evt; KeyboardData *keyboard = data; (void) keyboard; D_MAGIC_ASSERT( device, UniqueDevice ); D_MAGIC_ASSERT( keyboard, KeyboardData ); D_ASSERT( event != NULL ); D_DEBUG_AT( UniQuE_Keyboard, "keyboard_process_event( %p, %p, %p, %p ) <- type 0x%08x\n", device, data, ctx, event, event->type ); switch (event->type) { case DIET_KEYPRESS: case DIET_KEYRELEASE: evt.type = UIET_KEY; evt.keyboard.device_id = event->device_id; evt.keyboard.press = (event->type == DIET_KEYPRESS); evt.keyboard.key_code = event->key_code; evt.keyboard.key_id = event->key_id; evt.keyboard.key_symbol = event->key_symbol; evt.keyboard.modifiers = event->modifiers; evt.keyboard.locks = event->locks; unique_device_dispatch( device, &evt ); break; default: break; } }
void * VoodooDispatcher::DispatchLoop() { D_DEBUG_AT( Voodoo_Dispatcher, "VoodooDispatcher::%s( %p )\n", __func__, this ); direct_mutex_lock( &lock ); while (!manager->is_quit) { VoodooPacket *packet; D_MAGIC_ASSERT( this, VoodooDispatcher ); if (packets) { packet = (VoodooPacket*) packets; direct_list_remove( &packets, &packet->link ); manager->connection->WakeUp(); } else { direct_waitqueue_wait( &queue, &lock ); continue; } direct_mutex_unlock( &lock ); ProcessMessages( (VoodooMessageHeader*) packet->data_start(), packet->size() ); D_FREE( packet ); direct_mutex_lock( &lock ); } direct_mutex_unlock( &lock ); return NULL; }
/* * Called by davinciSetState() to ensure that the source ARGB modulation is properly set * for execution of blitting functions. */ static inline void davinci_validate_SOURCE_MULT( DavinciDeviceData *ddev, CardState *state ) { switch (ddev->dst_format) { case DSPF_ARGB: if (state->blittingflags & DSBLIT_COLORIZE) ddev->source_mult = 0xff000000 | ddev->color_argb; else ddev->source_mult = 0xffffffff; break; default: D_BUG( "unexpected format %s", dfb_pixelformat_name(ddev->dst_format) ); return; } D_DEBUG_AT( Davinci_2D, " => SOURCE_MULT: 0x%08lx\n", ddev->source_mult ); /* Set the flag. */ DAVINCI_VALIDATE( SOURCE_MULT ); }
static DFBResult IDirectFBDisplayLayer_GetLevel( IDirectFBDisplayLayer *thiz, int *level ) { DFBResult ret; int lvl; D_DEBUG_AT( Layer, "%s( %p )\n", __FUNCTION__, thiz ); DIRECT_INTERFACE_GET_DATA(IDirectFBDisplayLayer) if (!level) return DFB_INVARG; ret = dfb_layer_get_level( data->layer, &lvl ); if (ret) return ret; *level = lvl; return DFB_OK; }
static DFBResult IDirectFBDisplayLayer_SetDstColorKey( IDirectFBDisplayLayer *thiz, u8 r, u8 g, u8 b ) { DFBColorKey key; D_DEBUG_AT( Layer, "%s( %p )\n", __FUNCTION__, thiz ); DIRECT_INTERFACE_GET_DATA(IDirectFBDisplayLayer) if (data->level == DLSCL_SHARED) return DFB_ACCESSDENIED; key.r = r; key.g = g; key.b = b; key.index = -1; return CoreLayerContext_SetDstColorKey( data->context, &key ); }
static DFBResult IDirectFBWindow_RequestFocus( IDirectFBWindow *thiz ) { CoreWindow *window; DIRECT_INTERFACE_GET_DATA(IDirectFBWindow) D_DEBUG_AT( IDirectFB_Window, "%s()\n", __FUNCTION__ ); if (data->destroyed) return DFB_DESTROYED; window = data->window; if (window->config.options & DWOP_GHOST) return DFB_UNSUPPORTED; if (!window->config.opacity && !(window->caps & DWCAPS_INPUTONLY)) return DFB_UNSUPPORTED; return dfb_window_request_focus( window ); }
static DFBResult IDirectFBWindow_Bind( IDirectFBWindow *thiz, IDirectFBWindow *source, int x, int y ) { IDirectFBWindow_data *source_data; DIRECT_INTERFACE_GET_DATA(IDirectFBWindow) D_DEBUG_AT( IDirectFB_Window, "%s()\n", __FUNCTION__ ); if (data->destroyed) return DFB_DESTROYED; DIRECT_INTERFACE_GET_DATA_FROM(source, source_data, IDirectFBWindow); if (source_data->destroyed) return DFB_DESTROYED; return dfb_window_bind( data->window, source_data->window, x, y ); }
DFBResult CoreSlaveDispatch__Dispatch( CoreDFB *obj, FusionID caller, int method, void *ptr, unsigned int length, void *ret_ptr, unsigned int ret_size, unsigned int *ret_length ) { DFBResult ret; D_DEBUG_AT( DirectFB_CoreSlave, "CoreSlaveDispatch::%s( %p )\n", __FUNCTION__, obj ); Core_PushIdentity( caller ); ret = __CoreSlaveDispatch__Dispatch( obj, caller, method, ptr, length, ret_ptr, ret_size, ret_length ); Core_PopIdentity(); return ret; }
static DFBResult primaryInitOutput( CoreScreen *screen, void *driver_data, void *screen_data, int output, DFBScreenOutputDescription *description, DFBScreenOutputConfig *config ) { DFBX11 *x11 = driver_data; DFBX11Shared *shared = x11->shared; (void) shared; D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); description->caps = DSOCAPS_RESOLUTION; config->flags |= DSOCONF_RESOLUTION; config->resolution = DSOR_UNKNOWN; return DFB_OK; }
static DFBResult ICoreResourceManager_test_CreateClient( ICoreResourceManager *thiz, FusionID identity, ICoreResourceClient **ret_client ) { DFBResult ret; ICoreResourceClient *client; DIRECT_INTERFACE_GET_DATA(ICoreResourceManager_test) D_DEBUG_AT( ICoreResourceManager_test, "%s( %p )\n", __FUNCTION__, thiz ); DIRECT_ALLOCATE_INTERFACE( client, ICoreResourceClient ); ret = ICoreResourceClient_test_Construct( client, thiz, identity ); if (ret) return ret; *ret_client = client; return DFB_OK; }
VoodooConnectionLink::~VoodooConnectionLink() { D_DEBUG_AT( Voodoo_Connection, "VoodooConnectionLink::%s( %p )\n", __func__, this ); D_MAGIC_ASSERT( this, VoodooConnection ); /* Acquire locks and wake up waiters. */ direct_mutex_lock( &output.lock ); direct_waitqueue_broadcast( &output.wait ); direct_mutex_unlock( &output.lock ); /* Destroy conditions. */ direct_waitqueue_deinit( &output.wait ); /* Destroy locks. */ direct_mutex_deinit( &output.lock ); /* Deallocate buffers. */ D_FREE( input.buffer ); direct_tls_unregister( &output.tls ); }
DirectResult fusion_shm_pool_detach( FusionSHM *shm, FusionSHMPoolShared *pool ) { DirectResult ret; FusionSHMShared *shared; D_DEBUG_AT( Fusion_SHMPool, "%s( %p, %p )\n", __FUNCTION__, shm, pool ); D_MAGIC_ASSERT( shm, FusionSHM ); D_MAGIC_ASSERT( pool, FusionSHMPoolShared ); shared = shm->shared; D_MAGIC_ASSERT( shared, FusionSHMShared ); D_ASSERT( shared == pool->shm ); ret = fusion_skirmish_prevail( &pool->lock ); if (ret) { fusion_skirmish_dismiss( &shared->lock ); return ret; } D_ASSERT( pool->active ); D_ASSERT( pool->index >= 0 ); D_ASSERT( pool->index < FUSION_SHM_MAX_POOLS ); D_ASSERT( pool->pool_id == shm->pools[pool->index].pool_id ); D_ASSERT( pool == &shared->pools[pool->index] ); D_ASSERT( shm->pools[pool->index].attached ); D_MAGIC_ASSERT( &shm->pools[pool->index], FusionSHMPool ); leave_pool( shm, &shm->pools[pool->index], pool ); fusion_skirmish_dismiss( &pool->lock ); return DR_OK; }
static DFBResult IDirectFBWindow_SetStackingClass( IDirectFBWindow *thiz, DFBWindowStackingClass stacking_class ) { DIRECT_INTERFACE_GET_DATA(IDirectFBWindow) D_DEBUG_AT( IDirectFB_Window, "%s()\n", __FUNCTION__ ); if (data->destroyed) return DFB_DESTROYED; switch (stacking_class) { case DWSC_MIDDLE: case DWSC_UPPER: case DWSC_LOWER: break; default: return DFB_INVARG; } return dfb_window_change_stacking( data->window, stacking_class ); }
DirectResult coma_thread_init( ComaThread *thread, Coma *coma ) { FusionWorld *world; D_ASSERT( thread != NULL ); D_ASSERT( coma != NULL ); D_DEBUG_AT( Coma_Thread, "%s( %p, %p )\n", __FUNCTION__, thread, coma ); world = coma_world( coma ); thread->shmpool = coma_shmpool( coma ); /* Remember creator. */ thread->fusion_id = fusion_id( world ); D_MAGIC_SET( thread, ComaThread ); return DR_OK; }
/* * End thread, close device and free private data. */ static void driver_close_device( void *driver_data ) { X11InputData *data = driver_data; D_DEBUG_AT( X11_Input, "%s()\n", __FUNCTION__ ); /* stop input thread */ data->stop = true; /* it is possible that this "close" function is called from the same * thread that the input device is actually running on. * This happens when you e.g. click the close box with your mouse. * As a fix, we check if we are this thread. */ if (data->thread != direct_thread_self()) { direct_thread_join( data->thread ); direct_thread_destroy( data->thread ); } /* free private data */ D_FREE ( data ); }
static DFBResult IDirectFBWindow_SetDstGeometry( IDirectFBWindow *thiz, const DFBWindowGeometry *geometry ) { DFBResult ret; CoreWindowConfig config; DIRECT_INTERFACE_GET_DATA(IDirectFBWindow) D_DEBUG_AT( IDirectFB_Window, "%s()\n", __FUNCTION__ ); ret = CheckGeometry( geometry ); if (ret) return ret; if (data->destroyed) return DFB_DESTROYED; config.dst_geometry = *geometry; return dfb_window_set_config( data->window, &config, CWCF_DST_GEOMETRY ); }
static DFBResult primaryFlipRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, DFBSurfaceFlipFlags flags, CoreSurfaceBufferLock *left_lock, CoreSurfaceBufferLock *right_lock ) { DFBX11 *x11 = driver_data; DFBX11Shared *shared = x11->shared; X11LayerData *lds = layer_data; D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); dfb_surface_flip( surface, false ); lds->shown = true; return DisplaySurface( x11, layer_data, shared->vdp_queue, left_lock ); }
static void shutdown_pool( FusionSHM *shm, FusionSHMPool *pool, FusionSHMPoolShared *shared ) { FusionWorld *world; D_DEBUG_AT( Fusion_SHMPool, "%s( %p, %p, %p )\n", __FUNCTION__, shm, pool, shared ); D_MAGIC_ASSERT( shm, FusionSHM ); D_MAGIC_ASSERT( pool, FusionSHMPool ); D_MAGIC_ASSERT( shared, FusionSHMPoolShared ); world = shm->world; D_MAGIC_ASSERT( world, FusionWorld ); SHFREE( shared, shared->name ); fusion_dbg_print_memleaks( shared ); if (munmap( shared->addr_base, shared->max_size )) D_PERROR( "Fusion/SHM: Could not munmap shared memory file '%s'!\n", pool->filename ); if (unlink( pool->filename )) D_PERROR( "Fusion/SHM: Could not unlink shared memory file '%s'!\n", pool->filename ); shared->active = false; pool->attached = false; D_FREE( pool->filename ); D_MAGIC_CLEAR( pool ); fusion_skirmish_destroy( &shared->lock ); D_MAGIC_CLEAR( shared ); }
static int dfb_core_arena_shutdown( FusionArena *arena, void *ctx, bool emergency) { DFBResult ret; CoreDFB *core = ctx; CoreDFBShared *shared; FusionSHMPoolShared *pool; D_MAGIC_ASSERT( core, CoreDFB ); shared = core->shared; D_MAGIC_ASSERT( shared, CoreDFBShared ); pool = shared->shmpool; D_DEBUG_AT( DirectFB_Core, "Shutting down...\n" ); if (!core->master) { D_WARN( "refusing shutdown in slave" ); return dfb_core_leave( core, emergency ); } CoreDFB_Deinit_Dispatch( &shared->call ); /* Shutdown. */ ret = dfb_core_shutdown( core, emergency ); fusion_skirmish_destroy( &shared->lock ); D_MAGIC_CLEAR( shared ); SHFREE( pool, shared ); fusion_shm_pool_destroy( core->world, pool ); return ret; }
static DFBResult IDirectFBDisplayLayer_GetScreen( IDirectFBDisplayLayer *thiz, IDirectFBScreen **interface ) { DFBResult ret; IDirectFBScreen *screen; D_DEBUG_AT( Layer, "%s( %p )\n", __FUNCTION__, thiz ); DIRECT_INTERFACE_GET_DATA(IDirectFBDisplayLayer) if (!interface) return DFB_INVARG; DIRECT_ALLOCATE_INTERFACE( screen, IDirectFBScreen ); ret = IDirectFBScreen_Construct( screen, data->screen ); *interface = ret ? NULL : screen; return ret; }
DFBResult IWindow_Real::GetSurface( CoreSurface **ret_surface ) { DFBResult ret; D_DEBUG_AT( Core_Window, "IWindow_Real::%s( %p )\n", __FUNCTION__, obj ); D_ASSERT( ret_surface != NULL ); if (!obj->surface) return DFB_UNSUPPORTED; ret = (DFBResult) dfb_surface_ref( obj->surface ); if (ret) return ret; *ret_surface = obj->surface; return DFB_OK; }
static DFBResult IDirectFBDisplayLayer_SetScreenPosition( IDirectFBDisplayLayer *thiz, int x, int y ) { DFBPoint position; D_DEBUG_AT( Layer, "%s( %p )\n", __FUNCTION__, thiz ); DIRECT_INTERFACE_GET_DATA(IDirectFBDisplayLayer) if (! D_FLAGS_IS_SET( data->desc.caps, DLCAPS_SCREEN_POSITION )) return DFB_UNSUPPORTED; if (data->level == DLSCL_SHARED) return DFB_ACCESSDENIED; position.x = x; position.y = y; return CoreLayerContext_SetScreenPosition( data->context, &position ); }