static DFBResult system_initialize( CoreDFB *core, void **data ) { CoreScreen *core_screen; D_ASSERT( dfb_vnc == NULL ); dfb_vnc = (DFBVNC*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFBVNC) ); if (!dfb_vnc) { D_ERROR( "DirectFB/VNC: Couldn't allocate shared memory!\n" ); return D_OOSHM(); } dfb_vnc_core = core; fusion_skirmish_init( &dfb_vnc->lock, "VNC System", dfb_core_world(core) ); fusion_call_init( &dfb_vnc->call, dfb_vnc_call_handler, NULL, dfb_core_world(core) ); core_screen = dfb_screens_register( NULL, NULL, &vncPrimaryScreenFuncs ); dfb_layers_register( core_screen, NULL, &vncPrimaryLayerFuncs ); fusion_arena_add_shared_field( dfb_core_arena( core ), "vnc", dfb_vnc ); *data = dfb_vnc; return DFB_OK; }
static DFBResult system_initialize( CoreDFB *core, void **data ) { char *driver; CoreScreen *screen; D_ASSERT( dfb_osx == NULL ); dfb_osx = (DFBOSX*) SHCALLOC( dfb_core_shmpool(dfb_osx_core), 1, sizeof(DFBOSX) ); if (!dfb_osx) { D_ERROR( "DirectFB/OSX: Couldn't allocate shared memory!\n" ); return D_OOSHM(); } dfb_osx_core = core; /* Initialize OSX */ fusion_skirmish_init( &dfb_osx->lock, "OSX System", dfb_core_world(core) ); fusion_call_init( &dfb_osx->call, dfb_osx_call_handler, NULL, dfb_core_world(core) ); screen = dfb_screens_register( NULL, NULL, &osxPrimaryScreenFuncs ); dfb_layers_register( screen, NULL, &osxPrimaryLayerFuncs ); fusion_arena_add_shared_field( dfb_core_arena( core ), "OSX", dfb_osx ); *data = dfb_osx; return DFB_OK; }
static DFBResult system_join( CoreDFB *core, void **ret_data ) { DFBResult ret; void *tmp; PVR2DData *data; PVR2DDataShared *shared; D_ASSERT( m_data == NULL ); data = D_CALLOC( 1, sizeof(PVR2DData) ); if (!data) return D_OOM(); data->core = core; ret = fusion_arena_get_shared_field( dfb_core_arena( core ), "pvr2d", &tmp ); if (ret) { D_FREE( data ); return ret; } data->shared = shared = tmp; *ret_data = m_data = data; data->screen = dfb_screens_register( NULL, data, pvr2dPrimaryScreenFuncs ); data->layer = dfb_layers_register( data->screen, data, pvr2dPrimaryLayerFuncs ); dfb_surface_pool_join( core, shared->pool, pvr2dSurfacePoolFuncs ); return DFB_OK; }
static DFBResult system_join( CoreDFB *core, void **data ) { DFBResult ret; void *ptr; DFBX11 *x11; DFBX11Shared *shared; D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); x11 = D_CALLOC( 1, sizeof(DFBX11) ); if (!x11) return D_OOM(); fusion_arena_get_shared_field( dfb_core_arena( core ), "x11", &ptr ); shared = ptr; /* * Local init (master and slave) */ ret = InitLocal( x11, shared, core ); if (ret) { D_FREE( x11 ); return ret; } /* * Must be set before joining the pools! */ *data = x11; /* * Slave init */ if (shared->x11image_pool) dfb_surface_pool_join( core, shared->x11image_pool, &x11SurfacePoolFuncs ); #ifdef USE_GLX if (shared->glx_pool) dfb_surface_pool_join( core, shared->glx_pool, &glxSurfacePoolFuncs ); #endif if (shared->vpsmem_pool) dfb_surface_pool_join( core, shared->vpsmem_pool, &vpsmemSurfacePoolFuncs ); #ifdef USE_GLX if (shared->x11_pool_bridge) dfb_surface_pool_bridge_join( core, shared->x11_pool_bridge, &x11SurfacePoolBridgeFuncs, x11 ); #endif return DFB_OK; }
static DFBResult system_initialize( CoreDFB *core, void **ret_data ) { DFBResult ret; DevMemData *data; DevMemDataShared *shared; FusionSHMPoolShared *pool; D_ASSERT( m_data == NULL ); if (!dfb_config->video_phys || !dfb_config->video_length) { D_ERROR( "System/DevMem: Please supply 'video-phys = 0xXXXXXXXX' and 'video-length = XXXX' options!\n" ); return DFB_INVARG; } if (dfb_config->mmio_phys && !dfb_config->mmio_length) { D_ERROR( "System/DevMem: Please supply both 'mmio-phys = 0xXXXXXXXX' and 'mmio-length = XXXX' options or none!\n" ); return DFB_INVARG; } data = D_CALLOC( 1, sizeof(DevMemData) ); if (!data) return D_OOM(); pool = dfb_core_shmpool( core ); shared = SHCALLOC( pool, 1, sizeof(DevMemDataShared) ); if (!shared) { D_FREE( data ); return D_OOSHM(); } shared->shmpool = pool; data->shared = shared; ret = MapMemAndReg( data, dfb_config->video_phys, dfb_config->video_length, dfb_config->mmio_phys, dfb_config->mmio_length ); if (ret) { SHFREE( pool, shared ); D_FREE( data ); return ret; } *ret_data = m_data = data; dfb_surface_pool_initialize( core, &devmemSurfacePoolFuncs, &shared->pool ); fusion_arena_add_shared_field( dfb_core_arena( core ), "devmem", shared ); return DFB_OK; }
static DFBResult system_initialize( CoreDFB *core, void **ret_data ) { DFBResult ret; PVR2DData *data; PVR2DDataShared *shared; FusionSHMPoolShared *pool; D_ASSERT( m_data == NULL ); data = D_CALLOC( 1, sizeof(PVR2DData) ); if (!data) return D_OOM(); data->core = core; pool = dfb_core_shmpool( core ); shared = SHCALLOC( pool, 1, sizeof(PVR2DDataShared) ); if (!shared) { D_FREE( data ); return D_OOSHM(); } shared->shmpool = pool; data->shared = shared; ret = InitPVR2D( data ); if (ret) { SHFREE( pool, shared ); D_FREE( data ); return ret; } ret = InitEGL( data ); if (ret) { SHFREE( pool, shared ); D_FREE( data ); return ret; } *ret_data = m_data = data; data->screen = dfb_screens_register( NULL, data, pvr2dPrimaryScreenFuncs ); data->layer = dfb_layers_register( data->screen, data, pvr2dPrimaryLayerFuncs ); dfb_surface_pool_initialize( core, pvr2dSurfacePoolFuncs, &shared->pool ); fusion_arena_add_shared_field( dfb_core_arena( core ), "pvr2d", shared ); return DFB_OK; }
DFBResult dfb_core_part_initialize( CoreDFB *core, CorePart *core_part ) { DFBResult ret; void *local = NULL; void *shared = NULL; FusionSHMPoolShared *pool; pool = dfb_core_shmpool( core ); if (core_part->initialized) { D_BUG( "%s already initialized", core_part->name ); return DFB_BUG; } D_DEBUG_AT( Core_Parts, "Going to initialize '%s' core...\n", core_part->name ); if (core_part->size_local) local = D_CALLOC( 1, core_part->size_local ); if (core_part->size_shared) shared = SHCALLOC( pool, 1, core_part->size_shared ); D_INFO("Going to initialize '%s' core...\n", core_part->name ); ret = core_part->Initialize( core, local, shared ); D_INFO("Core '%s' initialized ...\n", core_part->name ); if (ret) { D_ERROR( "DirectFB/Core: Could not initialize '%s' core!\n" " --> %s\n", core_part->name, DirectFBErrorString( ret ) ); if (shared) SHFREE( pool, shared ); if (local) D_FREE( local ); return ret; } if (shared) fusion_arena_add_shared_field( dfb_core_arena( core ), core_part->name, shared ); core_part->data_local = local; core_part->data_shared = shared; core_part->initialized = true; return DFB_OK; }
static DFBResult system_initialize( CoreDFB *core, void **data ) { char *driver; CoreScreen *screen; D_ASSERT( dfb_sdl == NULL ); dfb_sdl = (DFBSDL*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFBSDL) ); if (!dfb_sdl) { D_ERROR( "DirectFB/SDL: Couldn't allocate shared memory!\n" ); return D_OOSHM(); } dfb_sdl_core = core; dfb_fbdev_read_modes(); /* use same mode list as a fake */ driver = getenv( "SDL_VIDEODRIVER" ); if (driver && !strcasecmp( driver, "directfb" )) { D_INFO( "DirectFB/SDL: SDL_VIDEODRIVER is 'directfb', unsetting it.\n" ); unsetenv( "SDL_VIDEODRIVER" ); } /* Initialize SDL */ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { D_ERROR( "DirectFB/SDL: Couldn't initialize SDL: %s\n", SDL_GetError() ); SHFREE( dfb_core_shmpool(core), dfb_sdl ); dfb_sdl = NULL; return DFB_INIT; } fusion_skirmish_init( &dfb_sdl->lock, "SDL System", dfb_core_world(core) ); fusion_call_init( &dfb_sdl->call, dfb_sdl_call_handler, NULL, dfb_core_world(core) ); screen = dfb_screens_register( NULL, NULL, sdlPrimaryScreenFuncs ); dfb_layers_register( screen, NULL, sdlPrimaryLayerFuncs ); fusion_arena_add_shared_field( dfb_core_arena( core ), "sdl", dfb_sdl ); dfb_surface_pool_initialize( core, &sdlSurfacePoolFuncs, &dfb_sdl->sdl_pool ); *data = dfb_sdl; return DFB_OK; }
static DFBResult system_join( CoreDFB *core, void **ret_data ) { DFBResult ret; void *tmp; DevMemData *data; DevMemDataShared *shared; D_ASSERT( m_data == NULL ); if (!dfb_config->video_phys || !dfb_config->video_length) { D_ERROR( "System/DevMem: Please supply 'video-phys = 0xXXXXXXXX' and 'video-length = XXXX' options!\n" ); return DFB_INVARG; } if (dfb_config->mmio_phys && !dfb_config->mmio_length) { D_ERROR( "System/DevMem: Please supply both 'mmio-phys = 0xXXXXXXXX' and 'mmio-length = XXXX' options or none!\n" ); return DFB_INVARG; } data = D_CALLOC( 1, sizeof(DevMemData) ); if (!data) return D_OOM(); ret = fusion_arena_get_shared_field( dfb_core_arena( core ), "devmem", &tmp ); if (ret) { D_FREE( data ); return ret; } data->shared = shared = tmp; ret = MapMemAndReg( data, dfb_config->video_phys, dfb_config->video_length, dfb_config->mmio_phys, dfb_config->mmio_length ); if (ret) { D_FREE( data ); return ret; } *ret_data = m_data = data; dfb_surface_pool_join( core, shared->pool, &devmemSurfacePoolFuncs ); return DFB_OK; }
DFBResult dfb_core_part_join( CoreDFB *core, CorePart *core_part ) { DFBResult ret; void *local = NULL; void *shared = NULL; if (core_part->initialized) { D_BUG( "%s already joined", core_part->name ); return DFB_BUG; } D_DEBUG_AT( Core_Parts, "Going to join '%s' core...\n", core_part->name ); if (core_part->size_shared && fusion_arena_get_shared_field( dfb_core_arena( core ), core_part->name, &shared )) return DFB_FUSION; if (core_part->size_local) local = D_CALLOC( 1, core_part->size_local ); ret = core_part->Join( core, local, shared ); if (ret) { D_ERROR( "DirectFB/Core: Could not join '%s' core!\n" " --> %s\n", core_part->name, DirectFBErrorString( ret ) ); if (local) D_FREE( local ); return ret; } core_part->data_local = local; core_part->data_shared = shared; core_part->initialized = true; return DFB_OK; }
static DFBResult system_join( CoreDFB *core, void **data ) { void *ret; CoreScreen *core_screen; D_ASSERT( dfb_vnc == NULL ); fusion_arena_get_shared_field( dfb_core_arena( core ), "vnc", &ret ); dfb_vnc = ret; dfb_vnc_core = core; core_screen = dfb_screens_register( NULL, NULL, &vncPrimaryScreenFuncs ); dfb_layers_register( core_screen, NULL, &vncPrimaryLayerFuncs ); *data = dfb_vnc; return DFB_OK; }
static DFBResult system_join( CoreDFB *core, void **data ) { void *ret; CoreScreen *screen; D_ASSERT( dfb_sdl == NULL ); fusion_arena_get_shared_field( dfb_core_arena( core ), "sdl", &ret ); dfb_sdl = ret; dfb_sdl_core = core; screen = dfb_screens_register( NULL, NULL, sdlPrimaryScreenFuncs ); dfb_layers_register( screen, NULL, sdlPrimaryLayerFuncs ); dfb_surface_pool_join( core, dfb_sdl->sdl_pool, &sdlSurfacePoolFuncs ); *data = dfb_sdl; return DFB_OK; }
static DFBResult system_initialize( CoreDFB *core, void **data ) { DFBResult ret; DFBX11 *x11; DFBX11Shared *shared; D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); x11 = D_CALLOC( 1, sizeof(DFBX11) ); if (!x11) return D_OOM(); shared = SHCALLOC( dfb_core_shmpool( core ), 1, sizeof(DFBX11Shared) ); if (!shared) { D_FREE( x11 ); return D_OOSHM(); } /* we need the error handler to signal the error to us, so use a global static */ shared_for_error_handler = shared; XSetErrorHandler( error_handler ); /* * Local init (master and slave) */ ret = InitLocal( x11, shared, core ); if (ret) { SHFREE( dfb_core_shmpool( core ), shared ); D_FREE( x11 ); return ret; } /* * Shared init (master only) */ shared->data_shmpool = dfb_core_shmpool_data( core ); shared->screen_size.w = x11->screenptr->width; shared->screen_size.h = x11->screenptr->height; fusion_skirmish_init( &shared->lock, "X11 System", dfb_core_world(core) ); fusion_call_init( &shared->call, call_handler, x11, dfb_core_world(core) ); /* * Must be set before initializing the pools! */ *data = x11; /* * Master init */ dfb_surface_pool_initialize( core, &x11SurfacePoolFuncs, &shared->x11image_pool ); #ifdef USE_GLX dfb_surface_pool_initialize( core, &glxSurfacePoolFuncs, &shared->glx_pool ); #endif if (dfb_config->video_length) { shared->vpsmem_length = dfb_config->video_length; dfb_surface_pool_initialize( core, &vpsmemSurfacePoolFuncs, &shared->vpsmem_pool ); } #ifdef USE_GLX dfb_surface_pool_bridge_initialize( core, &x11SurfacePoolBridgeFuncs, x11, &shared->x11_pool_bridge ); #endif fusion_arena_add_shared_field( dfb_core_arena( core ), "x11", shared ); return DFB_OK; }
static DFBResult system_initialize( CoreDFB *core, void **data ) { int i, n; CoreScreen *screen; D_ASSERT( dfb_x11 == NULL ); dfb_x11 = (DFBX11*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFBX11) ); if (!dfb_x11) { D_ERROR( "DirectFB/X11: Couldn't allocate shared memory!\n" ); return D_OOSHM(); } dfb_x11_core = core; fusion_skirmish_init( &dfb_x11->lock, "X11 System", dfb_core_world(core) ); fusion_call_init( &dfb_x11->call, call_handler, NULL, dfb_core_world(core) ); dfb_surface_pool_initialize( core, &x11SurfacePoolFuncs, &dfb_x11->surface_pool ); screen = dfb_screens_register( NULL, NULL, &x11PrimaryScreenFuncs ); dfb_layers_register( screen, NULL, &x11PrimaryLayerFuncs ); fusion_arena_add_shared_field( dfb_core_arena( core ), "x11", dfb_x11 ); *data = dfb_x11; XInitThreads(); dfb_x11->data_shmpool = dfb_core_shmpool_data( core ); dfb_x11->display = XOpenDisplay(getenv("DISPLAY")); if (!dfb_x11->display) { D_ERROR("X11: Error in XOpenDisplay for '%s'\n", getenv("DISPLAY")); return DFB_INIT; } dfb_x11->screenptr = DefaultScreenOfDisplay(dfb_x11->display); dfb_x11->screennum = DefaultScreen(dfb_x11->display); for (i=0; i<dfb_x11->screenptr->ndepths; i++) { const Depth *depth = &dfb_x11->screenptr->depths[i]; for (n=0; n<depth->nvisuals; n++) { Visual *visual = &depth->visuals[n]; D_DEBUG( "X11/Visual: ID %02lu, depth %d, red 0x%06lx, green 0x%06lx, blue 0x%06lx, %d bits/rgb, %d entries\n", visual->visualid, depth->depth, visual->red_mask, visual->green_mask, visual->blue_mask, visual->bits_per_rgb, visual->map_entries ); switch (depth->depth) { case 24: if (visual->red_mask == 0xff0000 && visual->green_mask == 0x00ff00 && visual->blue_mask == 0x0000ff) { dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = visual; dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = visual; } break; case 16: if (visual->red_mask == 0xf800 && visual->green_mask == 0x07e0 && visual->blue_mask == 0x001f) dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = visual; break; case 15: if (visual->red_mask == 0x7c00 && visual->green_mask == 0x03e0 && visual->blue_mask == 0x001f) dfb_x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)] = visual; break; } } } return DFB_OK; }