static void
IComaComponent_One_Destruct( IComaComponent *thiz )
{
     int                      i;
     IComaComponent_One_data *data = thiz->priv;

     D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );

     /* If method_func is non-NULL, we're the creator */
     if (data->method_func) {
          if (data->dispatch_thread) {
               data->dispatch_stop = true;

               OneQueue_WakeUp( &data->method_qid, 1 );

               direct_thread_join( data->dispatch_thread );
               direct_thread_destroy( data->dispatch_thread );
          }

          OneQueue_Destroy( data->method_qid );

          for (i=0; i<data->num_notifications; i--)
               OneQueue_Destroy( data->notifications[i].qid );
     }


     data->notify_stop = true;

     OneQueue_WakeUp( &data->notify_qid, 1 );

     if (data->notify_thread) {
          direct_thread_join( data->notify_thread );
          direct_thread_destroy( data->notify_thread );
     }

     OneQueue_Destroy( data->notify_qid );


     direct_hash_iterate( data->calls, call_iterator, data );
     direct_hash_destroy( data->calls );
     direct_mutex_deinit( &data->calls_lock );

     if (data->notifications)
          D_FREE( data->notifications );

     if (data->listeners)
          D_FREE( data->listeners );

     One_Shutdown();

     DIRECT_DEALLOCATE_INTERFACE( thiz );
}
Exemple #2
0
void
VoodooConnectionPacket::Stop()
{
     D_DEBUG_AT( Voodoo_Connection, "VoodooConnectionPacket::%s( %p )\n", __func__, this );

     D_MAGIC_ASSERT( this, VoodooConnection );

     direct_mutex_lock( &output.lock );

     while (!closed && output.packets) {
          D_DEBUG_AT( Voodoo_Connection, "  -> waiting for output packets to be sent...\n" );

          direct_waitqueue_wait( &output.wait, &output.lock );
     }

     direct_mutex_unlock( &output.lock );

     stop = true;

     link->WakeUp( link );

     /* Wait for manager threads exiting. */
     direct_thread_join( io );
     direct_thread_destroy( io );

     VoodooConnectionLink::Stop();
}
Exemple #3
0
/*
 * End thread, close device and free private data.
 */
