DirectResult direct_signals_initialize( void ) { #ifndef ANDROID_NDK sigset_t mask; int i; #endif D_DEBUG_AT( Direct_Signals, "Initializing...\n" ); direct_recursive_mutex_init( &handlers_lock ); #ifdef ANDROID_NDK install_handlers(); #else if (direct_config->sighandler) { if (direct_config->sighandler_thread) { sigemptyset( &mask ); for (i=0; i<NUM_SIGS_TO_HANDLE; i++) sigaddset( &mask, sigs_to_handle[i] ); pthread_sigmask( SIG_BLOCK, &mask, NULL ); sighandler_thread = direct_thread_create( DTT_CRITICAL, handle_signals, NULL, "SigHandler" ); D_ASSERT( sighandler_thread != NULL ); } else install_handlers(); } #endif return DR_OK; }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd, buttons, axes; JoystickData *data; char devicename[20]; /* open the right device */ snprintf( devicename, 20, "/dev/js%d", number ); fd = open( devicename, O_RDONLY ); if (fd < 0) { /* try new-style device names */ snprintf( devicename, 20, "/dev/input/js%d", number ); fd = open( devicename, O_RDONLY ); if (fd < 0) { D_PERROR( "DirectFB/Joystick: Could not open `%s'!\n", devicename ); return DFB_INIT; /* no joystick available */ } } /* query number of buttons and axes */ ioctl( fd, JSIOCGBUTTONS, &buttons ); ioctl( fd, JSIOCGAXES, &axes ); /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "Joystick" ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Unknown" ); info->prefered_id = DIDID_JOYSTICK; info->desc.type = DIDTF_JOYSTICK; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_button = buttons - 1; info->desc.max_axis = axes - 1; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(JoystickData) ); data->fd = fd; data->device = device; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, joystickEventThread, data, "Joystick Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; int flags; MouseProtocol protocol; SerialMouseData *data; protocol = mouse_get_protocol(); if (protocol == LAST_PROTOCOL) /* shouldn't happen */ return DFB_BUG; /* open device */ flags = O_NONBLOCK | (dfb_config->mouse_gpm_source ? O_RDONLY : O_RDWR); fd = open( dfb_config->mouse_source, flags ); if (fd < 0) { D_PERROR( "DirectFB/SerialMouse: Error opening '%s'!\n", dfb_config->mouse_source ); return DFB_INIT; } /* reset the O_NONBLOCK flag */ fcntl (fd, F_SETFL, fcntl (fd, F_GETFL) & ~O_NONBLOCK); /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(SerialMouseData) ); data->fd = fd; data->device = device; data->protocol = protocol; mouse_setspeed( data ); /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "Serial Mouse (%s)", protocol_names[protocol] ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Unknown" ); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = (protocol > PROTOCOL_MS) ? DIBI_MIDDLE : DIBI_RIGHT; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, protocol == PROTOCOL_MOUSESYSTEMS ? mouseEventThread_mousesystems : mouseEventThread_ms, data, "SerMouse Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DFBResult driver_open_device(CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data){ int fd; PeMData *data; /* open device */ fd = PeMOpenDevice (dfb_config->penmount_device); if (fd < 0) { D_PERROR("DirectFB/PenMount: Error opening '%s'!\n", dfb_config->penmount_device); return DFB_INIT; } data = D_CALLOC (1, sizeof(PeMData)); if (!data) { close (fd); return D_OOM (); } data->fd = fd; data->device = device; /* Must define the correct resolution of screen */ data->screen_width = PeM_SCREENWIDTH; data->screen_height = PeM_SCREENHEIGHT; /* The following variable are defined to adjust the orientation of * the touchscreen. Variables are either max screen height/width or 0. */ data->min_x = PeM_MINX; data->min_y = PeM_MINY; /* fill device info structure */ snprintf(info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "PenMount 9509"); snprintf(info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "AMT"); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; #ifndef DIRECTFB_DISABLE_DEPRECATED info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; #else info->desc.caps = DIDCAPS_AXES | DIDCAPS_BUTTONS; #endif info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* start input thread */ data->thread = direct_thread_create (DTT_INPUT, PenMountEventThread, data, "PenMount Input"); /* set private data pointer */ *driver_data = data; return DFB_OK; }
void __D_perf_init() { direct_hash_init( &counter_hash, 7 ); direct_mutex_init( &counter_lock ); if (direct_config->perf_dump_interval) direct_thread_create( DTT_DEFAULT, direct_perf_dump_thread, NULL, "Perf Dump" ); }
static DFBResult driver_open_device(CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data) { int fd; MuTData *data; /* open device */ fd = MuTOpenDevice (dfb_config->mut_device); D_INFO("MuTouch:driver_open_device %s fd %d\n", dfb_config->mut_device,fd); if (fd < 0) { return DFB_INIT; } data = D_CALLOC (1, sizeof(MuTData)); if (!data) { close (fd); return D_OOM (); } data->fd = fd; data->device = device; /* Must define the correct resolution of screen */ data->screen_width = MuT_SCREENWIDTH; data->screen_height = MuT_SCREENHEIGHT; /* The following variable are defined to adjust the orientation of * the touchscreen. Variables are either max screen height/width or 0. */ data->min_x = MuT_MINX; data->min_y = MuT_MINY; /* fill device info structure */ snprintf(info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "MuTouch"); snprintf(info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Microtouch"); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* start input thread */ data->thread = direct_thread_create (DTT_INPUT, MuTouchEventThread, data, "MuTouch Input"); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DFBResult driver_open_device(CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data) { int fd; eloData *data; /* open device */ fd = eloOpenDevice(elo_DEVICE); if(fd < 0) { D_PERROR("DirectFB/elo: Error opening '"elo_DEVICE"'!\n"); return DFB_INIT; } data = D_CALLOC(1, sizeof(eloData)); if (!data) { close(fd); return D_OOM(); } data->fd = fd; data->device = device; /* Must define the correct resolution of screen */ data->screen_width = elo_SCREENWIDTH; data->screen_height = elo_SCREENHEIGHT; /* The following variable are defined to adjust the orientation of * the touchscreen. Variables are either max screen height/width or 0. */ data->min_x = elo_MINX; data->min_y = elo_MINY; /* fill device info structure */ snprintf(info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "elo"); snprintf(info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "elo Systems"); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* start input thread */ data->thread = direct_thread_create (DTT_INPUT, eloTouchEventThread, data, "ELO Touch Input"); /* set private data pointer */ *driver_data = data; return DFB_OK; }
DFBResult CoreInputHubClient_Activate( CoreInputHubClient *client ) { D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ ); D_ASSERT( !client->activate_stop && client->activate_thread == NULL ); client->activate_thread = direct_thread_create( DTT_DEFAULT, CoreInputHubClient_ActivateThread, client, "InputHub/Activate" ); return DFB_OK; }
/* * Open the device, fill out information about it, * allocate and fill private data, start input thread. * Called during initialization, resuming or taking over mastership. */ static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; DreamboxremoteData *data; /* open device */ fd = open( DEVICE, O_RDONLY); if (fd < 0) { D_PERROR( "DirectFB/dreamboxremote: could not open device" ); return DFB_INIT; } /* apply voodoo */ //ioctl( fd, RC_IOCTL_BCODES, 0 ); /* set device name */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "dreambox remote control" ); /* set device vendor */ snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "DM7000/DM56XX/DM500" ); /* set one of the primary input device IDs */ info->prefered_id = DIDID_REMOTE; /* set type flags */ info->desc.type = DIDTF_REMOTE; /* set capabilities */ info->desc.caps = DICAPS_KEYS; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(DreamboxremoteData) ); data->fd = fd; data->device = device; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, dreamboxremoteEventThread, data, "DreamBox Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
void VoodooConnectionPacket::Start( VoodooManager *manager ) { D_DEBUG_AT( Voodoo_Connection, "VoodooConnectionPacket::%s( %p )\n", __func__, this ); D_MAGIC_ASSERT( this, VoodooConnection ); D_ASSERT( manager != NULL ); D_ASSERT( this->manager == NULL ); this->manager = manager; io = direct_thread_create( DTT_DEFAULT, io_loop_main, this, "Voodoo IO" ); }
/* * Open the device, fill out information about it, * allocate and fill private data, start input thread. * Called during initialization, resuming or taking over mastership. */ static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; SonypiData *data; /* open device */ fd = open( DEVICE, O_RDONLY); if (fd < 0) { D_PERROR( "DirectFB/sonypi: could not open device" ); return DFB_INIT; } /* set device name */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "PI Jogdial" ); /* set device vendor */ snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Sony" ); /* set one of the primary input device IDs */ info->prefered_id = DIDID_MOUSE; /* set type flags */ info->desc.type = DIDTF_MOUSE; /* set capabilities */ info->desc.caps = DICAPS_BUTTONS | DICAPS_AXES; info->desc.max_axis = DIAI_Z; info->desc.max_button = DIBI_MIDDLE; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(SonypiData) ); data->fd = fd; data->device = device; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, sonypiEventThread, data, "Sony PI Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
/* * Open the device, fill out information about it, * allocate and fill private data, start input thread. * Called during initialization, resuming or taking over mastership. */ static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { SDLInputData *data; DFBSDL *dfb_sdl = dfb_system_data(); fusion_skirmish_prevail( &dfb_sdl->lock ); SDL_EnableUNICODE( true ); SDL_EnableKeyRepeat( 250, 40 ); fusion_skirmish_dismiss( &dfb_sdl->lock ); /* set device name */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "SDL Input" ); /* set device vendor */ snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "SDL" ); /* set one of the primary input device IDs */ info->prefered_id = DIDID_KEYBOARD; /* set type flags */ info->desc.type = DIDTF_JOYSTICK | DIDTF_KEYBOARD | DIDTF_MOUSE; /* set capabilities */ info->desc.caps = DICAPS_ALL; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(SDLInputData) ); data->device = device; data->dfb_sdl = dfb_sdl; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, sdlEventThread, data, "SDL Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DFBResult primaryInitLayer( CoreLayer *layer, void *driver_data, void *layer_data, DFBDisplayLayerDescription *description, DFBDisplayLayerConfig *config, DFBColorAdjustment *adjustment ) { /* set capabilities and type */ description->caps = DLCAPS_SURFACE; description->type = DLTF_GRAPHICS; /* set name */ snprintf( description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "SDL Primary Layer" ); /* fill out the default configuration */ config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; config->buffermode = DLBM_FRONTONLY; if (dfb_config->mode.width) config->width = dfb_config->mode.width; else config->width = 640; if (dfb_config->mode.height) config->height = dfb_config->mode.height; else config->height = 480; if (dfb_config->mode.format != DSPF_UNKNOWN) config->pixelformat = dfb_config->mode.format; else if (dfb_config->mode.depth > 0) config->pixelformat = dfb_pixelformat_for_depth( dfb_config->mode.depth ); else config->pixelformat = DSPF_RGB16; /* Initialize update lock and condition. */ pthread_mutex_init( &dfb_sdl->update.lock, NULL ); pthread_cond_init( &dfb_sdl->update.cond, NULL ); /* Start update thread. */ dfb_sdl->update.thread = direct_thread_create( DTT_OUTPUT, ScreenUpdateLoop, NULL, "Screen Update" ); if (!dfb_sdl->update.thread) return DFB_FAILURE; return DFB_OK; }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; WM97xxTSData *data; /* open device */ fd = open( "/dev/touchscreen/wm97xx", O_RDONLY | O_NOCTTY ); if (fd < 0) { D_PERROR( "DirectFB/WM97xx: Error opening `/dev/touchscreen/wm97xx'!\n" ); return DFB_INIT; } /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "WM97xx Touchscreen" ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Wolfson Microelectronics" ); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(WM97xxTSData) ); if (!data) { close( fd ); return D_OOM(); } data->fd = fd; data->device = device; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, wm97xxtsEventThread, data, "WM97xx TS Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
/* * Open the device, fill out information about it, * allocate and fill private data, start input thread. * Called during initialization, resuming or taking over mastership. */ static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { X11InputData *data; DFBX11 *x11 = dfb_system_data(); DFBX11Shared *shared = x11->shared; D_DEBUG_AT( X11_Input, "%s()\n", __FUNCTION__ ); fusion_skirmish_prevail( &shared->lock ); fusion_skirmish_dismiss( &shared->lock ); /* set device vendor and name */ snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "XServer" ); snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "X11 Input" ); /* set one of the primary input device IDs */ info->prefered_id = DIDID_KEYBOARD; /* set type flags */ info->desc.type = DIDTF_JOYSTICK | DIDTF_KEYBOARD | DIDTF_MOUSE; /* set capabilities */ info->desc.caps = DICAPS_ALL; /* enable translation of fake raw hardware keycodes */ info->desc.min_keycode = 8; info->desc.max_keycode = 255; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(X11InputData) ); data->device = device; data->x11 = x11; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, x11EventThread, data, "X11 Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
DirectResult direct_processor_init( DirectProcessor *processor, const char *name, const DirectProcessorFuncs *funcs, unsigned int data_size, void *context, int idle_ms ) { D_ASSERT( processor != NULL ); D_ASSERT( name != NULL ); D_ASSERT( funcs != NULL ); D_ASSERT( funcs->Process != NULL ); D_ASSERT( data_size > 0 ); D_DEBUG_AT( Direct_Processor, "%s( %p, %p, %p, %u, %p )\n", __FUNCTION__, processor, name, funcs, data_size, context ); processor->name = D_STRDUP( name ); if (!processor->name) return D_OOM(); processor->funcs = funcs; processor->data_size = data_size; processor->context = context; processor->idle_ms = idle_ms; processor->max_recycled = (8000 / data_size) + 1; direct_fifo_init( &processor->commands ); direct_fifo_init( &processor->recycled ); #if 0 direct_waitqueue_init( &processor->lock_cond, NULL ); direct_mutex_init( &processor->lock_mutex, NULL ); #endif D_MAGIC_SET( processor, DirectProcessor ); processor->thread = direct_thread_create( DTT_DEFAULT, processor_thread, processor, name ); if (!processor->thread) { D_MAGIC_CLEAR( processor ); direct_fifo_destroy( &processor->commands ); direct_fifo_destroy( &processor->recycled ); D_FREE( processor->name ); return DR_INIT; } return DR_OK; }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; ucb1x00TSData *data; /* open device */ fd = open( "/dev/ucb1x00-ts", O_RDONLY | O_NOCTTY ); if (fd < 0) { D_PERROR( "DirectFB/ucb1x00: Error opening `/dev/ucb1x00-ts'!\n" ); return DFB_INIT; } /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "ucb1x00 Touchscreen" ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Unknown" ); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(ucb1x00TSData) ); data->fd = fd; data->device = device; event_buffer = malloc( sizeof( TS_EVENT) * config.numevents ); /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, ucb1x00tsEventThread, data, "UCB TS Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DirectResult RUN_call_threaded( int index, int thread_count ) { int i; DirectThread *threads[thread_count]; for (i=0; i<thread_count; i++) { threads[i] = direct_thread_create( DTT_DEFAULT, RUN_call_thread_main, (void*)(long)index, "Test" ); } for (i=0; i<thread_count; i++) { direct_thread_join( threads[i] ); direct_thread_destroy( threads[i] ); } return DR_OK; }
VoodooDispatcher::VoodooDispatcher( VoodooManager *manager ) : magic(0), manager(manager), packets(NULL) { D_DEBUG_AT( Voodoo_Dispatcher, "VoodooDispatcher::%s( %p )\n", __func__, this ); /* Initialize lock. */ direct_mutex_init( &lock ); /* Initialize wait queue. */ direct_waitqueue_init( &queue ); D_MAGIC_SET( this, VoodooDispatcher ); dispatch_loop = direct_thread_create( DTT_MESSAGING, DispatchLoopMain, this, "Voodoo Dispatch" ); }
// "ouvre" le device et commnce à le préparer : static DFBResult driver_open_device(CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data) { int fd; ZytData *data; /* open device */ fd = ZytOpenDevice (dfb_config->zytronic_device); D_INFO("ZYT, driver_open_device %s fd %d\n", dfb_config->zytronic_device,fd); if (fd < 0) { return DFB_INIT; } ZytActivateDevice(fd); //on configure le controleur pour fonctionner en mode normal data = D_CALLOC (1, sizeof(ZytData)); data->fd = fd; data->device = device; /* fill device info structure */ snprintf(info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "Zypos"); snprintf(info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Zytronic"); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* start input thread */ data->thread = direct_thread_create (DTT_INPUT, ZytronicEventThread, data, "Zytronic Input"); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DFBResult mesaInitLayer( CoreLayer *layer, void *driver_data, void *layer_data, DFBDisplayLayerDescription *description, DFBDisplayLayerConfig *config, DFBColorAdjustment *adjustment ) { MesaData *mesa = driver_data; mesa->drmeventcontext.version = DRM_EVENT_CONTEXT_VERSION; mesa->drmeventcontext.vblank_handler = NULL; mesa->drmeventcontext.page_flip_handler = page_flip_handler; description->type = DLTF_GRAPHICS; description->caps = DLCAPS_SURFACE; description->surface_caps = DSCAPS_NONE; description->surface_accessor = CSAID_LAYER0; direct_snputs( description->name, "Mesa Layer", DFB_DISPLAY_LAYER_DESC_NAME_LENGTH ); config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT; config->width = dfb_config->mode.width ?: mesa->mode.hdisplay; config->height = dfb_config->mode.height ?: mesa->mode.vdisplay; config->pixelformat = dfb_config->mode.format ?: DSPF_ARGB; config->buffermode = DLBM_FRONTONLY; direct_mutex_init( &mesa->lock ); direct_waitqueue_init( &mesa->wq_event ); direct_waitqueue_init( &mesa->wq_flip ); mesa->thread = direct_thread_create( DTT_CRITICAL, Mesa_BufferThread_Main, mesa, "Mesa/Buffer" ); return DFB_OK; }
static void vt_start_flushing( void ) { dfb_vt->flush = true; dfb_vt->flush_thread = direct_thread_create( DTT_DEFAULT, vt_flush_thread, NULL, "VT Flusher" ); }
info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; info->desc.max_axis = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(H3600TSData) ); data->fd = fd; data->device = device; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, h3600tsEventThread, data, "H3600 TS Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; } /* * Fetch one entry from the device's keymap if supported. */ static DFBResult driver_get_keymap_entry( CoreInputDevice *device, void *driver_data, DFBInputDeviceKeymapEntry *entry ) {
int main( int argc, char *argv[] ) { DirectResult ret; IFusionDale *dale; int i; //dfb_config_init( &argc, &argv ); ret = FusionDaleInit( &argc, &argv ); if (ret) { D_DERROR( ret, "FusionDaleInit() failed!\n" ); return -1; } ret = FusionDaleCreate( &dale ); if (ret) { D_DERROR( ret, "FusionDaleCreate() failed!\n" ); return -2; } ret = dale->EnterComa( dale, "Coma Test", &coma ); if (ret) { D_DERROR( ret, "IFusionDale::EnterComa('Coma Test') failed!\n" ); return -3; } direct_mutex_init( &decoupled_calls_lock ); direct_waitqueue_init( &decoupled_calls_wq ); for (i=1; i<argc; i++) { if (strncmp( argv[i], "create", 6 ) == 0) { int n, num; int threads = 1; if (sscanf( argv[i]+6, "%d,%d", &num, &threads ) >= 1) { for (n=0; n<num; n++) { RUN_create( n ); } for (n=0; n<threads; n++) { direct_thread_create( DTT_DEFAULT, DecoupledCall_thread_main, NULL, "Process" ); } pause(); } else fprintf( stderr, "Wrong number '%s'!\n", argv[i]+6 ); } else if (strncmp( argv[i], "call", 4 ) == 0) { int index, threads = 1; if (sscanf( argv[i]+4, "%d,%d", &index, &threads ) >= 1) { RUN_call_threaded( index, threads ); } else fprintf( stderr, "Wrong number '%s'!\n", argv[i]+4 ); } } direct_waitqueue_deinit( &decoupled_calls_wq ); direct_mutex_deinit( &decoupled_calls_lock ); coma->Release( coma ); dale->Release( dale ); return 0; }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; int mouseId = -1; int flags; PS2MouseData *data; /* open device */ flags = (dfb_config->mouse_gpm_source) ? (O_RDONLY | O_NONBLOCK) : (O_RDWR | O_SYNC | O_EXCL); fd = open( devlist[number], flags ); if (fd < 0) { D_PERROR( "DirectFB/PS2Mouse: failed opening `%s' !\n", devlist[number] ); close( fd ); return DFB_INIT; } fcntl( fd, F_SETFL, fcntl ( fd, F_GETFL ) & ~O_NONBLOCK ); if (!dfb_config->mouse_gpm_source) { mouseId = init_ps2( fd, true ); if (mouseId < 0) { D_PERROR( "DirectFB/PS2Mouse: could not initialize mouse on `%s'!\n", devlist[number] ); close( fd ); return DFB_INIT; } } if (dfb_config->mouse_protocol) { if (strcasecmp( dfb_config->mouse_protocol, "IMPS/2" ) == 0) { mouseId = PS2_ID_IMPS2; } else if (strcasecmp( dfb_config->mouse_protocol, "PS/2" ) == 0) { mouseId = PS2_ID_PS2; } else { D_ERROR( "DirectFB/PS2Mouse: unsupported protocol `%s' !\n", dfb_config->mouse_protocol ); close( fd ); return DFB_INIT; } } /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, (mouseId == PS2_ID_IMPS2) ? "IMPS/2 Mouse" : "PS/2 Mouse" ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Unknown" ); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; #ifndef DIRECTFB_DISABLE_DEPRECATED info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; #else info->desc.caps = DIDCAPS_AXES | DIDCAPS_BUTTONS; #endif info->desc.max_axis = (mouseId == PS2_ID_IMPS2) ? DIAI_Z : DIAI_Y; info->desc.max_button = DIBI_MIDDLE; /* TODO: probe!? */ /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(PS2MouseData) ); if (!data) { close( fd ); return D_OOM(); } data->fd = fd; data->device = device; data->mouseId = mouseId; data->packetLength = (mouseId == PS2_ID_IMPS2) ? 4 : 3; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, ps2mouseEventThread, data, "PS/2 Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static DFBResult vt_init_switching() { const char cursoroff_str[] = "\033[?1;0;0c"; const char blankoff_str[] = "\033[9;0]"; char buf[32]; D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); /* FIXME: Opening the device should be moved out of this function. */ snprintf(buf, 32, "/dev/tty%d", dfb_vt->num); dfb_vt->fd = open( buf, O_RDWR | O_NOCTTY ); if (dfb_vt->fd < 0) { if (errno == ENOENT) { snprintf(buf, 32, "/dev/vc/%d", dfb_vt->num); dfb_vt->fd = open( buf, O_RDWR | O_NOCTTY ); if (dfb_vt->fd < 0) { if (errno == ENOENT) { D_PERROR( "DirectFB/core/vt: Couldn't open " "neither `/dev/tty%d' nor `/dev/vc/%d'!\n", dfb_vt->num, dfb_vt->num ); } else { D_PERROR( "DirectFB/core/vt: " "Error opening `%s'!\n", buf ); } return errno2result( errno ); } } else { D_PERROR( "DirectFB/core/vt: Error opening `%s'!\n", buf ); return errno2result( errno ); } } /* attach to the new TTY before doing anything like KDSETMODE with it, otherwise we'd get access denied error: */ ioctl( dfb_vt->fd, TIOCSCTTY, 0 ); write( dfb_vt->fd, cursoroff_str, sizeof(cursoroff_str) ); if (dfb_config->kd_graphics) { if (ioctl( dfb_vt->fd, KDSETMODE, KD_GRAPHICS ) < 0) { D_PERROR( "DirectFB/fbdev/vt: KD_GRAPHICS failed!\n" ); close( dfb_vt->fd ); return DFB_INIT; } } else { write( dfb_vt->fd, blankoff_str, sizeof(blankoff_str) ); } if (dfb_config->vt_switching) { struct vt_mode vt; struct sigaction sig_tty; memset( &sig_tty, 0, sizeof( sig_tty ) ); sig_tty.sa_handler = vt_switch_handler; sigfillset( &sig_tty.sa_mask ); if (sigaction( SIG_SWITCH_FROM, &sig_tty, &dfb_vt->sig_usr1 ) || sigaction( SIG_SWITCH_TO, &sig_tty, &dfb_vt->sig_usr2 )) { D_PERROR( "DirectFB/fbdev/vt: sigaction failed!\n" ); close( dfb_vt->fd ); return DFB_INIT; } vt.mode = VT_PROCESS; vt.waitv = 0; vt.relsig = SIG_SWITCH_FROM; vt.acqsig = SIG_SWITCH_TO; if (ioctl( dfb_vt->fd, VT_SETMODE, &vt ) < 0) { D_PERROR( "DirectFB/fbdev/vt: VT_SETMODE failed!\n" ); sigaction( SIG_SWITCH_FROM, &dfb_vt->sig_usr1, NULL ); sigaction( SIG_SWITCH_TO, &dfb_vt->sig_usr2, NULL ); close( dfb_vt->fd ); return DFB_INIT; } direct_util_recursive_pthread_mutex_init( &dfb_vt->lock ); pthread_cond_init( &dfb_vt->wait, NULL ); dfb_vt->vt_sig = -1; dfb_vt->thread = direct_thread_create( DTT_CRITICAL, vt_thread, NULL, "VT Switcher" ); } return DFB_OK; }
int main(int argc, char *argv[]) { IDirectFBDisplayLayer *layer; DFBWindowDescription dwsc; DFBSurfaceDescription dsc; DFBDisplayLayerConfig config; IDirectFBWindow *window_mic, *window_camera, *window_case, *window_tp; IDirectFBSurface *surface_case, *surface_tp, *surface_camera; IDirectFBSurface *surface_mic, *primary, *surface_button; IDirectFBFont *font; DFBRectangle rect; DFBFontDescription font_desc; DirectThread *thread_camera, *thread_music, *thread_mic, *thread_tp, *thread_flashlight, *thread_case[case_num]; DirectThread *thread_button; // int font_size = 24; // int camera_frame = 0; int i; char font_file[50] = "/misc/font/wqy-zenhei.ttc"; char conf_file[50] = "/misc/pcba.conf"; bool overflow = false; case_t *case_x; case_x = malloc((case_num + 3) * sizeof(case_t)); //20 case,11 auto case,gps is the last autocase init_case(case_x, case_num + 3, gps + 1); if(parser_config_file(conf_file, case_x)) { printf("config file open error, use default\n"); } parse_global_config(case_x); printf("camera_frame = %d\n", camera_frame); printf("font_size = %d\n", font_size); printf("camera pixel [%d*%d]\n", camera_pixel_width, camera_pixel_height); #ifndef __GS900A__ ion_open_alc(); #endif //define window size int screen_width, screen_height; int mic_width, camera_window_width, camera_window_height; int case_width, case_name_align, case_result_align; int font_height; //change env char event_path[100]; char env_gsensor[256]; //enable gsensor i = get_input_event_name(case_x[gsensor].dev_name, event_path); if(i != -1) { sprintf(env_gsensor, "echo 1 > /sys/class/input/input%d/enable", i); system(env_gsensor); } else { printf("----error! gsensor not found\n"); } //vibrate test for 3 second test_vibrate(3); //dfb init DFBCHECK(DirectFBInit(&argc, &argv)); DFBCHECK(DirectFBCreate(&dfb)); font_desc.flags = DFDESC_HEIGHT; font_desc.height = font_size; DFBCHECK(dfb->CreateFont( dfb, font_file, &font_desc, &font)); DFBCHECK(font->GetHeight(font, &font_height)); DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer)); DFBCHECK(layer->GetConfiguration( layer, &config )); // DFBCHECK(layer->SetRotation( layer, 180 )); //set window size screen_width = config.width; screen_height = config.height; mic_width = screen_width / 20; camera_window_width = (screen_width - mic_width) / 2; camera_window_height = screen_height / 2; case_width = screen_width - mic_width - camera_window_width; case_name_align = font_size; case_result_align = 7 * font_size; //create tp window dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS; dwsc.posx = 0; dwsc.posy = 0; dwsc.width = screen_width; dwsc.height = screen_height; dwsc.caps = DWCAPS_ALPHACHANNEL; DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_tp)); DFBCHECK(window_tp->GetSurface(window_tp, &surface_tp)); DFBCHECK(window_tp->SetOptions(window_tp, DWOP_ALPHACHANNEL)); DFBCHECK(window_tp->SetStackingClass(window_tp, DWSC_UPPER)); DFBCHECK(window_tp->RaiseToTop(window_tp)); DFBCHECK(surface_tp->Clear(surface_tp, 0, 0, 0, 0)); DFBCHECK(surface_tp->SetColor(surface_tp, 0, 0xff, 0, 0xff)); DFBCHECK(window_tp->SetOpacity(window_tp, 0xff)); //config camera window dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT; dwsc.posx = case_width + mic_width; dwsc.posy = 0; dwsc.width = camera_window_width; dwsc.height = screen_height; DFBCHECK(layer->CreateWindow( layer, &dwsc, &window_camera )); DFBCHECK(window_camera->GetSurface(window_camera, &windowsurface)); DFBCHECK(windowsurface->SetColor(windowsurface, 0, 0, 0, 0xff)); DFBCHECK(windowsurface->FillRectangle(windowsurface, 0, 0, camera_window_width , screen_height)); DFBCHECK(windowsurface->Flip(windowsurface, NULL, 0)); DFBCHECK(window_camera->SetOpacity( window_camera, 0xff )); drawRGB(windowsurface, 0, screen_height / 2, camera_window_width, screen_height /2); rect.x = 0; rect.y = 0; rect.w = camera_window_width; rect.h = camera_window_height; DFBCHECK(windowsurface->GetSubSurface(windowsurface, &rect, &surface_camera)); rect.x = 0; rect.y = screen_height / 4 * 3; rect.w = camera_window_width; rect.h = screen_height - rect.y; DFBCHECK(windowsurface->GetSubSurface(windowsurface, &rect, &surface_button)); //create camera surface dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; dsc.pixelformat = DSPF_NV12; dsc.width = camera_pixel_width; dsc.height = camera_pixel_height; DFBCHECK(dfb->CreateSurface(dfb, &dsc, &camera_source)); //config mic window dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT; dwsc.posx = case_width; dwsc.posy = 0; dwsc.width = mic_width; dwsc.height = screen_height; DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_mic)); DFBCHECK(window_mic->GetSurface(window_mic, &surface_mic)); DFBCHECK(surface_mic->SetColor(surface_mic, 0, 0, 0, 0xff)); DFBCHECK(surface_mic->FillRectangle(surface_mic, 0, 0, mic_width , screen_height)); DFBCHECK(surface_mic->Flip(surface_mic, NULL, 0)); DFBCHECK(window_mic->SetOpacity( window_mic, 0xff)); //config case window dwsc.posx = 0; dwsc.posy = 0; dwsc.width = case_width; dwsc.height = screen_height; DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_case)); DFBCHECK(window_case->GetSurface(window_case, &surface_case)); DFBCHECK(surface_case->SetColor(surface_case, 0xff, 0xff, 0xff, 0xff)); DFBCHECK(surface_case->SetFont(surface_case, font)); DFBCHECK(surface_case->FillRectangle(surface_case, 0, 0, case_width, screen_height)); //draw headline DFBCHECK(surface_case->SetColor(surface_case, 0xff, 0xff, 0, 0xff)); DFBCHECK(surface_case->FillRectangle(surface_case, 0, 0, case_width, font_size + 2)); DFBCHECK(surface_case->FillRectangle(surface_case, 0, screen_height / 2, case_width, font_size + 2)); DFBCHECK(surface_case->SetColor(surface_case, 0, 0, 0, 0xff)); DFBCHECK(surface_case->DrawString(surface_case, "自动测试选项", -1, case_width / 2, 0, DSTF_TOPCENTER)); DFBCHECK(surface_case->DrawString(surface_case, "手动测试选项", -1, case_width / 2, screen_height / 2, DSTF_TOPCENTER)); int auto_skip = 0; int manu_skip = 0; int skip_height = 0; bool double_line = false; //draw string for(i = 0; i < case_num; i++) { double_line = false; if(overflow) { case_x[i].enable = 0; continue; } if(!case_x[i].enable) { if(case_x[i].type) manu_skip++; else auto_skip++; //case_x[i].position = -1; continue; } if(case_x[i].doubleline == 1) { double_line = true; } if(case_x[i].type) skip_height = manu_skip * (font_height); else skip_height = auto_skip * (font_height); case_x[i].position = case_x[i].type * screen_height / 2 + (case_x[i].index + 1) * (font_height); case_x[i].position -= skip_height; // printf("name_h = %d\n", case_x[i].position); DFBCHECK(surface_case->SetColor(surface_case, 0, 0, 0, 0xff)); DFBCHECK(surface_case->DrawString(surface_case, case_x[i].name, -1, case_name_align, case_x[i].position, DSTF_TOPLEFT)); DFBCHECK(surface_case->SetColor(surface_case, 0xc0, 0xc0, 0xc0, 0xff)); DFBCHECK(surface_case->DrawString(surface_case, case_x[i].init_string, -1, case_result_align, case_x[i].position, DSTF_TOPLEFT)); rect.x = case_result_align; rect.y = case_x[i].position; rect.w = case_width - case_result_align; rect.h = font_height; if((rect.y + rect.h) > screen_height) { overflow = true; case_x[i].enable = 0; printf("case %d overflow, disable all case after it\n", i); continue; } if(double_line) { // case_x[i].position = -2; rect.h *= 2; if(case_x[i].type) manu_skip--; else auto_skip--; } DFBCHECK(surface_case->GetSubSurface(surface_case, &rect, &case_x[i].surface)); DFBCHECK(case_x[i].surface->SetFont(case_x[i].surface, font)); } DFBCHECK(window_case->SetOpacity(window_case, 0xff )); #ifdef __GS900A__ system("echo 1 > /sys/devices/e0250000.hdmi/enable"); #endif //start case thread for(i = 0; i < case_num; i++) { char thread_name[10]; sprintf(thread_name,"thread_%d", i); if(case_x[i].enable) { thread_case[i] = direct_thread_create(DTT_DEFAULT, case_thread, &case_x[i], thread_name); } } case_x[tp].surface = surface_tp; //start thread #ifdef __GS702C__ thread_music = direct_thread_create(DTT_DEFAULT, music_thread, NULL, "music"); thread_mic = direct_thread_create(DTT_DEFAULT, mic_thread, surface_mic, "mic"); #else thread_music = direct_thread_create(DTT_DEFAULT, tinyalsa_music_thread, NULL, "tinyalsa_music"); thread_mic = direct_thread_create(DTT_DEFAULT, tinyalsa_mic_thread, surface_mic, "tinyalsa_mic"); #endif thread_tp = direct_thread_create(DTT_DEFAULT, tp_thread, &case_x[tp], "tp"); thread_flashlight = direct_thread_create(DTT_DEFAULT, flashlight_thread, &case_x[flashlight], "flashlight"); thread_camera = direct_thread_create(DTT_DEFAULT, camera_thread, &camera_frame, "camera" ); //thread_mic = direct_thread_create(DTT_DEFAULT, mic_thread, surface_mic, "mic"); thread_button = direct_thread_create(DTT_DEFAULT, handle_record_button, surface_button, "button"); sleep(1); DFBCHECK(surface_case->Flip(surface_case, NULL, 0)); if(iio_read(info, case_x[gsensor].enable, case_x[gyro].enable, case_x[comp].enable) == -1) printf("get iio device error\n"); //block in iio_read //useless statement for(i = 0; i < case_num; i++) { if(case_x[i].enable) { direct_thread_join(thread_case[i]); case_x[i].surface->Release(case_x[i].surface); direct_thread_destroy(thread_case[i]); printf("thread %d destroyed\n", i); } } direct_thread_join(thread_camera); direct_thread_destroy(thread_camera); direct_thread_join(thread_music); direct_thread_destroy(thread_music); direct_thread_join(thread_mic); direct_thread_destroy(thread_mic); surface_button->Release(surface_button); surface_camera->Release(surface_camera); camera_source->Release(camera_source); windowsurface->Release(windowsurface); window_camera->Release(window_camera); surface_case->Release(surface_case); window_case->Release(window_case); layer->Release(layer); font->Release(font); dfb->Release(dfb); #ifndef __GS900A__ ion_close_alc(); #endif }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; struct termios ts; KeyboardData *data; if (dfb_system_type() == CORE_FBDEV && dfb_config->vt) { FBDev *dfb_fbdev = dfb_system_data(); fd = dup( dfb_fbdev->vt->fd ); if (fd < 0) { D_PERROR( "DirectFB/Keyboard: Could not dup() file descriptor of TTY!\n" ); return DFB_INIT; } /* put keyboard into medium raw mode */ if (ioctl( fd, KDSKBMODE, K_MEDIUMRAW ) < 0) { D_PERROR( "DirectFB/Keyboard: K_MEDIUMRAW failed!\n" ); return DFB_INIT; } } else { fd = open( "/dev/tty0", O_RDWR | O_NOCTTY ); if (fd < 0) { D_PERROR( "DirectFB/Keyboard: Could not open() /dev/tty0!\n" ); return DFB_INIT; } } /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(KeyboardData) ); data->device = device; data->vt_fd = fd; tcgetattr( data->vt_fd, &data->old_ts ); ts = data->old_ts; ts.c_cc[VTIME] = 0; ts.c_cc[VMIN] = 1; ts.c_lflag &= ~(ICANON|ECHO|ISIG); ts.c_iflag = 0; tcsetattr( data->vt_fd, TCSAFLUSH, &ts ); tcsetpgrp( data->vt_fd, getpgrp() ); /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "Keyboard" ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Unknown" ); /* claim to be the primary keyboard */ info->prefered_id = DIDID_KEYBOARD; /* classify as a keyboard able to produce key events */ info->desc.type = DIDTF_KEYBOARD; info->desc.caps = DICAPS_KEYS; /* enable translation of raw hardware keycodes */ info->desc.min_keycode = 0; info->desc.max_keycode = 127; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, keyboardEventThread, data, "Keyboard Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static void TestResize( IDirectFB *dfb ) { DFBResult ret; DirectThread *thread; DFBWindowDescription desc; IDirectFBDisplayLayer *layer; IDirectFBWindow *window; IDirectFBSurface *surface; DFBInputEvent evt; IDirectFBEventBuffer *keybuffer; quit = 0; /* Create an input buffer for key events */ ret = dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS, DFB_FALSE, &keybuffer); if (ret) { D_DERROR( ret, "DFBTest/Resize: CreateInputBuffer() failed!\n" ); return; } ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ); if (ret) { D_DERROR( ret, "DFBTest/Resize: Failed to get display layer!\n" ); keybuffer->Release( keybuffer ); return; } desc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT; desc.width = 500; desc.height = 500; desc.pixelformat = DSPF_ARGB; ret = layer->CreateWindow( layer, &desc, &window ); if (ret) { D_DERROR( ret, "DFBTest/Resize: CreateWindow() failed!\n" ); keybuffer->Release( keybuffer ); layer->Release( layer ); return; } ret = window->GetSurface( window, &surface ); if (ret) { D_DERROR( ret, "DFBTest/Resize: GetSurface() failed!\n" ); keybuffer->Release( keybuffer ); window->Release( window ); layer->Release( layer ); return; } thread = direct_thread_create( DTT_DEFAULT, TestThread, surface, "Test" ); while (!quit) { ret = window->Resize( window, 500, 400 ); if (ret) D_DERROR( ret, "DFBTest/Resize: Resize() failed!\n" ); ret = window->Resize( window, 500, 500 ); if (ret) D_DERROR( ret, "DFBTest/Resize: Resize() failed!\n" ); /* Process keybuffer */ while (keybuffer->GetEvent( keybuffer, DFB_EVENT(&evt)) == DFB_OK) { if (evt.type == DIET_KEYPRESS) { switch (DFB_LOWER_CASE(evt.key_symbol)) { case DIKS_ESCAPE: case DIKS_SMALL_Q: case DIKS_BACK: case DIKS_STOP: case DIKS_EXIT: /* Quit main loop & test thread */ quit = 1; direct_thread_join(thread); break; default: break; } } } } keybuffer->Release( keybuffer ); surface->Release( surface ); window->Release( window ); layer->Release( layer ); }
int fusion_init( int world, int abi_version, int *world_ret ) { char buf[20]; FusionEnter enter; /* Check against multiple initialization. */ if (_fusion_id) { /* Increment local reference counter. */ fusion_refs++; return _fusion_id; } direct_initialize(); /* Open Fusion Kernel Device. */ if (world < 0) { for (world=0; world<256; world++) { snprintf( buf, sizeof(buf), "/dev/fusion/%d", world ); _fusion_fd = open (buf, O_RDWR | O_NONBLOCK | O_EXCL); if (_fusion_fd < 0) { if (errno == EBUSY) continue; D_PERROR( "Fusion/Init: opening '%s' failed!\n", buf ); direct_shutdown(); return -1; } else break; } } else { snprintf( buf, sizeof(buf), "/dev/fusion/%d", world ); _fusion_fd = open (buf, O_RDWR | O_NONBLOCK); if (_fusion_fd < 0) { D_PERROR( "Fusion/Init: opening '%s' failed!\n", buf ); direct_shutdown(); return -1; } } enter.api.major = FUSION_API_MAJOR; enter.api.minor = FUSION_API_MINOR; enter.fusion_id = 0; /* Get our Fusion ID. */ if (ioctl( _fusion_fd, FUSION_ENTER, &enter )) { D_PERROR( "Fusion/Init: FUSION_ENTER failed!\n" ); goto error; } if (!enter.fusion_id) { D_ERROR( "Fusion/Init: Got no ID from FUSION_ENTER! Kernel module might be too old.\n" ); goto error; } _fusion_id = enter.fusion_id; /* Initialize local reference counter. */ fusion_refs = 1; /* Initialize shmalloc part. */ if (!__shmalloc_init( world, _fusion_id == 1 )) { D_ERROR( "Fusion/Init: Shared memory initialization failed.\n" "\n" "Please make sure that a tmpfs mount point with at least 4MB of free space\n" "is available for read/write, see the DirectFB README for more instructions.\n" ); goto error; } if (_fusion_id == 1) { _fusion_shared = __shmalloc_allocate_root( sizeof(FusionShared) ); _fusion_shared->abi_version = abi_version; fusion_skirmish_init( &_fusion_shared->arenas_lock, "Fusion Arenas" ); fusion_skirmish_init( &_fusion_shared->reactor_globals, "Fusion Reactor Globals" ); _sheap->reactor = fusion_reactor_new( sizeof(long), "Shared Memory Heap" ); if (!_sheap->reactor) { __shmalloc_exit( true, true ); goto error_reactor; } gettimeofday( &_fusion_shared->start_time, NULL ); } else { _fusion_shared = __shmalloc_get_root(); if (_fusion_shared->abi_version != abi_version) { D_ERROR( "Fusion/Init: ABI version mismatch (my: %d, their: %d)\n", abi_version, _fusion_shared->abi_version ); __shmalloc_exit( false, false ); goto error; } } __shmalloc_attach(); direct_clock_set_start( &_fusion_shared->start_time ); direct_signal_handler_add( SIGSEGV, fusion_signal_handler, NULL, &signal_handler ); read_loop = direct_thread_create( DTT_MESSAGING, fusion_read_loop, NULL, "Fusion Dispatch" ); if (world_ret) *world_ret = world; return _fusion_id; error_reactor: fusion_skirmish_destroy( &_fusion_shared->arenas_lock ); fusion_skirmish_destroy( &_fusion_shared->reactor_globals ); error: _fusion_shared = NULL; _fusion_id = 0; close( _fusion_fd ); _fusion_fd = -1; direct_shutdown(); return -1; }