static void
driver_close_device( void *driver_data )
{
     X11InputData *data   = driver_data;
     DFBX11       *x11    = data->x11;
     DFBX11Shared *shared = x11->shared;

     D_DEBUG_AT( X11_Input, "%s()\n", __FUNCTION__ );

     /* stop input thread */
     data->stop = true;

     if (!shared->x_error) {
          XLockDisplay( x11->display );
          XSync( x11->display, False );
          XUnlockDisplay( x11->display );
     }

     /* 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 );
}
Exemple #4
0
static void
driver_close_device( void *driver_data )
{
    KeyboardData *data = (KeyboardData*) driver_data;

    /* stop input thread */
    direct_thread_cancel( data->thread );
    direct_thread_join( data->thread );
    direct_thread_destroy( data->thread );

    if (tcsetattr( data->vt_fd, TCSAFLUSH, &data->old_ts ) < 0)
        D_PERROR("DirectFB/keyboard: tcsetattr for original values failed!\n");

    if (dfb_system_type() == CORE_FBDEV && dfb_config->vt) {
        if (ioctl( data->vt_fd, KDSKBMODE, K_XLATE ) < 0)
            D_PERROR("DirectFB/keyboard: Could not set mode to XLATE!\n");
        if (ioctl( data->vt_fd, KDSETMODE, KD_TEXT ) < 0)
            D_PERROR("DirectFB/keyboard: Could not set terminal mode to text!\n");
    }

    close( data->vt_fd );

    /* free private data */
    D_FREE( data );
}
Exemple #5
0
DFBResult
CoreInputHubClient_Destroy( CoreInputHubClient *client )
{
     D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ );

     OneThread_Destroy( client->thread );

     OneQueue_Destroy( client->listen_qid );

     if (client->activate_thread) {
          direct_mutex_lock( &client->lock );

          client->activate_stop = true;

          direct_waitqueue_broadcast( &client->wq );

          direct_mutex_unlock( &client->lock );


          direct_thread_join( client->activate_thread );
          direct_thread_destroy( client->activate_thread );
     }

     direct_mutex_deinit( &client->lock );
     direct_waitqueue_deinit( &client->wq );

     D_FREE( client );

     return DFB_OK;
}
Exemple #6
0
DirectResult
voodoo_manager_destroy( VoodooManager *manager )
{
     D_MAGIC_ASSERT( manager, VoodooManager );

     D_DEBUG( "Voodoo/Manager: Destroying manager at %p!\n", manager );

     if (!manager->quit)
          voodoo_manager_quit( manager );

     /* Wait for manager threads exiting. */
     direct_thread_join( manager->input.thread );
     direct_thread_destroy( manager->input.thread );

     direct_thread_join( manager->dispatcher );
     direct_thread_destroy( manager->dispatcher );

     direct_thread_join( manager->output.thread );
     direct_thread_destroy( manager->output.thread );

     /* Destroy conditions. */
     pthread_cond_destroy( &manager->input.wait );
     pthread_cond_destroy( &manager->response.wait );
     pthread_cond_destroy( &manager->output.wait );

     /* Destroy locks. */
     pthread_mutex_destroy( &manager->instances.lock );
     pthread_mutex_destroy( &manager->input.lock );
     pthread_mutex_destroy( &manager->response.lock );
     pthread_mutex_destroy( &manager->output.lock );

     /* Release all remaining interfaces. */
     direct_hash_iterate( manager->instances.local, instance_iterator, (void*) false );
     direct_hash_iterate( manager->instances.local, instance_iterator, (void*) true );
     direct_hash_destroy( manager->instances.local );

     direct_hash_destroy( manager->instances.remote );

     D_MAGIC_CLEAR( manager );

     /* Deallocate manager structure. */
     D_FREE( manager );

     return DR_OK;
}
static void
IDirectFBVideoProvider_Xine_Destruct( IDirectFBVideoProvider *thiz )
{
     IDirectFBVideoProvider_Xine_data *data = thiz->priv;

     if (data->xine) {
          if (data->stream) {              
               xine_stop( data->stream );

               xine_close( data->stream );

               if (data->queue)
                    xine_event_dispose_queue( data->queue );
               
               xine_dispose( data->stream );
          }

          if (data->post)
               xine_post_dispose( data->xine, data->post );

          if (data->vo)
               xine_close_video_driver( data->xine, data->vo );

          if (data->ao)
               xine_close_audio_driver( data->xine, data->ao );

          if (data->cfg) {
               xine_config_save( data->xine, data->cfg );
               D_FREE( data->cfg );
          }

          xine_exit( data->xine );
     }

     if (data->buffer_thread) {
          direct_thread_cancel( data->buffer_thread );
          direct_thread_join( data->buffer_thread );
          direct_thread_destroy( data->buffer_thread );
     }
 
     if (data->buffer)
          data->buffer->Release( data->buffer );

     if (data->pipe) {
          unlink( data->pipe );
          D_FREE( data->pipe );
     }

     if (data->events)
          data->events->Release( data->events );

     D_FREE( data->mrl );

     pthread_mutex_destroy( &data->lock );
     
     DIRECT_DEALLOCATE_INTERFACE( thiz );
}
Exemple #8
0
static void
vt_stop_flushing( void )
{
     dfb_vt->flush = false;
     direct_thread_cancel( dfb_vt->flush_thread );
     direct_thread_join( dfb_vt->flush_thread );
     direct_thread_destroy( dfb_vt->flush_thread );
     dfb_vt->flush_thread = NULL;
}
Exemple #9
0
void
fusion_exit( bool emergency )
{
     int               foo;
     FusionSendMessage msg;

     D_ASSERT( fusion_refs > 0 );

     /* decrement local reference counter */
     if (--fusion_refs)
          return;

     if (!emergency) {
          /* Wake up the read loop thread. */
          msg.fusion_id = _fusion_id;
          msg.msg_id    = 0;
          msg.msg_data  = &foo;
          msg.msg_size  = sizeof(foo);

          while (ioctl( _fusion_fd, FUSION_SEND_MESSAGE, &msg ) < 0) {
               if (errno != EINTR) {
                    D_PERROR ("FUSION_SEND_MESSAGE");
                    break;
               }
          }

          /* Wait for its termination. */
          direct_thread_join( read_loop );
     }

     direct_thread_destroy( read_loop );

     direct_signal_handler_remove( signal_handler );

     /* Master has to deinitialize shared data. */
     if (_fusion_id == 1) {
          fusion_skirmish_destroy( &_fusion_shared->reactor_globals );
          fusion_skirmish_destroy( &_fusion_shared->arenas_lock );
     }

     _fusion_shared = NULL;

     /* Deinitialize or leave shared memory. */
     __shmalloc_exit( _fusion_id == 1, true );

     /* Reset local dispatch nodes. */
     _fusion_reactor_free_all();

     _fusion_id = 0;

     if (close( _fusion_fd ))
          D_PERROR( "Fusion/Exit: closing the fusion device failed!\n" );
     _fusion_fd = -1;

     direct_shutdown();
}
Exemple #10
0
static void driver_close_device(void *driver_data){
     PeMData *data = (PeMData *)driver_data;

     /* stop input thread */
     direct_thread_cancel (data->thread);
     direct_thread_join (data->thread);
     direct_thread_destroy (data->thread);

     /* close device */
     close (data->fd);

     /* free private data */
     D_FREE (data);
}
Exemple #11
0
/*
 * End thread, close device and free private data.
 */
static void
driver_close_device( void *driver_data )
{
     SDLInputData *data = (SDLInputData*) driver_data;

     /* stop input thread */
     data->stop = 1;

     direct_thread_join( data->thread );
     direct_thread_destroy( data->thread );

     /* free private data */
     D_FREE ( data );
}
// "fermeture" du driver ***
static void driver_close_device(void *driver_data)
{
     ZytData *data = (ZytData *)driver_data;

     /* stop input thread */
     direct_thread_cancel (data->thread);
     direct_thread_join (data->thread);
     direct_thread_destroy (data->thread);

     /* close device */
     tcsetattr(data->fd,TCSANOW,&saved_options); // remise en l'état de l'ancienne configuration du port
     close (data->fd);

     /* free private data */
     D_FREE (data);
}
Exemple #13
0
static DFBResult
system_shutdown( bool emergency )
{
     FusionSHMPoolShared *pool;

     D_ASSERT( dfb_sdl != NULL );

     /* Stop update thread. */
     if (dfb_sdl->update.thread) {
          if (!emergency) {
               dfb_sdl->update.quit = true;

               pthread_cond_signal( &dfb_sdl->update.cond );

               direct_thread_join( dfb_sdl->update.thread );
          }

          direct_thread_destroy( dfb_sdl->update.thread );
     }

     dfb_surface_pool_destroy( dfb_sdl->sdl_pool );

     fusion_call_destroy( &dfb_sdl->call );

     fusion_skirmish_prevail( &dfb_sdl->lock );

     SDL_Quit();

     fusion_skirmish_destroy( &dfb_sdl->lock );

     pool = dfb_core_shmpool(dfb_sdl_core);

     while (dfb_sdl->modes) {
          VideoMode *next = dfb_sdl->modes->next;

          SHFREE( pool, dfb_sdl->modes );

          dfb_sdl->modes = next;
     }

     SHFREE( pool, dfb_sdl );
     dfb_sdl = NULL;
     dfb_sdl_core = NULL;

     return DFB_OK;
}
Exemple #14
0
static void
driver_close_device( void *driver_data )
{
     WM97xxTSData *data = (WM97xxTSData*) driver_data;

     /* stop input thread */
     direct_thread_cancel( data->thread );
     direct_thread_join( data->thread );
     direct_thread_destroy( data->thread );

     /* close device */
     if (close( data->fd ) < 0)
          D_PERROR( "DirectFB/WM97xx: Error closing `/dev/touchscreen/wm97xx'!\n" );

     /* free private data */
     D_FREE( data );
}
Exemple #15
0
static void driver_close_device(void *driver_data)
{
  eloData *data = (eloData *)driver_data;

  /* stop input thread */
  direct_thread_cancel(data->thread);
  direct_thread_join(data->thread);
  direct_thread_destroy(data->thread);

  /* restore termnial settings for the port */
  tty_rawmode(data->fd,0);

  /* close device */
  close(data->fd);

  /* free private data */
  D_FREE(data);
}
Exemple #16
0
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;
}
Exemple #17
0
DirectResult
direct_processor_destroy( DirectProcessor *processor )
{
     void *item;

     D_MAGIC_ASSERT( processor, DirectProcessor );

     D_DEBUG_AT( Direct_Processor, "%s( %p '%s' )\n", __FUNCTION__, processor, processor->name );

     processor->stop = true;

     direct_thread_terminate( processor->thread );

     direct_fifo_wakeup( &processor->commands );
     direct_fifo_wakeup( &processor->recycled );

     direct_thread_join( processor->thread );
     direct_thread_destroy( processor->thread );


     while ((item = direct_fifo_pull( &processor->commands )) != NULL)
          D_FREE( item );
          
     direct_fifo_destroy( &processor->commands );


     while ((item = direct_fifo_pull( &processor->recycled )) != NULL)
          D_FREE( item );

     direct_fifo_destroy( &processor->recycled );


#if 0
     direct_waitqueue_deinit( &processor->lock_cond );
     direct_mutex_deinit( &processor->lock_mutex );
#endif

     D_FREE( processor->name );

     D_MAGIC_CLEAR( processor );

     return DR_OK;
}
Exemple #18
0
void
__D_perf_deinit()
{
     if (counter_dump_thread) {
          DirectThread *thread = counter_dump_thread;

          direct_thread_lock( thread );
          counter_dump_thread = NULL;
          direct_thread_notify( thread );
          direct_thread_unlock( thread );

          direct_thread_join( thread );
          direct_thread_destroy( thread );
     }

     //direct_perf_dump_all();

     direct_hash_deinit( &counter_hash );
     direct_mutex_deinit( &counter_lock );
}
Exemple #19
0
static void
driver_close_device( void *driver_data )
{
     ucb1x00TSData *data = (ucb1x00TSData*) driver_data;

     /* stop input thread */
     direct_thread_cancel( data->thread );
     direct_thread_join( data->thread );
     direct_thread_destroy( data->thread );

     /* close device */
     if (close( data->fd ) < 0)
          D_PERROR( "DirectFB/ucb1x00: Error closing `/dev/ucb1x00-ts'!\n" );

     if (event_buffer)
          free( event_buffer );

     /* free private data */
     D_FREE( data );
}
Exemple #20
0
DirectResult
direct_signals_shutdown( void )
{
     D_DEBUG_AT( Direct_Signals, "Shutting down...\n" );
#ifdef ANDROID_NDK
     remove_handlers();
#else
     if (direct_config->sighandler_thread) {
          if (sighandler_thread) {
               direct_thread_kill( sighandler_thread, SIG_CLOSE_SIGHANDLER );
               direct_thread_join( sighandler_thread );
               direct_thread_destroy( sighandler_thread );
               sighandler_thread = NULL;
          }
     }
     else
          remove_handlers();
#endif
     direct_mutex_deinit( &handlers_lock );

     return DR_OK;
}
static void
IDirectFBEventBuffer_Requestor_Destruct( IDirectFBEventBuffer *thiz )
{
     IDirectFBEventBuffer_Requestor_data *data = thiz->priv;

     D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );

     data->stop = true;

     data->src->WakeUp( data->src );

     direct_thread_join( data->thread );
     direct_thread_destroy( data->thread );

     data->src->Release( data->src );

     voodoo_manager_request( data->manager, data->instance,
                             IDIRECTFBEVENTBUFFER_METHOD_ID_Release, VREQ_NONE, NULL,
                             VMBT_NONE );

     DIRECT_DEALLOCATE_INTERFACE( thiz );
}
Exemple #22
0
VoodooDispatcher::~VoodooDispatcher()
{
     D_DEBUG_AT( Voodoo_Dispatcher, "VoodooDispatcher::%s( %p )\n", __func__, this );

     D_MAGIC_ASSERT( this, VoodooDispatcher );

     /* Acquire lock and wake up waiters. */
     direct_mutex_lock( &lock );
     direct_waitqueue_broadcast( &queue );
     direct_mutex_unlock( &lock );

     /* Wait for dispatcher loop exiting. */
     direct_thread_join( dispatch_loop );
     direct_thread_destroy( dispatch_loop );

     /* Destroy queue. */
     direct_waitqueue_deinit( &queue );

     /* Destroy lock. */
     direct_mutex_deinit( &lock );

     D_MAGIC_CLEAR( this );
}
Exemple #23
0
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
}
Exemple #24
0
DFBResult
dfb_vt_shutdown( bool emergency )
{
     const char cursoron_str[] = "\033[?0;0;0c";
     const char blankon_str[] = "\033[9;10]";

     D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ );

     if (!dfb_vt)
          return DFB_OK;

     if (dfb_config->vt_switching) {
          if (ioctl( dfb_vt->fd, VT_SETMODE, &dfb_vt->vt_mode ) < 0)
               D_PERROR( "DirectFB/fbdev/vt: Unable to restore VT mode!!!\n" );

          sigaction( SIG_SWITCH_FROM, &dfb_vt->sig_usr1, NULL );
          sigaction( SIG_SWITCH_TO, &dfb_vt->sig_usr2, NULL );

          direct_thread_cancel( dfb_vt->thread );
          direct_thread_join( dfb_vt->thread );
          direct_thread_destroy( dfb_vt->thread );

          pthread_mutex_destroy( &dfb_vt->lock );
          pthread_cond_destroy( &dfb_vt->wait );
     }

     if (dfb_config->kd_graphics) {
          if (ioctl( dfb_vt->fd, KDSETMODE, KD_TEXT ) < 0)
               D_PERROR( "DirectFB/Keyboard: KD_TEXT failed!\n" );
     }
     else {
          write( dfb_vt->fd, blankon_str, sizeof(blankon_str) );
     }
     write( dfb_vt->fd, cursoron_str, sizeof(cursoron_str) );

     if (dfb_config->vt_switch) {
          D_DEBUG_AT( VT, "  -> switching back...\n" );

          if (ioctl( dfb_vt->fd0, VT_ACTIVATE, dfb_vt->prev ) < 0)
               D_PERROR( "DirectFB/core/vt: VT_ACTIVATE" );

          if (ioctl( dfb_vt->fd0, VT_WAITACTIVE, dfb_vt->prev ) < 0)
               D_PERROR( "DirectFB/core/vt: VT_WAITACTIVE" );

          D_DEBUG_AT( VT, "  -> switched back...\n" );

          usleep( 40000 );

          /* restore con2fbmap */
          vt_set_fb( dfb_vt->num, dfb_vt->old_fb );

          if (close( dfb_vt->fd ) < 0)
               D_PERROR( "DirectFB/core/vt: Unable to "
                          "close file descriptor of allocated VT!\n" );

          if (ioctl( dfb_vt->fd0, VT_DISALLOCATE, dfb_vt->num ) < 0)
               D_PERROR( "DirectFB/core/vt: Unable to disallocate VT!\n" );
     }
     else {
          /* restore con2fbmap */
          vt_set_fb( dfb_vt->num, dfb_vt->old_fb );

          if (close( dfb_vt->fd ) < 0)
               D_PERROR( "DirectFB/core/vt: Unable to "
                          "close file descriptor of current VT!\n" );
     }

     if (close( dfb_vt->fd0 ) < 0)
          D_PERROR( "DirectFB/core/vt: Unable to "
                     "close file descriptor of tty0!\n" );

     D_FREE( dfb_vt );
     dfb_vt = dfb_fbdev->vt = NULL;

     return DFB_OK;
}